]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Merge 3.8-rc5 into staging-next
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Jan 2013 05:25:02 +0000 (21:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Jan 2013 05:25:02 +0000 (21:25 -0800)
This resolves a merge issue with a iio driver, and the zram code.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
419 files changed:
MAINTAINERS
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/adc/lp8788_adc.c
drivers/iio/adc/max1363.c
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
drivers/iio/common/hid-sensors/hid-sensor-attributes.h [deleted file]
drivers/iio/common/hid-sensors/hid-sensor-trigger.c
drivers/iio/common/hid-sensors/hid-sensor-trigger.h
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/magnetometer/hid-sensor-magn-3d.c
drivers/platform/Kconfig
drivers/platform/Makefile
drivers/platform/goldfish/Kconfig [new file with mode: 0644]
drivers/platform/goldfish/Makefile [new file with mode: 0644]
drivers/platform/goldfish/goldfish_pipe.c [new file with mode: 0644]
drivers/platform/goldfish/pdev_bus.c [new file with mode: 0644]
drivers/rtc/Kconfig
drivers/rtc/Makefile
drivers/rtc/rtc-hid-sensor-time.c [new file with mode: 0644]
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/Kconfig
drivers/staging/android/alarm-dev.c
drivers/staging/android/android_alarm.h
drivers/staging/android/binder.c
drivers/staging/android/binder.h
drivers/staging/bcm/Adapter.h
drivers/staging/bcm/Bcmchar.c
drivers/staging/bcm/CmHost.c
drivers/staging/bcm/CmHost.h
drivers/staging/bcm/Debug.h
drivers/staging/bcm/IPv6Protocol.c
drivers/staging/bcm/IPv6ProtocolHdr.h
drivers/staging/bcm/InterfaceDld.c
drivers/staging/bcm/Ioctl.h
drivers/staging/bcm/Macros.h
drivers/staging/bcm/Misc.c
drivers/staging/bcm/PHSDefines.h
drivers/staging/bcm/PHSModule.c
drivers/staging/bcm/PHSModule.h
drivers/staging/bcm/Protocol.h
drivers/staging/bcm/Prototypes.h
drivers/staging/bcm/Qos.c
drivers/staging/bcm/hostmibs.c
drivers/staging/bcm/led_control.c
drivers/staging/bcm/led_control.h
drivers/staging/bcm/nvm.c
drivers/staging/bcm/nvm.h
drivers/staging/bcm/target_params.h
drivers/staging/bcm/vendorspecificextn.c
drivers/staging/bcm/vendorspecificextn.h
drivers/staging/ced1401/ced_ioc.c
drivers/staging/ced1401/usb1401.c
drivers/staging/ced1401/usb1401.h
drivers/staging/comedi/Kconfig
drivers/staging/comedi/Makefile
drivers/staging/comedi/comedi.h
drivers/staging/comedi/comedi_buf.c [new file with mode: 0644]
drivers/staging/comedi/comedi_compat32.c
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedi_internal.h
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/8255_pci.c
drivers/staging/comedi/drivers/Makefile
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c [deleted file]
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
drivers/staging/comedi/drivers/addi_apci_035.c
drivers/staging/comedi/drivers/addi_apci_1032.c
drivers/staging/comedi/drivers/addi_apci_1500.c
drivers/staging/comedi/drivers/addi_apci_1516.c
drivers/staging/comedi/drivers/addi_apci_1564.c
drivers/staging/comedi/drivers/addi_apci_16xx.c
drivers/staging/comedi/drivers/addi_apci_1710.c
drivers/staging/comedi/drivers/addi_apci_2032.c
drivers/staging/comedi/drivers/addi_apci_2200.c
drivers/staging/comedi/drivers/addi_apci_3120.c
drivers/staging/comedi/drivers/addi_apci_3200.c
drivers/staging/comedi/drivers/addi_apci_3501.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c
drivers/staging/comedi/drivers/addi_watchdog.c [new file with mode: 0644]
drivers/staging/comedi/drivers/addi_watchdog.h [new file with mode: 0644]
drivers/staging/comedi/drivers/adl_pci6208.c
drivers/staging/comedi/drivers/adl_pci7x3x.c
drivers/staging/comedi/drivers/adl_pci8164.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/adv_pci1723.c
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/amplc_dio200.c
drivers/staging/comedi/drivers/amplc_pc236.c
drivers/staging/comedi/drivers/amplc_pc263.c
drivers/staging/comedi/drivers/amplc_pci224.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/comedi/drivers/cb_pcidas64.c
drivers/staging/comedi/drivers/cb_pcidda.c
drivers/staging/comedi/drivers/cb_pcimdas.c
drivers/staging/comedi/drivers/cb_pcimdda.c
drivers/staging/comedi/drivers/comedi_test.c
drivers/staging/comedi/drivers/contec_pci_dio.c
drivers/staging/comedi/drivers/daqboard2000.c
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das08_cs.c
drivers/staging/comedi/drivers/dt3000.c
drivers/staging/comedi/drivers/dt9812.c
drivers/staging/comedi/drivers/dyna_pci10xx.c
drivers/staging/comedi/drivers/gsc_hpdi.c
drivers/staging/comedi/drivers/icp_multi.c
drivers/staging/comedi/drivers/jr3_pci.c
drivers/staging/comedi/drivers/ke_counter.c
drivers/staging/comedi/drivers/me4000.c
drivers/staging/comedi/drivers/me_daq.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_670x.c
drivers/staging/comedi/drivers/ni_daq_700.c
drivers/staging/comedi/drivers/ni_daq_dio24.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc_cs.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_mio_cs.c
drivers/staging/comedi/drivers/ni_pcidio.c
drivers/staging/comedi/drivers/ni_pcimio.c
drivers/staging/comedi/drivers/ni_tio.c
drivers/staging/comedi/drivers/ni_tiocmd.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcm_common.c [deleted file]
drivers/staging/comedi/drivers/pcm_common.h [deleted file]
drivers/staging/comedi/drivers/pcmda12.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/skel.c
drivers/staging/comedi/kcomedilib/kcomedilib_main.c
drivers/staging/comedi/proc.c
drivers/staging/csr/sme_sys.c
drivers/staging/csr/unifi_sme.c
drivers/staging/cxt1e1/linux.c
drivers/staging/dgrp/dgrp_specproc.c
drivers/staging/echo/echo.c
drivers/staging/et131x/et131x.c
drivers/staging/et131x/et131x.h
drivers/staging/ft1000/ft1000-pcmcia/ft1000.h
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
drivers/staging/ft1000/ft1000-usb/ft1000_download.c
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
drivers/staging/ft1000/ft1000.h
drivers/staging/goldfish/Kconfig [new file with mode: 0644]
drivers/staging/goldfish/Makefile [new file with mode: 0644]
drivers/staging/goldfish/README [new file with mode: 0644]
drivers/staging/goldfish/goldfish_audio.c [new file with mode: 0644]
drivers/staging/goldfish/goldfish_nand.c [new file with mode: 0644]
drivers/staging/goldfish/goldfish_nand_reg.h [new file with mode: 0644]
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/iio/iio_simple_dummy.c
drivers/staging/iio/iio_simple_dummy_buffer.c
drivers/staging/imx-drm/ipu-v3/ipu-common.c
drivers/staging/imx-drm/ipu-v3/ipu-di.c
drivers/staging/keucr/usb.c
drivers/staging/line6/Kconfig
drivers/staging/line6/capture.c
drivers/staging/line6/driver.c
drivers/staging/line6/driver.h
drivers/staging/line6/midi.c
drivers/staging/line6/midi.h
drivers/staging/line6/midibuf.c
drivers/staging/line6/midibuf.h
drivers/staging/line6/pcm.c
drivers/staging/line6/playback.c
drivers/staging/line6/pod.c
drivers/staging/line6/toneport.c
drivers/staging/line6/variax.c
drivers/staging/omap-thermal/omap-bandgap.c
drivers/staging/omap-thermal/omap-thermal-common.c
drivers/staging/omapdrm/omap_dmm_priv.h
drivers/staging/omapdrm/omap_dmm_tiler.c
drivers/staging/omapdrm/omap_drv.c
drivers/staging/omapdrm/omap_drv.h
drivers/staging/omapdrm/omap_gem.c
drivers/staging/omapdrm/omap_gem_dmabuf.c
drivers/staging/omapdrm/tcm.h
drivers/staging/ozwpan/TODO
drivers/staging/ramster/Kconfig [deleted file]
drivers/staging/ramster/Makefile [deleted file]
drivers/staging/ramster/tmem.c [deleted file]
drivers/staging/ramster/tmem.h [deleted file]
drivers/staging/ramster/zcache-main.c [deleted file]
drivers/staging/rtl8187se/ieee80211/dot11d.c
drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192u/changes
drivers/staging/rtl8192u/ieee80211/Makefile
drivers/staging/rtl8192u/ieee80211/aes.c
drivers/staging/rtl8192u/ieee80211/arc4.c
drivers/staging/rtl8192u/ieee80211/crypto_compat.h
drivers/staging/rtl8192u/ieee80211/dot11d.c
drivers/staging/rtl8192u/ieee80211/ieee80211.h
drivers/staging/rtl8192u/ieee80211/ieee80211_module.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/internal.h
drivers/staging/rtl8192u/ieee80211/rtl819x_BA.h
drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
drivers/staging/rtl8192u/ieee80211/rtl819x_HT.h
drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192u/ieee80211/rtl_crypto.h
drivers/staging/rtl8192u/r8180_93cx6.c
drivers/staging/rtl8192u/r8180_pm.h
drivers/staging/rtl8192u/r8190_rtl8256.c
drivers/staging/rtl8192u/r8192U.h
drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/rtl8192u/r8192U_dm.c
drivers/staging/rtl8192u/r8192U_dm.h
drivers/staging/rtl8192u/r8192U_hw.h
drivers/staging/rtl8192u/r8192U_wx.c
drivers/staging/rtl8192u/r819xU_HTGen.h
drivers/staging/rtl8192u/r819xU_HTType.h
drivers/staging/rtl8192u/r819xU_cmdpkt.c
drivers/staging/rtl8192u/r819xU_cmdpkt.h
drivers/staging/rtl8192u/r819xU_firmware.c
drivers/staging/rtl8192u/r819xU_firmware.h
drivers/staging/rtl8192u/r819xU_phy.c
drivers/staging/rtl8192u/r819xU_phyreg.h
drivers/staging/rtl8712/ethernet.h
drivers/staging/rtl8712/hal_init.c
drivers/staging/rtl8712/ieee80211.h
drivers/staging/rtl8712/mlme_linux.c
drivers/staging/rtl8712/os_intfs.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl871x_cmd.c
drivers/staging/rtl8712/rtl871x_cmd.h
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
drivers/staging/rtl8712/rtl871x_ioctl_set.c
drivers/staging/rtl8712/rtl871x_mlme.c
drivers/staging/rtl8712/rtl871x_mp.h
drivers/staging/rtl8712/rtl871x_mp_ioctl.c
drivers/staging/rtl8712/rtl871x_security.h
drivers/staging/rtl8712/sta_info.h
drivers/staging/rtl8712/usb_intf.c
drivers/staging/rtl8712/usb_ops_linux.c
drivers/staging/rtl8712/wifi.h
drivers/staging/rtl8712/xmit_linux.c
drivers/staging/sb105x/sb_mp_register.h
drivers/staging/sb105x/sb_pci_mp.c
drivers/staging/sep/sep_crypto.c
drivers/staging/slicoss/slic.h
drivers/staging/slicoss/slichw.h
drivers/staging/slicoss/slicoss.c
drivers/staging/speakup/Kconfig
drivers/staging/speakup/buffers.c
drivers/staging/speakup/fakekey.c
drivers/staging/speakup/i18n.c
drivers/staging/speakup/i18n.h
drivers/staging/speakup/keyhelp.c
drivers/staging/speakup/kobjects.c
drivers/staging/speakup/main.c
drivers/staging/speakup/selection.c
drivers/staging/speakup/serialio.c
drivers/staging/speakup/speakup.h
drivers/staging/speakup/speakup_acntpc.c
drivers/staging/speakup/speakup_acntsa.c
drivers/staging/speakup/speakup_apollo.c
drivers/staging/speakup/speakup_audptr.c
drivers/staging/speakup/speakup_bns.c
drivers/staging/speakup/speakup_decext.c
drivers/staging/speakup/speakup_decpc.c
drivers/staging/speakup/speakup_dectlk.c
drivers/staging/speakup/speakup_dtlk.c
drivers/staging/speakup/speakup_dummy.c
drivers/staging/speakup/speakup_keypc.c
drivers/staging/speakup/speakup_ltlk.c
drivers/staging/speakup/speakup_spkout.c
drivers/staging/speakup/speakup_txprt.c
drivers/staging/speakup/spk_priv.h
drivers/staging/speakup/synth.c
drivers/staging/speakup/thread.c
drivers/staging/speakup/varhandlers.c
drivers/staging/tidspbridge/core/tiomap3430.c
drivers/staging/tidspbridge/include/dspbridge/proc.h
drivers/staging/tidspbridge/pmgr/cod.c
drivers/staging/tidspbridge/pmgr/dbll.c
drivers/staging/tidspbridge/pmgr/dspapi.c
drivers/staging/tidspbridge/rmgr/dbdcd.c
drivers/staging/tidspbridge/rmgr/drv_interface.c
drivers/staging/tidspbridge/rmgr/nldr.c
drivers/staging/tidspbridge/rmgr/node.c
drivers/staging/tidspbridge/rmgr/proc.c
drivers/staging/usbip/Kconfig
drivers/staging/usbip/stub_dev.c
drivers/staging/usbip/stub_rx.c
drivers/staging/usbip/usbip_common.c
drivers/staging/usbip/usbip_event.c
drivers/staging/usbip/userspace/.gitignore [new file with mode: 0644]
drivers/staging/usbip/userspace/Makefile.am
drivers/staging/usbip/userspace/README
drivers/staging/usbip/userspace/configure.ac
drivers/staging/usbip/userspace/src/Makefile.am
drivers/staging/usbip/userspace/src/usbip_attach.c
drivers/staging/usbip/userspace/src/usbipd.c
drivers/staging/usbip/vhci_hcd.c
drivers/staging/usbip/vhci_rx.c
drivers/staging/usbip/vhci_tx.c
drivers/staging/vme/devices/Kconfig
drivers/staging/vt6655/channel.c
drivers/staging/vt6655/device.h
drivers/staging/vt6655/rxtx.c
drivers/staging/vt6655/wcmd.c
drivers/staging/vt6655/wmgr.c
drivers/staging/vt6656/80211mgr.c
drivers/staging/vt6656/80211mgr.h
drivers/staging/vt6656/baseband.c
drivers/staging/vt6656/baseband.h
drivers/staging/vt6656/bssdb.c
drivers/staging/vt6656/bssdb.h
drivers/staging/vt6656/card.c
drivers/staging/vt6656/card.h
drivers/staging/vt6656/channel.c
drivers/staging/vt6656/channel.h
drivers/staging/vt6656/control.c
drivers/staging/vt6656/control.h
drivers/staging/vt6656/datarate.c
drivers/staging/vt6656/datarate.h
drivers/staging/vt6656/device.h
drivers/staging/vt6656/dpc.c
drivers/staging/vt6656/dpc.h
drivers/staging/vt6656/firmware.c
drivers/staging/vt6656/firmware.h
drivers/staging/vt6656/hostap.c
drivers/staging/vt6656/hostap.h
drivers/staging/vt6656/int.c
drivers/staging/vt6656/int.h
drivers/staging/vt6656/iwctl.c
drivers/staging/vt6656/key.c
drivers/staging/vt6656/key.h
drivers/staging/vt6656/mac.c
drivers/staging/vt6656/mac.h
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/power.c
drivers/staging/vt6656/power.h
drivers/staging/vt6656/rf.c
drivers/staging/vt6656/rf.h
drivers/staging/vt6656/rxtx.c
drivers/staging/vt6656/rxtx.h
drivers/staging/vt6656/ttype.h
drivers/staging/vt6656/usbpipe.c
drivers/staging/vt6656/usbpipe.h
drivers/staging/vt6656/wcmd.c
drivers/staging/vt6656/wcmd.h
drivers/staging/vt6656/wctl.c
drivers/staging/vt6656/wctl.h
drivers/staging/vt6656/wmgr.c
drivers/staging/vt6656/wmgr.h
drivers/staging/vt6656/wpa2.c
drivers/staging/vt6656/wpactl.c
drivers/staging/vt6656/wpactl.h
drivers/staging/winbond/Kconfig
drivers/staging/wlags49_h2/ap_h2.c
drivers/staging/wlags49_h2/ap_h25.c
drivers/staging/wlags49_h2/sta_h2.c
drivers/staging/wlags49_h2/wl_enc.c
drivers/staging/wlags49_h2/wl_netdev.h
drivers/staging/wlags49_h2/wl_priv.c
drivers/staging/wlags49_h2/wl_priv.h
drivers/staging/wlags49_h2/wl_profile.h
drivers/staging/wlags49_h2/wl_util.h
drivers/staging/wlags49_h2/wl_wext.c
drivers/staging/wlan-ng/prism2mgmt.c
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/vb_init.c
drivers/staging/xgifb/vb_init.h
drivers/staging/xgifb/vb_setmode.c
drivers/staging/xgifb/vb_struct.h
drivers/staging/zcache/Kconfig
drivers/staging/zcache/Makefile
drivers/staging/zcache/ramster.h [moved from drivers/staging/ramster/ramster.h with 100% similarity]
drivers/staging/zcache/ramster/heartbeat.c [moved from drivers/staging/ramster/ramster/heartbeat.c with 100% similarity]
drivers/staging/zcache/ramster/heartbeat.h [moved from drivers/staging/ramster/ramster/heartbeat.h with 100% similarity]
drivers/staging/zcache/ramster/masklog.c [moved from drivers/staging/ramster/ramster/masklog.c with 100% similarity]
drivers/staging/zcache/ramster/masklog.h [moved from drivers/staging/ramster/ramster/masklog.h with 100% similarity]
drivers/staging/zcache/ramster/nodemanager.c [moved from drivers/staging/ramster/ramster/nodemanager.c with 100% similarity]
drivers/staging/zcache/ramster/nodemanager.h [moved from drivers/staging/ramster/ramster/nodemanager.h with 100% similarity]
drivers/staging/zcache/ramster/r2net.c [moved from drivers/staging/ramster/ramster/r2net.c with 100% similarity]
drivers/staging/zcache/ramster/ramster.c [moved from drivers/staging/ramster/ramster/ramster.c with 100% similarity]
drivers/staging/zcache/ramster/ramster.h [moved from drivers/staging/ramster/ramster/ramster.h with 100% similarity]
drivers/staging/zcache/ramster/ramster_nodemanager.h [moved from drivers/staging/ramster/ramster/ramster_nodemanager.h with 100% similarity]
drivers/staging/zcache/ramster/tcp.c [moved from drivers/staging/ramster/ramster/tcp.c with 100% similarity]
drivers/staging/zcache/ramster/tcp.h [moved from drivers/staging/ramster/ramster/tcp.h with 100% similarity]
drivers/staging/zcache/ramster/tcp_internal.h [moved from drivers/staging/ramster/ramster/tcp_internal.h with 100% similarity]
drivers/staging/zcache/tmem.c
drivers/staging/zcache/tmem.h
drivers/staging/zcache/zbud.c [moved from drivers/staging/ramster/zbud.c with 99% similarity]
drivers/staging/zcache/zbud.h [moved from drivers/staging/ramster/zbud.h with 100% similarity]
drivers/staging/zcache/zcache-main.c
drivers/staging/zcache/zcache.h [moved from drivers/staging/ramster/zcache.h with 100% similarity]
drivers/staging/zram/Kconfig
drivers/staging/zram/zram_drv.c
drivers/staging/zsmalloc/zsmalloc-main.c
include/linux/hid-sensor-hub.h
include/linux/hid-sensor-ids.h

index 8ae709e34523c4eb25c7cde1e4e4a9afb7e9704d..1f91703cb86c6ca409d037bd799410401336df1b 100644 (file)
@@ -7303,8 +7303,7 @@ S:        Odd Fixes
 F:     drivers/staging/olpc_dcon/
 
 STAGING - OZMO DEVICES USB OVER WIFI DRIVER
-M:     Rupesh Gujare <rgujare@ozmodevices.com>
-M:     Chris Kelly <ckelly@ozmodevices.com>
+M:     Rupesh Gujare <rupesh.gujare@atmel.com>
 S:     Maintained
 F:     drivers/staging/ozwpan/
 
index 0b0c3c66f6c07f8778c96ec76b513db80a16cf7a..dd8ea428493450cfce48dfb3161202d85b5d9177 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include "../common/hid-sensors/hid-sensor-attributes.h"
 #include "../common/hid-sensors/hid-sensor-trigger.h"
 
 /*Format: HID-SENSOR-usage_id_in_hex*/
@@ -44,7 +43,7 @@ enum accel_3d_channel {
 
 struct accel_3d_state {
        struct hid_sensor_hub_callbacks callbacks;
-       struct hid_sensor_iio_common common_attributes;
+       struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info accel[ACCEL_3D_CHANNEL_MAX];
        u32 accel_val[ACCEL_3D_CHANNEL_MAX];
 };
index 72955e45e9e043bf96bd4d177abefe4d8b1e5e95..f8bcb1f5892df23e2c3c4e25289eaa1fc96752ba 100644 (file)
@@ -179,7 +179,7 @@ static int lp8788_iio_map_register(struct iio_dev *indio_dev,
 
        ret = iio_map_array_register(indio_dev, map);
        if (ret) {
-               dev_err(adc->lp->dev, "iio map err: %d\n", ret);
+               dev_err(&indio_dev->dev, "iio map err: %d\n", ret);
                return ret;
        }
 
@@ -214,7 +214,7 @@ static int lp8788_adc_probe(struct platform_device *pdev)
 
        mutex_init(&adc->lock);
 
-       indio_dev->dev.parent = lp->dev;
+       indio_dev->dev.parent = &pdev->dev;
        indio_dev->name = pdev->name;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &lp8788_adc_info;
@@ -223,7 +223,7 @@ static int lp8788_adc_probe(struct platform_device *pdev)
 
        ret = iio_device_register(indio_dev);
        if (ret) {
-               dev_err(lp->dev, "iio dev register err: %d\n", ret);
+               dev_err(&pdev->dev, "iio dev register err: %d\n", ret);
                goto err_iio_device;
        }
 
index 03b25b3dc71eb95703d2131230e2f11cb2dae03c..eba1034d860640760ac8b06e02f764fcff572e49 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/iio/driver.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
 
 #define MAX1363_SETUP_BYTE(a) ((a) | 0x80)
 
@@ -55,7 +56,7 @@
 #define MAX1363_SETUP_POWER_UP_INT_REF         0x10
 #define MAX1363_SETUP_POWER_DOWN_INT_REF       0x00
 
-/* think about includeing max11600 etc - more settings */
+/* think about including max11600 etc - more settings */
 #define MAX1363_SETUP_EXT_CLOCK                        0x08
 #define MAX1363_SETUP_INT_CLOCK                        0x00
 #define MAX1363_SETUP_UNIPOLAR                 0x00
@@ -86,7 +87,7 @@
 /* max123{6-9} only */
 #define MAX1236_SCAN_MID_TO_CHANNEL            0x40
 
-/* max1363 only - merely part of channel selects or don't care for others*/
+/* max1363 only - merely part of channel selects or don't care for others */
 #define MAX1363_CONFIG_EN_MON_MODE_READ 0x18
 
 #define MAX1363_CHANNEL_SEL(a) ((a) << 1)
@@ -133,7 +134,7 @@ enum max1363_modes {
  * @mode_list:         array of available scan modes
  * @default_mode:      the scan mode in which the chip starts up
  * @int_vref_mv:       the internal reference voltage
- * @num_channels:      number of channels
+ * @num_modes:         number of modes
  * @bits:              accuracy of the adc in bits
  */
 struct max1363_chip_info {
@@ -152,7 +153,7 @@ struct max1363_chip_info {
  * @client:            i2c_client
  * @setupbyte:         cache of current device setup byte
  * @configbyte:                cache of current device config byte
- * @chip_info:         chip model specific constants, available modes etc
+ * @chip_info:         chip model specific constants, available modes, etc.
  * @current_mode:      the scan mode of this chip
  * @requestedmask:     a valid requested set of channels
  * @reg:               supply regulator
@@ -293,7 +294,7 @@ static const struct max1363_mode max1363_mode_table[] = {
 
 static const struct max1363_mode
 *max1363_match_mode(const unsigned long *mask,
-const struct max1363_chip_info *ci)
+       const struct max1363_chip_info *ci)
 {
        int i;
        if (mask)
@@ -1394,7 +1395,7 @@ static int max1363_initial_setup(struct max1363_state *st)
                | MAX1363_SETUP_UNIPOLAR
                | MAX1363_SETUP_NORESET;
 
-       /* Set scan mode writes the config anyway so wait until then*/
+       /* Set scan mode writes the config anyway so wait until then */
        st->setupbyte = MAX1363_SETUP_BYTE(st->setupbyte);
        st->current_mode = &max1363_mode_table[st->chip_info->default_mode];
        st->configbyte = MAX1363_CONFIG_BYTE(st->configbyte);
@@ -1423,7 +1424,6 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
        return 0;
 }
 
-
 static irqreturn_t max1363_trigger_handler(int irq, void *p)
 {
        struct iio_poll_func *pf = p;
@@ -1564,7 +1564,7 @@ static int max1363_probe(struct i2c_client *client,
        if (ret)
                goto error_disable_reg;
 
-       /* Estabilish that the iio_dev is a child of the i2c device */
+       /* Establish that the iio_dev is a child of the i2c device */
        indio_dev->dev.parent = &client->dev;
        indio_dev->name = id->name;
        indio_dev->channels = st->chip_info->channels;
@@ -1577,16 +1577,11 @@ static int max1363_probe(struct i2c_client *client,
        if (ret < 0)
                goto error_free_available_scan_masks;
 
-       ret = max1363_register_buffered_funcs_and_init(indio_dev);
+       ret = iio_triggered_buffer_setup(indio_dev, NULL,
+               &max1363_trigger_handler, &max1363_buffered_setup_ops);
        if (ret)
                goto error_free_available_scan_masks;
 
-       ret = iio_buffer_register(indio_dev,
-                                 st->chip_info->channels,
-                                 st->chip_info->num_channels);
-       if (ret)
-               goto error_cleanup_buffer;
-
        if (client->irq) {
                ret = request_threaded_irq(st->client->irq,
                                           NULL,
@@ -1608,9 +1603,7 @@ error_free_irq:
        if (client->irq)
                free_irq(st->client->irq, indio_dev);
 error_uninit_buffer:
-       iio_buffer_unregister(indio_dev);
-error_cleanup_buffer:
-       max1363_buffer_cleanup(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
 error_free_available_scan_masks:
        kfree(indio_dev->available_scan_masks);
 error_disable_reg:
@@ -1633,8 +1626,7 @@ static int max1363_remove(struct i2c_client *client)
        iio_device_unregister(indio_dev);
        if (client->irq)
                free_irq(st->client->irq, indio_dev);
-       iio_buffer_unregister(indio_dev);
-       max1363_buffer_cleanup(indio_dev);
+       iio_triggered_buffer_cleanup(indio_dev);
        kfree(indio_dev->available_scan_masks);
        regulator_disable(st->reg);
        regulator_put(st->reg);
index 75374955cabae0a1d2bf873b8f69692107f781ed..75b54730a963ab9c950ff465cd935047fc06306b 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/hid-sensor-hub.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
-#include "hid-sensor-attributes.h"
 
 static int pow_10(unsigned power)
 {
@@ -114,7 +113,7 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2)
        return value;
 }
 
-int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
+int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
                                int *val1, int *val2)
 {
        s32 value;
@@ -141,7 +140,7 @@ int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
 }
 EXPORT_SYMBOL(hid_sensor_read_samp_freq_value);
 
-int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
+int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
                                int val1, int val2)
 {
        s32 value;
@@ -169,7 +168,7 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
 }
 EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);
 
-int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
+int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
                                int *val1, int *val2)
 {
        s32 value;
@@ -191,7 +190,7 @@ int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
 }
 EXPORT_SYMBOL(hid_sensor_read_raw_hyst_value);
 
-int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
+int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
                                        int val1, int val2)
 {
        s32 value;
@@ -212,7 +211,7 @@ EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
 
 int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
                                        u32 usage_id,
-                                       struct hid_sensor_iio_common *st)
+                                       struct hid_sensor_common *st)
 {
 
        sensor_hub_input_get_attribute_info(hsdev,
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.h b/drivers/iio/common/hid-sensors/hid-sensor-attributes.h
deleted file mode 100644 (file)
index a4676a0..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * HID Sensors Driver
- * Copyright (c) 2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * 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 St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-#ifndef _HID_SENSORS_ATTRIBUTES_H
-#define _HID_SENSORS_ATTRIBUTES_H
-
-/* Common hid sensor iio structure */
-struct hid_sensor_iio_common {
-       struct hid_sensor_hub_device *hsdev;
-       struct platform_device *pdev;
-       unsigned usage_id;
-       bool data_ready;
-       struct hid_sensor_hub_attribute_info poll;
-       struct hid_sensor_hub_attribute_info report_state;
-       struct hid_sensor_hub_attribute_info power_state;
-       struct hid_sensor_hub_attribute_info sensitivity;
-};
-
-/*Convert from hid unit expo to regular exponent*/
-static inline int hid_sensor_convert_exponent(int unit_expo)
-{
-       if (unit_expo < 0x08)
-               return unit_expo;
-       else if (unit_expo <= 0x0f)
-               return -(0x0f-unit_expo+1);
-       else
-               return 0;
-}
-
-int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
-                                       u32 usage_id,
-                                       struct hid_sensor_iio_common *st);
-int hid_sensor_write_raw_hyst_value(struct hid_sensor_iio_common *st,
-                                       int val1, int val2);
-int hid_sensor_read_raw_hyst_value(struct hid_sensor_iio_common *st,
-                                       int *val1, int *val2);
-int hid_sensor_write_samp_freq_value(struct hid_sensor_iio_common *st,
-                                       int val1, int val2);
-int hid_sensor_read_samp_freq_value(struct hid_sensor_iio_common *st,
-                                       int *val1, int *val2);
-
-#endif
index d60198a6ca29a0ee6fa187fb6dbdbb2016df5ca3..7a525a91105d38a7570c1caddf85e41bdaf9553d 100644 (file)
 #include <linux/iio/iio.h>
 #include <linux/iio/trigger.h>
 #include <linux/iio/sysfs.h>
-#include "hid-sensor-attributes.h"
 #include "hid-sensor-trigger.h"
 
 static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
                                                bool state)
 {
-       struct hid_sensor_iio_common *st = trig->private_data;
+       struct hid_sensor_common *st = trig->private_data;
        int state_val;
 
        state_val = state ? 1 : 0;
@@ -64,7 +63,7 @@ static const struct iio_trigger_ops hid_sensor_trigger_ops = {
 };
 
 int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
-                               struct hid_sensor_iio_common *attrb)
+                               struct hid_sensor_common *attrb)
 {
        int ret;
        struct iio_trigger *trig;
index fd982971b1b868ad9cb13132f43eba307637ad5c..9a8731478eda4cdb95867e5dffdd10d1ec9bcbae 100644 (file)
@@ -20,7 +20,7 @@
 #define _HID_SENSOR_TRIGGER_H
 
 int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
-                               struct hid_sensor_iio_common *attrb);
+                               struct hid_sensor_common *attrb);
 void hid_sensor_remove_trigger(struct iio_dev *indio_dev);
 
 #endif
index 06e7cc35450c633a9e08e55450907f6e00241518..fcfc83a9f86119a91899769632477f7005052c43 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include "../common/hid-sensors/hid-sensor-attributes.h"
 #include "../common/hid-sensors/hid-sensor-trigger.h"
 
 /*Format: HID-SENSOR-usage_id_in_hex*/
@@ -44,7 +43,7 @@ enum gyro_3d_channel {
 
 struct gyro_3d_state {
        struct hid_sensor_hub_callbacks callbacks;
-       struct hid_sensor_iio_common common_attributes;
+       struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info gyro[GYRO_3D_CHANNEL_MAX];
        u32 gyro_val[GYRO_3D_CHANNEL_MAX];
 };
index e2d042f2a544b0b55bcdbee9bf84e6ed5430a252..3d7e8c9b4beb15eb9cce8f3790ea136701a77c79 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include "../common/hid-sensors/hid-sensor-attributes.h"
 #include "../common/hid-sensors/hid-sensor-trigger.h"
 
 /*Format: HID-SENSOR-usage_id_in_hex*/
@@ -39,7 +38,7 @@
 
 struct als_state {
        struct hid_sensor_hub_callbacks callbacks;
-       struct hid_sensor_iio_common common_attributes;
+       struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info als_illum;
        u32 illum;
 };
index 7ac2c7483ba8ae51f95243311929cc028110aea2..d8d01265220bfe5048be6adc3610524857a8b5df 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
-#include "../common/hid-sensors/hid-sensor-attributes.h"
 #include "../common/hid-sensors/hid-sensor-trigger.h"
 
 /*Format: HID-SENSOR-usage_id_in_hex*/
@@ -44,7 +43,7 @@ enum magn_3d_channel {
 
 struct magn_3d_state {
        struct hid_sensor_hub_callbacks callbacks;
-       struct hid_sensor_iio_common common_attributes;
+       struct hid_sensor_common common_attributes;
        struct hid_sensor_hub_attribute_info magn[MAGN_3D_CHANNEL_MAX];
        u32 magn_val[MAGN_3D_CHANNEL_MAX];
 };
index 8390dca2b4e1b53fd67b90359fd2d70bcbafec6e..69616aeaa966218efa16eb3858324107e816e7bf 100644 (file)
@@ -1,3 +1,7 @@
 if X86
 source "drivers/platform/x86/Kconfig"
 endif
+if GOLDFISH
+source "drivers/platform/goldfish/Kconfig"
+endif
+
index b17c16ce54adabc1160474b9aaf3fc2342804308..8a44a4cd6d1efc30789d5da4cc392447695d68ae 100644 (file)
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_X86)              += x86/
 obj-$(CONFIG_OLPC)             += olpc/
+obj-$(CONFIG_GOLDFISH)         += goldfish/
diff --git a/drivers/platform/goldfish/Kconfig b/drivers/platform/goldfish/Kconfig
new file mode 100644 (file)
index 0000000..635ef25
--- /dev/null
@@ -0,0 +1,5 @@
+config GOLDFISH_PIPE
+       tristate "Goldfish virtual device for QEMU pipes"
+       ---help---
+         This is a virtual device to drive the QEMU pipe interface used by
+         the Goldfish Android Virtual Device.
diff --git a/drivers/platform/goldfish/Makefile b/drivers/platform/goldfish/Makefile
new file mode 100644 (file)
index 0000000..a002239
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Makefile for Goldfish platform specific drivers
+#
+obj-$(CONFIG_GOLDFISH) +=      pdev_bus.o
+obj-$(CONFIG_GOLDFISH_PIPE)    += goldfish_pipe.o
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
new file mode 100644 (file)
index 0000000..4f5aa83
--- /dev/null
@@ -0,0 +1,612 @@
+/*
+ * Copyright (C) 2011 Google, Inc.
+ * Copyright (C) 2012 Intel, Inc.
+ * Copyright (C) 2013 Intel, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+/* This source file contains the implementation of a special device driver
+ * that intends to provide a *very* fast communication channel between the
+ * guest system and the QEMU emulator.
+ *
+ * Usage from the guest is simply the following (error handling simplified):
+ *
+ *    int  fd = open("/dev/qemu_pipe",O_RDWR);
+ *    .... write() or read() through the pipe.
+ *
+ * This driver doesn't deal with the exact protocol used during the session.
+ * It is intended to be as simple as something like:
+ *
+ *    // do this _just_ after opening the fd to connect to a specific
+ *    // emulator service.
+ *    const char*  msg = "<pipename>";
+ *    if (write(fd, msg, strlen(msg)+1) < 0) {
+ *       ... could not connect to <pipename> service
+ *       close(fd);
+ *    }
+ *
+ *    // after this, simply read() and write() to communicate with the
+ *    // service. Exact protocol details left as an exercise to the reader.
+ *
+ * This driver is very fast because it doesn't copy any data through
+ * intermediate buffers, since the emulator is capable of translating
+ * guest user addresses into host ones.
+ *
+ * Note that we must however ensure that each user page involved in the
+ * exchange is properly mapped during a transfer.
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/miscdevice.h>
+#include <linux/platform_device.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/bitops.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+
+/*
+ * IMPORTANT: The following constants must match the ones used and defined
+ * in external/qemu/hw/goldfish_pipe.c in the Android source tree.
+ */
+
+/* pipe device registers */
+#define PIPE_REG_COMMAND               0x00  /* write: value = command */
+#define PIPE_REG_STATUS                        0x04  /* read */
+#define PIPE_REG_CHANNEL               0x08  /* read/write: channel id */
+#define PIPE_REG_SIZE                  0x0c  /* read/write: buffer size */
+#define PIPE_REG_ADDRESS               0x10  /* write: physical address */
+#define PIPE_REG_WAKES                 0x14  /* read: wake flags */
+#define PIPE_REG_PARAMS_ADDR_LOW       0x18  /* read/write: batch data address */
+#define PIPE_REG_PARAMS_ADDR_HIGH      0x1c  /* read/write: batch data address */
+#define PIPE_REG_ACCESS_PARAMS         0x20  /* write: batch access */
+
+/* list of commands for PIPE_REG_COMMAND */
+#define CMD_OPEN                       1  /* open new channel */
+#define CMD_CLOSE                      2  /* close channel (from guest) */
+#define CMD_POLL                       3  /* poll read/write status */
+
+/* List of bitflags returned in status of CMD_POLL command */
+#define PIPE_POLL_IN                   (1 << 0)
+#define PIPE_POLL_OUT                  (1 << 1)
+#define PIPE_POLL_HUP                  (1 << 2)
+
+/* The following commands are related to write operations */
+#define CMD_WRITE_BUFFER       4  /* send a user buffer to the emulator */
+#define CMD_WAKE_ON_WRITE      5  /* tell the emulator to wake us when writing
+                                    is possible */
+
+/* The following commands are related to read operations, they must be
+ * listed in the same order than the corresponding write ones, since we
+ * will use (CMD_READ_BUFFER - CMD_WRITE_BUFFER) as a special offset
+ * in goldfish_pipe_read_write() below.
+ */
+#define CMD_READ_BUFFER        6  /* receive a user buffer from the emulator */
+#define CMD_WAKE_ON_READ       7  /* tell the emulator to wake us when reading
+                                  * is possible */
+
+/* Possible status values used to signal errors - see goldfish_pipe_error_convert */
+#define PIPE_ERROR_INVAL       -1
+#define PIPE_ERROR_AGAIN       -2
+#define PIPE_ERROR_NOMEM       -3
+#define PIPE_ERROR_IO          -4
+
+/* Bit-flags used to signal events from the emulator */
+#define PIPE_WAKE_CLOSED       (1 << 0)  /* emulator closed pipe */
+#define PIPE_WAKE_READ         (1 << 1)  /* pipe can now be read from */
+#define PIPE_WAKE_WRITE        (1 << 2)  /* pipe can now be written to */
+
+struct access_params {
+       u32 channel;
+       u32 size;
+       u32 address;
+       u32 cmd;
+       u32 result;
+       /* reserved for future extension */
+       u32 flags;
+};
+
+/* The global driver data. Holds a reference to the i/o page used to
+ * communicate with the emulator, and a wake queue for blocked tasks
+ * waiting to be awoken.
+ */
+struct goldfish_pipe_dev {
+       spinlock_t lock;
+       unsigned char __iomem *base;
+       struct access_params *aps;
+       int irq;
+};
+
+static struct goldfish_pipe_dev   pipe_dev[1];
+
+/* This data type models a given pipe instance */
+struct goldfish_pipe {
+       struct goldfish_pipe_dev *dev;
+       struct mutex lock;
+       unsigned long flags;
+       wait_queue_head_t wake_queue;
+};
+
+
+/* Bit flags for the 'flags' field */
+enum {
+       BIT_CLOSED_ON_HOST = 0,  /* pipe closed by host */
+       BIT_WAKE_ON_WRITE  = 1,  /* want to be woken on writes */
+       BIT_WAKE_ON_READ   = 2,  /* want to be woken on reads */
+};
+
+
+static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd)
+{ 
+       unsigned long flags;
+       u32 status;
+       struct goldfish_pipe_dev *dev = pipe->dev;
+
+       spin_lock_irqsave(&dev->lock, flags);
+       writel((u32)pipe, dev->base + PIPE_REG_CHANNEL);
+       writel(cmd, dev->base + PIPE_REG_COMMAND);
+       status = readl(dev->base + PIPE_REG_STATUS);
+       spin_unlock_irqrestore(&dev->lock, flags);
+       return status;
+}
+
+static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd)
+{ 
+       unsigned long flags;
+       struct goldfish_pipe_dev *dev = pipe->dev;
+
+       spin_lock_irqsave(&dev->lock, flags);
+       writel((u32)pipe, dev->base + PIPE_REG_CHANNEL);
+       writel(cmd, dev->base + PIPE_REG_COMMAND);
+       spin_unlock_irqrestore(&dev->lock, flags);
+}
+
+/* This function converts an error code returned by the emulator through
+ * the PIPE_REG_STATUS i/o register into a valid negative errno value.
+ */
+static int goldfish_pipe_error_convert(int status)
+{
+       switch (status) {
+       case PIPE_ERROR_AGAIN:
+               return -EAGAIN;
+       case PIPE_ERROR_NOMEM:
+               return -ENOMEM;
+       case PIPE_ERROR_IO:
+               return -EIO;
+       default:
+               return -EINVAL;
+       }
+}
+
+/*
+ * Notice: QEMU will return 0 for un-known register access, indicating
+ * param_acess is supported or not
+ */
+static int valid_batchbuffer_addr(struct goldfish_pipe_dev *dev,
+                                 struct access_params *aps)
+{
+       u32 aph, apl;
+       u64 paddr;
+       aph = readl(dev->base + PIPE_REG_PARAMS_ADDR_HIGH);
+       apl = readl(dev->base + PIPE_REG_PARAMS_ADDR_LOW);
+
+       paddr = ((u64)aph << 32) | apl;
+       if (paddr != (__pa(aps)))
+               return 0;
+       return 1;
+}
+
+/* 0 on success */
+static int setup_access_params_addr(struct platform_device *pdev,
+                                       struct goldfish_pipe_dev *dev)
+{
+       u64 paddr;
+       struct access_params *aps;
+
+       aps = devm_kzalloc(&pdev->dev, sizeof(struct access_params), GFP_KERNEL);
+       if (!aps)
+               return -1;
+
+       /* FIXME */
+       paddr = __pa(aps);
+       writel((u32)(paddr >> 32), dev->base + PIPE_REG_PARAMS_ADDR_HIGH);
+       writel((u32)paddr, dev->base + PIPE_REG_PARAMS_ADDR_LOW);
+
+       if (valid_batchbuffer_addr(dev, aps)) {
+               dev->aps = aps;
+               return 0;
+       } else
+               return -1;
+}
+
+/* A value that will not be set by qemu emulator */
+#define INITIAL_BATCH_RESULT (0xdeadbeaf)
+static int access_with_param(struct goldfish_pipe_dev *dev, const int cmd,
+                               unsigned long address, unsigned long avail,
+                               struct goldfish_pipe *pipe, int *status)
+{
+       struct access_params *aps = dev->aps;
+
+       if (aps == NULL)
+               return -1;
+
+       aps->result = INITIAL_BATCH_RESULT;
+       aps->channel = (unsigned long)pipe;
+       aps->size = avail;
+       aps->address = address;
+       aps->cmd = cmd;
+       writel(cmd, dev->base + PIPE_REG_ACCESS_PARAMS);
+       /*
+        * If the aps->result has not changed, that means
+        * that the batch command failed
+        */
+       if (aps->result == INITIAL_BATCH_RESULT)
+               return -1;
+       *status = aps->result;
+       return 0;
+}
+
+/* This function is used for both reading from and writing to a given
+ * pipe.
+ */
+static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
+                                   size_t bufflen, int is_write)
+{
+       unsigned long irq_flags;
+       struct goldfish_pipe *pipe = filp->private_data;
+       struct goldfish_pipe_dev *dev = pipe->dev;
+       const int cmd_offset = is_write ? 0
+                                       : (CMD_READ_BUFFER - CMD_WRITE_BUFFER);
+       unsigned long address, address_end;
+       int ret = 0;
+
+       /* If the emulator already closed the pipe, no need to go further */
+       if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
+               return -EIO;
+
+       /* Null reads or writes succeeds */
+       if (unlikely(bufflen) == 0)
+               return 0;
+
+       /* Check the buffer range for access */
+       if (!access_ok(is_write ? VERIFY_WRITE : VERIFY_READ,
+                       buffer, bufflen))
+               return -EFAULT;
+
+       /* Serialize access to the pipe */
+       if (mutex_lock_interruptible(&pipe->lock))
+               return -ERESTARTSYS;
+
+       address = (unsigned long)(void *)buffer;
+       address_end = address + bufflen;
+
+       while (address < address_end) {
+               unsigned long  page_end = (address & PAGE_MASK) + PAGE_SIZE;
+               unsigned long  next     = page_end < address_end ? page_end
+                                                                : address_end;
+               unsigned long  avail    = next - address;
+               int status, wakeBit;
+
+               /* Ensure that the corresponding page is properly mapped */
+               /* FIXME: this isn't safe or sufficient - use get_user_pages */
+               if (is_write) {
+                       char c;
+                       /* Ensure that the page is mapped and readable */
+                       if (__get_user(c, (char __user *)address)) {
+                               if (!ret)
+                                       ret = -EFAULT;
+                               break;
+                       }
+               } else {
+                       /* Ensure that the page is mapped and writable */
+                       if (__put_user(0, (char __user *)address)) {
+                               if (!ret)
+                                       ret = -EFAULT;
+                               break;
+                       }
+               }
+
+               /* Now, try to transfer the bytes in the current page */
+               spin_lock_irqsave(&dev->lock, irq_flags);
+               if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset,
+                               address, avail, pipe, &status)) {
+                       writel((u32)pipe, dev->base + PIPE_REG_CHANNEL);
+                       writel(avail, dev->base + PIPE_REG_SIZE);
+                       writel(address, dev->base + PIPE_REG_ADDRESS);
+                       writel(CMD_WRITE_BUFFER + cmd_offset,
+                                       dev->base + PIPE_REG_COMMAND);
+                       status = readl(dev->base + PIPE_REG_STATUS);
+               }
+               spin_unlock_irqrestore(&dev->lock, irq_flags);
+
+               if (status > 0) { /* Correct transfer */
+                       ret += status;
+                       address += status;
+                       continue;
+               }
+
+               if (status == 0)  /* EOF */
+                       break;
+
+               /* An error occured. If we already transfered stuff, just
+               * return with its count. We expect the next call to return
+               * an error code */
+               if (ret > 0)
+                       break;
+
+               /* If the error is not PIPE_ERROR_AGAIN, or if we are not in
+               * non-blocking mode, just return the error code.
+               */
+               if (status != PIPE_ERROR_AGAIN ||
+                       (filp->f_flags & O_NONBLOCK) != 0) {
+                       ret = goldfish_pipe_error_convert(status);
+                       break;
+               }
+
+               /* We will have to wait until more data/space is available.
+               * First, mark the pipe as waiting for a specific wake signal.
+               */
+               wakeBit = is_write ? BIT_WAKE_ON_WRITE : BIT_WAKE_ON_READ;
+               set_bit(wakeBit, &pipe->flags);
+
+               /* Tell the emulator we're going to wait for a wake event */
+               goldfish_cmd(pipe, CMD_WAKE_ON_WRITE + cmd_offset);
+
+               /* Unlock the pipe, then wait for the wake signal */
+               mutex_unlock(&pipe->lock);
+
+               while (test_bit(wakeBit, &pipe->flags)) {
+                       if (wait_event_interruptible(
+                                       pipe->wake_queue,
+                                       !test_bit(wakeBit, &pipe->flags)))
+                               return -ERESTARTSYS;
+
+                       if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
+                               return -EIO;
+               }
+
+               /* Try to re-acquire the lock */
+               if (mutex_lock_interruptible(&pipe->lock))
+                       return -ERESTARTSYS;
+
+               /* Try the transfer again */
+               continue;
+       }
+       mutex_unlock(&pipe->lock);
+       return ret;
+}
+
+static ssize_t goldfish_pipe_read(struct file *filp, char __user *buffer,
+                             size_t bufflen, loff_t *ppos)
+{
+       return goldfish_pipe_read_write(filp, buffer, bufflen, 0);
+}
+
+static ssize_t goldfish_pipe_write(struct file *filp,
+                               const char __user *buffer, size_t bufflen,
+                               loff_t *ppos)
+{
+       return goldfish_pipe_read_write(filp, (char __user *)buffer,
+                                                               bufflen, 1);
+}
+
+
+static unsigned int goldfish_pipe_poll(struct file *filp, poll_table *wait)
+{
+       struct goldfish_pipe *pipe = filp->private_data;
+       unsigned int mask = 0;
+       int status;
+
+       mutex_lock(&pipe->lock);
+
+       poll_wait(filp, &pipe->wake_queue, wait);
+
+       status = goldfish_cmd_status(pipe, CMD_POLL);
+
+       mutex_unlock(&pipe->lock);
+
+       if (status & PIPE_POLL_IN)
+               mask |= POLLIN | POLLRDNORM;
+
+       if (status & PIPE_POLL_OUT)
+               mask |= POLLOUT | POLLWRNORM;
+
+       if (status & PIPE_POLL_HUP)
+               mask |= POLLHUP;
+
+       if (test_bit(BIT_CLOSED_ON_HOST, &pipe->flags))
+               mask |= POLLERR;
+
+       return mask;
+}
+
+static irqreturn_t goldfish_pipe_interrupt(int irq, void *dev_id)
+{
+       struct goldfish_pipe_dev *dev = dev_id;
+       unsigned long irq_flags;
+       int count = 0;
+
+       /* We're going to read from the emulator a list of (channel,flags)
+       * pairs corresponding to the wake events that occured on each
+       * blocked pipe (i.e. channel).
+       */
+       spin_lock_irqsave(&dev->lock, irq_flags);
+       for (;;) {
+               /* First read the channel, 0 means the end of the list */
+               struct goldfish_pipe *pipe;
+               unsigned long wakes;
+               unsigned long channel = readl(dev->base + PIPE_REG_CHANNEL);
+
+               if (channel == 0)
+                       break;
+
+               /* Convert channel to struct pipe pointer + read wake flags */
+               wakes = readl(dev->base + PIPE_REG_WAKES);
+               pipe  = (struct goldfish_pipe *)(ptrdiff_t)channel;
+
+               /* Did the emulator just closed a pipe? */
+               if (wakes & PIPE_WAKE_CLOSED) {
+                       set_bit(BIT_CLOSED_ON_HOST, &pipe->flags);
+                       wakes |= PIPE_WAKE_READ | PIPE_WAKE_WRITE;
+               }
+               if (wakes & PIPE_WAKE_READ)
+                       clear_bit(BIT_WAKE_ON_READ, &pipe->flags);
+               if (wakes & PIPE_WAKE_WRITE)
+                       clear_bit(BIT_WAKE_ON_WRITE, &pipe->flags);
+
+               wake_up_interruptible(&pipe->wake_queue);
+               count++;
+       }
+       spin_unlock_irqrestore(&dev->lock, irq_flags);
+
+       return (count == 0) ? IRQ_NONE : IRQ_HANDLED;
+}
+
+/**
+ *     goldfish_pipe_open      -       open a channel to the AVD
+ *     @inode: inode of device
+ *     @file: file struct of opener
+ *
+ *     Create a new pipe link between the emulator and the use application.
+ *     Each new request produces a new pipe.
+ *
+ *     Note: we use the pipe ID as a mux. All goldfish emulations are 32bit
+ *     right now so this is fine. A move to 64bit will need this addressing
+ */
+static int goldfish_pipe_open(struct inode *inode, struct file *file)
+{
+       struct goldfish_pipe *pipe;
+       struct goldfish_pipe_dev *dev = pipe_dev;
+       int32_t status;
+
+       /* Allocate new pipe kernel object */
+       pipe = kzalloc(sizeof(*pipe), GFP_KERNEL);
+       if (pipe == NULL)
+               return -ENOMEM;
+
+       pipe->dev = dev;
+       mutex_init(&pipe->lock);
+       init_waitqueue_head(&pipe->wake_queue);
+
+       /*
+        * Now, tell the emulator we're opening a new pipe. We use the
+        * pipe object's address as the channel identifier for simplicity.
+        */
+
+       status = goldfish_cmd_status(pipe, CMD_OPEN);
+       if (status < 0) {
+               kfree(pipe);
+               return status;
+       }
+
+       /* All is done, save the pipe into the file's private data field */
+       file->private_data = pipe;
+       return 0;
+}
+
+static int goldfish_pipe_release(struct inode *inode, struct file *filp)
+{
+       struct goldfish_pipe *pipe = filp->private_data;
+
+       /* The guest is closing the channel, so tell the emulator right now */
+       goldfish_cmd(pipe, CMD_CLOSE);
+       kfree(pipe);
+       filp->private_data = NULL;
+       return 0;
+}
+
+static const struct file_operations goldfish_pipe_fops = {
+       .owner = THIS_MODULE,
+       .read = goldfish_pipe_read,
+       .write = goldfish_pipe_write,
+       .poll = goldfish_pipe_poll,
+       .open = goldfish_pipe_open,
+       .release = goldfish_pipe_release,
+};
+
+static struct miscdevice goldfish_pipe_device = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "goldfish_pipe",
+       .fops = &goldfish_pipe_fops,
+};
+
+static int goldfish_pipe_probe(struct platform_device *pdev)
+{
+       int err;
+       struct resource *r;
+       struct goldfish_pipe_dev *dev = pipe_dev;
+
+       /* not thread safe, but this should not happen */
+       WARN_ON(dev->base != NULL);
+
+       spin_lock_init(&dev->lock);
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (r == NULL || resource_size(r) < PAGE_SIZE) {
+               dev_err(&pdev->dev, "can't allocate i/o page\n");
+               return -EINVAL;
+       }
+       dev->base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
+       if (dev->base == NULL) {
+               dev_err(&pdev->dev, "ioremap failed\n");
+               return -EINVAL;
+       }
+
+       r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (r == NULL) {
+               err = -EINVAL;
+               goto error;
+       }
+       dev->irq = r->start;
+
+       err = devm_request_irq(&pdev->dev, dev->irq, goldfish_pipe_interrupt,
+                               IRQF_SHARED, "goldfish_pipe", dev);
+       if (err) {
+               dev_err(&pdev->dev, "unable to allocate IRQ\n");
+               goto error;
+       }
+
+       err = misc_register(&goldfish_pipe_device);
+       if (err) {
+               dev_err(&pdev->dev, "unable to register device\n");
+               goto error;
+       }
+       setup_access_params_addr(pdev, dev);
+       return 0;
+
+error:
+       dev->base = NULL;
+       return err;
+}
+
+static int goldfish_pipe_remove(struct platform_device *pdev)
+{
+       struct goldfish_pipe_dev *dev = pipe_dev;
+       misc_deregister(&goldfish_pipe_device);
+       dev->base = NULL;
+       return 0;
+}
+
+static struct platform_driver goldfish_pipe = {
+       .probe = goldfish_pipe_probe,
+       .remove = goldfish_pipe_remove,
+       .driver = {
+               .name = "goldfish_pipe"
+       }
+};
+
+module_platform_driver(goldfish_pipe);
+MODULE_AUTHOR("David Turner <digit@google.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/platform/goldfish/pdev_bus.c b/drivers/platform/goldfish/pdev_bus.c
new file mode 100644 (file)
index 0000000..92cc4cf
--- /dev/null
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2007 Google, Inc.
+ * Copyright (C) 2011 Intel, Inc.
+ * Copyright (C) 2013 Intel, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+
+#define PDEV_BUS_OP_DONE        (0x00)
+#define PDEV_BUS_OP_REMOVE_DEV  (0x04)
+#define PDEV_BUS_OP_ADD_DEV     (0x08)
+
+#define PDEV_BUS_OP_INIT        (0x00)
+
+#define PDEV_BUS_OP             (0x00)
+#define PDEV_BUS_GET_NAME       (0x04)
+#define PDEV_BUS_NAME_LEN       (0x08)
+#define PDEV_BUS_ID             (0x0c)
+#define PDEV_BUS_IO_BASE        (0x10)
+#define PDEV_BUS_IO_SIZE        (0x14)
+#define PDEV_BUS_IRQ            (0x18)
+#define PDEV_BUS_IRQ_COUNT      (0x1c)
+
+struct pdev_bus_dev {
+       struct list_head list;
+       struct platform_device pdev;
+       struct resource resources[0];
+};
+
+static void goldfish_pdev_worker(struct work_struct *work);
+
+static void __iomem *pdev_bus_base;
+static unsigned long pdev_bus_addr;
+static unsigned long pdev_bus_len;
+static u32 pdev_bus_irq;
+static LIST_HEAD(pdev_bus_new_devices);
+static LIST_HEAD(pdev_bus_registered_devices);
+static LIST_HEAD(pdev_bus_removed_devices);
+static DECLARE_WORK(pdev_bus_worker, goldfish_pdev_worker);
+
+
+static void goldfish_pdev_worker(struct work_struct *work)
+{
+       int ret;
+       struct pdev_bus_dev *pos, *n;
+
+       list_for_each_entry_safe(pos, n, &pdev_bus_removed_devices, list) {
+               list_del(&pos->list);
+               platform_device_unregister(&pos->pdev);
+               kfree(pos);
+       }
+       list_for_each_entry_safe(pos, n, &pdev_bus_new_devices, list) {
+               list_del(&pos->list);
+               ret = platform_device_register(&pos->pdev);
+               if (ret)
+                       pr_err("goldfish_pdev_worker failed to register device, %s\n",
+                                                               pos->pdev.name);
+               list_add_tail(&pos->list, &pdev_bus_registered_devices);
+       }
+}
+
+static void goldfish_pdev_remove(void)
+{
+       struct pdev_bus_dev *pos, *n;
+       u32 base;
+
+       base = readl(pdev_bus_base + PDEV_BUS_IO_BASE);
+
+       list_for_each_entry_safe(pos, n, &pdev_bus_new_devices, list) {
+               if (pos->resources[0].start == base) {
+                       list_del(&pos->list);
+                       kfree(pos);
+                       return;
+               }
+       }
+       list_for_each_entry_safe(pos, n, &pdev_bus_registered_devices, list) {
+               if (pos->resources[0].start == base) {
+                       list_del(&pos->list);
+                       list_add_tail(&pos->list, &pdev_bus_removed_devices);
+                       schedule_work(&pdev_bus_worker);
+                       return;
+               }
+       };
+       pr_err("goldfish_pdev_remove could not find device at %x\n", base);
+}
+
+static int goldfish_new_pdev(void)
+{
+       struct pdev_bus_dev *dev;
+       u32 name_len;
+       u32 irq = -1, irq_count;
+       int resource_count = 2;
+       u32 base;
+       char *name;
+
+       base = readl(pdev_bus_base + PDEV_BUS_IO_BASE);
+
+       irq_count = readl(pdev_bus_base + PDEV_BUS_IRQ_COUNT);
+       name_len = readl(pdev_bus_base + PDEV_BUS_NAME_LEN);
+       if (irq_count)
+               resource_count++;
+
+       dev = kzalloc(sizeof(*dev) +
+               sizeof(struct resource) * resource_count +
+               name_len + 1 + sizeof(*dev->pdev.dev.dma_mask), GFP_ATOMIC);
+       if (dev == NULL)
+               return -ENOMEM;
+
+       dev->pdev.num_resources = resource_count;
+       dev->pdev.resource = (struct resource *)(dev + 1);
+       dev->pdev.name = name = (char *)(dev->pdev.resource + resource_count);
+       dev->pdev.dev.coherent_dma_mask = ~0;
+       dev->pdev.dev.dma_mask = (void *)(dev->pdev.name + name_len + 1);
+       *dev->pdev.dev.dma_mask = ~0;
+
+       writel((unsigned long)name, pdev_bus_base + PDEV_BUS_GET_NAME);
+       name[name_len] = '\0';
+       dev->pdev.id = readl(pdev_bus_base + PDEV_BUS_ID);
+       dev->pdev.resource[0].start = base;
+       dev->pdev.resource[0].end = base +
+                               readl(pdev_bus_base + PDEV_BUS_IO_SIZE) - 1;
+       dev->pdev.resource[0].flags = IORESOURCE_MEM;
+       if (irq_count) {
+               irq = readl(pdev_bus_base + PDEV_BUS_IRQ);
+               dev->pdev.resource[1].start = irq;
+               dev->pdev.resource[1].end = irq + irq_count - 1;
+               dev->pdev.resource[1].flags = IORESOURCE_IRQ;
+       }
+
+       pr_debug("goldfish_new_pdev %s at %x irq %d\n", name, base, irq);
+       list_add_tail(&dev->list, &pdev_bus_new_devices);
+       schedule_work(&pdev_bus_worker);
+
+       return 0;
+}
+
+static irqreturn_t goldfish_pdev_bus_interrupt(int irq, void *dev_id)
+{
+       irqreturn_t ret = IRQ_NONE;
+       while (1) {
+               u32 op = readl(pdev_bus_base + PDEV_BUS_OP);
+               switch (op) {
+               case PDEV_BUS_OP_DONE:
+                       return IRQ_NONE;
+
+               case PDEV_BUS_OP_REMOVE_DEV:
+                       goldfish_pdev_remove();
+                       break;
+
+               case PDEV_BUS_OP_ADD_DEV:
+                       goldfish_new_pdev();
+                       break;
+               }
+               ret = IRQ_HANDLED;
+       }
+       return ret;
+}
+
+static int goldfish_pdev_bus_probe(struct platform_device *pdev)
+{
+       int ret;
+       struct resource *r;
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (r == NULL)
+               return -EINVAL;
+
+       pdev_bus_addr = r->start;
+       pdev_bus_len = resource_size(r);
+
+       if (request_mem_region(pdev_bus_addr, pdev_bus_len, "goldfish")) {
+               dev_err(&pdev->dev, "unable to reserve Goldfish MMIO.\n");
+               return -EBUSY;
+       }
+
+       pdev_bus_base = ioremap(pdev_bus_addr, pdev_bus_len);
+       if (pdev_bus_base == NULL) {
+               ret = -ENOMEM;
+               dev_err(&pdev->dev, "unable to map Goldfish MMIO.\n");
+               goto free_resources;
+       }
+
+       r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (r == NULL) {
+               ret = -ENOENT;
+               goto free_map;
+       }
+
+       pdev_bus_irq = r->start;
+
+       ret = request_irq(pdev_bus_irq, goldfish_pdev_bus_interrupt,
+                               IRQF_SHARED, "goldfish_pdev_bus", pdev);
+       if (ret) {
+               dev_err(&pdev->dev, "unable to request Goldfish IRQ\n");
+               goto free_map;
+       }
+
+       writel(PDEV_BUS_OP_INIT, pdev_bus_base + PDEV_BUS_OP);
+       return 0;
+
+free_map:
+       iounmap(pdev_bus_base);
+free_resources:
+       release_mem_region(pdev_bus_addr, pdev_bus_len);
+       return ret;
+}
+
+static int goldfish_pdev_bus_remove(struct platform_device *pdev)
+{
+       iounmap(pdev_bus_base);
+       free_irq(pdev_bus_irq, pdev);
+       release_mem_region(pdev_bus_addr, pdev_bus_len);
+       return 0;
+}
+
+static struct platform_driver goldfish_pdev_bus_driver = {
+       .probe = goldfish_pdev_bus_probe,
+       .remove = goldfish_pdev_bus_remove,
+       .driver = {
+               .name = "goldfish_pdev_bus"
+       }
+};
+
+module_platform_driver(goldfish_pdev_bus_driver);
index 923a9da9c829d7be9a3fe95bac77b0b7e4431de6..fabef47c1efcae4c66cb34a31f69514c0e99d491 100644 (file)
@@ -1173,4 +1173,20 @@ config RTC_DRV_SNVS
           This driver can also be built as a module, if so, the module
           will be called "rtc-snvs".
 
+comment "HID Sensor RTC drivers"
+
+config RTC_DRV_HID_SENSOR_TIME
+       tristate "HID Sensor Time"
+       depends on USB_HID
+       select IIO
+       select HID_SENSOR_HUB
+       select HID_SENSOR_IIO_COMMON
+       help
+         Say yes here to build support for the HID Sensors of type Time.
+         This drivers makes such sensors available as RTCs.
+
+         If this driver is compiled as a module, it will be named
+         rtc-hid-sensor-time.
+
+
 endif # RTC_CLASS
index 4418ef3f9ecc9278b53aae5dd5177cff522b24ba..68a3ca937c88f12a46a2e3949175b86fcfe37b7d 100644 (file)
@@ -52,6 +52,7 @@ obj-$(CONFIG_RTC_DRV_EM3027)  += rtc-em3027.o
 obj-$(CONFIG_RTC_DRV_EP93XX)   += rtc-ep93xx.o
 obj-$(CONFIG_RTC_DRV_FM3130)   += rtc-fm3130.o
 obj-$(CONFIG_RTC_DRV_GENERIC)  += rtc-generic.o
+obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o
 obj-$(CONFIG_RTC_DRV_IMXDI)    += rtc-imxdi.o
 obj-$(CONFIG_RTC_DRV_ISL1208)  += rtc-isl1208.o
 obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c
new file mode 100644 (file)
index 0000000..0438c9e
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * HID Sensor Time Driver
+ * Copyright (c) 2012, Alexander Holler.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * 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 St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/hid-sensor-hub.h>
+#include <linux/iio/iio.h>
+#include <linux/rtc.h>
+
+/* Format: HID-SENSOR-usage_id_in_hex */
+/* Usage ID from spec for Time: 0x2000A0 */
+#define DRIVER_NAME "HID-SENSOR-2000a0" /* must be lowercase */
+
+enum hid_time_channel {
+       CHANNEL_SCAN_INDEX_YEAR,
+       CHANNEL_SCAN_INDEX_MONTH,
+       CHANNEL_SCAN_INDEX_DAY,
+       CHANNEL_SCAN_INDEX_HOUR,
+       CHANNEL_SCAN_INDEX_MINUTE,
+       CHANNEL_SCAN_INDEX_SECOND,
+       TIME_RTC_CHANNEL_MAX,
+};
+
+struct hid_time_state {
+       struct hid_sensor_hub_callbacks callbacks;
+       struct hid_sensor_common common_attributes;
+       struct hid_sensor_hub_attribute_info info[TIME_RTC_CHANNEL_MAX];
+       struct rtc_time last_time;
+       spinlock_t lock_last_time;
+       struct completion comp_last_time;
+       struct rtc_time time_buf;
+       struct rtc_device *rtc;
+};
+
+static const u32 hid_time_addresses[TIME_RTC_CHANNEL_MAX] = {
+       HID_USAGE_SENSOR_TIME_YEAR,
+       HID_USAGE_SENSOR_TIME_MONTH,
+       HID_USAGE_SENSOR_TIME_DAY,
+       HID_USAGE_SENSOR_TIME_HOUR,
+       HID_USAGE_SENSOR_TIME_MINUTE,
+       HID_USAGE_SENSOR_TIME_SECOND,
+};
+
+/* Channel names for verbose error messages */
+static const char * const hid_time_channel_names[TIME_RTC_CHANNEL_MAX] = {
+       "year", "month", "day", "hour", "minute", "second",
+};
+
+/* Callback handler to send event after all samples are received and captured */
+static int hid_time_proc_event(struct hid_sensor_hub_device *hsdev,
+                               unsigned usage_id, void *priv)
+{
+       unsigned long flags;
+       struct hid_time_state *time_state = platform_get_drvdata(priv);
+
+       spin_lock_irqsave(&time_state->lock_last_time, flags);
+       time_state->last_time = time_state->time_buf;
+       spin_unlock_irqrestore(&time_state->lock_last_time, flags);
+       complete(&time_state->comp_last_time);
+       return 0;
+}
+
+static int hid_time_capture_sample(struct hid_sensor_hub_device *hsdev,
+                               unsigned usage_id, size_t raw_len,
+                               char *raw_data, void *priv)
+{
+       struct hid_time_state *time_state = platform_get_drvdata(priv);
+       struct rtc_time *time_buf = &time_state->time_buf;
+
+       switch (usage_id) {
+       case HID_USAGE_SENSOR_TIME_YEAR:
+               time_buf->tm_year = *(u8 *)raw_data;
+               if (time_buf->tm_year < 70)
+                       /* assume we are in 1970...2069 */
+                       time_buf->tm_year += 100;
+               break;
+       case HID_USAGE_SENSOR_TIME_MONTH:
+               /* sensor sending the month as 1-12, we need 0-11 */
+               time_buf->tm_mon = *(u8 *)raw_data-1;
+               break;
+       case HID_USAGE_SENSOR_TIME_DAY:
+               time_buf->tm_mday = *(u8 *)raw_data;
+               break;
+       case HID_USAGE_SENSOR_TIME_HOUR:
+               time_buf->tm_hour = *(u8 *)raw_data;
+               break;
+       case HID_USAGE_SENSOR_TIME_MINUTE:
+               time_buf->tm_min = *(u8 *)raw_data;
+               break;
+       case HID_USAGE_SENSOR_TIME_SECOND:
+               time_buf->tm_sec = *(u8 *)raw_data;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
+/* small helper, haven't found any other way */
+static const char *hid_time_attrib_name(u32 attrib_id)
+{
+       static const char unknown[] = "unknown";
+       unsigned i;
+
+       for (i = 0; i < TIME_RTC_CHANNEL_MAX; ++i) {
+               if (hid_time_addresses[i] == attrib_id)
+                       return hid_time_channel_names[i];
+       }
+       return unknown; /* should never happen */
+}
+
+static int hid_time_parse_report(struct platform_device *pdev,
+                               struct hid_sensor_hub_device *hsdev,
+                               unsigned usage_id,
+                               struct hid_time_state *time_state)
+{
+       int report_id, i;
+
+       for (i = 0; i < TIME_RTC_CHANNEL_MAX; ++i)
+               if (sensor_hub_input_get_attribute_info(hsdev,
+                               HID_INPUT_REPORT, usage_id,
+                               hid_time_addresses[i],
+                               &time_state->info[i]) < 0)
+                       return -EINVAL;
+       /* Check the (needed) attributes for sanity */
+       report_id = time_state->info[0].report_id;
+       if (report_id < 0) {
+               dev_err(&pdev->dev, "bad report ID!\n");
+               return -EINVAL;
+       }
+       for (i = 0; i < TIME_RTC_CHANNEL_MAX; ++i) {
+               if (time_state->info[i].report_id != report_id) {
+                       dev_err(&pdev->dev,
+                               "not all needed attributes inside the same report!\n");
+                       return -EINVAL;
+               }
+               if (time_state->info[i].size != 1) {
+                       dev_err(&pdev->dev,
+                               "attribute '%s' not 8 bits wide!\n",
+                               hid_time_attrib_name(
+                                       time_state->info[i].attrib_id));
+                       return -EINVAL;
+               }
+               if (time_state->info[i].units !=
+                               HID_USAGE_SENSOR_UNITS_NOT_SPECIFIED &&
+                               /* allow attribute seconds with unit seconds */
+                               !(time_state->info[i].attrib_id ==
+                               HID_USAGE_SENSOR_TIME_SECOND &&
+                               time_state->info[i].units ==
+                               HID_USAGE_SENSOR_UNITS_SECOND)) {
+                       dev_err(&pdev->dev,
+                               "attribute '%s' hasn't a unit of type 'none'!\n",
+                               hid_time_attrib_name(
+                                       time_state->info[i].attrib_id));
+                       return -EINVAL;
+               }
+               if (time_state->info[i].unit_expo) {
+                       dev_err(&pdev->dev,
+                               "attribute '%s' hasn't a unit exponent of 1!\n",
+                               hid_time_attrib_name(
+                                       time_state->info[i].attrib_id));
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+static int hid_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       unsigned long flags;
+       struct hid_time_state *time_state =
+               platform_get_drvdata(to_platform_device(dev));
+       int ret;
+
+       INIT_COMPLETION(time_state->comp_last_time);
+       /* get a report with all values through requesting one value */
+       sensor_hub_input_attr_get_raw_value(time_state->common_attributes.hsdev,
+                       HID_USAGE_SENSOR_TIME, hid_time_addresses[0],
+                       time_state->info[0].report_id);
+       /* wait for all values (event) */
+       ret = wait_for_completion_killable_timeout(
+                       &time_state->comp_last_time, HZ*6);
+       if (ret > 0) {
+               /* no error */
+               spin_lock_irqsave(&time_state->lock_last_time, flags);
+               *tm = time_state->last_time;
+               spin_unlock_irqrestore(&time_state->lock_last_time, flags);
+               return 0;
+       }
+       if (!ret)
+               return -EIO; /* timeouted */
+       return ret; /* killed (-ERESTARTSYS) */
+}
+
+static const struct rtc_class_ops hid_time_rtc_ops = {
+       .read_time = hid_rtc_read_time,
+};
+
+static int hid_time_probe(struct platform_device *pdev)
+{
+       int ret = 0;
+       struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+       struct hid_time_state *time_state = devm_kzalloc(&pdev->dev,
+               sizeof(struct hid_time_state), GFP_KERNEL);
+
+       if (time_state == NULL)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, time_state);
+
+       init_completion(&time_state->comp_last_time);
+       time_state->common_attributes.hsdev = hsdev;
+       time_state->common_attributes.pdev = pdev;
+
+       ret = hid_sensor_parse_common_attributes(hsdev,
+                               HID_USAGE_SENSOR_TIME,
+                               &time_state->common_attributes);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to setup common attributes!\n");
+               return ret;
+       }
+
+       ret = hid_time_parse_report(pdev, hsdev, HID_USAGE_SENSOR_TIME,
+                                       time_state);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to setup attributes!\n");
+               return ret;
+       }
+
+       time_state->callbacks.send_event = hid_time_proc_event;
+       time_state->callbacks.capture_sample = hid_time_capture_sample;
+       time_state->callbacks.pdev = pdev;
+       ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_TIME,
+                                       &time_state->callbacks);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "register callback failed!\n");
+               return ret;
+       }
+
+       time_state->rtc = rtc_device_register("hid-sensor-time",
+                               &pdev->dev, &hid_time_rtc_ops, THIS_MODULE);
+
+       if (IS_ERR(time_state->rtc)) {
+               dev_err(&pdev->dev, "rtc device register failed!\n");
+               return PTR_ERR(time_state->rtc);
+       }
+
+       return ret;
+}
+
+static int hid_time_remove(struct platform_device *pdev)
+{
+       struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
+       struct hid_time_state *time_state = platform_get_drvdata(pdev);
+
+       rtc_device_unregister(time_state->rtc);
+       sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_TIME);
+
+       return 0;
+}
+
+static struct platform_driver hid_time_platform_driver = {
+       .driver = {
+               .name   = DRIVER_NAME,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = hid_time_probe,
+       .remove         = hid_time_remove,
+};
+module_platform_driver(hid_time_platform_driver);
+
+MODULE_DESCRIPTION("HID Sensor Time");
+MODULE_AUTHOR("Alexander Holler <holler@ahsoftware.de>");
+MODULE_LICENSE("GPL");
index 329bdb42109f9a726bec9ebd74359a2f97bfd287..3a7965d6ac28a69ff43d0747f191477ae419e75e 100644 (file)
@@ -74,8 +74,6 @@ source "drivers/staging/iio/Kconfig"
 
 source "drivers/staging/zram/Kconfig"
 
-source "drivers/staging/zcache/Kconfig"
-
 source "drivers/staging/zsmalloc/Kconfig"
 
 source "drivers/staging/wlags49_h2/Kconfig"
@@ -128,8 +126,6 @@ source "drivers/staging/csr/Kconfig"
 
 source "drivers/staging/omap-thermal/Kconfig"
 
-source "drivers/staging/ramster/Kconfig"
-
 source "drivers/staging/silicom/Kconfig"
 
 source "drivers/staging/ced1401/Kconfig"
@@ -142,4 +138,8 @@ source "drivers/staging/sb105x/Kconfig"
 
 source "drivers/staging/fwserial/Kconfig"
 
+source "drivers/staging/zcache/Kconfig"
+
+source "drivers/staging/goldfish/Kconfig"
+
 endif # STAGING
index c7ec486680f7f460226bae0444e16db604d9fc79..5971865d0c61017ff5bcfa12dc1f9efdb79874d7 100644 (file)
@@ -31,7 +31,6 @@ obj-$(CONFIG_VME_BUS)         += vme/
 obj-$(CONFIG_DX_SEP)            += sep/
 obj-$(CONFIG_IIO)              += iio/
 obj-$(CONFIG_ZRAM)             += zram/
-obj-$(CONFIG_ZCACHE)           += zcache/
 obj-$(CONFIG_ZSMALLOC)         += zsmalloc/
 obj-$(CONFIG_WLAGS49_H2)       += wlags49_h2/
 obj-$(CONFIG_WLAGS49_H25)      += wlags49_h25/
@@ -56,10 +55,11 @@ obj-$(CONFIG_USB_G_CCG)             += ccg/
 obj-$(CONFIG_WIMAX_GDM72XX)    += gdm72xx/
 obj-$(CONFIG_CSR_WIFI)         += csr/
 obj-$(CONFIG_OMAP_BANDGAP)     += omap-thermal/
-obj-$(CONFIG_ZCACHE2)          += ramster/
 obj-$(CONFIG_NET_VENDOR_SILICOM)       += silicom/
 obj-$(CONFIG_CED1401)          += ced1401/
 obj-$(CONFIG_DRM_IMX)          += imx-drm/
 obj-$(CONFIG_DGRP)             += dgrp/
 obj-$(CONFIG_SB105X)           += sb105x/
 obj-$(CONFIG_FIREWIRE_SERIAL)  += fwserial/
+obj-$(CONFIG_ZCACHE)           += zcache/
+obj-$(CONFIG_GOLDFISH)         += goldfish/
index 0ce50d12c30f9618c003bc20087cf7dfaff3eda6..465a28c08f20f890bd2e24fbd680fa4a8d7ada92 100644 (file)
@@ -11,19 +11,42 @@ if ANDROID
 config ANDROID_BINDER_IPC
        bool "Android Binder IPC Driver"
        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 ASHMEM
        bool "Enable the Anonymous Shared Memory Subsystem"
        default n
        depends on SHMEM || TINY_SHMEM
-       help
+       ---help---
          The ashmem subsystem is a new shared memory allocator, similar to
          POSIX SHM but with different behavior and sporting a simpler
          file-based API.
 
+         It is, in theory, a good memory allocator for low-memory devices,
+         because it can discard shared memory units when under memory pressure.
+
 config ANDROID_LOGGER
        tristate "Android log driver"
        default n
+       ---help---
+         This adds support for system-wide logging using four log buffers.
+
+         These are:
+
+             1: main
+             2: events
+             3: radio
+             4: system
+
+         Log reading and writing is performed via normal Linux reads and
+         optimized writes. This optimization avoids logging having too
+         much overhead in the system.
 
 config ANDROID_TIMED_OUTPUT
        bool "Timed output class driver"
@@ -38,13 +61,13 @@ config ANDROID_LOW_MEMORY_KILLER
        bool "Android Low Memory Killer"
        default N
        ---help---
-         Register processes to be killed when memory is low
+         Registers processes to be killed when memory is low
 
 config ANDROID_INTF_ALARM_DEV
        bool "Android alarm driver"
        depends on RTC_CLASS
        default n
-       help
+       ---help---
          Provides non-wakeup and rtc backed wakeup alarms based on rtc or
          elapsed realtime, and a non-wakeup alarm on the monotonic clock.
          Also exports the alarm interface to user-space.
index a9b293ff3cc8350b8fc1faed4f32dab3fb118873..ceb1c643753d9fef288d7d5eda97b5191b7726a7 100644 (file)
@@ -42,10 +42,6 @@ do {                                                                 \
        ANDROID_ALARM_RTC_WAKEUP_MASK | \
        ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK)
 
-/* support old userspace code */
-#define ANDROID_ALARM_SET_OLD               _IOW('a', 2, time_t) /* set alarm */
-#define ANDROID_ALARM_SET_AND_WAIT_OLD      _IOW('a', 3, time_t)
-
 static int alarm_opened;
 static DEFINE_SPINLOCK(alarm_slock);
 static struct wakeup_source alarm_wake_lock;
@@ -96,18 +92,116 @@ static void devalarm_cancel(struct devalarm *alrm)
                hrtimer_cancel(&alrm->u.hrt);
 }
 
+static void alarm_clear(enum android_alarm_type alarm_type)
+{
+       uint32_t alarm_type_mask = 1U << alarm_type;
+       unsigned long flags;
 
-static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+       spin_lock_irqsave(&alarm_slock, flags);
+       alarm_dbg(IO, "alarm %d clear\n", alarm_type);
+       devalarm_try_to_cancel(&alarms[alarm_type]);
+       if (alarm_pending) {
+               alarm_pending &= ~alarm_type_mask;
+               if (!alarm_pending && !wait_pending)
+                       __pm_relax(&alarm_wake_lock);
+       }
+       alarm_enabled &= ~alarm_type_mask;
+       spin_unlock_irqrestore(&alarm_slock, flags);
+
+}
+
+static void alarm_set(enum android_alarm_type alarm_type,
+                                                       struct timespec *ts)
 {
-       int rv = 0;
+       uint32_t alarm_type_mask = 1U << alarm_type;
        unsigned long flags;
-       struct timespec new_alarm_time;
-       struct timespec new_rtc_time;
-       struct timespec tmp_time;
+
+       spin_lock_irqsave(&alarm_slock, flags);
+       alarm_dbg(IO, "alarm %d set %ld.%09ld\n",
+                       alarm_type, ts->tv_sec, ts->tv_nsec);
+       alarm_enabled |= alarm_type_mask;
+       devalarm_start(&alarms[alarm_type], timespec_to_ktime(*ts));
+       spin_unlock_irqrestore(&alarm_slock, flags);
+}
+
+static int alarm_wait(void)
+{
+       unsigned long flags;
+       int rv = 0;
+
+       spin_lock_irqsave(&alarm_slock, flags);
+       alarm_dbg(IO, "alarm wait\n");
+       if (!alarm_pending && wait_pending) {
+               __pm_relax(&alarm_wake_lock);
+               wait_pending = 0;
+       }
+       spin_unlock_irqrestore(&alarm_slock, flags);
+
+       rv = wait_event_interruptible(alarm_wait_queue, alarm_pending);
+       if (rv)
+               return rv;
+
+       spin_lock_irqsave(&alarm_slock, flags);
+       rv = alarm_pending;
+       wait_pending = 1;
+       alarm_pending = 0;
+       spin_unlock_irqrestore(&alarm_slock, flags);
+
+       return rv;
+}
+
+static int alarm_set_rtc(struct timespec *ts)
+{
        struct rtc_time new_rtc_tm;
        struct rtc_device *rtc_dev;
+       unsigned long flags;
+       int rv = 0;
+
+       rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
+       rtc_dev = alarmtimer_get_rtcdev();
+       rv = do_settimeofday(ts);
+       if (rv < 0)
+               return rv;
+       if (rtc_dev)
+               rv = rtc_set_time(rtc_dev, &new_rtc_tm);
+
+       spin_lock_irqsave(&alarm_slock, flags);
+       alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
+       wake_up(&alarm_wait_queue);
+       spin_unlock_irqrestore(&alarm_slock, flags);
+
+       return rv;
+}
+
+static int alarm_get_time(enum android_alarm_type alarm_type,
+                                                       struct timespec *ts)
+{
+       int rv = 0;
+
+       switch (alarm_type) {
+       case ANDROID_ALARM_RTC_WAKEUP:
+       case ANDROID_ALARM_RTC:
+               getnstimeofday(ts);
+               break;
+       case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP:
+       case ANDROID_ALARM_ELAPSED_REALTIME:
+               get_monotonic_boottime(ts);
+               break;
+       case ANDROID_ALARM_SYSTEMTIME:
+               ktime_get_ts(ts);
+               break;
+       default:
+               rv = -EINVAL;
+       }
+       return rv;
+}
+
+static long alarm_do_ioctl(struct file *file, unsigned int cmd,
+                                                       struct timespec *ts)
+{
+       int rv = 0;
+       unsigned long flags;
        enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
-       uint32_t alarm_type_mask = 1U << alarm_type;
 
        if (alarm_type >= ANDROID_ALARM_TYPE_COUNT)
                return -EINVAL;
@@ -130,115 +224,89 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        switch (ANDROID_ALARM_BASE_CMD(cmd)) {
        case ANDROID_ALARM_CLEAR(0):
-               spin_lock_irqsave(&alarm_slock, flags);
-               alarm_dbg(IO, "alarm %d clear\n", alarm_type);
-               devalarm_try_to_cancel(&alarms[alarm_type]);
-               if (alarm_pending) {
-                       alarm_pending &= ~alarm_type_mask;
-                       if (!alarm_pending && !wait_pending)
-                               __pm_relax(&alarm_wake_lock);
-               }
-               alarm_enabled &= ~alarm_type_mask;
-               spin_unlock_irqrestore(&alarm_slock, flags);
+               alarm_clear(alarm_type);
                break;
-
-       case ANDROID_ALARM_SET_OLD:
-       case ANDROID_ALARM_SET_AND_WAIT_OLD:
-               if (get_user(new_alarm_time.tv_sec, (int __user *)arg)) {
-                       rv = -EFAULT;
-                       goto err1;
-               }
-               new_alarm_time.tv_nsec = 0;
-               goto from_old_alarm_set;
-
-       case ANDROID_ALARM_SET_AND_WAIT(0):
        case ANDROID_ALARM_SET(0):
-               if (copy_from_user(&new_alarm_time, (void __user *)arg,
-                   sizeof(new_alarm_time))) {
-                       rv = -EFAULT;
-                       goto err1;
-               }
-from_old_alarm_set:
-               spin_lock_irqsave(&alarm_slock, flags);
-               alarm_dbg(IO, "alarm %d set %ld.%09ld\n",
-                         alarm_type,
-                         new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
-               alarm_enabled |= alarm_type_mask;
-               devalarm_start(&alarms[alarm_type],
-                       timespec_to_ktime(new_alarm_time));
-               spin_unlock_irqrestore(&alarm_slock, flags);
-               if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_SET_AND_WAIT(0)
-                   && cmd != ANDROID_ALARM_SET_AND_WAIT_OLD)
-                       break;
+               alarm_set(alarm_type, ts);
+               break;
+       case ANDROID_ALARM_SET_AND_WAIT(0):
+               alarm_set(alarm_type, ts);
                /* fall though */
        case ANDROID_ALARM_WAIT:
-               spin_lock_irqsave(&alarm_slock, flags);
-               alarm_dbg(IO, "alarm wait\n");
-               if (!alarm_pending && wait_pending) {
-                       __pm_relax(&alarm_wake_lock);
-                       wait_pending = 0;
-               }
-               spin_unlock_irqrestore(&alarm_slock, flags);
-               rv = wait_event_interruptible(alarm_wait_queue, alarm_pending);
-               if (rv)
-                       goto err1;
-               spin_lock_irqsave(&alarm_slock, flags);
-               rv = alarm_pending;
-               wait_pending = 1;
-               alarm_pending = 0;
-               spin_unlock_irqrestore(&alarm_slock, flags);
+               rv = alarm_wait();
                break;
        case ANDROID_ALARM_SET_RTC:
-               if (copy_from_user(&new_rtc_time, (void __user *)arg,
-                   sizeof(new_rtc_time))) {
-                       rv = -EFAULT;
-                       goto err1;
-               }
-               rtc_time_to_tm(new_rtc_time.tv_sec, &new_rtc_tm);
-               rtc_dev = alarmtimer_get_rtcdev();
-               rv = do_settimeofday(&new_rtc_time);
-               if (rv < 0)
-                       goto err1;
-               if (rtc_dev)
-                       rv = rtc_set_time(rtc_dev, &new_rtc_tm);
-               spin_lock_irqsave(&alarm_slock, flags);
-               alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
-               wake_up(&alarm_wait_queue);
-               spin_unlock_irqrestore(&alarm_slock, flags);
-               if (rv < 0)
-                       goto err1;
+               rv = alarm_set_rtc(ts);
                break;
        case ANDROID_ALARM_GET_TIME(0):
-               switch (alarm_type) {
-               case ANDROID_ALARM_RTC_WAKEUP:
-               case ANDROID_ALARM_RTC:
-                       getnstimeofday(&tmp_time);
-                       break;
-               case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP:
-               case ANDROID_ALARM_ELAPSED_REALTIME:
-                       get_monotonic_boottime(&tmp_time);
-                       break;
-               case ANDROID_ALARM_SYSTEMTIME:
-                       ktime_get_ts(&tmp_time);
-                       break;
-               default:
-                       rv = -EINVAL;
-                       goto err1;
-               }
-               if (copy_to_user((void __user *)arg, &tmp_time,
-                   sizeof(tmp_time))) {
-                       rv = -EFAULT;
-                       goto err1;
-               }
+               rv = alarm_get_time(alarm_type, ts);
                break;
 
        default:
                rv = -EINVAL;
        }
-err1:
        return rv;
 }
 
+static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+
+       struct timespec ts;
+       int rv;
+
+       switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+       case ANDROID_ALARM_SET_AND_WAIT(0):
+       case ANDROID_ALARM_SET(0):
+       case ANDROID_ALARM_SET_RTC:
+               if (copy_from_user(&ts, (void __user *)arg, sizeof(ts)))
+                       return -EFAULT;
+               break;
+       }
+
+       rv = alarm_do_ioctl(file, cmd, &ts);
+
+       switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+       case ANDROID_ALARM_GET_TIME(0):
+               if (copy_to_user((void __user *)arg, &ts, sizeof(ts)))
+                       return -EFAULT;
+               break;
+       }
+
+       return rv;
+}
+#ifdef CONFIG_COMPAT
+static long alarm_compat_ioctl(struct file *file, unsigned int cmd,
+                                                       unsigned long arg)
+{
+
+       struct timespec ts;
+       int rv;
+
+       switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+       case ANDROID_ALARM_SET_AND_WAIT_COMPAT(0):
+       case ANDROID_ALARM_SET_COMPAT(0):
+       case ANDROID_ALARM_SET_RTC_COMPAT:
+               if (compat_get_timespec(&ts, (void __user *)arg))
+                       return -EFAULT;
+               /* fall through */
+       case ANDROID_ALARM_GET_TIME_COMPAT(0):
+               cmd = ANDROID_ALARM_COMPAT_TO_NORM(cmd);
+               break;
+       }
+
+       rv = alarm_do_ioctl(file, cmd, &ts);
+
+       switch (ANDROID_ALARM_BASE_CMD(cmd)) {
+       case ANDROID_ALARM_GET_TIME(0): /* NOTE: we modified cmd above */
+               if (compat_put_timespec(&ts, (void __user *)arg))
+                       return -EFAULT;
+               break;
+       }
+
+       return rv;
+}
+#endif
+
 static int alarm_open(struct inode *inode, struct file *file)
 {
        file->private_data = NULL;
@@ -319,6 +387,9 @@ static const struct file_operations alarm_fops = {
        .unlocked_ioctl = alarm_ioctl,
        .open = alarm_open,
        .release = alarm_release,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = alarm_compat_ioctl,
+#endif
 };
 
 static struct miscdevice alarm_device = {
index d0cafd6371996c75e3ee094b2be3168ad14d38b7..4fd32f337f9cbb878419794e966fe8b47851a75a 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/ioctl.h>
 #include <linux/time.h>
+#include <linux/compat.h>
 
 enum android_alarm_type {
        /* return code bit numbers or set alarm arg */
@@ -59,4 +60,22 @@ enum android_alarm_return_flags {
 #define ANDROID_ALARM_BASE_CMD(cmd)         (cmd & ~(_IOC(0, 0, 0xf0, 0)))
 #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd)    (_IOC_NR(cmd) >> 4)
 
+
+#ifdef CONFIG_COMPAT
+#define ANDROID_ALARM_SET_COMPAT(type)         ALARM_IOW(2, type, \
+                                                       struct compat_timespec)
+#define ANDROID_ALARM_SET_AND_WAIT_COMPAT(type)        ALARM_IOW(3, type, \
+                                                       struct compat_timespec)
+#define ANDROID_ALARM_GET_TIME_COMPAT(type)    ALARM_IOW(4, type, \
+                                                       struct compat_timespec)
+#define ANDROID_ALARM_SET_RTC_COMPAT           _IOW('a', 5, \
+                                                       struct compat_timespec)
+#define ANDROID_ALARM_IOCTL_NR(cmd)            (_IOC_NR(cmd) & ((1<<4)-1))
+#define ANDROID_ALARM_COMPAT_TO_NORM(cmd)  \
+                               ALARM_IOW(ANDROID_ALARM_IOCTL_NR(cmd), \
+                                       ANDROID_ALARM_IOCTL_TO_TYPE(cmd), \
+                                       struct timespec)
+
+#endif
+
 #endif
index 2d12e8a1f82ee06b89f8be1127e644c16ead8994..538ebe213129f61fdbe414ebe7d666703958806e 100644 (file)
@@ -3227,7 +3227,7 @@ static void print_binder_proc(struct seq_file *m,
                m->count = start_pos;
 }
 
-static const char *binder_return_strings[] = {
+static const char * const binder_return_strings[] = {
        "BR_ERROR",
        "BR_OK",
        "BR_TRANSACTION",
@@ -3248,7 +3248,7 @@ static const char *binder_return_strings[] = {
        "BR_FAILED_REPLY"
 };
 
-static const char *binder_command_strings[] = {
+static const char * const binder_command_strings[] = {
        "BC_TRANSACTION",
        "BC_REPLY",
        "BC_ACQUIRE_RESULT",
@@ -3268,7 +3268,7 @@ static const char *binder_command_strings[] = {
        "BC_DEAD_BINDER_DONE"
 };
 
-static const char *binder_objstat_strings[] = {
+static const char * const binder_objstat_strings[] = {
        "proc",
        "thread",
        "node",
index 2f7d195d8b154e2ddf0ca872cd720b8784853168..76ead8dac265a7ca8cfb534c2095cff7d842fc3a 100644 (file)
@@ -163,7 +163,7 @@ struct binder_pri_ptr_cookie {
        void *cookie;
 };
 
-enum BinderDriverReturnProtocol {
+enum binder_driver_return_protocol {
        BR_ERROR = _IOR('r', 0, int),
        /*
         * int: error code
@@ -251,7 +251,7 @@ enum BinderDriverReturnProtocol {
         */
 };
 
-enum BinderDriverCommandProtocol {
+enum binder_driver_command_protocol {
        BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data),
        BC_REPLY = _IOW('c', 1, struct binder_transaction_data),
        /*
index f57794827f730e135e3435fc76658d3f27581c20..1d8bf08b5bfd4e946a892ddc358dfd18387e2aab 100644 (file)
@@ -95,7 +95,7 @@ struct bcm_classifier_rule {
        UCHAR           ucDirection;
        BOOLEAN         bIpv6Protocol;
        UINT32          u32PHSRuleID;
-       S_PHS_RULE      sPhsRule;
+       struct bcm_phs_rule sPhsRule;
        UCHAR           u8AssociatedPHSI;
 
        /* Classification fields for ETH CS */
@@ -288,7 +288,7 @@ struct bcm_mini_adapter {
        wait_queue_head_t       ioctl_fw_dnld_wait_queue;
        BOOLEAN                 waiting_to_fw_download_done;
        pid_t                   fw_download_process_pid;
-       PSTARGETPARAMS          pstargetparams;
+       struct bcm_target_params *pstargetparams;
        BOOLEAN                 device_removed;
        BOOLEAN                 DeviceAccess;
        BOOLEAN                 bIsAutoCorrectEnabled;
@@ -303,10 +303,10 @@ struct bcm_mini_adapter {
        struct task_struct      *transmit_packet_thread;
 
        /* LED Related Structures */
-       LED_INFO_STRUCT         LEDInfo;
+       struct bcm_led_info     LEDInfo;
 
        /* Driver State for LED Blinking */
-       LedEventInfo_t          DriverState;
+       enum bcm_led_events     DriverState;
        /* Interface Specific */
        PVOID                   pvInterfaceAdapter;
        int (*bcm_file_download)(PVOID,
@@ -333,7 +333,7 @@ struct bcm_mini_adapter {
        /* BOOLEAN                      bTriedToWakeUpFromShutdown; */
        BOOLEAN                 bLinkDownRequested;
        int                     downloadDDR;
-       PHS_DEVICE_EXTENSION    stBCMPhsContext;
+       struct bcm_phs_extension stBCMPhsContext;
        struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo;
        uint8_t                 ucaPHSPktRestoreBuf[2048];
        uint8_t                 bPHSEnabled;
@@ -345,7 +345,7 @@ struct bcm_mini_adapter {
        struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
        atomic_t                uiMBupdate;
        UINT32                  PmuMode;
-       NVM_TYPE                eNVMType;
+       enum bcm_nvm_type       eNVMType;
        UINT                    uiSectorSize;
        UINT                    uiSectorSizeInCFG;
        BOOLEAN                 bSectorSizeOverride;
@@ -366,9 +366,9 @@ struct bcm_mini_adapter {
        struct device           *pstCreatedClassDevice;
 
        /*      BOOLEAN                         InterfaceUpStatus; */
-       PFLASH2X_CS_INFO        psFlash2xCSInfo;
-       PFLASH_CS_INFO          psFlashCSInfo;
-       PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo;
+       struct bcm_flash2x_cs_info *psFlash2xCSInfo;
+       struct bcm_flash_cs_info *psFlashCSInfo;
+       struct bcm_flash2x_vendor_info *psFlash2xVendorInfo;
        UINT                    uiFlashBaseAdd; /* Flash start address */
        UINT                    uiActiveISOOffset; /* Active ISO offset chosen before f/w download */
        enum bcm_flash2x_section_val eActiveISO; /* Active ISO section val */
@@ -392,7 +392,7 @@ struct bcm_mini_adapter {
        struct semaphore        LowPowerModeSync;
        ULONG                   liDrainCalculated;
        UINT                    gpioBitMap;
-       S_BCM_DEBUG_STATE       stDebugState;
+       struct bcm_debug_state  stDebugState;
 };
 
 #define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
index efad33e3ba738df98dc9285d0a58769b61e97637..491e2bfbc46487a51cbb4e62ef71613876b0cddb 100644 (file)
@@ -1013,7 +1013,7 @@ cntrlEnd:
        }
 
        case IOCTL_BCM_GET_CURRENT_STATUS: {
-               LINK_STATE link_state;
+               struct bcm_link_state link_state;
 
                /* Copy Ioctl Buffer structure */
                if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) {
@@ -1229,13 +1229,13 @@ cntrlEnd:
        case IOCTL_BCM_SET_DEBUG:
 #ifdef DEBUG
        {
-               USER_BCM_DBG_STATE sUserDebugState;
+               struct bcm_user_debug_state sUserDebugState;
 
                BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n");
                if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer)))
                        return -EFAULT;
 
-               if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE)))
+               if (copy_from_user(&sUserDebugState, IoBuffer.InputBuffer, sizeof(struct bcm_user_debug_state)))
                        return -EFAULT;
 
                BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ",
@@ -1783,16 +1783,16 @@ cntrlEnd:
                }
 
                if (IsFlash2x(Adapter) == TRUE) {
-                       if (IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO))
+                       if (IoBuffer.OutputLength < sizeof(struct bcm_flash2x_cs_info))
                                return -EINVAL;
 
-                       if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO)))
+                       if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlash2xCSInfo, sizeof(struct bcm_flash2x_cs_info)))
                                return -EFAULT;
                } else {
-                       if (IoBuffer.OutputLength < sizeof(FLASH_CS_INFO))
+                       if (IoBuffer.OutputLength < sizeof(struct bcm_flash_cs_info))
                                return -EINVAL;
 
-                       if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO)))
+                       if (copy_to_user(IoBuffer.OutputBuffer, Adapter->psFlashCSInfo, sizeof(struct bcm_flash_cs_info)))
                                return -EFAULT;
                }
        }
index 23ddc3d7c9ea9f134bd452f5f4673209fe835c59..976514502927a116466ca5cc5ec3181148a20b4b 100644 (file)
@@ -113,7 +113,7 @@ static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIn
 static inline VOID
 CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry,
                B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc,
-               BOOLEAN bIpVersion6, E_IPADDR_CONTEXT eIpAddrContext)
+               BOOLEAN bIpVersion6, enum bcm_ipaddr_context eIpAddrContext)
 {
        int i = 0;
        UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS;
@@ -440,7 +440,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
        B_UINT16 u16PacketClassificationRuleIndex = 0;
        int i;
        struct bcm_convergence_types *psfCSType = NULL;
-       S_PHS_RULE sPhsRule;
+       struct bcm_phs_rule sPhsRule;
        USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
        UINT UGIValue = 0;
 
@@ -703,7 +703,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer
                                                        /* Update PHS Rule For the Classifier */
                                                        if (sPhsRule.u8PHSI) {
                                                                Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI;
-                                                               memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(S_PHS_RULE));
+                                                               memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule, &sPhsRule, sizeof(struct bcm_phs_rule));
                                                        }
                                                }
                                        }
index eecad8d90aeaba7fdb7a12d71591f05c408d267b..4ddfc3d45bc0145d9be4bb4d1efe936d3c5500e8 100644 (file)
@@ -27,32 +27,28 @@ struct bcm_add_indication_alt {
        u8      u8Type;
        u8      u8Direction;
        u16     u16TID;
-       /* brief 16bitCID */
        u16     u16CID;
-       /* brief 16bitVCID */
        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;  /* < 8-bit Padding */
-       u16     u16Padd; /* < 16 bit Padding */
+       u8      u8Padd;
+       u16     u16Padd;
 };
 
 struct bcm_change_indication {
        u8      u8Type;
        u8      u8Direction;
        u16     u16TID;
-       /* brief 16bitCID */
        u16     u16CID;
-       /* brief 16bitVCID */
        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;  /* < 8-bit Padding */
-       u16     u16Padd; /* < 16 bit */
+       u8      u8Padd;
+       u16     u16Padd;
 };
 
 unsigned long StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, void *pvBuffer, unsigned int *puBufferLength);
index 8018a189f817148e31285681679447f9bf0d7564..7b331215c1acc985c2cbc4fc6e603fe7474e2bdc 100644 (file)
 #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.
  */
-/*-----------------BEGIN TYPEs------------------------------------------*/
-#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
-/*-----------------END TYPEs------------------------------------------*/
-#define NUMTYPES                       4               // careful!
-
-/*-----------------BEGIN SUBTYPEs---------------------------------------*/
-
-/*-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
-// ??ISR.C
-
-#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)
-/*-----------------END SUBTYPEs------------------------------------------*/
-
+#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.
@@ -157,57 +144,58 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */
  * 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
+#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
+ * 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.
+ * 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
+#define DBG_LVL_ALL    BCM_ALL
 
-/*---Userspace mapping of Debug State.
+/* ---Userspace mapping of Debug State.
  * Delibrately matches that of the Windows driver..
  * The TestApp's ioctl passes this struct to us.
  */
-typedef struct
-{
+struct bcm_user_debug_state {
        unsigned int Subtype, Type;
        unsigned int OnOff;
-//     unsigned int debug_level;        /* future expansion */
-} __attribute__((packed)) USER_BCM_DBG_STATE;
+/*     unsigned int debug_level; future expansion */
+} __packed;
 
-//---Kernel-space mapping of Debug State
-typedef struct _S_BCM_DEBUG_STATE {
-       UINT type;
+/* ---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 !
         */
-       UINT subtype[(NUMTYPES*2)+1];
-       UINT debug_level;
-} S_BCM_DEBUG_STATE;
-/* 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
+       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.
+/* --- Only for direct printk's; "hidden" to API. */
 #define DBG_TYPE_PRINTK                3
 
 #define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) \
@@ -215,40 +203,40 @@ typedef struct _S_BCM_DEBUG_STATE {
                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])) { \
+                       (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)              \
-                               printk(KERN_DEBUG string, ##args);      \
+                               pr_debug("%s:\n", string);      \
                        else                                            \
-                               printk(KERN_DEBUG "%s:" string, __func__, ##args);      \
+                               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]))) {        \
-               printk(KERN_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++) {              \
+#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]);   \
+                       /* 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
-
index 4745ddd62f5b335425bb3dc56984b7a87d5b0f71..6d803e7b094a819a8d76efe0879d15da4e48eec9 100644 (file)
@@ -1,10 +1,10 @@
 #include "headers.h"
 
 static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       IPV6Header *pstIpv6Header);
+       struct bcm_ipv6_hdr *pstIpv6Header);
 static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       IPV6Header *pstIpv6Header);
-static VOID DumpIpv6Header(IPV6Header *pstIpv6Header);
+       struct bcm_ipv6_hdr *pstIpv6Header);
+static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header);
 
 static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
        UCHAR *pucNextHeader, BOOLEAN *bParseDone, USHORT *pusPayloadLength)
@@ -38,17 +38,17 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
 
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
                                        DBG_LVL_ALL, "\nIPv6 HopByHop Header");
-                       usNextHeaderOffset += sizeof(IPV6HopByHopOptionsHeader);
+                       usNextHeaderOffset += sizeof(struct bcm_ipv6_options_hdr);
                }
                break;
 
        case IPV6HDR_TYPE_ROUTING:
                {
-                       IPV6RoutingHeader *pstIpv6RoutingHeader;
+                       struct bcm_ipv6_routing_hdr *pstIpv6RoutingHeader;
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
                                        DBG_LVL_ALL, "\nIPv6 Routing Header");
-                       pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr;
-                       usNextHeaderOffset += sizeof(IPV6RoutingHeader);
+                       pstIpv6RoutingHeader = (struct bcm_ipv6_routing_hdr *)pucPayloadPtr;
+                       usNextHeaderOffset += sizeof(struct bcm_ipv6_routing_hdr);
                        usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES;
 
                }
@@ -58,25 +58,25 @@ static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
                                        DBG_LVL_ALL,
                                        "\nIPv6 Fragmentation Header");
-                       usNextHeaderOffset += sizeof(IPV6FragmentHeader);
+                       usNextHeaderOffset += sizeof(struct bcm_ipv6_fragment_hdr);
 
                }
                break;
        case IPV6HDR_TYPE_DESTOPTS:
                {
-                       IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr;
+                       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(IPV6DestOptionsHeader);
+                       usNextHeaderOffset += sizeof(struct bcm_ipv6_dest_options_hdr);
                        usNextHeaderOffset += nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ;
 
                }
                break;
        case IPV6HDR_TYPE_AUTHENTICATION:
                {
-                       IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr;
+                       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,
@@ -186,13 +186,13 @@ USHORT    IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
        USHORT  ushDestPort = 0;
        USHORT  ushSrcPort = 0;
        UCHAR   ucNextProtocolAboveIP = 0;
-       IPV6Header *pstIpv6Header = NULL;
+       struct bcm_ipv6_hdr *pstIpv6Header = NULL;
        BOOLEAN bClassificationSucceed = FALSE;
 
        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
                        DBG_LVL_ALL, "IpVersion6 ==========>\n");
 
-       pstIpv6Header = (IPV6Header *)pcIpHeader;
+       pstIpv6Header = (struct bcm_ipv6_hdr *)pcIpHeader;
 
        DumpIpv6Header(pstIpv6Header);
 
@@ -200,7 +200,7 @@ USHORT      IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
         * Try to get the next higher layer protocol
         * and the Ports Nos if TCP or UDP
         */
-       ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)),
+       ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(struct bcm_ipv6_hdr)),
                                                        &ushSrcPort,
                                                        &ushDestPort,
                                                        pstIpv6Header->usPayloadLength,
@@ -289,7 +289,7 @@ USHORT      IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
 
 
 static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       IPV6Header *pstIpv6Header)
+       struct bcm_ipv6_hdr *pstIpv6Header)
 {
        UINT uiLoopIndex = 0;
        UINT uiIpv6AddIndex = 0;
@@ -345,7 +345,7 @@ static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule
 }
 
 static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
-       IPV6Header *pstIpv6Header)
+       struct bcm_ipv6_hdr *pstIpv6Header)
 {
        UINT uiLoopIndex = 0;
        UINT uiIpv6AddIndex = 0;
@@ -414,7 +414,7 @@ VOID DumpIpv6Address(ULONG *puIpv6Address)
 
 }
 
-static VOID DumpIpv6Header(IPV6Header *pstIpv6Header)
+static VOID DumpIpv6Header(struct bcm_ipv6_hdr *pstIpv6Header)
 {
        UCHAR ucVersion;
        UCHAR ucPrio;
index 8ba88a5b081c46ca22728df0b0e90afa5079b7f9..96b36a579af202b9d8419bcb99e6c9fe22b3d195 100644 (file)
@@ -1,7 +1,6 @@
 #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_ENCRYPTEDSECURITYPAYLOAD 0x34
 #define MASK_IPV6_CS_SPEC 0x2
 
-
-#define TCP_HEADER_TYPE 0x6
-#define UDP_HEADER_TYPE 0x11
+#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.
-*/
+ * Size of Dest Options field of Destinations Options Header
+ * in bytes.
+ */
 #define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8
 
-//typedef  unsigned char UCHAR;
-//typedef  unsigned short USHORT;
-//typedef  unsigned long int ULONG;
-
-typedef struct IPV6HeaderFormatTag
-{
-       UCHAR  ucVersionPrio;
-       UCHAR  aucFlowLabel[3];
-       USHORT usPayloadLength;
-       UCHAR  ucNextHeader;
-       UCHAR  ucHopLimit;
-       ULONG  ulSrcIpAddress[4];
-       ULONG  ulDestIpAddress[4];
-}IPV6Header;
-
-typedef struct IPV6RoutingHeaderFormatTag
-{
-       UCHAR ucNextHeader;
-       UCHAR ucRoutingType;
-       UCHAR ucNumAddresses;
-       UCHAR ucNextAddress;
-       ULONG ulReserved;
-       //UCHAR aucAddressList[0];
-
-}IPV6RoutingHeader;
-
-typedef struct IPV6FragmentHeaderFormatTag
-{
-       UCHAR ucNextHeader;
-       UCHAR ucReserved;
-       USHORT usFragmentOffset;
-       ULONG  ulIdentification;
-}IPV6FragmentHeader;
-
-typedef struct IPV6DestOptionsHeaderFormatTag
-{
-       UCHAR ucNextHeader;
-       UCHAR ucHdrExtLen;
-       UCHAR ucDestOptions[6];
-       //UCHAR udExtDestOptions[0];
-}IPV6DestOptionsHeader;
-
-typedef struct IPV6HopByHopOptionsHeaderFormatTag
-{
-       UCHAR ucNextHeader;
-       UCHAR ucMisc[3];
-       ULONG ulJumboPayloadLen;
-}IPV6HopByHopOptionsHeader;
-
-typedef struct IPV6AuthenticationHeaderFormatTag
-{
-       UCHAR ucNextHeader;
-       UCHAR ucLength;
-       USHORT usReserved;
-       ULONG  ulSecurityParametersIndex;
-       //UCHAR  ucAuthenticationData[0];
-
-}IPV6AuthenticationHeader;
-
-typedef struct IPV6IcmpHeaderFormatTag
-{
-       UCHAR ucType;
-       UCHAR ucCode;
-       USHORT usChecksum;
-       //UCHAR  ucIcmpMsg[0];
-
-}IPV6IcmpHeader;
-
-typedef enum _E_IPADDR_CONTEXT
-{
+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
+};
 
-}E_IPADDR_CONTEXT;
-
-
-
-//Function Prototypes
-
-USHORT IpVersion6(struct bcm_mini_adapter *Adapter, /**< Pointer to the driver control structure */
-                                       PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
-                                       struct bcm_classifier_rule *pstClassifierRule );
+/* Function Prototypes */
 
-VOID DumpIpv6Address(ULONG *puIpv6Address);
+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);
 
-extern BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
-extern BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
-extern BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
+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
index 87117a797d5bff1b78efec79d342eb133f010df8..64ea6edb9dc2b8c39c260ee9eeb204aead27afc3 100644 (file)
@@ -138,12 +138,12 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm
        B_UINT32 value = 0;
 
        if (Adapter->pstargetparams == NULL) {
-               Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL);
+               Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL);
                if (Adapter->pstargetparams == NULL)
                        return -ENOMEM;
        }
 
-       if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS))
+       if (psFwInfo->u32FirmwareLength != sizeof(struct bcm_target_params))
                return -EIO;
 
        retval = copy_from_user(Adapter->pstargetparams, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
@@ -195,7 +195,7 @@ static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm
                }
        }
 
-       retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(STARGETPARAMS), CONFIG_BEGIN_ADDR);
+       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");
index 8c70af90969bfcebae918d60917d9932eda57fef..e253c080a787e6fc4c39be37ec6a12618723b794 100644 (file)
@@ -108,7 +108,7 @@ enum bcm_interface_type {
 };
 
 struct bcm_driver_info {
-       NVM_TYPE        u32NVMType;
+       enum bcm_nvm_type       u32NVMType;
        unsigned int            MaxRDMBufferSize;
        enum bcm_interface_type u32InterfaceType;
        unsigned int            u32DSDStartOffset;
@@ -202,8 +202,8 @@ struct bcm_flash2x_bitmap {
 };
 
 struct bcm_time_elapsed {
-       unsigned long long ul64TimeElapsedSinceNetEntry;
-       u32  uiReserved[4];
+       u64 ul64TimeElapsedSinceNetEntry;
+       u32 uiReserved[4];
 };
 
 enum {
index 46f5f0feea889d7e689d13975125b49b4bfcfbdd..dc01e3016d4fc7e5f5db734f5ae81db324e85a96 100644 (file)
 #define GPIO_MODE_REGISTER       0x0F000034
 #define GPIO_PIN_STATE_REGISTER  0x0F000038
 
-
-typedef struct _LINK_STATE {
-       UCHAR ucLinkStatus;
-       UCHAR bIdleMode;
-       UCHAR bShutdownMode;
-} LINK_STATE, *PLINK_STATE;
-
+struct bcm_link_state {
+       unsigned char ucLinkStatus;
+       unsigned char bIdleMode;
+       unsigned char bShutdownMode;
+};
 
 enum enLinkStatus {
        WAIT_FOR_SYNC = 1,
@@ -182,13 +180,12 @@ enum enLinkStatus {
        COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW = 9
 };
 
-typedef enum _E_PHS_DSC_ACTION {
+enum bcm_phs_dsc_action {
        eAddPHSRule = 0,
        eSetPHSRule,
        eDeletePHSRule,
        eDeleteAllPHSRules
-} E_PHS_DSC_ACTION;
-
+};
 
 #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ  0x89 /* Host to Mac */
 #define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 /* Mac to Host */
@@ -324,18 +321,18 @@ typedef enum _E_PHS_DSC_ACTION {
 #define HPM_CONFIG_MSW    0x0F000D58
 
 #define T3B 0xbece0310
-typedef enum eNVM_TYPE {
+enum bcm_nvm_type {
        NVM_AUTODETECT = 0,
        NVM_EEPROM,
        NVM_FLASH,
        NVM_UNKNOWN
-} NVM_TYPE;
+};
 
-typedef enum ePMU_MODES {
+enum bcm_pmu_modes {
        HYBRID_MODE_7C  = 0,
        INTERNAL_MODE_6 = 1,
        HYBRID_MODE_6   = 2
-} PMU_MODE;
+};
 
 #define MAX_RDM_WRM_RETIRES 1
 
index c92078e7fe86b321937823fbd0f46c8931eae6cd..b5c2c4c15f926dc1d1dde8b7615099964bb56739 100644 (file)
@@ -956,7 +956,7 @@ int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter)
        /* Download cfg file */
        status = buffDnldVerify(ps_adapter,
                                (PUCHAR)ps_adapter->pstargetparams,
-                               sizeof(STARGETPARAMS),
+                               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");
@@ -1053,7 +1053,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
        if (!buff)
                return -ENOMEM;
 
-       Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL);
+       Adapter->pstargetparams = kmalloc(sizeof(struct bcm_target_params), GFP_KERNEL);
        if (Adapter->pstargetparams == NULL) {
                kfree(buff);
                return -ENOMEM;
@@ -1070,7 +1070,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
        len = kernel_read(flp, 0, buff, BUFFER_1K);
        filp_close(flp, NULL);
 
-       if (len != sizeof(STARGETPARAMS)) {
+       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);
@@ -1082,7 +1082,7 @@ static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
        /*
         * Values in Adapter->pstargetparams are in network byte order
         */
-       memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS));
+       memcpy(Adapter->pstargetparams, buff, sizeof(struct bcm_target_params));
        kfree(buff);
        beceem_parse_target_struct(Adapter);
        return STATUS_SUCCESS;
@@ -1134,7 +1134,7 @@ void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter)
 
        uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag);
        pr_info(DRV_NAME ": uiEEPROMFlag  : 0x%X\n", uiEEPROMFlag);
-       Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3);
+       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;
index 6016fc502d2d7e73d2aa3d432dedc6250c8dc55a..cd78ee4ffa220bd9c54adb80e8fef38e8d434a61 100644 (file)
 #ifndef BCM_PHS_DEFINES_H
 #define BCM_PHS_DEFINES_H
 
-#define PHS_INVALID_TABLE_INDEX 0xffffffff
-
-/************************* MACROS **********************************************/
+#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
-
-typedef struct _S_PHS_RULE
-{
-    /// brief 8bit PHSI Of The Service Flow
-    B_UINT8                         u8PHSI;
-    /// brief PHSF Of The Service Flow
-    B_UINT8                         u8PHSFLength;
-    B_UINT8                         u8PHSF[MAX_PHS_LENGTHS];
-    /// brief PHSM Of The Service Flow
-    B_UINT8                         u8PHSMLength;
-    B_UINT8                         u8PHSM[MAX_PHS_LENGTHS];
-    /// brief 8bit PHSS Of The Service Flow
-    B_UINT8                         u8PHSS;
-    /// brief 8bit PHSV Of The Service Flow
-    B_UINT8                         u8PHSV;
-   //Reference Count for this PHS Rule
-    B_UINT8                         u8RefCnt;
-   //Flag to Store Unclassified PHS rules only in DL
-    B_UINT8                                                    bUnclassifiedPHSRule;
-
-       B_UINT8                                                 u8Reserved[3];
-
-       LONG                                                    PHSModifiedBytes;
-       ULONG                                   PHSModifiedNumPackets;
-       ULONG                                   PHSErrorNumPackets;
-}S_PHS_RULE;
-
-
-typedef enum _E_CLASSIFIER_ENTRY_CONTEXT
-{
+/* 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
-}E_CLASSIFIER_ENTRY_CONTEXT;
-
-typedef struct _S_CLASSIFIER_ENTRY
-{
-       B_UINT8  bUsed;
-       B_UINT16 uiClassifierRuleId;
-       B_UINT8  u8PHSI;
-       S_PHS_RULE *pstPhsRule;
-       B_UINT8 bUnclassifiedPHSRule;
-
-}S_CLASSIFIER_ENTRY;
-
-
-typedef struct _S_CLASSIFIER_TABLE
-{
-       B_UINT16 uiTotalClassifiers;
-       S_CLASSIFIER_ENTRY stActivePhsRulesList[MAX_PHSRULE_PER_SF];
-       S_CLASSIFIER_ENTRY stOldPhsRulesList[MAX_PHSRULE_PER_SF];
-       B_UINT16    uiOldestPhsRuleIndex;
-
-}S_CLASSIFIER_TABLE;
-
-
-typedef struct _S_SERVICEFLOW_ENTRY
-{
-       B_UINT8         bUsed;
-       B_UINT16    uiVcid;
-       S_CLASSIFIER_TABLE  *pstClassifierTable;
-}S_SERVICEFLOW_ENTRY;
-
-typedef struct _S_SERVICEFLOW_TABLE
-{
-       B_UINT16 uiTotalServiceFlows;
-       S_SERVICEFLOW_ENTRY stSFList[MAX_SERVICEFLOWS];
-
-}S_SERVICEFLOW_TABLE;
-
-
-typedef struct _PHS_DEVICE_EXTENSION
-{
-       /* PHS Specific data*/
-       S_SERVICEFLOW_TABLE *pstServiceFlowPhsRulesTable;
-       void   *CompressedTxBuffer;
-       void   *UnCompressedRxBuffer;
-}PHS_DEVICE_EXTENSION,*PPHS_DEVICE_EXTENSION;
-
+};
+
+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
index 6dc0bbcfeab01ac960713d81b0f46d9b64a5c126..7028bc95b4f9413933d66a7717a7a89235e879aa 100644 (file)
@@ -1,24 +1,24 @@
 #include "headers.h"
 
-static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16  uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI);
+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,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_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,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,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,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,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 BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule);
+static BOOLEAN ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule);
 
-static BOOLEAN DerefPhsRule(B_UINT16  uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule);
+static BOOLEAN DerefPhsRule(B_UINT16  uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule);
 
-static UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry);
+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(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule);
+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(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable);
+static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable);
 
-static int phs_compress(S_PHS_RULE   *phs_members,unsigned char *in_buf,
+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 );
 
 
@@ -26,7 +26,7 @@ static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buff
                                                                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,\
-                                                 S_PHS_RULE   *phs_rules,UINT *header_size);
+                                                 struct bcm_phs_rule *phs_rules, UINT *header_size);
 
 
 static ULONG PhsCompress(void* pvContext,
@@ -291,17 +291,17 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
 // TRUE(1)     -If allocation of memory was success full.
 // FALSE       -If allocation of memory fails.
 //-----------------------------------------------------------------------------
-int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter *Adapter)
+int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adapter *Adapter)
 {
        int i;
-       S_SERVICEFLOW_TABLE *pstServiceFlowTable;
+       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(S_SERVICEFLOW_TABLE), GFP_KERNEL);
+               kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL);
 
     if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
        {
@@ -312,8 +312,8 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter
        pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
        for(i=0;i<MAX_SERVICEFLOWS;i++)
        {
-               S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i];
-               sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL);
+               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");
@@ -351,7 +351,7 @@ int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter
 }
 
 
-int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt)
+int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt)
 {
        if(pPHSDeviceExt->pstServiceFlowPhsRulesTable)
        {
@@ -381,7 +381,7 @@ 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 S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table.
+       IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table.
 
 Return Value:
 
@@ -392,17 +392,17 @@ Return Value:
 ULONG PhsUpdateClassifierRule(IN void* pvContext,
                                                                IN B_UINT16  uiVcid ,
                                                                IN B_UINT16  uiClsId   ,
-                                                               IN S_PHS_RULE *psPhsRule,
+                                                               IN struct bcm_phs_rule *psPhsRule,
                                                                IN B_UINT8  u8AssociatedPHSI)
 {
        ULONG lStatus =0;
        UINT nSFIndex =0 ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
 
 
-       PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+       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");
 
@@ -460,12 +460,12 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
 {
        ULONG lStatus =0;
        UINT nSFIndex =0, nClsidIndex =0 ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
+       struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
 
-       PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+       struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext;
 
        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n");
 
@@ -495,7 +495,7 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
                                                if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
                                                        kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
                                                memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0,
-                                                       sizeof(S_CLASSIFIER_ENTRY));
+                                                       sizeof(struct bcm_phs_classifier_entry));
                                        }
                                }
                        }
@@ -526,10 +526,10 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
 {
        ULONG lStatus =0;
        UINT nSFIndex =0, nClsidIndex =0 ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
+       struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+       struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext;
 
        if(pDeviceExtension)
        {
@@ -554,7 +554,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
                                        kfree(pstClassifierEntry->pstPhsRule);
 
                        }
-                       memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY));
+                       memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry));
                }
 
                nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
@@ -563,7 +563,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
           if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
                {
                        kfree(pstClassifierEntry->pstPhsRule);
-                       memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY));
+                       memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry));
                }
        }
        return lStatus;
@@ -590,10 +590,10 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
 
        ULONG lStatus =0;
        UINT nSFIndex =0, nClsidIndex =0  ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
+       struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+       struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext;
     BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n");
 
        if(pDeviceExtension)
@@ -624,7 +624,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
                                            pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
                                         .pstPhsRule = NULL;
                                }
-                               memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
+                               memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry));
                                if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule)
                                {
                                        if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
@@ -638,7 +638,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
                                        pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
                               .pstPhsRule = NULL;
                                }
-                               memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
+                               memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry));
                        }
                }
                pstServiceFlowEntry->bUsed = FALSE;
@@ -680,15 +680,15 @@ ULONG PhsCompress(IN void* pvContext,
                                  OUT UINT *pNewHeaderSize )
 {
        UINT nSFIndex =0, nClsidIndex =0  ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
-       S_PHS_RULE *pstPhsRule = NULL;
+       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);
 
 
 
-       PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+       struct bcm_phs_extension *pDeviceExtension= (struct bcm_phs_extension *)pvContext;
 
 
        if(pDeviceExtension == NULL)
@@ -775,12 +775,12 @@ ULONG PhsDeCompress(IN void* pvContext,
                                  OUT UINT *pOutHeaderSize )
 {
        UINT nSFIndex =0, nPhsRuleIndex =0 ;
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_PHS_RULE *pstPhsRule = NULL;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
+       struct bcm_phs_rule *pstPhsRule = NULL;
        UINT phsi;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       PPHS_DEVICE_EXTENSION pDeviceExtension=
-        (PPHS_DEVICE_EXTENSION)pvContext;
+       struct bcm_phs_extension *pDeviceExtension=
+        (struct bcm_phs_extension *)pvContext;
 
        *pInHeaderSize = 0;
 
@@ -844,7 +844,7 @@ ULONG PhsDeCompress(IN void* pvContext,
 // Does not return any value.
 //-----------------------------------------------------------------------------
 
-static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
+static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable)
 {
        int i,j;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -854,9 +854,9 @@ static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTa
        {
                for(i=0;i<MAX_SERVICEFLOWS;i++)
                {
-                       S_SERVICEFLOW_ENTRY stServiceFlowEntry =
+                       struct bcm_phs_entry stServiceFlowEntry =
                 psServiceFlowRulesTable->stSFList[i];
-                       S_CLASSIFIER_TABLE *pstClassifierRulesTable =
+                       struct bcm_phs_classifier_table *pstClassifierRulesTable =
                 stServiceFlowEntry.pstClassifierTable;
 
                        if(pstClassifierRulesTable)
@@ -898,7 +898,7 @@ static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTa
 
 
 
-static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule)
+static BOOLEAN ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule)
 {
        if(psPhsRule)
        {
@@ -927,8 +927,8 @@ static BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule)
        }
 }
 
-UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable,
-    IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry)
+UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,
+    IN B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry)
 {
        int  i;
        for(i=0;i<MAX_SERVICEFLOWS;i++)
@@ -948,12 +948,12 @@ UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable,
 }
 
 
-UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
-        IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
-        OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry)
+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;
-       S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
+       struct bcm_phs_classifier_entry *psClassifierRules = NULL;
        for(i=0;i<MAX_PHSRULE_PER_SF;i++)
        {
 
@@ -981,12 +981,12 @@ UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
        return PHS_INVALID_TABLE_INDEX;
 }
 
-static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
-                           IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
-                           OUT S_PHS_RULE **ppstPhsRule)
+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;
-       S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
+       struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
        for(i=0;i<MAX_PHSRULE_PER_SF;i++)
        {
                if(eClsContext == eActiveClassifierRuleContext)
@@ -1013,11 +1013,11 @@ static UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
 }
 
 UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16  uiClsId,
-                      IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,
+                      IN struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule,
                       B_UINT8 u8AssociatedPHSI)
 {
 
-    S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
+       struct bcm_phs_classifier_table *psaClassifiertable = NULL;
        UINT uiStatus = 0;
        int iSfIndex;
        BOOLEAN bFreeEntryFound =FALSE;
@@ -1050,13 +1050,13 @@ UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16  uiClsId,
 }
 
 UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
-            IN B_UINT16  uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,
-              S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI)
+            IN B_UINT16  uiClsId,IN struct bcm_phs_entry *pstServiceFlowEntry,
+              struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI)
 {
-       S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
+       struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
        UINT uiStatus =PHS_SUCCESS;
        UINT nClassifierIndex = 0;
-       S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
+       struct bcm_phs_classifier_table *psaClassifiertable = NULL;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
     psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
 
@@ -1141,12 +1141,12 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
 }
 
 static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
-    S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
-    E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI)
+    struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule,
+    enum bcm_phs_classifier_context eClsContext,B_UINT8 u8AssociatedPHSI)
 {
        UINT iClassifierIndex = 0;
        BOOLEAN bFreeEntryFound = FALSE;
-       S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
+       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");
@@ -1227,7 +1227,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
        {
                if(psClassifierRules->pstPhsRule == NULL)
                {
-                       psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL);
+                       psClassifierRules->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule),GFP_KERNEL);
 
           if(NULL == psClassifierRules->pstPhsRule)
                                return ERR_PHSRULE_MEMALLOC_FAIL;
@@ -1240,7 +1240,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
 
         /* Update The PHS rule */
                memcpy(psClassifierRules->pstPhsRule,
-                   psPhsRule, sizeof(S_PHS_RULE));
+                   psPhsRule, sizeof(struct bcm_phs_rule));
        }
        else
        {
@@ -1252,11 +1252,11 @@ static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
 
 
 static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,
-      IN S_CLASSIFIER_ENTRY *pstClassifierEntry,
-      S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
+      IN struct bcm_phs_classifier_entry *pstClassifierEntry,
+      struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule,
       B_UINT8 u8AssociatedPHSI)
 {
-       S_PHS_RULE *pstAddPhsRule = NULL;
+       struct bcm_phs_rule *pstAddPhsRule = NULL;
        UINT              nPhsRuleIndex = 0;
        BOOLEAN       bPHSRuleOrphaned = FALSE;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -1281,13 +1281,13 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,
                //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId
                if(FALSE == bPHSRuleOrphaned)
                {
-                       pstClassifierEntry->pstPhsRule = kmalloc(sizeof(S_PHS_RULE), GFP_KERNEL);
+                       pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL);
                        if(NULL == pstClassifierEntry->pstPhsRule)
                        {
                                return ERR_PHSRULE_MEMALLOC_FAIL;
                        }
                }
-               memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE));
+               memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule));
 
        }
        else
@@ -1312,7 +1312,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,
 
 }
 
-static BOOLEAN DerefPhsRule(IN B_UINT16  uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule)
+static BOOLEAN DerefPhsRule(IN B_UINT16  uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule)
 {
        if(pstPhsRule==NULL)
                return FALSE;
@@ -1331,14 +1331,14 @@ static BOOLEAN DerefPhsRule(IN B_UINT16  uiClsId,S_CLASSIFIER_TABLE *psaClassifi
        }
 }
 
-void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
+void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)
 {
        int i,j,k,l;
        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++)
        {
-               S_SERVICEFLOW_ENTRY stServFlowEntry =
+               struct bcm_phs_entry stServFlowEntry =
                                pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i];
                if(stServFlowEntry.bUsed)
                {
@@ -1346,7 +1346,7 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
                        {
                                for(l=0;l<2;l++)
                                {
-                                       S_CLASSIFIER_ENTRY stClsEntry;
+                                       struct bcm_phs_classifier_entry stClsEntry;
                                        if(l==0)
                                        {
                                                stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j];
@@ -1408,10 +1408,10 @@ void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
 //-----------------------------------------------------------------------------
 
 int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
S_PHS_RULE   *decomp_phs_rules,UINT *header_size)
              struct bcm_phs_rule *decomp_phs_rules, UINT *header_size)
 {
        int phss,size=0;
-        S_PHS_RULE   *tmp_memb;
+       struct bcm_phs_rule *tmp_memb;
        int bit,i=0;
        unsigned char *phsf,*phsm;
        int in_buf_len = *header_size-1;
@@ -1490,7 +1490,7 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
 //     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(S_PHS_RULE  *phs_rule,unsigned char *in_buf
+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;
index b5f21157ac472f319e5a43309377b2b70765ad52..82d8682841809d17858e4f8f43f7db66e9a0383e 100644 (file)
@@ -22,15 +22,15 @@ void DumpDataPacketHeader(PUCHAR pPkt);
 
 void DumpFullPacket(UCHAR *pBuf,UINT nPktLen);
 
-void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
+void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension);
 
 
-int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,struct bcm_mini_adapter *Adapter);
+int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,struct bcm_mini_adapter *Adapter);
 
-int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt);
+int PhsCleanup(struct bcm_phs_extension *pPHSDeviceExt);
 
 //Utility Functions
-ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId,S_PHS_RULE *psPhsRule,B_UINT8  u8AssociatedPHSI );
+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);
 
@@ -39,12 +39,12 @@ ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16  uiClsI
 ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ;
 
 
-BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule);
+BOOLEAN ValidatePHSRule(struct bcm_phs_rule *psPhsRule);
 
-UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry);
+UINT GetServiceFlowEntry(struct bcm_phs_table *psServiceFlowTable,B_UINT16 uiVcid, struct bcm_phs_entry **ppstServiceFlowEntry);
 
 
-void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
+void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension);
 
 
 #endif
index 562d4dd81a7c13d18a564e791f3fff2014dae7bc..9818128d9320d524d692743b8b43782f84ff0311 100644 (file)
@@ -1,98 +1,83 @@
 /************************************
-*      Protocol.h
+*      Protocol.h
 *************************************/
 #ifndef        __PROTOCOL_H__
 #define        __PROTOCOL_H__
 
-
-#define IPV4                           4
-#define IPV6                6
-
+#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        */
-}/*__attribute__((packed))*/;
-
-
-struct TransportHeaderT
-{
-       union
-       {
+       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;
        };
-} __attribute__((packed));
-typedef struct TransportHeaderT xporthdr;
-
+} __packed;
 
-typedef enum _E_NWPKT_IPFRAME_TYPE
-{
+enum bcm_ip_frame_type {
        eNonIPPacket,
        eIPv4Packet,
        eIPv6Packet
-}E_NWPKT_IPFRAME_TYPE;
+};
 
-typedef enum _E_NWPKT_ETHFRAME_TYPE
-{
+enum bcm_eth_frame_type {
        eEthUnsupportedFrame,
        eEth802LLCFrame,
        eEth802LLCSNAPFrame,
        eEth802QVLANFrame,
        eEthOtherFrame
-} E_NWPKT_ETHFRAME_TYPE;
-
-typedef struct _S_ETHCS_PKT_INFO
-{
-       E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType;
-       E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType;
-       USHORT  usEtherType;
-       UCHAR   ucDSAP;
-}S_ETHCS_PKT_INFO,*PS_ETHCS_PKT_INFO;
-
-typedef struct _ETH_CS_802_Q_FRAME
-{
+};
+
+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;
-       USHORT UserPriority:3;
-       USHORT CFI:1;
-       USHORT VLANID:12;
-       USHORT EthType;
-} __attribute__((packed)) ETH_CS_802_Q_FRAME;
-
-typedef struct _ETH_CS_802_LLC_FRAME
-{
+       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;
-}__attribute__((packed)) ETH_CS_802_LLC_FRAME;
+} __packed;
 
-typedef struct _ETH_CS_802_LLC_SNAP_FRAME
-{
+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;
-} __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME;
+} __packed;
 
-typedef struct _ETH_CS_ETH2_FRAME
-{
+struct bcm_ethernet2_frame {
        struct bcm_eth_header EThHdr;
-} __attribute__((packed)) ETH_CS_ETH2_FRAME;
+} __packed;
 
 #define ETHERNET_FRAMETYPE_IPV4                ntohs(0x0800)
-#define ETHERNET_FRAMETYPE_IPV6        ntohs(0x86dd)
-#define ETHERNET_FRAMETYPE_802QVLAN    ntohs(0x8100)
+#define ETHERNET_FRAMETYPE_IPV6                ntohs(0x86dd)
+#define ETHERNET_FRAMETYPE_802QVLAN    ntohs(0x8100)
 
-//Per SF CS Specification Encodings
-typedef enum _E_SERVICEFLOW_CS_SPEC_
-{
-       eCSSpecUnspecified =0,
+/* Per SF CS Specification Encodings */
+enum bcm_spec_encoding {
+       eCSSpecUnspecified = 0,
        eCSPacketIPV4,
        eCSPacketIPV6,
        eCS802_3PacketEthernet,
@@ -102,50 +87,42 @@ typedef enum _E_SERVICEFLOW_CS_SPEC_
        eCSPacketIPV4Over802_1QVLAN,
        eCSPacketIPV6Over802_1QVLAN,
        eCSPacketUnsupported
-}E_SERVICEFLOW_CS_SPEC;
-
-
-#define        IP6_HEADER_LEN  40
-
-#define IP_VERSION(byte)        (((byte&0xF0)>>4))
-
+};
 
+#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
-typedef struct _TCP_HEADER
-{
-       USHORT usSrcPort;
-       USHORT usDestPort;
-       ULONG  ulSeqNumber;
-       ULONG  ulAckNumber;
-       UCHAR  HeaderLength;
-    UCHAR  ucFlags;
-       USHORT usWindowsSize;
-       USHORT usChkSum;
-       USHORT usUrgetPtr;
-} TCP_HEADER,*PTCP_HEADER;
-#define TCP_HEADER_LEN         sizeof(TCP_HEADER)
-#define TCP_ACK             0x10  //Bit 4 in tcpflags field.
+#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__
+#endif /* __PROTOCOL_H__ */
index 90dbe0f4785e099d9bdcfbe640b3f39535f8b3ff..2a673b125f008e83f5f8a82b64b176a2f928ea16 100644 (file)
@@ -33,9 +33,9 @@ INT SearchSfid(struct bcm_mini_adapter *Adapter,UINT uiSfid);
 
 USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb);
 
-BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
-BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
-BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
+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*/
index 1b857bd887f0f3ab0755750987384c25149fdd41..8d142a547e7fd9e29b1037af075d225b3a51924c 100644 (file)
@@ -4,8 +4,8 @@ This file contains the routines related to Quality of Service.
 */
 #include "headers.h"
 
-static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
-static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport);
+static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo);
+static BOOLEAN 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 );
@@ -117,7 +117,7 @@ BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfSer
 *
 * Returns     - TRUE(If address matches) else FAIL.
 ****************************************************************************/
-BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol)
+bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol)
 {
        UCHAR   ucLoopIndex=0;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -146,7 +146,7 @@ BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProt
 *
 * Returns     - TRUE(If address matches) else FAIL.
 ***************************************************************************/
-BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort)
+bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort)
 {
        UCHAR   ucLoopIndex=0;
 
@@ -178,7 +178,7 @@ BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrc
 *
 * Returns     - TRUE(If address matches) else FAIL.
 ***************************************************************************/
-BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort)
+bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort)
 {
        UCHAR   ucLoopIndex=0;
        struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -208,12 +208,12 @@ static USHORT     IpVersion4(struct bcm_mini_adapter *Adapter,
                           struct iphdr *iphd,
                           struct bcm_classifier_rule *pstClassifierRule)
 {
-       xporthdr                *xprt_hdr=NULL;
+       struct bcm_transport_header *xprt_hdr = NULL;
        BOOLEAN bClassificationSucceed=FALSE;
 
        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>");
 
-       xprt_hdr=(xporthdr *)((PUCHAR)iphd + sizeof(struct iphdr));
+       xprt_hdr=(struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr));
 
        do {
                BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d",
@@ -446,7 +446,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
 {
        INT                     uiLoopIndex=0;
        struct bcm_classifier_rule *pstClassifierRule = NULL;
-       S_ETHCS_PKT_INFO stEthCsPktInfo;
+       struct bcm_eth_packet_info stEthCsPktInfo;
        PVOID pvEThPayload = NULL;
        struct iphdr            *pIpHeader = NULL;
        INT       uiSfIndex=0;
@@ -454,7 +454,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
        BOOLEAN bFragmentedPkt=FALSE,bClassificationSucceed=FALSE;
        USHORT  usCurrFragment =0;
 
-       PTCP_HEADER pTcpHeader;
+       struct bcm_tcp_header *pTcpHeader;
        UCHAR IpHeaderLength;
        UCHAR TcpHeaderLength;
 
@@ -467,32 +467,32 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
                case eEth802LLCFrame:
                {
                        BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n");
-            pIpHeader = pvEThPayload + sizeof(ETH_CS_802_LLC_FRAME);
+                       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(ETH_CS_802_LLC_SNAP_FRAME);
+                       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(ETH_CS_802_Q_FRAME);
+                       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(ETH_CS_ETH2_FRAME);
+                       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(ETH_CS_ETH2_FRAME);
+                       pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
                        break;
                }
        }
@@ -614,7 +614,7 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
                if((TCP == pIpHeader->protocol ) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len) )
                {
                         IpHeaderLength   = pIpHeader->ihl;
-                        pTcpHeader = (PTCP_HEADER)(((PUCHAR)pIpHeader)+(IpHeaderLength*4));
+                        pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4));
                         TcpHeaderLength  = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength);
 
                        if((pTcpHeader->ucFlags & TCP_ACK) &&
@@ -683,7 +683,7 @@ static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifie
        return TRUE;
 }
 
-static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
+static BOOLEAN 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)||
@@ -718,7 +718,7 @@ static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRul
 
 }
 
-static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
+static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo)
 {
        BOOLEAN bClassificationSucceed = FALSE;
        USHORT usVLANID;
@@ -769,7 +769,7 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule
 
 
 static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,
-                               PS_ETHCS_PKT_INFO pstEthCsPktInfo,
+                               struct bcm_eth_packet_info *pstEthCsPktInfo,
                                struct bcm_classifier_rule *pstClassifierRule,
                                B_UINT8 EthCSCupport)
 {
@@ -802,7 +802,7 @@ static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff*
 }
 
 static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,
-                           PS_ETHCS_PKT_INFO pstEthCsPktInfo)
+                           struct bcm_eth_packet_info *pstEthCsPktInfo)
 {
        USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype);
 
@@ -815,7 +815,7 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,
                {
                        //802.1Q VLAN Header
                        pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame;
-                       u16Etype = ((ETH_CS_802_Q_FRAME*)pvEthPayload)->EthType;
+                       u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType;
                        //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority
                }
                else
@@ -830,12 +830,12 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,
                //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 = ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->DSAP;
-               if(pstEthCsPktInfo->ucDSAP == 0xAA && ((ETH_CS_802_LLC_FRAME*)pvEthPayload)->SSAP == 0xAA)
+               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 = ((ETH_CS_802_LLC_SNAP_FRAME*)pvEthPayload)->usEtherType;
+                       u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType;
                }
        }
        if(u16Etype == ETHERNET_FRAMETYPE_IPV4)
index 3c5f4a5f0376a96dae1837391157f9514cc6bfd0..f55300db1d48825085dea70182a93be07a475f5a 100644 (file)
 
 INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs)
 {
-       S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
-       S_PHS_RULE *pstPhsRule = NULL;
-       S_CLASSIFIER_TABLE *pstClassifierTable = NULL;
-       S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
-       PPHS_DEVICE_EXTENSION pDeviceExtension = (PPHS_DEVICE_EXTENSION) &Adapter->stBCMPhsContext;
+       struct bcm_phs_entry *pstServiceFlowEntry = NULL;
+       struct bcm_phs_rule *pstPhsRule = NULL;
+       struct bcm_phs_classifier_table *pstClassifierTable = NULL;
+       struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
+       struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext;
 
        UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0;
 
@@ -70,7 +70,7 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m
 
                                memcpy(&pstHostMibs->
                                       astPhsRulesTable[nPhsTableIndex].u8PHSI,
-                                      &pstPhsRule->u8PHSI, sizeof(S_PHS_RULE));
+                                      &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule));
                                nPhsTableIndex++;
 
                        }
index 252a1b31d618e82b8ab091d811fe9946e9d63da7..05a948a3698cb15eabdd8b25418ca26e96b79366 100644 (file)
@@ -24,7 +24,7 @@ BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
 }
 
 static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
-               ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate)
+               ULONG timeout, INT num_of_time, enum bcm_led_events currdriverstate)
 {
        int Status = STATUS_SUCCESS;
        BOOLEAN bInfinite = FALSE;
@@ -97,7 +97,7 @@ static INT ScaleRateofTransfer(ULONG rate)
 
 static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx,
                UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex,
-               LedEventInfo_t currdriverstate)
+               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;
@@ -607,7 +607,7 @@ static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
 
 static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx,
                UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,
-               LedEventInfo_t currdriverstate)
+               enum bcm_led_events currdriverstate)
 {
        UINT uiIndex = 0;
 
@@ -651,7 +651,7 @@ static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
        UCHAR GPIO_num = 0;
        UCHAR uiLedIndex = 0;
        UINT uiResetValue = 0;
-       LedEventInfo_t currdriverstate = 0;
+       enum bcm_led_events currdriverstate = 0;
        ulong timeout = 0;
 
        INT Status = 0;
index ed8fbc091115d0b9af8c61b0c72afcda63b275e5..bae40e22e11bf30951d245fc5e5159f1da567fc8 100644 (file)
 #ifndef _LED_CONTROL_H
 #define _LED_CONTROL_H
 
-/*************************TYPE DEF**********************/
-#define NUM_OF_LEDS 4
-
+#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 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(GPIO, index) do { \
-                                                       UINT gpio_val = GPIO; \
-                                                       (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \
-                                                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \
-                                                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \
-                                               } while (0);
-
-#define TURN_OFF_LED(GPIO, index)  do { \
-                                                       UINT gpio_val = GPIO; \
-                                                       (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ? \
-                                                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \
-                                                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val));  \
-                                               } while (0);
-
-#define B_ULONG32 unsigned long
-
-/*******************************************************/
-
-
-typedef enum _LEDColors{
-       RED_LED = 1,
-       BLUE_LED = 2,
-       YELLOW_LED = 3,
-       GREEN_LED = 4
-} LEDColors;   /*Enumerated values of different LED types*/
-
-typedef enum LedEvents {
-       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
-} LedEventInfo_t;      /* Enumerated values of different driver states */
+#define TURN_ON_LED(GPIO, index) do {                                  \
+               unsigned int gpio_val = GPIO;                                   \
+               (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ?   \
+                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_SET_REG, &gpio_val, sizeof(gpio_val)) : \
+                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)); \
+       } while (0)
+
+#define TURN_OFF_LED(GPIO, index)  do {                                        \
+               unsigned int gpio_val = GPIO;                                   \
+               (Adapter->LEDInfo.LEDState[index].BitPolarity == 1) ?   \
+                       wrmaltWithLock(Adapter, BCM_GPIO_OUTPUT_CLR_REG, &gpio_val, sizeof(gpio_val)) : \
+                       wrmaltWithLock(Adapter, 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
  */
-typedef struct LedStateInfo_t {
-       UCHAR LED_Type; /* specify GPIO number - use 0xFF if not used */
-       UCHAR LED_On_State; /* Bits set or reset for different states */
-       UCHAR LED_Blink_State; /* Bits set or reset for blinking LEDs for different states */
-       UCHAR GPIO_Num;
-       UCHAR BitPolarity; /* To represent whether H/W is normal polarity or reverse polarity */
-} LEDStateInfo, *pLEDStateInfo;
-
-
-typedef struct _LED_INFO_STRUCT {
-       LEDStateInfo    LEDState[NUM_OF_LEDS];
-       BOOLEAN         bIdleMode_tx_from_host; /* Variable to notify whether driver came out from idlemode due to Host or target*/
-       BOOLEAN                 bIdle_led_off;
-       wait_queue_head_t   notify_led_event;
+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;
-       BOOLEAN                 bLedInitDone;
+       struct task_struct      *led_cntrl_threadid;
+       int             led_thread_running;
+       bool            bLedInitDone;
+};
 
-} LED_INFO_STRUCT, *PLED_INFO_STRUCT;
 /* 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*/
-
-
+#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
-
index eab676fe53a6af44429fd164fadd6fa40039b113..e6152f4df14b4beaf515907e47098740613c5c82 100644 (file)
@@ -12,7 +12,7 @@ static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsi
 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 NVM_TYPE BcmGetNvmType(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);
 
@@ -472,7 +472,7 @@ static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter,
 static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter)
 {
        if (IsFlash2x(Adapter))
-               return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER);
+               return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header);
        else
                return 32 * 1024;
 }
@@ -1978,7 +1978,7 @@ int BeceemNVMWrite(struct bcm_mini_adapter *Adapter,
 int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize)
 {
        int Status = -1;
-       FLASH_CS_INFO sFlashCsInfo = {0};
+       struct bcm_flash_cs_info sFlashCsInfo = {0};
        unsigned int uiTemp = 0;
        unsigned int uiSectorSig = 0;
        unsigned int uiCurrentSectorSize = 0;
@@ -2228,20 +2228,20 @@ int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
                BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
                return -EINVAL;
        }
-       psAdapter->psFlashCSInfo = (PFLASH_CS_INFO)kzalloc(sizeof(FLASH_CS_INFO), GFP_KERNEL);
+       psAdapter->psFlashCSInfo = (struct bcm_flash_cs_info *)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 = (PFLASH2X_CS_INFO)kzalloc(sizeof(FLASH2X_CS_INFO), GFP_KERNEL);
+       psAdapter->psFlash2xCSInfo = (struct bcm_flash2x_cs_info *)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 = (PFLASH2X_VENDORSPECIFIC_INFO)kzalloc(sizeof(FLASH2X_VENDORSPECIFIC_INFO), GFP_KERNEL);
+       psAdapter->psFlash2xVendorInfo = (struct bcm_flash2x_vendor_info *)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);
@@ -2264,7 +2264,7 @@ int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
        return STATUS_SUCCESS;
 }
 
-static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bcm_mini_adapter *Adapter)
+static int BcmDumpFlash2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo, struct bcm_mini_adapter *Adapter)
 {
        unsigned int Index = 0;
 
@@ -2324,7 +2324,7 @@ static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bc
        return STATUS_SUCCESS;
 }
 
-static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo)
+static int ConvertEndianOf2XCSStructure(struct bcm_flash2x_cs_info *psFlash2xCSInfo)
 {
        unsigned int Index = 0;
 
@@ -2381,7 +2381,7 @@ static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo)
        return STATUS_SUCCESS;
 }
 
-static int ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo)
+static int ConvertEndianOfCSStructure(struct bcm_flash_cs_info *psFlashCSInfo)
 {
        /* unsigned int Index = 0; */
        psFlashCSInfo->MagicNumber                              = ntohl(psFlashCSInfo->MagicNumber);
@@ -2446,7 +2446,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
 
                switch (i) {
                case DSD0:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+                       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
@@ -2454,7 +2454,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
                        break;
 
                case DSD1:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+                       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
@@ -2462,7 +2462,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
                        break;
 
                case DSD2:
-                       if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+                       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
@@ -2509,7 +2509,7 @@ static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
 
 static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
 {
-       /* FLASH_CS_INFO sFlashCsInfo = {0}; */
+       /* struct bcm_flash_cs_info sFlashCsInfo = {0}; */
 
        #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
                unsigned int value;
@@ -2522,8 +2522,8 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
 
        Adapter->uiFlashBaseAdd = 0;
        Adapter->ulFlashCalStart = 0;
-       memset(Adapter->psFlashCSInfo, 0 , sizeof(FLASH_CS_INFO));
-       memset(Adapter->psFlash2xCSInfo, 0 , sizeof(FLASH2X_CS_INFO));
+       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;
@@ -2551,7 +2551,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
        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(FLASH_CS_INFO));
+               BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(struct bcm_flash_cs_info));
                ConvertEndianOfCSStructure(Adapter->psFlashCSInfo);
                Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart);
 
@@ -2576,7 +2576,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
                Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF;
        } else {
                if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL,
-                                       Adapter->ulFlashControlSectionStart, sizeof(FLASH2X_CS_INFO))) {
+                                       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;
                }
@@ -2629,7 +2629,7 @@ static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
  *
  */
 
-static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter)
+static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter)
 {
        unsigned int uiData = 0;
 
@@ -2810,6 +2810,7 @@ int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x
        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);
@@ -3101,7 +3102,7 @@ static int BcmDumpFlash2xSectionBitMap(struct bcm_flash2x_bitmap *psFlash2xBitMa
 
 int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_bitmap *psFlash2xBitMap)
 {
-       PFLASH2X_CS_INFO psFlash2xCSInfo = Adapter->psFlash2xCSInfo;
+       struct bcm_flash2x_cs_info *psFlash2xCSInfo = Adapter->psFlash2xCSInfo;
        enum bcm_flash2x_section_val uiHighestPriDSD = 0;
        enum bcm_flash2x_section_val uiHighestPriISO = 0;
        BOOLEAN SetActiveDSDDone = FALSE;
@@ -3354,8 +3355,8 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
        unsigned int SectImagePriority = 0;
        int Status = STATUS_SUCCESS;
 
-       /* DSD_HEADER sDSD = {0};
-        * ISO_HEADER sISO = {0};
+       /* struct bcm_dsd_header sDSD = {0};
+        * struct bcm_iso_header sISO = {0};
         */
        int HighestPriDSD = 0 ;
        int HighestPriISO = 0;
@@ -3391,7 +3392,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
                                Status = BcmFlash2xBulkWrite(Adapter,
                                                        &SectImagePriority,
                                                        HighestPriISO,
-                                                       0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+                                                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
                                                        SIGNATURE_SIZE,
                                                        TRUE);
                                if (Status) {
@@ -3416,7 +3417,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
                        Status = BcmFlash2xBulkWrite(Adapter,
                                                &SectImagePriority,
                                                eFlash2xSectVal,
-                                               0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+                                               0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
                                                SIGNATURE_SIZE,
                                                TRUE);
                        if (Status) {
@@ -3452,7 +3453,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
                                Status = BcmFlash2xBulkWrite(Adapter,
                                                        &SectImagePriority,
                                                        HighestPriDSD,
-                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
                                                        SIGNATURE_SIZE,
                                                        TRUE);
                                if (Status) {
@@ -3472,7 +3473,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
                                Status = BcmFlash2xBulkWrite(Adapter,
                                                        &SectImagePriority,
                                                        HighestPriDSD,
-                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+                                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
                                                        SIGNATURE_SIZE,
                                                        TRUE);
                                if (Status) {
@@ -3492,7 +3493,7 @@ int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_secti
                        Status = BcmFlash2xBulkWrite(Adapter,
                                                &SectImagePriority,
                                                eFlash2xSectVal,
-                                               Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+                                               Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
                                                SIGNATURE_SIZE,
                                                TRUE);
                        if (Status) {
@@ -3550,7 +3551,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section
        Status = BcmFlash2xBulkRead(Adapter,
                                &ISOLength,
                                sCopySectStrut.SrcSection,
-                               0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageSize),
+                               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");
@@ -3561,7 +3562,7 @@ int BcmCopyISO(struct bcm_mini_adapter *Adapter, struct bcm_flash2x_copy_section
        if (ISOLength % Adapter->uiSectorSize)
                ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize);
 
-       sigOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber);
+       sigOffset = FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber);
 
        Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL);
 
@@ -3846,7 +3847,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio
        unsigned int uiSignature = 0;
        unsigned int uiOffset = 0;
 
-       /* DSD_HEADER dsdHeader = {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;
@@ -3863,7 +3864,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio
                uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER);
                uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader;
 
-               uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber);
+               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");
@@ -3872,7 +3873,7 @@ int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sectio
        } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) {
                uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER);
                /* uiOffset = 0; */
-               uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber);
+               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;
@@ -4141,14 +4142,14 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned
                (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) {
                /* offset from the sector boundary having the header map */
                offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize;
-               HeaderSizeToProtect = sizeof(DSD_HEADER);
+               HeaderSizeToProtect = sizeof(struct bcm_dsd_header);
                bHasHeader = TRUE;
        }
 
        if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) ||
                uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) {
                offsetToProtect = 0;
-               HeaderSizeToProtect = sizeof(ISO_HEADER);
+               HeaderSizeToProtect = sizeof(struct bcm_iso_header);
                bHasHeader = TRUE;
        }
        /* If Header is present overwrite passed buffer with this */
@@ -4167,7 +4168,7 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned
                kfree(pTempBuff);
        }
        if (bHasHeader && Adapter->bSigCorrupted) {
-               sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber)));
+               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");
@@ -4175,7 +4176,7 @@ int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned
                        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(PDSD_HEADER, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER);
+               *((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;
        }
@@ -4268,7 +4269,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_
 {
        unsigned int uiDSDsig = 0;
        /* unsigned int sigoffsetInMap = 0;
-        * DSD_HEADER dsdHeader = {0};
+        * struct bcm_dsd_header dsdHeader = {0};
         */
 
        /* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */
@@ -4280,7 +4281,7 @@ int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_
        BcmFlash2xBulkRead(Adapter,
                        &uiDSDsig,
                        dsd,
-                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber),
+                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImageMagicNumber),
                        SIGNATURE_SIZE);
 
        uiDSDsig = ntohl(uiDSDsig);
@@ -4293,7 +4294,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v
 {
        /* unsigned int priOffsetInMap = 0 ; */
        unsigned int uiDSDPri = STATUS_FAILURE;
-       /* DSD_HEADER dsdHeader = {0};
+       /* struct bcm_dsd_header dsdHeader = {0};
         * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader;
         */
        if (IsSectionWritable(Adapter, dsd)) {
@@ -4301,7 +4302,7 @@ int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v
                        BcmFlash2xBulkRead(Adapter,
                                        &uiDSDPri,
                                        dsd,
-                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+                                       Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(struct bcm_dsd_header *, DSDImagePriority),
                                        4);
 
                        uiDSDPri = ntohl(uiDSDPri);
@@ -4348,7 +4349,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_
 {
        unsigned int uiISOsig = 0;
        /* unsigned int sigoffsetInMap = 0;
-        * ISO_HEADER ISOHeader = {0};
+        * struct bcm_iso_header ISOHeader = {0};
         * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader;
         */
        if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) {
@@ -4358,7 +4359,7 @@ int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_
        BcmFlash2xBulkRead(Adapter,
                        &uiISOsig,
                        iso,
-                       0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber),
+                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageMagicNumber),
                        SIGNATURE_SIZE);
 
        uiISOsig = ntohl(uiISOsig);
@@ -4375,7 +4376,7 @@ int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_v
                        BcmFlash2xBulkRead(Adapter,
                                        &ISOPri,
                                        iso,
-                                       0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+                                       0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImagePriority),
                                        4);
 
                        ISOPri = ntohl(ISOPri);
@@ -4568,7 +4569,7 @@ static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_sect
                return -ENOMEM;
        }
 
-       uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER);
+       uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(struct bcm_dsd_header);
        uiOffset -= MAX_RW_SIZE;
 
        BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE);
index 651b5a455b32aea6dce65165604068adf75c2227..e765cca5d96659f7b977dc233f9d004cd517f6c8 100644 (file)
 /***************************************************************************************
-//
-// 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:
-//
-****************************************************************************************/
-
+ *
+ * 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_
 
-typedef struct _FLASH_SECTOR_INFO
-{
-       UINT uiSectorSig;
-       UINT uiSectorSize;
-
-}FLASH_SECTOR_INFO,*PFLASH_SECTOR_INFO;
-
-typedef struct _FLASH_CS_INFO
-{
-       B_UINT32 MagicNumber;
-// let the magic number be 0xBECE-F1A5 - F1A5 for "flas-h"
-
-       B_UINT32 FlashLayoutVersion ;
-
-    // ISO Image/Format/BuildTool versioning
-    B_UINT32 ISOImageVersion;
-
-    // SCSI/Flash BootLoader versioning
-    B_UINT32 SCSIFirmwareVersion;
-
-
-       B_UINT32 OffsetFromZeroForPart1ISOImage;
-// typically 0
-
-       B_UINT32 OffsetFromZeroForScsiFirmware;
-//typically at 12MB
-
-       B_UINT32 SizeOfScsiFirmware ;
-//size of the firmware - depends on binary size
-
-       B_UINT32 OffsetFromZeroForPart2ISOImage;
-// typically at first Word Aligned offset 12MB +                 sizeOfScsiFirmware.
-
-       B_UINT32 OffsetFromZeroForCalibrationStart;
-// typically at 15MB
-
-       B_UINT32 OffsetFromZeroForCalibrationEnd;
-
-// VSA0 offsets
-       B_UINT32 OffsetFromZeroForVSAStart;
-       B_UINT32 OffsetFromZeroForVSAEnd;
-
-// Control Section offsets
-       B_UINT32 OffsetFromZeroForControlSectionStart;
-       B_UINT32 OffsetFromZeroForControlSectionData;
-
-// NO Data Activity timeout to switch from MSC to NW Mode
-       B_UINT32 CDLessInactivityTimeout;
-
-// New ISO Image Signature
-       B_UINT32 NewImageSignature;
-
-// Signature to validate the sector size.
-       B_UINT32 FlashSectorSizeSig;
-
-// Sector Size
-       B_UINT32 FlashSectorSize;
-
-// Write Size Support
-       B_UINT32 FlashWriteSupportSize;
-
-// Total Flash Size
-       B_UINT32 TotalFlashSize;
-
-// Flash Base Address for offset specified
-       B_UINT32 FlashBaseAddr;
-
-// Flash Part Max Size
-       B_UINT32 FlashPartMaxSize;
-
-// Is CDLess or Flash Bootloader
-       B_UINT32 IsCDLessDeviceBootSig;
-
-// MSC Timeout after reset to switch from MSC to NW Mode
-       B_UINT32 MassStorageTimeout;
-
-
-}FLASH_CS_INFO,*PFLASH_CS_INFO;
-
-#define FLASH2X_TOTAL_SIZE (64*1024*1024)
-#define DEFAULT_SECTOR_SIZE                     (64*1024)
-
-typedef struct _FLASH_2X_CS_INFO
-{
-
-       // magic number as 0xBECE-F1A5 - F1A5 for "flas-h"
-       B_UINT32 MagicNumber;
-
-       B_UINT32 FlashLayoutVersion ;
-
-    // ISO Image/Format/BuildTool versioning
-    B_UINT32 ISOImageVersion;
-
-    // SCSI/Flash BootLoader versioning
-    B_UINT32 SCSIFirmwareVersion;
-
-       // ISO Image1 Part1/SCSI Firmware/Flash Bootloader Start offset, size
-       B_UINT32 OffsetFromZeroForPart1ISOImage;
-       B_UINT32 OffsetFromZeroForScsiFirmware;
-       B_UINT32 SizeOfScsiFirmware ;
-
-       // ISO Image1 Part2 start offset
-       B_UINT32 OffsetFromZeroForPart2ISOImage;
-
-
-       // DSD0 offset
-       B_UINT32 OffsetFromZeroForDSDStart;
-       B_UINT32 OffsetFromZeroForDSDEnd;
-
-       // VSA0 offset
-       B_UINT32 OffsetFromZeroForVSAStart;
-       B_UINT32 OffsetFromZeroForVSAEnd;
-
-       // Control Section offset
-       B_UINT32 OffsetFromZeroForControlSectionStart;
-       B_UINT32 OffsetFromZeroForControlSectionData;
-
-       // NO Data Activity timeout to switch from MSC to NW Mode
-       B_UINT32 CDLessInactivityTimeout;
-
-       // New ISO Image Signature
-       B_UINT32 NewImageSignature;
-
-       B_UINT32 FlashSectorSizeSig;                    // Sector Size Signature
-       B_UINT32 FlashSectorSize;                       // Sector Size
-       B_UINT32 FlashWriteSupportSize;         // Write Size Support
-
-       B_UINT32 TotalFlashSize;                        // Total Flash Size
-
-       // Flash Base Address for offset specified
-       B_UINT32 FlashBaseAddr;
-       B_UINT32 FlashPartMaxSize;                      // Flash Part Max Size
-
-       // Is CDLess or Flash Bootloader
-       B_UINT32 IsCDLessDeviceBootSig;
-
-       // MSC Timeout after reset to switch from MSC to NW Mode
-       B_UINT32 MassStorageTimeout;
-
+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 */
-       B_UINT32 OffsetISOImage1Part1Start;     // ISO Image1 Part1 offset
-       B_UINT32 OffsetISOImage1Part1End;
-       B_UINT32 OffsetISOImage1Part2Start;     // ISO Image1 Part2 offset
-       B_UINT32 OffsetISOImage1Part2End;
-       B_UINT32 OffsetISOImage1Part3Start;     // ISO Image1 Part3 offset
-       B_UINT32 OffsetISOImage1Part3End;
-
-       B_UINT32 OffsetISOImage2Part1Start;     // ISO Image2 Part1 offset
-       B_UINT32 OffsetISOImage2Part1End;
-       B_UINT32 OffsetISOImage2Part2Start;     // ISO Image2 Part2 offset
-       B_UINT32 OffsetISOImage2Part2End;
-       B_UINT32 OffsetISOImage2Part3Start;     // ISO Image2 Part3 offset
-       B_UINT32 OffsetISOImage2Part3End;
-
-
-       // DSD Header offset from start of DSD
-       B_UINT32 OffsetFromDSDStartForDSDHeader;
-       B_UINT32 OffsetFromZeroForDSD1Start;    // DSD 1 offset
-       B_UINT32 OffsetFromZeroForDSD1End;
-       B_UINT32 OffsetFromZeroForDSD2Start;    // DSD 2 offset
-       B_UINT32 OffsetFromZeroForDSD2End;
-
-       B_UINT32 OffsetFromZeroForVSA1Start;    // VSA 1 offset
-       B_UINT32 OffsetFromZeroForVSA1End;
-       B_UINT32 OffsetFromZeroForVSA2Start;    // VSA 2 offset
-       B_UINT32 OffsetFromZeroForVSA2End;
-
+       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
-*      */
-       B_UINT32 SectorAccessBitMap[FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)];
-
-// All expansions to the control data structure should add here
-
-}FLASH2X_CS_INFO,*PFLASH2X_CS_INFO;
-
-typedef struct _VENDOR_SECTION_INFO
-{
-       B_UINT32 OffsetFromZeroForSectionStart;
-       B_UINT32 OffsetFromZeroForSectionEnd;
-       B_UINT32 AccessFlags;
-       B_UINT32 Reserved[16];
-
-} VENDOR_SECTION_INFO, *PVENDOR_SECTION_INFO;
-
-typedef struct _FLASH2X_VENDORSPECIFIC_INFO
-{
-       VENDOR_SECTION_INFO VendorSection[TOTAL_SECTIONS];
-       B_UINT32 Reserved[16];
-
-} FLASH2X_VENDORSPECIFIC_INFO, *PFLASH2X_VENDORSPECIFIC_INFO;
-
-typedef struct _DSD_HEADER
-{
-       B_UINT32 DSDImageSize;
-       B_UINT32 DSDImageCRC;
-       B_UINT32 DSDImagePriority;
-       //We should not consider right now. Reading reserve is worthless.
-       B_UINT32 Reserved[252]; // Resvd for DSD Header
-       B_UINT32 DSDImageMagicNumber;
-
-}DSD_HEADER, *PDSD_HEADER;
-
-typedef struct _ISO_HEADER
-{
-       B_UINT32 ISOImageMagicNumber;
-       B_UINT32 ISOImageSize;
-       B_UINT32 ISOImageCRC;
-       B_UINT32 ISOImagePriority;
-       //We should not consider right now. Reading reserve is worthless.
-       B_UINT32 Reserved[60]; //Resvd for ISO Header extension
-
-}ISO_HEADER, *PISO_HEADER;
-
-#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
+        * 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)
+ * 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) ((PUCHAR)&((HeaderPointer)(NULL))->Field - (PUCHAR)(NULL))
+#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
 
index ad7ec0054938b41034cd585b39e3a111217840ba..dc45f9ab854d1e424c141c1c0c437df9c841763e 100644 (file)
@@ -1,81 +1,57 @@
 #ifndef TARGET_PARAMS_H
 #define TARGET_PARAMS_H
 
-typedef struct _TARGET_PARAMS
-{
-      B_UINT32 m_u32CfgVersion;
-
-      // Scanning Related Params
-      B_UINT32 m_u32CenterFrequency;
-      B_UINT32 m_u32BandAScan;
-      B_UINT32 m_u32BandBScan;
-      B_UINT32 m_u32BandCScan;
-
-
-      // QoS Params
-      B_UINT32 m_u32ErtpsOptions;
-
-      B_UINT32 m_u32PHSEnable;
-
-
-      // HO Params
-      B_UINT32 m_u32HoEnable;
-
-      B_UINT32 m_u32HoReserved1;
-      B_UINT32 m_u32HoReserved2;
-      // Power Control Params
-
-      B_UINT32 m_u32MimoEnable;
-
-      B_UINT32 m_u32SecurityEnable;
-
-      B_UINT32 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*/
-      B_UINT32 m_u32PowerSavingModeOptions;
-
-      B_UINT32 m_u32ArqEnable;
-
-      // From Version #3, the HARQ section renamed as general
-      B_UINT32 m_u32HarqEnable;
-       // EEPROM Param Location
-       B_UINT32  m_u32EEPROMFlag;
-       // BINARY TYPE - 4th MSByte: Interface Type -  3rd MSByte: Vendor Type - 2nd MSByte
-       // Unused - LSByte
-      B_UINT32   m_u32Customize;
-      B_UINT32   m_u32ConfigBW;  /* In Hz */
-      B_UINT32   m_u32ShutDownInitThresholdTimer;
-
-      B_UINT32  m_u32RadioParameter;
-      B_UINT32  m_u32PhyParameter1;
-      B_UINT32  m_u32PhyParameter2;
-      B_UINT32  m_u32PhyParameter3;
-
-      B_UINT32   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
-
-       B_UINT32 m_u32MaxMACDataperDLFrame;
-       B_UINT32 m_u32MaxMACDataperULFrame;
-
-       B_UINT32 m_u32Corr2MacFlags;
-
-    //adding driver params.
-       B_UINT32 HostDrvrConfig1;
-    B_UINT32 HostDrvrConfig2;
-    B_UINT32 HostDrvrConfig3;
-    B_UINT32 HostDrvrConfig4;
-    B_UINT32 HostDrvrConfig5;
-    B_UINT32 HostDrvrConfig6;
-    B_UINT32 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.
-       B_UINT32 m_u32BandAMCEnable;
-
-} stTargetParams,TARGET_PARAMS,*PTARGET_PARAMS, STARGETPARAMS, *PSTARGETPARAMS;
+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
index 40be60aa909aadcceffec17280f555f91e79fc19..be1f91d955aa2716c69cb8b87d9c9dfd55de0d99 100644 (file)
@@ -11,7 +11,7 @@
 //             STATUS_SUCCESS/STATUS_FAILURE
 //
 //-----------------------------------------------------------------------------
-INT vendorextnGetSectionInfo(PVOID  pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo)
+INT vendorextnGetSectionInfo(PVOID  pContext, struct bcm_flash2x_vendor_info *pVendorInfo)
 {
        return STATUS_FAILURE;
 }
index 834410e29e75002417b5c4529b1e0a834b518aaf..52890d216edf3b9828e7ad040c6df4d0e6195a25 100644 (file)
@@ -4,7 +4,7 @@
 
 #define CONTINUE_COMMON_PATH 0xFFFF
 
-INT vendorextnGetSectionInfo(PVOID  pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo);
+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);
index d0434714afd3ee04cb53abccc0594a2a2c99bd57..82a333f6433e3f4a852e4ed62f7936bfe4ad707b 100644 (file)
@@ -123,7 +123,7 @@ int SendString(DEVICE_EXTENSION * pdx, const char __user * pData,
                iReturn = PutChars(pdx, buffer, n);
        }
 
-       Allowi(pdx, false);     // make sure we have input int
+       Allowi(pdx);            // make sure we have input int
        mutex_unlock(&pdx->io_mutex);
 
        return iReturn;
@@ -140,7 +140,7 @@ int SendChar(DEVICE_EXTENSION * pdx, char c)
        mutex_lock(&pdx->io_mutex);     // Protect disconnect from new i/o
        iReturn = PutChars(pdx, &c, 1);
        dev_dbg(&pdx->interface->dev, "SendChar >%c< (0x%02x)", c, c);
-       Allowi(pdx, false);     // Make sure char reads are running
+       Allowi(pdx);    // Make sure char reads are running
        mutex_unlock(&pdx->io_mutex);
        return iReturn;
 }
@@ -433,8 +433,8 @@ int GetChar(DEVICE_EXTENSION * pdx)
 
        dev_dbg(&pdx->interface->dev, "GetChar");
 
-       Allowi(pdx, false);     // Make sure char reads are running
-       SendChars(pdx);         // and send any buffered chars
+       Allowi(pdx);    // Make sure char reads are running
+       SendChars(pdx); // and send any buffered chars
 
        spin_lock_irq(&pdx->charInLock);
        if (pdx->dwNumInput > 0)        // worth looking
@@ -447,7 +447,7 @@ int GetChar(DEVICE_EXTENSION * pdx)
                iReturn = U14ERR_NOIN;  // no input data to read
        spin_unlock_irq(&pdx->charInLock);
 
-       Allowi(pdx, false);     // Make sure char reads are running
+       Allowi(pdx);    // Make sure char reads are running
 
        mutex_unlock(&pdx->io_mutex);   // Protect disconnect from new i/o
        return iReturn;
@@ -472,7 +472,7 @@ int GetString(DEVICE_EXTENSION * pdx, char __user * pUser, int n)
                return -ENOMEM;
 
        mutex_lock(&pdx->io_mutex);     // Protect disconnect from new i/o
-       Allowi(pdx, false);     // Make sure char reads are running
+       Allowi(pdx);    // Make sure char reads are running
        SendChars(pdx);         // and send any buffered chars
 
        spin_lock_irq(&pdx->charInLock);
@@ -518,7 +518,7 @@ int GetString(DEVICE_EXTENSION * pdx, char __user * pUser, int n)
        } else
                spin_unlock_irq(&pdx->charInLock);
 
-       Allowi(pdx, false);     // Make sure char reads are running
+       Allowi(pdx);    // Make sure char reads are running
        mutex_unlock(&pdx->io_mutex);   // Protect disconnect from new i/o
 
        return iReturn;
@@ -531,7 +531,7 @@ int Stat1401(DEVICE_EXTENSION * pdx)
 {
        int iReturn;
        mutex_lock(&pdx->io_mutex);     // Protect disconnect from new i/o
-       Allowi(pdx, false);     // make sure we allow pending chars
+       Allowi(pdx);            // make sure we allow pending chars
        SendChars(pdx);         // in both directions
        iReturn = pdx->dwNumInput;      // no lock as single read
        mutex_unlock(&pdx->io_mutex);   // Protect disconnect from new i/o
@@ -550,7 +550,7 @@ int LineCount(DEVICE_EXTENSION * pdx)
        int iReturn = 0;        // will be count of line ends
 
        mutex_lock(&pdx->io_mutex);     // Protect disconnect from new i/o
-       Allowi(pdx, false);     // Make sure char reads are running
+       Allowi(pdx);            // Make sure char reads are running
        SendChars(pdx);         // and send any buffered chars
        spin_lock_irq(&pdx->charInLock);        // Get protection
 
index a27043a2f8c51011677f76c6f52e581b268603ef..60bed3e90fb835e7e69fc2897b6131e6b417bbce 100644 (file)
@@ -697,7 +697,7 @@ static void staged_callback(struct urb *pUrb)
        // in Allowi as if it were protected by the char lock. In any case, most systems will
        // not be upset by char input during DMA... sigh. Needs sorting out.
        if (bRestartCharInput)  // may be out of date, but...
-               Allowi(pdx, true);      // ...Allowi tests a lock too.
+               Allowi(pdx);    // ...Allowi tests a lock too.
        dev_dbg(&pdx->interface->dev, "%s done", __func__);
 }
 
@@ -1172,7 +1172,7 @@ static void ced_readchar_callback(struct urb *pUrb)
        pdx->bReadCharsPending = false; // No longer have a pending read
        spin_unlock(&pdx->charInLock);  // already at irq level
 
-       Allowi(pdx, true);      // see if we can do the next one
+       Allowi(pdx);    // see if we can do the next one
 }
 
 /****************************************************************************
@@ -1182,7 +1182,7 @@ static void ced_readchar_callback(struct urb *pUrb)
 ** we can pick up any inward transfers. This can be called in multiple contexts
 ** so we use the irqsave version of the spinlock.
 ****************************************************************************/
-int Allowi(DEVICE_EXTENSION * pdx, bool bInCallback)
+int Allowi(DEVICE_EXTENSION * pdx)
 {
        int iReturn = U14ERR_NOERROR;
        unsigned long flags;
@@ -1211,9 +1211,7 @@ int Allowi(DEVICE_EXTENSION * pdx, bool bInCallback)
                                 pdx, pdx->bInterval);
                pdx->pUrbCharIn->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;     // short xfers are OK by default
                usb_anchor_urb(pdx->pUrbCharIn, &pdx->submitted);       // in case we need to kill it
-               iReturn =
-                   usb_submit_urb(pdx->pUrbCharIn,
-                                  bInCallback ? GFP_ATOMIC : GFP_KERNEL);
+               iReturn = usb_submit_urb(pdx->pUrbCharIn, GFP_ATOMIC);
                if (iReturn) {
                        usb_unanchor_urb(pdx->pUrbCharIn);      // remove from list of active Urbs
                        pdx->bPipeError[nPipe] = 1;     // Flag an error to be handled later
index adb5fa402bd4ebd290e2012afecf873720414b48..8fc6958b6f08d32438f6bf751eec93a8daeb1558 100644 (file)
@@ -204,7 +204,7 @@ typedef struct _DEVICE_EXTENSION
 
 /// Definitions of routimes used between compilation object files
 // in usb1401.c
-extern int Allowi(DEVICE_EXTENSION* pdx, bool bInCallback);
+extern int Allowi(DEVICE_EXTENSION* pdx);
 extern int SendChars(DEVICE_EXTENSION* pdx);
 extern void ced_draw_down(DEVICE_EXTENSION *pdx);
 extern int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
index 36eec320569c6bd14d077be6328b34ae4fede36f..4c80ac935ee2026b2f48cc0527b8a6dabc568278 100644 (file)
@@ -1,7 +1,6 @@
 config COMEDI
        tristate "Data acquisition support (comedi)"
        depends on m
-       depends on BROKEN || FRV || M32R || MN10300 || SUPERH || TILE || X86
        ---help---
          Enable support a wide range of data acquisition devices
          for Linux.
@@ -567,6 +566,13 @@ config COMEDI_8255_PCI
          To compile this driver as a module, choose M here: the module will
          be called 8255_pci.
 
+config COMEDI_ADDI_WATCHDOG
+       tristate
+       ---help---
+         Provides support for the watchdog subdevice found on many ADDI-DATA
+         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---
@@ -593,6 +599,7 @@ config COMEDI_ADDI_APCI_1500
 
 config COMEDI_ADDI_APCI_1516
        tristate "ADDI-DATA APCI-1016/1516/2016 support"
+       select COMEDI_ADDI_WATCHDOG
        ---help---
          Enable support for ADDI-DATA APCI-1016, APCI-1516 and APCI-2016 boards.
          These are 16 channel, optically isolated, digital I/O boards. The 1516
@@ -619,6 +626,7 @@ config COMEDI_ADDI_APCI_16XX
 
 config COMEDI_ADDI_APCI_2032
        tristate "ADDI-DATA APCI_2032 support"
+       select COMEDI_ADDI_WATCHDOG
        ---help---
          Enable support for ADDI-DATA APCI_2032 cards
 
@@ -627,6 +635,7 @@ config COMEDI_ADDI_APCI_2032
 
 config COMEDI_ADDI_APCI_2200
        tristate "ADDI-DATA APCI_2200 support"
+       select COMEDI_ADDI_WATCHDOG
        ---help---
          Enable support for ADDI-DATA APCI_2200 cards
 
index 8dbd306fef887235ae03a6cbb9e2deb02f74f218..51816c3fc268a93078f391319a957e5c52421934 100644 (file)
@@ -1,11 +1,9 @@
-obj-$(CONFIG_COMEDI) += comedi.o
+comedi-y                       := comedi_fops.o range.o drivers.o \
+                                  comedi_buf.o
+comedi-$(CONFIG_PROC_FS)       += proc.o
+comedi-$(CONFIG_COMPAT)                += comedi_compat32.o
 
-obj-$(CONFIG_COMEDI)   += kcomedilib/
-obj-$(CONFIG_COMEDI)   += drivers/
+obj-$(CONFIG_COMEDI)           += comedi.o
 
-comedi-y :=            \
-       comedi_fops.o   \
-       proc.o          \
-       range.o         \
-       drivers.o       \
-       comedi_compat32.o \
+obj-$(CONFIG_COMEDI)           += kcomedilib/
+obj-$(CONFIG_COMEDI)           += drivers/
index c8a8ca12612745c21b9f1cebf4a6e88b6fb72cbf..4233605df30ace5057dc40f16df7ad24b6496605 100644 (file)
 
 /* number of config options in the config structure */
 #define COMEDI_NDEVCONFOPTS 32
-/*length of nth chunk of firmware data*/
+
+/*
+ * NOTE: 'comedi_config --init-data' is deprecated
+ *
+ * The following indexes in the config options were used by
+ * comedi_config to pass firmware blobs from user space to the
+ * comedi drivers. The request_firmware() hotplug interface is
+ * now used by all comedi drivers instead.
+ */
+
+/* length of nth chunk of firmware data -*/
 #define COMEDI_DEVCONF_AUX_DATA3_LENGTH                25
 #define COMEDI_DEVCONF_AUX_DATA2_LENGTH                26
 #define COMEDI_DEVCONF_AUX_DATA1_LENGTH                27
diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c
new file mode 100644 (file)
index 0000000..9b997ae
--- /dev/null
@@ -0,0 +1,415 @@
+/*
+ * comedi_buf.c
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1997-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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "comedidev.h"
+#include "comedi_internal.h"
+
+#ifdef PAGE_KERNEL_NOCACHE
+#define COMEDI_PAGE_PROTECTION         PAGE_KERNEL_NOCACHE
+#else
+#define COMEDI_PAGE_PROTECTION         PAGE_KERNEL
+#endif
+
+static void __comedi_buf_free(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             unsigned n_pages)
+{
+       struct comedi_async *async = s->async;
+       struct comedi_buf_page *buf;
+       unsigned i;
+
+       if (async->prealloc_buf) {
+               vunmap(async->prealloc_buf);
+               async->prealloc_buf = NULL;
+               async->prealloc_bufsz = 0;
+       }
+
+       if (!async->buf_page_list)
+               return;
+
+       for (i = 0; i < n_pages; ++i) {
+               buf = &async->buf_page_list[i];
+               if (buf->virt_addr) {
+                       clear_bit(PG_reserved,
+                                 &(virt_to_page(buf->virt_addr)->flags));
+                       if (s->async_dma_dir != DMA_NONE) {
+                               dma_free_coherent(dev->hw_dev,
+                                                 PAGE_SIZE,
+                                                 buf->virt_addr,
+                                                 buf->dma_addr);
+                       } else {
+                               free_page((unsigned long)buf->virt_addr);
+                       }
+               }
+       }
+       vfree(async->buf_page_list);
+       async->buf_page_list = NULL;
+       async->n_buf_pages = 0;
+}
+
+static void __comedi_buf_alloc(struct comedi_device *dev,
+                              struct comedi_subdevice *s,
+                              unsigned n_pages)
+{
+       struct comedi_async *async = s->async;
+       struct page **pages = NULL;
+       struct comedi_buf_page *buf;
+       unsigned i;
+
+       async->buf_page_list = vzalloc(sizeof(*buf) * n_pages);
+       if (async->buf_page_list)
+               pages = vmalloc(sizeof(struct page *) * n_pages);
+
+       if (!pages)
+               return;
+
+       for (i = 0; i < n_pages; i++) {
+               buf = &async->buf_page_list[i];
+               if (s->async_dma_dir != DMA_NONE)
+                       buf->virt_addr = dma_alloc_coherent(dev->hw_dev,
+                                                           PAGE_SIZE,
+                                                           &buf->dma_addr,
+                                                           GFP_KERNEL |
+                                                           __GFP_COMP);
+               else
+                       buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL);
+               if (!buf->virt_addr)
+                       break;
+
+               set_bit(PG_reserved, &(virt_to_page(buf->virt_addr)->flags));
+
+               pages[i] = virt_to_page(buf->virt_addr);
+       }
+
+       /* vmap the prealloc_buf if all the pages were allocated */
+       if (i == n_pages)
+               async->prealloc_buf = vmap(pages, n_pages, VM_MAP,
+                                          COMEDI_PAGE_PROTECTION);
+
+       vfree(pages);
+}
+
+int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
+                    unsigned long new_size)
+{
+       struct comedi_async *async = s->async;
+
+       /* Round up new_size to multiple of PAGE_SIZE */
+       new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
+
+       /* if no change is required, do nothing */
+       if (async->prealloc_buf && async->prealloc_bufsz == new_size)
+               return 0;
+
+       /* deallocate old buffer */
+       __comedi_buf_free(dev, s, async->n_buf_pages);
+
+       /* allocate new buffer */
+       if (new_size) {
+               unsigned n_pages = new_size >> PAGE_SHIFT;
+
+               __comedi_buf_alloc(dev, s, n_pages);
+
+               if (!async->prealloc_buf) {
+                       /* allocation failed */
+                       __comedi_buf_free(dev, s, n_pages);
+                       return -ENOMEM;
+               }
+               async->n_buf_pages = n_pages;
+       }
+       async->prealloc_bufsz = new_size;
+
+       return 0;
+}
+
+void comedi_buf_reset(struct comedi_async *async)
+{
+       async->buf_write_alloc_count = 0;
+       async->buf_write_count = 0;
+       async->buf_read_alloc_count = 0;
+       async->buf_read_count = 0;
+
+       async->buf_write_ptr = 0;
+       async->buf_read_ptr = 0;
+
+       async->cur_chan = 0;
+       async->scan_progress = 0;
+       async->munge_chan = 0;
+       async->munge_count = 0;
+       async->munge_ptr = 0;
+
+       async->events = 0;
+}
+
+static unsigned int comedi_buf_write_n_available(struct comedi_async *async)
+{
+       unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
+
+       return free_end - async->buf_write_alloc_count;
+}
+
+static unsigned int __comedi_buf_write_alloc(struct comedi_async *async,
+                                            unsigned int nbytes,
+                                            int strict)
+{
+       unsigned int available = comedi_buf_write_n_available(async);
+
+       if (nbytes > available)
+               nbytes = strict ? 0 : available;
+
+       async->buf_write_alloc_count += nbytes;
+
+       /*
+        * ensure the async buffer 'counts' are read and updated
+        * before we write data to the write-alloc'ed buffer space
+        */
+       smp_mb();
+
+       return nbytes;
+}
+
+/* allocates chunk for the writer from free buffer space */
+unsigned int comedi_buf_write_alloc(struct comedi_async *async,
+                                   unsigned int nbytes)
+{
+       return __comedi_buf_write_alloc(async, nbytes, 0);
+}
+EXPORT_SYMBOL(comedi_buf_write_alloc);
+
+/*
+ * munging is applied to data by core as it passes between user
+ * and kernel space
+ */
+static unsigned int comedi_buf_munge(struct comedi_async *async,
+                                    unsigned int num_bytes)
+{
+       struct comedi_subdevice *s = async->subdevice;
+       unsigned int count = 0;
+       const unsigned num_sample_bytes = bytes_per_sample(s);
+
+       if (!s->munge || (async->cmd.flags & CMDF_RAWDATA)) {
+               async->munge_count += num_bytes;
+               count = num_bytes;
+       } else {
+               /* don't munge partial samples */
+               num_bytes -= num_bytes % num_sample_bytes;
+               while (count < num_bytes) {
+                       int block_size = num_bytes - count;
+                       unsigned int buf_end;
+
+                       buf_end = async->prealloc_bufsz - async->munge_ptr;
+                       if (block_size > buf_end)
+                               block_size = buf_end;
+
+                       s->munge(s->device, s,
+                                async->prealloc_buf + async->munge_ptr,
+                                block_size, async->munge_chan);
+
+                       /*
+                        * ensure data is munged in buffer before the
+                        * async buffer munge_count is incremented
+                        */
+                       smp_wmb();
+
+                       async->munge_chan += block_size / num_sample_bytes;
+                       async->munge_chan %= async->cmd.chanlist_len;
+                       async->munge_count += block_size;
+                       async->munge_ptr += block_size;
+                       async->munge_ptr %= async->prealloc_bufsz;
+                       count += block_size;
+               }
+       }
+
+       return count;
+}
+
+unsigned int comedi_buf_write_n_allocated(struct comedi_async *async)
+{
+       return async->buf_write_alloc_count - async->buf_write_count;
+}
+
+/* transfers a chunk from writer to filled buffer space */
+unsigned int comedi_buf_write_free(struct comedi_async *async,
+                                  unsigned int nbytes)
+{
+       unsigned int allocated = comedi_buf_write_n_allocated(async);
+
+       if (nbytes > allocated)
+               nbytes = allocated;
+
+       async->buf_write_count += nbytes;
+       async->buf_write_ptr += nbytes;
+       comedi_buf_munge(async, async->buf_write_count - async->munge_count);
+       if (async->buf_write_ptr >= async->prealloc_bufsz)
+               async->buf_write_ptr %= async->prealloc_bufsz;
+
+       return nbytes;
+}
+EXPORT_SYMBOL(comedi_buf_write_free);
+
+unsigned int comedi_buf_read_n_available(struct comedi_async *async)
+{
+       unsigned num_bytes;
+
+       if (!async)
+               return 0;
+
+       num_bytes = async->munge_count - async->buf_read_count;
+
+       /*
+        * ensure the async buffer 'counts' are read before we
+        * attempt to read data from the buffer
+        */
+       smp_rmb();
+
+       return num_bytes;
+}
+EXPORT_SYMBOL(comedi_buf_read_n_available);
+
+/* allocates a chunk for the reader from filled (and munged) buffer space */
+unsigned int comedi_buf_read_alloc(struct comedi_async *async,
+                                  unsigned int nbytes)
+{
+       unsigned int available;
+
+       available = async->munge_count - async->buf_read_alloc_count;
+       if (nbytes > available)
+               nbytes = available;
+
+       async->buf_read_alloc_count += nbytes;
+
+       /*
+        * ensure the async buffer 'counts' are read before we
+        * attempt to read data from the read-alloc'ed buffer space
+        */
+       smp_rmb();
+
+       return nbytes;
+}
+EXPORT_SYMBOL(comedi_buf_read_alloc);
+
+static unsigned int comedi_buf_read_n_allocated(struct comedi_async *async)
+{
+       return async->buf_read_alloc_count - async->buf_read_count;
+}
+
+/* transfers control of a chunk from reader to free buffer space */
+unsigned int comedi_buf_read_free(struct comedi_async *async,
+                                 unsigned int nbytes)
+{
+       unsigned int allocated;
+
+       /*
+        * ensure data has been read out of buffer before
+        * the async read count is incremented
+        */
+       smp_mb();
+
+       allocated = comedi_buf_read_n_allocated(async);
+       if (nbytes > allocated)
+               nbytes = allocated;
+
+       async->buf_read_count += nbytes;
+       async->buf_read_ptr += nbytes;
+       async->buf_read_ptr %= async->prealloc_bufsz;
+       return nbytes;
+}
+EXPORT_SYMBOL(comedi_buf_read_free);
+
+int comedi_buf_put(struct comedi_async *async, short x)
+{
+       unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1);
+
+       if (n < sizeof(short)) {
+               async->events |= COMEDI_CB_ERROR;
+               return 0;
+       }
+       *(short *)(async->prealloc_buf + async->buf_write_ptr) = x;
+       comedi_buf_write_free(async, sizeof(short));
+       return 1;
+}
+EXPORT_SYMBOL(comedi_buf_put);
+
+int comedi_buf_get(struct comedi_async *async, short *x)
+{
+       unsigned int n = comedi_buf_read_n_available(async);
+
+       if (n < sizeof(short))
+               return 0;
+       comedi_buf_read_alloc(async, sizeof(short));
+       *x = *(short *)(async->prealloc_buf + async->buf_read_ptr);
+       comedi_buf_read_free(async, sizeof(short));
+       return 1;
+}
+EXPORT_SYMBOL(comedi_buf_get);
+
+void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
+                         const void *data, unsigned int num_bytes)
+{
+       unsigned int write_ptr = async->buf_write_ptr + offset;
+
+       if (write_ptr >= async->prealloc_bufsz)
+               write_ptr %= async->prealloc_bufsz;
+
+       while (num_bytes) {
+               unsigned int block_size;
+
+               if (write_ptr + num_bytes > async->prealloc_bufsz)
+                       block_size = async->prealloc_bufsz - write_ptr;
+               else
+                       block_size = num_bytes;
+
+               memcpy(async->prealloc_buf + write_ptr, data, block_size);
+
+               data += block_size;
+               num_bytes -= block_size;
+
+               write_ptr = 0;
+       }
+}
+EXPORT_SYMBOL(comedi_buf_memcpy_to);
+
+void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
+                           void *dest, unsigned int nbytes)
+{
+       void *src;
+       unsigned int read_ptr = async->buf_read_ptr + offset;
+
+       if (read_ptr >= async->prealloc_bufsz)
+               read_ptr %= async->prealloc_bufsz;
+
+       while (nbytes) {
+               unsigned int block_size;
+
+               src = async->prealloc_buf + read_ptr;
+
+               if (nbytes >= async->prealloc_bufsz - read_ptr)
+                       block_size = async->prealloc_bufsz - read_ptr;
+               else
+                       block_size = nbytes;
+
+               memcpy(dest, src, block_size);
+               nbytes -= block_size;
+               dest += block_size;
+               read_ptr = 0;
+       }
+}
+EXPORT_SYMBOL(comedi_buf_memcpy_from);
index 4b7cbfad1d74ff31914a4ea32a6047472c94fdd9..ad208cdd53d406f8ad8151038b91ae49ce700c87 100644 (file)
@@ -30,8 +30,6 @@
 #include "comedi.h"
 #include "comedi_compat32.h"
 
-#ifdef CONFIG_COMPAT
-
 #define COMEDI32_CHANINFO _IOR(CIO, 3, struct comedi32_chaninfo_struct)
 #define COMEDI32_RANGEINFO _IOR(CIO, 8, struct comedi32_rangeinfo_struct)
 /* N.B. COMEDI32_CMD and COMEDI_CMD ought to use _IOWR, not _IOR.
@@ -460,5 +458,3 @@ long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        return raw_ioctl(file, cmd, arg);
 }
-
-#endif /* CONFIG_COMPAT */
index 9b038e4a7e711eea1b5bd3873706847b701de2fe..b798e42ee0147c6685512d5612e76595bd9266e3 100644 (file)
 
 #include "comedi_internal.h"
 
-MODULE_AUTHOR("http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi core module");
-MODULE_LICENSE("GPL");
-
 #ifdef CONFIG_COMEDI_DEBUG
 int comedi_debug;
 EXPORT_SYMBOL(comedi_debug);
@@ -62,7 +58,7 @@ MODULE_PARM_DESC(comedi_debug,
                );
 #endif
 
-bool comedi_autoconfig = 1;
+bool comedi_autoconfig = true;
 module_param(comedi_autoconfig, bool, S_IRUGO);
 MODULE_PARM_DESC(comedi_autoconfig,
                 "enable drivers to auto-configure comedi devices (default 1)");
@@ -86,17 +82,58 @@ MODULE_PARM_DESC(comedi_default_buf_maxsize_kb,
                 "default maximum size of asynchronous buffer in KiB (default "
                 __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")");
 
+struct comedi_file_info {
+       struct comedi_device *device;
+       struct comedi_subdevice *read_subdevice;
+       struct comedi_subdevice *write_subdevice;
+       struct device *hardware_device;
+};
+
 static DEFINE_SPINLOCK(comedi_file_info_table_lock);
-static struct comedi_device_file_info
-*comedi_file_info_table[COMEDI_NUM_MINORS];
+static struct comedi_file_info *comedi_file_info_table[COMEDI_NUM_MINORS];
 
-static void do_become_nonbusy(struct comedi_device *dev,
-                             struct comedi_subdevice *s);
-static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static struct comedi_file_info *comedi_file_info_from_minor(unsigned minor)
+{
+       struct comedi_file_info *info;
+
+       BUG_ON(minor >= COMEDI_NUM_MINORS);
+       spin_lock(&comedi_file_info_table_lock);
+       info = comedi_file_info_table[minor];
+       spin_unlock(&comedi_file_info_table_lock);
+       return info;
+}
+
+static struct comedi_device *
+comedi_dev_from_file_info(struct comedi_file_info *info)
+{
+       return info ? info->device : NULL;
+}
+
+struct comedi_device *comedi_dev_from_minor(unsigned minor)
+{
+       return comedi_dev_from_file_info(comedi_file_info_from_minor(minor));
+}
+EXPORT_SYMBOL_GPL(comedi_dev_from_minor);
 
-static int comedi_fasync(int fd, struct file *file, int on);
+static struct comedi_subdevice *
+comedi_read_subdevice(const struct comedi_file_info *info)
+{
+       if (info->read_subdevice)
+               return info->read_subdevice;
+       if (info->device)
+               return info->device->read_subdev;
+       return NULL;
+}
 
-static int is_device_busy(struct comedi_device *dev);
+static struct comedi_subdevice *
+comedi_write_subdevice(const struct comedi_file_info *info)
+{
+       if (info->write_subdevice)
+               return info->write_subdevice;
+       if (info->device)
+               return info->device->write_subdev;
+       return NULL;
+}
 
 static int resize_async_buffer(struct comedi_device *dev,
                               struct comedi_subdevice *s,
@@ -134,7 +171,7 @@ static int resize_async_buffer(struct comedi_device *dev,
        }
 
        DPRINTK("comedi%i subd %d buffer resized to %i bytes\n",
-               dev->minor, (int)(s - dev->subdevices), async->prealloc_bufsz);
+               dev->minor, s->index, async->prealloc_bufsz);
        return 0;
 }
 
@@ -143,8 +180,8 @@ static int resize_async_buffer(struct comedi_device *dev,
 static ssize_t show_max_read_buffer_kb(struct device *dev,
                                       struct device_attribute *attr, char *buf)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_read_subdevice(info);
        unsigned int size = 0;
 
        mutex_lock(&info->device->mutex);
@@ -159,8 +196,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
                                        struct device_attribute *attr,
                                        const char *buf, size_t count)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_read_subdevice(info);
        unsigned int size;
        int err;
 
@@ -184,8 +221,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
 static ssize_t show_read_buffer_kb(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_read_subdevice(info);
        unsigned int size = 0;
 
        mutex_lock(&info->device->mutex);
@@ -200,8 +237,8 @@ static ssize_t store_read_buffer_kb(struct device *dev,
                                    struct device_attribute *attr,
                                    const char *buf, size_t count)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_read_subdevice(info);
        unsigned int size;
        int err;
 
@@ -226,8 +263,8 @@ static ssize_t show_max_write_buffer_kb(struct device *dev,
                                        struct device_attribute *attr,
                                        char *buf)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_write_subdevice(info);
        unsigned int size = 0;
 
        mutex_lock(&info->device->mutex);
@@ -242,8 +279,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
                                         struct device_attribute *attr,
                                         const char *buf, size_t count)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_write_subdevice(info);
        unsigned int size;
        int err;
 
@@ -267,8 +304,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
 static ssize_t show_write_buffer_kb(struct device *dev,
                                    struct device_attribute *attr, char *buf)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_write_subdevice(info);
        unsigned int size = 0;
 
        mutex_lock(&info->device->mutex);
@@ -283,8 +320,8 @@ static ssize_t store_write_buffer_kb(struct device *dev,
                                     struct device_attribute *attr,
                                     const char *buf, size_t count)
 {
-       struct comedi_device_file_info *info = dev_get_drvdata(dev);
-       struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+       struct comedi_file_info *info = dev_get_drvdata(dev);
+       struct comedi_subdevice *s = comedi_write_subdevice(info);
        unsigned int size;
        int err;
 
@@ -317,6 +354,103 @@ static struct device_attribute comedi_dev_attrs[] = {
        __ATTR_NULL
 };
 
+static void comedi_set_subdevice_runflags(struct comedi_subdevice *s,
+                                         unsigned mask, unsigned bits)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&s->spin_lock, flags);
+       s->runflags &= ~mask;
+       s->runflags |= (bits & mask);
+       spin_unlock_irqrestore(&s->spin_lock, flags);
+}
+
+static unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s)
+{
+       unsigned long flags;
+       unsigned runflags;
+
+       spin_lock_irqsave(&s->spin_lock, flags);
+       runflags = s->runflags;
+       spin_unlock_irqrestore(&s->spin_lock, flags);
+       return runflags;
+}
+
+bool comedi_is_subdevice_running(struct comedi_subdevice *s)
+{
+       unsigned runflags = comedi_get_subdevice_runflags(s);
+
+       return (runflags & SRF_RUNNING) ? true : false;
+}
+EXPORT_SYMBOL_GPL(comedi_is_subdevice_running);
+
+static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s)
+{
+       unsigned runflags = comedi_get_subdevice_runflags(s);
+
+       return (runflags & SRF_ERROR) ? true : false;
+}
+
+static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
+{
+       unsigned runflags = comedi_get_subdevice_runflags(s);
+
+       return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true;
+}
+
+/*
+   This function restores a subdevice to an idle state.
+ */
+static void do_become_nonbusy(struct comedi_device *dev,
+                             struct comedi_subdevice *s)
+{
+       struct comedi_async *async = s->async;
+
+       comedi_set_subdevice_runflags(s, SRF_RUNNING, 0);
+       if (async) {
+               comedi_buf_reset(async);
+               async->inttrig = NULL;
+               kfree(async->cmd.chanlist);
+               async->cmd.chanlist = NULL;
+       } else {
+               dev_err(dev->class_dev,
+                       "BUG: (?) do_become_nonbusy called with async=NULL\n");
+       }
+
+       s->busy = NULL;
+}
+
+static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+{
+       int ret = 0;
+
+       if (comedi_is_subdevice_running(s) && s->cancel)
+               ret = s->cancel(dev, s);
+
+       do_become_nonbusy(dev, s);
+
+       return ret;
+}
+
+static int is_device_busy(struct comedi_device *dev)
+{
+       struct comedi_subdevice *s;
+       int i;
+
+       if (!dev->attached)
+               return 0;
+
+       for (i = 0; i < dev->n_subdevices; i++) {
+               s = &dev->subdevices[i];
+               if (s->busy)
+                       return 1;
+               if (s->async && s->async->mmap_count)
+                       return 1;
+       }
+
+       return 0;
+}
+
 /*
        COMEDI_DEVCONFIG
        device config ioctl
@@ -335,8 +469,6 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
 {
        struct comedi_devconfig it;
        int ret;
-       unsigned char *aux_data = NULL;
-       int aux_len;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
@@ -352,36 +484,15 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
                return 0;
        }
 
-       if (copy_from_user(&it, arg, sizeof(struct comedi_devconfig)))
+       if (copy_from_user(&it, arg, sizeof(it)))
                return -EFAULT;
 
        it.board_name[COMEDI_NAMELEN - 1] = 0;
 
-       if (comedi_aux_data(it.options, 0) &&
-           it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
-               int bit_shift;
-               aux_len = it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
-               if (aux_len < 0)
-                       return -EFAULT;
-
-               aux_data = vmalloc(aux_len);
-               if (!aux_data)
-                       return -ENOMEM;
-
-               if (copy_from_user(aux_data,
-                                  (unsigned char __user *
-                                   )comedi_aux_data(it.options, 0), aux_len)) {
-                       vfree(aux_data);
-                       return -EFAULT;
-               }
-               it.options[COMEDI_DEVCONF_AUX_DATA_LO] =
-                   (unsigned long)aux_data;
-               if (sizeof(void *) > sizeof(int)) {
-                       bit_shift = sizeof(int) * 8;
-                       it.options[COMEDI_DEVCONF_AUX_DATA_HI] =
-                           ((unsigned long)aux_data) >> bit_shift;
-               } else
-                       it.options[COMEDI_DEVCONF_AUX_DATA_HI] = 0;
+       if (it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
+               dev_warn(dev->class_dev,
+                        "comedi_config --init_data is deprecated\n");
+               return -EINVAL;
        }
 
        ret = comedi_device_attach(dev, &it);
@@ -392,9 +503,6 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
                }
        }
 
-       if (aux_data)
-               vfree(aux_data);
-
        return ret;
 }
 
@@ -420,7 +528,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev,
        struct comedi_subdevice *s;
        int retval = 0;
 
-       if (copy_from_user(&bc, arg, sizeof(struct comedi_bufconfig)))
+       if (copy_from_user(&bc, arg, sizeof(bc)))
                return -EFAULT;
 
        if (bc.subdevice >= dev->n_subdevices || bc.subdevice < 0)
@@ -453,7 +561,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev,
        bc.maximum_size = async->max_bufsize;
 
 copyback:
-       if (copy_to_user(arg, &bc, sizeof(struct comedi_bufconfig)))
+       if (copy_to_user(arg, &bc, sizeof(bc)))
                return -EFAULT;
 
        return 0;
@@ -477,14 +585,10 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
                            struct comedi_devinfo __user *arg,
                            struct file *file)
 {
-       struct comedi_devinfo devinfo;
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_device_file_info *dev_file_info =
-           comedi_get_device_file_info(minor);
-       struct comedi_subdevice *read_subdev =
-           comedi_get_read_subdevice(dev_file_info);
-       struct comedi_subdevice *write_subdev =
-           comedi_get_write_subdevice(dev_file_info);
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_subdevice *s;
+       struct comedi_devinfo devinfo;
 
        memset(&devinfo, 0, sizeof(devinfo));
 
@@ -494,17 +598,19 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
        strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
        strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
 
-       if (read_subdev)
-               devinfo.read_subdevice = read_subdev - dev->subdevices;
+       s = comedi_read_subdevice(info);
+       if (s)
+               devinfo.read_subdevice = s->index;
        else
                devinfo.read_subdevice = -1;
 
-       if (write_subdev)
-               devinfo.write_subdevice = write_subdev - dev->subdevices;
+       s = comedi_write_subdevice(info);
+       if (s)
+               devinfo.write_subdevice = s->index;
        else
                devinfo.write_subdevice = -1;
 
-       if (copy_to_user(arg, &devinfo, sizeof(struct comedi_devinfo)))
+       if (copy_to_user(arg, &devinfo, sizeof(devinfo)))
                return -EFAULT;
 
        return 0;
@@ -531,9 +637,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev,
        struct comedi_subdinfo *tmp, *us;
        struct comedi_subdevice *s;
 
-       tmp =
-           kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo),
-                   GFP_KERNEL);
+       tmp = kcalloc(dev->n_subdevices, sizeof(*tmp), GFP_KERNEL);
        if (!tmp)
                return -ENOMEM;
 
@@ -545,7 +649,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev,
                us->type = s->type;
                us->n_chan = s->n_chan;
                us->subd_flags = s->subdev_flags;
-               if (comedi_get_subdevice_runflags(s) & SRF_RUNNING)
+               if (comedi_is_subdevice_running(s))
                        us->subd_flags |= SDF_RUNNING;
 #define TIMER_nanosec 5                /* backwards compatibility */
                us->timer_type = TIMER_nanosec;
@@ -584,8 +688,7 @@ static int do_subdinfo_ioctl(struct comedi_device *dev,
                us->settling_time_0 = s->settling_time_0;
        }
 
-       ret = copy_to_user(arg, tmp,
-                          dev->n_subdevices * sizeof(struct comedi_subdinfo));
+       ret = copy_to_user(arg, tmp, dev->n_subdevices * sizeof(*tmp));
 
        kfree(tmp);
 
@@ -612,7 +715,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev,
        struct comedi_subdevice *s;
        struct comedi_chaninfo it;
 
-       if (copy_from_user(&it, arg, sizeof(struct comedi_chaninfo)))
+       if (copy_from_user(&it, arg, sizeof(it)))
                return -EFAULT;
 
        if (it.subdev >= dev->n_subdevices)
@@ -679,7 +782,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
        struct comedi_subdevice *s;
        struct comedi_async *async;
 
-       if (copy_from_user(&bi, arg, sizeof(struct comedi_bufinfo)))
+       if (copy_from_user(&bi, arg, sizeof(bi)))
                return -EFAULT;
 
        if (bi.subdevice >= dev->n_subdevices || bi.subdevice < 0)
@@ -714,9 +817,8 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
                bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read);
                comedi_buf_read_free(async, bi.bytes_read);
 
-               if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR |
-                                                         SRF_RUNNING))
-                   && async->buf_write_count == async->buf_read_count) {
+               if (comedi_is_subdevice_idle(s) &&
+                   async->buf_write_count == async->buf_read_count) {
                        do_become_nonbusy(dev, s);
                }
        }
@@ -734,103 +836,12 @@ copyback_position:
        bi.buf_read_ptr = async->buf_read_ptr;
 
 copyback:
-       if (copy_to_user(arg, &bi, sizeof(struct comedi_bufinfo)))
+       if (copy_to_user(arg, &bi, sizeof(bi)))
                return -EFAULT;
 
        return 0;
 }
 
-static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
-                     unsigned int *data, void *file);
-/*
- *     COMEDI_INSNLIST
- *     synchronous instructions
- *
- *     arg:
- *             pointer to sync cmd structure
- *
- *     reads:
- *             sync cmd struct at arg
- *             instruction list
- *             data (for writes)
- *
- *     writes:
- *             data (for reads)
- */
-/* arbitrary limits */
-#define MAX_SAMPLES 256
-static int do_insnlist_ioctl(struct comedi_device *dev,
-                            struct comedi_insnlist __user *arg, void *file)
-{
-       struct comedi_insnlist insnlist;
-       struct comedi_insn *insns = NULL;
-       unsigned int *data = NULL;
-       int i = 0;
-       int ret = 0;
-
-       if (copy_from_user(&insnlist, arg, sizeof(struct comedi_insnlist)))
-               return -EFAULT;
-
-       data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL);
-       if (!data) {
-               DPRINTK("kmalloc failed\n");
-               ret = -ENOMEM;
-               goto error;
-       }
-
-       insns =
-           kcalloc(insnlist.n_insns, sizeof(struct comedi_insn), GFP_KERNEL);
-       if (!insns) {
-               DPRINTK("kmalloc failed\n");
-               ret = -ENOMEM;
-               goto error;
-       }
-
-       if (copy_from_user(insns, insnlist.insns,
-                          sizeof(struct comedi_insn) * insnlist.n_insns)) {
-               DPRINTK("copy_from_user failed\n");
-               ret = -EFAULT;
-               goto error;
-       }
-
-       for (i = 0; i < insnlist.n_insns; i++) {
-               if (insns[i].n > MAX_SAMPLES) {
-                       DPRINTK("number of samples too large\n");
-                       ret = -EINVAL;
-                       goto error;
-               }
-               if (insns[i].insn & INSN_MASK_WRITE) {
-                       if (copy_from_user(data, insns[i].data,
-                                          insns[i].n * sizeof(unsigned int))) {
-                               DPRINTK("copy_from_user failed\n");
-                               ret = -EFAULT;
-                               goto error;
-                       }
-               }
-               ret = parse_insn(dev, insns + i, data, file);
-               if (ret < 0)
-                       goto error;
-               if (insns[i].insn & INSN_MASK_READ) {
-                       if (copy_to_user(insns[i].data, data,
-                                        insns[i].n * sizeof(unsigned int))) {
-                               DPRINTK("copy_to_user failed\n");
-                               ret = -EFAULT;
-                               goto error;
-                       }
-               }
-               if (need_resched())
-                       schedule();
-       }
-
-error:
-       kfree(insns);
-       kfree(data);
-
-       if (ret < 0)
-               return ret;
-       return i;
-}
-
 static int check_insn_config_length(struct comedi_insn *insn,
                                    unsigned int *data)
 {
@@ -1062,76 +1073,153 @@ out:
 }
 
 /*
- *     COMEDI_INSN
+ *     COMEDI_INSNLIST
  *     synchronous instructions
  *
  *     arg:
- *             pointer to insn
+ *             pointer to sync cmd structure
  *
  *     reads:
- *             struct comedi_insn struct at arg
+ *             sync cmd struct at arg
+ *             instruction list
  *             data (for writes)
  *
  *     writes:
  *             data (for reads)
  */
-static int do_insn_ioctl(struct comedi_device *dev,
-                        struct comedi_insn __user *arg, void *file)
+/* arbitrary limits */
+#define MAX_SAMPLES 256
+static int do_insnlist_ioctl(struct comedi_device *dev,
+                            struct comedi_insnlist __user *arg, void *file)
 {
-       struct comedi_insn insn;
+       struct comedi_insnlist insnlist;
+       struct comedi_insn *insns = NULL;
        unsigned int *data = NULL;
+       int i = 0;
        int ret = 0;
 
+       if (copy_from_user(&insnlist, arg, sizeof(insnlist)))
+               return -EFAULT;
+
        data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL);
        if (!data) {
+               DPRINTK("kmalloc failed\n");
                ret = -ENOMEM;
                goto error;
        }
 
-       if (copy_from_user(&insn, arg, sizeof(struct comedi_insn))) {
-               ret = -EFAULT;
+       insns = kcalloc(insnlist.n_insns, sizeof(*insns), GFP_KERNEL);
+       if (!insns) {
+               DPRINTK("kmalloc failed\n");
+               ret = -ENOMEM;
                goto error;
        }
 
-       /* This is where the behavior of insn and insnlist deviate. */
-       if (insn.n > MAX_SAMPLES)
-               insn.n = MAX_SAMPLES;
-       if (insn.insn & INSN_MASK_WRITE) {
-               if (copy_from_user(data,
-                                  insn.data,
-                                  insn.n * sizeof(unsigned int))) {
-                       ret = -EFAULT;
-                       goto error;
-               }
-       }
-       ret = parse_insn(dev, &insn, data, file);
-       if (ret < 0)
+       if (copy_from_user(insns, insnlist.insns,
+                          sizeof(*insns) * insnlist.n_insns)) {
+               DPRINTK("copy_from_user failed\n");
+               ret = -EFAULT;
                goto error;
-       if (insn.insn & INSN_MASK_READ) {
-               if (copy_to_user(insn.data,
-                                data,
-                                insn.n * sizeof(unsigned int))) {
-                       ret = -EFAULT;
-                       goto error;
-               }
        }
-       ret = insn.n;
-
-error:
-       kfree(data);
 
-       return ret;
+       for (i = 0; i < insnlist.n_insns; i++) {
+               if (insns[i].n > MAX_SAMPLES) {
+                       DPRINTK("number of samples too large\n");
+                       ret = -EINVAL;
+                       goto error;
+               }
+               if (insns[i].insn & INSN_MASK_WRITE) {
+                       if (copy_from_user(data, insns[i].data,
+                                          insns[i].n * sizeof(unsigned int))) {
+                               DPRINTK("copy_from_user failed\n");
+                               ret = -EFAULT;
+                               goto error;
+                       }
+               }
+               ret = parse_insn(dev, insns + i, data, file);
+               if (ret < 0)
+                       goto error;
+               if (insns[i].insn & INSN_MASK_READ) {
+                       if (copy_to_user(insns[i].data, data,
+                                        insns[i].n * sizeof(unsigned int))) {
+                               DPRINTK("copy_to_user failed\n");
+                               ret = -EFAULT;
+                               goto error;
+                       }
+               }
+               if (need_resched())
+                       schedule();
+       }
+
+error:
+       kfree(insns);
+       kfree(data);
+
+       if (ret < 0)
+               return ret;
+       return i;
 }
 
-static void comedi_set_subdevice_runflags(struct comedi_subdevice *s,
-                                         unsigned mask, unsigned bits)
+/*
+ *     COMEDI_INSN
+ *     synchronous instructions
+ *
+ *     arg:
+ *             pointer to insn
+ *
+ *     reads:
+ *             struct comedi_insn struct at arg
+ *             data (for writes)
+ *
+ *     writes:
+ *             data (for reads)
+ */
+static int do_insn_ioctl(struct comedi_device *dev,
+                        struct comedi_insn __user *arg, void *file)
 {
-       unsigned long flags;
+       struct comedi_insn insn;
+       unsigned int *data = NULL;
+       int ret = 0;
 
-       spin_lock_irqsave(&s->spin_lock, flags);
-       s->runflags &= ~mask;
-       s->runflags |= (bits & mask);
-       spin_unlock_irqrestore(&s->spin_lock, flags);
+       data = kmalloc(sizeof(unsigned int) * MAX_SAMPLES, GFP_KERNEL);
+       if (!data) {
+               ret = -ENOMEM;
+               goto error;
+       }
+
+       if (copy_from_user(&insn, arg, sizeof(insn))) {
+               ret = -EFAULT;
+               goto error;
+       }
+
+       /* This is where the behavior of insn and insnlist deviate. */
+       if (insn.n > MAX_SAMPLES)
+               insn.n = MAX_SAMPLES;
+       if (insn.insn & INSN_MASK_WRITE) {
+               if (copy_from_user(data,
+                                  insn.data,
+                                  insn.n * sizeof(unsigned int))) {
+                       ret = -EFAULT;
+                       goto error;
+               }
+       }
+       ret = parse_insn(dev, &insn, data, file);
+       if (ret < 0)
+               goto error;
+       if (insn.insn & INSN_MASK_READ) {
+               if (copy_to_user(insn.data,
+                                data,
+                                insn.n * sizeof(unsigned int))) {
+                       ret = -EFAULT;
+                       goto error;
+               }
+       }
+       ret = insn.n;
+
+error:
+       kfree(data);
+
+       return ret;
 }
 
 static int do_cmd_ioctl(struct comedi_device *dev,
@@ -1143,7 +1231,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
        int ret = 0;
        unsigned int __user *user_chanlist;
 
-       if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) {
+       if (copy_from_user(&cmd, arg, sizeof(cmd))) {
                DPRINTK("bad cmd address\n");
                return -EFAULT;
        }
@@ -1233,7 +1321,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
                /* restore chanlist pointer before copying back */
                cmd.chanlist = (unsigned int __force *)user_chanlist;
                cmd.data = NULL;
-               if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) {
+               if (copy_to_user(arg, &cmd, sizeof(cmd))) {
                        DPRINTK("fault writing cmd\n");
                        ret = -EFAULT;
                        goto cleanup;
@@ -1248,7 +1336,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
                goto cleanup;
        }
 
-       comedi_reset_async_buf(async);
+       comedi_buf_reset(async);
 
        async->cb_mask =
            COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR |
@@ -1292,7 +1380,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
        unsigned int *chanlist = NULL;
        unsigned int __user *user_chanlist;
 
-       if (copy_from_user(&cmd, arg, sizeof(struct comedi_cmd))) {
+       if (copy_from_user(&cmd, arg, sizeof(cmd))) {
                DPRINTK("bad cmd address\n");
                return -EFAULT;
        }
@@ -1356,7 +1444,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
        /* restore chanlist pointer before copying back */
        cmd.chanlist = (unsigned int __force *)user_chanlist;
 
-       if (copy_to_user(arg, &cmd, sizeof(struct comedi_cmd))) {
+       if (copy_to_user(arg, &cmd, sizeof(cmd))) {
                DPRINTK("bad cmd address\n");
                ret = -EFAULT;
                goto cleanup;
@@ -1533,14 +1621,12 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
                                  unsigned long arg)
 {
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_device_file_info *dev_file_info =
-           comedi_get_device_file_info(minor);
-       struct comedi_device *dev;
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_device *dev = comedi_dev_from_file_info(info);
        int rc;
 
-       if (dev_file_info == NULL || dev_file_info->device == NULL)
+       if (!dev)
                return -ENODEV;
-       dev = dev_file_info->device;
 
        mutex_lock(&dev->mutex);
 
@@ -1551,7 +1637,7 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
                                        (struct comedi_devconfig __user *)arg);
                if (rc == 0)
                        /* Evade comedi_auto_unconfig(). */
-                       dev_file_info->hardware_device = NULL;
+                       info->hardware_device = NULL;
                goto done;
        }
 
@@ -1624,19 +1710,6 @@ done:
        return rc;
 }
 
-static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       int ret = 0;
-
-       if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) && s->cancel)
-               ret = s->cancel(dev, s);
-
-       do_become_nonbusy(dev, s);
-
-       return ret;
-}
-
-
 static void comedi_vm_open(struct vm_area_struct *area)
 {
        struct comedi_async *async;
@@ -1671,40 +1744,38 @@ static struct vm_operations_struct comedi_vm_ops = {
 static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
 {
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_async *async = NULL;
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_device *dev = comedi_dev_from_file_info(info);
+       struct comedi_subdevice *s;
+       struct comedi_async *async;
        unsigned long start = vma->vm_start;
        unsigned long size;
        int n_pages;
        int i;
        int retval;
-       struct comedi_subdevice *s;
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
 
-       dev_file_info = comedi_get_device_file_info(minor);
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        mutex_lock(&dev->mutex);
+
        if (!dev->attached) {
                DPRINTK("no driver configured on comedi%i\n", dev->minor);
                retval = -ENODEV;
                goto done;
        }
+
        if (vma->vm_flags & VM_WRITE)
-               s = comedi_get_write_subdevice(dev_file_info);
+               s = comedi_write_subdevice(info);
        else
-               s = comedi_get_read_subdevice(dev_file_info);
-
-       if (s == NULL) {
+               s = comedi_read_subdevice(info);
+       if (!s) {
                retval = -EINVAL;
                goto done;
        }
+
        async = s->async;
-       if (async == NULL) {
+       if (!async) {
                retval = -EINVAL;
                goto done;
        }
@@ -1727,11 +1798,11 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
 
        n_pages = size >> PAGE_SHIFT;
        for (i = 0; i < n_pages; ++i) {
+               struct comedi_buf_page *buf = &async->buf_page_list[i];
+
                if (remap_pfn_range(vma, start,
-                                   page_to_pfn(virt_to_page
-                                               (async->buf_page_list
-                                                [i].virt_addr)), PAGE_SIZE,
-                                   PAGE_SHARED)) {
+                                   page_to_pfn(virt_to_page(buf->virt_addr)),
+                                   PAGE_SIZE, PAGE_SHARED)) {
                        retval = -EAGAIN;
                        goto done;
                }
@@ -1753,50 +1824,40 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
 {
        unsigned int mask = 0;
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_subdevice *read_subdev;
-       struct comedi_subdevice *write_subdev;
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
-       dev_file_info = comedi_get_device_file_info(minor);
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_device *dev = comedi_dev_from_file_info(info);
+       struct comedi_subdevice *s;
 
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        mutex_lock(&dev->mutex);
+
        if (!dev->attached) {
                DPRINTK("no driver configured on comedi%i\n", dev->minor);
-               mutex_unlock(&dev->mutex);
-               return 0;
+               goto done;
        }
 
-       mask = 0;
-       read_subdev = comedi_get_read_subdevice(dev_file_info);
-       if (read_subdev) {
-               poll_wait(file, &read_subdev->async->wait_head, wait);
-               if (!read_subdev->busy
-                   || comedi_buf_read_n_available(read_subdev->async) > 0
-                   || !(comedi_get_subdevice_runflags(read_subdev) &
-                        SRF_RUNNING)) {
+       s = comedi_read_subdevice(info);
+       if (s) {
+               poll_wait(file, &s->async->wait_head, wait);
+               if (!s->busy || !comedi_is_subdevice_running(s) ||
+                   comedi_buf_read_n_available(s->async) > 0)
                        mask |= POLLIN | POLLRDNORM;
-               }
        }
-       write_subdev = comedi_get_write_subdevice(dev_file_info);
-       if (write_subdev) {
-               poll_wait(file, &write_subdev->async->wait_head, wait);
-               comedi_buf_write_alloc(write_subdev->async,
-                                      write_subdev->async->prealloc_bufsz);
-               if (!write_subdev->busy
-                   || !(comedi_get_subdevice_runflags(write_subdev) &
-                        SRF_RUNNING)
-                   || comedi_buf_write_n_allocated(write_subdev->async) >=
-                   bytes_per_sample(write_subdev->async->subdevice)) {
+
+       s = comedi_write_subdevice(info);
+       if (s) {
+               unsigned int bps = bytes_per_sample(s->async->subdevice);
+
+               poll_wait(file, &s->async->wait_head, wait);
+               comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz);
+               if (!s->busy || !comedi_is_subdevice_running(s) ||
+                   comedi_buf_write_n_allocated(s->async) >= bps)
                        mask |= POLLOUT | POLLWRNORM;
-               }
        }
 
+done:
        mutex_unlock(&dev->mutex);
        return mask;
 }
@@ -1809,53 +1870,38 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
        int n, m, count = 0, retval = 0;
        DECLARE_WAITQUEUE(wait, current);
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
-       dev_file_info = comedi_get_device_file_info(minor);
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_device *dev = comedi_dev_from_file_info(info);
 
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        if (!dev->attached) {
                DPRINTK("no driver configured on comedi%i\n", dev->minor);
-               retval = -ENODEV;
-               goto done;
+               return -ENODEV;
        }
 
-       s = comedi_get_write_subdevice(dev_file_info);
-       if (s == NULL) {
-               retval = -EIO;
-               goto done;
-       }
+       s = comedi_write_subdevice(info);
+       if (!s)
+               return -EIO;
+
        async = s->async;
 
-       if (!nbytes) {
-               retval = 0;
-               goto done;
-       }
-       if (!s->busy) {
-               retval = 0;
-               goto done;
-       }
-       if (s->busy != file) {
-               retval = -EACCES;
-               goto done;
-       }
+       if (!s->busy || !nbytes)
+               return 0;
+       if (s->busy != file)
+               return -EACCES;
+
        add_wait_queue(&async->wait_head, &wait);
        while (nbytes > 0 && !retval) {
                set_current_state(TASK_INTERRUPTIBLE);
 
-               if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
+               if (!comedi_is_subdevice_running(s)) {
                        if (count == 0) {
-                               if (comedi_get_subdevice_runflags(s) &
-                                       SRF_ERROR) {
+                               if (comedi_is_subdevice_in_error(s))
                                        retval = -EPIPE;
-                               } else {
+                               else
                                        retval = 0;
-                               }
                                do_become_nonbusy(dev, s);
                        }
                        break;
@@ -1908,7 +1954,6 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&async->wait_head, &wait);
 
-done:
        return count ? count : retval;
 }
 
@@ -1920,40 +1965,26 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
        int n, m, count = 0, retval = 0;
        DECLARE_WAITQUEUE(wait, current);
        const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
-       dev_file_info = comedi_get_device_file_info(minor);
+       struct comedi_file_info *info = comedi_file_info_from_minor(minor);
+       struct comedi_device *dev = comedi_dev_from_file_info(info);
 
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        if (!dev->attached) {
                DPRINTK("no driver configured on comedi%i\n", dev->minor);
-               retval = -ENODEV;
-               goto done;
+               return -ENODEV;
        }
 
-       s = comedi_get_read_subdevice(dev_file_info);
-       if (s == NULL) {
-               retval = -EIO;
-               goto done;
-       }
+       s = comedi_read_subdevice(info);
+       if (!s)
+               return -EIO;
+
        async = s->async;
-       if (!nbytes) {
-               retval = 0;
-               goto done;
-       }
-       if (!s->busy) {
-               retval = 0;
-               goto done;
-       }
-       if (s->busy != file) {
-               retval = -EACCES;
-               goto done;
-       }
+       if (!s->busy || !nbytes)
+               return 0;
+       if (s->busy != file)
+               return -EACCES;
 
        add_wait_queue(&async->wait_head, &wait);
        while (nbytes > 0 && !retval) {
@@ -1970,14 +2001,12 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                        n = m;
 
                if (n == 0) {
-                       if (!(comedi_get_subdevice_runflags(s) & SRF_RUNNING)) {
+                       if (!comedi_is_subdevice_running(s)) {
                                do_become_nonbusy(dev, s);
-                               if (comedi_get_subdevice_runflags(s) &
-                                   SRF_ERROR) {
+                               if (comedi_is_subdevice_in_error(s))
                                        retval = -EPIPE;
-                               } else {
+                               else
                                        retval = 0;
-                               }
                                break;
                        }
                        if (file->f_flags & O_NONBLOCK) {
@@ -2015,48 +2044,22 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                buf += n;
                break;          /* makes device work like a pipe */
        }
-       if (!(comedi_get_subdevice_runflags(s) & (SRF_ERROR | SRF_RUNNING)) &&
+       if (comedi_is_subdevice_idle(s) &&
            async->buf_read_count - async->buf_write_count == 0) {
                do_become_nonbusy(dev, s);
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&async->wait_head, &wait);
 
-done:
        return count ? count : retval;
 }
 
-/*
-   This function restores a subdevice to an idle state.
- */
-static void do_become_nonbusy(struct comedi_device *dev,
-                             struct comedi_subdevice *s)
-{
-       struct comedi_async *async = s->async;
-
-       comedi_set_subdevice_runflags(s, SRF_RUNNING, 0);
-       if (async) {
-               comedi_reset_async_buf(async);
-               async->inttrig = NULL;
-               kfree(async->cmd.chanlist);
-               async->cmd.chanlist = NULL;
-       } else {
-               dev_err(dev->class_dev,
-                       "BUG: (?) do_become_nonbusy called with async=NULL\n");
-       }
-
-       s->busy = NULL;
-}
-
 static int comedi_open(struct inode *inode, struct file *file)
 {
        const unsigned minor = iminor(inode);
-       struct comedi_device_file_info *dev_file_info =
-           comedi_get_device_file_info(minor);
-       struct comedi_device *dev =
-           dev_file_info ? dev_file_info->device : NULL;
+       struct comedi_device *dev = comedi_dev_from_minor(minor);
 
-       if (dev == NULL) {
+       if (!dev) {
                DPRINTK("invalid minor number\n");
                return -ENODEV;
        }
@@ -2128,19 +2131,25 @@ ok:
        return 0;
 }
 
+static int comedi_fasync(int fd, struct file *file, int on)
+{
+       const unsigned minor = iminor(file->f_dentry->d_inode);
+       struct comedi_device *dev = comedi_dev_from_minor(minor);
+
+       if (!dev)
+               return -ENODEV;
+
+       return fasync_helper(fd, file, on, &dev->async_queue);
+}
+
 static int comedi_close(struct inode *inode, struct file *file)
 {
        const unsigned minor = iminor(inode);
+       struct comedi_device *dev = comedi_dev_from_minor(minor);
        struct comedi_subdevice *s = NULL;
        int i;
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
-       dev_file_info = comedi_get_device_file_info(minor);
 
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        mutex_lock(&dev->mutex);
@@ -2172,22 +2181,6 @@ static int comedi_close(struct inode *inode, struct file *file)
        return 0;
 }
 
-static int comedi_fasync(int fd, struct file *file, int on)
-{
-       const unsigned minor = iminor(file->f_dentry->d_inode);
-       struct comedi_device_file_info *dev_file_info;
-       struct comedi_device *dev;
-       dev_file_info = comedi_get_device_file_info(minor);
-
-       if (dev_file_info == NULL)
-               return -ENODEV;
-       dev = dev_file_info->device;
-       if (dev == NULL)
-               return -ENODEV;
-
-       return fasync_helper(fd, file, on, &dev->async_queue);
-}
-
 static const struct file_operations comedi_fops = {
        .owner = THIS_MODULE,
        .unlocked_ioctl = comedi_unlocked_ioctl,
@@ -2205,99 +2198,6 @@ static const struct file_operations comedi_fops = {
 static struct class *comedi_class;
 static struct cdev comedi_cdev;
 
-static void comedi_cleanup_legacy_minors(void)
-{
-       unsigned i;
-
-       for (i = 0; i < comedi_num_legacy_minors; i++)
-               comedi_free_board_minor(i);
-}
-
-static int __init comedi_init(void)
-{
-       int i;
-       int retval;
-
-       pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n");
-
-       if (comedi_num_legacy_minors < 0 ||
-           comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
-               pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\".  Valid values are 0 through %i.\n",
-                      COMEDI_NUM_BOARD_MINORS);
-               return -EINVAL;
-       }
-
-       /*
-        * comedi is unusable if both comedi_autoconfig and
-        * comedi_num_legacy_minors are zero, so we might as well adjust the
-        * defaults in that case
-        */
-       if (comedi_autoconfig == 0 && comedi_num_legacy_minors == 0)
-               comedi_num_legacy_minors = 16;
-
-       memset(comedi_file_info_table, 0,
-              sizeof(struct comedi_device_file_info *) * COMEDI_NUM_MINORS);
-
-       retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
-                                       COMEDI_NUM_MINORS, "comedi");
-       if (retval)
-               return -EIO;
-       cdev_init(&comedi_cdev, &comedi_fops);
-       comedi_cdev.owner = THIS_MODULE;
-       kobject_set_name(&comedi_cdev.kobj, "comedi");
-       if (cdev_add(&comedi_cdev, MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS)) {
-               unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
-                                        COMEDI_NUM_MINORS);
-               return -EIO;
-       }
-       comedi_class = class_create(THIS_MODULE, "comedi");
-       if (IS_ERR(comedi_class)) {
-               pr_err("comedi: failed to create class\n");
-               cdev_del(&comedi_cdev);
-               unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
-                                        COMEDI_NUM_MINORS);
-               return PTR_ERR(comedi_class);
-       }
-
-       comedi_class->dev_attrs = comedi_dev_attrs;
-
-       /* XXX requires /proc interface */
-       comedi_proc_init();
-
-       /* create devices files for legacy/manual use */
-       for (i = 0; i < comedi_num_legacy_minors; i++) {
-               int minor;
-               minor = comedi_alloc_board_minor(NULL);
-               if (minor < 0) {
-                       comedi_cleanup_legacy_minors();
-                       cdev_del(&comedi_cdev);
-                       unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
-                                                COMEDI_NUM_MINORS);
-                       return minor;
-               }
-       }
-
-       return 0;
-}
-
-static void __exit comedi_cleanup(void)
-{
-       int i;
-
-       comedi_cleanup_legacy_minors();
-       for (i = 0; i < COMEDI_NUM_MINORS; ++i)
-               BUG_ON(comedi_file_info_table[i]);
-
-       class_destroy(comedi_class);
-       cdev_del(&comedi_cdev);
-       unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS);
-
-       comedi_proc_cleanup();
-}
-
-module_init(comedi_init);
-module_exit(comedi_cleanup);
-
 void comedi_error(const struct comedi_device *dev, const char *s)
 {
        dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s);
@@ -2312,7 +2212,7 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 
        /* DPRINTK("comedi_event 0x%x\n",mask); */
 
-       if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0)
+       if (!comedi_is_subdevice_running(s))
                return;
 
        if (s->
@@ -2347,40 +2247,9 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 EXPORT_SYMBOL(comedi_event);
 
-unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s)
-{
-       unsigned long flags;
-       unsigned runflags;
-
-       spin_lock_irqsave(&s->spin_lock, flags);
-       runflags = s->runflags;
-       spin_unlock_irqrestore(&s->spin_lock, flags);
-       return runflags;
-}
-EXPORT_SYMBOL(comedi_get_subdevice_runflags);
-
-static int is_device_busy(struct comedi_device *dev)
-{
-       struct comedi_subdevice *s;
-       int i;
-
-       if (!dev->attached)
-               return 0;
-
-       for (i = 0; i < dev->n_subdevices; i++) {
-               s = &dev->subdevices[i];
-               if (s->busy)
-                       return 1;
-               if (s->async && s->async->mmap_count)
-                       return 1;
-       }
-
-       return 0;
-}
-
 static void comedi_device_init(struct comedi_device *dev)
 {
-       memset(dev, 0, sizeof(struct comedi_device));
+       memset(dev, 0, sizeof(*dev));
        spin_lock_init(&dev->spinlock);
        mutex_init(&dev->mutex);
        dev->minor = -1;
@@ -2398,11 +2267,11 @@ static void comedi_device_cleanup(struct comedi_device *dev)
 
 int comedi_alloc_board_minor(struct device *hardware_device)
 {
-       struct comedi_device_file_info *info;
+       struct comedi_file_info *info;
        struct device *csdev;
        unsigned i;
 
-       info = kzalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (info == NULL)
                return -ENOMEM;
        info->device = kzalloc(sizeof(struct comedi_device), GFP_KERNEL);
@@ -2439,7 +2308,7 @@ int comedi_alloc_board_minor(struct device *hardware_device)
 
 void comedi_free_board_minor(unsigned minor)
 {
-       struct comedi_device_file_info *info;
+       struct comedi_file_info *info;
 
        BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
        spin_lock(&comedi_file_info_table_lock);
@@ -2464,7 +2333,7 @@ void comedi_free_board_minor(unsigned minor)
 int comedi_find_board_minor(struct device *hardware_device)
 {
        int minor;
-       struct comedi_device_file_info *info;
+       struct comedi_file_info *info;
 
        for (minor = 0; minor < COMEDI_NUM_BOARD_MINORS; minor++) {
                spin_lock(&comedi_file_info_table_lock);
@@ -2481,12 +2350,12 @@ int comedi_find_board_minor(struct device *hardware_device)
 int comedi_alloc_subdevice_minor(struct comedi_device *dev,
                                 struct comedi_subdevice *s)
 {
-       struct comedi_device_file_info *info;
+       struct comedi_file_info *info;
        struct device *csdev;
        unsigned i;
 
-       info = kmalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
-       if (info == NULL)
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
+       if (!info)
                return -ENOMEM;
        info->device = dev;
        info->read_subdevice = s;
@@ -2507,7 +2376,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
        s->minor = i;
        csdev = device_create(comedi_class, dev->class_dev,
                              MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i_subd%i",
-                             dev->minor, (int)(s - dev->subdevices));
+                             dev->minor, s->index);
        if (!IS_ERR(csdev))
                s->class_dev = csdev;
        dev_set_drvdata(csdev, info);
@@ -2517,7 +2386,7 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
 
 void comedi_free_subdevice_minor(struct comedi_subdevice *s)
 {
-       struct comedi_device_file_info *info;
+       struct comedi_file_info *info;
 
        if (s == NULL)
                return;
@@ -2539,14 +2408,98 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
        kfree(info);
 }
 
-struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor)
+static void comedi_cleanup_legacy_minors(void)
 {
-       struct comedi_device_file_info *info;
+       unsigned i;
 
-       BUG_ON(minor >= COMEDI_NUM_MINORS);
-       spin_lock(&comedi_file_info_table_lock);
-       info = comedi_file_info_table[minor];
-       spin_unlock(&comedi_file_info_table_lock);
-       return info;
+       for (i = 0; i < comedi_num_legacy_minors; i++)
+               comedi_free_board_minor(i);
 }
-EXPORT_SYMBOL_GPL(comedi_get_device_file_info);
+
+static int __init comedi_init(void)
+{
+       int i;
+       int retval;
+
+       pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n");
+
+       if (comedi_num_legacy_minors < 0 ||
+           comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
+               pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\".  Valid values are 0 through %i.\n",
+                      COMEDI_NUM_BOARD_MINORS);
+               return -EINVAL;
+       }
+
+       /*
+        * comedi is unusable if both comedi_autoconfig and
+        * comedi_num_legacy_minors are zero, so we might as well adjust the
+        * defaults in that case
+        */
+       if (!comedi_autoconfig && comedi_num_legacy_minors == 0)
+               comedi_num_legacy_minors = 16;
+
+       memset(comedi_file_info_table, 0,
+              sizeof(struct comedi_file_info *) * COMEDI_NUM_MINORS);
+
+       retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
+                                       COMEDI_NUM_MINORS, "comedi");
+       if (retval)
+               return -EIO;
+       cdev_init(&comedi_cdev, &comedi_fops);
+       comedi_cdev.owner = THIS_MODULE;
+       kobject_set_name(&comedi_cdev.kobj, "comedi");
+       if (cdev_add(&comedi_cdev, MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS)) {
+               unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
+                                        COMEDI_NUM_MINORS);
+               return -EIO;
+       }
+       comedi_class = class_create(THIS_MODULE, "comedi");
+       if (IS_ERR(comedi_class)) {
+               pr_err("comedi: failed to create class\n");
+               cdev_del(&comedi_cdev);
+               unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
+                                        COMEDI_NUM_MINORS);
+               return PTR_ERR(comedi_class);
+       }
+
+       comedi_class->dev_attrs = comedi_dev_attrs;
+
+       /* XXX requires /proc interface */
+       comedi_proc_init();
+
+       /* create devices files for legacy/manual use */
+       for (i = 0; i < comedi_num_legacy_minors; i++) {
+               int minor;
+               minor = comedi_alloc_board_minor(NULL);
+               if (minor < 0) {
+                       comedi_cleanup_legacy_minors();
+                       cdev_del(&comedi_cdev);
+                       unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
+                                                COMEDI_NUM_MINORS);
+                       return minor;
+               }
+       }
+
+       return 0;
+}
+module_init(comedi_init);
+
+static void __exit comedi_cleanup(void)
+{
+       int i;
+
+       comedi_cleanup_legacy_minors();
+       for (i = 0; i < COMEDI_NUM_MINORS; ++i)
+               BUG_ON(comedi_file_info_table[i]);
+
+       class_destroy(comedi_class);
+       cdev_del(&comedi_cdev);
+       unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS);
+
+       comedi_proc_cleanup();
+}
+module_exit(comedi_cleanup);
+
+MODULE_AUTHOR("http://www.comedi.org");
+MODULE_DESCRIPTION("Comedi core module");
+MODULE_LICENSE("GPL");
index e70ef0515d9afa671ab52958cc3984a653858c14..5e6f05b30e6c8bdbe9b7205d1a122bf602b457a9 100644 (file)
@@ -13,9 +13,11 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
 int comedi_alloc_board_minor(struct device *hardware_device);
 void comedi_free_board_minor(unsigned minor);
 int comedi_find_board_minor(struct device *hardware_device);
-void comedi_reset_async_buf(struct comedi_async *async);
+
 int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
                     unsigned long new_size);
+void comedi_buf_reset(struct comedi_async *async);
+unsigned int comedi_buf_write_n_allocated(struct comedi_async *async);
 
 extern unsigned int comedi_default_buf_size_kb;
 extern unsigned int comedi_default_buf_maxsize_kb;
index 692e1e615d443d1fa334f78f07873d118da032e7..e2b7d606e1c0daba1bc20116fdbe8b6515d8c372 100644 (file)
@@ -77,6 +77,7 @@
 
 struct comedi_subdevice {
        struct comedi_device *device;
+       int index;
        int type;
        int n_chan;
        int subdev_flags;
@@ -250,13 +251,6 @@ static inline const void *comedi_board(const struct comedi_device *dev)
        return dev->board_ptr;
 }
 
-struct comedi_device_file_info {
-       struct comedi_device *device;
-       struct comedi_subdevice *read_subdevice;
-       struct comedi_subdevice *write_subdevice;
-       struct device *hardware_device;
-};
-
 #ifdef CONFIG_COMEDI_DEBUG
 extern int comedi_debug;
 #else
@@ -280,27 +274,7 @@ enum comedi_minor_bits {
 static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4;
 static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
 
-struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor);
-
-static inline struct comedi_subdevice *comedi_get_read_subdevice(
-       const struct comedi_device_file_info *info)
-{
-       if (info->read_subdevice)
-               return info->read_subdevice;
-       if (info->device == NULL)
-               return NULL;
-       return info->device->read_subdev;
-}
-
-static inline struct comedi_subdevice *comedi_get_write_subdevice(
-       const struct comedi_device_file_info *info)
-{
-       if (info->write_subdevice)
-               return info->write_subdevice;
-       if (info->device == NULL)
-               return NULL;
-       return info->device->write_subdev;
-}
+struct comedi_device *comedi_dev_from_minor(unsigned minor);
 
 int comedi_alloc_subdevices(struct comedi_device *, int);
 
@@ -342,6 +316,27 @@ void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
        module_driver(__comedi_driver, comedi_pci_driver_register, \
                        comedi_pci_driver_unregister, &(__pci_driver))
 
+struct pcmcia_driver;
+
+int comedi_pcmcia_driver_register(struct comedi_driver *,
+                                       struct pcmcia_driver *);
+void comedi_pcmcia_driver_unregister(struct comedi_driver *,
+                                       struct pcmcia_driver *);
+
+/**
+ * module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver
+ * @__comedi_driver: comedi_driver struct
+ * @__pcmcia_driver: pcmcia_driver struct
+ *
+ * Helper macro for comedi PCMCIA drivers which do not do anything special
+ * in module init/exit. This eliminates a lot of boilerplate. Each
+ * module may only use this macro once, and calling it replaces
+ * module_init() and module_exit()
+ */
+#define module_comedi_pcmcia_driver(__comedi_driver, __pcmcia_driver) \
+       module_driver(__comedi_driver, comedi_pcmcia_driver_register, \
+                       comedi_pcmcia_driver_unregister, &(__pcmcia_driver))
+
 struct usb_driver;
 
 int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *);
@@ -389,10 +384,11 @@ enum subdevice_runflags {
        SRF_RUNNING = 0x08000000
 };
 
+bool comedi_is_subdevice_running(struct comedi_subdevice *s);
+
 int comedi_check_chanlist(struct comedi_subdevice *s,
                          int n,
                          unsigned int *chanlist);
-unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s);
 
 /* range stuff */
 
@@ -460,56 +456,20 @@ comedi_to_usb_interface(struct comedi_device *dev)
        return dev->hw_dev ? to_usb_interface(dev->hw_dev) : NULL;
 }
 
-int comedi_buf_put(struct comedi_async *async, short x);
-int comedi_buf_get(struct comedi_async *async, short *x);
-
-unsigned int comedi_buf_write_n_available(struct comedi_async *async);
-unsigned int comedi_buf_write_alloc(struct comedi_async *async,
-                                   unsigned int nbytes);
-unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
-                                          unsigned int nbytes);
-unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes);
-unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes);
-unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes);
-unsigned int comedi_buf_read_n_available(struct comedi_async *async);
+unsigned int comedi_buf_write_alloc(struct comedi_async *, unsigned int);
+unsigned int comedi_buf_write_free(struct comedi_async *, unsigned int);
+
+unsigned int comedi_buf_read_n_available(struct comedi_async *);
+unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
+unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
+
+int comedi_buf_put(struct comedi_async *, short);
+int comedi_buf_get(struct comedi_async *, short *);
+
 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
                          const void *source, unsigned int num_bytes);
 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
                            void *destination, unsigned int num_bytes);
-static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async)
-{
-       return async->buf_write_alloc_count - async->buf_write_count;
-}
-
-static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async)
-{
-       return async->buf_read_alloc_count - async->buf_read_count;
-}
-
-static inline void *comedi_aux_data(int options[], int n)
-{
-       unsigned long address;
-       unsigned long addressLow;
-       int bit_shift;
-       if (sizeof(int) >= sizeof(void *))
-               address = options[COMEDI_DEVCONF_AUX_DATA_LO];
-       else {
-               address = options[COMEDI_DEVCONF_AUX_DATA_HI];
-               bit_shift = sizeof(int) * 8;
-               address <<= bit_shift;
-               addressLow = options[COMEDI_DEVCONF_AUX_DATA_LO];
-               addressLow &= (1UL << bit_shift) - 1;
-               address |= addressLow;
-       }
-       if (n >= 1)
-               address += options[COMEDI_DEVCONF_AUX_DATA0_LENGTH];
-       if (n >= 2)
-               address += options[COMEDI_DEVCONF_AUX_DATA1_LENGTH];
-       if (n >= 3)
-               address += options[COMEDI_DEVCONF_AUX_DATA2_LENGTH];
-       BUG_ON(n > 3);
-       return (void *)address;
-}
 
 int comedi_alloc_subdevice_minor(struct comedi_device *dev,
                                 struct comedi_subdevice *s);
@@ -524,10 +484,7 @@ static inline int comedi_pci_auto_config(struct pci_dev *pcidev,
        return comedi_auto_config(&pcidev->dev, driver, 0);
 }
 
-static inline void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
-{
-       comedi_auto_unconfig(&pcidev->dev);
-}
+void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
 
 static inline int comedi_usb_auto_config(struct usb_interface *intf,
                                         struct comedi_driver *driver)
index 50cf498698e210a6f12a2ac04b57abe833da65f0..87eeee58bda793e934d18cf8e66dbfbe036159a5 100644 (file)
@@ -24,6 +24,8 @@
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/ds.h>
 #include <linux/usb.h>
 #include <linux/errno.h>
 #include <linux/kconfig.h>
 #include "comedidev.h"
 #include "comedi_internal.h"
 
-static int postconfig(struct comedi_device *dev);
-static int insn_rw_emulate_bits(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data);
-static void *comedi_recognize(struct comedi_driver *driv, const char *name);
-static void comedi_report_boards(struct comedi_driver *driv);
-static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);
-
 struct comedi_driver *comedi_drivers;
 
 int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
@@ -70,6 +64,7 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
        for (i = 0; i < num_subdevices; ++i) {
                s = &dev->subdevices[i];
                s->device = dev;
+               s->index = i;
                s->async_dma_dir = DMA_NONE;
                spin_lock_init(&s->spin_lock);
                s->minor = -1;
@@ -128,131 +123,106 @@ void comedi_device_detach(struct comedi_device *dev)
        __comedi_device_detach(dev);
 }
 
-/* do a little post-config cleanup */
-/* called with module refcount incremented, decrements it */
-static int comedi_device_postconfig(struct comedi_device *dev)
+static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-       int ret = postconfig(dev);
-       module_put(dev->driver->module);
-       if (ret < 0) {
-               __comedi_device_detach(dev);
-               return ret;
-       }
-       if (!dev->board_name) {
-               dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n");
-               dev->board_name = "BUG";
-       }
-       smp_wmb();
-       dev->attached = 1;
-       return 0;
+       return -EINVAL;
 }
 
-int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
+              struct comedi_insn *insn, unsigned int *data)
 {
-       struct comedi_driver *driv;
+       return -EINVAL;
+}
+
+static int insn_rw_emulate_bits(struct comedi_device *dev,
+                               struct comedi_subdevice *s,
+                               struct comedi_insn *insn, unsigned int *data)
+{
+       struct comedi_insn new_insn;
        int ret;
+       static const unsigned channels_per_bitfield = 32;
 
-       if (dev->attached)
-               return -EBUSY;
+       unsigned chan = CR_CHAN(insn->chanspec);
+       const unsigned base_bitfield_channel =
+           (chan < channels_per_bitfield) ? 0 : chan;
+       unsigned int new_data[2];
+       memset(new_data, 0, sizeof(new_data));
+       memset(&new_insn, 0, sizeof(new_insn));
+       new_insn.insn = INSN_BITS;
+       new_insn.chanspec = base_bitfield_channel;
+       new_insn.n = 2;
+       new_insn.subdev = insn->subdev;
 
-       for (driv = comedi_drivers; driv; driv = driv->next) {
-               if (!try_module_get(driv->module))
-                       continue;
-               if (driv->num_names) {
-                       dev->board_ptr = comedi_recognize(driv, it->board_name);
-                       if (dev->board_ptr)
-                               break;
-               } else if (strcmp(driv->driver_name, it->board_name) == 0)
-                       break;
-               module_put(driv->module);
-       }
-       if (driv == NULL) {
-               /*  recognize has failed if we get here */
-               /*  report valid board names before returning error */
-               for (driv = comedi_drivers; driv; driv = driv->next) {
-                       if (!try_module_get(driv->module))
-                               continue;
-                       comedi_report_boards(driv);
-                       module_put(driv->module);
-               }
-               return -EIO;
-       }
-       if (driv->attach == NULL) {
-               /* driver does not support manual configuration */
-               dev_warn(dev->class_dev,
-                        "driver '%s' does not support attach using comedi_config\n",
-                        driv->driver_name);
-               module_put(driv->module);
-               return -ENOSYS;
+       if (insn->insn == INSN_WRITE) {
+               if (!(s->subdev_flags & SDF_WRITABLE))
+                       return -EINVAL;
+               new_data[0] = 1 << (chan - base_bitfield_channel); /* mask */
+               new_data[1] = data[0] ? (1 << (chan - base_bitfield_channel))
+                             : 0; /* bits */
        }
-       /* initialize dev->driver here so
-        * comedi_error() can be called from attach */
-       dev->driver = driv;
-       ret = driv->attach(dev, it);
-       if (ret < 0) {
-               module_put(dev->driver->module);
-               __comedi_device_detach(dev);
+
+       ret = s->insn_bits(dev, s, &new_insn, new_data);
+       if (ret < 0)
                return ret;
-       }
-       return comedi_device_postconfig(dev);
-}
 
-int comedi_driver_register(struct comedi_driver *driver)
-{
-       driver->next = comedi_drivers;
-       comedi_drivers = driver;
+       if (insn->insn == INSN_READ)
+               data[0] = (new_data[1] >> (chan - base_bitfield_channel)) & 1;
 
-       return 0;
+       return 1;
 }
-EXPORT_SYMBOL(comedi_driver_register);
 
-int comedi_driver_unregister(struct comedi_driver *driver)
+static int __comedi_device_postconfig_async(struct comedi_device *dev,
+                                           struct comedi_subdevice *s)
 {
-       struct comedi_driver *prev;
-       int i;
-
-       /* check for devices using this driver */
-       for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
-               struct comedi_device_file_info *dev_file_info =
-                   comedi_get_device_file_info(i);
-               struct comedi_device *dev;
-
-               if (dev_file_info == NULL)
-                       continue;
-               dev = dev_file_info->device;
+       struct comedi_async *async;
+       unsigned int buf_size;
+       int ret;
 
-               mutex_lock(&dev->mutex);
-               if (dev->attached && dev->driver == driver) {
-                       if (dev->use_count)
-                               dev_warn(dev->class_dev,
-                                        "BUG! detaching device with use_count=%d\n",
-                                        dev->use_count);
-                       comedi_device_detach(dev);
-               }
-               mutex_unlock(&dev->mutex);
+       if ((s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) == 0) {
+               dev_warn(dev->class_dev,
+                        "async subdevices must support SDF_CMD_READ or SDF_CMD_WRITE\n");
+               return -EINVAL;
+       }
+       if (!s->do_cmdtest) {
+               dev_warn(dev->class_dev,
+                        "async subdevices must have a do_cmdtest() function\n");
+               return -EINVAL;
        }
 
-       if (comedi_drivers == driver) {
-               comedi_drivers = driver->next;
-               return 0;
+       async = kzalloc(sizeof(*async), GFP_KERNEL);
+       if (!async) {
+               dev_warn(dev->class_dev, "failed to allocate async struct\n");
+               return -ENOMEM;
        }
+       init_waitqueue_head(&async->wait_head);
+       async->subdevice = s;
+       s->async = async;
 
-       for (prev = comedi_drivers; prev->next; prev = prev->next) {
-               if (prev->next == driver) {
-                       prev->next = driver->next;
-                       return 0;
-               }
+       async->max_bufsize = comedi_default_buf_maxsize_kb * 1024;
+       buf_size = comedi_default_buf_size_kb * 1024;
+       if (buf_size > async->max_bufsize)
+               buf_size = async->max_bufsize;
+
+       if (comedi_buf_alloc(dev, s, buf_size) < 0) {
+               dev_warn(dev->class_dev, "Buffer allocation failed\n");
+               return -ENOMEM;
        }
-       return -EINVAL;
+       if (s->buf_change) {
+               ret = s->buf_change(dev, s, buf_size);
+               if (ret < 0)
+                       return ret;
+       }
+
+       comedi_alloc_subdevice_minor(dev, s);
+
+       return 0;
 }
-EXPORT_SYMBOL(comedi_driver_unregister);
 
-static int postconfig(struct comedi_device *dev)
+static int __comedi_device_postconfig(struct comedi_device *dev)
 {
-       int i;
        struct comedi_subdevice *s;
-       struct comedi_async *async = NULL;
        int ret;
+       int i;
 
        for (i = 0; i < dev->n_subdevices; i++) {
                s = &dev->subdevices[i];
@@ -264,42 +234,9 @@ static int postconfig(struct comedi_device *dev)
                        s->len_chanlist = 1;
 
                if (s->do_cmd) {
-                       unsigned int buf_size;
-
-                       BUG_ON((s->subdev_flags & (SDF_CMD_READ |
-                                                  SDF_CMD_WRITE)) == 0);
-                       BUG_ON(!s->do_cmdtest);
-
-                       async =
-                           kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
-                       if (async == NULL) {
-                               dev_warn(dev->class_dev,
-                                        "failed to allocate async struct\n");
-                               return -ENOMEM;
-                       }
-                       init_waitqueue_head(&async->wait_head);
-                       async->subdevice = s;
-                       s->async = async;
-
-                       async->max_bufsize =
-                               comedi_default_buf_maxsize_kb * 1024;
-                       buf_size = comedi_default_buf_size_kb * 1024;
-                       if (buf_size > async->max_bufsize)
-                               buf_size = async->max_bufsize;
-
-                       async->prealloc_buf = NULL;
-                       async->prealloc_bufsz = 0;
-                       if (comedi_buf_alloc(dev, s, buf_size) < 0) {
-                               dev_warn(dev->class_dev,
-                                        "Buffer allocation failed\n");
-                               return -ENOMEM;
-                       }
-                       if (s->buf_change) {
-                               ret = s->buf_change(dev, s, buf_size);
-                               if (ret < 0)
-                                       return ret;
-                       }
-                       comedi_alloc_subdevice_minor(dev, s);
+                       ret = __comedi_device_postconfig_async(dev, s);
+                       if (ret)
+                               return ret;
                }
 
                if (!s->range_table && !s->range_table_list)
@@ -326,6 +263,25 @@ static int postconfig(struct comedi_device *dev)
        return 0;
 }
 
+/* do a little post-config cleanup */
+/* called with module refcount incremented, decrements it */
+static int comedi_device_postconfig(struct comedi_device *dev)
+{
+       int ret = __comedi_device_postconfig(dev);
+       module_put(dev->driver->module);
+       if (ret < 0) {
+               __comedi_device_detach(dev);
+               return ret;
+       }
+       if (!dev->board_name) {
+               dev_warn(dev->class_dev, "BUG: dev->board_name=NULL\n");
+               dev->board_name = "BUG";
+       }
+       smp_wmb();
+       dev->attached = 1;
+       return 0;
+}
+
 /*
  * Generic recognize function for drivers that register their supported
  * board names.
@@ -384,457 +340,107 @@ static void comedi_report_boards(struct comedi_driver *driv)
                pr_info(" %s\n", driv->driver_name);
 }
 
-static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-       return -EINVAL;
-}
-
-int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
-              struct comedi_insn *insn, unsigned int *data)
-{
-       return -EINVAL;
-}
-
-static int insn_rw_emulate_bits(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
+int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
-       struct comedi_insn new_insn;
+       struct comedi_driver *driv;
        int ret;
-       static const unsigned channels_per_bitfield = 32;
-
-       unsigned chan = CR_CHAN(insn->chanspec);
-       const unsigned base_bitfield_channel =
-           (chan < channels_per_bitfield) ? 0 : chan;
-       unsigned int new_data[2];
-       memset(new_data, 0, sizeof(new_data));
-       memset(&new_insn, 0, sizeof(new_insn));
-       new_insn.insn = INSN_BITS;
-       new_insn.chanspec = base_bitfield_channel;
-       new_insn.n = 2;
-       new_insn.subdev = insn->subdev;
-
-       if (insn->insn == INSN_WRITE) {
-               if (!(s->subdev_flags & SDF_WRITABLE))
-                       return -EINVAL;
-               new_data[0] = 1 << (chan - base_bitfield_channel); /* mask */
-               new_data[1] = data[0] ? (1 << (chan - base_bitfield_channel))
-                             : 0; /* bits */
-       }
-
-       ret = s->insn_bits(dev, s, &new_insn, new_data);
-       if (ret < 0)
-               return ret;
-
-       if (insn->insn == INSN_READ)
-               data[0] = (new_data[1] >> (chan - base_bitfield_channel)) & 1;
-
-       return 1;
-}
 
-int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
-                    unsigned long new_size)
-{
-       struct comedi_async *async = s->async;
-
-       /* Round up new_size to multiple of PAGE_SIZE */
-       new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
-
-       /* if no change is required, do nothing */
-       if (async->prealloc_buf && async->prealloc_bufsz == new_size)
-               return 0;
-
-       /*  deallocate old buffer */
-       if (async->prealloc_buf) {
-               vunmap(async->prealloc_buf);
-               async->prealloc_buf = NULL;
-               async->prealloc_bufsz = 0;
-       }
-       if (async->buf_page_list) {
-               unsigned i;
-               for (i = 0; i < async->n_buf_pages; ++i) {
-                       if (async->buf_page_list[i].virt_addr) {
-                               clear_bit(PG_reserved,
-                                       &(virt_to_page(async->buf_page_list[i].
-                                                       virt_addr)->flags));
-                               if (s->async_dma_dir != DMA_NONE) {
-                                       dma_free_coherent(dev->hw_dev,
-                                                         PAGE_SIZE,
-                                                         async->
-                                                         buf_page_list
-                                                         [i].virt_addr,
-                                                         async->
-                                                         buf_page_list
-                                                         [i].dma_addr);
-                               } else {
-                                       free_page((unsigned long)
-                                                 async->buf_page_list[i].
-                                                 virt_addr);
-                               }
-                       }
-               }
-               vfree(async->buf_page_list);
-               async->buf_page_list = NULL;
-               async->n_buf_pages = 0;
-       }
-       /*  allocate new buffer */
-       if (new_size) {
-               unsigned i = 0;
-               unsigned n_pages = new_size >> PAGE_SHIFT;
-               struct page **pages = NULL;
-
-               async->buf_page_list =
-                   vzalloc(sizeof(struct comedi_buf_page) * n_pages);
-               if (async->buf_page_list)
-                       pages = vmalloc(sizeof(struct page *) * n_pages);
-
-               if (pages) {
-                       for (i = 0; i < n_pages; i++) {
-                               if (s->async_dma_dir != DMA_NONE) {
-                                       async->buf_page_list[i].virt_addr =
-                                           dma_alloc_coherent(dev->hw_dev,
-                                                              PAGE_SIZE,
-                                                              &async->
-                                                              buf_page_list
-                                                              [i].dma_addr,
-                                                              GFP_KERNEL |
-                                                              __GFP_COMP);
-                               } else {
-                                       async->buf_page_list[i].virt_addr =
-                                           (void *)
-                                           get_zeroed_page(GFP_KERNEL);
-                               }
-                               if (async->buf_page_list[i].virt_addr == NULL)
-                                       break;
-
-                               set_bit(PG_reserved,
-                                       &(virt_to_page(async->buf_page_list[i].
-                                                       virt_addr)->flags));
-                               pages[i] = virt_to_page(async->buf_page_list[i].
-                                                               virt_addr);
-                       }
-               }
-               if (i == n_pages) {
-                       async->prealloc_buf =
-#ifdef PAGE_KERNEL_NOCACHE
-                           vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE);
-#else
-                           vmap(pages, n_pages, VM_MAP, PAGE_KERNEL);
-#endif
-               }
-               vfree(pages);
-
-               if (async->prealloc_buf == NULL) {
-                       /* Some allocation failed above. */
-                       if (async->buf_page_list) {
-                               for (i = 0; i < n_pages; i++) {
-                                       if (async->buf_page_list[i].virt_addr ==
-                                           NULL) {
-                                               break;
-                                       }
-                                       clear_bit(PG_reserved,
-                                               &(virt_to_page(async->
-                                                       buf_page_list[i].
-                                                       virt_addr)->flags));
-                                       if (s->async_dma_dir != DMA_NONE) {
-                                               dma_free_coherent(dev->hw_dev,
-                                                                 PAGE_SIZE,
-                                                                 async->
-                                                                 buf_page_list
-                                                                 [i].virt_addr,
-                                                                 async->
-                                                                 buf_page_list
-                                                                 [i].dma_addr);
-                                       } else {
-                                               free_page((unsigned long)
-                                                         async->buf_page_list
-                                                         [i].virt_addr);
-                                       }
-                               }
-                               vfree(async->buf_page_list);
-                               async->buf_page_list = NULL;
-                       }
-                       return -ENOMEM;
-               }
-               async->n_buf_pages = n_pages;
-       }
-       async->prealloc_bufsz = new_size;
-
-       return 0;
-}
+       if (dev->attached)
+               return -EBUSY;
 
-/* munging is applied to data by core as it passes between user
- * and kernel space */
-static unsigned int comedi_buf_munge(struct comedi_async *async,
-                                    unsigned int num_bytes)
-{
-       struct comedi_subdevice *s = async->subdevice;
-       unsigned int count = 0;
-       const unsigned num_sample_bytes = bytes_per_sample(s);
-
-       if (s->munge == NULL || (async->cmd.flags & CMDF_RAWDATA)) {
-               async->munge_count += num_bytes;
-               BUG_ON((int)(async->munge_count - async->buf_write_count) > 0);
-               return num_bytes;
-       }
-       /* don't munge partial samples */
-       num_bytes -= num_bytes % num_sample_bytes;
-       while (count < num_bytes) {
-               int block_size;
-
-               block_size = num_bytes - count;
-               if (block_size < 0) {
-                       dev_warn(s->device->class_dev,
-                                "%s: %s: bug! block_size is negative\n",
-                                __FILE__, __func__);
+       for (driv = comedi_drivers; driv; driv = driv->next) {
+               if (!try_module_get(driv->module))
+                       continue;
+               if (driv->num_names) {
+                       dev->board_ptr = comedi_recognize(driv, it->board_name);
+                       if (dev->board_ptr)
+                               break;
+               } else if (strcmp(driv->driver_name, it->board_name) == 0)
                        break;
-               }
-               if ((int)(async->munge_ptr + block_size -
-                         async->prealloc_bufsz) > 0)
-                       block_size = async->prealloc_bufsz - async->munge_ptr;
-
-               s->munge(s->device, s, async->prealloc_buf + async->munge_ptr,
-                        block_size, async->munge_chan);
-
-               smp_wmb();      /* barrier insures data is munged in buffer
-                                * before munge_count is incremented */
-
-               async->munge_chan += block_size / num_sample_bytes;
-               async->munge_chan %= async->cmd.chanlist_len;
-               async->munge_count += block_size;
-               async->munge_ptr += block_size;
-               async->munge_ptr %= async->prealloc_bufsz;
-               count += block_size;
+               module_put(driv->module);
        }
-       BUG_ON((int)(async->munge_count - async->buf_write_count) > 0);
-       return count;
-}
-
-unsigned int comedi_buf_write_n_available(struct comedi_async *async)
-{
-       unsigned int free_end;
-       unsigned int nbytes;
-
-       if (async == NULL)
-               return 0;
-
-       free_end = async->buf_read_count + async->prealloc_bufsz;
-       nbytes = free_end - async->buf_write_alloc_count;
-       nbytes -= nbytes % bytes_per_sample(async->subdevice);
-       /* barrier insures the read of buf_read_count in this
-          query occurs before any following writes to the buffer which
-          might be based on the return value from this query.
-        */
-       smp_mb();
-       return nbytes;
-}
-
-/* allocates chunk for the writer from free buffer space */
-unsigned int comedi_buf_write_alloc(struct comedi_async *async,
-                                   unsigned int nbytes)
-{
-       unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
-
-       if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0)
-               nbytes = free_end - async->buf_write_alloc_count;
-
-       async->buf_write_alloc_count += nbytes;
-       /* barrier insures the read of buf_read_count above occurs before
-          we write data to the write-alloc'ed buffer space */
-       smp_mb();
-       return nbytes;
-}
-EXPORT_SYMBOL(comedi_buf_write_alloc);
-
-/* allocates nothing unless it can completely fulfill the request */
-unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
-                                          unsigned int nbytes)
-{
-       unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
-
-       if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0)
-               nbytes = 0;
-
-       async->buf_write_alloc_count += nbytes;
-       /* barrier insures the read of buf_read_count above occurs before
-          we write data to the write-alloc'ed buffer space */
-       smp_mb();
-       return nbytes;
-}
-
-/* transfers a chunk from writer to filled buffer space */
-unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
-{
-       if ((int)(async->buf_write_count + nbytes -
-                 async->buf_write_alloc_count) > 0) {
-               dev_info(async->subdevice->device->class_dev,
-                        "attempted to write-free more bytes than have been write-allocated.\n");
-               nbytes = async->buf_write_alloc_count - async->buf_write_count;
+       if (driv == NULL) {
+               /*  recognize has failed if we get here */
+               /*  report valid board names before returning error */
+               for (driv = comedi_drivers; driv; driv = driv->next) {
+                       if (!try_module_get(driv->module))
+                               continue;
+                       comedi_report_boards(driv);
+                       module_put(driv->module);
+               }
+               return -EIO;
        }
-       async->buf_write_count += nbytes;
-       async->buf_write_ptr += nbytes;
-       comedi_buf_munge(async, async->buf_write_count - async->munge_count);
-       if (async->buf_write_ptr >= async->prealloc_bufsz)
-               async->buf_write_ptr %= async->prealloc_bufsz;
-
-       return nbytes;
-}
-EXPORT_SYMBOL(comedi_buf_write_free);
-
-/* allocates a chunk for the reader from filled (and munged) buffer space */
-unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes)
-{
-       if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) >
-           0) {
-               nbytes = async->munge_count - async->buf_read_alloc_count;
+       if (driv->attach == NULL) {
+               /* driver does not support manual configuration */
+               dev_warn(dev->class_dev,
+                        "driver '%s' does not support attach using comedi_config\n",
+                        driv->driver_name);
+               module_put(driv->module);
+               return -ENOSYS;
        }
-       async->buf_read_alloc_count += nbytes;
-       /* barrier insures read of munge_count occurs before we actually read
-          data out of buffer */
-       smp_rmb();
-       return nbytes;
-}
-EXPORT_SYMBOL(comedi_buf_read_alloc);
-
-/* transfers control of a chunk from reader to free buffer space */
-unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
-{
-       /* barrier insures data has been read out of
-        * buffer before read count is incremented */
-       smp_mb();
-       if ((int)(async->buf_read_count + nbytes -
-                 async->buf_read_alloc_count) > 0) {
-               dev_info(async->subdevice->device->class_dev,
-                        "attempted to read-free more bytes than have been read-allocated.\n");
-               nbytes = async->buf_read_alloc_count - async->buf_read_count;
+       /* initialize dev->driver here so
+        * comedi_error() can be called from attach */
+       dev->driver = driv;
+       ret = driv->attach(dev, it);
+       if (ret < 0) {
+               module_put(dev->driver->module);
+               __comedi_device_detach(dev);
+               return ret;
        }
-       async->buf_read_count += nbytes;
-       async->buf_read_ptr += nbytes;
-       async->buf_read_ptr %= async->prealloc_bufsz;
-       return nbytes;
+       return comedi_device_postconfig(dev);
 }
-EXPORT_SYMBOL(comedi_buf_read_free);
 
-void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
-                         const void *data, unsigned int num_bytes)
+int comedi_driver_register(struct comedi_driver *driver)
 {
-       unsigned int write_ptr = async->buf_write_ptr + offset;
-
-       if (write_ptr >= async->prealloc_bufsz)
-               write_ptr %= async->prealloc_bufsz;
-
-       while (num_bytes) {
-               unsigned int block_size;
-
-               if (write_ptr + num_bytes > async->prealloc_bufsz)
-                       block_size = async->prealloc_bufsz - write_ptr;
-               else
-                       block_size = num_bytes;
-
-               memcpy(async->prealloc_buf + write_ptr, data, block_size);
-
-               data += block_size;
-               num_bytes -= block_size;
+       driver->next = comedi_drivers;
+       comedi_drivers = driver;
 
-               write_ptr = 0;
-       }
+       return 0;
 }
-EXPORT_SYMBOL(comedi_buf_memcpy_to);
+EXPORT_SYMBOL(comedi_driver_register);
 
-void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
-                           void *dest, unsigned int nbytes)
+int comedi_driver_unregister(struct comedi_driver *driver)
 {
-       void *src;
-       unsigned int read_ptr = async->buf_read_ptr + offset;
-
-       if (read_ptr >= async->prealloc_bufsz)
-               read_ptr %= async->prealloc_bufsz;
-
-       while (nbytes) {
-               unsigned int block_size;
+       struct comedi_driver *prev;
+       int i;
 
-               src = async->prealloc_buf + read_ptr;
+       /* check for devices using this driver */
+       for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
+               struct comedi_device *dev = comedi_dev_from_minor(i);
 
-               if (nbytes >= async->prealloc_bufsz - read_ptr)
-                       block_size = async->prealloc_bufsz - read_ptr;
-               else
-                       block_size = nbytes;
+               if (!dev)
+                       continue;
 
-               memcpy(dest, src, block_size);
-               nbytes -= block_size;
-               dest += block_size;
-               read_ptr = 0;
+               mutex_lock(&dev->mutex);
+               if (dev->attached && dev->driver == driver) {
+                       if (dev->use_count)
+                               dev_warn(dev->class_dev,
+                                        "BUG! detaching device with use_count=%d\n",
+                                        dev->use_count);
+                       comedi_device_detach(dev);
+               }
+               mutex_unlock(&dev->mutex);
        }
-}
-EXPORT_SYMBOL(comedi_buf_memcpy_from);
-
-unsigned int comedi_buf_read_n_available(struct comedi_async *async)
-{
-       unsigned num_bytes;
-
-       if (async == NULL)
-               return 0;
-       num_bytes = async->munge_count - async->buf_read_count;
-       /* barrier insures the read of munge_count in this
-          query occurs before any following reads of the buffer which
-          might be based on the return value from this query.
-        */
-       smp_rmb();
-       return num_bytes;
-}
-EXPORT_SYMBOL(comedi_buf_read_n_available);
-
-int comedi_buf_get(struct comedi_async *async, short *x)
-{
-       unsigned int n = comedi_buf_read_n_available(async);
-
-       if (n < sizeof(short))
-               return 0;
-       comedi_buf_read_alloc(async, sizeof(short));
-       *x = *(short *)(async->prealloc_buf + async->buf_read_ptr);
-       comedi_buf_read_free(async, sizeof(short));
-       return 1;
-}
-EXPORT_SYMBOL(comedi_buf_get);
-
-int comedi_buf_put(struct comedi_async *async, short x)
-{
-       unsigned int n = comedi_buf_write_alloc_strict(async, sizeof(short));
 
-       if (n < sizeof(short)) {
-               async->events |= COMEDI_CB_ERROR;
+       if (comedi_drivers == driver) {
+               comedi_drivers = driver->next;
                return 0;
        }
-       *(short *)(async->prealloc_buf + async->buf_write_ptr) = x;
-       comedi_buf_write_free(async, sizeof(short));
-       return 1;
-}
-EXPORT_SYMBOL(comedi_buf_put);
-
-void comedi_reset_async_buf(struct comedi_async *async)
-{
-       async->buf_write_alloc_count = 0;
-       async->buf_write_count = 0;
-       async->buf_read_alloc_count = 0;
-       async->buf_read_count = 0;
-
-       async->buf_write_ptr = 0;
-       async->buf_read_ptr = 0;
-
-       async->cur_chan = 0;
-       async->scan_progress = 0;
-       async->munge_chan = 0;
-       async->munge_count = 0;
-       async->munge_ptr = 0;
 
-       async->events = 0;
+       for (prev = comedi_drivers; prev->next; prev = prev->next) {
+               if (prev->next == driver) {
+                       prev->next = driver->next;
+                       return 0;
+               }
+       }
+       return -EINVAL;
 }
+EXPORT_SYMBOL(comedi_driver_unregister);
 
 int comedi_auto_config(struct device *hardware_device,
                       struct comedi_driver *driver, unsigned long context)
 {
        int minor;
-       struct comedi_device_file_info *dev_file_info;
        struct comedi_device *comedi_dev;
        int ret;
 
@@ -852,8 +458,7 @@ int comedi_auto_config(struct device *hardware_device,
        if (minor < 0)
                return minor;
 
-       dev_file_info = comedi_get_device_file_info(minor);
-       comedi_dev = dev_file_info->device;
+       comedi_dev = comedi_dev_from_minor(minor);
 
        mutex_lock(&comedi_dev->mutex);
        if (comedi_dev->attached)
@@ -888,7 +493,6 @@ void comedi_auto_unconfig(struct device *hardware_device)
        minor = comedi_find_board_minor(hardware_device);
        if (minor < 0)
                return;
-       BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
        comedi_free_board_minor(minor);
 }
 EXPORT_SYMBOL_GPL(comedi_auto_unconfig);
@@ -936,10 +540,6 @@ int comedi_pci_driver_register(struct comedi_driver *comedi_driver,
        if (ret < 0)
                return ret;
 
-       /* FIXME: Remove this test after auditing all comedi pci drivers */
-       if (!pci_driver->name)
-               pci_driver->name = comedi_driver->driver_name;
-
        ret = pci_register_driver(pci_driver);
        if (ret < 0) {
                comedi_driver_unregister(comedi_driver);
@@ -958,6 +558,42 @@ void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver,
 }
 EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister);
 
+void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
+{
+       comedi_auto_unconfig(&pcidev->dev);
+}
+EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig);
+
+#if IS_ENABLED(CONFIG_PCMCIA)
+int comedi_pcmcia_driver_register(struct comedi_driver *comedi_driver,
+               struct pcmcia_driver *pcmcia_driver)
+{
+       int ret;
+
+       ret = comedi_driver_register(comedi_driver);
+       if (ret < 0)
+               return ret;
+
+       ret = pcmcia_register_driver(pcmcia_driver);
+       if (ret < 0) {
+               comedi_driver_unregister(comedi_driver);
+               return ret;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_register);
+
+void comedi_pcmcia_driver_unregister(struct comedi_driver *comedi_driver,
+               struct pcmcia_driver *pcmcia_driver)
+{
+       pcmcia_unregister_driver(pcmcia_driver);
+       comedi_driver_unregister(comedi_driver);
+}
+EXPORT_SYMBOL_GPL(comedi_pcmcia_driver_unregister);
+
+#endif
+
 #if IS_ENABLED(CONFIG_USB)
 
 int comedi_usb_driver_register(struct comedi_driver *comedi_driver,
index e0a79521f35a1f1c03c8cc3867229b6024cf13c4..87fe96da971d4f9184ea6516c1ed70bdf9bf99a2 100644 (file)
@@ -314,11 +314,6 @@ static int pci_8255_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &pci_8255_driver);
 }
 
-static void pci_8255_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(pci_8255_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_ADLINK_PCI7224) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_ADLINK_PCI7248) },
@@ -342,7 +337,7 @@ static struct pci_driver pci_8255_pci_driver = {
        .name           = "8255_pci",
        .id_table       = pci_8255_pci_table,
        .probe          = pci_8255_pci_probe,
-       .remove         = pci_8255_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(pci_8255_driver, pci_8255_pci_driver);
 
index 0de4d2eb76fca34124e5f63df93a63db384603e5..fd74e7ecb4008d3758355b7acf67ae019058bffb 100644 (file)
@@ -2,7 +2,6 @@
 #
 
 # Comedi "helper" modules
-obj-$(CONFIG_COMEDI)                   += pcm_common.o
 
 # Comedi misc drivers
 obj-$(CONFIG_COMEDI_BOND)              += comedi_bond.o
@@ -56,6 +55,7 @@ obj-$(CONFIG_COMEDI_POC)              += poc.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
index 90cc43263aee921204008fcff3d30dd4a16f7369..1051fa5ce8f7e571c810d7f0b602a40f712df1f6 100644 (file)
@@ -11,13 +11,21 @@ Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
        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 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.
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
-You should also find the complete GPL in the COPYING file accompanying this source code.
+You should also find the complete GPL in the COPYING file accompanying this
+source code.
 
 @endverbatim
 */
@@ -29,10 +37,10 @@ You should also find the complete GPL in the COPYING file accompanying this sour
   | 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                       |
+  | Project   : ADDI DATA         | Compiler : GCC                        |
   | Modulname : addi_common.c     | Version  : 2.96                       |
   +-------------------------------+---------------------------------------+
-  | Author    :           | Date     :                                   |
+  | Author    :           | Date     :                                    |
   +-----------------------------------------------------------------------+
   | Description : ADDI COMMON Main Module                                 |
   +-----------------------------------------------------------------------+
@@ -167,11 +175,11 @@ static int addi_auto_attach(struct comedi_device *dev,
        if (this_board->i_PCIEeprom) {
                if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
                        /*  Set 3 wait stait */
-                       if (!(strcmp(dev->board_name, "apci035"))) {
+                       if (!(strcmp(dev->board_name, "apci035")))
                                outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
-                       } else {
+                       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);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.c
deleted file mode 100644 (file)
index 5958a9c..0000000
+++ /dev/null
@@ -1,807 +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.
-
-You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-You should also find the complete GPL in the COPYING file accompanying this source code.
-
-@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     : API APCI1648    | Compiler : gcc                        |
-  | Module name : TTL.C           | Version  : 2.96                       |
-  +-------------------------------+---------------------------------------+
-  | Project manager: S. Weber     | Date     :  25/05/2005                |
-  +-----------------------------------------------------------------------+
-  | Description :   APCI-16XX TTL I/O module                              |
-  |                                                                       |
-  |                                                                       |
-  +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +-----------------------------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |25.05.2005| S.Weber   | Creation                                       |
-  |          |           |                                                |
-  +-----------------------------------------------------------------------+
-*/
-
-#ifndef COMEDI_SUBD_TTLIO
-#define COMEDI_SUBD_TTLIO              11 /* Digital Input Output But TTL */
-#endif
-
-#define APCI16XX_TTL_INIT              0
-#define APCI16XX_TTL_INITDIRECTION     1
-#define APCI16XX_TTL_OUTPUTMEMORY      2
-
-#define APCI16XX_TTL_READCHANNEL       0
-#define APCI16XX_TTL_READPORT          1
-
-#define APCI16XX_TTL_WRITECHANNEL_ON   0
-#define APCI16XX_TTL_WRITECHANNEL_OFF  1
-#define APCI16XX_TTL_WRITEPORT_ON      2
-#define APCI16XX_TTL_WRITEPORT_OFF     3
-
-#define APCI16XX_TTL_READ_ALL_INPUTS   0
-#define APCI16XX_TTL_READ_ALL_OUTPUTS  1
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : int   i_APCI16XX_InsnConfigInitTTLIO                   |
-|                          (struct comedi_device    *dev,                           |
-|                           struct comedi_subdevice *s,                             |
-|                           struct comedi_insn      *insn,                          |
-|                           unsigned int         *data)                          |
-+----------------------------------------------------------------------------+
-| Task           APCI16XX_TTL_INIT (using defaults)   :                      |
-|                Configure the TTL I/O operating mode from all ports         |
-|                You must calling this function be                           |
-|                for you call any other function witch access of TTL.        |
-|                APCI16XX_TTL_INITDIRECTION(user inputs for direction)       |
-+----------------------------------------------------------------------------+
-| Input Parameters  : b_InitType    = (unsigned char) data[0];                        |
-|                     b_Port0Mode   = (unsigned char) data[1];                        |
-|                     b_Port1Mode   = (unsigned char) data[2];                        |
-|                     b_Port2Mode   = (unsigned char) data[3];                        |
-|                     b_Port3Mode   = (unsigned char) data[4];                        |
-|                     ........                                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :>0: No error                                            |
-|                    -1: Port 0 mode selection is wrong                      |
-|                    -2: Port 1 mode selection is wrong                      |
-|                    -3: Port 2 mode selection is wrong                      |
-|                    -4: Port 3 mode selection is wrong                      |
-|                    -X: Port X-1 mode selection is wrong                    |
-|                    ....                                                    |
-|                    -100 : Config command error                             |
-|                    -101 : Data size error                                  |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI16XX_InsnConfigInitTTLIO(struct comedi_device *dev,
-                                         struct comedi_subdevice *s,
-                                         struct comedi_insn *insn,
-                                         unsigned int *data)
-{
-       const struct addi_board *this_board = comedi_board(dev);
-       struct addi_private *devpriv = dev->private;
-       int i_ReturnValue = insn->n;
-       unsigned char b_Command = 0;
-       unsigned char b_Cpt = 0;
-       unsigned char b_NumberOfPort =
-               (unsigned char) (this_board->i_NbrTTLChannel / 8);
-
-       /************************/
-       /* Test the buffer size */
-       /************************/
-
-       if (insn->n >= 1) {
-          /*******************/
-               /* Get the command */
-               /* **************** */
-
-               b_Command = (unsigned char) data[0];
-
-          /********************/
-               /* Test the command */
-          /********************/
-
-               if ((b_Command == APCI16XX_TTL_INIT) ||
-                       (b_Command == APCI16XX_TTL_INITDIRECTION) ||
-                       (b_Command == APCI16XX_TTL_OUTPUTMEMORY)) {
-             /***************************************/
-                       /* Test the initialisation buffer size */
-             /***************************************/
-
-                       if ((b_Command == APCI16XX_TTL_INITDIRECTION)
-                               && ((unsigned char) (insn->n - 1) != b_NumberOfPort)) {
-                /*******************/
-                               /* Data size error */
-                /*******************/
-
-                               printk("\nBuffer size error");
-                               i_ReturnValue = -101;
-                       }
-
-                       if ((b_Command == APCI16XX_TTL_OUTPUTMEMORY)
-                               && ((unsigned char) (insn->n) != 2)) {
-                /*******************/
-                               /* Data size error */
-                /*******************/
-
-                               printk("\nBuffer size error");
-                               i_ReturnValue = -101;
-                       }
-               } else {
-             /************************/
-                       /* Config command error */
-             /************************/
-
-                       printk("\nCommand selection error");
-                       i_ReturnValue = -100;
-               }
-       } else {
-          /*******************/
-               /* Data size error */
-          /*******************/
-
-               printk("\nBuffer size error");
-               i_ReturnValue = -101;
-       }
-
-       /**************************************************************************/
-       /* Test if no error occur and APCI16XX_TTL_INITDIRECTION command selected */
-       /**************************************************************************/
-
-       if ((i_ReturnValue >= 0) && (b_Command == APCI16XX_TTL_INITDIRECTION)) {
-               memset(devpriv->ul_TTLPortConfiguration, 0,
-                       sizeof(devpriv->ul_TTLPortConfiguration));
-
-          /*************************************/
-               /* Test the port direction selection */
-          /*************************************/
-
-               for (b_Cpt = 1;
-                       (b_Cpt <= b_NumberOfPort) && (i_ReturnValue >= 0);
-                       b_Cpt++) {
-             /**********************/
-                       /* Test the direction */
-             /**********************/
-
-                       if ((data[b_Cpt] != 0) && (data[b_Cpt] != 0xFF)) {
-                /************************/
-                               /* Port direction error */
-                /************************/
-
-                               printk("\nPort %d direction selection error",
-                                       (int) b_Cpt);
-                               i_ReturnValue = -(int) b_Cpt;
-                       }
-
-             /**************************/
-                       /* Save the configuration */
-             /**************************/
-
-                       devpriv->ul_TTLPortConfiguration[(b_Cpt - 1) / 4] =
-                               devpriv->ul_TTLPortConfiguration[(b_Cpt -
-                                       1) / 4] | (data[b_Cpt] << (8 * ((b_Cpt -
-                                                       1) % 4)));
-               }
-       }
-
-       /**************************/
-       /* Test if no error occur */
-       /**************************/
-
-       if (i_ReturnValue >= 0) {
-          /***********************************/
-               /* Test if TTL port initilaisation */
-          /***********************************/
-
-               if ((b_Command == APCI16XX_TTL_INIT)
-                       || (b_Command == APCI16XX_TTL_INITDIRECTION)) {
-             /******************************/
-                       /* Set all port configuration */
-             /******************************/
-
-                       for (b_Cpt = 0; b_Cpt <= b_NumberOfPort; b_Cpt++) {
-                               if ((b_Cpt % 4) == 0) {
-                   /*************************/
-                                       /* Set the configuration */
-                   /*************************/
-
-                                       outl(devpriv->
-                                               ul_TTLPortConfiguration[b_Cpt /
-                                                       4],
-                                               devpriv->iobase + 32 + b_Cpt);
-                               }
-                       }
-               }
-       }
-
-       /************************************************/
-       /* Test if output memory initialisation command */
-       /************************************************/
-
-       if (b_Command == APCI16XX_TTL_OUTPUTMEMORY) {
-               if (data[1]) {
-                       devpriv->b_OutputMemoryStatus = ADDIDATA_ENABLE;
-               } else {
-                       devpriv->b_OutputMemoryStatus = ADDIDATA_DISABLE;
-               }
-       }
-
-       return i_ReturnValue;
-}
-
-/*
-+----------------------------------------------------------------------------+
-|                            INPUT FUNCTIONS                                 |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : int     i_APCI16XX_InsnBitsReadTTLIO                   |
-|                          (struct comedi_device    *dev,                           |
-|                           struct comedi_subdevice *s,                             |
-|                           struct comedi_insn      *insn,                          |
-|                           unsigned int         *data)                          |
-+----------------------------------------------------------------------------+
-| Task              : Read the status from selected TTL digital input        |
-|                     (b_InputChannel)                                       |
-+----------------------------------------------------------------------------+
-| Task              : Read the status from digital input port                |
-|                     (b_SelectedPort)                                       |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                        |
-|              APCI16XX_TTL_READCHANNEL                                      |
-|                    b_SelectedPort= CR_RANGE(insn->chanspec);               |
-|                    b_InputChannel= CR_CHAN(insn->chanspec);                |
-|                    b_ReadType          = (unsigned char) data[0];                          |
-|                                                                            |
-|              APCI16XX_TTL_READPORT                                         |
-|                    b_SelectedPort= CR_RANGE(insn->chanspec);               |
-|                    b_ReadType          = (unsigned char) data[0];                          |
-+----------------------------------------------------------------------------+
-| Output Parameters : data[0]    0 : Channle is not active                   |
-|                                1 : Channle is active                       |
-+----------------------------------------------------------------------------+
-| Return Value      : >0  : No error                                         |
-|                    -100 : Config command error                             |
-|                    -101 : Data size error                                  |
-|                    -102 : The selected TTL input port is wrong             |
-|                    -103 : The selected TTL digital input is wrong          |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI16XX_InsnBitsReadTTLIO(struct comedi_device *dev,
-                                       struct comedi_subdevice *s,
-                                       struct comedi_insn *insn,
-                                       unsigned int *data)
-{
-       const struct addi_board *this_board = comedi_board(dev);
-       struct addi_private *devpriv = dev->private;
-       int i_ReturnValue = insn->n;
-       unsigned char b_Command = 0;
-       unsigned char b_NumberOfPort =
-               (unsigned char) (this_board->i_NbrTTLChannel / 8);
-       unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
-       unsigned char b_InputChannel = CR_CHAN(insn->chanspec);
-       unsigned char *pb_Status;
-       unsigned int dw_Status;
-
-       /************************/
-       /* Test the buffer size */
-       /************************/
-
-       if (insn->n >= 1) {
-          /*******************/
-               /* Get the command */
-               /* **************** */
-
-               b_Command = (unsigned char) data[0];
-
-          /********************/
-               /* Test the command */
-          /********************/
-
-               if ((b_Command == APCI16XX_TTL_READCHANNEL)
-                       || (b_Command == APCI16XX_TTL_READPORT)) {
-             /**************************/
-                       /* Test the selected port */
-             /**************************/
-
-                       if (b_SelectedPort < b_NumberOfPort) {
-                /**********************/
-                               /* Test if input port */
-                /**********************/
-
-                               if (((devpriv->ul_TTLPortConfiguration
-                                                       [b_SelectedPort /
-                                                               4] >> (8 *
-                                                               (b_SelectedPort
-                                                                       %
-                                                                       4))) &
-                                               0xFF) == 0) {
-                   /***************************/
-                                       /* Test the channel number */
-                   /***************************/
-
-                                       if ((b_Command ==
-                                                       APCI16XX_TTL_READCHANNEL)
-                                               && (b_InputChannel > 7)) {
-                      /*******************************************/
-                                               /* The selected TTL digital input is wrong */
-                      /*******************************************/
-
-                                               printk("\nChannel selection error");
-                                               i_ReturnValue = -103;
-                                       }
-                               } else {
-                   /****************************************/
-                                       /* The selected TTL input port is wrong */
-                   /****************************************/
-
-                                       printk("\nPort selection error");
-                                       i_ReturnValue = -102;
-                               }
-                       } else {
-                /****************************************/
-                               /* The selected TTL input port is wrong */
-                /****************************************/
-
-                               printk("\nPort selection error");
-                               i_ReturnValue = -102;
-                       }
-               } else {
-             /************************/
-                       /* Config command error */
-             /************************/
-
-                       printk("\nCommand selection error");
-                       i_ReturnValue = -100;
-               }
-       } else {
-          /*******************/
-               /* Data size error */
-          /*******************/
-
-               printk("\nBuffer size error");
-               i_ReturnValue = -101;
-       }
-
-       /**************************/
-       /* Test if no error occur */
-       /**************************/
-
-       if (i_ReturnValue >= 0) {
-               pb_Status = (unsigned char *) &data[0];
-
-          /*******************************/
-               /* Get the digital inpu status */
-          /*******************************/
-
-               dw_Status =
-                       inl(devpriv->iobase + 8 + ((b_SelectedPort / 4) * 4));
-               dw_Status = (dw_Status >> (8 * (b_SelectedPort % 4))) & 0xFF;
-
-          /***********************/
-               /* Save the port value */
-          /***********************/
-
-               *pb_Status = (unsigned char) dw_Status;
-
-          /***************************************/
-               /* Test if read channel status command */
-          /***************************************/
-
-               if (b_Command == APCI16XX_TTL_READCHANNEL) {
-                       *pb_Status = (*pb_Status >> b_InputChannel) & 1;
-               }
-       }
-
-       return i_ReturnValue;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : int i_APCI16XX_InsnReadTTLIOAllPortValue               |
-|                          (struct comedi_device    *dev,                           |
-|                           struct comedi_subdevice *s,                             |
-|                           struct comedi_insn      *insn,                          |
-|                           unsigned int         *data)                          |
-+----------------------------------------------------------------------------+
-| Task              : Read the status from all digital input ports           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : -                                                      |
-+----------------------------------------------------------------------------+
-| Output Parameters : data[0] : Port 0 to 3 data                             |
-|                     data[1] : Port 4 to 7 data                             |
-|                     ....                                                   |
-+----------------------------------------------------------------------------+
-| Return Value      : 0: No error                                            |
-|                    -100 : Read command error                               |
-|                    -101 : Data size error                                  |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI16XX_InsnReadTTLIOAllPortValue(struct comedi_device *dev,
-                                               struct comedi_subdevice *s,
-                                               struct comedi_insn *insn,
-                                               unsigned int *data)
-{
-       const struct addi_board *this_board = comedi_board(dev);
-       struct addi_private *devpriv = dev->private;
-       unsigned char b_Command = (unsigned char) CR_AREF(insn->chanspec);
-       int i_ReturnValue = insn->n;
-       unsigned char b_Cpt = 0;
-       unsigned char b_NumberOfPort = 0;
-       unsigned int *pls_ReadData = data;
-
-       /********************/
-       /* Test the command */
-       /********************/
-
-       if ((b_Command == APCI16XX_TTL_READ_ALL_INPUTS)
-               || (b_Command == APCI16XX_TTL_READ_ALL_OUTPUTS)) {
-          /**********************************/
-               /* Get the number of 32-Bit ports */
-          /**********************************/
-
-               b_NumberOfPort =
-                       (unsigned char) (this_board->i_NbrTTLChannel / 32);
-               if ((b_NumberOfPort * 32) <
-                       this_board->i_NbrTTLChannel) {
-                       b_NumberOfPort = b_NumberOfPort + 1;
-               }
-
-          /************************/
-               /* Test the buffer size */
-          /************************/
-
-               if (insn->n >= b_NumberOfPort) {
-                       if (b_Command == APCI16XX_TTL_READ_ALL_INPUTS) {
-                /**************************/
-                               /* Read all digital input */
-                /**************************/
-
-                               for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt++) {
-                   /************************/
-                                       /* Read the 32-Bit port */
-                   /************************/
-
-                                       pls_ReadData[b_Cpt] =
-                                               inl(devpriv->iobase + 8 +
-                                               (b_Cpt * 4));
-
-                   /**************************************/
-                                       /* Mask all channels used als outputs */
-                   /**************************************/
-
-                                       pls_ReadData[b_Cpt] =
-                                               pls_ReadData[b_Cpt] &
-                                               (~devpriv->
-                                               ul_TTLPortConfiguration[b_Cpt]);
-                               }
-                       } else {
-                /****************************/
-                               /* Read all digital outputs */
-                /****************************/
-
-                               for (b_Cpt = 0; b_Cpt < b_NumberOfPort; b_Cpt++) {
-                   /************************/
-                                       /* Read the 32-Bit port */
-                   /************************/
-
-                                       pls_ReadData[b_Cpt] =
-                                               inl(devpriv->iobase + 20 +
-                                               (b_Cpt * 4));
-
-                   /**************************************/
-                                       /* Mask all channels used als outputs */
-                   /**************************************/
-
-                                       pls_ReadData[b_Cpt] =
-                                               pls_ReadData[b_Cpt] & devpriv->
-                                               ul_TTLPortConfiguration[b_Cpt];
-                               }
-                       }
-               } else {
-             /*******************/
-                       /* Data size error */
-             /*******************/
-
-                       printk("\nBuffer size error");
-                       i_ReturnValue = -101;
-               }
-       } else {
-          /*****************/
-               /* Command error */
-          /*****************/
-
-               printk("\nCommand selection error");
-               i_ReturnValue = -100;
-       }
-
-       return i_ReturnValue;
-}
-
-/*
-+----------------------------------------------------------------------------+
-|                            OUTPUT FUNCTIONS                                |
-+----------------------------------------------------------------------------+
-*/
-
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : int     i_APCI16XX_InsnBitsWriteTTLIO                  |
-|                          (struct comedi_device    *dev,                           |
-|                           struct comedi_subdevice *s,                             |
-|                           struct comedi_insn      *insn,                          |
-|                           unsigned int         *data)                          |
-+----------------------------------------------------------------------------+
-| Task              : Set the state from selected TTL digital output         |
-|                     (b_OutputChannel)                                      |
-+----------------------------------------------------------------------------+
-| Task              : Set the state from digital output port                 |
-|                     (b_SelectedPort)                                       |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                        |
-|              APCI16XX_TTL_WRITECHANNEL_ON | APCI16XX_TTL_WRITECHANNEL_OFF  |
-|                    b_SelectedPort = CR_RANGE(insn->chanspec);              |
-|                    b_OutputChannel= CR_CHAN(insn->chanspec);               |
-|                    b_Command      = (unsigned char) data[0];                        |
-|                                                                            |
-|              APCI16XX_TTL_WRITEPORT_ON | APCI16XX_TTL_WRITEPORT_OFF        |
-|                    b_SelectedPort = CR_RANGE(insn->chanspec);              |
-|                    b_Command      = (unsigned char) data[0];                        |
-+----------------------------------------------------------------------------+
-| Output Parameters : data[0] : TTL output port 0 to 3 data                  |
-|                     data[1] : TTL output port 4 to 7 data                  |
-|                     ....                                                   |
-+----------------------------------------------------------------------------+
-| Return Value      : >0  : No error                                         |
-|                    -100 : Command error                                    |
-|                    -101 : Data size error                                  |
-|                    -102 : The selected TTL output port is wrong            |
-|                    -103 : The selected TTL digital output is wrong         |
-|                    -104 : Output memory disabled                           |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI16XX_InsnBitsWriteTTLIO(struct comedi_device *dev,
-                                        struct comedi_subdevice *s,
-                                        struct comedi_insn *insn,
-                                        unsigned int *data)
-{
-       const struct addi_board *this_board = comedi_board(dev);
-       struct addi_private *devpriv = dev->private;
-       int i_ReturnValue = insn->n;
-       unsigned char b_Command = 0;
-       unsigned char b_NumberOfPort =
-               (unsigned char) (this_board->i_NbrTTLChannel / 8);
-       unsigned char b_SelectedPort = CR_RANGE(insn->chanspec);
-       unsigned char b_OutputChannel = CR_CHAN(insn->chanspec);
-       unsigned int dw_Status = 0;
-
-       /************************/
-       /* Test the buffer size */
-       /************************/
-
-       if (insn->n >= 1) {
-          /*******************/
-               /* Get the command */
-               /* **************** */
-
-               b_Command = (unsigned char) data[0];
-
-          /********************/
-               /* Test the command */
-          /********************/
-
-               if ((b_Command == APCI16XX_TTL_WRITECHANNEL_ON) ||
-                       (b_Command == APCI16XX_TTL_WRITEPORT_ON) ||
-                       (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) ||
-                       (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) {
-             /**************************/
-                       /* Test the selected port */
-             /**************************/
-
-                       if (b_SelectedPort < b_NumberOfPort) {
-                /***********************/
-                               /* Test if output port */
-                /***********************/
-
-                               if (((devpriv->ul_TTLPortConfiguration
-                                                       [b_SelectedPort /
-                                                               4] >> (8 *
-                                                               (b_SelectedPort
-                                                                       %
-                                                                       4))) &
-                                               0xFF) == 0xFF) {
-                   /***************************/
-                                       /* Test the channel number */
-                   /***************************/
-
-                                       if (((b_Command == APCI16XX_TTL_WRITECHANNEL_ON) || (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF)) && (b_OutputChannel > 7)) {
-                      /********************************************/
-                                               /* The selected TTL digital output is wrong */
-                      /********************************************/
-
-                                               printk("\nChannel selection error");
-                                               i_ReturnValue = -103;
-                                       }
-
-                                       if (((b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) || (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE)) {
-                      /********************************************/
-                                               /* The selected TTL digital output is wrong */
-                      /********************************************/
-
-                                               printk("\nOutput memory disabled");
-                                               i_ReturnValue = -104;
-                                       }
-
-                   /************************/
-                                       /* Test the buffer size */
-                   /************************/
-
-                                       if (((b_Command == APCI16XX_TTL_WRITEPORT_ON) || (b_Command == APCI16XX_TTL_WRITEPORT_OFF)) && (insn->n < 2)) {
-                      /*******************/
-                                               /* Data size error */
-                      /*******************/
-
-                                               printk("\nBuffer size error");
-                                               i_ReturnValue = -101;
-                                       }
-                               } else {
-                   /*****************************************/
-                                       /* The selected TTL output port is wrong */
-                   /*****************************************/
-
-                                       printk("\nPort selection error %lX",
-                                               (unsigned long)devpriv->
-                                               ul_TTLPortConfiguration[0]);
-                                       i_ReturnValue = -102;
-                               }
-                       } else {
-                /****************************************/
-                               /* The selected TTL output port is wrong */
-                /****************************************/
-
-                               printk("\nPort selection error %d %d",
-                                       b_SelectedPort, b_NumberOfPort);
-                               i_ReturnValue = -102;
-                       }
-               } else {
-             /************************/
-                       /* Config command error */
-             /************************/
-
-                       printk("\nCommand selection error");
-                       i_ReturnValue = -100;
-               }
-       } else {
-          /*******************/
-               /* Data size error */
-          /*******************/
-
-               printk("\nBuffer size error");
-               i_ReturnValue = -101;
-       }
-
-       /**************************/
-       /* Test if no error occur */
-       /**************************/
-
-       if (i_ReturnValue >= 0) {
-          /********************************/
-               /* Get the digital output state */
-          /********************************/
-
-               dw_Status =
-                       inl(devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4));
-
-          /**********************************/
-               /* Test if output memory not used */
-          /**********************************/
-
-               if (devpriv->b_OutputMemoryStatus == ADDIDATA_DISABLE) {
-             /*********************************/
-                       /* Clear the selected port value */
-             /*********************************/
-
-                       dw_Status =
-                               dw_Status & (0xFFFFFFFFUL -
-                               (0xFFUL << (8 * (b_SelectedPort % 4))));
-               }
-
-          /******************************/
-               /* Test if setting channel ON */
-          /******************************/
-
-               if (b_Command == APCI16XX_TTL_WRITECHANNEL_ON) {
-                       dw_Status =
-                               dw_Status | (1UL << ((8 * (b_SelectedPort %
-                                                       4)) + b_OutputChannel));
-               }
-
-          /***************************/
-               /* Test if setting port ON */
-          /***************************/
-
-               if (b_Command == APCI16XX_TTL_WRITEPORT_ON) {
-                       dw_Status =
-                               dw_Status | ((data[1] & 0xFF) << (8 *
-                                       (b_SelectedPort % 4)));
-               }
-
-          /*******************************/
-               /* Test if setting channel OFF */
-          /*******************************/
-
-               if (b_Command == APCI16XX_TTL_WRITECHANNEL_OFF) {
-                       dw_Status =
-                               dw_Status & (0xFFFFFFFFUL -
-                               (1UL << ((8 * (b_SelectedPort % 4)) +
-                                               b_OutputChannel)));
-               }
-
-          /****************************/
-               /* Test if setting port OFF */
-          /****************************/
-
-               if (b_Command == APCI16XX_TTL_WRITEPORT_OFF) {
-                       dw_Status =
-                               dw_Status & (0xFFFFFFFFUL -
-                               ((data[1] & 0xFF) << (8 * (b_SelectedPort %
-                                                       4))));
-               }
-
-               outl(dw_Status,
-                       devpriv->iobase + 20 + ((b_SelectedPort / 4) * 4));
-       }
-
-       return i_ReturnValue;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_Reset(struct comedi_device *dev)               |                                                         +----------------------------------------------------------------------------+
-| Task              :resets all the registers                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev                                     |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      : -                                                      |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI16XX_Reset(struct comedi_device *dev)
-{
-       return 0;
-}
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci2200.c
deleted file mode 100644 (file)
index 9d4a117..0000000
+++ /dev/null
@@ -1,263 +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.
-
-You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-You should also find the complete GPL in the COPYING file accompanying this source code.
-
-@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-2200       | Compiler   : GCC                      |
-  | Module name : hwdrv_apci2200.c| Version    : 2.96                     |
-  +-------------------------------+---------------------------------------+
-  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
-  +-------------------------------+---------------------------------------+
-  | Description :   Hardware Layer Access For APCI-2200                   |
-  +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +----------+-----------+------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |           |                                                |
-  |          |           |                                                |
-  |          |           |                                                |
-  +----------+-----------+------------------------------------------------+
-*/
-
-/*********      Definitions for APCI-2200 card  *****/
-
-/* Card Specific information */
-#define APCI2200_ADDRESS_RANGE         64
-
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI2200_DIGITAL_OP            4
-#define APCI2200_DIGITAL_IP            0
-
-/* TIMER COUNTER WATCHDOG DEFINES */
-
-#define APCI2200_WATCHDOG              0x08
-#define APCI2200_WATCHDOG_ENABLEDISABLE        12
-#define APCI2200_WATCHDOG_RELOAD_VALUE 4
-#define APCI2200_WATCHDOG_STATUS       16
-
-static int apci2200_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] = inw(devpriv->iobase + APCI2200_DIGITAL_IP);
-
-       return insn->n;
-}
-
-static int apci2200_do_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int mask = data[0];
-       unsigned int bits = data[1];
-
-       s->state = inw(devpriv->iobase + APCI2200_DIGITAL_OP);
-       if (mask) {
-               s->state &= ~mask;
-               s->state |= (bits & mask);
-
-               outw(s->state, devpriv->iobase + APCI2200_DIGITAL_OP);
-       }
-
-       data[1] = s->state;
-
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_ConfigWatchdog(struct comedi_device *dev,
-|                      struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)  |
-|                                                                                   |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Watchdog                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   struct comedi_device *dev      : Driver handle              |
-|                     struct comedi_subdevice *s,   :pointer to subdevice structure
-|                      struct comedi_insn *insn      :pointer to insn structure      |
-|                     unsigned int *data          : Data Pointer to read status                                                                                                             |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI2200_ConfigWatchdog(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       if (data[0] == 0) {
-               /* Disable the watchdog */
-               outw(0x0,
-                       devpriv->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_ENABLEDISABLE);
-               /* Loading the Reload value */
-               outw(data[1],
-                       devpriv->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_RELOAD_VALUE);
-               data[1] = data[1] >> 16;
-               outw(data[1],
-                       devpriv->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_RELOAD_VALUE + 2);
-       }                       /* if(data[0]==0) */
-       else {
-               printk("\nThe input parameters are wrong\n");
-               return -EINVAL;
-       }                       /* elseif(data[0]==0) */
-
-       return insn->n;
-}
-
- /*
-    +----------------------------------------------------------------------------+
-    | Function   Name   : int i_APCI2200_StartStopWriteWatchdog                  |
-    |                           (struct comedi_device *dev,struct comedi_subdevice *s,
-    struct comedi_insn *insn,unsigned int *data);                      |
-    +----------------------------------------------------------------------------+
-    | Task              : Start / Stop The Watchdog                              |
-    +----------------------------------------------------------------------------+
-    | Input Parameters  : struct comedi_device *dev      : Driver handle                |
-    |                     struct comedi_subdevice *s,   :pointer to subdevice structure
-    struct comedi_insn *insn      :pointer to insn structure      |
-    |                     unsigned int *data          : Data Pointer to read status  |
-    +----------------------------------------------------------------------------+
-    | Output Parameters :       --                                                                                                       |
-    +----------------------------------------------------------------------------+
-    | Return Value      : TRUE  : No error occur                                 |
-    |                       : FALSE : Error occur. Return the error          |
-    |                                                                            |
-    +----------------------------------------------------------------------------+
-  */
-
-static int i_APCI2200_StartStopWriteWatchdog(struct comedi_device *dev,
-                                            struct comedi_subdevice *s,
-                                            struct comedi_insn *insn,
-                                            unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       switch (data[0]) {
-       case 0:         /* stop the watchdog */
-               outw(0x0, devpriv->iobase + APCI2200_WATCHDOG + APCI2200_WATCHDOG_ENABLEDISABLE);       /* disable the watchdog */
-               break;
-       case 1:         /* start the watchdog */
-               outw(0x0001,
-                       devpriv->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_ENABLEDISABLE);
-               break;
-       case 2:         /* Software trigger */
-               outw(0x0201,
-                       devpriv->iobase + APCI2200_WATCHDOG +
-                       APCI2200_WATCHDOG_ENABLEDISABLE);
-               break;
-       default:
-               printk("\nSpecified functionality does not exist\n");
-               return -EINVAL;
-       }                       /*  switch(data[0]) */
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_ReadWatchdog                            |
-|                      (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,
-|                    unsigned int *data);                                           |
-+----------------------------------------------------------------------------+
-| Task              : Read The Watchdog                                      |
-+----------------------------------------------------------------------------+
-| Input Parameters  :   struct comedi_device *dev      : Driver handle              |
-|                     struct comedi_subdevice *s,   :pointer to subdevice structure
-|                      struct comedi_insn *insn      :pointer to insn structure      |
-|                     unsigned int *data          : Data Pointer to read status  |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI2200_ReadWatchdog(struct comedi_device *dev,
-                                  struct comedi_subdevice *s,
-                                  struct comedi_insn *insn,
-                                  unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       data[0] =
-               inw(devpriv->iobase + APCI2200_WATCHDOG +
-               APCI2200_WATCHDOG_STATUS) & 0x1;
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI2200_Reset(struct comedi_device *dev)               |                                                                                                          |
-+----------------------------------------------------------------------------+
-| Task              :resets all the registers                                |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI2200_Reset(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-
-       outw(0x0, devpriv->iobase + APCI2200_DIGITAL_OP);       /* RESETS THE DIGITAL OUTPUTS */
-       outw(0x0,
-               devpriv->iobase + APCI2200_WATCHDOG +
-               APCI2200_WATCHDOG_ENABLEDISABLE);
-       outw(0x0,
-               devpriv->iobase + APCI2200_WATCHDOG +
-               APCI2200_WATCHDOG_RELOAD_VALUE);
-       outw(0x0,
-               devpriv->iobase + APCI2200_WATCHDOG +
-               APCI2200_WATCHDOG_RELOAD_VALUE + 2);
-       return 0;
-}
index 7a18ce704ba4e4d5793bc5679376e38cb8eb1e37..ebc1534a8df89b3f8d837499f6a67d27079797ef 100644 (file)
-/**
-@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.
-
-You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-You should also find the complete GPL in the COPYING file accompanying this source code.
-
-@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-3501       | Compiler   : GCC                      |
-  | Module name : hwdrv_apci3501.c| Version    : 2.96                     |
-  +-------------------------------+---------------------------------------+
-  | Project manager: Eric Stolz   | Date       :  02/12/2002              |
-  +-------------------------------+---------------------------------------+
-  | Description :   Hardware Layer Access For APCI-3501                   |
-  +-----------------------------------------------------------------------+
-  |                             UPDATES                                   |
-  +----------+-----------+------------------------------------------------+
-  |   Date   |   Author  |          Description of updates                |
-  +----------+-----------+------------------------------------------------+
-  |          |           |                                                |
-  |          |           |                                                |
-  |          |           |                                                |
-  +----------+-----------+------------------------------------------------+
-*/
-
-/* Card Specific information */
-#define APCI3501_ADDRESS_RANGE         255
-
-#define APCI3501_DIGITAL_IP            0x50
-#define APCI3501_DIGITAL_OP            0x40
-#define APCI3501_ANALOG_OUTPUT         0x00
-
-/* Analog Output related Defines */
-#define APCI3501_AO_VOLT_MODE          0
-#define APCI3501_AO_PROG               4
-#define APCI3501_AO_TRIG_SCS           8
-#define UNIPOLAR                       0
-#define BIPOLAR                                1
-#define MODE0                          0
-#define MODE1                          1
-
 /* Watchdog Related Defines */
 
-#define APCI3501_WATCHDOG              0x20
-#define APCI3501_TCW_SYNC_ENABLEDISABLE        0
-#define APCI3501_TCW_RELOAD_VALUE      4
-#define APCI3501_TCW_TIMEBASE          8
-#define APCI3501_TCW_PROG              12
-#define APCI3501_TCW_TRIG_STATUS       16
-#define APCI3501_TCW_IRQ               20
-#define APCI3501_TCW_WARN_TIMEVAL      24
-#define APCI3501_TCW_WARN_TIMEBASE     28
 #define ADDIDATA_TIMER                 0
 #define ADDIDATA_WATCHDOG              2
 
-/* ANALOG OUTPUT RANGE */
-static struct comedi_lrange range_apci3501_ao = {
-       2, {
-               BIP_RANGE(10),
-               UNI_RANGE(10)
-       }
-};
-
-static int apci3501_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->iobase + APCI3501_DIGITAL_IP) & 0x3;
-
-       return insn->n;
-}
-
-static int apci3501_do_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int mask = data[0];
-       unsigned int bits = data[1];
-
-       s->state = inl(devpriv->iobase + APCI3501_DIGITAL_OP);
-       if (mask) {
-               s->state &= ~mask;
-               s->state |= (bits & mask);
-
-               outl(s->state, devpriv->iobase + APCI3501_DIGITAL_OP);
-       }
-
-       data[1] = s->state;
-
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3501_ConfigAnalogOutput                      |
-|                        (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                      struct comedi_insn *insn,unsigned int *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Analog Output Subdevice                 |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev      : Driver handle                |
-|                     struct comedi_subdevice *s     : Subdevice Pointer            |
-|                     struct comedi_insn *insn       : Insn Structure Pointer       |
-|                     unsigned int *data          : Data Pointer contains        |
-|                                          configuration parameters as below |
-|                                                                            |
-|                                      data[0]            : Voltage Mode                |
-|                                                0:Mode 0                    |
-|                                                1:Mode 1                    |
-|                                                                            |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-static int i_APCI3501_ConfigAnalogOutput(struct comedi_device *dev,
-                                        struct comedi_subdevice *s,
-                                        struct comedi_insn *insn,
-                                        unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       outl(data[0],
-               devpriv->iobase + APCI3501_ANALOG_OUTPUT +
-               APCI3501_AO_VOLT_MODE);
-
-       if (data[0]) {
-               devpriv->b_InterruptMode = MODE1;
-       } else {
-               devpriv->b_InterruptMode = MODE0;
-       }
-       return insn->n;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3501_WriteAnalogOutput                       |
-|                        (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                      struct comedi_insn *insn,unsigned int *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Writes To the Selected Anlog Output Channel            |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev      : Driver handle                |
-|                     struct comedi_subdevice *s     : Subdevice Pointer            |
-|                     struct comedi_insn *insn       : Insn Structure Pointer       |
-|                     unsigned int *data          : Data Pointer contains        |
-|                                          configuration parameters as below |
-|                                                                            |
-|                                                                            |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-static int i_APCI3501_WriteAnalogOutput(struct comedi_device *dev,
-                                       struct comedi_subdevice *s,
-                                       struct comedi_insn *insn,
-                                       unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int ul_Command1 = 0, ul_Channel_no, ul_Polarity, ul_DAC_Ready = 0;
-
-       ul_Channel_no = CR_CHAN(insn->chanspec);
-
-       if (devpriv->b_InterruptMode == MODE1) {
-               ul_Polarity = 0x80000000;
-               if ((*data < 0) || (*data > 16384)) {
-                       printk("\nIn WriteAnalogOutput :: Not Valid Data\n");
-               }
-
-       }                       /*  end if(devpriv->b_InterruptMode==MODE1) */
-       else {
-               ul_Polarity = 0;
-               if ((*data < 0) || (*data > 8192)) {
-                       printk("\nIn WriteAnalogOutput :: Not Valid Data\n");
-               }
-
-       }                       /*  end else */
-
-       if ((ul_Channel_no < 0) || (ul_Channel_no > 7)) {
-               printk("\nIn WriteAnalogOutput :: Not Valid Channel\n");
-       }                       /*  end if((ul_Channel_no<0)||(ul_Channel_no>7)) */
-
-       ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT);
-
-       while (ul_DAC_Ready == 0) {
-               ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT);
-               ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1;
-       }
-
-       if (ul_DAC_Ready) {
-/* Output the Value on the output channels. */
-               ul_Command1 =
-                       (unsigned int) ((unsigned int) (ul_Channel_no & 0xFF) |
-                       (unsigned int) ((*data << 0x8) & 0x7FFFFF00L) |
-                       (unsigned int) (ul_Polarity));
-               outl(ul_Command1,
-                       devpriv->iobase + APCI3501_ANALOG_OUTPUT +
-                       APCI3501_AO_PROG);
-       }
-
-       return insn->n;
-}
-
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3501_ConfigTimerCounterWatchdog              |
-|                        (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                      struct comedi_insn *insn,unsigned int *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Configures The Timer , Counter or Watchdog             |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev : Driver handle                     |
-|                     unsigned int *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            |
-|                                        data[0]            : 0 Configure As Timer      |
-|                                                                                 1 Configure As Counter    |
-|                                                                                 2 Configure As Watchdog   |
-|                                        data[1]            : 1 Enable  Interrupt       |
-|                                                                                 0 Disable Interrupt       |
-|                                        data[2]            : Time Unit                 |
-|                                        data[3]                        : Reload Value                      |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
+ * (*insn_config) for the timer subdevice
+ *
+ * Configures The Timer, Counter or Watchdog
+ * Data Pointer contains configuration parameters as below
+ *     data[0] : 0 Configure As Timer
+ *               1 Configure As Counter
+ *               2 Configure As Watchdog
+ *     data[1] : 1 Enable  Interrupt
+ *               0 Disable Interrupt
+ *     data[2] : Time Unit
+ *     data[3] : Reload Value
+ */
 static int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev,
                                                 struct comedi_subdevice *s,
                                                 struct comedi_insn *insn,
                                                 unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3501_private *devpriv = dev->private;
        unsigned int ul_Command1 = 0;
 
        devpriv->tsk_Current = current;
@@ -276,224 +29,146 @@ static int i_APCI3501_ConfigTimerCounterWatchdog(struct comedi_device *dev,
 
                devpriv->b_TimerSelectMode = ADDIDATA_WATCHDOG;
                /* Disable the watchdog */
-               outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);     /* disable Wa */
+               outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
 
                if (data[1] == 1) {
                        /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
-                       outl(0x02,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG);
                } else {
-                       outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);     /* disable Timer interrupt */
+                       /* disable Timer interrupt */
+                       outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
                }
 
-               /* Loading the Timebase value */
-               outl(data[2],
-                       devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_TIMEBASE);
+               outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
+               outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
 
-               /* Loading the Reload value */
-               outl(data[3],
-                       devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_RELOAD_VALUE);
-               /* Set the mode */
-               ul_Command1 = inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG) | 0xFFF819E0UL;      /* e2->e0 */
-               outl(ul_Command1,
-                       devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_PROG);
-       }                       /* end if(data[0]==ADDIDATA_WATCHDOG) */
+               /* Set the mode (e2->e0) */
+               ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG) | 0xFFF819E0UL;
+               outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+       }
 
        else if (data[0] == ADDIDATA_TIMER) {
                /* First Stop The Timer */
-               ul_Command1 =
-                       inl(devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_PROG);
+               ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
-               outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);     /* Stop The Timer */
+               outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
                devpriv->b_TimerSelectMode = ADDIDATA_TIMER;
                if (data[1] == 1) {
                        /* Enable TIMER int & DISABLE ALL THE OTHER int SOURCES */
-                       outl(0x02,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(0x02, dev->iobase + APCI3501_TIMER_CTRL_REG);
                } else {
-                       outl(0x0, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);     /* disable Timer interrupt */
+                       /* disable Timer interrupt */
+                       outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
                }
 
-               /*  Loading Timebase */
-               outl(data[2],
-                       devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_TIMEBASE);
-
-               /* Loading the Reload value */
-               outl(data[3],
-                       devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_RELOAD_VALUE);
+               outl(data[2], dev->iobase + APCI3501_TIMER_TIMEBASE_REG);
+               outl(data[3], dev->iobase + APCI3501_TIMER_RELOAD_REG);
 
-               /*  printk ("\nTimer Address :: %x\n", (devpriv->iobase+APCI3501_WATCHDOG)); */
-               ul_Command1 =
-                       inl(devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_PROG);
+               /* mode 2 */
+               ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                ul_Command1 =
                        (ul_Command1 & 0xFFF719E2UL) | 2UL << 13UL | 0x10UL;
-               outl(ul_Command1, devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);     /* mode 2 */
-
-       }                       /* end if(data[0]==ADDIDATA_TIMER) */
+               outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+       }
 
        return insn->n;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3501_StartStopWriteTimerCounterWatchdog      |
-|                        (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                      struct comedi_insn *insn,unsigned int *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Start / Stop The Selected Timer , Counter or Watchdog  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev : Driver handle                     |
-|                     unsigned int *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            |
-|                                        data[0]            : 0 Timer                   |
-|                                                                                 1 Counter                 |
-|                                                                                 2 Watchdog                    |                             |                                         data[1]            : 1 Start                   |
-|                                                                                 0 Stop                                |                                                                                                                    2 Trigger                 |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
+ * (*insn_write) for the timer subdevice
+ *
+ * Start / Stop The Selected Timer , Counter or Watchdog
+ * Data Pointer contains configuration parameters as below
+ *     data[0] : 0 Timer
+ *               1 Counter
+ *               2 Watchdog
+ *     data[1] : 1 Start
+ *               0 Stop
+ *               2 Trigger
+ */
 static int i_APCI3501_StartStopWriteTimerCounterWatchdog(struct comedi_device *dev,
                                                         struct comedi_subdevice *s,
                                                         struct comedi_insn *insn,
                                                         unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3501_private *devpriv = dev->private;
        unsigned int ul_Command1 = 0;
        int i_Temp;
 
        if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
 
                if (data[1] == 1) {
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
                        /* Enable the Watchdog */
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
                }
 
                else if (data[1] == 0)  /* Stop The Watchdog */
                {
                        /* Stop The Watchdog */
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
-                       outl(0x0,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
                } else if (data[1] == 2) {
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x200UL;
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
-               }               /* if(data[1]==2) */
-       }                       /*  end if (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
+                       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+               }
+       }
 
        if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
                if (data[1] == 1) {
 
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x1UL;
                        /* Enable the Timer */
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
                } else if (data[1] == 0) {
                        /* Stop The Timer */
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = ul_Command1 & 0xFFFFF9FEUL;
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
                }
 
                else if (data[1] == 2) {
                        /* Trigger the Timer */
-                       ul_Command1 =
-                               inl(devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
                        ul_Command1 = (ul_Command1 & 0xFFFFF9FFUL) | 0x200UL;
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_WATCHDOG +
-                               APCI3501_TCW_PROG);
+                       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
                }
+       }
 
-       }                       /*  end if (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
-       i_Temp = inl(devpriv->iobase + APCI3501_WATCHDOG +
-               APCI3501_TCW_TRIG_STATUS) & 0x1;
+       i_Temp = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
        return insn->n;
 }
 
 /*
-+----------------------------------------------------------------------------+
-| Function   Name   : int i_APCI3501_ReadTimerCounterWatchdog                |
-|                        (struct comedi_device *dev,struct comedi_subdevice *s,               |
-|                      struct comedi_insn *insn,unsigned int *data)                     |
-+----------------------------------------------------------------------------+
-| Task              : Read The Selected Timer , Counter or Watchdog          |
-+----------------------------------------------------------------------------+
-| Input Parameters  : struct comedi_device *dev : Driver handle                     |
-|                     unsigned int *data         : Data Pointer contains             |
-|                                          configuration parameters as below |
-|                                                                            |
-|                                        data[0]            : 0 Timer                   |
-|                                                                                 1 Counter                 |
-|                                                                                 2 Watchdog                |                             |                                      data[1]             : Timer Counter Watchdog Number   |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
+ * (*insn_read) for the timer subdevice
+ *
+ * Read The Selected Timer, Counter or Watchdog
+ * Data Pointer contains configuration parameters as below
+ *     data[0] : 0 Timer
+ *               1 Counter
+ *               2 Watchdog
+ *     data[1] : Timer Counter Watchdog Number
+ */
 static int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev,
                                               struct comedi_subdevice *s,
                                               struct comedi_insn *insn,
                                               unsigned int *data)
 {
-       struct addi_private *devpriv = dev->private;
+       struct apci3501_private *devpriv = dev->private;
 
        if (devpriv->b_TimerSelectMode == ADDIDATA_WATCHDOG) {
-               data[0] =
-                       inl(devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_TRIG_STATUS) & 0x1;
-               data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG);
-       }                       /*  end if  (devpriv->b_TimerSelectMode==ADDIDATA_WATCHDOG) */
+               data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
+               data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
+       }
 
        else if (devpriv->b_TimerSelectMode == ADDIDATA_TIMER) {
-               data[0] =
-                       inl(devpriv->iobase + APCI3501_WATCHDOG +
-                       APCI3501_TCW_TRIG_STATUS) & 0x1;
-               data[1] = inl(devpriv->iobase + APCI3501_WATCHDOG);
-       }                       /*  end if  (devpriv->b_TimerSelectMode==ADDIDATA_TIMER) */
+               data[0] = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
+               data[1] = inl(dev->iobase + APCI3501_TIMER_SYNC_REG);
+       }
 
        else if ((devpriv->b_TimerSelectMode != ADDIDATA_TIMER)
                && (devpriv->b_TimerSelectMode != ADDIDATA_WATCHDOG)) {
@@ -501,111 +176,3 @@ static int i_APCI3501_ReadTimerCounterWatchdog(struct comedi_device *dev,
        }
        return insn->n;
 }
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   :  int i_APCI3501_Reset(struct comedi_device *dev)                      |
-|                                                                                       |
-+----------------------------------------------------------------------------+
-| Task              :Resets the registers of the card                        |
-+----------------------------------------------------------------------------+
-| Input Parameters  :                                                        |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      :                                                        |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_APCI3501_Reset(struct comedi_device *dev)
-{
-       struct addi_private *devpriv = dev->private;
-       int i_Count = 0, i_temp = 0;
-       unsigned int ul_Command1 = 0, ul_Polarity, ul_DAC_Ready = 0;
-
-       outl(0x0, devpriv->iobase + APCI3501_DIGITAL_OP);
-       outl(1, devpriv->iobase + APCI3501_ANALOG_OUTPUT +
-               APCI3501_AO_VOLT_MODE);
-
-       ul_Polarity = 0x80000000;
-
-       for (i_Count = 0; i_Count <= 7; i_Count++) {
-               ul_DAC_Ready = inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT);
-
-               while (ul_DAC_Ready == 0) {
-                       ul_DAC_Ready =
-                               inl(devpriv->iobase + APCI3501_ANALOG_OUTPUT);
-                       ul_DAC_Ready = (ul_DAC_Ready >> 8) & 1;
-               }
-
-               if (ul_DAC_Ready) {
-                       /*  Output the Value on the output channels. */
-                       ul_Command1 =
-                               (unsigned int) ((unsigned int) (i_Count & 0xFF) |
-                               (unsigned int) ((i_temp << 0x8) & 0x7FFFFF00L) |
-                               (unsigned int) (ul_Polarity));
-                       outl(ul_Command1,
-                               devpriv->iobase + APCI3501_ANALOG_OUTPUT +
-                               APCI3501_AO_PROG);
-               }
-       }
-
-       return 0;
-}
-
-/*
-+----------------------------------------------------------------------------+
-| Function   Name   : static void v_APCI3501_Interrupt                                      |
-|                                        (int irq , void *d)      |
-+----------------------------------------------------------------------------+
-| Task              : Interrupt processing Routine                           |
-+----------------------------------------------------------------------------+
-| Input Parameters  : int irq                 : irq number                   |
-|                     void *d                 : void pointer                 |
-+----------------------------------------------------------------------------+
-| Output Parameters :  --                                                                                                       |
-+----------------------------------------------------------------------------+
-| Return Value      : TRUE  : No error occur                                 |
-|                          : FALSE : Error occur. Return the error          |
-|                                                                               |
-+----------------------------------------------------------------------------+
-*/
-static void v_APCI3501_Interrupt(int irq, void *d)
-{
-       int i_temp;
-       struct comedi_device *dev = d;
-       struct addi_private *devpriv = dev->private;
-       unsigned int ui_Timer_AOWatchdog;
-       unsigned long ul_Command1;
-
-       /*  Disable Interrupt */
-       ul_Command1 =
-               inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
-
-       ul_Command1 = (ul_Command1 & 0xFFFFF9FDul);
-       outl(ul_Command1,
-               devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
-
-       ui_Timer_AOWatchdog =
-               inl(devpriv->iobase + APCI3501_WATCHDOG +
-               APCI3501_TCW_IRQ) & 0x1;
-
-       if ((!ui_Timer_AOWatchdog)) {
-               comedi_error(dev, "IRQ from unknown source");
-               return;
-       }
-
-/*
-* Enable Interrupt Send a signal to from kernel to user space
-*/
-       send_sig(SIGIO, devpriv->tsk_Current, 0);
-       ul_Command1 =
-               inl(devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
-       ul_Command1 = ((ul_Command1 & 0xFFFFF9FDul) | 1 << 1);
-       outl(ul_Command1,
-               devpriv->iobase + APCI3501_WATCHDOG + APCI3501_TCW_PROG);
-       i_temp = inl(devpriv->iobase + APCI3501_WATCHDOG +
-               APCI3501_TCW_TRIG_STATUS) & 0x1;
-       return;
-}
index c981d4b1cc731573575dafe0c82c646190a54166..d69d6ec78361cf5d5da62589f07b3f0994f78813 100644 (file)
@@ -53,11 +53,6 @@ static int apci035_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci035_driver);
 }
 
-static void apci035_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci035_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA,  0x0300) },
        { 0 }
@@ -68,7 +63,7 @@ static struct pci_driver apci035_pci_driver = {
        .name           = "addi_apci_035",
        .id_table       = apci035_pci_table,
        .probe          = apci035_pci_probe,
-       .remove         = apci035_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci035_driver, apci035_pci_driver);
 
index 7f9424205a64d748b0c86aeac52fcaaf8010b2cb..d2abfc2a7be54096f334126b478dd4a056b286e9 100644 (file)
@@ -375,11 +375,6 @@ static int apci1032_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci1032_driver);
 }
 
-static void apci1032_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci1032_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1003) },
        { 0 }
@@ -390,7 +385,7 @@ static struct pci_driver apci1032_pci_driver = {
        .name           = "addi_apci_1032",
        .id_table       = apci1032_pci_table,
        .probe          = apci1032_pci_probe,
-       .remove         = apci1032_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver);
 
index 8e686a9b811b4b3204617972b449e37d7d5978b4..1ac40629012c8f783ceeadd011809c59313d2856 100644 (file)
@@ -53,11 +53,6 @@ static int apci1500_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci1500_driver);
 }
 
-static void apci1500_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci1500_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x80fc) },
        { 0 }
@@ -68,7 +63,7 @@ static struct pci_driver apci1500_pci_driver = {
        .name           = "addi_apci_1500",
        .id_table       = apci1500_pci_table,
        .probe          = apci1500_pci_probe,
-       .remove         = apci1500_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver);
 
index 8fef04b4d1974edc3d462aa80d796771dc22652e..1721ba7f4e5396b4ab62688bb9105721899310e4 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include "../comedidev.h"
+#include "addi_watchdog.h"
 #include "comedi_fc.h"
 
 /*
  * PCI bar 2 I/O Register map - Watchdog (APCI-1516 and APCI-2016)
  */
 #define APCI1516_WDOG_REG              0x00
-#define APCI1516_WDOG_RELOAD_REG       0x04
-#define APCI1516_WDOG_CTRL_REG         0x0c
-#define APCI1516_WDOG_CTRL_ENABLE      (1 << 0)
-#define APCI1516_WDOG_CTRL_SW_TRIG     (1 << 9)
-#define APCI1516_WDOG_STATUS_REG       0x10
-#define APCI1516_WDOG_STATUS_ENABLED   (1 << 0)
-#define APCI1516_WDOG_STATUS_SW_TRIG   (1 << 1)
 
 struct apci1516_boardinfo {
        const char *name;
@@ -86,7 +80,6 @@ static const struct apci1516_boardinfo apci1516_boardtypes[] = {
 
 struct apci1516_private {
        unsigned long wdog_iobase;
-       unsigned int ctrl;
 };
 
 static int apci1516_di_insn_bits(struct comedi_device *dev,
@@ -120,82 +113,6 @@ static int apci1516_do_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
- * The watchdog subdevice is configured with two INSN_CONFIG instructions:
- *
- * Enable the watchdog and set the reload timeout:
- *     data[0] = INSN_CONFIG_ARM
- *     data[1] = timeout reload value
- *
- * Disable the watchdog:
- *     data[0] = INSN_CONFIG_DISARM
- */
-static int apci1516_wdog_insn_config(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
-{
-       struct apci1516_private *devpriv = dev->private;
-       unsigned int reload;
-
-       switch (data[0]) {
-       case INSN_CONFIG_ARM:
-               devpriv->ctrl = APCI1516_WDOG_CTRL_ENABLE;
-               reload = data[1] & s->maxdata;
-               outw(reload, devpriv->wdog_iobase + APCI1516_WDOG_RELOAD_REG);
-
-               /* Time base is 20ms, let the user know the timeout */
-               dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n",
-                       20 * reload + 20);
-               break;
-       case INSN_CONFIG_DISARM:
-               devpriv->ctrl = 0;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       outw(devpriv->ctrl, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
-
-       return insn->n;
-}
-
-static int apci1516_wdog_insn_write(struct comedi_device *dev,
-                                   struct comedi_subdevice *s,
-                                   struct comedi_insn *insn,
-                                   unsigned int *data)
-{
-       struct apci1516_private *devpriv = dev->private;
-       int i;
-
-       if (devpriv->ctrl == 0) {
-               dev_warn(dev->class_dev, "watchdog is disabled\n");
-               return -EINVAL;
-       }
-
-       /* "ping" the watchdog */
-       for (i = 0; i < insn->n; i++) {
-               outw(devpriv->ctrl | APCI1516_WDOG_CTRL_SW_TRIG,
-                       devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
-       }
-
-       return insn->n;
-}
-
-static int apci1516_wdog_insn_read(struct comedi_device *dev,
-                                  struct comedi_subdevice *s,
-                                  struct comedi_insn *insn,
-                                  unsigned int *data)
-{
-       struct apci1516_private *devpriv = dev->private;
-       int i;
-
-       for (i = 0; i < insn->n; i++)
-               data[i] = inw(devpriv->wdog_iobase + APCI1516_WDOG_STATUS_REG);
-
-       return insn->n;
-}
-
 static int apci1516_reset(struct comedi_device *dev)
 {
        const struct apci1516_boardinfo *this_board = comedi_board(dev);
@@ -205,8 +122,8 @@ static int apci1516_reset(struct comedi_device *dev)
                return 0;
 
        outw(0x0, dev->iobase + APCI1516_DO_REG);
-       outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
-       outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_RELOAD_REG);
+
+       addi_watchdog_reset(devpriv->wdog_iobase);
 
        return 0;
 }
@@ -285,13 +202,9 @@ static int apci1516_auto_attach(struct comedi_device *dev,
        /* Initialize the watchdog subdevice */
        s = &dev->subdevices[2];
        if (this_board->has_wdog) {
-               s->type         = COMEDI_SUBD_TIMER;
-               s->subdev_flags = SDF_WRITEABLE;
-               s->n_chan       = 1;
-               s->maxdata      = 0xff;
-               s->insn_write   = apci1516_wdog_insn_write;
-               s->insn_read    = apci1516_wdog_insn_read;
-               s->insn_config  = apci1516_wdog_insn_config;
+               ret = addi_watchdog_init(s, devpriv->wdog_iobase);
+               if (ret)
+                       return ret;
        } else {
                s->type         = COMEDI_SUBD_UNUSED;
        }
@@ -304,10 +217,12 @@ static void apci1516_detach(struct comedi_device *dev)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
 
-       if (dev->iobase) {
+       if (dev->iobase)
                apci1516_reset(dev);
+       if (dev->subdevices)
+               addi_watchdog_cleanup(&dev->subdevices[2]);
+       if (dev->iobase)
                comedi_pci_disable(pcidev);
-       }
 }
 
 static struct comedi_driver apci1516_driver = {
@@ -323,11 +238,6 @@ static int apci1516_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci1516_driver);
 }
 
-static void apci1516_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci1516_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1016) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1516) },
@@ -340,7 +250,7 @@ static struct pci_driver apci1516_pci_driver = {
        .name           = "addi_apci_1516",
        .id_table       = apci1516_pci_table,
        .probe          = apci1516_pci_probe,
-       .remove         = apci1516_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci1516_driver, apci1516_pci_driver);
 
index 513e536f292fc3e8c16fa8c7edc2249a6149920b..3556c61551b9456794c5446753eb5cf05b1982cd 100644 (file)
@@ -50,11 +50,6 @@ static int apci1564_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci1564_driver);
 }
 
-static void apci1564_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci1564_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1006) },
        { 0 }
@@ -65,7 +60,7 @@ static struct pci_driver apci1564_pci_driver = {
        .name           = "addi_apci_1564",
        .id_table       = apci1564_pci_table,
        .probe          = apci1564_pci_probe,
-       .remove         = apci1564_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver);
 
index ab9a96ac8180f4207394e344f0890da0c597f673..8b88503deccae4341a3a56b8ec19904475fcc598 100644 (file)
+/*
+ * addi_apci_16xx.c
+ * Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
+ * Project manager: S. Weber
+ *
+ *     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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * You should also find the complete GPL in the COPYING file accompanying
+ * this source code.
+ */
+
 #include "../comedidev.h"
-#include "comedi_fc.h"
-#include "amcc_s5933.h"
 
-#include "addi-data/addi_common.h"
+/*
+ * PCI device ids supported by this driver
+ */
+#define PCI_DEVICE_ID_APCI1648         0x1009
+#define PCI_DEVICE_ID_APCI1696         0x100a
+
+/*
+ * Register I/O map
+ */
+#define APCI16XX_IN_REG(x)             (((x) * 4) + 0x08)
+#define APCI16XX_OUT_REG(x)            (((x) * 4) + 0x14)
+#define APCI16XX_DIR_REG(x)            (((x) * 4) + 0x20)
 
-#include "addi-data/addi_eeprom.c"
-#include "addi-data/hwdrv_apci16xx.c"
-#include "addi-data/addi_common.c"
+struct apci16xx_boardinfo {
+       const char *name;
+       unsigned short vendor;
+       unsigned short device;
+       int n_chan;
+};
 
-static const struct addi_board apci16xx_boardtypes[] = {
+static const struct apci16xx_boardinfo apci16xx_boardtypes[] = {
        {
-               .pc_DriverName          = "apci1648",
-               .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
-               .i_DeviceId             = 0x1009,
-               .i_IorangeBase0         = 128,
-               .i_PCIEeprom            = ADDIDATA_NO_EEPROM,
-               .i_NbrTTLChannel        = 48,
-               .reset                  = i_APCI16XX_Reset,
-               .ttl_config             = i_APCI16XX_InsnConfigInitTTLIO,
-               .ttl_bits               = i_APCI16XX_InsnBitsReadTTLIO,
-               .ttl_read               = i_APCI16XX_InsnReadTTLIOAllPortValue,
-               .ttl_write              = i_APCI16XX_InsnBitsWriteTTLIO,
+               .name           = "apci1648",
+               .vendor         = PCI_VENDOR_ID_ADDIDATA,
+               .device         = PCI_DEVICE_ID_APCI1648,
+               .n_chan         = 48,           /* 2 subdevices */
        }, {
-               .pc_DriverName          = "apci1696",
-               .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
-               .i_DeviceId             = 0x100A,
-               .i_IorangeBase0         = 128,
-               .i_PCIEeprom            = ADDIDATA_NO_EEPROM,
-               .i_NbrTTLChannel        = 96,
-               .reset                  = i_APCI16XX_Reset,
-               .ttl_config             = i_APCI16XX_InsnConfigInitTTLIO,
-               .ttl_bits               = i_APCI16XX_InsnBitsReadTTLIO,
-               .ttl_read               = i_APCI16XX_InsnReadTTLIOAllPortValue,
-               .ttl_write              = i_APCI16XX_InsnBitsWriteTTLIO,
+               .name           = "apci1696",
+               .vendor         = PCI_VENDOR_ID_ADDIDATA,
+               .device         = PCI_DEVICE_ID_APCI1696,
+               .n_chan         = 96,           /* 3 subdevices */
        },
 };
 
+static int apci16xx_insn_config(struct comedi_device *dev,
+                               struct comedi_subdevice *s,
+                               struct comedi_insn *insn,
+                               unsigned int *data)
+{
+       unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec);
+       unsigned int bits;
+
+       /*
+        * Each 8-bit "port" is configurable as either input or
+        * output. Changing the configuration of any channel in
+        * a port changes the entire port.
+        */
+       if (chan_mask & 0x000000ff)
+               bits = 0x000000ff;
+       else if (chan_mask & 0x0000ff00)
+               bits = 0x0000ff00;
+       else if (chan_mask & 0x00ff0000)
+               bits = 0x00ff0000;
+       else
+               bits = 0xff000000;
+
+       switch (data[0]) {
+       case INSN_CONFIG_DIO_INPUT:
+               s->io_bits &= ~bits;
+               break;
+       case INSN_CONFIG_DIO_OUTPUT:
+               s->io_bits |= bits;
+               break;
+       case INSN_CONFIG_DIO_QUERY:
+               data[1] = (s->io_bits & bits) ? COMEDI_INPUT : COMEDI_OUTPUT;
+               return insn->n;
+       default:
+               return -EINVAL;
+       }
+
+       outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(s->index));
+
+       return insn->n;
+}
+
+static int apci16xx_dio_insn_bits(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
+{
+       unsigned int mask = data[0];
+       unsigned int bits = data[1];
+
+       /* Only update the channels configured as outputs */
+       mask &= s->io_bits;
+       if (mask) {
+               s->state &= ~mask;
+               s->state |= (bits & mask);
+
+               outl(s->state, dev->iobase + APCI16XX_OUT_REG(s->index));
+       }
+
+       data[1] = inl(dev->iobase + APCI16XX_IN_REG(s->index));
+
+       return insn->n;
+}
+
+static const void *apci16xx_find_boardinfo(struct comedi_device *dev,
+                                          struct pci_dev *pcidev)
+{
+       const struct apci16xx_boardinfo *board;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(apci16xx_boardtypes); i++) {
+               board = &apci16xx_boardtypes[i];
+               if (board->vendor == pcidev->vendor &&
+                   board->device == pcidev->device)
+                       return board;
+       }
+       return NULL;
+}
+
+static int apci16xx_auto_attach(struct comedi_device *dev,
+                               unsigned long context_unused)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       const struct apci16xx_boardinfo *board;
+       struct comedi_subdevice *s;
+       unsigned int n_subdevs;
+       unsigned int last;
+       int i;
+       int ret;
+
+       board = apci16xx_find_boardinfo(dev, pcidev);
+       if (!board)
+               return -ENODEV;
+       dev->board_ptr = board;
+       dev->board_name = board->name;
+
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+
+       dev->iobase = pci_resource_start(pcidev, 0);
+
+       /*
+        * Work out the nubmer of subdevices needed to support all the
+        * digital i/o channels on the board. Each subdevice supports
+        * up to 32 channels.
+        */
+       n_subdevs = board->n_chan / 32;
+       if ((n_subdevs * 32) < board->n_chan) {
+               last = board->n_chan - (n_subdevs * 32);
+               n_subdevs++;
+       } else {
+               last = 0;
+       }
+
+       ret = comedi_alloc_subdevices(dev, n_subdevs);
+       if (ret)
+               return ret;
+
+       /* Initialize the TTL digital i/o subdevices */
+       for (i = 0; i < n_subdevs; i++) {
+               s = &dev->subdevices[i];
+               s->type         = COMEDI_SUBD_DIO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_READABLE;
+               s->n_chan       = ((i * 32) < board->n_chan) ? 32 : last;
+               s->maxdata      = 1;
+               s->range_table  = &range_digital;
+               s->insn_config  = apci16xx_insn_config;
+               s->insn_bits    = apci16xx_dio_insn_bits;
+
+               /* Default all channels to inputs */
+               s->io_bits      = 0;
+               outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(i));
+       }
+
+       return 0;
+}
+
+static void apci16xx_detach(struct comedi_device *dev)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+       }
+}
+
 static struct comedi_driver apci16xx_driver = {
        .driver_name    = "addi_apci_16xx",
        .module         = THIS_MODULE,
-       .auto_attach    = addi_auto_attach,
-       .detach         = i_ADDI_Detach,
+       .auto_attach    = apci16xx_auto_attach,
+       .detach         = apci16xx_detach,
        .num_names      = ARRAY_SIZE(apci16xx_boardtypes),
-       .board_name     = &apci16xx_boardtypes[0].pc_DriverName,
-       .offset         = sizeof(struct addi_board),
+       .board_name     = &apci16xx_boardtypes[0].name,
+       .offset         = sizeof(struct apci16xx_boardinfo),
 };
 
 static int apci16xx_pci_probe(struct pci_dev *dev,
@@ -52,14 +228,9 @@ static int apci16xx_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci16xx_driver);
 }
 
-static void apci16xx_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci16xx_pci_table) = {
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1009) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x100a) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1648) },
+       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, PCI_DEVICE_ID_APCI1696) },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, apci16xx_pci_table);
@@ -68,10 +239,10 @@ static struct pci_driver apci16xx_pci_driver = {
        .name           = "addi_apci_16xx",
        .id_table       = apci16xx_pci_table,
        .probe          = apci16xx_pci_probe,
-       .remove         = apci16xx_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci16xx_driver, apci16xx_pci_driver);
 
+MODULE_DESCRIPTION("ADDI-DATA APCI-1648/1696, TTL I/O boards");
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");
index 152e7ef9b17b6fd04500a9099d731eb7bd610d90..7eb03b1839157cf235b3bced5be758679cebf646 100644 (file)
@@ -128,11 +128,6 @@ static int apci1710_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci1710_driver);
 }
 
-static void apci1710_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci1710_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, APCI1710_BOARD_DEVICE_ID) },
        { 0 }
@@ -143,7 +138,7 @@ static struct pci_driver apci1710_pci_driver = {
        .name           = "addi_apci_1710",
        .id_table       = apci1710_pci_table,
        .probe          = apci1710_pci_probe,
-       .remove         = apci1710_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci1710_driver, apci1710_pci_driver);
 
index 8f8d3e95fc789fc281911c6969276b6681bc1966..5ad9db9b84b206dafcc426f067d7a6554cb798b5 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include "../comedidev.h"
+#include "addi_watchdog.h"
 #include "comedi_fc.h"
 
 /*
 #define APCI2032_STATUS_REG            0x0c
 #define APCI2032_STATUS_IRQ            (1 << 0)
 #define APCI2032_WDOG_REG              0x10
-#define APCI2032_WDOG_RELOAD_REG       0x14
-#define APCI2032_WDOG_TIMEBASE         0x18
-#define APCI2032_WDOG_CTRL_REG         0x1c
-#define APCI2032_WDOG_CTRL_ENABLE      (1 << 0)
-#define APCI2032_WDOG_CTRL_SW_TRIG     (1 << 9)
-#define APCI2032_WDOG_STATUS_REG       0x20
-#define APCI2032_WDOG_STATUS_ENABLED   (1 << 0)
-#define APCI2032_WDOG_STATUS_SW_TRIG   (1 << 1)
-
-struct apci2032_private {
-       unsigned int wdog_ctrl;
+
+struct apci2032_int_private {
+       spinlock_t spinlock;
+       unsigned int stop_count;
+       bool active;
+       unsigned char enabled_isns;
 };
 
 static int apci2032_do_insn_bits(struct comedi_device *dev,
@@ -79,88 +75,47 @@ static int apci2032_do_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
- * The watchdog subdevice is configured with two INSN_CONFIG instructions:
- *
- * Enable the watchdog and set the reload timeout:
- *     data[0] = INSN_CONFIG_ARM
- *     data[1] = timeout reload value
- *
- * Disable the watchdog:
- *     data[0] = INSN_CONFIG_DISARM
- */
-static int apci2032_wdog_insn_config(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
+static int apci2032_int_insn_bits(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
 {
-       struct apci2032_private *devpriv = dev->private;
-       unsigned int reload;
-
-       switch (data[0]) {
-       case INSN_CONFIG_ARM:
-               devpriv->wdog_ctrl = APCI2032_WDOG_CTRL_ENABLE;
-               reload = data[1] & s->maxdata;
-               outw(reload, dev->iobase + APCI2032_WDOG_RELOAD_REG);
-
-               /* Time base is 20ms, let the user know the timeout */
-               dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n",
-                       20 * reload + 20);
-               break;
-       case INSN_CONFIG_DISARM:
-               devpriv->wdog_ctrl = 0;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       outw(devpriv->wdog_ctrl, dev->iobase + APCI2032_WDOG_CTRL_REG);
-
+       data[1] = inl(dev->iobase + APCI2032_INT_STATUS_REG) & 3;
        return insn->n;
 }
 
-static int apci2032_wdog_insn_write(struct comedi_device *dev,
-                                   struct comedi_subdevice *s,
-                                   struct comedi_insn *insn,
-                                   unsigned int *data)
+static void apci2032_int_stop(struct comedi_device *dev,
+                             struct comedi_subdevice *s)
 {
-       struct apci2032_private *devpriv = dev->private;
-       int i;
-
-       if (devpriv->wdog_ctrl == 0) {
-               dev_warn(dev->class_dev, "watchdog is disabled\n");
-               return -EINVAL;
-       }
-
-       /* "ping" the watchdog */
-       for (i = 0; i < insn->n; i++) {
-               outw(devpriv->wdog_ctrl | APCI2032_WDOG_CTRL_SW_TRIG,
-                       dev->iobase + APCI2032_WDOG_CTRL_REG);
-       }
+       struct apci2032_int_private *subpriv = s->private;
 
-       return insn->n;
+       subpriv->active = false;
+       subpriv->enabled_isns = 0;
+       outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG);
 }
 
-static int apci2032_wdog_insn_read(struct comedi_device *dev,
-                                  struct comedi_subdevice *s,
-                                  struct comedi_insn *insn,
-                                  unsigned int *data)
+static bool apci2032_int_start(struct comedi_device *dev,
+                              struct comedi_subdevice *s,
+                              unsigned char enabled_isns)
 {
-       int i;
-
-       for (i = 0; i < insn->n; i++)
-               data[i] = inl(dev->iobase + APCI2032_WDOG_STATUS_REG);
-
-       return insn->n;
-}
+       struct apci2032_int_private *subpriv = s->private;
+       struct comedi_cmd *cmd = &s->async->cmd;
+       bool do_event;
+
+       subpriv->enabled_isns = enabled_isns;
+       subpriv->stop_count = cmd->stop_arg;
+       if (cmd->stop_src == TRIG_COUNT && subpriv->stop_count == 0) {
+               /* An empty acquisition! */
+               s->async->events |= COMEDI_CB_EOA;
+               subpriv->active = false;
+               do_event = true;
+       } else {
+               subpriv->active = true;
+               outl(enabled_isns, dev->iobase + APCI2032_INT_CTRL_REG);
+               do_event = false;
+       }
 
-static int apci2032_int_insn_bits(struct comedi_device *dev,
-                                 struct comedi_subdevice *s,
-                                 struct comedi_insn *insn,
-                                 unsigned int *data)
-{
-       data[1] = s->state;
-       return insn->n;
+       return do_event;
 }
 
 static int apci2032_int_cmdtest(struct comedi_device *dev,
@@ -172,15 +127,17 @@ static int apci2032_int_cmdtest(struct comedi_device *dev,
        /* Step 1 : check if triggers are trivially valid */
 
        err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
        err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
+       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+
        /* Step 2b : and mutually compatible */
 
        if (err)
@@ -189,18 +146,11 @@ static int apci2032_int_cmdtest(struct comedi_device *dev,
        /* Step 3: check if arguments are trivially valid */
 
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-
-       /*
-        * 0 == no trigger
-        * 1 == trigger on VCC interrupt
-        * 2 == trigger on CC interrupt
-        * 3 == trigger on either VCC or CC interrupt
-        */
-       err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 3);
-
+       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       if (cmd->stop_src == TRIG_NONE)
+               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -217,8 +167,22 @@ static int apci2032_int_cmd(struct comedi_device *dev,
                            struct comedi_subdevice *s)
 {
        struct comedi_cmd *cmd = &s->async->cmd;
+       struct apci2032_int_private *subpriv = s->private;
+       unsigned char enabled_isns;
+       unsigned int n;
+       unsigned long flags;
+       bool do_event;
+
+       enabled_isns = 0;
+       for (n = 0; n < cmd->chanlist_len; n++)
+               enabled_isns |= 1 << CR_CHAN(cmd->chanlist[n]);
 
-       outl(cmd->scan_begin_arg, dev->iobase + APCI2032_INT_CTRL_REG);
+       spin_lock_irqsave(&subpriv->spinlock, flags);
+       do_event = apci2032_int_start(dev, s, enabled_isns);
+       spin_unlock_irqrestore(&subpriv->spinlock, flags);
+
+       if (do_event)
+               comedi_event(dev, s);
 
        return 0;
 }
@@ -226,7 +190,13 @@ static int apci2032_int_cmd(struct comedi_device *dev,
 static int apci2032_int_cancel(struct comedi_device *dev,
                               struct comedi_subdevice *s)
 {
-       outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG);
+       struct apci2032_int_private *subpriv = s->private;
+       unsigned long flags;
+
+       spin_lock_irqsave(&subpriv->spinlock, flags);
+       if (subpriv->active)
+               apci2032_int_stop(dev, s);
+       spin_unlock_irqrestore(&subpriv->spinlock, flags);
 
        return 0;
 }
@@ -235,19 +205,64 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
 {
        struct comedi_device *dev = d;
        struct comedi_subdevice *s = dev->read_subdev;
+       struct apci2032_int_private *subpriv;
        unsigned int val;
+       bool do_event = false;
+
+       if (!dev->attached)
+               return IRQ_NONE;
 
        /* Check if VCC OR CC interrupt has occurred */
        val = inl(dev->iobase + APCI2032_STATUS_REG) & APCI2032_STATUS_IRQ;
        if (!val)
                return IRQ_NONE;
 
-       s->state = inl(dev->iobase + APCI2032_INT_STATUS_REG);
-       outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG);
+       subpriv = s->private;
+       spin_lock(&subpriv->spinlock);
 
-       comedi_buf_put(s->async, s->state);
-       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-       comedi_event(dev, s);
+       val = inl(dev->iobase + APCI2032_INT_STATUS_REG) & 3;
+       /* Disable triggered interrupt sources. */
+       outl(~val & 3, dev->iobase + APCI2032_INT_CTRL_REG);
+       /*
+        * Note: We don't reenable the triggered interrupt sources because they
+        * are level-sensitive, hardware error status interrupt sources and
+        * they'd keep triggering interrupts repeatedly.
+        */
+
+       if (subpriv->active && (val & subpriv->enabled_isns) != 0) {
+               unsigned short bits;
+               unsigned int n, len;
+               unsigned int *chanlist;
+
+               /* Bits in scan data correspond to indices in channel list. */
+               bits = 0;
+               len = s->async->cmd.chanlist_len;
+               chanlist = &s->async->cmd.chanlist[0];
+               for (n = 0; n < len; n++)
+                       if ((val & (1U << CR_CHAN(chanlist[n]))) != 0)
+                               bits |= 1U << n;
+
+               if (comedi_buf_put(s->async, bits)) {
+                       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+                       if (s->async->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);
 
        return IRQ_HANDLED;
 }
@@ -256,8 +271,8 @@ static int apci2032_reset(struct comedi_device *dev)
 {
        outl(0x0, dev->iobase + APCI2032_DO_REG);
        outl(0x0, dev->iobase + APCI2032_INT_CTRL_REG);
-       outl(0x0, dev->iobase + APCI2032_WDOG_CTRL_REG);
-       outl(0x0, dev->iobase + APCI2032_WDOG_RELOAD_REG);
+
+       addi_watchdog_reset(dev->iobase + APCI2032_WDOG_REG);
 
        return 0;
 }
@@ -266,21 +281,16 @@ static int apci2032_auto_attach(struct comedi_device *dev,
                                unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       struct apci2032_private *devpriv;
        struct comedi_subdevice *s;
        int ret;
 
        dev->board_name = dev->driver->driver_name;
 
-       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
-       if (!devpriv)
-               return -ENOMEM;
-       dev->private = devpriv;
-
        ret = comedi_pci_enable(pcidev, dev->board_name);
        if (ret)
                return ret;
        dev->iobase = pci_resource_start(pcidev, 1);
+       apci2032_reset(dev);
 
        if (pcidev->irq > 0) {
                ret = request_irq(pcidev->irq, apci2032_interrupt,
@@ -304,32 +314,34 @@ static int apci2032_auto_attach(struct comedi_device *dev,
 
        /* Initialize the watchdog subdevice */
        s = &dev->subdevices[1];
-       s->type         = COMEDI_SUBD_TIMER;
-       s->subdev_flags = SDF_WRITEABLE;
-       s->n_chan       = 1;
-       s->maxdata      = 0xff;
-       s->insn_write   = apci2032_wdog_insn_write;
-       s->insn_read    = apci2032_wdog_insn_read;
-       s->insn_config  = apci2032_wdog_insn_config;
+       ret = addi_watchdog_init(s, dev->iobase + APCI2032_WDOG_REG);
+       if (ret)
+               return ret;
 
        /* Initialize the interrupt subdevice */
        s = &dev->subdevices[2];
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 2;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci2032_int_insn_bits;
        if (dev->irq) {
+               struct apci2032_int_private *subpriv;
+
                dev->read_subdev = s;
-               s->type         = COMEDI_SUBD_DI | SDF_CMD_READ;
-               s->subdev_flags = SDF_READABLE;
-               s->n_chan       = 1;
-               s->maxdata      = 1;
-               s->range_table  = &range_digital;
-               s->insn_bits    = apci2032_int_insn_bits;
+               subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
+               if (!subpriv)
+                       return -ENOMEM;
+               spin_lock_init(&subpriv->spinlock);
+               s->private      = subpriv;
+               s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+               s->len_chanlist = 2;
                s->do_cmdtest   = apci2032_int_cmdtest;
                s->do_cmd       = apci2032_int_cmd;
                s->cancel       = apci2032_int_cancel;
-       } else {
-               s->type         = COMEDI_SUBD_UNUSED;
        }
 
-       apci2032_reset(dev);
        return 0;
 }
 
@@ -341,6 +353,10 @@ static void apci2032_detach(struct comedi_device *dev)
                apci2032_reset(dev);
        if (dev->irq)
                free_irq(dev->irq, dev);
+       if (dev->read_subdev)
+               kfree(dev->read_subdev->private);
+       if (dev->subdevices)
+               addi_watchdog_cleanup(&dev->subdevices[1]);
        if (pcidev) {
                if (dev->iobase)
                        comedi_pci_disable(pcidev);
@@ -360,11 +376,6 @@ static int apci2032_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci2032_driver);
 }
 
-static void apci2032_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci2032_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1004) },
        { 0 }
@@ -375,7 +386,7 @@ static struct pci_driver apci2032_pci_driver = {
        .name           = "addi_apci_2032",
        .id_table       = apci2032_pci_table,
        .probe          = apci2032_pci_probe,
-       .remove         = apci2032_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver);
 
index 7c2c5db01218a71640a8314d8dfe16b57d89481d..a9891b4e60e61edfa07740c2b4f4dbdac20607a7 100644 (file)
+/*
+ * addi_apci_2200.c
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * You should also find the complete GPL in the COPYING file accompanying
+ * this source code.
+ */
+
 #include "../comedidev.h"
-#include "comedi_fc.h"
-#include "amcc_s5933.h"
-
-#include "addi-data/addi_common.h"
-
-#include "addi-data/addi_eeprom.c"
-#include "addi-data/hwdrv_apci2200.c"
-#include "addi-data/addi_common.c"
-
-static const struct addi_board apci2200_boardtypes[] = {
-       {
-               .pc_DriverName          = "apci2200",
-               .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
-               .i_DeviceId             = 0x1005,
-               .i_IorangeBase0         = 4,
-               .i_IorangeBase1         = APCI2200_ADDRESS_RANGE,
-               .i_PCIEeprom            = ADDIDATA_EEPROM,
-               .pc_EepromChip          = ADDIDATA_93C76,
-               .i_NbrDiChannel         = 8,
-               .i_NbrDoChannel         = 16,
-               .i_Timer                = 1,
-               .reset                  = i_APCI2200_Reset,
-               .di_bits                = apci2200_di_insn_bits,
-               .do_bits                = apci2200_do_insn_bits,
-               .timer_config           = i_APCI2200_ConfigWatchdog,
-               .timer_write            = i_APCI2200_StartStopWriteWatchdog,
-               .timer_read             = i_APCI2200_ReadWatchdog,
-       },
-};
+#include "addi_watchdog.h"
+
+/*
+ * I/O Register Map
+ */
+#define APCI2200_DI_REG                        0x00
+#define APCI2200_DO_REG                        0x04
+#define APCI2200_WDOG_REG              0x08
+
+static int apci2200_di_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       data[1] = inw(dev->iobase + APCI2200_DI_REG);
+
+       return insn->n;
+}
+
+static int apci2200_do_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       unsigned int mask = data[0];
+       unsigned int bits = data[1];
+
+       s->state = inw(dev->iobase + APCI2200_DO_REG);
+       if (mask) {
+               s->state &= ~mask;
+               s->state |= (bits & mask);
+
+               outw(s->state, dev->iobase + APCI2200_DO_REG);
+       }
+
+       data[1] = s->state;
+
+       return insn->n;
+}
+
+static int apci2200_reset(struct comedi_device *dev)
+{
+       outw(0x0, dev->iobase + APCI2200_DO_REG);
+
+       addi_watchdog_reset(dev->iobase + APCI2200_WDOG_REG);
+
+       return 0;
+}
+
+static int apci2200_auto_attach(struct comedi_device *dev,
+                               unsigned long context_unused)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       struct comedi_subdevice *s;
+       int ret;
+
+       dev->board_name = dev->driver->driver_name;
+
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+
+       dev->iobase = pci_resource_start(pcidev, 1);
+
+       ret = comedi_alloc_subdevices(dev, 3);
+       if (ret)
+               return ret;
+
+       /* Initialize the digital input subdevice */
+       s = &dev->subdevices[0];
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 8;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci2200_di_insn_bits;
+
+       /* Initialize the digital output subdevice */
+       s = &dev->subdevices[1];
+       s->type         = COMEDI_SUBD_DO;
+       s->subdev_flags = SDF_WRITEABLE;
+       s->n_chan       = 16;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci2200_do_insn_bits;
+
+       /* Initialize the watchdog subdevice */
+       s = &dev->subdevices[2];
+       ret = addi_watchdog_init(s, dev->iobase + APCI2200_WDOG_REG);
+       if (ret)
+               return ret;
+
+       apci2200_reset(dev);
+       return 0;
+}
+
+static void apci2200_detach(struct comedi_device *dev)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (dev->iobase)
+               apci2200_reset(dev);
+       if (dev->subdevices)
+               addi_watchdog_cleanup(&dev->subdevices[2]);
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+       }
+}
 
 static struct comedi_driver apci2200_driver = {
        .driver_name    = "addi_apci_2200",
        .module         = THIS_MODULE,
-       .auto_attach    = addi_auto_attach,
-       .detach         = i_ADDI_Detach,
-       .num_names      = ARRAY_SIZE(apci2200_boardtypes),
-       .board_name     = &apci2200_boardtypes[0].pc_DriverName,
-       .offset         = sizeof(struct addi_board),
+       .auto_attach    = apci2200_auto_attach,
+       .detach         = apci2200_detach,
 };
 
 static int apci2200_pci_probe(struct pci_dev *dev,
@@ -45,11 +153,6 @@ static int apci2200_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci2200_driver);
 }
 
-static void apci2200_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci2200_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x1005) },
        { 0 }
@@ -60,10 +163,10 @@ static struct pci_driver apci2200_pci_driver = {
        .name           = "addi_apci_2200",
        .id_table       = apci2200_pci_table,
        .probe          = apci2200_pci_probe,
-       .remove         = apci2200_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci2200_driver, apci2200_pci_driver);
 
+MODULE_DESCRIPTION("ADDI-DATA APCI-2200 Relay board, optically isolated");
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");
index fec2962affc7b938cdc0d9b8310db642f647d2dc..8cad18f7fc4913c62adc5d75ece74c3c0b16aafe 100644 (file)
@@ -251,11 +251,6 @@ static int apci3120_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci3120_driver);
 }
 
-static void apci3120_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci3120_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x818d) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA_OLD, 0x828d) },
@@ -267,7 +262,7 @@ static struct pci_driver apci3120_pci_driver = {
        .name           = "addi_apci_3120",
        .id_table       = apci3120_pci_table,
        .probe          = apci3120_pci_probe,
-       .remove         = apci3120_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver);
 
index 9085b774b48dc15015f964faabe5e8858889b346..c11bf4bda4262cd9c767c46c6cb333e281eed1c4 100644 (file)
@@ -106,15 +106,10 @@ static int apci3200_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci3200_driver);
 }
 
-static void apci3200_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver apci3200_pci_driver = {
        .name           = "addi_apci_3200",
        .id_table       = apci3200_pci_table,
        .probe          = apci3200_pci_probe,
-       .remove         = apci3200_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci3200_driver, apci3200_pci_driver);
index ed297deb8634bc6fbd128cf831b7c8f5a391a6d3..8920b96ab212f1a44993f1ad354a07fd9ac4831d 100644 (file)
+/*
+ * addi_apci_3501.c
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * You should also find the complete GPL in the COPYING file accompanying
+ * this source code.
+ */
+
 #include "../comedidev.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
-#include "addi-data/addi_common.h"
+/*
+ * PCI bar 1 register I/O map
+ */
+#define APCI3501_AO_CTRL_STATUS_REG            0x00
+#define APCI3501_AO_CTRL_BIPOLAR               (1 << 0)
+#define APCI3501_AO_STATUS_READY               (1 << 8)
+#define APCI3501_AO_DATA_REG                   0x04
+#define APCI3501_AO_DATA_CHAN(x)               ((x) << 0)
+#define APCI3501_AO_DATA_VAL(x)                        ((x) << 8)
+#define APCI3501_AO_DATA_BIPOLAR               (1 << 31)
+#define APCI3501_AO_TRIG_SCS_REG               0x08
+#define APCI3501_TIMER_SYNC_REG                        0x20
+#define APCI3501_TIMER_RELOAD_REG              0x24
+#define APCI3501_TIMER_TIMEBASE_REG            0x28
+#define APCI3501_TIMER_CTRL_REG                        0x2c
+#define APCI3501_TIMER_STATUS_REG              0x30
+#define APCI3501_TIMER_IRQ_REG                 0x34
+#define APCI3501_TIMER_WARN_RELOAD_REG         0x38
+#define APCI3501_TIMER_WARN_TIMEBASE_REG       0x3c
+#define APCI3501_DO_REG                                0x40
+#define APCI3501_DI_REG                                0x50
 
-#include "addi-data/addi_eeprom.c"
-#include "addi-data/hwdrv_apci3501.c"
-#include "addi-data/addi_common.c"
-
-static const struct addi_board apci3501_boardtypes[] = {
-       {
-               .pc_DriverName          = "apci3501",
-               .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
-               .i_DeviceId             = 0x3001,
-               .i_IorangeBase0         = 64,
-               .i_IorangeBase1         = APCI3501_ADDRESS_RANGE,
-               .i_PCIEeprom            = ADDIDATA_EEPROM,
-               .pc_EepromChip          = ADDIDATA_S5933,
-               .i_AoMaxdata            = 16383,
-               .pr_AoRangelist         = &range_apci3501_ao,
-               .i_NbrDiChannel         = 2,
-               .i_NbrDoChannel         = 2,
-               .i_DoMaxdata            = 0x3,
-               .i_Timer                = 1,
-               .interrupt              = v_APCI3501_Interrupt,
-               .reset                  = i_APCI3501_Reset,
-               .ao_config              = i_APCI3501_ConfigAnalogOutput,
-               .ao_write               = i_APCI3501_WriteAnalogOutput,
-               .di_bits                = apci3501_di_insn_bits,
-               .do_bits                = apci3501_do_insn_bits,
-               .timer_config           = i_APCI3501_ConfigTimerCounterWatchdog,
-               .timer_write            = i_APCI3501_StartStopWriteTimerCounterWatchdog,
-               .timer_read             = i_APCI3501_ReadTimerCounterWatchdog,
-       },
+/*
+ * AMCC S5933 NVRAM
+ */
+#define NVRAM_USER_DATA_START  0x100
+
+#define NVCMD_BEGIN_READ       (0x7 << 5)
+#define NVCMD_LOAD_LOW         (0x4 << 5)
+#define NVCMD_LOAD_HIGH                (0x5 << 5)
+
+/*
+ * Function types stored in the eeprom
+ */
+#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
+
+struct apci3501_private {
+       int i_IobaseAmcc;
+       struct task_struct *tsk_Current;
+       unsigned char b_TimerSelectMode;
 };
 
-static DEFINE_PCI_DEVICE_TABLE(apci3501_pci_table) = {
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3001) },
-       { 0 }
+static struct comedi_lrange apci3501_ao_range = {
+       2, {
+               BIP_RANGE(10),
+               UNI_RANGE(10)
+       }
 };
-MODULE_DEVICE_TABLE(pci, apci3501_pci_table);
+
+static int apci3501_wait_for_dac(struct comedi_device *dev)
+{
+       unsigned int status;
+
+       do {
+               status = inl(dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
+       } while (!(status & APCI3501_AO_STATUS_READY));
+
+       return 0;
+}
+
+static int apci3501_ao_insn_write(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
+{
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int range = CR_RANGE(insn->chanspec);
+       unsigned int val = 0;
+       int i;
+       int ret;
+
+       /*
+        * All analog output channels have the same output range.
+        *      14-bit bipolar: 0-10V
+        *      13-bit unipolar: +/-10V
+        * Changing the range of one channel changes all of them!
+        */
+       if (range) {
+               outl(0, dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
+       } else {
+               val |= APCI3501_AO_DATA_BIPOLAR;
+               outl(APCI3501_AO_CTRL_BIPOLAR,
+                    dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
+       }
+
+       val |= APCI3501_AO_DATA_CHAN(chan);
+
+       for (i = 0; i < insn->n; i++) {
+               if (range == 1) {
+                       if (data[i] > 0x1fff) {
+                               dev_err(dev->class_dev,
+                                       "Unipolar resolution is only 13-bits\n");
+                               return -EINVAL;
+                       }
+               }
+
+               ret = apci3501_wait_for_dac(dev);
+               if (ret)
+                       return ret;
+
+               outl(val | APCI3501_AO_DATA_VAL(data[i]),
+                    dev->iobase + APCI3501_AO_DATA_REG);
+       }
+
+       return insn->n;
+}
+
+#include "addi-data/hwdrv_apci3501.c"
+
+static int apci3501_di_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       data[1] = inl(dev->iobase + APCI3501_DI_REG) & 0x3;
+
+       return insn->n;
+}
+
+static int apci3501_do_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       unsigned int mask = data[0];
+       unsigned int bits = data[1];
+
+       s->state = inl(dev->iobase + APCI3501_DO_REG);
+       if (mask) {
+               s->state &= ~mask;
+               s->state |= (bits & mask);
+
+               outl(s->state, dev->iobase + APCI3501_DO_REG);
+       }
+
+       data[1] = s->state;
+
+       return insn->n;
+}
+
+static void apci3501_eeprom_wait(unsigned long iobase)
+{
+       unsigned char val;
+
+       do {
+               val = inb(iobase + AMCC_OP_REG_MCSR_NVCMD);
+       } while (val & 0x80);
+}
+
+static unsigned short apci3501_eeprom_readw(unsigned long iobase,
+                                           unsigned short addr)
+{
+       unsigned short val = 0;
+       unsigned char tmp;
+       unsigned char i;
+
+       /* Add the offset to the start of the user data */
+       addr += NVRAM_USER_DATA_START;
+
+       for (i = 0; i < 2; i++) {
+               /* Load the low 8 bit address */
+               outb(NVCMD_LOAD_LOW, iobase + AMCC_OP_REG_MCSR_NVCMD);
+               apci3501_eeprom_wait(iobase);
+               outb((addr + i) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
+               apci3501_eeprom_wait(iobase);
+
+               /* Load the high 8 bit address */
+               outb(NVCMD_LOAD_HIGH, iobase + AMCC_OP_REG_MCSR_NVCMD);
+               apci3501_eeprom_wait(iobase);
+               outb(((addr + i) >> 8) & 0xff,
+                       iobase + AMCC_OP_REG_MCSR_NVDATA);
+               apci3501_eeprom_wait(iobase);
+
+               /* Read the eeprom data byte */
+               outb(NVCMD_BEGIN_READ, iobase + AMCC_OP_REG_MCSR_NVCMD);
+               apci3501_eeprom_wait(iobase);
+               tmp = inb(iobase + AMCC_OP_REG_MCSR_NVDATA);
+               apci3501_eeprom_wait(iobase);
+
+               if (i == 0)
+                       val |= tmp;
+               else
+                       val |= (tmp << 8);
+       }
+
+       return val;
+}
+
+static int apci3501_eeprom_get_ao_n_chan(struct comedi_device *dev)
+{
+       struct apci3501_private *devpriv = dev->private;
+       unsigned long iobase = devpriv->i_IobaseAmcc;
+       unsigned char nfuncs;
+       int i;
+
+       nfuncs = apci3501_eeprom_readw(iobase, 10) & 0xff;
+
+       /* Read functionality details */
+       for (i = 0; i < nfuncs; i++) {
+               unsigned short offset = i * 4;
+               unsigned short addr;
+               unsigned char func;
+               unsigned short val;
+
+               func = apci3501_eeprom_readw(iobase, 12 + offset) & 0x3f;
+               addr = apci3501_eeprom_readw(iobase, 14 + offset);
+
+               if (func == EEPROM_ANALOGOUTPUT) {
+                       val = apci3501_eeprom_readw(iobase, addr + 10);
+                       return (val >> 4) & 0x3ff;
+               }
+       }
+       return 0;
+}
+
+static int apci3501_eeprom_insn_read(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
+{
+       struct apci3501_private *devpriv = dev->private;
+       unsigned short addr = CR_CHAN(insn->chanspec);
+
+       data[0] = apci3501_eeprom_readw(devpriv->i_IobaseAmcc, 2 * addr);
+
+       return insn->n;
+}
+
+static irqreturn_t apci3501_interrupt(int irq, void *d)
+{
+       struct comedi_device *dev = d;
+       struct apci3501_private *devpriv = dev->private;
+       unsigned int ui_Timer_AOWatchdog;
+       unsigned long ul_Command1;
+       int i_temp;
+
+       /*  Disable Interrupt */
+       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+       ul_Command1 = (ul_Command1 & 0xFFFFF9FDul);
+       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+
+       ui_Timer_AOWatchdog = inl(dev->iobase + APCI3501_TIMER_IRQ_REG) & 0x1;
+       if ((!ui_Timer_AOWatchdog)) {
+               comedi_error(dev, "IRQ from unknown source");
+               return IRQ_NONE;
+       }
+
+       /* Enable Interrupt Send a signal to from kernel to user space */
+       send_sig(SIGIO, devpriv->tsk_Current, 0);
+       ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+       ul_Command1 = ((ul_Command1 & 0xFFFFF9FDul) | 1 << 1);
+       outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
+       i_temp = inl(dev->iobase + APCI3501_TIMER_STATUS_REG) & 0x1;
+
+       return IRQ_HANDLED;
+}
+
+static int apci3501_reset(struct comedi_device *dev)
+{
+       unsigned int val;
+       int chan;
+       int ret;
+
+       /* Reset all digital outputs to "0" */
+       outl(0x0, dev->iobase + APCI3501_DO_REG);
+
+       /* Default all analog outputs to 0V (bipolar) */
+       outl(APCI3501_AO_CTRL_BIPOLAR,
+            dev->iobase + APCI3501_AO_CTRL_STATUS_REG);
+       val = APCI3501_AO_DATA_BIPOLAR | APCI3501_AO_DATA_VAL(0);
+
+       /* Set all analog output channels */
+       for (chan = 0; chan < 8; chan++) {
+               ret = apci3501_wait_for_dac(dev);
+               if (ret) {
+                       dev_warn(dev->class_dev,
+                                "%s: DAC not-ready for channel %i\n",
+                                __func__, chan);
+               } else {
+                       outl(val | APCI3501_AO_DATA_CHAN(chan),
+                            dev->iobase + APCI3501_AO_DATA_REG);
+               }
+       }
+
+       return 0;
+}
+
+static int apci3501_auto_attach(struct comedi_device *dev,
+                               unsigned long context_unused)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+       struct apci3501_private *devpriv;
+       struct comedi_subdevice *s;
+       int ao_n_chan;
+       int ret;
+
+       dev->board_name = dev->driver->driver_name;
+
+       devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
+       if (!devpriv)
+               return -ENOMEM;
+       dev->private = devpriv;
+
+       ret = comedi_pci_enable(pcidev, dev->board_name);
+       if (ret)
+               return ret;
+
+       dev->iobase = pci_resource_start(pcidev, 1);
+       devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
+
+       ao_n_chan = apci3501_eeprom_get_ao_n_chan(dev);
+
+       if (pcidev->irq > 0) {
+               ret = request_irq(pcidev->irq, apci3501_interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
+
+       ret = comedi_alloc_subdevices(dev, 5);
+       if (ret)
+               return ret;
+
+       /* Initialize the analog output subdevice */
+       s = &dev->subdevices[0];
+       if (ao_n_chan) {
+               s->type         = COMEDI_SUBD_AO;
+               s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+               s->n_chan       = ao_n_chan;
+               s->maxdata      = 0x3fff;
+               s->range_table  = &apci3501_ao_range;
+               s->insn_write   = apci3501_ao_insn_write;
+       } else {
+               s->type         = COMEDI_SUBD_UNUSED;
+       }
+
+       /* Initialize the digital input subdevice */
+       s = &dev->subdevices[1];
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 2;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci3501_di_insn_bits;
+
+       /* Initialize the digital output subdevice */
+       s = &dev->subdevices[2];
+       s->type         = COMEDI_SUBD_DO;
+       s->subdev_flags = SDF_WRITEABLE;
+       s->n_chan       = 2;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci3501_do_insn_bits;
+
+       /* Initialize the timer/watchdog subdevice */
+       s = &dev->subdevices[3];
+       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 = i_APCI3501_StartStopWriteTimerCounterWatchdog;
+       s->insn_read = i_APCI3501_ReadTimerCounterWatchdog;
+       s->insn_config = i_APCI3501_ConfigTimerCounterWatchdog;
+
+       /* Initialize the eeprom subdevice */
+       s = &dev->subdevices[4];
+       s->type         = COMEDI_SUBD_MEMORY;
+       s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+       s->n_chan       = 256;
+       s->maxdata      = 0xffff;
+       s->insn_read    = apci3501_eeprom_insn_read;
+
+       apci3501_reset(dev);
+       return 0;
+}
+
+static void apci3501_detach(struct comedi_device *dev)
+{
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+       if (dev->iobase)
+               apci3501_reset(dev);
+       if (dev->irq)
+               free_irq(dev->irq, dev);
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+       }
+}
 
 static struct comedi_driver apci3501_driver = {
        .driver_name    = "addi_apci_3501",
        .module         = THIS_MODULE,
-       .auto_attach    = addi_auto_attach,
-       .detach         = i_ADDI_Detach,
-       .num_names      = ARRAY_SIZE(apci3501_boardtypes),
-       .board_name     = &apci3501_boardtypes[0].pc_DriverName,
-       .offset         = sizeof(struct addi_board),
+       .auto_attach    = apci3501_auto_attach,
+       .detach         = apci3501_detach,
 };
 
 static int apci3501_pci_probe(struct pci_dev *dev,
@@ -57,19 +444,20 @@ static int apci3501_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci3501_driver);
 }
 
-static void apci3501_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
+static DEFINE_PCI_DEVICE_TABLE(apci3501_pci_table) = {
+       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3001) },
+       { 0 }
+};
+MODULE_DEVICE_TABLE(pci, apci3501_pci_table);
 
 static struct pci_driver apci3501_pci_driver = {
        .name           = "addi_apci_3501",
        .id_table       = apci3501_pci_table,
        .probe          = apci3501_pci_probe,
-       .remove         = apci3501_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci3501_driver, apci3501_pci_driver);
 
+MODULE_DESCRIPTION("ADDI-DATA APCI-3501 Analog output board");
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
 MODULE_LICENSE("GPL");
index 1562347ed64b3d0df64cebbc3e25214e37909ef6..69f5bf4d52e06548fda049f3bd55f19d04342c18 100644 (file)
@@ -751,11 +751,6 @@ static int apci3xxx_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &apci3xxx_driver);
 }
 
-static void apci3xxx_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(apci3xxx_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3010) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300f) },
@@ -790,7 +785,7 @@ static struct pci_driver apci3xxx_pci_driver = {
        .name           = "addi_apci_3xxx",
        .id_table       = apci3xxx_pci_table,
        .probe          = apci3xxx_pci_probe,
-       .remove         = apci3xxx_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(apci3xxx_driver, apci3xxx_pci_driver);
 
diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c
new file mode 100644 (file)
index 0000000..375ab66
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * COMEDI driver for the watchdog subdevice found on some addi-data boards
+ * Copyright (c) 2013 H Hartley Sweeten <hsweeten@visionengravers.com>
+ *
+ * Based on implementations in various addi-data COMEDI drivers.
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "../comedidev.h"
+#include "addi_watchdog.h"
+
+/*
+ * Register offsets/defines for the addi-data watchdog
+ */
+#define ADDI_WDOG_REG                  0x00
+#define ADDI_WDOG_RELOAD_REG           0x04
+#define ADDI_WDOG_TIMEBASE             0x08
+#define ADDI_WDOG_CTRL_REG             0x0c
+#define ADDI_WDOG_CTRL_ENABLE          (1 << 0)
+#define ADDI_WDOG_CTRL_SW_TRIG         (1 << 9)
+#define ADDI_WDOG_STATUS_REG           0x10
+#define ADDI_WDOG_STATUS_ENABLED       (1 << 0)
+#define ADDI_WDOG_STATUS_SW_TRIG       (1 << 1)
+
+struct addi_watchdog_private {
+       unsigned long iobase;
+       unsigned int wdog_ctrl;
+};
+
+/*
+ * The watchdog subdevice is configured with two INSN_CONFIG instructions:
+ *
+ * Enable the watchdog and set the reload timeout:
+ *     data[0] = INSN_CONFIG_ARM
+ *     data[1] = timeout reload value
+ *
+ * Disable the watchdog:
+ *     data[0] = INSN_CONFIG_DISARM
+ */
+static int addi_watchdog_insn_config(struct comedi_device *dev,
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
+{
+       struct addi_watchdog_private *spriv = s->private;
+       unsigned int reload;
+
+       switch (data[0]) {
+       case INSN_CONFIG_ARM:
+               spriv->wdog_ctrl = ADDI_WDOG_CTRL_ENABLE;
+               reload = data[1] & s->maxdata;
+               outl(reload, spriv->iobase + ADDI_WDOG_RELOAD_REG);
+
+               /* Time base is 20ms, let the user know the timeout */
+               dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n",
+                       20 * reload + 20);
+               break;
+       case INSN_CONFIG_DISARM:
+               spriv->wdog_ctrl = 0;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       outl(spriv->wdog_ctrl, spriv->iobase + ADDI_WDOG_CTRL_REG);
+
+       return insn->n;
+}
+
+static int addi_watchdog_insn_read(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
+{
+       struct addi_watchdog_private *spriv = s->private;
+       int i;
+
+       for (i = 0; i < insn->n; i++)
+               data[i] = inl(spriv->iobase + ADDI_WDOG_STATUS_REG);
+
+       return insn->n;
+}
+
+static int addi_watchdog_insn_write(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_insn *insn,
+                                   unsigned int *data)
+{
+       struct addi_watchdog_private *spriv = s->private;
+       int i;
+
+       if (spriv->wdog_ctrl == 0) {
+               dev_warn(dev->class_dev, "watchdog is disabled\n");
+               return -EINVAL;
+       }
+
+       /* "ping" the watchdog */
+       for (i = 0; i < insn->n; i++) {
+               outl(spriv->wdog_ctrl | ADDI_WDOG_CTRL_SW_TRIG,
+                    spriv->iobase + ADDI_WDOG_CTRL_REG);
+       }
+
+       return insn->n;
+}
+
+void addi_watchdog_reset(unsigned long iobase)
+{
+       outl(0x0, iobase + ADDI_WDOG_CTRL_REG);
+       outl(0x0, iobase + ADDI_WDOG_RELOAD_REG);
+}
+EXPORT_SYMBOL_GPL(addi_watchdog_reset);
+
+int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase)
+{
+       struct addi_watchdog_private *spriv;
+
+       spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
+       if (!spriv)
+               return -ENOMEM;
+
+       spriv->iobase = iobase;
+
+       s->private      = spriv;
+
+       s->type         = COMEDI_SUBD_TIMER;
+       s->subdev_flags = SDF_WRITEABLE;
+       s->n_chan       = 1;
+       s->maxdata      = 0xff;
+       s->insn_config  = addi_watchdog_insn_config;
+       s->insn_read    = addi_watchdog_insn_read;
+       s->insn_write   = addi_watchdog_insn_write;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(addi_watchdog_init);
+
+void addi_watchdog_cleanup(struct comedi_subdevice *s)
+{
+       kfree(s->private);
+}
+EXPORT_SYMBOL_GPL(addi_watchdog_cleanup);
+
+static int __init addi_watchdog_module_init(void)
+{
+       return 0;
+}
+module_init(addi_watchdog_module_init);
+
+static void __exit addi_watchdog_module_exit(void)
+{
+}
+module_exit(addi_watchdog_module_exit);
+
+MODULE_DESCRIPTION("ADDI-DATA Watchdog subdevice");
+MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/addi_watchdog.h b/drivers/staging/comedi/drivers/addi_watchdog.h
new file mode 100644 (file)
index 0000000..f374a7b
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _ADDI_WATCHDOG_H
+#define _ADDI_WATCHDOG_H
+
+#include "../comedidev.h"
+
+void addi_watchdog_reset(unsigned long iobase);
+int addi_watchdog_init(struct comedi_subdevice *, unsigned long iobase);
+void addi_watchdog_cleanup(struct comedi_subdevice *s);
+
+#endif
index 9a56eed3910f18b89e85b5f2e465908d9a0134a6..41df0105e824d13b4ebdfd6d8ac4a613403dc14a 100644 (file)
@@ -270,11 +270,6 @@ static int adl_pci6208_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adl_pci6208_driver);
 }
 
-static void adl_pci6208_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci6208_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI6208) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI6216) },
@@ -286,7 +281,7 @@ static struct pci_driver adl_pci6208_pci_driver = {
        .name           = "adl_pci6208",
        .id_table       = adl_pci6208_pci_table,
        .probe          = adl_pci6208_pci_probe,
-       .remove         = adl_pci6208_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adl_pci6208_driver, adl_pci6208_pci_driver);
 
index 772edc02f5ce5d437f28736d922e20f394f6cf2c..2a8bc9804961651356ea794f20fa7deee6563318 100644 (file)
@@ -302,11 +302,6 @@ static int adl_pci7x3x_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adl_pci7x3x_driver);
 }
 
-static void adl_pci7x3x_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7x3x_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7233) },
@@ -322,7 +317,7 @@ static struct pci_driver adl_pci7x3x_pci_driver = {
        .name           = "adl_pci7x3x",
        .id_table       = adl_pci7x3x_pci_table,
        .probe          = adl_pci7x3x_pci_probe,
-       .remove         = adl_pci7x3x_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adl_pci7x3x_driver, adl_pci7x3x_pci_driver);
 
index 4dd9d707a79ddd6278f17d8c350a5a1ec6083e7a..bfa71e07af1fb63071b75184783361173cfb2f84 100644 (file)
@@ -298,11 +298,6 @@ static int adl_pci8164_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adl_pci8164_driver);
 }
 
-static void adl_pci8164_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) },
        {0}
@@ -313,7 +308,7 @@ static struct pci_driver adl_pci8164_pci_driver = {
        .name           = "adl_pci8164",
        .id_table       = adl_pci8164_pci_table,
        .probe          = adl_pci8164_pci_probe,
-       .remove         = adl_pci8164_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adl_pci8164_driver, adl_pci8164_pci_driver);
 
index a339b9dd27cf7c04c5f3c3461470653e7caed5c6..1a31e910fcbd23e6046da83c9fbb5d57887bc8e7 100644 (file)
@@ -963,11 +963,6 @@ static int pci9111_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adl_pci9111_driver);
 }
 
-static void pci9111_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) },
        /* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */
@@ -979,7 +974,7 @@ static struct pci_driver adl_pci9111_pci_driver = {
        .name           = "adl_pci9111",
        .id_table       = pci9111_pci_table,
        .probe          = pci9111_pci_probe,
-       .remove         = pci9111_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adl_pci9111_driver, adl_pci9111_pci_driver);
 
index b6dda809bd1373234ef0eadf151bb50764610a1f..d21dfe65ba856acfa1c3a97f4832992d3d1a77fa 100644 (file)
@@ -2225,11 +2225,6 @@ static int adl_pci9118_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adl_pci9118_driver);
 }
 
-static void adl_pci9118_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adl_pci9118_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80d9) },
        { 0 }
@@ -2240,7 +2235,7 @@ static struct pci_driver adl_pci9118_pci_driver = {
        .name           = "adl_pci9118",
        .id_table       = adl_pci9118_pci_table,
        .probe          = adl_pci9118_pci_probe,
-       .remove         = adl_pci9118_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adl_pci9118_driver, adl_pci9118_pci_driver);
 
index a6fd8c2c16cabeaed8c3f51ebbc293828e64c9f8..d232d0c60a922d3547cdf7d8305a359348b251ce 100644 (file)
@@ -1402,11 +1402,6 @@ static int adv_pci1710_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adv_pci1710_driver);
 }
 
-static void adv_pci1710_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adv_pci1710_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
@@ -1421,7 +1416,7 @@ static struct pci_driver adv_pci1710_pci_driver = {
        .name           = "adv_pci1710",
        .id_table       = adv_pci1710_pci_table,
        .probe          = adv_pci1710_pci_probe,
-       .remove         = adv_pci1710_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver);
 
index 5af73146dd855593ac223500267d040a0aaa7a3b..1be8902f8231c03b0385d2095d82c2ba93b80d85 100644 (file)
@@ -327,11 +327,6 @@ static int adv_pci1723_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adv_pci1723_driver);
 }
 
-static void adv_pci1723_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adv_pci1723_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1723) },
        { 0 }
@@ -342,7 +337,7 @@ static struct pci_driver adv_pci1723_pci_driver = {
        .name           = "adv_pci1723",
        .id_table       = adv_pci1723_pci_table,
        .probe          = adv_pci1723_pci_probe,
-       .remove         = adv_pci1723_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adv_pci1723_driver, adv_pci1723_pci_driver);
 
index 05a663e970c640a79af081806f482ccb468a759e..35887e40ef0c5d121c18dceefbdc47181494eeb7 100644 (file)
@@ -1206,11 +1206,6 @@ static int adv_pci_dio_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &adv_pci_dio_driver);
 }
 
-static void adv_pci_dio_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(adv_pci_dio_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1730) },
        { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1733) },
@@ -1234,7 +1229,7 @@ static struct pci_driver adv_pci_dio_pci_driver = {
        .name           = "adv_pci_dio",
        .id_table       = adv_pci_dio_pci_table,
        .probe          = adv_pci_dio_pci_probe,
-       .remove         = adv_pci_dio_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(adv_pci_dio_driver, adv_pci_dio_pci_driver);
 
index 5f309ba88a1afa0a0ae4130902f76c868bd43f3b..1fadf5d0ad26d860bad4fa3e0a236b9616438cce 100644 (file)
@@ -1977,8 +1977,7 @@ static int dio200_auto_attach(struct comedi_device *dev,
                devpriv->io.u.iobase = (unsigned long)base;
                devpriv->io.regtype = io_regtype;
        }
-       switch (thisboard->model)
-       {
+       switch (thisboard->model) {
        case pcie215_model:
        case pcie236_model:
        case pcie296_model:
@@ -2079,16 +2078,11 @@ static int amplc_dio200_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &amplc_dio200_driver);
 }
 
-static void amplc_dio200_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver amplc_dio200_pci_driver = {
        .name = DIO200_DRIVER_NAME,
        .id_table = dio200_pci_table,
        .probe = &amplc_dio200_pci_probe,
-       .remove = &amplc_dio200_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(amplc_dio200_driver, amplc_dio200_pci_driver);
 #else
index 28983541957787683201d1f46da984ebc3a07d58..5011016a947ea48f0746ed127df0680df04b2278 100644 (file)
@@ -614,16 +614,11 @@ static int amplc_pc236_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &amplc_pc236_driver);
 }
 
-static void amplc_pc236_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver amplc_pc236_pci_driver = {
        .name = PC236_DRIVER_NAME,
        .id_table = pc236_pci_table,
        .probe = &amplc_pc236_pci_probe,
-       .remove = &amplc_pc236_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 
 module_comedi_pci_driver(amplc_pc236_driver, amplc_pc236_pci_driver);
index dfbff77cd795e4432c9bc86aa7c1d0cb10d1a9ea..c34bb009b710630bd376f69a9e5cbe6d54f17e32 100644 (file)
@@ -372,16 +372,11 @@ static int amplc_pc263_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &amplc_pc263_driver);
 }
 
-static void amplc_pc263_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver amplc_pc263_pci_driver = {
        .name = PC263_DRIVER_NAME,
        .id_table = pc263_pci_table,
        .probe = &amplc_pc263_pci_probe,
-       .remove = &amplc_pc263_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(amplc_pc263_driver, amplc_pc263_pci_driver);
 #else
index 6e2566a2dd57929f3a9da5c356646cd539c1afd9..24794f4c565f2b4335553f7976ee942fb7c7cfff 100644 (file)
@@ -1512,11 +1512,6 @@ static int amplc_pci224_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &amplc_pci224_driver);
 }
 
-static void amplc_pci224_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(amplc_pci224_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234) },
@@ -1528,7 +1523,7 @@ static struct pci_driver amplc_pci224_pci_driver = {
        .name           = "amplc_pci224",
        .id_table       = amplc_pci224_pci_table,
        .probe          = amplc_pci224_pci_probe,
-       .remove         = amplc_pci224_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(amplc_pci224_driver, amplc_pci224_pci_driver);
 
index 366c68be56bd812fcdb9b8003a98b50ffd7cbfae..2440596a3ec4f950b184ccb250037ed3ae73ad77 100644 (file)
@@ -2863,11 +2863,6 @@ static int amplc_pci230_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &amplc_pci230_driver);
 }
 
-static void amplc_pci230_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(amplc_pci230_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230) },
        { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260) },
@@ -2879,7 +2874,7 @@ static struct pci_driver amplc_pci230_pci_driver = {
        .name           = "amplc_pci230",
        .id_table       = amplc_pci230_pci_table,
        .probe          = amplc_pci230_pci_probe,
-       .remove         = amplc_pci230_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(amplc_pci230_driver, amplc_pci230_pci_driver);
 
index 93731de1f2b1b1317682c5a04bf6ccba93485efe..e253fc03ceface18ce93658a4c4e7a53f3404a3c 100644 (file)
@@ -548,30 +548,7 @@ static struct pcmcia_driver das16cs_driver = {
        .id_table       = das16cs_id_table,
 };
 
-static int __init das16cs_init(void)
-{
-       int ret;
-
-       ret = comedi_driver_register(&driver_das16cs);
-       if (ret < 0)
-               return ret;
-
-       ret = pcmcia_register_driver(&das16cs_driver);
-       if (ret < 0) {
-               comedi_driver_unregister(&driver_das16cs);
-               return ret;
-       }
-
-       return 0;
-}
-module_init(das16cs_init);
-
-static void __exit das16cs_exit(void)
-{
-       pcmcia_unregister_driver(&das16cs_driver);
-       comedi_driver_unregister(&driver_das16cs);
-}
-module_exit(das16cs_exit);
+module_comedi_pcmcia_driver(driver_das16cs, das16cs_driver);
 
 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
 MODULE_DESCRIPTION("Comedi driver for Computer Boards PC-CARD DAS16/16");
index aed68639cc9a106b4cecefa888d788827642335a..0fd6fcf0cefea39ffec1c2a22004b62e706d52fd 100644 (file)
@@ -1632,11 +1632,6 @@ static int cb_pcidas_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &cb_pcidas_driver);
 }
 
-static void cb_pcidas_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) },
        { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) },
@@ -1654,7 +1649,7 @@ static struct pci_driver cb_pcidas_pci_driver = {
        .name           = "cb_pcidas",
        .id_table       = cb_pcidas_pci_table,
        .probe          = cb_pcidas_pci_probe,
-       .remove         = cb_pcidas_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(cb_pcidas_driver, cb_pcidas_pci_driver);
 
index d72b46cc06bc53c6b7bbcdc4eb0cb0a3c0c22862..e7d297708a5b00a6b3c02f63a43fe858caf56cac 100644 (file)
@@ -4220,11 +4220,6 @@ static int cb_pcidas64_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &cb_pcidas64_driver);
 }
 
-static void cb_pcidas64_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidas64_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001d) },
        { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001e) },
@@ -4253,7 +4248,7 @@ static struct pci_driver cb_pcidas64_pci_driver = {
        .name           = "cb_pcidas64",
        .id_table       = cb_pcidas64_pci_table,
        .probe          = cb_pcidas64_pci_probe,
-       .remove         = cb_pcidas64_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(cb_pcidas64_driver, cb_pcidas64_pci_driver);
 
index 7c6029a8c3e14af64a86b6cac02a108513268286..04be8c62d79d82114fce528391b150e205256fe6 100644 (file)
@@ -438,11 +438,6 @@ static int cb_pcidda_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &cb_pcidda_driver);
 }
 
-static void cb_pcidda_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA02_12) },
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA04_12) },
@@ -458,7 +453,7 @@ static struct pci_driver cb_pcidda_pci_driver = {
        .name           = "cb_pcidda",
        .id_table       = cb_pcidda_pci_table,
        .probe          = cb_pcidda_pci_probe,
-       .remove         = cb_pcidda_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(cb_pcidda_driver, cb_pcidda_pci_driver);
 
index b43a5f80ac26ed19d3afb920dafe9cdb7a0e5b2a..709c5c670f40df1df93bd20c1e45d331345b4c6d 100644 (file)
@@ -299,11 +299,6 @@ static int cb_pcimdas_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &cb_pcimdas_driver);
 }
 
-static void cb_pcimdas_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0056) },
        { 0 }
@@ -314,7 +309,7 @@ static struct pci_driver cb_pcimdas_pci_driver = {
        .name           = "cb_pcimdas",
        .id_table       = cb_pcimdas_pci_table,
        .probe          = cb_pcimdas_pci_probe,
-       .remove         = cb_pcimdas_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver);
 
index 699b84f54cc744bb0fec76a67debeda0b9b40836..74aa4e062596a88fde9459978b239e0100ea534a 100644 (file)
@@ -222,11 +222,6 @@ static int cb_pcimdda_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &cb_pcimdda_driver);
 }
 
-static void cb_pcimdda_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(cb_pcimdda_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_ID_PCIM_DDA06_16) },
        { 0 }
@@ -237,7 +232,7 @@ static struct pci_driver cb_pcimdda_driver_pci_driver = {
        .name           = "cb_pcimdda",
        .id_table       = cb_pcimdda_pci_table,
        .probe          = cb_pcimdda_pci_probe,
-       .remove         = cb_pcimdda_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(cb_pcimdda_driver, cb_pcimdda_driver_pci_driver);
 
index 01de996239f1e6142f07f9851cc840e8ddc14a75..270fea5c6b512a7bc462173b7b9cade1210ba04d 100644 (file)
@@ -62,15 +62,14 @@ zero volts).
 /* Data unique to this driver */
 struct waveform_private {
        struct timer_list timer;
-       struct timeval last;    /* time at which last timer interrupt occurred */
+       struct timeval 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 (modulo waveform period) */
-       unsigned long usec_remainder;   /* usec since last scan; */
-       unsigned long ai_count; /* number of conversions remaining */
+       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 int scan_period;       /* scan period in usec */
        unsigned int convert_period;    /* conversion period in usec */
-       unsigned timer_running:1;
        unsigned int ao_loopbacks[N_CHANS];
 };
 
@@ -86,8 +85,9 @@ static const struct comedi_lrange waveform_ai_ranges = {
         }
 };
 
-static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
-                          unsigned long current_time)
+static unsigned short fake_sawtooth(struct comedi_device *dev,
+                                   unsigned int range_index,
+                                   unsigned long current_time)
 {
        struct waveform_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
@@ -110,9 +110,9 @@ static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
        return offset + value;
 }
 
-static short fake_squarewave(struct comedi_device *dev,
-                            unsigned int range_index,
-                            unsigned long current_time)
+static unsigned short fake_squarewave(struct comedi_device *dev,
+                                     unsigned int range_index,
+                                     unsigned long current_time)
 {
        struct waveform_private *devpriv = dev->private;
        struct comedi_subdevice *s = dev->read_subdev;
@@ -132,15 +132,17 @@ static short fake_squarewave(struct comedi_device *dev,
        return offset + value;
 }
 
-static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
-                          unsigned long current_time)
+static unsigned short fake_flatline(struct comedi_device *dev,
+                                   unsigned int range_index,
+                                   unsigned long current_time)
 {
        return dev->read_subdev->maxdata / 2;
 }
 
 /* generates a different waveform depending on what channel is read */
-static short fake_waveform(struct comedi_device *dev, unsigned int channel,
-                          unsigned int range, unsigned long current_time)
+static unsigned short fake_waveform(struct comedi_device *dev,
+                                   unsigned int channel, unsigned int range,
+                                   unsigned long current_time)
 {
        enum {
                SAWTOOTH_CHAN,
@@ -176,6 +178,7 @@ static void waveform_ai_interrupt(unsigned long arg)
        unsigned long elapsed_time;
        unsigned int num_scans;
        struct timeval now;
+       bool stopping = false;
 
        do_gettimeofday(&now);
 
@@ -189,37 +192,35 @@ static void waveform_ai_interrupt(unsigned long arg)
            (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
        async->events = 0;
 
+       if (cmd->stop_src == TRIG_COUNT) {
+               unsigned int remaining = cmd->stop_arg - devpriv->ai_count;
+               if (num_scans >= remaining) {
+                       /* about to finish */
+                       num_scans = remaining;
+                       stopping = true;
+               }
+       }
+
        for (i = 0; i < num_scans; i++) {
                for (j = 0; j < cmd->chanlist_len; j++) {
-                       cfc_write_to_buffer(dev->read_subdev,
-                                           fake_waveform(dev,
-                                                         CR_CHAN(cmd->
-                                                                 chanlist[j]),
-                                                         CR_RANGE(cmd->
-                                                                  chanlist[j]),
-                                                         devpriv->
-                                                         usec_current +
-                                                         i *
-                                                         devpriv->scan_period +
-                                                         j *
-                                                         devpriv->
-                                                         convert_period));
-               }
-               devpriv->ai_count++;
-               if (cmd->stop_src == TRIG_COUNT
-                   && devpriv->ai_count >= cmd->stop_arg) {
-                       async->events |= COMEDI_CB_EOA;
-                       break;
+                       unsigned short sample;
+                       sample = fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
+                                              CR_RANGE(cmd->chanlist[j]),
+                                              devpriv->usec_current +
+                                                  i * devpriv->scan_period +
+                                                  j * devpriv->convert_period);
+                       cfc_write_to_buffer(dev->read_subdev, sample);
                }
        }
 
+       devpriv->ai_count += i;
        devpriv->usec_current += elapsed_time;
        devpriv->usec_current %= devpriv->usec_period;
 
-       if ((async->events & COMEDI_CB_EOA) == 0 && devpriv->timer_running)
-               mod_timer(&devpriv->timer, jiffies + 1);
+       if (stopping)
+               async->events |= COMEDI_CB_EOA;
        else
-               del_timer(&devpriv->timer);
+               mod_timer(&devpriv->timer, jiffies + 1);
 
        comedi_event(dev, dev->read_subdev);
 }
@@ -317,7 +318,6 @@ static int waveform_ai_cmd(struct comedi_device *dev,
                return -1;
        }
 
-       devpriv->timer_running = 1;
        devpriv->ai_count = 0;
        devpriv->scan_period = cmd->scan_begin_arg / nano_per_micro;
 
@@ -344,7 +344,6 @@ static int waveform_ai_cancel(struct comedi_device *dev,
 {
        struct waveform_private *devpriv = dev->private;
 
-       devpriv->timer_running = 0;
        del_timer_sync(&devpriv->timer);
        return 0;
 }
index 1a18fa37bfd0a08ab12293066658a7bc00d30e4b..e0273c445af64082cb906ef721628cb8596c3bd9 100644 (file)
@@ -130,11 +130,6 @@ static int contec_pci_dio_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &contec_pci_dio_driver);
 }
 
-static void contec_pci_dio_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(contec_pci_dio_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L) },
        { 0 }
@@ -145,7 +140,7 @@ static struct pci_driver contec_pci_dio_pci_driver = {
        .name           = "contec_pci_dio",
        .id_table       = contec_pci_dio_pci_table,
        .probe          = contec_pci_dio_pci_probe,
-       .remove         = contec_pci_dio_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(contec_pci_dio_driver, contec_pci_dio_pci_driver);
 
index 992e557e6ae1b4b7b08f0635e40abf7e6b8a7ea4..d1fc190313c56f17392bdfa1821aa65aa2065b8f 100644 (file)
@@ -485,7 +485,7 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev)
        writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
        udelay(10000);
        writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
-       udelay(10000);          /* Not in the original code, but I like symmetry... */
+       udelay(10000);  /* Not in the original code, but I like symmetry... */
 }
 
 static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask)
@@ -799,11 +799,6 @@ static int daqboard2000_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &daqboard2000_driver);
 }
 
-static void daqboard2000_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_IOTECH, 0x0409) },
        { 0 }
@@ -814,7 +809,7 @@ static struct pci_driver daqboard2000_pci_driver = {
        .name           = "daqboard2000",
        .id_table       = daqboard2000_pci_table,
        .probe          = daqboard2000_pci_probe,
-       .remove         = daqboard2000_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(daqboard2000_driver, daqboard2000_pci_driver);
 
index b15e05808cb0c211a7eceb289f33dee9cca321e3..37f03c2b766dfae8f697960c5b5480a272a6e3ef 100644 (file)
@@ -891,16 +891,11 @@ static int das08_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &das08_driver);
 }
 
-static void das08_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver das08_pci_driver = {
        .id_table = das08_pci_table,
        .name =  DRV_NAME,
        .probe = &das08_pci_probe,
-       .remove = &das08_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 #endif /* DO_PCI */
 
index 024262375e3c2abed705da3c753c5f73e3525ef2..73a2418933f7e6027badd3731161ea2c9af93b54 100644 (file)
@@ -181,31 +181,7 @@ static struct pcmcia_driver das08_cs_driver = {
        .id_table       = das08_cs_id_table,
 };
 
-static int __init das08_cs_init_module(void)
-{
-       int ret;
-
-       ret = comedi_driver_register(&driver_das08_cs);
-       if (ret < 0)
-               return ret;
-
-       ret = pcmcia_register_driver(&das08_cs_driver);
-       if (ret < 0) {
-               comedi_driver_unregister(&driver_das08_cs);
-               return ret;
-       }
-
-       return 0;
-
-}
-module_init(das08_cs_init_module);
-
-static void __exit das08_cs_exit_module(void)
-{
-       pcmcia_unregister_driver(&das08_cs_driver);
-       comedi_driver_unregister(&driver_das08_cs);
-}
-module_exit(das08_cs_exit_module);
+module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver);
 
 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
              "Frank Mori Hess <fmhess@users.sourceforge.net>");
index 960da8debe171b517f49bc0e9a13f253682fa26f..1fabe8870cd08cb400749b05b9262962ef5b680e 100644 (file)
@@ -856,11 +856,6 @@ static int dt3000_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &dt3000_driver);
 }
 
-static void dt3000_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(dt3000_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_DT, PCI_DEVICE_ID_DT3001) },
        { PCI_DEVICE(PCI_VENDOR_ID_DT, PCI_DEVICE_ID_DT3001_PGL) },
@@ -877,7 +872,7 @@ static struct pci_driver dt3000_pci_driver = {
        .name           = "dt3000",
        .id_table       = dt3000_pci_table,
        .probe          = dt3000_pci_probe,
-       .remove         = dt3000_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(dt3000_driver, dt3000_pci_driver);
 
index 176799849d20ec02c70c6860d106c03aebdff239..fc5b30c70737be9687f94048c603a3bfbf538df4 100644 (file)
@@ -1133,7 +1133,7 @@ static struct comedi_driver dt9812_comedi_driver = {
 
 static int __init usb_dt9812_init(void)
 {
-       int result, i;
+       int i;
 
        /* Initialize all driver slots */
        for (i = 0; i < DT9812_NUM_SLOTS; i++) {
@@ -1144,30 +1144,13 @@ static int __init usb_dt9812_init(void)
        }
        dt9812[12].serial = 0x0;
 
-       /* register with the USB subsystem */
-       result = usb_register(&dt9812_usb_driver);
-       if (result) {
-               pr_err("usb_register failed. Error number %d\n", result);
-               return result;
-       }
-       /* register with comedi */
-       result = comedi_driver_register(&dt9812_comedi_driver);
-       if (result) {
-               usb_deregister(&dt9812_usb_driver);
-               pr_err("comedi_driver_register failed. Error number %d\n",
-                      result);
-       }
-
-       return result;
+       return comedi_usb_driver_register(&dt9812_comedi_driver,
+                                               &dt9812_usb_driver);
 }
 
 static void __exit usb_dt9812_exit(void)
 {
-       /* unregister with comedi */
-       comedi_driver_unregister(&dt9812_comedi_driver);
-
-       /* deregister this driver with the USB subsystem */
-       usb_deregister(&dt9812_usb_driver);
+       comedi_usb_driver_unregister(&dt9812_comedi_driver, &dt9812_usb_driver);
 }
 
 module_init(usb_dt9812_init);
index 8497a36db7db9a851f07562e047e32a3db4ad1b7..5aa695e8465034bdb5a8828495fde6df589ed0ac 100644 (file)
@@ -276,11 +276,6 @@ static int dyna_pci10xx_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &dyna_pci10xx_driver);
 }
 
-static void dyna_pci10xx_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(dyna_pci10xx_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_PLX, 0x1050) },
        { 0 }
@@ -291,7 +286,7 @@ static struct pci_driver dyna_pci10xx_pci_driver = {
        .name           = "dyna_pci10xx",
        .id_table       = dyna_pci10xx_pci_table,
        .probe          = dyna_pci10xx_pci_probe,
-       .remove         = dyna_pci10xx_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(dyna_pci10xx_driver, dyna_pci10xx_pci_driver);
 
index 154598f6d5e3616489db4935ce9b707614aecae8..6d88b72fd4727efd032bd5a3d3038fd6595b871a 100644 (file)
@@ -946,11 +946,6 @@ static int gsc_hpdi_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &gsc_hpdi_driver);
 }
 
-static void gsc_hpdi_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(gsc_hpdi_pci_table) = {
        { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
                    0x2400, 0, 0, 0},
@@ -962,7 +957,7 @@ static struct pci_driver gsc_hpdi_pci_driver = {
        .name           = "gsc_hpdi",
        .id_table       = gsc_hpdi_pci_table,
        .probe          = gsc_hpdi_pci_probe,
-       .remove         = gsc_hpdi_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver);
 
index a91a448ba0f01fd75761b2b907079d2354157711..017429539bd4f2978962b9b8df78db3575aed537 100644 (file)
@@ -623,11 +623,6 @@ static int icp_multi_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &icp_multi_driver);
 }
 
-static void icp_multi_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(icp_multi_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_ICP, PCI_DEVICE_ID_ICP_MULTI) },
        { 0 }
@@ -638,7 +633,7 @@ static struct pci_driver icp_multi_pci_driver = {
        .name           = "icp_multi",
        .id_table       = icp_multi_pci_table,
        .probe          = icp_multi_pci_probe,
-       .remove         = icp_multi_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(icp_multi_driver, icp_multi_pci_driver);
 
index c756a35ce31a6fac27b81281b6e7738787da3703..8d79c761509b688f40f8cbb2f7b080ce7221dd7b 100644 (file)
@@ -844,11 +844,6 @@ static int jr3_pci_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &jr3_pci_driver);
 }
 
-static void jr3_pci_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL) },
        { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL_NEW) },
@@ -863,7 +858,7 @@ static struct pci_driver jr3_pci_pci_driver = {
        .name           = "jr3_pci",
        .id_table       = jr3_pci_pci_table,
        .probe          = jr3_pci_pci_probe,
-       .remove         = jr3_pci_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(jr3_pci_driver, jr3_pci_pci_driver);
 
index 19c94282ac3ff46a29c19c6807caf2fe14153835..535800a369018241c171afc7ad5bc583938f6a21 100644 (file)
@@ -152,11 +152,6 @@ static int ke_counter_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ke_counter_driver);
 }
 
-static void ke_counter_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(ke_counter_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID) },
        { 0 }
@@ -167,7 +162,7 @@ static struct pci_driver ke_counter_pci_driver = {
        .name           = "ke_counter",
        .id_table       = ke_counter_pci_table,
        .probe          = ke_counter_pci_probe,
-       .remove         = ke_counter_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ke_counter_driver, ke_counter_pci_driver);
 
index 3c4b0228e8dc5d6f93f718d67087c99a461e432f..4312b3707d16c773d8b4a0f77cf1199cc9b32a77 100644 (file)
@@ -1734,11 +1734,6 @@ static int me4000_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &me4000_driver);
 }
 
-static void me4000_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = {
        {PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4650)},
        {PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, PCI_DEVICE_ID_MEILHAUS_ME4660)},
@@ -1761,7 +1756,7 @@ static struct pci_driver me4000_pci_driver = {
        .name           = "me4000",
        .id_table       = me4000_pci_table,
        .probe          = me4000_pci_probe,
-       .remove         = me4000_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(me4000_driver, me4000_pci_driver);
 
index ce8e3d3f135ccd31b6bdd1d6855d56561f6a5733..ee8bafcc46d118318f4639b4fcd9d4005b9c20b9 100644 (file)
@@ -619,11 +619,6 @@ static int me_daq_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &me_daq_driver);
 }
 
-static void me_daq_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(me_daq_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID) },
        { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID) },
@@ -635,7 +630,7 @@ static struct pci_driver me_daq_pci_driver = {
        .name           = "me_daq",
        .id_table       = me_daq_pci_table,
        .probe          = me_daq_pci_probe,
-       .remove         = me_daq_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(me_daq_driver, me_daq_pci_driver);
 
index 5196b460ce113b4e45435a1de79353c845340632..67aa6f4e4329f69d52f96205ebd08aba8ac7edcd 100644 (file)
@@ -452,16 +452,11 @@ static int ni6527_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni6527_driver);
 }
 
-static void ni6527_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver ni6527_pci_driver = {
        .name = DRIVER_NAME,
        .id_table = ni6527_pci_table,
        .probe = ni6527_pci_probe,
-       .remove = ni6527_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni6527_driver, ni6527_pci_driver);
 
index 2fb4b7790aebb1aafd6a639bcbc95e7526fe9736..fb7e8b887ce70cd6e64f74205206e84891ff832b 100644 (file)
@@ -787,16 +787,11 @@ static int ni_65xx_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni_65xx_driver);
 }
 
-static void ni_65xx_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver ni_65xx_pci_driver = {
        .name = "ni_65xx",
        .id_table = ni_65xx_pci_table,
        .probe = ni_65xx_pci_probe,
-       .remove = ni_65xx_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni_65xx_driver, ni_65xx_pci_driver);
 
index 26baf9c96fff74b0338cd53a848377927009712c..bdef2e4dd3db5b77ccffd4b40f8a4c64d4dc5bc9 100644 (file)
@@ -1327,11 +1327,6 @@ static int ni_660x_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni_660x_driver);
 }
 
-static void ni_660x_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = {
        {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c60)},
        {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1310)},
@@ -1345,7 +1340,7 @@ static struct pci_driver ni_660x_pci_driver = {
        .name           = "ni_660x",
        .id_table       = ni_660x_pci_table,
        .probe          = ni_660x_pci_probe,
-       .remove         = ni_660x_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni_660x_driver, ni_660x_pci_driver);
 
index 272caeb6ecee8dbae71f852a8646c2a25192c5ee..6f3c0909c06d2b317816c1d0a6ec2a49d6811a5b 100644 (file)
@@ -309,11 +309,6 @@ static int ni_670x_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni_670x_driver);
 }
 
-static void ni_670x_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c90) },
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1920) },
@@ -325,7 +320,7 @@ static struct pci_driver ni_670x_pci_driver = {
        .name           = "ni_670x",
        .id_table       = ni_670x_pci_table,
        .probe          = ni_670x_pci_probe,
-       .remove         = ni_670x_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni_670x_driver, ni_670x_pci_driver);
 
index 68d7c6a5db7dac901fd2f208f923106930c3553f..ff0e1993f173c03381c9a4ef16db95be71f7e8f6 100644 (file)
@@ -334,30 +334,7 @@ static struct pcmcia_driver daq700_cs_driver = {
        .id_table       = daq700_cs_ids,
 };
 
-static int __init daq700_cs_init(void)
-{
-       int ret;
-
-       ret = comedi_driver_register(&daq700_driver);
-       if (ret < 0)
-               return ret;
-
-       ret = pcmcia_register_driver(&daq700_cs_driver);
-       if (ret < 0) {
-               comedi_driver_unregister(&daq700_driver);
-               return ret;
-       }
-
-       return 0;
-}
-module_init(daq700_cs_init);
-
-static void __exit daq700_cs_exit(void)
-{
-       pcmcia_unregister_driver(&daq700_cs_driver);
-       comedi_driver_unregister(&daq700_driver);
-}
-module_exit(daq700_cs_exit);
+module_comedi_pcmcia_driver(daq700_driver, daq700_cs_driver);
 
 MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>");
 MODULE_DESCRIPTION(
index 7b333353c5d9707baee59322036ce8e25ae9d6c2..dd22691b1df1c7deea021f283f2c5320f8a7758e 100644 (file)
@@ -318,31 +318,4 @@ static struct pcmcia_driver dio24_cs_driver = {
        .name = "ni_daq_dio24",
 };
 
-static int __init init_dio24_cs(void)
-{
-       printk("ni_daq_dio24: HOLA SOY YO!\n");
-       pcmcia_register_driver(&dio24_cs_driver);
-       return 0;
-}
-
-static void __exit exit_dio24_cs(void)
-{
-       pcmcia_unregister_driver(&dio24_cs_driver);
-}
-
-int __init init_module(void)
-{
-       int ret;
-
-       ret = init_dio24_cs();
-       if (ret < 0)
-               return ret;
-
-       return comedi_driver_register(&driver_dio24);
-}
-
-void __exit cleanup_module(void)
-{
-       exit_dio24_cs();
-       comedi_driver_unregister(&driver_dio24);
-}
+module_comedi_pcmcia_driver(driver_dio24, dio24_cs_driver);
index d29c4d761bac943e04bcf72ab8d797a329bad648..dedb2ab780f3e3211fd476b91f03cc7aede7acff 100644 (file)
@@ -2116,16 +2116,11 @@ static int labpc_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &labpc_driver);
 }
 
-static void labpc_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver labpc_pci_driver = {
        .name = DRV_NAME,
        .id_table = labpc_pci_table,
        .probe = labpc_pci_probe,
-       .remove = labpc_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(labpc_driver, labpc_pci_driver);
 #else
index bfe19fa7d66f6206919a8c5856682f4e71b237e7..b26496df3e967eef7f1af8931587b1e47cdabf09 100644 (file)
@@ -282,33 +282,4 @@ static struct pcmcia_driver labpc_cs_driver = {
        .name = "daqcard-1200",
 };
 
-static int __init init_labpc_cs(void)
-{
-       pcmcia_register_driver(&labpc_cs_driver);
-       return 0;
-}
-
-static void __exit exit_labpc_cs(void)
-{
-       pcmcia_unregister_driver(&labpc_cs_driver);
-}
-
-static int __init labpc_init_module(void)
-{
-       int ret;
-
-       ret = init_labpc_cs();
-       if (ret < 0)
-               return ret;
-
-       return comedi_driver_register(&driver_labpc_cs);
-}
-
-static void __exit labpc_exit_module(void)
-{
-       exit_labpc_cs();
-       comedi_driver_unregister(&driver_labpc_cs);
-}
-
-module_init(labpc_init_module);
-module_exit(labpc_exit_module);
+module_comedi_pcmcia_driver(driver_labpc_cs, labpc_cs_driver);
index 56dc59908d362af9d674d63ff847d7e180ded33d..b7403597e9050e1f96a32b2d6592d092e6d120e8 100644 (file)
@@ -986,7 +986,7 @@ static void ni_event(struct comedi_device *dev, struct comedi_subdevice *s)
        if (s->
            async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW |
                             COMEDI_CB_EOA)) {
-               switch (s - dev->subdevices) {
+               switch (s->index) {
                case NI_AI_SUBDEV:
                        ni_ai_reset(dev, s);
                        break;
@@ -1086,7 +1086,7 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
                            ("ni_mio_common: a_status=0xffff.  Card removed?\n");
                        /* we probably aren't even running a command now,
                         * so it's a good idea to be careful. */
-                       if (comedi_get_subdevice_runflags(s) & SRF_RUNNING) {
+                       if (comedi_is_subdevice_running(s)) {
                                s->async->events |=
                                    COMEDI_CB_ERROR | COMEDI_CB_EOA;
                                ni_event(dev, s);
index 76c6a13ea9d627ad0e8fbcc5b3f5c576dda5c1d5..b5c5d58352dcdf10c66ee9e10d2d2edbbb5f8395 100644 (file)
@@ -408,8 +408,6 @@ static int ni_getboardtype(struct comedi_device *dev,
        return 0;
 }
 
-#ifdef MODULE
-
 static const struct pcmcia_device_id ni_mio_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d),        /* DAQCard-ai-16xe-50 */
        PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c),        /* DAQCard-ai-16e-4 */
@@ -434,20 +432,4 @@ static struct pcmcia_driver ni_mio_cs_driver = {
        .name = "ni_mio_cs",
 };
 
-int init_module(void)
-{
-       pcmcia_register_driver(&ni_mio_cs_driver);
-       comedi_driver_register(&driver_ni_mio_cs);
-       return 0;
-}
-
-void cleanup_module(void)
-{
-       pcmcia_unregister_driver(&ni_mio_cs_driver);
-#if 0
-       while (cur_dev != NULL)
-               cs_detach(cur_dev->handle);
-#endif
-       comedi_driver_unregister(&driver_ni_mio_cs);
-}
-#endif
+module_comedi_pcmcia_driver(driver_ni_mio_cs, ni_mio_cs_driver);
index 084ebea33ab9af9a1b835aad7e9b86bd6c75c11c..ba8c2f2561f526947e614fb561662a2397fdbd73 100644 (file)
@@ -1224,11 +1224,6 @@ static int ni_pcidio_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni_pcidio_driver);
 }
 
-static void ni_pcidio_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) },
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) },
@@ -1241,7 +1236,7 @@ static struct pci_driver ni_pcidio_pci_driver = {
        .name           = "ni_pcidio",
        .id_table       = ni_pcidio_pci_table,
        .probe          = ni_pcidio_pci_probe,
-       .remove         = ni_pcidio_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni_pcidio_driver, ni_pcidio_pci_driver);
 
index fd1662b4175db8755b8c605ed90f08437c12ba4c..26a870cbc7a1285cbf0e5e943d894538c7b1728c 100644 (file)
@@ -1791,11 +1791,6 @@ static int ni_pcimio_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &ni_pcimio_driver);
 }
 
-static void ni_pcimio_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(ni_pcimio_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0162) },
        { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1170) },
@@ -1858,7 +1853,7 @@ static struct pci_driver ni_pcimio_pci_driver = {
        .name           = "ni_pcimio",
        .id_table       = ni_pcimio_pci_table,
        .probe          = ni_pcimio_pci_probe,
-       .remove         = ni_pcimio_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(ni_pcimio_driver, ni_pcimio_pci_driver);
 
index 98f87897e2a823b31085b92cf03adf865015f449..225287769dc18f13cb50427fd789d91c94d0c55b 100644 (file)
@@ -276,7 +276,7 @@ static inline unsigned NI_660x_RTSI_Second_Gate_Select(unsigned n)
 }
 
 static const unsigned int counter_status_mask =
-    COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
+       COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING;
 
 static int __init ni_tio_init_module(void)
 {
index 0c991b99da1349adb2d3987c3e168de66b8d5edd..13747f324936deebf5fde0fbcc7f6a9a45520872 100644 (file)
@@ -159,6 +159,7 @@ static int ni_tio_input_cmd(struct ni_gpct *counter, struct comedi_async *async)
                async->inttrig = NULL;
                mite_dma_arm(counter->mite_chan);
                retval = ni_tio_arm(counter, 1, cmd->start_arg);
+               break;
        case TRIG_OTHER:
                async->inttrig = NULL;
                mite_dma_arm(counter->mite_chan);
index 06127a5f62a0af53ab0bd8574dc94ec82308e3db..b5af22eb7c37ddfe99be864b9315bb838e98053b 100644 (file)
@@ -243,8 +243,8 @@ static const struct comedi_lrange range_pcl818l_h_ai = { 4, {
 };
 
 static const struct comedi_lrange range718_bipolar1 = { 1, {BIP_RANGE(1),} };
-static const struct comedi_lrange range718_bipolar0_5 =
-    { 1, {BIP_RANGE(0.5),} };
+static const struct comedi_lrange range718_bipolar0_5 = {
+       1, {BIP_RANGE(0.5),} };
 static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} };
 static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} };
 
@@ -1005,17 +1005,14 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
        switch (devpriv->dma) {
        case 1:         /*  DMA */
        case 3:
-               if (devpriv->dma_rtc == 0) {
+               if (devpriv->dma_rtc == 0)
                        pcl818_ai_mode13dma_int(mode, dev, s);
-               }
 #ifdef unused
-               else {
+               else
                        pcl818_ai_mode13dma_rtc(mode, dev, s);
-               }
 #else
-               else {
+               else
                        return -EINVAL;
-               }
 #endif
                break;
        case 0:
@@ -1069,7 +1066,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
 */
 #ifdef PCL818_MODE13_AO
 static int pcl818_ao_mode13(int mode, struct comedi_device *dev,
-                           struct comedi_subdevice *s, comedi_trig * it)
+                           struct comedi_subdevice *s, comedi_trig *it)
 {
        struct pcl818_private *devpriv = dev->private;
        int divisor1 = 0, divisor2 = 0;
@@ -1124,7 +1121,7 @@ static int pcl818_ao_mode13(int mode, struct comedi_device *dev,
    ANALOG OUTPUT MODE 1, 818 cards
 */
 static int pcl818_ao_mode1(struct comedi_device *dev,
-                          struct comedi_subdevice *s, comedi_trig * it)
+                          struct comedi_subdevice *s, comedi_trig *it)
 {
        return pcl818_ao_mode13(1, dev, s, it);
 }
@@ -1134,7 +1131,7 @@ static int pcl818_ao_mode1(struct comedi_device *dev,
    ANALOG OUTPUT MODE 3, 818 cards
 */
 static int pcl818_ao_mode3(struct comedi_device *dev,
-                          struct comedi_subdevice *s, comedi_trig * it)
+                          struct comedi_subdevice *s, comedi_trig *it)
 {
        return pcl818_ao_mode13(3, dev, s, it);
 }
diff --git a/drivers/staging/comedi/drivers/pcm_common.c b/drivers/staging/comedi/drivers/pcm_common.c
deleted file mode 100644 (file)
index 8a718ae..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "../comedidev.h"
-
-#include "comedi_fc.h"
-#include "pcm_common.h"
-
-int comedi_pcm_cmdtest(struct comedi_device *dev,
-                      struct comedi_subdevice *s, struct comedi_cmd *cmd)
-{
-       int err = 0;
-
-       /* Step 1 : check if triggers are trivially valid */
-
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
-
-       if (err)
-               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->stop_src);
-
-       /* 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);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-
-       switch (cmd->stop_src) {
-       case TRIG_COUNT:
-               /* any count allowed */
-               break;
-       case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
-               break;
-       default:
-               break;
-       }
-
-       if (err)
-               return 3;
-
-       /* step 4: fix up any arguments */
-
-       /* if (err) return 4; */
-
-       return 0;
-}
-EXPORT_SYMBOL(comedi_pcm_cmdtest);
-
-MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcm_common.h b/drivers/staging/comedi/drivers/pcm_common.h
deleted file mode 100644 (file)
index cd4840c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _comedi_common_H
-#define _comedi_common_H
-
-extern int comedi_pcm_cmdtest(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_cmd *cmd);
-
-#endif
index 0882dafaf57bf229730f373dfba40b0fdaa518f9..48b049b7d36a2f646ed32812ef0c344c45bd17b2 100644 (file)
@@ -55,7 +55,6 @@ Configuration Options:
 
 #include <linux/pci.h>         /* for PCI devices */
 
-#define SDEV_NO ((int)(s - dev->subdevices))
 #define CHANS 8
 #define IOSIZE 16
 #define LSB(x) ((unsigned char)((x) & 0xff))
index 7522bfb6db0864fe45e643061d77e4f31bc156d0..d6d3d9584ea42fbe50c08a1a709703fa6bb54d95 100644 (file)
@@ -78,9 +78,10 @@ Configuration Options:
 
 #include <linux/interrupt.h>
 #include <linux/slab.h>
+#include <linux/pci.h>
+
 #include "../comedidev.h"
-#include "pcm_common.h"
-#include <linux/pci.h>         /* for PCI devices */
+#include "comedi_fc.h"
 
 /* This stuff is all from pcmuio.c -- it refers to the DIO subdevices only */
 #define CHANS_PER_PORT   8
@@ -93,7 +94,6 @@ Configuration Options:
 #define INTR_PORTS_PER_SUBDEV (INTR_CHANS_PER_ASIC/CHANS_PER_PORT)
 #define MAX_DIO_CHANS   (PORTS_PER_ASIC*1*CHANS_PER_PORT)
 #define MAX_ASICS       (MAX_DIO_CHANS/CHANS_PER_ASIC)
-#define SDEV_NO ((int)(s - dev->subdevices))
 #define CALC_N_DIO_SUBDEVS(nchans) ((nchans)/MAX_CHANS_PER_SUBDEV + (!!((nchans)%MAX_CHANS_PER_SUBDEV)) /*+ (nchans > INTR_CHANS_PER_ASIC ? 2 : 1)*/)
 /* IO Memory sizes */
 #define ASIC_IOSIZE (0x0B)
@@ -802,11 +802,59 @@ static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-static int
-pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-              struct comedi_cmd *cmd)
+static int pcmmio_cmdtest(struct comedi_device *dev,
+                         struct comedi_subdevice *s,
+                         struct comedi_cmd *cmd)
 {
-       return comedi_pcm_cmdtest(dev, s, cmd);
+       int err = 0;
+
+       /* Step 1 : check if triggers are trivially valid */
+
+       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+
+       if (err)
+               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->stop_src);
+
+       /* 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);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+
+       switch (cmd->stop_src) {
+       case TRIG_COUNT:
+               /* any count allowed */
+               break;
+       case TRIG_NONE:
+               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               break;
+       default:
+               break;
+       }
+
+       if (err)
+               return 3;
+
+       /* step 4: fix up any arguments */
+
+       /* if (err) return 4; */
+
+       return 0;
 }
 
 static int adc_wait_ready(unsigned long iobase)
index 31ea20c2d39e1ebe39df58a845b86d70b3787d68..b74431fba15179eb87bac38b44238ccfb5a24cf3 100644 (file)
@@ -77,10 +77,10 @@ Configuration Options:
 
 #include <linux/interrupt.h>
 #include <linux/slab.h>
-#include "../comedidev.h"
-#include "pcm_common.h"
+#include <linux/pci.h>
 
-#include <linux/pci.h>         /* for PCI devices */
+#include "../comedidev.h"
+#include "comedi_fc.h"
 
 #define CHANS_PER_PORT   8
 #define PORTS_PER_ASIC   6
@@ -92,7 +92,6 @@ Configuration Options:
 #define INTR_PORTS_PER_SUBDEV (INTR_CHANS_PER_ASIC/CHANS_PER_PORT)
 #define MAX_DIO_CHANS   (PORTS_PER_ASIC*2*CHANS_PER_PORT)
 #define MAX_ASICS       (MAX_DIO_CHANS/CHANS_PER_ASIC)
-#define SDEV_NO ((int)(s - dev->subdevices))
 #define CALC_N_SUBDEVS(nchans) ((nchans)/MAX_CHANS_PER_SUBDEV + (!!((nchans)%MAX_CHANS_PER_SUBDEV)) /*+ (nchans > INTR_CHANS_PER_ASIC ? 2 : 1)*/)
 /* IO Memory sizes */
 #define ASIC_IOSIZE (0x10)
@@ -740,11 +739,59 @@ static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        return 0;
 }
 
-static int
-pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-              struct comedi_cmd *cmd)
+static int pcmuio_cmdtest(struct comedi_device *dev,
+                         struct comedi_subdevice *s,
+                         struct comedi_cmd *cmd)
 {
-       return comedi_pcm_cmdtest(dev, s, cmd);
+       int err = 0;
+
+       /* Step 1 : check if triggers are trivially valid */
+
+       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+
+       if (err)
+               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->stop_src);
+
+       /* 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);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+
+       switch (cmd->stop_src) {
+       case TRIG_COUNT:
+               /* any count allowed */
+               break;
+       case TRIG_NONE:
+               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               break;
+       default:
+               break;
+       }
+
+       if (err)
+               return 3;
+
+       /* step 4: fix up any arguments */
+
+       /* if (err) return 4; */
+
+       return 0;
 }
 
 static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
index ef0cdaa7f02e4b75e2aa7886a70190a0c392de1b..55d8cc641967a807a3b5e85d8bb96f28e4edca17 100644 (file)
@@ -1038,9 +1038,6 @@ static int daqp_cs_resume(struct pcmcia_device *link)
 }
 
 /*====================================================================*/
-
-#ifdef MODULE
-
 static const struct pcmcia_device_id daqp_cs_id_table[] = {
        PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027),
        PCMCIA_DEVICE_NULL
@@ -1061,17 +1058,4 @@ static struct pcmcia_driver daqp_cs_driver = {
        .name = "quatech_daqp_cs",
 };
 
-int __init init_module(void)
-{
-       pcmcia_register_driver(&daqp_cs_driver);
-       comedi_driver_register(&driver_daqp);
-       return 0;
-}
-
-void __exit cleanup_module(void)
-{
-       comedi_driver_unregister(&driver_daqp);
-       pcmcia_unregister_driver(&daqp_cs_driver);
-}
-
-#endif
+module_comedi_pcmcia_driver(driver_daqp, daqp_cs_driver);
index 8d7c948a919cadec14235b9bf3c680187b528fd5..5581452764274b9f9130b2f42b59127ce7481486 100644 (file)
@@ -1420,11 +1420,6 @@ static int rtd520_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &rtd520_driver);
 }
 
-static void rtd520_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = {
        { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x7520) },
        { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x4520) },
@@ -1436,7 +1431,7 @@ static struct pci_driver rtd520_pci_driver = {
        .name           = "rtd520",
        .id_table       = rtd520_pci_table,
        .probe          = rtd520_pci_probe,
-       .remove         = rtd520_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(rtd520_driver, rtd520_pci_driver);
 
index 6dc1d281286550fd8ace7b748b365ac38b219b34..0c7221c6dfeab705b61bdb6c04c3809f73b5201d 100644 (file)
@@ -2836,11 +2836,6 @@ static int s626_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &s626_driver);
 }
 
-static void s626_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 /*
  * For devices with vendor:device id == 0x1131:0x7146 you must specify
  * also subvendor:subdevice ids, because otherwise it will conflict with
@@ -2857,7 +2852,7 @@ static struct pci_driver s626_pci_driver = {
        .name           = "s626",
        .id_table       = s626_pci_table,
        .probe          = s626_pci_probe,
-       .remove         = s626_pci_remove,
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(s626_driver, s626_pci_driver);
 
index e2d79700a615c6f9f0439060c3699cbb747b9586..0aad815f92f538f8ac3859688f78ab23e5c2a6a6 100644 (file)
@@ -707,15 +707,11 @@ static int skel_pci_probe(struct pci_dev *dev,
        return comedi_pci_auto_config(dev, &skel_driver);
 }
 
-static void skel_pci_remove(struct pci_dev *dev)
-{
-       comedi_pci_auto_unconfig(dev);
-}
-
 static struct pci_driver skel_pci_driver = {
+       .name = "dummy",
        .id_table = skel_pci_table,
        .probe = &skel_pci_probe,
-       .remove = &skel_pci_remove
+       .remove         = comedi_pci_auto_unconfig,
 };
 module_comedi_pci_driver(skel_driver, skel_pci_driver);
 #else
index 4dc09a210883ad4741cecb937653ea88d8006c2b..8932a510d96c7b27ac0338ad0743de64b14fd8c4 100644 (file)
@@ -42,7 +42,6 @@ MODULE_LICENSE("GPL");
 
 struct comedi_device *comedi_open(const char *filename)
 {
-       struct comedi_device_file_info *dev_file_info;
        struct comedi_device *dev;
        unsigned int minor;
 
@@ -54,12 +53,9 @@ struct comedi_device *comedi_open(const char *filename)
        if (minor >= COMEDI_NUM_BOARD_MINORS)
                return NULL;
 
-       dev_file_info = comedi_get_device_file_info(minor);
-       if (dev_file_info == NULL)
-               return NULL;
-       dev = dev_file_info->device;
+       dev = comedi_dev_from_minor(minor);
 
-       if (dev == NULL || !dev->attached)
+       if (!dev || !dev->attached)
                return NULL;
 
        if (!try_module_get(dev->driver->module))
index 01acbe97653c9a3da577a60731f2f90fdfeb23a3..362c214bcc0bb05d4b7113104a37d13f02d62616 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/proc_fs.h>
 #include <linux/string.h>
 
-#ifdef CONFIG_PROC_FS
 static int comedi_read(char *buf, char **start, off_t offset, int len,
                       int *eof, void *data)
 {
@@ -49,13 +48,10 @@ static int comedi_read(char *buf, char **start, off_t offset, int len,
                     "driver_name, board_name, n_subdevices");
 
        for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
-               struct comedi_device_file_info *dev_file_info =
-                   comedi_get_device_file_info(i);
-               struct comedi_device *dev;
+               struct comedi_device *dev = comedi_dev_from_minor(i);
 
-               if (dev_file_info == NULL)
+               if (!dev)
                        continue;
-               dev = dev_file_info->device;
 
                if (dev->attached) {
                        devices_q = 1;
@@ -95,4 +91,3 @@ void comedi_proc_cleanup(void)
 {
        remove_proc_entry("comedi", NULL);
 }
-#endif
index 2b068197ed44b227df59a6ae84dd094a91a4ed2a..b1151a28d8e33785ca7156a2698d33237b850680 100644 (file)
@@ -280,7 +280,7 @@ void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
     CSR_SIGNAL *signal;
     u16 interfaceTag = 0;
     CSR_MA_PACKET_REQUEST *req;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+    netInterface_priv_t *interfacePriv;
 
     if (priv == NULL) {
         return;
@@ -294,6 +294,8 @@ void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
         return;
     }
 
+    interfacePriv = priv->interfacePriv[interfaceTag];
+
     /* Initialize bulkdata to avoid os_net_buf is garbage */
     memset(&bulkdata, 0, sizeof(bulk_data_param_t));
 
@@ -1498,7 +1500,7 @@ void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
     u8 *daddr, *saddr;
     u16 interfaceTag = mareq->interfaceTag & 0x00ff;
     int queue;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+    netInterface_priv_t *interfacePriv;
 
     if (!mareq->frame || !priv || !priv->smepriv)
     {
@@ -1510,6 +1512,8 @@ void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
         unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
         return;
     }
+
+    interfacePriv = priv->interfacePriv[interfaceTag];
     /* get a pointer to dest & source Mac address */
     daddr = mareq->frame;
     saddr = (mareq->frame + ETH_ALEN);
@@ -2056,9 +2060,9 @@ void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
     CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg;
     CsrResult status = CSR_RESULT_SUCCESS;
     unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+    netInterface_priv_t *interfacePriv;
 
-    unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler \n");
+    unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler\n");
     if (priv == NULL)
     {
         unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
@@ -2071,6 +2075,8 @@ void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
         return;
     }
 
+    interfacePriv = priv->interfacePriv[req->interfaceTag];
+
     switch(interfacePriv->interfaceMode)
     {
         case CSR_WIFI_ROUTER_CTRL_MODE_AP:
@@ -2471,7 +2477,7 @@ void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv,CsrWifiFsmEvent* msg)
     CsrResult status = CSR_RESULT_SUCCESS;
     unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
     u32 handle = 0;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+    netInterface_priv_t *interfacePriv;
 
     unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n");
     if (priv == NULL)
@@ -2486,6 +2492,8 @@ void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv,CsrWifiFsmEvent* msg)
         return;
     }
 
+    interfacePriv = priv->interfacePriv[req->interfaceTag];
+
     switch(interfacePriv->interfaceMode)
     {
         case CSR_WIFI_ROUTER_CTRL_MODE_AP:
@@ -3036,21 +3044,24 @@ void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
     ul_client_t *client;
     CSR_SIGNAL signal;
     CSR_MA_PACKET_INDICATION *pkt_ind;
-    netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+    netInterface_priv_t *interfacePriv;
+
+    if (priv == NULL) {
+           unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n", __func__);
+           return;
+    }
+
+    if (priv->smepriv == NULL) {
+           unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n", __func__);
+           return;
+    }
+
+    interfacePriv = priv->interfacePriv[req->interfaceTag];
 
     if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
 
        unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
 
-        if (priv == NULL) {
-            unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n",__FUNCTION__);
-            return;
-        }
-
-        if (priv->smepriv == NULL) {
-             unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n",__FUNCTION__);
-             return;
-        }
 
         if (req->dataLength == 0 || req->data == NULL) {
              unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n",__FUNCTION__);
index 7c6c4138fc76dba99998e7be91420cc3a0d01035..76690374246cfb6c27c12a68770bc6e41a91ba0e 100644 (file)
@@ -1196,7 +1196,6 @@ void uf_send_pkt_to_encrypt(struct work_struct *work)
 
         if (pktBulkDataLength > 0) {
                    pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
-                   memset(pktBulkData, 0, pktBulkDataLength);
            } else {
                    unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
                    return;
index 0ff2865edec8d567688de5c2adb20fd7c9c514ad..a829b6231a6622bd72124ce4317f3c64bb243d83 100644 (file)
@@ -773,7 +773,9 @@ do_del_chan (struct net_device * musycc_dev, void *data)
     if (copy_from_user (&cp, data,
                         sizeof (struct sbecom_chan_param)))
         return -EFAULT;
-    sprintf (buf, CHANNAME "%d", cp.channum);
+    if (cp.channum > 999)
+        return -EINVAL;
+    snprintf (buf, sizeof(buf), CHANNAME "%d", cp.channum);
     if (!(dev = dev_get_by_name (&init_net, buf)))
         return -ENOENT;
     dev_put (dev);
index c214078a89e91a650fac11e763c7746bb09e8ba7..e09fc9cf318b397cb39c15101b32caf7add0d128 100644 (file)
@@ -181,13 +181,13 @@ static struct dgrp_proc_entry dgrp_dpa_table[] = {
 
 void dgrp_unregister_proc(void)
 {
-       unregister_proc_table(dgrp_table, dgrp_proc_dir_entry);
        net_entry_pointer = NULL;
        mon_entry_pointer = NULL;
        dpa_entry_pointer = NULL;
        ports_entry_pointer = NULL;
 
        if (dgrp_proc_dir_entry) {
+               unregister_proc_table(dgrp_table, dgrp_proc_dir_entry);
                remove_proc_entry(dgrp_proc_dir_entry->name,
                                  dgrp_proc_dir_entry->parent);
                dgrp_proc_dir_entry = NULL;
@@ -231,6 +231,8 @@ static void register_proc_table(struct dgrp_proc_entry *table,
 
        if (table == NULL)
                return;
+       if (root == NULL)
+               return;
 
        for (; table->id; table++) {
                /* Can't do anything without a proc name. */
index ca87ce9874b1986c89570db3a0ef941c2c9a3406..5882139d49afc3d204f175d00c81e97c0794220f 100644 (file)
 static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift)
 {
        int i;
-       int j;
        int offset1;
        int offset2;
        int factor;
@@ -142,7 +141,7 @@ static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift)
 
        /* asm("st:"); */
        n = ec->taps;
-       for (i = 0, j = offset2; i < n; i++, j++) {
+       for (i = 0; i < n; i++) {
                exp = *phist++ * factor;
                ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15);
        }
@@ -230,6 +229,7 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
 {
        struct oslec_state *ec;
        int i;
+       const int16_t *history;
 
        ec = kzalloc(sizeof(*ec), GFP_KERNEL);
        if (!ec)
@@ -239,15 +239,22 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
        ec->log2taps = top_bit(len);
        ec->curr_pos = ec->taps - 1;
 
-       for (i = 0; i < 2; i++) {
-               ec->fir_taps16[i] =
-                   kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
-               if (!ec->fir_taps16[i])
-                       goto error_oom;
-       }
+       ec->fir_taps16[0] =
+           kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
+       if (!ec->fir_taps16[0])
+               goto error_oom_0;
+
+       ec->fir_taps16[1] =
+           kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
+       if (!ec->fir_taps16[1])
+               goto error_oom_1;
 
-       fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps);
-       fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps);
+       history = fir16_create(&ec->fir_state, ec->fir_taps16[0], ec->taps);
+       if (!history)
+               goto error_state;
+       history = fir16_create(&ec->fir_state_bg, ec->fir_taps16[1], ec->taps);
+       if (!history)
+               goto error_state_bg;
 
        for (i = 0; i < 5; i++)
                ec->xvtx[i] = ec->yvtx[i] = ec->xvrx[i] = ec->yvrx[i] = 0;
@@ -257,7 +264,7 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
 
        ec->snapshot = kcalloc(ec->taps, sizeof(int16_t), GFP_KERNEL);
        if (!ec->snapshot)
-               goto error_oom;
+               goto error_snap;
 
        ec->cond_met = 0;
        ec->Pstates = 0;
@@ -270,10 +277,15 @@ struct oslec_state *oslec_create(int len, int adaption_mode)
 
        return ec;
 
-error_oom:
-       for (i = 0; i < 2; i++)
-               kfree(ec->fir_taps16[i]);
-
+error_snap:
+       fir16_free(&ec->fir_state_bg);
+error_state_bg:
+       fir16_free(&ec->fir_state);
+error_state:
+       kfree(ec->fir_taps16[1]);
+error_oom_1:
+       kfree(ec->fir_taps16[0]);
+error_oom_0:
        kfree(ec);
        return NULL;
 }
index 84bbcd48e26489753ed30581980c93864fb3ace3..4a7c302666ce9d5509e1ea19f58a651ddf3ac835 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * Agere Systems Inc.
+/* Agere Systems Inc.
  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
  *
  * Copyright Â© 2005 Agere Systems Inc.
@@ -50,7 +49,6 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
- *
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -102,8 +100,7 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere S
 #define INTERNAL_MEM_RX_OFFSET  0x1FF  /* 50%   Tx, 50%   Rx */
 
 /* ISR defines */
-/*
- * For interrupts, normal running is:
+/* For interrupts, normal running is:
  *       rxdma_xfr_done, phy_interrupt, mac_stat_interrupt,
  *       watchdog_interrupt & txdma_xfer_done
  *
@@ -139,19 +136,19 @@ MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere S
 #define NIC_SEND_HANG_THRESHOLD        0
 
 /* MP_TCB flags */
-#define fMP_DEST_MULTI                 0x00000001
-#define fMP_DEST_BROAD                 0x00000002
+#define FMP_DEST_MULTI                 0x00000001
+#define FMP_DEST_BROAD                 0x00000002
 
 /* MP_ADAPTER flags */
-#define fMP_ADAPTER_INTERRUPT_IN_USE   0x00000008
+#define FMP_ADAPTER_INTERRUPT_IN_USE   0x00000008
 
 /* MP_SHARED flags */
-#define fMP_ADAPTER_LOWER_POWER                0x00200000
+#define FMP_ADAPTER_LOWER_POWER                0x00200000
 
-#define fMP_ADAPTER_NON_RECOVER_ERROR  0x00800000
-#define fMP_ADAPTER_HARDWARE_ERROR     0x04000000
+#define FMP_ADAPTER_NON_RECOVER_ERROR  0x00800000
+#define FMP_ADAPTER_HARDWARE_ERROR     0x04000000
 
-#define fMP_ADAPTER_FAIL_SEND_MASK     0x3ff00000
+#define FMP_ADAPTER_FAIL_SEND_MASK     0x3ff00000
 
 /* Some offsets in PCI config space that are actually used. */
 #define ET1310_PCI_MAC_ADDRESS         0xA4
@@ -245,8 +242,7 @@ struct pkt_stat_desc {
 
 /* Typedefs for the RX DMA status word */
 
-/*
- * rx status word 0 holds part of the status bits of the Rx DMA engine
+/* rx status word 0 holds part of the status bits of the Rx DMA engine
  * that get copied out to memory by the ET-1310.  Word 0 is a 32 bit word
  * which contains the Free Buffer ring 0 and 1 available offset.
  *
@@ -256,8 +252,7 @@ struct pkt_stat_desc {
  * bit 26 Wrap flag for FBR0
  */
 
-/*
- * RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine
+/* RXSTAT_WORD1_t structure holds part of the status bits of the Rx DMA engine
  * that get copied out to memory by the ET-1310.  Word 3 is a 32 bit word
  * which contains the Packet Status Ring available offset.
  *
@@ -267,8 +262,7 @@ struct pkt_stat_desc {
  * bit 29-31 unused
  */
 
-/*
- * struct rx_status_block is a structure representing the status of the Rx
+/* struct rx_status_block is a structure representing the status of the Rx
  * DMA engine it sits in free memory, and is pointed to by 0x101c / 0x1020
  */
 struct rx_status_block {
@@ -276,8 +270,7 @@ struct rx_status_block {
        u32 word1;
 };
 
-/*
- * Structure for look-up table holding free buffer ring pointers, addresses
+/* Structure for look-up table holding free buffer ring pointers, addresses
  * and state.
  */
 struct fbr_lookup {
@@ -293,8 +286,7 @@ struct fbr_lookup {
        dma_addr_t       buffsize;
 };
 
-/*
- * struct rx_ring is the sructure representing the adaptor's local
+/* struct rx_ring is the sructure representing the adaptor's local
  * reference(s) to the rings
  */
 struct rx_ring {
@@ -317,8 +309,7 @@ struct rx_ring {
 };
 
 /* TX defines */
-/*
- * word 2 of the control bits in the Tx Descriptor ring for the ET-1310
+/* word 2 of the control bits in the Tx Descriptor ring for the ET-1310
  *
  * 0-15: length of packet
  * 16-27: VLAN tag
@@ -344,6 +335,10 @@ struct rx_ring {
  * 14: UDP checksum assist
  */
 
+#define TXDESC_FLAG_LASTPKT            0x0001
+#define TXDESC_FLAG_FIRSTPKT           0x0002
+#define TXDESC_FLAG_INTPROC            0x0004
+
 /* struct tx_desc represents each descriptor on the ring */
 struct tx_desc {
        u32 addr_hi;
@@ -352,8 +347,7 @@ struct tx_desc {
        u32 flags;      /* data (detailed above) */
 };
 
-/*
- * The status of the Tx DMA engine it sits in free memory, and is pointed to
+/* The status of the Tx DMA engine it sits in free memory, and is pointed to
  * by 0x101c / 0x1020. This is a DMA10 type
  */
 
@@ -402,15 +396,13 @@ struct tx_ring {
        int since_irq;
 };
 
-/*
- * Do not change these values: if changed, then change also in respective
+/* Do not change these values: if changed, then change also in respective
  * TXdma and Rxdma engines
  */
 #define NUM_DESC_PER_RING_TX         512    /* TX Do not change these values */
 #define NUM_TCB                      64
 
-/*
- * These values are all superseded by registry entries to facilitate tuning.
+/* These values are all superseded by registry entries to facilitate tuning.
  * Once the desired performance has been achieved, the optimal registry values
  * should be re-populated to these #defines:
  */
@@ -555,8 +547,7 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status)
        u32 reg;
        int i;
 
-       /*
-        * 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and
+       /* 1. Check LBCIF Status Register for bits 6 & 3:2 all equal to 0 and
         *    bits 7,1:0 both equal to 1, at least once after reset.
         *    Subsequent operations need only to check that bits 1:0 are equal
         *    to 1 prior to starting a single byte read/write
@@ -577,9 +568,7 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status)
        return -ETIMEDOUT;
 }
 
-
-/**
- * eeprom_write - Write a byte to the ET1310's EEPROM
+/* eeprom_write - Write a byte to the ET1310's EEPROM
  * @adapter: pointer to our private adapter structure
  * @addr: the address to write
  * @data: the value to write
@@ -597,8 +586,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
        u32 status;
        u32 val = 0;
 
-       /*
-        * For an EEPROM, an I2C single byte write is defined as a START
+       /* For an EEPROM, an I2C single byte write is defined as a START
         * condition followed by the device address, EEPROM address, one byte
         * of data and a STOP condition.  The STOP condition will trigger the
         * EEPROM's internally timed write cycle to the nonvolatile memory.
@@ -610,12 +598,11 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
        if (err)
                return err;
 
-        /*
-        * 2. Write to the LBCIF Control Register:  bit 7=1, bit 6=1, bit 3=0,
-        *    and bits 1:0 both =0.  Bit 5 should be set according to the
-        *    type of EEPROM being accessed (1=two byte addressing, 0=one
-        *    byte addressing).
-        */
+        /* 2. Write to the LBCIF Control Register:  bit 7=1, bit 6=1, bit 3=0,
+         *    and bits 1:0 both =0.  Bit 5 should be set according to the
+         *    type of EEPROM being accessed (1=two byte addressing, 0=one
+         *    byte addressing).
+         */
        if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
                        LBCIF_CONTROL_LBCIF_ENABLE | LBCIF_CONTROL_I2C_WRITE))
                return -EIO;
@@ -628,14 +615,12 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
                /* Write the address to the LBCIF Address Register */
                if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr))
                        break;
-               /*
-                * Write the data to the LBCIF Data Register (the I2C write
+               /* Write the data to the LBCIF Data Register (the I2C write
                 * will begin).
                 */
                if (pci_write_config_byte(pdev, LBCIF_DATA_REGISTER, data))
                        break;
-               /*
-                * Monitor bit 1:0 of the LBCIF Status Register.  When bits
+               /* Monitor bit 1:0 of the LBCIF Status Register.  When bits
                 * 1:0 are both equal to 1, the I2C write has completed and the
                 * internal write cycle of the EEPROM is about to start.
                 * (bits 1:0 = 01 is a legal state while waiting from both
@@ -646,8 +631,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
                if (err < 0)
                        return 0;
 
-               /*
-                * Check bit 3 of the LBCIF Status Register.  If  equal to 1,
+               /* Check bit 3 of the LBCIF Status Register.  If  equal to 1,
                 * an error has occurred.Don't break here if we are revision
                 * 1, this is so we do a blind write for load bug.
                 */
@@ -655,8 +639,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
                        && adapter->pdev->revision == 0)
                        break;
 
-               /*
-                * Check bit 2 of the LBCIF Status Register.  If equal to 1 an
+               /* Check bit 2 of the LBCIF Status Register.  If equal to 1 an
                 * ACK error has occurred on the address phase of the write.
                 * This could be due to an actual hardware failure or the
                 * EEPROM may still be in its internal write cycle from a
@@ -664,8 +647,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
                  *repeated later.
                 */
                if (status & LBCIF_STATUS_ACK_ERROR) {
-                       /*
-                        * This could be due to an actual hardware failure
+                       /* This could be due to an actual hardware failure
                         * or the EEPROM may still be in its internal write
                         * cycle from a previous write. This write operation
                         * was ignored and must be repeated later.
@@ -678,8 +660,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
                break;
        }
 
-       /*
-        * Set bit 6 of the LBCIF Control Register = 0.
+       /* Set bit 6 of the LBCIF Control Register = 0.
         */
        udelay(10);
 
@@ -708,8 +689,7 @@ static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
        return writeok ? 0 : -EIO;
 }
 
-/**
- * eeprom_read - Read a byte from the ET1310's EEPROM
+/* eeprom_read - Read a byte from the ET1310's EEPROM
  * @adapter: pointer to our private adapter structure
  * @addr: the address from which to read
  * @pdata: a pointer to a byte in which to store the value of the read
@@ -724,16 +704,14 @@ static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata)
        int err;
        u32 status;
 
-       /*
-        * A single byte read is similar to the single byte write, with the
+       /* A single byte read is similar to the single byte write, with the
         * exception of the data flow:
         */
 
        err = eeprom_wait_ready(pdev, NULL);
        if (err)
                return err;
-       /*
-        * Write to the LBCIF Control Register:  bit 7=1, bit 6=0, bit 3=0,
+       /* Write to the LBCIF Control Register:  bit 7=1, bit 6=0, bit 3=0,
         * and bits 1:0 both =0.  Bit 5 should be set according to the type
         * of EEPROM being accessed (1=two byte addressing, 0=one byte
         * addressing).
@@ -741,27 +719,23 @@ static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata)
        if (pci_write_config_byte(pdev, LBCIF_CONTROL_REGISTER,
                                  LBCIF_CONTROL_LBCIF_ENABLE))
                return -EIO;
-       /*
-        * Write the address to the LBCIF Address Register (I2C read will
+       /* Write the address to the LBCIF Address Register (I2C read will
         * begin).
         */
        if (pci_write_config_dword(pdev, LBCIF_ADDRESS_REGISTER, addr))
                return -EIO;
-       /*
-        * Monitor bit 0 of the LBCIF Status Register.  When = 1, I2C read
+       /* Monitor bit 0 of the LBCIF Status Register.  When = 1, I2C read
         * is complete. (if bit 1 =1 and bit 0 stays = 0, a hardware failure
         * has occurred).
         */
        err = eeprom_wait_ready(pdev, &status);
        if (err < 0)
                return err;
-       /*
-        * Regardless of error status, read data byte from LBCIF Data
+       /* Regardless of error status, read data byte from LBCIF Data
         * Register.
         */
        *pdata = err;
-       /*
-        * Check bit 2 of the LBCIF Status Register.  If = 1,
+       /* Check bit 2 of the LBCIF Status Register.  If = 1,
         * then an error has occurred.
         */
        return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0;
@@ -775,13 +749,12 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter)
        /* We first need to check the EEPROM Status code located at offset
         * 0xB2 of config space
         */
-       pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS,
-                                     &eestatus);
+       pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus);
 
        /* THIS IS A WORKAROUND:
         * I need to call this function twice to get my card in a
         * LG M1 Express Dual running. I tried also a msleep before this
-        * function, because I thought there could be some time condidions
+        * function, because I thought there could be some time conditions
         * but it didn't work. Call the whole function twice also work.
         */
        if (pci_read_config_byte(pdev, ET1310_PCI_EEPROM_STATUS, &eestatus)) {
@@ -836,36 +809,35 @@ static int et131x_init_eeprom(struct et131x_adapter *adapter)
        return 0;
 }
 
-/**
- * et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310.
+/* et131x_rx_dma_enable - re-start of Rx_DMA on the ET1310.
  * @adapter: pointer to our adapter structure
  */
 static void et131x_rx_dma_enable(struct et131x_adapter *adapter)
 {
        /* Setup the receive dma configuration register for normal operation */
-       u32 csr =  0x2000;      /* FBR1 enable */
+       u32 csr =  ET_RXDMA_CSR_FBR1_ENABLE;
 
        if (adapter->rx_ring.fbr[1]->buffsize == 4096)
-               csr |= 0x0800;
+               csr |= ET_RXDMA_CSR_FBR1_SIZE_LO;
        else if (adapter->rx_ring.fbr[1]->buffsize == 8192)
-               csr |= 0x1000;
+               csr |= ET_RXDMA_CSR_FBR1_SIZE_HI;
        else if (adapter->rx_ring.fbr[1]->buffsize == 16384)
-               csr |= 0x1800;
+               csr |= ET_RXDMA_CSR_FBR1_SIZE_LO | ET_RXDMA_CSR_FBR1_SIZE_HI;
 
-       csr |= 0x0400;          /* FBR0 enable */
+       csr |= ET_RXDMA_CSR_FBR0_ENABLE;
        if (adapter->rx_ring.fbr[0]->buffsize == 256)
-               csr |= 0x0100;
+               csr |= ET_RXDMA_CSR_FBR0_SIZE_LO;
        else if (adapter->rx_ring.fbr[0]->buffsize == 512)
-               csr |= 0x0200;
+               csr |= ET_RXDMA_CSR_FBR0_SIZE_HI;
        else if (adapter->rx_ring.fbr[0]->buffsize == 1024)
-               csr |= 0x0300;
+               csr |= ET_RXDMA_CSR_FBR0_SIZE_LO | ET_RXDMA_CSR_FBR0_SIZE_HI;
        writel(csr, &adapter->regs->rxdma.csr);
 
        csr = readl(&adapter->regs->rxdma.csr);
-       if (csr & 0x00020000) {
+       if (csr & ET_RXDMA_CSR_HALT_STATUS) {
                udelay(5);
                csr = readl(&adapter->regs->rxdma.csr);
-               if (csr & 0x00020000) {
+               if (csr & ET_RXDMA_CSR_HALT_STATUS) {
                        dev_err(&adapter->pdev->dev,
                            "RX Dma failed to exit halt state.  CSR 0x%08x\n",
                                csr);
@@ -873,28 +845,27 @@ static void et131x_rx_dma_enable(struct et131x_adapter *adapter)
        }
 }
 
-/**
- * et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310
+/* et131x_rx_dma_disable - Stop of Rx_DMA on the ET1310
  * @adapter: pointer to our adapter structure
  */
 static void et131x_rx_dma_disable(struct et131x_adapter *adapter)
 {
        u32 csr;
        /* Setup the receive dma configuration register */
-       writel(0x00002001, &adapter->regs->rxdma.csr);
+       writel(ET_RXDMA_CSR_HALT | ET_RXDMA_CSR_FBR1_ENABLE,
+              &adapter->regs->rxdma.csr);
        csr = readl(&adapter->regs->rxdma.csr);
-       if ((csr & 0x00020000) == 0) {  /* Check halt status (bit 17) */
+       if (!(csr & ET_RXDMA_CSR_HALT_STATUS)) {
                udelay(5);
                csr = readl(&adapter->regs->rxdma.csr);
-               if ((csr & 0x00020000) == 0)
+               if (!(csr & ET_RXDMA_CSR_HALT_STATUS))
                        dev_err(&adapter->pdev->dev,
-                       "RX Dma failed to enter halt state. CSR 0x%08x\n",
-                               csr);
+                             "RX Dma failed to enter halt state. CSR 0x%08x\n",
+                             csr);
        }
 }
 
-/**
- * et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310.
+/* et131x_tx_dma_enable - re-start of Tx_DMA on the ET1310.
  * @adapter: pointer to our adapter structure
  *
  * Mainly used after a return to the D0 (full-power) state from a lower state.
@@ -918,8 +889,7 @@ static inline void add_12bit(u32 *v, int n)
        *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
 }
 
-/**
- * et1310_config_mac_regs1 - Initialize the first part of MAC regs
+/* et1310_config_mac_regs1 - Initialize the first part of MAC regs
  * @adapter: pointer to our adapter structure
  */
 static void et1310_config_mac_regs1(struct et131x_adapter *adapter)
@@ -932,7 +902,10 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter)
        /* First we need to reset everything.  Write to MAC configuration
         * register 1 to perform reset.
         */
-       writel(0xC00F0000, &macregs->cfg1);
+       writel(ET_MAC_CFG1_SOFT_RESET | ET_MAC_CFG1_SIM_RESET  |
+              ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC |
+              ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC,
+              &macregs->cfg1);
 
        /* Next lets configure the MAC Inter-packet gap register */
        ipg = 0x38005860;               /* IPG1 0x38 IPG2 0x58 B2B 0x60 */
@@ -947,7 +920,7 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter)
        writel(0, &macregs->if_ctrl);
 
        /* Let's move on to setting up the mii management configuration */
-       writel(0x07, &macregs->mii_mgmt_cfg);   /* Clock reset 0x7 */
+       writel(ET_MAC_MIIMGMT_CLK_RST, &macregs->mii_mgmt_cfg);
 
        /* Next lets configure the MAC Station Address register.  These
         * values are read from the EEPROM during initialization and stored
@@ -978,8 +951,7 @@ static void et1310_config_mac_regs1(struct et131x_adapter *adapter)
        writel(0, &macregs->cfg1);
 }
 
-/**
- * et1310_config_mac_regs2 - Initialize the second part of MAC regs
+/* et1310_config_mac_regs2 - Initialize the second part of MAC regs
  * @adapter: pointer to our adapter structure
  */
 static void et1310_config_mac_regs2(struct et131x_adapter *adapter)
@@ -998,38 +970,44 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter)
        ifctrl = readl(&mac->if_ctrl);
 
        /* Set up the if mode bits */
-       cfg2 &= ~0x300;
+       cfg2 &= ~ET_MAC_CFG2_IFMODE_MASK;
        if (phydev && phydev->speed == SPEED_1000) {
-               cfg2 |= 0x200;
+               cfg2 |= ET_MAC_CFG2_IFMODE_1000;
                /* Phy mode bit */
-               ifctrl &= ~(1 << 24);
+               ifctrl &= ~ET_MAC_IFCTRL_PHYMODE;
        } else {
-               cfg2 |= 0x100;
-               ifctrl |= (1 << 24);
+               cfg2 |= ET_MAC_CFG2_IFMODE_100;
+               ifctrl |= ET_MAC_IFCTRL_PHYMODE;
        }
 
        /* We need to enable Rx/Tx */
-       cfg1 |= CFG1_RX_ENABLE | CFG1_TX_ENABLE | CFG1_TX_FLOW;
+       cfg1 |= ET_MAC_CFG1_RX_ENABLE | ET_MAC_CFG1_TX_ENABLE |
+                                                       ET_MAC_CFG1_TX_FLOW;
        /* Initialize loop back to off */
-       cfg1 &= ~(CFG1_LOOPBACK | CFG1_RX_FLOW);
+       cfg1 &= ~(ET_MAC_CFG1_LOOPBACK | ET_MAC_CFG1_RX_FLOW);
        if (adapter->flowcontrol == FLOW_RXONLY ||
                                adapter->flowcontrol == FLOW_BOTH)
-               cfg1 |= CFG1_RX_FLOW;
+               cfg1 |= ET_MAC_CFG1_RX_FLOW;
        writel(cfg1, &mac->cfg1);
 
        /* Now we need to initialize the MAC Configuration 2 register */
        /* preamble 7, check length, huge frame off, pad crc, crc enable
-          full duplex off */
-       cfg2 |= 0x7016;
-       cfg2 &= ~0x0021;
+        * full duplex off
+        */
+       cfg2 |= 0x7 << ET_MAC_CFG2_PREAMBLE_SHIFT;
+       cfg2 |= ET_MAC_CFG2_IFMODE_LEN_CHECK;
+       cfg2 |= ET_MAC_CFG2_IFMODE_PAD_CRC;
+       cfg2 |= ET_MAC_CFG2_IFMODE_CRC_ENABLE;
+       cfg2 &= ~ET_MAC_CFG2_IFMODE_HUGE_FRAME;
+       cfg2 &= ~ET_MAC_CFG2_IFMODE_FULL_DPLX;
 
        /* Turn on duplex if needed */
        if (phydev && phydev->duplex == DUPLEX_FULL)
-               cfg2 |= 0x01;
+               cfg2 |= ET_MAC_CFG2_IFMODE_FULL_DPLX;
 
-       ifctrl &= ~(1 << 26);
+       ifctrl &= ~ET_MAC_IFCTRL_GHDMODE;
        if (phydev && phydev->duplex == DUPLEX_HALF)
-               ifctrl |= (1<<26);      /* Enable ghd */
+               ifctrl |= ET_MAC_IFCTRL_GHDMODE;
 
        writel(ifctrl, &mac->if_ctrl);
        writel(cfg2, &mac->cfg2);
@@ -1038,7 +1016,7 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter)
                udelay(10);
                delay++;
                cfg1 = readl(&mac->cfg1);
-       } while ((cfg1 & CFG1_WAIT) != CFG1_WAIT && delay < 100);
+       } while ((cfg1 & ET_MAC_CFG1_WAIT) != ET_MAC_CFG1_WAIT && delay < 100);
 
        if (delay == 100) {
                dev_warn(&adapter->pdev->dev,
@@ -1047,18 +1025,17 @@ static void et1310_config_mac_regs2(struct et131x_adapter *adapter)
        }
 
        /* Enable txmac */
-       ctl |= 0x09;    /* TX mac enable, FC disable */
+       ctl |= ET_TX_CTRL_TXMAC_ENABLE | ET_TX_CTRL_FC_DISABLE;
        writel(ctl, &adapter->regs->txmac.ctl);
 
        /* Ready to start the RXDMA/TXDMA engine */
-       if (adapter->flags & fMP_ADAPTER_LOWER_POWER) {
+       if (adapter->flags & FMP_ADAPTER_LOWER_POWER) {
                et131x_rx_dma_enable(adapter);
                et131x_tx_dma_enable(adapter);
        }
 }
 
-/**
- * et1310_in_phy_coma - check if the device is in phy coma
+/* et1310_in_phy_coma - check if the device is in phy coma
  * @adapter: pointer to our adapter structure
  *
  * Returns 0 if the device is not in phy coma, 1 if it is in phy coma
@@ -1139,19 +1116,19 @@ static void et1310_setup_device_for_unicast(struct et131x_adapter *adapter)
         * Set up unicast packet filter reg 3 to be the octets 2 - 5 of the
         * MAC address for first address
         */
-       uni_pf3 = (adapter->addr[0] << ET_UNI_PF_ADDR2_1_SHIFT) |
-                 (adapter->addr[1] << ET_UNI_PF_ADDR2_2_SHIFT) |
-                 (adapter->addr[0] << ET_UNI_PF_ADDR1_1_SHIFT) |
+       uni_pf3 = (adapter->addr[0] << ET_RX_UNI_PF_ADDR2_1_SHIFT) |
+                 (adapter->addr[1] << ET_RX_UNI_PF_ADDR2_2_SHIFT) |
+                 (adapter->addr[0] << ET_RX_UNI_PF_ADDR1_1_SHIFT) |
                   adapter->addr[1];
 
-       uni_pf2 = (adapter->addr[2] << ET_UNI_PF_ADDR2_3_SHIFT) |
-                 (adapter->addr[3] << ET_UNI_PF_ADDR2_4_SHIFT) |
-                 (adapter->addr[4] << ET_UNI_PF_ADDR2_5_SHIFT) |
+       uni_pf2 = (adapter->addr[2] << ET_RX_UNI_PF_ADDR2_3_SHIFT) |
+                 (adapter->addr[3] << ET_RX_UNI_PF_ADDR2_4_SHIFT) |
+                 (adapter->addr[4] << ET_RX_UNI_PF_ADDR2_5_SHIFT) |
                   adapter->addr[5];
 
-       uni_pf1 = (adapter->addr[2] << ET_UNI_PF_ADDR1_3_SHIFT) |
-                 (adapter->addr[3] << ET_UNI_PF_ADDR1_4_SHIFT) |
-                 (adapter->addr[4] << ET_UNI_PF_ADDR1_5_SHIFT) |
+       uni_pf1 = (adapter->addr[2] << ET_RX_UNI_PF_ADDR1_3_SHIFT) |
+                 (adapter->addr[3] << ET_RX_UNI_PF_ADDR1_4_SHIFT) |
+                 (adapter->addr[4] << ET_RX_UNI_PF_ADDR1_5_SHIFT) |
                   adapter->addr[5];
 
        pm_csr = readl(&adapter->regs->global.pm_csr);
@@ -1208,13 +1185,13 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
        writel(0, &rxmac->mask4_word3);
 
        /* Lets setup the WOL Source Address */
-       sa_lo = (adapter->addr[2] << ET_WOL_LO_SA3_SHIFT) |
-               (adapter->addr[3] << ET_WOL_LO_SA4_SHIFT) |
-               (adapter->addr[4] << ET_WOL_LO_SA5_SHIFT) |
+       sa_lo = (adapter->addr[2] << ET_RX_WOL_LO_SA3_SHIFT) |
+               (adapter->addr[3] << ET_RX_WOL_LO_SA4_SHIFT) |
+               (adapter->addr[4] << ET_RX_WOL_LO_SA5_SHIFT) |
                 adapter->addr[5];
        writel(sa_lo, &rxmac->sa_lo);
 
-       sa_hi = (u32) (adapter->addr[0] << ET_WOL_HI_SA1_SHIFT) |
+       sa_hi = (u32) (adapter->addr[0] << ET_RX_WOL_HI_SA1_SHIFT) |
                       adapter->addr[1];
        writel(sa_hi, &rxmac->sa_hi);
 
@@ -1224,7 +1201,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
        /* Let's initialize the Unicast Packet filtering address */
        if (adapter->packet_filter & ET131X_PACKET_TYPE_DIRECTED) {
                et1310_setup_device_for_unicast(adapter);
-               pf_ctrl |= 4;   /* Unicast filter */
+               pf_ctrl |= ET_RX_PFCTRL_UNICST_FILTER_ENABLE;
        } else {
                writel(0, &rxmac->uni_pf_addr1);
                writel(0, &rxmac->uni_pf_addr2);
@@ -1233,13 +1210,13 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 
        /* Let's initialize the Multicast hash */
        if (!(adapter->packet_filter & ET131X_PACKET_TYPE_ALL_MULTICAST)) {
-               pf_ctrl |= 2;   /* Multicast filter */
+               pf_ctrl |= ET_RX_PFCTRL_MLTCST_FILTER_ENABLE;
                et1310_setup_device_for_multicast(adapter);
        }
 
        /* Runt packet filtering.  Didn't work in version A silicon. */
-       pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << 16;
-       pf_ctrl |= 8;   /* Fragment filter */
+       pf_ctrl |= (NIC_MIN_PACKET_SIZE + 4) << ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT;
+       pf_ctrl |= ET_RX_PFCTRL_FRAG_FILTER_ENABLE;
 
        if (adapter->registry_jumbo_packet > 8192)
                /* In order to transmit jumbo packets greater than 8k, the
@@ -1290,7 +1267,7 @@ static void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
         * but we still leave the packet filter on.
         */
        writel(pf_ctrl, &rxmac->pf_ctrl);
-       writel(0x9, &rxmac->ctrl);
+       writel(ET_RX_CTRL_RXMAC_ENABLE | ET_RX_CTRL_WOL_DISABLE, &rxmac->ctrl);
 }
 
 static void et1310_config_txmac_regs(struct et131x_adapter *adapter)
@@ -1372,8 +1349,7 @@ static void et1310_config_macstat_regs(struct et131x_adapter *adapter)
        writel(0xFFFE7E8B, &macstat->carry_reg2_mask);
 }
 
-/**
- * et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC
+/* et131x_phy_mii_read - Read from the PHY through the MII Interface on the MAC
  * @adapter: pointer to our private adapter structure
  * @addr: the address of the transceiver
  * @reg: the register to read
@@ -1401,7 +1377,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
        writel(0, &mac->mii_mgmt_cmd);
 
        /* Set up the register we need to read from on the correct PHY */
-       writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
+       writel(ET_MAC_MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
 
        writel(0x1, &mac->mii_mgmt_cmd);
 
@@ -1409,7 +1385,7 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
                udelay(50);
                delay++;
                mii_indicator = readl(&mac->mii_mgmt_indicator);
-       } while ((mii_indicator & MGMT_WAIT) && delay < 50);
+       } while ((mii_indicator & ET_MAC_MGMT_WAIT) && delay < 50);
 
        /* If we hit the max delay, we could not read the register */
        if (delay == 50) {
@@ -1422,8 +1398,9 @@ static int et131x_phy_mii_read(struct et131x_adapter *adapter, u8 addr,
        }
 
        /* If we hit here we were able to read the register and we need to
-        * return the value to the caller */
-       *value = readl(&mac->mii_mgmt_stat) & 0xFFFF;
+        * return the value to the caller
+        */
+       *value = readl(&mac->mii_mgmt_stat) & ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK;
 
        /* Stop the read operation */
        writel(0, &mac->mii_mgmt_cmd);
@@ -1447,8 +1424,7 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value)
        return et131x_phy_mii_read(adapter, phydev->addr, reg, value);
 }
 
-/**
- * et131x_mii_write - Write to a PHY register through the MII interface of the MAC
+/* et131x_mii_write - Write to a PHY reg through the MII interface of the MAC
  * @adapter: pointer to our private adapter structure
  * @reg: the register to read
  * @value: 16-bit value to write
@@ -1483,7 +1459,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
        writel(0, &mac->mii_mgmt_cmd);
 
        /* Set up the register we need to write to on the correct PHY */
-       writel(MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
+       writel(ET_MAC_MII_ADDR(addr, reg), &mac->mii_mgmt_addr);
 
        /* Add the value to write to the registers to the mac */
        writel(value, &mac->mii_mgmt_ctrl);
@@ -1492,7 +1468,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
                udelay(50);
                delay++;
                mii_indicator = readl(&mac->mii_mgmt_indicator);
-       } while ((mii_indicator & MGMT_BUSY) && delay < 100);
+       } while ((mii_indicator & ET_MAC_MGMT_BUSY) && delay < 100);
 
        /* If we hit the max delay, we could not write the register */
        if (delay == 100) {
@@ -1512,8 +1488,7 @@ static int et131x_mii_write(struct et131x_adapter *adapter, u8 reg, u16 value)
        /* Stop the write operation */
        writel(0, &mac->mii_mgmt_cmd);
 
-       /*
-        * set the registers we touched back to the state at which we entered
+       /* set the registers we touched back to the state at which we entered
         * this function
         */
        writel(mii_addr, &mac->mii_mgmt_addr);
@@ -1528,7 +1503,7 @@ static void et1310_phy_access_mii_bit(struct et131x_adapter *adapter,
                                      u8 *value)
 {
        u16 reg;
-       u16 mask = 0x0001 << bitnum;
+       u16 mask = 1 << bitnum;
 
        /* Read the requested register */
        et131x_mii_read(adapter, regnum, &reg);
@@ -1579,7 +1554,8 @@ static void et1310_config_flow_control(struct et131x_adapter *adapter)
                           (remote_async_pause == TRUEPHY_BIT_CLEAR)) {
                        adapter->flowcontrol = FLOW_NONE;
                } else {/* if (remote_pause == TRUEPHY_CLEAR_BIT &&
-                              remote_async_pause == TRUEPHY_SET_BIT) */
+                        *     remote_async_pause == TRUEPHY_SET_BIT)
+                        */
                        if (adapter->wanted_flow == FLOW_BOTH)
                                adapter->flowcontrol = FLOW_RXONLY;
                        else
@@ -1588,8 +1564,7 @@ static void et1310_config_flow_control(struct et131x_adapter *adapter)
        }
 }
 
-/**
- * et1310_update_macstat_host_counters - Update the local copy of the statistics
+/* et1310_update_macstat_host_counters - Update the local copy of the statistics
  * @adapter: pointer to the adapter structure
  */
 static void et1310_update_macstat_host_counters(struct et131x_adapter *adapter)
@@ -1616,8 +1591,7 @@ static void et1310_update_macstat_host_counters(struct et131x_adapter *adapter)
        stats->rx_other_errs        += readl(&macstat->rx_fragment_packets);
 }
 
-/**
- * et1310_handle_macstat_interrupt
+/* et1310_handle_macstat_interrupt
  * @adapter: pointer to the adapter structure
  *
  * One of the MACSTAT counters has wrapped.  Update the local copy of
@@ -1708,8 +1682,7 @@ static int et131x_mdio_reset(struct mii_bus *bus)
        return 0;
 }
 
-/**
- *     et1310_phy_power_down   -       PHY power control
+/*     et1310_phy_power_down   -       PHY power control
  *     @adapter: device to control
  *     @down: true for off/false for back on
  *
@@ -1729,8 +1702,7 @@ static void et1310_phy_power_down(struct et131x_adapter *adapter, bool down)
        et131x_mii_write(adapter, MII_BMCR, data);
 }
 
-/**
- * et131x_xcvr_init - Init the phy if we are setting it into force mode
+/* et131x_xcvr_init - Init the phy if we are setting it into force mode
  * @adapter: pointer to our private adapter structure
  *
  */
@@ -1761,8 +1733,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
        }
 }
 
-/**
- * et131x_configure_global_regs        - configure JAGCore global regs
+/* et131x_configure_global_regs        - configure JAGCore global regs
  * @adapter: pointer to our adapter structure
  *
  * Used to configure the global registers on the JAGCore
@@ -1808,8 +1779,7 @@ static void et131x_configure_global_regs(struct et131x_adapter *adapter)
        writel(0, &regs->watchdog_timer);
 }
 
-/**
- * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
+/* et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
  * @adapter: pointer to our adapter structure
  */
 static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
@@ -1839,7 +1809,7 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
        writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des);
        writel(0, &rx_dma->psr_full_offset);
 
-       psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
+       psr_num_des = readl(&rx_dma->psr_num_des) & ET_RXDMA_PSR_NUM_DES_MASK;
        writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
               &rx_dma->psr_min_des);
 
@@ -1849,11 +1819,11 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
        rx_local->local_psr_full = 0;
 
        for (id = 0; id < NUM_FBRS; id++) {
-               u32 *num_des;
-               u32 *full_offset;
-               u32 *min_des;
-               u32 *base_hi;
-               u32 *base_lo;
+               u32 __iomem *num_des;
+               u32 __iomem *full_offset;
+               u32 __iomem *min_des;
+               u32 __iomem *base_hi;
+               u32 __iomem *base_lo;
 
                if (id == 0) {
                        num_des = &rx_dma->fbr0_num_des;
@@ -1916,8 +1886,7 @@ static void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
        spin_unlock_irqrestore(&adapter->rcv_lock, flags);
 }
 
-/**
- * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
+/* et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
  * @adapter: pointer to our private adapter structure
  *
  * Configure the transmit engine with the ring buffers we have created
@@ -1948,8 +1917,7 @@ static void et131x_config_tx_dma_regs(struct et131x_adapter *adapter)
        adapter->tx_ring.send_idx = 0;
 }
 
-/**
- * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
+/* et131x_adapter_setup - Set the adapter up as per cassini+ documentation
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
@@ -1977,23 +1945,29 @@ static void et131x_adapter_setup(struct et131x_adapter *adapter)
        et131x_xcvr_init(adapter);
 }
 
-/**
- * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
+/* et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
  * @adapter: pointer to our private adapter structure
  */
 static void et131x_soft_reset(struct et131x_adapter *adapter)
 {
-       /* Disable MAC Core */
-       writel(0xc00f0000, &adapter->regs->mac.cfg1);
+       u32 reg;
 
-       /* Set everything to a reset value */
-       writel(0x7F, &adapter->regs->global.sw_reset);
-       writel(0x000f0000, &adapter->regs->mac.cfg1);
-       writel(0x00000000, &adapter->regs->mac.cfg1);
+       /* Disable MAC Core */
+       reg = ET_MAC_CFG1_SOFT_RESET | ET_MAC_CFG1_SIM_RESET |
+             ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC |
+             ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC;
+       writel(reg, &adapter->regs->mac.cfg1);
+
+       reg = ET_RESET_ALL;
+       writel(reg, &adapter->regs->global.sw_reset);
+
+       reg = ET_MAC_CFG1_RESET_RXMC | ET_MAC_CFG1_RESET_TXMC |
+             ET_MAC_CFG1_RESET_RXFUNC | ET_MAC_CFG1_RESET_TXFUNC;
+       writel(reg, &adapter->regs->mac.cfg1);
+       writel(0, &adapter->regs->mac.cfg1);
 }
 
-/**
- *     et131x_enable_interrupts        -       enable interrupt
+/*     et131x_enable_interrupts        -       enable interrupt
  *     @adapter: et131x device
  *
  *     Enable the appropriate interrupts on the ET131x according to our
@@ -2013,8 +1987,7 @@ static void et131x_enable_interrupts(struct et131x_adapter *adapter)
        writel(mask, &adapter->regs->global.int_mask);
 }
 
-/**
- *     et131x_disable_interrupts       -       interrupt disable
+/*     et131x_disable_interrupts       -       interrupt disable
  *     @adapter: et131x device
  *
  *     Block all interrupts from the et131x device at the device itself
@@ -2025,19 +1998,17 @@ static void et131x_disable_interrupts(struct et131x_adapter *adapter)
        writel(INT_MASK_DISABLE, &adapter->regs->global.int_mask);
 }
 
-/**
- * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310
+/* et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310
  * @adapter: pointer to our adapter structure
  */
 static void et131x_tx_dma_disable(struct et131x_adapter *adapter)
 {
        /* Setup the tramsmit dma configuration register */
-       writel(ET_TXDMA_CSR_HALT|ET_TXDMA_SNGL_EPKT,
+       writel(ET_TXDMA_CSR_HALT | ET_TXDMA_SNGL_EPKT,
                                        &adapter->regs->txdma.csr);
 }
 
-/**
- * et131x_enable_txrx - Enable tx/rx queues
+/* et131x_enable_txrx - Enable tx/rx queues
  * @netdev: device to be enabled
  */
 static void et131x_enable_txrx(struct net_device *netdev)
@@ -2049,15 +2020,14 @@ static void et131x_enable_txrx(struct net_device *netdev)
        et131x_tx_dma_enable(adapter);
 
        /* Enable device interrupts */
-       if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE)
+       if (adapter->flags & FMP_ADAPTER_INTERRUPT_IN_USE)
                et131x_enable_interrupts(adapter);
 
        /* We're ready to move some data, so start the queue */
        netif_start_queue(netdev);
 }
 
-/**
- * et131x_disable_txrx - Disable tx/rx queues
+/* et131x_disable_txrx - Disable tx/rx queues
  * @netdev: device to be disabled
  */
 static void et131x_disable_txrx(struct net_device *netdev)
@@ -2075,8 +2045,7 @@ static void et131x_disable_txrx(struct net_device *netdev)
        et131x_disable_interrupts(adapter);
 }
 
-/**
- * et131x_init_send - Initialize send data structures
+/* et131x_init_send - Initialize send data structures
  * @adapter: pointer to our private adapter structure
  */
 static void et131x_init_send(struct et131x_adapter *adapter)
@@ -2109,8 +2078,7 @@ static void et131x_init_send(struct et131x_adapter *adapter)
        tx_ring->send_tail = NULL;
 }
 
-/**
- * et1310_enable_phy_coma - called when network cable is unplugged
+/* et1310_enable_phy_coma - called when network cable is unplugged
  * @adapter: pointer to our adapter structure
  *
  * driver receive an phy status change interrupt while in D0 and check that
@@ -2139,8 +2107,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter)
        /* Save the GbE PHY speed and duplex modes. Need to restore this
         * when cable is plugged back in
         */
-       /*
-        * TODO - when PM is re-enabled, check if we need to
+       /* TODO - when PM is re-enabled, check if we need to
         * perform a similar task as this -
         * adapter->pdown_speed = adapter->ai_force_speed;
         * adapter->pdown_duplex = adapter->ai_force_duplex;
@@ -2148,7 +2115,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter)
 
        /* Stop sending packets. */
        spin_lock_irqsave(&adapter->send_hw_lock, flags);
-       adapter->flags |= fMP_ADAPTER_LOWER_POWER;
+       adapter->flags |= FMP_ADAPTER_LOWER_POWER;
        spin_unlock_irqrestore(&adapter->send_hw_lock, flags);
 
        /* Wait for outstanding Receive packets */
@@ -2164,8 +2131,7 @@ static void et1310_enable_phy_coma(struct et131x_adapter *adapter)
        writel(pmcsr, &adapter->regs->global.pm_csr);
 }
 
-/**
- * et1310_disable_phy_coma - Disable the Phy Coma Mode
+/* et1310_disable_phy_coma - Disable the Phy Coma Mode
  * @adapter: pointer to our adapter structure
  */
 static void et1310_disable_phy_coma(struct et131x_adapter *adapter)
@@ -2201,7 +2167,7 @@ static void et1310_disable_phy_coma(struct et131x_adapter *adapter)
        et131x_adapter_setup(adapter);
 
        /* Allow Tx to restart */
-       adapter->flags &= ~fMP_ADAPTER_LOWER_POWER;
+       adapter->flags &= ~FMP_ADAPTER_LOWER_POWER;
 
        et131x_enable_txrx(adapter->netdev);
 }
@@ -2211,9 +2177,10 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit)
        u32 tmp_free_buff_ring = *free_buff_ring;
        tmp_free_buff_ring++;
        /* This works for all cases where limit < 1024. The 1023 case
-          works because 1023++ is 1024 which means the if condition is not
-          taken but the carry of the bit into the wrap bit toggles the wrap
-          value correctly */
+        * works because 1023++ is 1024 which means the if condition is not
+        * taken but the carry of the bit into the wrap bit toggles the wrap
+        * value correctly
+        */
        if ((tmp_free_buff_ring & ET_DMA10_MASK) > limit) {
                tmp_free_buff_ring &= ~ET_DMA10_MASK;
                tmp_free_buff_ring ^= ET_DMA10_WRAP;
@@ -2224,8 +2191,7 @@ static inline u32 bump_free_buff_ring(u32 *free_buff_ring, u32 limit)
        return tmp_free_buff_ring;
 }
 
-/**
- * et131x_rx_dma_memory_alloc
+/* et131x_rx_dma_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success and errno on failure (as defined in errno.h)
@@ -2365,8 +2331,7 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
        pr_info("Packet Status Ring %llx\n",
                (unsigned long long) rx_ring->ps_ring_physaddr);
 
-       /*
-        * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
+       /* NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
         * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
         * are ever returned, make sure the high part is retrieved here before
         * storing the adjusted address.
@@ -2392,8 +2357,7 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
        return 0;
 }
 
-/**
- * et131x_rx_dma_memory_free - Free all memory allocated within this module.
+/* et131x_rx_dma_memory_free - Free all memory allocated within this module.
  * @adapter: pointer to our private adapter structure
  */
 static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
@@ -2480,8 +2444,7 @@ static void et131x_rx_dma_memory_free(struct et131x_adapter *adapter)
        rx_ring->num_ready_recv = 0;
 }
 
-/**
- * et131x_init_recv - Initialize receive data structures.
+/* et131x_init_recv - Initialize receive data structures.
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success and errno on failure (as defined in errno.h)
@@ -2518,8 +2481,7 @@ static int et131x_init_recv(struct et131x_adapter *adapter)
        return 0;
 }
 
-/**
- * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate.
+/* et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate.
  * @adapter: pointer to our adapter structure
  */
 static void et131x_set_rx_dma_timer(struct et131x_adapter *adapter)
@@ -2538,8 +2500,7 @@ static void et131x_set_rx_dma_timer(struct et131x_adapter *adapter)
        }
 }
 
-/**
- * NICReturnRFD - Recycle a RFD and put it back onto the receive list
+/* NICReturnRFD - Recycle a RFD and put it back onto the receive list
  * @adapter: pointer to our adapter
  * @rfd: pointer to the RFD
  */
@@ -2555,7 +2516,7 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd)
         * need to clean up OOB data
         */
        if (buff_index < rx_local->fbr[ring_index]->num_entries) {
-               u32 *offset;
+               u32 __iomem *offset;
                struct fbr_desc *next;
 
                spin_lock_irqsave(&adapter->fbr_lock, flags);
@@ -2599,8 +2560,7 @@ static void nic_return_rfd(struct et131x_adapter *adapter, struct rfd *rfd)
        WARN_ON(rx_local->num_ready_recv > rx_local->num_rfd);
 }
 
-/**
- * nic_rx_pkts - Checks the hardware for available packets
+/* nic_rx_pkts - Checks the hardware for available packets
  * @adapter: pointer to our adapter
  *
  * Returns rfd, a pointer to our MPRFD.
@@ -2783,8 +2743,7 @@ out:
        return rfd;
 }
 
-/**
- * et131x_handle_recv_interrupt - Interrupt handler for receive processing
+/* et131x_handle_recv_interrupt - Interrupt handler for receive processing
  * @adapter: pointer to our adapter
  *
  * Assumption, Rcv spinlock has been acquired.
@@ -2838,8 +2797,7 @@ static void et131x_handle_recv_interrupt(struct et131x_adapter *adapter)
                adapter->rx_ring.unfinished_receives = false;
 }
 
-/**
- * et131x_tx_dma_memory_alloc
+/* et131x_tx_dma_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success and errno on failure (as defined in errno.h).
@@ -2895,8 +2853,7 @@ static int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
        return 0;
 }
 
-/**
- * et131x_tx_dma_memory_free - Free all memory allocated within this module
+/* et131x_tx_dma_memory_free - Free all memory allocated within this module
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success and errno on failure (as defined in errno.h).
@@ -2928,8 +2885,7 @@ static void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
        kfree(adapter->tx_ring.tcb_ring);
 }
 
-/**
- * nic_send_packet - NIC specific send handler for version B silicon.
+/* nic_send_packet - NIC specific send handler for version B silicon.
  * @adapter: pointer to our adapter
  * @tcb: pointer to struct tcb
  *
@@ -2977,7 +2933,8 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
                         */
                        if (skb_headlen(skb) <= 1514) {
                                /* Low 16bits are length, high is vlan and
-                                  unused currently so zero */
+                                * unused currently so zero
+                                */
                                desc[frag].len_vlan = skb_headlen(skb);
                                dma_addr = dma_map_single(&adapter->pdev->dev,
                                                          skb->data,
@@ -3022,23 +2979,24 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
        if (phydev && phydev->speed == SPEED_1000) {
                if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) {
                        /* Last element & Interrupt flag */
-                       desc[frag - 1].flags = 0x5;
+                       desc[frag - 1].flags =
+                                   TXDESC_FLAG_INTPROC | TXDESC_FLAG_LASTPKT;
                        adapter->tx_ring.since_irq = 0;
                } else { /* Last element */
-                       desc[frag - 1].flags = 0x1;
+                       desc[frag - 1].flags = TXDESC_FLAG_LASTPKT;
                }
        } else
-               desc[frag - 1].flags = 0x5;
+               desc[frag - 1].flags =
+                                   TXDESC_FLAG_INTPROC | TXDESC_FLAG_LASTPKT;
 
-       desc[0].flags |= 2;     /* First element flag */
+       desc[0].flags |= TXDESC_FLAG_FIRSTPKT;
 
        tcb->index_start = adapter->tx_ring.send_idx;
        tcb->stale = 0;
 
        spin_lock_irqsave(&adapter->send_hw_lock, flags);
 
-       thiscopy = NUM_DESC_PER_RING_TX -
-                               INDEX10(adapter->tx_ring.send_idx);
+       thiscopy = NUM_DESC_PER_RING_TX - INDEX10(adapter->tx_ring.send_idx);
 
        if (thiscopy >= frag) {
                remainder = 0;
@@ -3106,8 +3064,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
        return 0;
 }
 
-/**
- * send_packet - Do the work to send a packet
+/* send_packet - Do the work to send a packet
  * @skb: the packet(s) to send
  * @adapter: a pointer to the device's private adapter structure
  *
@@ -3150,9 +3107,9 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter)
 
                if ((shbufva[0] == 0xffff) &&
                    (shbufva[1] == 0xffff) && (shbufva[2] == 0xffff)) {
-                       tcb->flags |= fMP_DEST_BROAD;
+                       tcb->flags |= FMP_DEST_BROAD;
                } else if ((shbufva[0] & 0x3) == 0x0001) {
-                       tcb->flags |=  fMP_DEST_MULTI;
+                       tcb->flags |=  FMP_DEST_MULTI;
                }
        }
 
@@ -3178,8 +3135,7 @@ static int send_packet(struct sk_buff *skb, struct et131x_adapter *adapter)
        return 0;
 }
 
-/**
- * et131x_send_packets - This function is called by the OS to send packets
+/* et131x_send_packets - This function is called by the OS to send packets
  * @skb: the packet(s) to send
  * @netdev:device on which to TX the above packet(s)
  *
@@ -3207,7 +3163,7 @@ static int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
                /* We need to see if the link is up; if it's not, make the
                 * netif layer think we're good and drop the packet
                 */
-               if ((adapter->flags & fMP_ADAPTER_FAIL_SEND_MASK) ||
+               if ((adapter->flags & FMP_ADAPTER_FAIL_SEND_MASK) ||
                                        !netif_carrier_ok(netdev)) {
                        dev_kfree_skb_any(skb);
                        skb = NULL;
@@ -3228,8 +3184,7 @@ static int et131x_send_packets(struct sk_buff *skb, struct net_device *netdev)
        return status;
 }
 
-/**
- * free_send_packet - Recycle a struct tcb
+/* free_send_packet - Recycle a struct tcb
  * @adapter: pointer to our adapter
  * @tcb: pointer to struct tcb
  *
@@ -3244,9 +3199,9 @@ static inline void free_send_packet(struct et131x_adapter *adapter,
        struct net_device_stats *stats = &adapter->net_stats;
        u64  dma_addr;
 
-       if (tcb->flags & fMP_DEST_BROAD)
+       if (tcb->flags & FMP_DEST_BROAD)
                atomic_inc(&adapter->stats.broadcast_pkts_xmtd);
-       else if (tcb->flags & fMP_DEST_MULTI)
+       else if (tcb->flags & FMP_DEST_MULTI)
                atomic_inc(&adapter->stats.multicast_pkts_xmtd);
        else
                atomic_inc(&adapter->stats.unicast_pkts_xmtd);
@@ -3301,8 +3256,7 @@ static inline void free_send_packet(struct et131x_adapter *adapter,
        WARN_ON(adapter->tx_ring.used < 0);
 }
 
-/**
- * et131x_free_busy_send_packets - Free and complete the stopped active sends
+/* et131x_free_busy_send_packets - Free and complete the stopped active sends
  * @adapter: pointer to our adapter
  *
  * Assumption - Send spinlock has been acquired
@@ -3345,8 +3299,7 @@ static void et131x_free_busy_send_packets(struct et131x_adapter *adapter)
        adapter->tx_ring.used = 0;
 }
 
-/**
- * et131x_handle_send_interrupt - Interrupt handler for sending processing
+/* et131x_handle_send_interrupt - Interrupt handler for sending processing
  * @adapter: pointer to our adapter
  *
  * Re-claim the send resources, complete sends and get more to send from
@@ -3438,6 +3391,7 @@ static void et131x_get_regs(struct net_device *netdev,
        struct address_map __iomem *aregs = adapter->regs;
        u32 *regs_buff = regs_data;
        u32 num = 0;
+       u16 tmp;
 
        memset(regs_data, 0, et131x_get_regs_len(netdev));
 
@@ -3445,44 +3399,68 @@ static void et131x_get_regs(struct net_device *netdev,
                        adapter->pdev->device;
 
        /* PHY regs */
-       et131x_mii_read(adapter, MII_BMCR, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_BMSR, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_PHYSID1, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_PHYSID2, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_ADVERTISE, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_LPA, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_EXPANSION, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, MII_BMCR, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_BMSR, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_PHYSID1, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_PHYSID2, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_ADVERTISE, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_LPA, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_EXPANSION, &tmp);
+       regs_buff[num++] = tmp;
        /* Autoneg next page transmit reg */
-       et131x_mii_read(adapter, 0x07, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, 0x07, &tmp);
+       regs_buff[num++] = tmp;
        /* Link partner next page reg */
-       et131x_mii_read(adapter, 0x08, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_CTRL1000, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_STAT1000, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, 0x0b, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, 0x0c, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_MMD_CTRL, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_MMD_DATA, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, MII_ESTATUS, (u16 *)&regs_buff[num++]);
-
-       et131x_mii_read(adapter, PHY_INDEX_REG, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_DATA_REG, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
-                       (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL,
-                       (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL+1,
-                       (u16 *)&regs_buff[num++]);
-
-       et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL,
-                       (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_CONFIG, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_PHY_CONTROL, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_INTERRUPT_MASK, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_INTERRUPT_STATUS,
-                       (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_PHY_STATUS, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_LED_1, (u16 *)&regs_buff[num++]);
-       et131x_mii_read(adapter, PHY_LED_2, (u16 *)&regs_buff[num++]);
+       et131x_mii_read(adapter, 0x08, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_CTRL1000, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_STAT1000, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, 0x0b, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, 0x0c, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_MMD_CTRL, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_MMD_DATA, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, MII_ESTATUS, &tmp);
+       regs_buff[num++] = tmp;
+
+       et131x_mii_read(adapter, PHY_INDEX_REG, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_DATA_REG, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_LOOPBACK_CONTROL + 1, &tmp);
+       regs_buff[num++] = tmp;
+
+       et131x_mii_read(adapter, PHY_REGISTER_MGMT_CONTROL, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_CONFIG, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_PHY_CONTROL, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_INTERRUPT_MASK, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_INTERRUPT_STATUS, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_PHY_STATUS, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_LED_1, &tmp);
+       regs_buff[num++] = tmp;
+       et131x_mii_read(adapter, PHY_LED_2, &tmp);
+       regs_buff[num++] = tmp;
 
        /* Global regs */
        regs_buff[num++] = readl(&aregs->global.txq_start_addr);
@@ -3579,8 +3557,8 @@ static struct ethtool_ops et131x_ethtool_ops = {
        .get_regs       = et131x_get_regs,
        .get_link       = ethtool_op_get_link,
 };
-/**
- * et131x_hwaddr_init - set up the MAC Address on the ET1310
+
+/* et131x_hwaddr_init - set up the MAC Address on the ET1310
  * @adapter: pointer to our private adapter structure
  */
 static void et131x_hwaddr_init(struct et131x_adapter *adapter)
@@ -3590,14 +3568,12 @@ static void et131x_hwaddr_init(struct et131x_adapter *adapter)
         * device
         */
        if (is_zero_ether_addr(adapter->rom_addr)) {
-               /*
-                * We need to randomly generate the last octet so we
+               /* We need to randomly generate the last octet so we
                 * decrease our chances of setting the mac address to
                 * same as another one of our cards in the system
                 */
                get_random_bytes(&adapter->addr[5], 1);
-               /*
-                * We have the default value in the register we are
+               /* We have the default value in the register we are
                 * working with so we need to copy the current
                 * address into the permanent address
                 */
@@ -3613,8 +3589,7 @@ static void et131x_hwaddr_init(struct et131x_adapter *adapter)
        }
 }
 
-/**
- * et131x_pci_init      - initial PCI setup
+/* et131x_pci_init      - initial PCI setup
  * @adapter: pointer to our private adapter structure
  * @pdev: our PCI device
  *
@@ -3706,8 +3681,7 @@ err_out:
        goto out;
 }
 
-/**
- * et131x_error_timer_handler
+/* et131x_error_timer_handler
  * @data: timer-specific variable; here a pointer to our adapter structure
  *
  * The routine called when the error timer expires, to track the number of
@@ -3721,7 +3695,8 @@ static void et131x_error_timer_handler(unsigned long data)
        if (et1310_in_phy_coma(adapter)) {
                /* Bring the device immediately out of coma, to
                 * prevent it from sleeping indefinitely, this
-                * mechanism could be improved! */
+                * mechanism could be improved!
+                */
                et1310_disable_phy_coma(adapter);
                adapter->boot_coma = 20;
        } else {
@@ -3747,8 +3722,7 @@ static void et131x_error_timer_handler(unsigned long data)
        mod_timer(&adapter->error_timer, jiffies + TX_ERROR_PERIOD * HZ / 1000);
 }
 
-/**
- * et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx
+/* et131x_adapter_memory_free - Free all memory allocated for use by Tx & Rx
  * @adapter: pointer to our private adapter structure
  */
 static void et131x_adapter_memory_free(struct et131x_adapter *adapter)
@@ -3758,8 +3732,7 @@ static void et131x_adapter_memory_free(struct et131x_adapter *adapter)
        et131x_rx_dma_memory_free(adapter);
 }
 
-/**
- * et131x_adapter_memory_alloc
+/* et131x_adapter_memory_alloc
  * @adapter: pointer to our private adapter structure
  *
  * Returns 0 on success, errno on failure (as defined in errno.h).
@@ -3801,60 +3774,54 @@ static void et131x_adjust_link(struct net_device *netdev)
        struct et131x_adapter *adapter = netdev_priv(netdev);
        struct  phy_device *phydev = adapter->phydev;
 
-       if (netif_carrier_ok(netdev)) {
-               adapter->boot_coma = 20;
-
-               if (phydev && phydev->speed == SPEED_10) {
-                       /*
-                        * NOTE - Is there a way to query this without
-                        * TruePHY?
-                        * && TRU_QueryCoreType(adapter->hTruePhy, 0)==
-                        * EMI_TRUEPHY_A13O) {
-                        */
-                       u16 register18;
-
-                       et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
-                                        &register18);
-                       et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-                                        register18 | 0x4);
-                       et131x_mii_write(adapter, PHY_INDEX_REG,
-                                        register18 | 0x8402);
-                       et131x_mii_write(adapter, PHY_DATA_REG,
-                                        register18 | 511);
-                       et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
-                                        register18);
-               }
-
-               et1310_config_flow_control(adapter);
-
-               if (phydev && phydev->speed == SPEED_1000 &&
-                               adapter->registry_jumbo_packet > 2048) {
-                       u16 reg;
-
-                       et131x_mii_read(adapter, PHY_CONFIG, &reg);
-                       reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
-                       reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
-                       et131x_mii_write(adapter, PHY_CONFIG, reg);
-               }
-
-               et131x_set_rx_dma_timer(adapter);
-               et1310_config_mac_regs2(adapter);
-       }
-
        if (phydev && phydev->link != adapter->link) {
-               /*
-                * Check to see if we are in coma mode and if
+               /* Check to see if we are in coma mode and if
                 * so, disable it because we will not be able
                 * to read PHY values until we are out.
                 */
                if (et1310_in_phy_coma(adapter))
                        et1310_disable_phy_coma(adapter);
 
+               adapter->link = phydev->link;
+               phy_print_status(phydev);
+
                if (phydev->link) {
                        adapter->boot_coma = 20;
+                       if (phydev && phydev->speed == SPEED_10) {
+                               /* NOTE - Is there a way to query this without
+                                * TruePHY?
+                                * && TRU_QueryCoreType(adapter->hTruePhy, 0)==
+                                * EMI_TRUEPHY_A13O) {
+                                */
+                               u16 register18;
+
+                               et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG,
+                                                &register18);
+                               et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
+                                                register18 | 0x4);
+                               et131x_mii_write(adapter, PHY_INDEX_REG,
+                                                register18 | 0x8402);
+                               et131x_mii_write(adapter, PHY_DATA_REG,
+                                                register18 | 511);
+                               et131x_mii_write(adapter, PHY_MPHY_CONTROL_REG,
+                                                register18);
+                       }
+
+                       et1310_config_flow_control(adapter);
+
+                       if (phydev && phydev->speed == SPEED_1000 &&
+                                       adapter->registry_jumbo_packet > 2048) {
+                               u16 reg;
+
+                               et131x_mii_read(adapter, PHY_CONFIG, &reg);
+                               reg &= ~ET_PHY_CONFIG_TX_FIFO_DEPTH;
+                               reg |= ET_PHY_CONFIG_FIFO_DEPTH_32;
+                               et131x_mii_write(adapter, PHY_CONFIG, reg);
+                       }
+
+                       et131x_set_rx_dma_timer(adapter);
+                       et1310_config_mac_regs2(adapter);
                } else {
-                       dev_warn(&adapter->pdev->dev,
-                           "Link down - cable problem ?\n");
                        adapter->boot_coma = 0;
 
                        if (phydev->speed == SPEED_10) {
@@ -3883,8 +3850,7 @@ static void et131x_adjust_link(struct net_device *netdev)
                        /* Re-initialize the send structures */
                        et131x_init_send(adapter);
 
-                       /*
-                        * Bring the device back to the state it was during
+                       /* Bring the device back to the state it was during
                         * init prior to autonegotiation being complete. This
                         * way, when we get the auto-neg complete interrupt,
                         * we can complete init by calling config_mac_regs2.
@@ -3899,9 +3865,6 @@ static void et131x_adjust_link(struct net_device *netdev)
                        et131x_enable_txrx(netdev);
                }
 
-               adapter->link = phydev->link;
-
-               phy_print_status(phydev);
        }
 }
 
@@ -3917,7 +3880,7 @@ static int et131x_mii_probe(struct net_device *netdev)
        }
 
        phydev = phy_connect(netdev, dev_name(&phydev->dev),
-                       &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII);
+                            &et131x_adjust_link, 0, PHY_INTERFACE_MODE_MII);
 
        if (IS_ERR(phydev)) {
                dev_err(&adapter->pdev->dev, "Could not attach to PHY\n");
@@ -3944,8 +3907,7 @@ static int et131x_mii_probe(struct net_device *netdev)
        return 0;
 }
 
-/**
- * et131x_adapter_init
+/* et131x_adapter_init
  * @adapter: pointer to the private adapter struct
  * @pdev: pointer to the PCI device
  *
@@ -3982,8 +3944,7 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,
        return adapter;
 }
 
-/**
- * et131x_pci_remove
+/* et131x_pci_remove
  * @pdev: a pointer to the device's pci_dev structure
  *
  * Registered in the pci_driver structure, this function is called when the
@@ -4010,8 +3971,7 @@ static void et131x_pci_remove(struct pci_dev *pdev)
        pci_disable_device(pdev);
 }
 
-/**
- * et131x_up - Bring up a device for use.
+/* et131x_up - Bring up a device for use.
  * @netdev: device to be opened
  */
 static void et131x_up(struct net_device *netdev)
@@ -4022,8 +3982,7 @@ static void et131x_up(struct net_device *netdev)
        phy_start(adapter->phydev);
 }
 
-/**
- * et131x_down - Bring down the device
+/* et131x_down - Bring down the device
  * @netdev: device to be brought down
  */
 static void et131x_down(struct net_device *netdev)
@@ -4072,14 +4031,13 @@ static SIMPLE_DEV_PM_OPS(et131x_pm_ops, et131x_suspend, et131x_resume);
 #define ET131X_PM_OPS NULL
 #endif
 
-/**
- * et131x_isr - The Interrupt Service Routine for the driver.
+/* et131x_isr - The Interrupt Service Routine for the driver.
  * @irq: the IRQ on which the interrupt was received.
  * @dev_id: device-specific info (here a pointer to a net_device struct)
  *
  * Returns a value indicating if the interrupt was handled.
  */
-irqreturn_t et131x_isr(int irq, void *dev_id)
+static irqreturn_t et131x_isr(int irq, void *dev_id)
 {
        bool handled = true;
        struct net_device *netdev = (struct net_device *)dev_id;
@@ -4161,8 +4119,7 @@ out:
        return IRQ_RETVAL(handled);
 }
 
-/**
- * et131x_isr_handler - The ISR handler
+/* et131x_isr_handler - The ISR handler
  * @p_adapter, a pointer to the device's private adapter structure
  *
  * scheduled to run in a deferred context by the ISR. This is where the ISR's
@@ -4175,8 +4132,7 @@ static void et131x_isr_handler(struct work_struct *work)
        u32 status = adapter->stats.interrupt_status;
        struct address_map __iomem *iomem = adapter->regs;
 
-       /*
-        * These first two are by far the most common.  Once handled, we clear
+       /* These first two are by far the most common.  Once handled, we clear
         * their two bits in the status word.  If the word is now zero, we
         * exit.
         */
@@ -4207,8 +4163,7 @@ static void et131x_isr_handler(struct work_struct *work)
 
        /* Handle Free Buffer Ring 0 and 1 Low interrupt */
        if (status & (ET_INTR_RXDMA_FB_R0_LOW | ET_INTR_RXDMA_FB_R1_LOW)) {
-               /*
-                * This indicates the number of unused buffers in RXDMA free
+               /* This indicates the number of unused buffers in RXDMA free
                 * buffer ring 0 is <= the limit you programmed. Free buffer
                 * resources need to be returned.  Free buffers are consumed as
                 * packets are passed from the network to the host. The host
@@ -4220,16 +4175,14 @@ static void et131x_isr_handler(struct work_struct *work)
                 * method of returning resources.
                 */
 
-               /*
-                *  If the user has flow control on, then we will
+               /*  If the user has flow control on, then we will
                 * send a pause packet, otherwise just exit
                 */
                if (adapter->flowcontrol == FLOW_TXONLY ||
                    adapter->flowcontrol == FLOW_BOTH) {
                        u32 pm_csr;
 
-                       /*
-                        * Tell the device to send a pause packet via the back
+                       /* Tell the device to send a pause packet via the back
                         * pressure register (bp req and bp xon/xoff)
                         */
                        pm_csr = readl(&iomem->global.pm_csr);
@@ -4240,8 +4193,7 @@ static void et131x_isr_handler(struct work_struct *work)
 
        /* Handle Packet Status Ring Low Interrupt */
        if (status & ET_INTR_RXDMA_STAT_LOW) {
-               /*
-                * Same idea as with the two Free Buffer Rings. Packets going
+               /* Same idea as with the two Free Buffer Rings. Packets going
                 * from the network to the host each consume a free buffer
                 * resource and a packet status resource. These resoures are
                 * passed to the OS. When the OS is done with the resources,
@@ -4252,8 +4204,7 @@ static void et131x_isr_handler(struct work_struct *work)
 
        /* Handle RXDMA Error Interrupt */
        if (status & ET_INTR_RXDMA_ERR) {
-               /*
-                * The rxdma_error interrupt is sent when a time-out on a
+               /* The rxdma_error interrupt is sent when a time-out on a
                 * request issued by the JAGCore has occurred or a completion is
                 * returned with an un-successful status. In both cases the
                 * request is considered complete. The JAGCore will
@@ -4276,8 +4227,7 @@ static void et131x_isr_handler(struct work_struct *work)
 
        /* Handle the Wake on LAN Event */
        if (status & ET_INTR_WOL) {
-               /*
-                * This is a secondary interrupt for wake on LAN. The driver
+               /* This is a secondary interrupt for wake on LAN. The driver
                 * should never see this, if it does, something serious is
                 * wrong. We will TRAP the message when we are in DBG mode,
                 * otherwise we will ignore it.
@@ -4289,8 +4239,7 @@ static void et131x_isr_handler(struct work_struct *work)
        if (status & ET_INTR_TXMAC) {
                u32 err = readl(&iomem->txmac.err);
 
-               /*
-                * When any of the errors occur and TXMAC generates an
+               /* When any of the errors occur and TXMAC generates an
                 * interrupt to report these errors, it usually means that
                 * TXMAC has detected an error in the data stream retrieved
                 * from the on-chip Tx Q. All of these errors are catastrophic
@@ -4302,20 +4251,18 @@ static void et131x_isr_handler(struct work_struct *work)
                         "TXMAC interrupt, error 0x%08x\n",
                         err);
 
-               /*
-                * If we are debugging, we want to see this error, otherwise we
+               /* If we are debugging, we want to see this error, otherwise we
                 * just want the device to be reset and continue
                 */
        }
 
        /* Handle RXMAC Interrupt */
        if (status & ET_INTR_RXMAC) {
-               /*
-                * These interrupts are catastrophic to the device, what we need
+               /* These interrupts are catastrophic to the device, what we need
                 * to do is disable the interrupts and set the flag to cause us
                 * to reset so we can solve this issue.
                 */
-               /* MP_SET_FLAG( adapter, fMP_ADAPTER_HARDWARE_ERROR); */
+               /* MP_SET_FLAG( adapter, FMP_ADAPTER_HARDWARE_ERROR); */
 
                dev_warn(&adapter->pdev->dev,
                         "RXMAC interrupt, error 0x%08x.  Requesting reset\n",
@@ -4326,16 +4273,14 @@ static void et131x_isr_handler(struct work_struct *work)
                         readl(&iomem->rxmac.ctrl),
                         readl(&iomem->rxmac.rxq_diag));
 
-               /*
-                * If we are debugging, we want to see this error, otherwise we
+               /* If we are debugging, we want to see this error, otherwise we
                 * just want the device to be reset and continue
                 */
        }
 
        /* Handle MAC_STAT Interrupt */
        if (status & ET_INTR_MAC_STAT) {
-               /*
-                * This means at least one of the un-masked counters in the
+               /* This means at least one of the un-masked counters in the
                 * MAC_STAT block has rolled over. Use this to maintain the top,
                 * software managed bits of the counter(s).
                 */
@@ -4344,8 +4289,7 @@ static void et131x_isr_handler(struct work_struct *work)
 
        /* Handle SLV Timeout Interrupt */
        if (status & ET_INTR_SLV_TIMEOUT) {
-               /*
-                * This means a timeout has occurred on a read or write request
+               /* This means a timeout has occurred on a read or write request
                 * to one of the JAGCore registers. The Global Resources block
                 * has terminated the request and on a read request, returned a
                 * "fake" value. The most likely reasons are: Bad Address or the
@@ -4356,8 +4300,7 @@ out:
        et131x_enable_interrupts(adapter);
 }
 
-/**
- * et131x_stats - Return the current device statistics.
+/* et131x_stats - Return the current device statistics.
  * @netdev: device whose stats are being queried
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
@@ -4403,8 +4346,7 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev)
        return stats;
 }
 
-/**
- * et131x_open - Open the device for use.
+/* et131x_open - Open the device for use.
  * @netdev: device to be opened
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
@@ -4430,15 +4372,14 @@ static int et131x_open(struct net_device *netdev)
                return result;
        }
 
-       adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE;
+       adapter->flags |= FMP_ADAPTER_INTERRUPT_IN_USE;
 
        et131x_up(netdev);
 
        return result;
 }
 
-/**
- * et131x_close - Close the device
+/* et131x_close - Close the device
  * @netdev: device to be closed
  *
  * Returns 0 on success, errno on failure (as defined in errno.h)
@@ -4449,15 +4390,14 @@ static int et131x_close(struct net_device *netdev)
 
        et131x_down(netdev);
 
-       adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE;
+       adapter->flags &= ~FMP_ADAPTER_INTERRUPT_IN_USE;
        free_irq(adapter->pdev->irq, netdev);
 
        /* Stop the error timer */
        return del_timer_sync(&adapter->error_timer);
 }
 
-/**
- * et131x_ioctl - The I/O Control handler for the driver
+/* et131x_ioctl - The I/O Control handler for the driver
  * @netdev: device on which the control request is being made
  * @reqbuf: a pointer to the IOCTL request buffer
  * @cmd: the IOCTL command code
@@ -4475,8 +4415,7 @@ static int et131x_ioctl(struct net_device *netdev, struct ifreq *reqbuf,
        return phy_mii_ioctl(adapter->phydev, reqbuf, cmd);
 }
 
-/**
- * et131x_set_packet_filter - Configures the Rx Packet filtering on the device
+/* et131x_set_packet_filter - Configures the Rx Packet filtering on the device
  * @adapter: pointer to our private adapter structure
  *
  * FIXME: lot of dups with MAC code
@@ -4504,8 +4443,7 @@ static int et131x_set_packet_filter(struct et131x_adapter *adapter)
        if ((filter & ET131X_PACKET_TYPE_PROMISCUOUS) || filter == 0)
                pf_ctrl &= ~7;  /* Clear filter bits */
        else {
-               /*
-                * Set us up with Multicast packet filtering.  Three cases are
+               /* Set us up with Multicast packet filtering.  Three cases are
                 * possible - (1) we have a multi-cast list, (2) we receive ALL
                 * multicast entries or (3) we receive none.
                 */
@@ -4541,8 +4479,7 @@ static int et131x_set_packet_filter(struct et131x_adapter *adapter)
        return status;
 }
 
-/**
- * et131x_multicast - The handler to configure multicasting on the interface
+/* et131x_multicast - The handler to configure multicasting on the interface
  * @netdev: a pointer to a net_device struct representing the device
  */
 static void et131x_multicast(struct net_device *netdev)
@@ -4611,8 +4548,7 @@ static void et131x_multicast(struct net_device *netdev)
        spin_unlock_irqrestore(&adapter->lock, flags);
 }
 
-/**
- * et131x_tx - The handler to tx a packet on the device
+/* et131x_tx - The handler to tx a packet on the device
  * @skb: data to be Tx'd
  * @netdev: device on which data is to be Tx'd
  *
@@ -4644,8 +4580,7 @@ static int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
        return status;
 }
 
-/**
- * et131x_tx_timeout - Timeout handler
+/* et131x_tx_timeout - Timeout handler
  * @netdev: a pointer to a net_device struct representing the device
  *
  * The handler called when a Tx request times out. The timeout period is
@@ -4659,17 +4594,17 @@ static void et131x_tx_timeout(struct net_device *netdev)
        unsigned long flags;
 
        /* If the device is closed, ignore the timeout */
-       if (~(adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE))
+       if (~(adapter->flags & FMP_ADAPTER_INTERRUPT_IN_USE))
                return;
 
        /* Any nonrecoverable hardware error?
         * Checks adapter->flags for any failure in phy reading
         */
-       if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR)
+       if (adapter->flags & FMP_ADAPTER_NON_RECOVER_ERROR)
                return;
 
        /* Hardware failure? */
-       if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) {
+       if (adapter->flags & FMP_ADAPTER_HARDWARE_ERROR) {
                dev_err(&adapter->pdev->dev, "hardware error - reset\n");
                return;
        }
@@ -4703,8 +4638,7 @@ static void et131x_tx_timeout(struct net_device *netdev)
        spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags);
 }
 
-/**
- * et131x_change_mtu - The handler called to change the MTU for the device
+/* et131x_change_mtu - The handler called to change the MTU for the device
  * @netdev: device whose MTU is to be changed
  * @new_mtu: the desired MTU
  *
@@ -4754,8 +4688,7 @@ static int et131x_change_mtu(struct net_device *netdev, int new_mtu)
        return result;
 }
 
-/**
- * et131x_set_mac_addr - handler to change the MAC address for the device
+/* et131x_set_mac_addr - handler to change the MAC address for the device
  * @netdev: device whose MAC is to be changed
  * @new_mac: the desired MAC address
  *
@@ -4828,8 +4761,7 @@ static const struct net_device_ops et131x_netdev_ops = {
        .ndo_do_ioctl           = et131x_ioctl,
 };
 
-/**
- * et131x_pci_setup - Perform device initialization
+/* et131x_pci_setup - Perform device initialization
  * @pdev: a pointer to the device's pci_dev structure
  * @ent: this device's entry in the pci_device_id table
  *
index 347e63ddde1fa1d1f2b112d1d10368ce4da5169e..bbe78a703a237783cd9e85b4e5088a824e9a4fcc 100644 (file)
  *31:  selfclr_disable
  */
 
+#define ET_RESET_ALL   0x007F;
+
 /*
  * SLV Timer reg at address 0x002C (low 24 bits)
  */
@@ -317,6 +319,14 @@ struct txdma_regs {                        /* Location: */
  * 18-31: unused
  */
 
+#define ET_RXDMA_CSR_HALT              0x0001
+#define ET_RXDMA_CSR_FBR0_SIZE_LO      0x0100
+#define ET_RXDMA_CSR_FBR0_SIZE_HI      0x0200
+#define ET_RXDMA_CSR_FBR0_ENABLE       0x0400
+#define ET_RXDMA_CSR_FBR1_SIZE_LO      0x0800
+#define ET_RXDMA_CSR_FBR1_SIZE_HI      0x1000
+#define ET_RXDMA_CSR_FBR1_ENABLE       0x2000
+#define ET_RXDMA_CSR_HALT_STATUS       0x00020000
 
 /*
  * structure for dma writeback lo reg in rxdma address map
@@ -384,6 +394,8 @@ struct txdma_regs {                 /* Location: */
  * 11-0: psr ndes
  */
 
+#define ET_RXDMA_PSR_NUM_DES_MASK      0xFFF;
+
 /*
  * structure for packet status ring available offset reg in rxdma address map
  * located at address 0x202C
@@ -559,6 +571,9 @@ struct rxdma_regs {                                 /* Location: */
  * 0: txmac_en
  */
 
+#define ET_TX_CTRL_FC_DISABLE  0x0008
+#define ET_TX_CTRL_TXMAC_ENABLE        0x0001
+
 /*
  * structure for shadow pointer reg in txmac address map
  * located at address 0x3004
@@ -674,6 +689,9 @@ struct txmac_regs {                 /* Location: */
  * 0: rxmac_en
  */
 
+#define ET_RX_CTRL_WOL_DISABLE 0x0008
+#define ET_RX_CTRL_RXMAC_ENABLE        0x0001
+
 /*
  * structure for Wake On Lan Control and CRC 0 reg in rxmac address map
  * located at address 0x4004
@@ -715,9 +733,9 @@ struct txmac_regs {                 /* Location: */
  * 7-0: sa6
  */
 
-#define ET_WOL_LO_SA3_SHIFT 24
-#define ET_WOL_LO_SA4_SHIFT 16
-#define ET_WOL_LO_SA5_SHIFT 8
+#define ET_RX_WOL_LO_SA3_SHIFT 24
+#define ET_RX_WOL_LO_SA4_SHIFT 16
+#define ET_RX_WOL_LO_SA5_SHIFT 8
 
 /*
  * structure for Wake On Lan Source Address Hi reg in rxmac address map
@@ -728,7 +746,7 @@ struct txmac_regs {                 /* Location: */
  * 7-0: sa2
  */
 
-#define ET_WOL_HI_SA1_SHIFT 8
+#define ET_RX_WOL_HI_SA1_SHIFT 8
 
 /*
  * structure for Wake On Lan mask reg in rxmac address map
@@ -746,9 +764,9 @@ struct txmac_regs {                 /* Location: */
  * 7-0: addr1_6
  */
 
-#define ET_UNI_PF_ADDR1_3_SHIFT 24
-#define ET_UNI_PF_ADDR1_4_SHIFT 16
-#define ET_UNI_PF_ADDR1_5_SHIFT 8
+#define ET_RX_UNI_PF_ADDR1_3_SHIFT 24
+#define ET_RX_UNI_PF_ADDR1_4_SHIFT 16
+#define ET_RX_UNI_PF_ADDR1_5_SHIFT 8
 
 /*
  * structure for Unicast Paket Filter Address 2 reg in rxmac address map
@@ -760,9 +778,9 @@ struct txmac_regs {                 /* Location: */
  * 7-0: addr2_6
  */
 
-#define ET_UNI_PF_ADDR2_3_SHIFT 24
-#define ET_UNI_PF_ADDR2_4_SHIFT 16
-#define ET_UNI_PF_ADDR2_5_SHIFT 8
+#define ET_RX_UNI_PF_ADDR2_3_SHIFT 24
+#define ET_RX_UNI_PF_ADDR2_4_SHIFT 16
+#define ET_RX_UNI_PF_ADDR2_5_SHIFT 8
 
 /*
  * structure for Unicast Paket Filter Address 1 & 2 reg in rxmac address map
@@ -774,10 +792,9 @@ struct txmac_regs {                        /* Location: */
  * 7-0: addr1_2
  */
 
-#define ET_UNI_PF_ADDR2_1_SHIFT 24
-#define ET_UNI_PF_ADDR2_2_SHIFT 16
-#define ET_UNI_PF_ADDR1_1_SHIFT 8
-
+#define ET_RX_UNI_PF_ADDR2_1_SHIFT 24
+#define ET_RX_UNI_PF_ADDR2_2_SHIFT 16
+#define ET_RX_UNI_PF_ADDR1_1_SHIFT 8
 
 /*
  * structure for Multicast Hash reg in rxmac address map
@@ -798,6 +815,12 @@ struct txmac_regs {                        /* Location: */
  * 0: filter_broad_en
  */
 
+#define ET_RX_PFCTRL_MIN_PKT_SZ_SHIFT          16;
+#define ET_RX_PFCTRL_FRAG_FILTER_ENABLE                0x0008;
+#define ET_RX_PFCTRL_UNICST_FILTER_ENABLE      0x0004;
+#define ET_RX_PFCTRL_MLTCST_FILTER_ENABLE      0x0002;
+#define ET_RX_PFCTRL_BRDCST_FILTER_ENABLE      0x0001;
+
 /*
  * structure for Memory Controller Interface Control Max Segment reg in rxmac
  * address map.  Located at address 0x4088
@@ -808,6 +831,10 @@ struct txmac_regs {                        /* Location: */
  * 0: seg_en
  */
 
+#define ET_RX_MCIF_CTRL_MAX_SEG_SIZE_SHIFT     2;
+#define ET_RX_MCIF_CTRL_MAX_SEG_FC_ENABLE      0x0002;
+#define ET_RX_MCIF_CTRL_MAX_SEG_ENABLE         0x0001;
+
 /*
  * structure for Memory Controller Interface Water Mark reg in rxmac address
  * map.  Located at address 0x408C
@@ -907,7 +934,6 @@ struct rxmac_regs {                                 /* Location: */
 
 /* END OF RXMAC REGISTER ADDRESS MAP */
 
-
 /* START OF MAC REGISTER ADDRESS MAP */
 
 /*
@@ -932,12 +958,18 @@ struct rxmac_regs {                                       /* Location: */
  * 0: tx enable
  */
 
-#define CFG1_LOOPBACK  0x00000100
-#define CFG1_RX_FLOW   0x00000020
-#define CFG1_TX_FLOW   0x00000010
-#define CFG1_RX_ENABLE 0x00000004
-#define CFG1_TX_ENABLE 0x00000001
-#define CFG1_WAIT      0x0000000A      /* RX & TX syncd */
+#define ET_MAC_CFG1_SOFT_RESET         0x80000000
+#define ET_MAC_CFG1_SIM_RESET          0x40000000
+#define ET_MAC_CFG1_RESET_RXMC         0x00080000
+#define ET_MAC_CFG1_RESET_TXMC         0x00040000
+#define ET_MAC_CFG1_RESET_RXFUNC       0x00020000
+#define ET_MAC_CFG1_RESET_TXFUNC       0x00010000
+#define ET_MAC_CFG1_LOOPBACK           0x00000100
+#define ET_MAC_CFG1_RX_FLOW            0x00000020
+#define ET_MAC_CFG1_TX_FLOW            0x00000010
+#define ET_MAC_CFG1_RX_ENABLE          0x00000004
+#define ET_MAC_CFG1_TX_ENABLE          0x00000001
+#define ET_MAC_CFG1_WAIT               0x0000000A      /* RX & TX syncd */
 
 /*
  * structure for configuration #2 reg in mac address map.
@@ -955,6 +987,15 @@ struct rxmac_regs {                                        /* Location: */
  * 0: full duplex
  */
 
+#define ET_MAC_CFG2_PREAMBLE_SHIFT     12;
+#define ET_MAC_CFG2_IFMODE_MASK                0x0300;
+#define ET_MAC_CFG2_IFMODE_1000                0x0200;
+#define ET_MAC_CFG2_IFMODE_100         0x0100;
+#define ET_MAC_CFG2_IFMODE_HUGE_FRAME  0x0020;
+#define ET_MAC_CFG2_IFMODE_LEN_CHECK   0x0010;
+#define ET_MAC_CFG2_IFMODE_PAD_CRC     0x0004;
+#define ET_MAC_CFG2_IFMODE_CRC_ENABLE  0x0002;
+#define ET_MAC_CFG2_IFMODE_FULL_DPLX   0x0001;
 
 /*
  * structure for Interpacket gap reg in mac address map.
@@ -1009,6 +1050,8 @@ struct rxmac_regs {                                       /* Location: */
  * 2-0: mgmt clock reset
  */
 
+#define ET_MAC_MIIMGMT_CLK_RST 0x0007
+
 /*
  * structure for MII Management Command reg in mac address map.
  * located at address 0x5024
@@ -1025,7 +1068,7 @@ struct rxmac_regs {                                       /* Location: */
  * 4-0: register
  */
 
-#define MII_ADDR(phy, reg)     ((phy) << 8 | (reg))
+#define ET_MAC_MII_ADDR(phy, reg)      ((phy) << 8 | (reg))
 
 /*
  * structure for MII Management Control reg in mac address map.
@@ -1041,6 +1084,8 @@ struct rxmac_regs {                                       /* Location: */
  * 15-0: phy control
  */
 
+#define ET_MAC_MIIMGMT_STAT_PHYCRTL_MASK 0xFFFF;
+
 /*
  * structure for MII Management Indicators reg in mac address map.
  * located at address 0x5034
@@ -1050,8 +1095,8 @@ struct rxmac_regs {                                       /* Location: */
  * 0: busy
  */
 
-#define MGMT_BUSY      0x00000001      /* busy */
-#define MGMT_WAIT      0x00000005      /* busy | not valid */
+#define ET_MAC_MGMT_BUSY       0x00000001      /* busy */
+#define ET_MAC_MGMT_WAIT       0x00000005      /* busy | not valid */
 
 /*
  * structure for Interface Control reg in mac address map.
@@ -1076,6 +1121,9 @@ struct rxmac_regs {                                       /* Location: */
  * 0: enable jabber protection
  */
 
+#define ET_MAC_IFCTRL_GHDMODE  (1 << 26)
+#define ET_MAC_IFCTRL_PHYMODE  (1 << 24)
+
 /*
  * structure for Interface Status reg in mac address map.
  * located at address 0x503C
index adb436ed2511c5e2b749dbbc3af9bb0594e36ced..65f7ab6cb467fbd96066868bb4dc209740e05d64 100644 (file)
 #define SUCCESS        0x00
 #define FAILURE        0x01
 
-struct ft1000_info {
-       struct net_device_stats stats;
-       u16 DrvErrNum;
-       u16 AsicID;
+struct ft1000_pcmcia {
        int PktIntfErr;
-       int CardReady;
-       int registered;
-       int mediastate;
        u16 packetseqnum;
-       u8 squeseqnum;                  /* sequence number on slow queue */
-       spinlock_t dpram_lock;
-       u16 fifo_cnt;
-       u8 DspVer[DSPVERSZ];            /* DSP version number */
-       u8 HwSerNum[HWSERNUMSZ];        /* Hardware Serial Number */
-       u8 Sku[SKUSZ];                  /* SKU */
-       u8 eui64[EUISZ];                /* EUI64 */
-       time_t ConTm;                   /* Connection Time */
-       u16 LedStat;
-       u16 ConStat;
-       u16 ProgConStat;
-       u8 ProductMode[MODESZ];
-       u8 RfCalVer[CALVERSZ];
-       u8 RfCalDate[CALDATESZ];
-       u16 DSP_TIME[4];
-       struct list_head prov_list;
-       u16 DSPInfoBlklen;
-       int (*ft1000_reset)(void *);
        void *link;
-       u16 DSPInfoBlk[MAX_DSP_SESS_REC];
-       union {
-               u16 Rec[MAX_DSP_SESS_REC];
-               u32 MagRec[MAX_DSP_SESS_REC/2];
-       } DSPSess;
-       struct proc_dir_entry *proc_ft1000;
-       char netdevname[IFNAMSIZ];
 };
 
 struct pcmcia_device;
index 86a680c09ba2a7e2bf62276d1f85e3415c0827c6..3fd499f09bcafc745ce259c04c208a578b688c67 100644 (file)
@@ -328,11 +328,12 @@ static void ft1000_disable_interrupts(struct net_device *dev)
 static void ft1000_reset_asic(struct net_device *dev)
 {
        struct ft1000_info *info = netdev_priv(dev);
+       struct ft1000_pcmcia *pcmcia = info->priv;
        u16 tempword;
 
        DEBUG(1, "ft1000_hw:ft1000_reset_asic called\n");
 
-       (*info->ft1000_reset) (info->link);
+       (*info->ft1000_reset) (pcmcia->link);
 
        // Let's use the register provided by the Magnemite ASIC to reset the
        // ASIC and DSP.
@@ -1397,12 +1398,13 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
 static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
 {
        struct ft1000_info *info = netdev_priv(dev);
+       struct ft1000_pcmcia *pcmcia = info->priv;
        u16 i;
        u32 templong;
        u16 tempword;
 
        DEBUG(1, "ft1000:ft1000_hw:ft1000_flush_fifo called\n");
-       if (info->PktIntfErr > MAX_PH_ERR) {
+       if (pcmcia->PktIntfErr > MAX_PH_ERR) {
                if (info->AsicID == ELECTRABUZZ_ID) {
                        info->DSP_TIME[0] =
                                ft1000_read_dpram(dev, FT1000_DSP_TIMER0);
@@ -1491,7 +1493,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
                                                        FIFO_FLUSH_BADCNT;
                                        } else {
                                                // Let's assume that we really flush the FIFO
-                                               info->PktIntfErr++;
+                                               pcmcia->PktIntfErr++;
                                                return;
                                        }
                                } else {
@@ -1522,7 +1524,7 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
                        DEBUG(0, "FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
                }
                if (DrvErrNum) {
-                       info->PktIntfErr++;
+                       pcmcia->PktIntfErr++;
                }
        }
 }
@@ -1731,6 +1733,7 @@ static int ft1000_copy_up_pkt(struct net_device *dev)
 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;
        union {
                struct pseudo_hdr blk;
                u16 buff[sizeof(struct pseudo_hdr) >> 1];
@@ -1780,7 +1783,7 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 * packet, u16 len)
        pseudo.blk.control = 0;
        pseudo.blk.rsvd1 = 0;
        pseudo.blk.seq_num = 0;
-       pseudo.blk.rsvd2 = info->packetseqnum++;
+       pseudo.blk.rsvd2 = pcmcia->packetseqnum++;
        pseudo.blk.qos_class = 0;
        /* Calculate pseudo header checksum */
        pseudo.blk.checksum = pseudo.buff[0];
@@ -2058,6 +2061,8 @@ void stop_ft1000_card(struct net_device *dev)
                kfree(ptr);
        }
 
+       kfree(info->priv);
+
        if (info->registered) {
                unregister_netdev(dev);
                info->registered = 0;
@@ -2100,6 +2105,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
                                                void *ft1000_reset)
 {
        struct ft1000_info *info;
+       struct ft1000_pcmcia *pcmcia;
        struct net_device *dev;
 
        static const struct net_device_ops ft1000ops =          // Slavius 21.10.2009 due to kernel changes
@@ -2141,10 +2147,13 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
 
        memset(&info->stats, 0, sizeof(struct net_device_stats));
 
+       info->priv = kzalloc(sizeof(struct ft1000_pcmcia), GFP_KERNEL);
+       pcmcia = info->priv;
+       pcmcia->link = link;
+
        spin_lock_init(&info->dpram_lock);
        info->DrvErrNum = 0;
        info->registered = 1;
-       info->link = link;
        info->ft1000_reset = ft1000_reset;
        info->mediastate = 0;
        info->fifo_cnt = 0;
index 72727c6b9e2e1e38f392579773cc3b21f7ff4f64..5337b415d450cee2540b00b9c09809cd49ad3bb6 100644 (file)
@@ -175,8 +175,8 @@ static int ft1000NotifyProc(struct notifier_block *this, unsigned long event,
 
        switch (event) {
        case NETDEV_CHANGENAME:
-               remove_proc_entry(info->netdevname, info->proc_ft1000);
-               create_proc_read_entry(dev->name, 0644, info->proc_ft1000,
+               remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
+               create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir,
                                           ft1000ReadProc, dev);
                snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
                break;
@@ -194,8 +194,8 @@ void ft1000InitProc(struct net_device *dev)
 
        info = netdev_priv(dev);
 
-       info->proc_ft1000 = proc_mkdir(FT1000_PROC, init_net.proc_net);
-       create_proc_read_entry(dev->name, 0644, info->proc_ft1000,
+       info->ft1000_proc_dir = proc_mkdir(FT1000_PROC, init_net.proc_net);
+       create_proc_read_entry(dev->name, 0644, info->ft1000_proc_dir,
                                   ft1000ReadProc, dev);
        snprintf(info->netdevname, IFNAMSIZ, "%s", dev->name);
        register_netdevice_notifier(&ft1000_netdev_notifier);
@@ -207,7 +207,7 @@ void ft1000CleanupProc(struct net_device *dev)
 
        info = netdev_priv(dev);
 
-       remove_proc_entry(dev->name, info->proc_ft1000);
+       remove_proc_entry(dev->name, info->ft1000_proc_dir);
        remove_proc_entry(FT1000_PROC, init_net.proc_net);
        unregister_netdevice_notifier(&ft1000_netdev_notifier);
 }
index 6d911fda47fb999e63e01abb07c7e23ec0135eac..297389e8c608367f5f5c3db88bdc448d73504b98 100644 (file)
@@ -137,29 +137,28 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist)
 // Notes:       Only called by init_module().
 //
 //---------------------------------------------------------------------------
-int ft1000_create_dev(struct ft1000_device *dev)
+int ft1000_create_dev(struct ft1000_usb *dev)
 {
-       struct ft1000_info *info = netdev_priv(dev->net);
     int result;
     int i;
        struct dentry *dir, *file;
        struct ft1000_debug_dirs *tmp;
 
     // make a new device name
-    sprintf(info->DeviceName, "%s%d", "FT1000_", info->CardNumber);
+    sprintf(dev->DeviceName, "%s%d", "FT1000_", dev->CardNumber);
 
     DEBUG("%s: number of instance = %d\n", __func__, ft1000_flarion_cnt);
-    DEBUG("DeviceCreated = %x\n", info->DeviceCreated);
+    DEBUG("DeviceCreated = %x\n", dev->DeviceCreated);
 
-    if (info->DeviceCreated)
+    if (dev->DeviceCreated)
     {
-       DEBUG("%s: \"%s\" already registered\n", __func__, info->DeviceName);
+       DEBUG("%s: \"%s\" already registered\n", __func__, dev->DeviceName);
        return -EIO;
     }
 
 
     // register the device
-    DEBUG("%s: \"%s\" debugfs device registration\n", __func__, info->DeviceName);
+    DEBUG("%s: \"%s\" debugfs device registration\n", __func__, dev->DeviceName);
 
        tmp = kmalloc(sizeof(struct ft1000_debug_dirs), GFP_KERNEL);
        if (tmp == NULL) {
@@ -167,7 +166,7 @@ int ft1000_create_dev(struct ft1000_device *dev)
                goto fail;
        }
 
-       dir = debugfs_create_dir(info->DeviceName, NULL);
+       dir = debugfs_create_dir(dev->DeviceName, NULL);
        if (IS_ERR(dir)) {
                result = PTR_ERR(dir);
                goto debug_dir_fail;
@@ -182,27 +181,27 @@ int ft1000_create_dev(struct ft1000_device *dev)
 
        tmp->dent = dir;
        tmp->file = file;
-       tmp->int_number = info->CardNumber;
-       list_add(&(tmp->list), &(info->nodes.list));
+       tmp->int_number = dev->CardNumber;
+       list_add(&(tmp->list), &(dev->nodes.list));
 
-    DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, info->DeviceName);
+    DEBUG("%s: registered debugfs directory \"%s\"\n", __func__, dev->DeviceName);
 
     // initialize application information
-    info->appcnt = 0;
+    dev->appcnt = 0;
     for (i=0; i<MAX_NUM_APP; i++) {
-        info->app_info[i].nTxMsg = 0;
-        info->app_info[i].nRxMsg = 0;
-        info->app_info[i].nTxMsgReject = 0;
-        info->app_info[i].nRxMsgMiss = 0;
-        info->app_info[i].fileobject = NULL;
-        info->app_info[i].app_id = i+1;
-        info->app_info[i].DspBCMsgFlag = 0;
-        info->app_info[i].NumOfMsg = 0;
-        init_waitqueue_head(&info->app_info[i].wait_dpram_msg);
-        INIT_LIST_HEAD (&info->app_info[i].app_sqlist);
+        dev->app_info[i].nTxMsg = 0;
+        dev->app_info[i].nRxMsg = 0;
+        dev->app_info[i].nTxMsgReject = 0;
+        dev->app_info[i].nRxMsgMiss = 0;
+        dev->app_info[i].fileobject = NULL;
+        dev->app_info[i].app_id = i+1;
+        dev->app_info[i].DspBCMsgFlag = 0;
+        dev->app_info[i].NumOfMsg = 0;
+        init_waitqueue_head(&dev->app_info[i].wait_dpram_msg);
+        INIT_LIST_HEAD (&dev->app_info[i].app_sqlist);
     }
 
-    info->DeviceCreated = TRUE;
+    dev->DeviceCreated = TRUE;
     ft1000_flarion_cnt++;
 
        return 0;
@@ -225,9 +224,10 @@ fail:
 // Notes:       Only called by cleanup_module().
 //
 //---------------------------------------------------------------------------
-void ft1000_destroy_dev(struct net_device *dev)
+void ft1000_destroy_dev(struct net_device *netdev)
 {
-       struct ft1000_info *info = netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(netdev);
+       struct ft1000_usb *dev = info->priv;
                int i;
        struct dpram_blk *pdpram_blk;
        struct dpram_blk *ptr;
@@ -238,12 +238,12 @@ void ft1000_destroy_dev(struct net_device *dev)
 
 
 
-    if (info->DeviceCreated)
+    if (dev->DeviceCreated)
        {
         ft1000_flarion_cnt--;
-               list_for_each_safe(pos, q, &info->nodes.list) {
+               list_for_each_safe(pos, q, &dev->nodes.list) {
                        dir = list_entry(pos, struct ft1000_debug_dirs, list);
-                       if (dir->int_number == info->CardNumber) {
+                       if (dir->int_number == dev->CardNumber) {
                                debugfs_remove(dir->file);
                                debugfs_remove(dir->dent);
                                list_del(pos);
@@ -251,17 +251,17 @@ void ft1000_destroy_dev(struct net_device *dev)
                        }
                }
                DEBUG("%s: unregistered device \"%s\"\n", __func__,
-                                          info->DeviceName);
+                                          dev->DeviceName);
 
         // Make sure we free any memory reserve for slow Queue
         for (i=0; i<MAX_NUM_APP; i++) {
-            while (list_empty(&info->app_info[i].app_sqlist) == 0) {
-                pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list);
+            while (list_empty(&dev->app_info[i].app_sqlist) == 0) {
+                pdpram_blk = list_entry(dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
                 list_del(&pdpram_blk->list);
                 ft1000_free_buffer(pdpram_blk, &freercvpool);
 
             }
-            wake_up_interruptible(&info->app_info[i].wait_dpram_msg);
+            wake_up_interruptible(&dev->app_info[i].wait_dpram_msg);
         }
 
         // Remove buffer allocated for receive command data
@@ -273,7 +273,7 @@ void ft1000_destroy_dev(struct net_device *dev)
                 kfree(ptr);
             }
         }
-               info->DeviceCreated = FALSE;
+               dev->DeviceCreated = FALSE;
        }
 
 
@@ -292,7 +292,7 @@ void ft1000_destroy_dev(struct net_device *dev)
 static int ft1000_open (struct inode *inode, struct file *file)
 {
        struct ft1000_info *info;
-       struct ft1000_device *dev = (struct ft1000_device *)inode->i_private;
+       struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private;
     int i,num;
 
     DEBUG("%s called\n", __func__);
@@ -301,17 +301,17 @@ static int ft1000_open (struct inode *inode, struct file *file)
 
        info = file->private_data = netdev_priv(dev->net);
 
-    DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), info->appcnt );
+    DEBUG("f_owner = %p number of application = %d\n", (&file->f_owner), dev->appcnt );
 
     // Check if maximum number of application exceeded
-    if (info->appcnt > MAX_NUM_APP) {
+    if (dev->appcnt > MAX_NUM_APP) {
         DEBUG("Maximum number of application exceeded\n");
         return -EACCES;
     }
 
     // Search for available application info block
     for (i=0; i<MAX_NUM_APP; i++) {
-        if ( (info->app_info[i].fileobject == NULL) ) {
+        if ( (dev->app_info[i].fileobject == NULL) ) {
             break;
         }
     }
@@ -322,12 +322,12 @@ static int ft1000_open (struct inode *inode, struct file *file)
         return -EACCES;
     }
 
-    info->appcnt++;
-    info->app_info[i].fileobject = &file->f_owner;
-    info->app_info[i].nTxMsg = 0;
-    info->app_info[i].nRxMsg = 0;
-    info->app_info[i].nTxMsgReject = 0;
-    info->app_info[i].nRxMsgMiss = 0;
+    dev->appcnt++;
+    dev->app_info[i].fileobject = &file->f_owner;
+    dev->app_info[i].nTxMsg = 0;
+    dev->app_info[i].nRxMsg = 0;
+    dev->app_info[i].nTxMsgReject = 0;
+    dev->app_info[i].nRxMsgMiss = 0;
 
        nonseekable_open(inode, file);
     return 0;
@@ -347,8 +347,9 @@ static int ft1000_open (struct inode *inode, struct file *file)
 
 static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
 {
-    struct net_device *dev = file->private_data;
-       struct ft1000_info *info;
+    struct net_device *netdev = file->private_data;
+       struct ft1000_info *info = netdev_priv(netdev);
+       struct ft1000_usb *dev = info->priv;
     int i;
 
     //DEBUG("ft1000_poll_dev called\n");
@@ -357,12 +358,10 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
         return (-EBADF);
     }
 
-       info = netdev_priv(dev);
-
     // Search for matching file object
     for (i=0; i<MAX_NUM_APP; i++) {
-        if ( info->app_info[i].fileobject == &file->f_owner) {
-            //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+        if ( dev->app_info[i].fileobject == &file->f_owner) {
+            //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", dev->app_info[i].app_id);
             break;
         }
     }
@@ -373,12 +372,12 @@ static unsigned int ft1000_poll_dev(struct file *file, poll_table *wait)
         return ( -EACCES );
     }
 
-    if (list_empty(&info->app_info[i].app_sqlist) == 0) {
+    if (list_empty(&dev->app_info[i].app_sqlist) == 0) {
         DEBUG("FT1000:ft1000_poll_dev:Message detected in slow queue\n");
         return(POLLIN | POLLRDNORM | POLLPRI);
     }
 
-    poll_wait (file, &info->app_info[i].wait_dpram_msg, wait);
+    poll_wait (file, &dev->app_info[i].wait_dpram_msg, wait);
     //DEBUG("FT1000:ft1000_poll_dev:Polling for data from DSP\n");
 
     return (0);
@@ -399,7 +398,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
 {
     void __user *argp = (void __user *)argument;
        struct ft1000_info *info;
-    struct ft1000_device *ft1000dev;
+    struct ft1000_usb *ft1000dev;
     int result=0;
     int cmd;
     int i;
@@ -428,7 +427,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
     //DEBUG("FT1000:ft1000_ioctl:command = 0x%x argument = 0x%8x\n", command, (u32)argument);
 
        info = file->private_data;
-       ft1000dev = info->pFt1000Dev;
+       ft1000dev = info->priv;
     cmd = _IOC_NR(command);
     //DEBUG("FT1000:ft1000_ioctl:cmd = 0x%x\n", cmd);
 
@@ -444,8 +443,8 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
             if (tempword == DSPBCMSGID) {
                 // Search for matching file object
                 for (i=0; i<MAX_NUM_APP; i++) {
-                    if ( info->app_info[i].fileobject == &file->f_owner) {
-                        info->app_info[i].DspBCMsgFlag = 1;
+                    if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
+                        ft1000dev->app_info[i].DspBCMsgFlag = 1;
                         DEBUG("FT1000:ft1000_ioctl:Registered for broadcast messages\n");
                         break;
                     }
@@ -534,15 +533,15 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
                 return (-EBADF);
             }
 
-            if (info->DrvMsgPend) {
+            if (ft1000dev->DrvMsgPend) {
                 return (-ENOTTY);
             }
 
-            if ( (info->DspAsicReset) || (info->fProvComplete == 0) ) {
+            if (ft1000dev->fProvComplete == 0) {
                 return (-EACCES);
             }
 
-            info->fAppMsgPend = 1;
+            ft1000dev->fAppMsgPend = 1;
 
             if (info->CardReady) {
 
@@ -571,7 +570,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
                 else {
                     // Check if this message came from a registered application
                     for (i=0; i<MAX_NUM_APP; i++) {
-                        if ( info->app_info[i].fileobject == &file->f_owner) {
+                        if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
                             break;
                         }
                     }
@@ -632,7 +631,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
 
                             // Insert slow queue sequence number
                             ppseudo_hdr->seq_num = info->squeseqnum++;
-                            ppseudo_hdr->portsrc = info->app_info[app_index].app_id;
+                            ppseudo_hdr->portsrc = ft1000dev->app_info[app_index].app_id;
                             // Calculate new checksum
                             ppseudo_hdr->checksum = *pmsg++;
                             //DEBUG("checksum = 0x%x\n", ppseudo_hdr->checksum);
@@ -645,7 +644,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
                            card_send_command(ft1000dev,(unsigned short*)dpram_data,total_len+2);
 
 
-                            info->app_info[app_index].nTxMsg++;
+                            ft1000dev->app_info[app_index].nTxMsg++;
                         }
                         else {
                             result = -EINVAL;
@@ -675,8 +674,8 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
 
             // Search for matching file object
             for (i=0; i<MAX_NUM_APP; i++) {
-                if ( info->app_info[i].fileobject == &file->f_owner) {
-                    //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+                if (ft1000dev->app_info[i].fileobject == &file->f_owner) {
+                    //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id);
                     break;
                 }
             }
@@ -690,13 +689,13 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
 
             result = 0;
             pioctl_dpram = argp;
-            if (list_empty(&info->app_info[i].app_sqlist) == 0) {
+            if (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
                 //DEBUG("FT1000:ft1000_ioctl:Message detected in slow queue\n");
                 spin_lock_irqsave(&free_buff_lock, flags);
-                pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list);
+                pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
                 list_del(&pdpram_blk->list);
-                info->app_info[i].NumOfMsg--;
-                //DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, info->app_info[i].NumOfMsg);
+                ft1000dev->app_info[i].NumOfMsg--;
+                //DEBUG("FT1000:ft1000_ioctl:NumOfMsg for app %d = %d\n", i, ft1000dev->app_info[i].NumOfMsg);
                 spin_unlock_irqrestore(&free_buff_lock, flags);
                 msglen = ntohs(*(u16 *)pdpram_blk->pbuffer) + PSEUDOSZ;
                 result = get_user(msglen, &pioctl_dpram->total_len);
@@ -723,7 +722,7 @@ static long ft1000_ioctl (struct file *file, unsigned int command,
         result = -ENOTTY;
         break;
     }
-    info->fAppMsgPend = 0;
+    ft1000dev->fAppMsgPend = 0;
     return result;
 }
 
@@ -741,6 +740,7 @@ static int ft1000_release (struct inode *inode, struct file *file)
 {
        struct ft1000_info *info;
     struct net_device *dev;
+    struct ft1000_usb *ft1000dev;
     int i;
        struct dpram_blk *pdpram_blk;
 
@@ -748,16 +748,17 @@ static int ft1000_release (struct inode *inode, struct file *file)
 
     dev = file->private_data;
        info = netdev_priv(dev);
+       ft1000dev = info->priv;
 
     if (ft1000_flarion_cnt == 0) {
-        info->appcnt--;
+        ft1000dev->appcnt--;
         return (-EBADF);
     }
 
     // Search for matching file object
     for (i=0; i<MAX_NUM_APP; i++) {
-        if ( info->app_info[i].fileobject == &file->f_owner) {
-            //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", info->app_info[i].app_id);
+        if ( ft1000dev->app_info[i].fileobject == &file->f_owner) {
+            //DEBUG("FT1000:ft1000_ioctl: Message is for AppId = %d\n", ft1000dev->app_info[i].app_id);
             break;
         }
     }
@@ -765,17 +766,17 @@ static int ft1000_release (struct inode *inode, struct file *file)
     if (i==MAX_NUM_APP)
            return 0;
 
-    while (list_empty(&info->app_info[i].app_sqlist) == 0) {
+    while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
         DEBUG("Remove and free memory queue up on slow queue\n");
-        pdpram_blk = list_entry(info->app_info[i].app_sqlist.next, struct dpram_blk, list);
+        pdpram_blk = list_entry(ft1000dev->app_info[i].app_sqlist.next, struct dpram_blk, list);
         list_del(&pdpram_blk->list);
         ft1000_free_buffer(pdpram_blk, &freercvpool);
     }
 
     // initialize application information
-    info->appcnt--;
-    DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, info->appcnt);
-    info->app_info[i].fileobject = NULL;
+    ft1000dev->appcnt--;
+    DEBUG("ft1000_chdev:%s:appcnt = %d\n", __FUNCTION__, ft1000dev->appcnt);
+    ft1000dev->app_info[i].fileobject = NULL;
 
     return 0;
 }
index 1972b72450d4ad8da84e5c0c29ad6acbca1259b5..5190c8ac4e0a77cbb03e4f5b4d14c4dd764469a0 100644 (file)
@@ -114,7 +114,7 @@ struct dsp_image_info {
 //---------------------------------------------------------------------------
 // Function:    check_usb_db
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //
 // Returns:     0 - success
 //
@@ -123,7 +123,7 @@ struct dsp_image_info {
 // Notes:
 //
 //---------------------------------------------------------------------------
-static u32 check_usb_db (struct ft1000_device *ft1000dev)
+static u32 check_usb_db (struct ft1000_usb *ft1000dev)
 {
        int loopcnt;
        u16 temp;
@@ -172,7 +172,7 @@ static u32 check_usb_db (struct ft1000_device *ft1000dev)
 //---------------------------------------------------------------------------
 // Function:    get_handshake
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //              u16 expected_value - the handshake value expected
 //
 // Returns:     handshakevalue - success
@@ -183,12 +183,11 @@ static u32 check_usb_db (struct ft1000_device *ft1000dev)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value)
+static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
 {
        u16 handshake;
        int loopcnt;
        u32 status = 0;
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
 
        loopcnt = 0;
 
@@ -196,10 +195,10 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value)
                /* Need to clear downloader doorbell if Hartley ASIC */
                status = ft1000_write_register(ft1000dev,  FT1000_DB_DNLD_RX,
                                                FT1000_REG_DOORBELL);
-               if (pft1000info->fcodeldr) {
+               if (ft1000dev->fcodeldr) {
                        DEBUG(" get_handshake: fcodeldr is %d\n",
-                               pft1000info->fcodeldr);
-                       pft1000info->fcodeldr = 0;
+                               ft1000dev->fcodeldr);
+                       ft1000dev->fcodeldr = 0;
                        status = check_usb_db(ft1000dev);
                        if (status != STATUS_SUCCESS) {
                                DEBUG("get_handshake: check_usb_db failed\n");
@@ -233,7 +232,7 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value)
 //---------------------------------------------------------------------------
 // Function:    put_handshake
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //              u16 handshake_value - handshake to be written
 //
 // Returns:     none
@@ -244,7 +243,7 @@ static u16 get_handshake(struct ft1000_device *ft1000dev, u16 expected_value)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static void put_handshake(struct ft1000_device *ft1000dev,u16 handshake_value)
+static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value)
 {
        u32 tempx;
        u16 tempword;
@@ -263,36 +262,35 @@ static void put_handshake(struct ft1000_device *ft1000dev,u16 handshake_value)
                                        FT1000_REG_DOORBELL);
 }
 
-static u16 get_handshake_usb(struct ft1000_device *ft1000dev, u16 expected_value)
+static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)
 {
        u16 handshake;
        int loopcnt;
        u16 temp;
        u32 status = 0;
 
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
        loopcnt = 0;
        handshake = 0;
 
        while (loopcnt < 100) {
-               if (pft1000info->usbboot == 2) {
+               if (ft1000dev->usbboot == 2) {
                        status = ft1000_read_dpram32(ft1000dev, 0,
-                                       (u8 *)&(pft1000info->tempbuf[0]), 64);
+                                       (u8 *)&(ft1000dev->tempbuf[0]), 64);
                        for (temp = 0; temp < 16; temp++) {
                                DEBUG("tempbuf %d = 0x%x\n", temp,
-                                       pft1000info->tempbuf[temp]);
+                                       ft1000dev->tempbuf[temp]);
                        }
                        status = ft1000_read_dpram16(ft1000dev,
                                                DWNLD_MAG1_HANDSHAKE_LOC,
                                                (u8 *)&handshake, 1);
                        DEBUG("handshake from read_dpram16 = 0x%x\n",
                                handshake);
-                       if (pft1000info->dspalive == pft1000info->tempbuf[6]) {
+                       if (ft1000dev->dspalive == ft1000dev->tempbuf[6]) {
                                handshake = 0;
                        } else {
-                               handshake = pft1000info->tempbuf[1];
-                               pft1000info->dspalive =
-                                               pft1000info->tempbuf[6];
+                               handshake = ft1000dev->tempbuf[1];
+                               ft1000dev->dspalive =
+                                               ft1000dev->tempbuf[6];
                        }
                } else {
                        status = ft1000_read_dpram16(ft1000dev,
@@ -311,7 +309,7 @@ static u16 get_handshake_usb(struct ft1000_device *ft1000dev, u16 expected_value
        return HANDSHAKE_TIMEOUT_VALUE;
 }
 
-static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_value)
+static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value)
 {
        int i;
 
@@ -321,7 +319,7 @@ static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_valu
 //---------------------------------------------------------------------------
 // Function:    get_request_type
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //
 // Returns:     request type - success
 //
@@ -330,15 +328,14 @@ static void put_handshake_usb(struct ft1000_device *ft1000dev,u16 handshake_valu
 // Notes:
 //
 //---------------------------------------------------------------------------
-static u16 get_request_type(struct ft1000_device *ft1000dev)
+static u16 get_request_type(struct ft1000_usb *ft1000dev)
 {
        u16 request_type;
        u32 status;
        u16 tempword;
        u32 tempx;
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
 
-       if (pft1000info->bootmode == 1) {
+       if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
                                DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx);
                tempx = ntohl(tempx);
@@ -354,22 +351,21 @@ static u16 get_request_type(struct ft1000_device *ft1000dev)
        return request_type;
 }
 
-static u16 get_request_type_usb(struct ft1000_device *ft1000dev)
+static u16 get_request_type_usb(struct ft1000_usb *ft1000dev)
 {
        u16 request_type;
        u32 status;
        u16 tempword;
        u32 tempx;
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
 
-       if (pft1000info->bootmode == 1) {
+       if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
                                DWNLD_MAG1_TYPE_LOC, (u8 *)&tempx);
                tempx = ntohl(tempx);
        } else {
-               if (pft1000info->usbboot == 2) {
-                       tempx = pft1000info->tempbuf[2];
-                       tempword = pft1000info->tempbuf[3];
+               if (ft1000dev->usbboot == 2) {
+                       tempx = ft1000dev->tempbuf[2];
+                       tempword = ft1000dev->tempbuf[3];
                } else {
                        tempx = 0;
                        status = ft1000_read_dpram16(ft1000dev,
@@ -387,7 +383,7 @@ static u16 get_request_type_usb(struct ft1000_device *ft1000dev)
 //---------------------------------------------------------------------------
 // Function:    get_request_value
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //
 // Returns:     request value - success
 //
@@ -396,14 +392,13 @@ static u16 get_request_type_usb(struct ft1000_device *ft1000dev)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static long get_request_value(struct ft1000_device *ft1000dev)
+static long get_request_value(struct ft1000_usb *ft1000dev)
 {
        u32 value;
        u16 tempword;
        u32 status;
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
 
-       if (pft1000info->bootmode == 1) {
+       if (ft1000dev->bootmode == 1) {
                status = fix_ft1000_read_dpram32(ft1000dev,
                                DWNLD_MAG1_SIZE_LOC, (u8 *)&value);
                value = ntohl(value);
@@ -424,7 +419,7 @@ static long get_request_value(struct ft1000_device *ft1000dev)
 //---------------------------------------------------------------------------
 // Function:    put_request_value
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //              long lvalue - value to be put into DPRAM location DWNLD_MAG1_SIZE_LOC
 //
 // Returns:     none
@@ -434,7 +429,7 @@ static long get_request_value(struct ft1000_device *ft1000dev)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static void put_request_value(struct ft1000_device *ft1000dev, long lvalue)
+static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue)
 {
        u32    tempx;
        u32    status;
@@ -485,7 +480,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset)
 //---------------------------------------------------------------------------
 // Function:    write_blk
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //              u16 **pUsFile - DSP image file pointer in u16
 //              u8  **pUcFile - DSP image file pointer in u8
 //              long   word_length - length of the buffer to be written
@@ -499,7 +494,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length)
+static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length)
 {
    u32 Status = STATUS_SUCCESS;
    u16 dpram;
@@ -507,7 +502,6 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi
    u16 tempword;
    u16 tempbuffer[64];
    u16 resultbuffer[64];
-       struct ft1000_info *pft1000info = netdev_priv(ft1000dev->net);
 
    //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length);
    dpram = (u16)DWNLD_MAG1_PS_HDR_LOC;
@@ -548,7 +542,7 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi
               //DEBUG("write_blk: loopcnt is %d\n", loopcnt);
               //DEBUG("write_blk: bootmode = %d\n", bootmode);
               //DEBUG("write_blk: dpram = %x\n", dpram);
-             if (pft1000info->bootmode == 0)
+             if (ft1000dev->bootmode == 0)
              {
                 if (dpram >= 0x3F4)
                      Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 8);
@@ -625,7 +619,7 @@ static void usb_dnld_complete (struct urb *urb)
 //---------------------------------------------------------------------------
 // Function:    write_blk_fifo
 //
-// Parameters:  struct ft1000_device  - device structure
+// Parameters:  struct ft1000_usb  - device structure
 //              u16 **pUsFile - DSP image file pointer in u16
 //              u8  **pUcFile - DSP image file pointer in u8
 //              long   word_length - length of the buffer to be written
@@ -639,7 +633,7 @@ static void usb_dnld_complete (struct urb *urb)
 // Notes:
 //
 //---------------------------------------------------------------------------
-static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile,
+static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile,
                          u8 **pUcFile, long word_length)
 {
        u32 Status = STATUS_SUCCESS;
@@ -682,7 +676,7 @@ static u32 write_blk_fifo(struct ft1000_device *ft1000dev, u16 **pUsFile,
 //  Returns:    status                  - return code
 //---------------------------------------------------------------------------
 
-u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
+u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                u32 FileLength)
 {
        u16 status = STATUS_SUCCESS;
@@ -718,9 +712,9 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
 
        DEBUG("Entered   scram_dnldr...\n");
 
-       pft1000info->fcodeldr = 0;
-       pft1000info->usbboot = 0;
-       pft1000info->dspalive = 0xffff;
+       ft1000dev->fcodeldr = 0;
+       ft1000dev->usbboot = 0;
+       ft1000dev->dspalive = 0xffff;
 
        //
        // Get version id of file, at first 4 bytes of file, for newer files.
@@ -745,7 +739,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                switch (state) {
                case STATE_START_DWNLD:
                        DEBUG("FT1000:STATE_START_DWNLD\n");
-                       if (pft1000info->usbboot)
+                       if (ft1000dev->usbboot)
                                handshake =
                                    get_handshake_usb(ft1000dev,
                                                      HANDSHAKE_DSP_BL_READY);
@@ -771,7 +765,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
 
                case STATE_BOOT_DWNLD:
                        DEBUG("FT1000:STATE_BOOT_DWNLD\n");
-                       pft1000info->bootmode = 1;
+                       ft1000dev->bootmode = 1;
                        handshake = get_handshake(ft1000dev, HANDSHAKE_REQUEST);
                        if (handshake == HANDSHAKE_REQUEST) {
                                /*
@@ -797,7 +791,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                                        //DEBUG("FT1000:download:s_file = 0x%8x\n", (int)s_file);
                                        //DEBUG("FT1000:download:c_file = 0x%8x\n", (int)c_file);
                                        state = STATE_CODE_DWNLD;
-                                       pft1000info->fcodeldr = 1;
+                                       ft1000dev->fcodeldr = 1;
                                        break;
                                case REQUEST_CODE_SEGMENT:
                                        //DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");
@@ -842,7 +836,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                                        status = STATUS_FAILURE;
                                        break;
                                }
-                               if (pft1000info->usbboot)
+                               if (ft1000dev->usbboot)
                                        put_handshake_usb(ft1000dev,
                                                          HANDSHAKE_RESPONSE);
                                else
@@ -858,8 +852,8 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
 
                case STATE_CODE_DWNLD:
                        //DEBUG("FT1000:STATE_CODE_DWNLD\n");
-                       pft1000info->bootmode = 0;
-                       if (pft1000info->usbboot)
+                       ft1000dev->bootmode = 0;
+                       if (ft1000dev->usbboot)
                                handshake =
                                    get_handshake_usb(ft1000dev,
                                                      HANDSHAKE_REQUEST);
@@ -870,7 +864,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                                /*
                                 * Get type associated with the request.
                                 */
-                               if (pft1000info->usbboot)
+                               if (ft1000dev->usbboot)
                                        request =
                                            get_request_type_usb(ft1000dev);
                                else
@@ -916,7 +910,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                                        }
                                        break;
                                case REQUEST_DONE_CL:
-                                       pft1000info->usbboot = 3;
+                                       ft1000dev->usbboot = 3;
                                        /* Reposition ptrs to beginning of provisioning section */
                                        s_file =
                                            (u16 *) (pFileStart +
@@ -965,9 +959,9 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
 
                                        write_blk_fifo(ft1000dev, &s_file,
                                                       &c_file, word_length);
-                                       if (pft1000info->usbboot == 0)
-                                               pft1000info->usbboot++;
-                                       if (pft1000info->usbboot == 1) {
+                                       if (ft1000dev->usbboot == 0)
+                                               ft1000dev->usbboot++;
+                                       if (ft1000dev->usbboot == 1) {
                                                tempword = 0;
                                                ft1000_write_dpram16(ft1000dev,
                                                                     DWNLD_MAG1_PS_HDR_LOC,
@@ -1117,7 +1111,7 @@ u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
                                        status = STATUS_FAILURE;
                                        break;
                                }
-                               if (pft1000info->usbboot)
+                               if (ft1000dev->usbboot)
                                        put_handshake_usb(ft1000dev,
                                                          HANDSHAKE_RESPONSE);
                                else
index 809fa4886961ac87768a18ff0bd4be86e8b8209f..9b8fed7b405b141ac234821b1a0ddfc0b7347326 100644 (file)
 
 //#define JDEBUG
 
-static int ft1000_reset(struct net_device *ft1000dev);
+static int ft1000_reset(void *ft1000dev);
 static int ft1000_submit_rx_urb(struct ft1000_info *info);
 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static int ft1000_open (struct net_device *dev);
 static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev);
-static int ft1000_chkcard (struct ft1000_device *dev);
+static int ft1000_chkcard (struct ft1000_usb *dev);
 
 static u8 tempbuffer[1600];
 
@@ -43,7 +43,7 @@ static u8 tempbuffer[1600];
 //---------------------------------------------------------------------------
 // Function:    ft1000_control
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              pipe - usb control message pipe
 //              request - control request
 //              requesttype - control message request type
@@ -61,7 +61,7 @@ static u8 tempbuffer[1600];
 // Notes:
 //
 //---------------------------------------------------------------------------
-static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe,
+static int ft1000_control(struct ft1000_usb *ft1000dev, unsigned int pipe,
                          u8 request, u8 requesttype, u16 value, u16 index,
                          void *data, u16 size, int timeout)
 {
@@ -84,7 +84,7 @@ static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe,
 //---------------------------------------------------------------------------
 // Function:    ft1000_read_register
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              Data - data buffer to hold the value read
 //              nRegIndex - register index
 //
@@ -97,7 +97,7 @@ static int ft1000_control(struct ft1000_device *ft1000dev, unsigned int pipe,
 //
 //---------------------------------------------------------------------------
 
-int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data,
+int ft1000_read_register(struct ft1000_usb *ft1000dev, u16* Data,
                         u16 nRegIndx)
 {
        int ret = STATUS_SUCCESS;
@@ -118,7 +118,7 @@ int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data,
 //---------------------------------------------------------------------------
 // Function:    ft1000_write_register
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              value - value to write into a register
 //              nRegIndex - register index
 //
@@ -130,7 +130,7 @@ int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data,
 // Notes:
 //
 //---------------------------------------------------------------------------
-int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value,
+int ft1000_write_register(struct ft1000_usb *ft1000dev, u16 value,
                          u16 nRegIndx)
 {
        int ret = STATUS_SUCCESS;
@@ -151,7 +151,7 @@ int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value,
 //---------------------------------------------------------------------------
 // Function:    ft1000_read_dpram32
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to read
 //              buffer - data buffer to hold the data read
 //              cnt - number of byte read from DPRAM
@@ -165,7 +165,7 @@ int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value,
 //
 //---------------------------------------------------------------------------
 
-int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
+int ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,
                        u16 cnt)
 {
        int ret = STATUS_SUCCESS;
@@ -186,7 +186,7 @@ int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 //---------------------------------------------------------------------------
 // Function:    ft1000_write_dpram32
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to write the data
 //              buffer - data buffer to write into DPRAM
 //              cnt - number of bytes to write
@@ -199,7 +199,7 @@ int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 // Notes:
 //
 //---------------------------------------------------------------------------
-int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
+int ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,
                         u16 cnt)
 {
        int ret = STATUS_SUCCESS;
@@ -223,7 +223,7 @@ int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 //---------------------------------------------------------------------------
 // Function:    ft1000_read_dpram16
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to read
 //              buffer - data buffer to hold the data read
 //              hightlow - high or low 16 bit word
@@ -236,7 +236,7 @@ int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 // Notes:
 //
 //---------------------------------------------------------------------------
-int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
+int ft1000_read_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer,
                        u8 highlow)
 {
        int ret = STATUS_SUCCESS;
@@ -263,7 +263,7 @@ int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 //---------------------------------------------------------------------------
 // Function:    ft1000_write_dpram16
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to write the data
 //              value - 16bits value to write
 //              hightlow - high or low 16 bit word
@@ -276,7 +276,7 @@ int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer,
 // Notes:
 //
 //---------------------------------------------------------------------------
-int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u8 highlow)
+int ft1000_write_dpram16(struct ft1000_usb *ft1000dev, u16 indx, u16 value, u8 highlow)
 {
        int ret = STATUS_SUCCESS;
        u8 request;
@@ -302,7 +302,7 @@ int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u
 //---------------------------------------------------------------------------
 // Function:    fix_ft1000_read_dpram32
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to read
 //              buffer - data buffer to hold the data read
 //
@@ -315,7 +315,7 @@ int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u
 // Notes:
 //
 //---------------------------------------------------------------------------
-int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx,
+int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev, u16 indx,
                            u8 *buffer)
 {
        u8 buf[16];
@@ -346,7 +346,7 @@ int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx,
 //---------------------------------------------------------------------------
 // Function:    fix_ft1000_write_dpram32
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              indx - starting address to write
 //              buffer - data buffer to write
 //
@@ -359,7 +359,7 @@ int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx,
 // Notes:
 //
 //---------------------------------------------------------------------------
-int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer)
+int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev, u16 indx, u8 *buffer)
 {
        u16 pos1;
        u16 pos2;
@@ -426,7 +426,7 @@ int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buff
 //
 //  Returns:    None
 //-----------------------------------------------------------------------
-static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value)
+static void card_reset_dsp(struct ft1000_usb *ft1000dev, bool value)
 {
        u16 status = STATUS_SUCCESS;
        u16 tempword;
@@ -465,7 +465,7 @@ static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value)
 //---------------------------------------------------------------------------
 // Function:    card_send_command
 //
-// Parameters:  ft1000_device  - device structure
+// Parameters:  ft1000_usb  - device structure
 //              ptempbuffer - command buffer
 //              size - command buffer size
 //
@@ -477,7 +477,7 @@ static void card_reset_dsp(struct ft1000_device *ft1000dev, bool value)
 // Notes:
 //
 //---------------------------------------------------------------------------
-void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer,
+void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,
                       int size)
 {
        unsigned short temp;
@@ -524,7 +524,7 @@ void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer,
 //
 //  Returns:    None
 //-----------------------------------------------------------------------
-int dsp_reload(struct ft1000_device *ft1000dev)
+int dsp_reload(struct ft1000_usb *ft1000dev)
 {
        u16 status;
        u16 tempword;
@@ -588,7 +588,7 @@ int dsp_reload(struct ft1000_device *ft1000dev)
 static void ft1000_reset_asic(struct net_device *dev)
 {
        struct ft1000_info *info = netdev_priv(dev);
-       struct ft1000_device *ft1000dev = info->pFt1000Dev;
+       struct ft1000_usb *ft1000dev = info->priv;
        u16 tempword;
 
        DEBUG("ft1000_hw:ft1000_reset_asic called\n");
@@ -627,15 +627,15 @@ static void ft1000_reset_asic(struct net_device *dev)
 static int ft1000_reset_card(struct net_device *dev)
 {
        struct ft1000_info *info = netdev_priv(dev);
-       struct ft1000_device *ft1000dev = info->pFt1000Dev;
+       struct ft1000_usb *ft1000dev = info->priv;
        u16 tempword;
        struct prov_record *ptr;
 
        DEBUG("ft1000_hw:ft1000_reset_card called.....\n");
 
-       info->fCondResetPend = 1;
+       ft1000dev->fCondResetPend = 1;
        info->CardReady = 0;
-       info->fProvComplete = 0;
+       ft1000dev->fProvComplete = 0;
 
        /* Make sure we free any memory reserve for provisioning */
        while (list_empty(&info->prov_list) == 0) {
@@ -666,7 +666,7 @@ static int ft1000_reset_card(struct net_device *dev)
 
        info->CardReady = 1;
 
-       info->fCondResetPend = 0;
+       ft1000dev->fCondResetPend = 0;
 
        return TRUE;
 }
@@ -694,7 +694,7 @@ static const struct net_device_ops ftnet_ops =
 // Notes:
 //
 //---------------------------------------------------------------------------
-int init_ft1000_netdev(struct ft1000_device *ft1000dev)
+int init_ft1000_netdev(struct ft1000_usb *ft1000dev)
 {
        struct net_device *netdev;
        struct ft1000_info *pInfo = NULL;
@@ -702,7 +702,7 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev)
        int i, ret_val;
        struct list_head *cur, *tmp;
        char card_nr[2];
-       unsigned long gCardIndex = 0;
+       u8 gCardIndex = 0;
 
        DEBUG("Enter init_ft1000_netdev...\n");
 
@@ -723,14 +723,14 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev)
        if (strncmp(netdev->name, "eth", 3) == 0) {
                card_nr[0] = netdev->name[3];
                card_nr[1] = '\0';
-               ret_val = strict_strtoul(card_nr, 10, &gCardIndex);
+               ret_val = kstrtou8(card_nr, 10, &gCardIndex);
                if (ret_val) {
                        printk(KERN_ERR "Can't parse netdev\n");
                        goto err_net;
                }
 
-               pInfo->CardNumber = gCardIndex;
-               DEBUG("card number = %d\n", pInfo->CardNumber);
+               ft1000dev->CardNumber = gCardIndex;
+               DEBUG("card number = %d\n", ft1000dev->CardNumber);
        } else {
                printk(KERN_ERR "ft1000: Invalid device name\n");
                ret_val = -ENXIO;
@@ -740,27 +740,27 @@ int init_ft1000_netdev(struct ft1000_device *ft1000dev)
        memset(&pInfo->stats, 0, sizeof(struct net_device_stats));
 
        spin_lock_init(&pInfo->dpram_lock);
-       pInfo->pFt1000Dev = ft1000dev;
+       pInfo->priv = ft1000dev;
        pInfo->DrvErrNum = 0;
        pInfo->registered = 1;
        pInfo->ft1000_reset = ft1000_reset;
        pInfo->mediastate = 0;
        pInfo->fifo_cnt = 0;
-       pInfo->DeviceCreated = FALSE;
+       ft1000dev->DeviceCreated = FALSE;
        pInfo->CardReady = 0;
        pInfo->DSP_TIME[0] = 0;
        pInfo->DSP_TIME[1] = 0;
        pInfo->DSP_TIME[2] = 0;
        pInfo->DSP_TIME[3] = 0;
-       pInfo->fAppMsgPend = 0;
-       pInfo->fCondResetPend = 0;
-       pInfo->usbboot = 0;
-       pInfo->dspalive = 0;
-       memset(&pInfo->tempbuf[0], 0, sizeof(pInfo->tempbuf));
+       ft1000dev->fAppMsgPend = 0;
+       ft1000dev->fCondResetPend = 0;
+       ft1000dev->usbboot = 0;
+       ft1000dev->dspalive = 0;
+       memset(&ft1000dev->tempbuf[0], 0, sizeof(ft1000dev->tempbuf));
 
        INIT_LIST_HEAD(&pInfo->prov_list);
 
-       INIT_LIST_HEAD(&pInfo->nodes.list);
+       INIT_LIST_HEAD(&ft1000dev->nodes.list);
 
        netdev->netdev_ops = &ftnet_ops;
 
@@ -822,7 +822,7 @@ err_net:
 // Notes:
 //
 //---------------------------------------------------------------------------
-int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
+int reg_ft1000_netdev(struct ft1000_usb *ft1000dev,
                      struct usb_interface *intf)
 {
        struct net_device *netdev;
@@ -854,7 +854,7 @@ int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
        return 0;
 }
 
-static int ft1000_reset(struct net_device *dev)
+int ft1000_reset(void *dev)
 {
        ft1000_reset_card(dev);
        return 0;
@@ -876,7 +876,7 @@ static int ft1000_reset(struct net_device *dev)
 static void ft1000_usb_transmit_complete(struct urb *urb)
 {
 
-       struct ft1000_device *ft1000dev = urb->context;
+       struct ft1000_usb *ft1000dev = urb->context;
 
        if (urb->status)
                pr_err("%s: TX status %d\n", ft1000dev->net->name, urb->status);
@@ -902,7 +902,7 @@ static void ft1000_usb_transmit_complete(struct urb *urb)
 static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
 {
        struct ft1000_info *pInfo = netdev_priv(netdev);
-       struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
+       struct ft1000_usb *pFt1000Dev = pInfo->priv;
 
        int count, ret;
        u8 *t;
@@ -981,7 +981,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 * packet, u16 len)
 static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ft1000_info *pInfo = netdev_priv(dev);
-       struct ft1000_device *pFt1000Dev = pInfo->pFt1000Dev;
+       struct ft1000_usb *pFt1000Dev = pInfo->priv;
        u8 *pdata;
        int maxlen, pipe;
 
@@ -1039,7 +1039,7 @@ err:
 static int ft1000_copy_up_pkt(struct urb *urb)
 {
        struct ft1000_info *info = urb->context;
-       struct ft1000_device *ft1000dev = info->pFt1000Dev;
+       struct ft1000_usb *ft1000dev = info->priv;
        struct net_device *net = ft1000dev->net;
 
        u16 tempword;
@@ -1134,7 +1134,7 @@ static int ft1000_copy_up_pkt(struct urb *urb)
 static int ft1000_submit_rx_urb(struct ft1000_info *info)
 {
        int result;
-       struct ft1000_device *pFt1000Dev = info->pFt1000Dev;
+       struct ft1000_usb *pFt1000Dev = info->priv;
 
        if (pFt1000Dev->status & FT1000_STATUS_CLOSING) {
                DEBUG("network driver is closed, return\n");
@@ -1177,9 +1177,10 @@ static int ft1000_submit_rx_urb(struct ft1000_info *info)
 static int ft1000_open(struct net_device *dev)
 {
        struct ft1000_info *pInfo = netdev_priv(dev);
+       struct ft1000_usb *pFt1000Dev = pInfo->priv;
        struct timeval tv;
 
-       DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber);
+       DEBUG("ft1000_open is called for card %d\n", pFt1000Dev->CardNumber);
 
        pInfo->stats.rx_bytes = 0;
        pInfo->stats.tx_bytes = 0;
@@ -1213,7 +1214,7 @@ static int ft1000_open(struct net_device *dev)
 int ft1000_close(struct net_device *net)
 {
        struct ft1000_info *pInfo = netdev_priv(net);
-       struct ft1000_device *ft1000dev = pInfo->pFt1000Dev;
+       struct ft1000_usb *ft1000dev = pInfo->priv;
 
        ft1000dev->status |= FT1000_STATUS_CLOSING;
 
@@ -1247,13 +1248,12 @@ static struct net_device_stats *ft1000_netdev_stats(struct net_device *dev)
 //              TRUE  (device is present)
 //
 //---------------------------------------------------------------------------
-static int ft1000_chkcard(struct ft1000_device *dev)
+static int ft1000_chkcard(struct ft1000_usb *dev)
 {
        u16 tempword;
        u16 status;
-       struct ft1000_info *info = netdev_priv(dev->net);
 
-       if (info->fCondResetPend) {
+       if (dev->fCondResetPend) {
                DEBUG
                    ("ft1000_hw:ft1000_chkcard:Card is being reset, return FALSE\n");
                return TRUE;
@@ -1293,7 +1293,7 @@ static int ft1000_chkcard(struct ft1000_device *dev)
 //          = 1 (successful)
 //
 //---------------------------------------------------------------------------
-static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
+static bool ft1000_receive_cmd(struct ft1000_usb *dev, u16 *pbuffer,
                               int maxsz, u16 *pnxtph)
 {
        u16 size, ret;
@@ -1360,7 +1360,7 @@ static bool ft1000_receive_cmd(struct ft1000_device *dev, u16 *pbuffer,
 
 static int ft1000_dsp_prov(void *arg)
 {
-       struct ft1000_device *dev = (struct ft1000_device *)arg;
+       struct ft1000_usb *dev = (struct ft1000_usb *)arg;
        struct ft1000_info *info = netdev_priv(dev->net);
        u16 tempword;
        u16 len;
@@ -1441,13 +1441,13 @@ static int ft1000_dsp_prov(void *arg)
 
        msleep(100);
 
-       info->fProvComplete = 1;
+       dev->fProvComplete = 1;
        info->CardReady = 1;
 
        return STATUS_SUCCESS;
 }
 
-static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
+static int ft1000_proc_drvmsg(struct ft1000_usb *dev, u16 size)
 {
        struct ft1000_info *info = netdev_priv(dev->net);
        u16 msgtype;
@@ -1498,7 +1498,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                                if (pmediamsg->state) {
                                        DEBUG("Media is up\n");
                                        if (info->mediastate == 0) {
-                                               if (info->NetDevRegDone) {
+                                               if (dev->NetDevRegDone) {
                                                        netif_wake_queue(dev->
                                                                         net);
                                                }
@@ -1508,7 +1508,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                                        DEBUG("Media is down\n");
                                        if (info->mediastate == 1) {
                                                info->mediastate = 0;
-                                               if (info->NetDevRegDone) {
+                                               if (dev->NetDevRegDone) {
                                                }
                                                info->ConTm = 0;
                                        }
@@ -1567,12 +1567,12 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                         * Send provisioning data to DSP
                         */
                        if (list_empty(&info->prov_list) == 0) {
-                               info->fProvComplete = 0;
+                               dev->fProvComplete = 0;
                                status = ft1000_dsp_prov(dev);
                                if (status != STATUS_SUCCESS)
                                        goto out;
                        } else {
-                               info->fProvComplete = 1;
+                               dev->fProvComplete = 1;
                                status =
                                    ft1000_write_register(dev, FT1000_DB_HB,
                                                          FT1000_REG_DOORBELL);
@@ -1605,7 +1605,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
        case DSP_GET_INFO:{
                        DEBUG("FT1000:drivermsg:Got DSP_GET_INFO\n");
                        /* copy dsp info block to dsp */
-                       info->DrvMsgPend = 1;
+                       dev->DrvMsgPend = 1;
                        /* allow any outstanding ioctl to finish */
                        mdelay(10);
                        status =
@@ -1667,7 +1667,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                        status =
                            ft1000_write_register(dev, FT1000_DB_DPRAM_TX,
                                                  FT1000_REG_DOORBELL);
-                       info->DrvMsgPend = 0;
+                       dev->DrvMsgPend = 0;
 
                        break;
                }
@@ -1675,7 +1675,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
        case GET_DRV_ERR_RPT_MSG:{
                        DEBUG("FT1000:drivermsg:Got GET_DRV_ERR_RPT_MSG\n");
                        /* copy driver error message to dsp */
-                       info->DrvMsgPend = 1;
+                       dev->DrvMsgPend = 1;
                        /* allow any outstanding ioctl to finish */
                        mdelay(10);
                        status =
@@ -1735,7 +1735,7 @@ static int ft1000_proc_drvmsg(struct ft1000_device *dev, u16 size)
                                                 (u16) (0x0012 + PSEUDOSZ));
                                info->DrvErrNum = 0;
                        }
-                       info->DrvMsgPend = 0;
+                       dev->DrvMsgPend = 0;
 
                        break;
                }
@@ -1753,7 +1753,7 @@ out:
 
 int ft1000_poll(void* dev_id)
 {
-    struct ft1000_device *dev = (struct ft1000_device *)dev_id;
+    struct ft1000_usb *dev = (struct ft1000_usb *)dev_id;
        struct ft1000_info *info = netdev_priv(dev->net);
 
     u16 tempword;
@@ -1804,8 +1804,8 @@ int ft1000_poll(void* dev_id)
                         // Check which application has registered for dsp broadcast messages
 
                        for (i=0; i<MAX_NUM_APP; i++) {
-                          if ( (info->app_info[i].DspBCMsgFlag) && (info->app_info[i].fileobject) &&
-                                         (info->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  )
+                          if ( (dev->app_info[i].DspBCMsgFlag) && (dev->app_info[i].fileobject) &&
+                                         (dev->app_info[i].NumOfMsg < MAX_MSG_LIMIT)  )
                           {
                               nxtph = FT1000_DPRAM_RX_BASE + 2;
                               pdpram_blk = ft1000_get_buffer (&freercvpool);
@@ -1813,15 +1813,15 @@ int ft1000_poll(void* dev_id)
                                   if ( ft1000_receive_cmd(dev, pdpram_blk->pbuffer, MAX_CMD_SQSIZE, &nxtph) ) {
                                        ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
                                       // Put message into the appropriate application block
-                                      info->app_info[i].nRxMsg++;
+                                      dev->app_info[i].nRxMsg++;
                                       spin_lock_irqsave(&free_buff_lock, flags);
-                                      list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
-                                      info->app_info[i].NumOfMsg++;
+                                      list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist);
+                                      dev->app_info[i].NumOfMsg++;
                                       spin_unlock_irqrestore(&free_buff_lock, flags);
-                                      wake_up_interruptible(&info->app_info[i].wait_dpram_msg);
+                                      wake_up_interruptible(&dev->app_info[i].wait_dpram_msg);
                                    }
                                    else {
-                                      info->app_info[i].nRxMsgMiss++;
+                                      dev->app_info[i].nRxMsgMiss++;
                                       // Put memory back to free pool
                                       ft1000_free_buffer(pdpram_blk, &freercvpool);
                                       DEBUG("pdpram_blk::ft1000_get_buffer NULL\n");
@@ -1829,7 +1829,7 @@ int ft1000_poll(void* dev_id)
                                }
                                else {
                                    DEBUG("Out of memory in free receive command pool\n");
-                                   info->app_info[i].nRxMsgMiss++;
+                                   dev->app_info[i].nRxMsgMiss++;
                                }
                            }
                        }
@@ -1842,7 +1842,7 @@ int ft1000_poll(void* dev_id)
                                ppseudo_hdr = (struct pseudo_hdr *)pdpram_blk->pbuffer;
                                // Search for correct application block
                                for (i=0; i<MAX_NUM_APP; i++) {
-                                   if (info->app_info[i].app_id == ppseudo_hdr->portdest) {
+                                   if (dev->app_info[i].app_id == ppseudo_hdr->portdest) {
                                        break;
                                    }
                                }
@@ -1853,15 +1853,15 @@ int ft1000_poll(void* dev_id)
                                    ft1000_free_buffer(pdpram_blk, &freercvpool);
                                }
                                else {
-                                   if (info->app_info[i].NumOfMsg > MAX_MSG_LIMIT) {
+                                   if (dev->app_info[i].NumOfMsg > MAX_MSG_LIMIT) {
                                       // Put memory back to free pool
                                       ft1000_free_buffer(pdpram_blk, &freercvpool);
                                    }
                                    else {
-                                       info->app_info[i].nRxMsg++;
+                                       dev->app_info[i].nRxMsg++;
                                        // Put message into the appropriate application block
-                                       list_add_tail(&pdpram_blk->list, &info->app_info[i].app_sqlist);
-                                      info->app_info[i].NumOfMsg++;
+                                       list_add_tail(&pdpram_blk->list, &dev->app_info[i].app_sqlist);
+                                      dev->app_info[i].NumOfMsg++;
                                    }
                                }
                            }
@@ -1921,7 +1921,7 @@ int ft1000_poll(void* dev_id)
         else if (tempword & FT1000_DB_COND_RESET) {
             DEBUG("ft1000_poll: FT1000_REG_DOORBELL message type:  FT1000_DB_COND_RESET\n");
 
-           if (info->fAppMsgPend == 0) {
+           if (dev->fAppMsgPend == 0) {
                // Reset ASIC and DSP
 
                 status    = ft1000_read_dpram16(dev, FT1000_MAG_DSP_TIMER0, (u8 *)&(info->DSP_TIME[0]), FT1000_MAG_DSP_TIMER0_INDX);
@@ -1934,8 +1934,8 @@ int ft1000_poll(void* dev_id)
                 info->ft1000_reset(dev->net);
             }
             else {
-                info->fProvComplete = 0;
-                info->fCondResetPend = 1;
+                dev->fProvComplete = 0;
+                dev->fCondResetPend = 1;
             }
 
             ft1000_write_register(dev, FT1000_DB_COND_RESET, FT1000_REG_DOORBELL);
index 1edaddba816f3277d23ea7b21f7b6523611b9b7e..b99640637fe0edb49a13f80b986e22ac40295dc2 100644 (file)
@@ -51,7 +51,7 @@
 #define FTNET_PROC init_net.proc_net
 
 
-int ft1000_read_dpram16 (struct ft1000_device *ft1000dev, u16 indx,
+int ft1000_read_dpram16 (struct ft1000_usb *ft1000dev, u16 indx,
                         u8 *buffer, u8 highlow);
 
 
@@ -94,11 +94,11 @@ ft1000ReadProc(char *page, char **start, off_t off, int count, int *eof,
 
 
        if (info->ProgConStat != 0xFF) {
-               ft1000_read_dpram16(info->pFt1000Dev, FT1000_MAG_DSP_LED,
+               ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_LED,
                           (u8 *)&ledStat, FT1000_MAG_DSP_LED_INDX);
                info->LedStat = ntohs(ledStat);
 
-               ft1000_read_dpram16(info->pFt1000Dev, FT1000_MAG_DSP_CON_STATE,
+               ft1000_read_dpram16(info->priv, FT1000_MAG_DSP_CON_STATE,
                        (u8 *)&conStat, FT1000_MAG_DSP_CON_STATE_INDX);
                info->ConStat = ntohs(conStat);
                do_gettimeofday(&tv);
index b2ecd0e6780e07d17743645f77788f95246a1fe5..1bf3792ffebeac87ce433d2db690347d8d7758d6 100644 (file)
@@ -63,11 +63,11 @@ static int ft1000_probe(struct usb_interface *interface,
        unsigned numaltsetting;
        int i, ret = 0, size;
 
-       struct ft1000_device *ft1000dev;
+       struct ft1000_usb *ft1000dev;
        struct ft1000_info *pft1000info = NULL;
        const struct firmware *dsp_fw;
 
-       ft1000dev = kzalloc(sizeof(struct ft1000_device), GFP_KERNEL);
+       ft1000dev = kzalloc(sizeof(struct ft1000_usb), GFP_KERNEL);
 
        if (!ft1000dev) {
                pr_err("out of memory allocating device structure\n");
@@ -171,11 +171,11 @@ static int ft1000_probe(struct usb_interface *interface,
        }
 
        gPollingfailed = FALSE;
-       pft1000info->pPollThread =
+       ft1000dev->pPollThread =
            kthread_run(ft1000_poll_thread, ft1000dev, "ft1000_poll");
 
-       if (IS_ERR(pft1000info->pPollThread)) {
-               ret = PTR_ERR(pft1000info->pPollThread);
+       if (IS_ERR(ft1000dev->pPollThread)) {
+               ret = PTR_ERR(ft1000dev->pPollThread);
                goto err_load;
        }
 
@@ -200,7 +200,7 @@ static int ft1000_probe(struct usb_interface *interface,
        if (ret)
                goto err_proc;
 
-       pft1000info->NetDevRegDone = 1;
+       ft1000dev->NetDevRegDone = 1;
 
        return 0;
 
@@ -208,7 +208,7 @@ err_proc:
        unregister_netdev(ft1000dev->net);
        free_netdev(ft1000dev->net);
 err_thread:
-       kthread_stop(pft1000info->pPollThread);
+       kthread_stop(ft1000dev->pPollThread);
 err_load:
        kfree(pFileStart);
 err_fw:
@@ -219,6 +219,7 @@ err_fw:
 static void ft1000_disconnect(struct usb_interface *interface)
 {
        struct ft1000_info *pft1000info;
+       struct ft1000_usb *ft1000dev;
 
        DEBUG("ft1000_disconnect is called\n");
 
@@ -226,28 +227,29 @@ static void ft1000_disconnect(struct usb_interface *interface)
        DEBUG("In disconnect pft1000info=%p\n", pft1000info);
 
        if (pft1000info) {
+               ft1000dev = pft1000info->priv;
                ft1000_cleanup_proc(pft1000info);
-               if (pft1000info->pPollThread)
-                       kthread_stop(pft1000info->pPollThread);
+               if (ft1000dev->pPollThread)
+                       kthread_stop(ft1000dev->pPollThread);
 
                DEBUG("ft1000_disconnect: threads are terminated\n");
 
-               if (pft1000info->pFt1000Dev->net) {
+               if (ft1000dev->net) {
                        DEBUG("ft1000_disconnect: destroy char driver\n");
-                       ft1000_destroy_dev(pft1000info->pFt1000Dev->net);
-                       unregister_netdev(pft1000info->pFt1000Dev->net);
+                       ft1000_destroy_dev(ft1000dev->net);
+                       unregister_netdev(ft1000dev->net);
                        DEBUG
                            ("ft1000_disconnect: network device unregistered\n");
-                       free_netdev(pft1000info->pFt1000Dev->net);
+                       free_netdev(ft1000dev->net);
 
                }
 
-               usb_free_urb(pft1000info->pFt1000Dev->rx_urb);
-               usb_free_urb(pft1000info->pFt1000Dev->tx_urb);
+               usb_free_urb(ft1000dev->rx_urb);
+               usb_free_urb(ft1000dev->tx_urb);
 
                DEBUG("ft1000_disconnect: urb freed\n");
 
-               kfree(pft1000info->pFt1000Dev);
+               kfree(ft1000dev);
        }
        kfree(pFileStart);
 
index 2aa6a1c7fd38046d67c07905a8a7efb8d3ab9032..bd1da1f19cd269430f31b804e5ec63ca8c313edc 100644 (file)
@@ -55,7 +55,14 @@ struct app_info_block {
 
 #define MAX_BUF_SIZE            4096
 
-struct ft1000_device {
+struct ft1000_debug_dirs {
+       struct list_head list;
+       struct dentry *dent;
+       struct dentry *file;
+       int int_number;
+};
+
+struct ft1000_usb {
        struct usb_device *dev;
        struct net_device *net;
 
@@ -69,71 +76,26 @@ struct ft1000_device {
 
        u8 bulk_in_endpointAddr;
        u8 bulk_out_endpointAddr;
-} __packed;
-
-struct ft1000_debug_dirs {
-       struct list_head list;
-       struct dentry *dent;
-       struct dentry *file;
-       int int_number;
-};
-
-struct ft1000_info {
-       struct ft1000_device *pFt1000Dev;
-       struct net_device_stats stats;
 
        struct task_struct *pPollThread;
-
        unsigned char fcodeldr;
        unsigned char bootmode;
        unsigned char usbboot;
        unsigned short dspalive;
-       u16 ASIC_ID;
        bool fProvComplete;
        bool fCondResetPend;
        bool fAppMsgPend;
-       u16 DrvErrNum;
-       u16 AsicID;
-       int DspAsicReset;
        int DeviceCreated;
-       int CardReady;
        int NetDevRegDone;
        u8 CardNumber;
        u8 DeviceName[15];
        struct ft1000_debug_dirs nodes;
-       int registered;
-       int mediastate;
-       u8 squeseqnum;                 /* sequence number on slow queue */
-       spinlock_t dpram_lock;
        spinlock_t fifo_lock;
-       u16 fifo_cnt;
-       u8 DspVer[DSPVERSZ];        /* DSP version number */
-       u8 HwSerNum[HWSERNUMSZ];    /* Hardware Serial Number */
-       u8 Sku[SKUSZ];              /* SKU */
-       u8 eui64[EUISZ];            /* EUI64 */
-       time_t ConTm;               /* Connection Time */
-       u8 ProductMode[MODESZ];
-       u8 RfCalVer[CALVERSZ];
-       u8 RfCalDate[CALDATESZ];
-       u16 DSP_TIME[4];
-       u16 LedStat;
-       u16 ConStat;
-       u16 ProgConStat;
-       struct list_head prov_list;
        int appcnt;
        struct app_info_block app_info[MAX_NUM_APP];
-       u16 DSPInfoBlklen;
        u16 DrvMsgPend;
-       int (*ft1000_reset)(struct net_device *dev);
-       u16 DSPInfoBlk[MAX_DSP_SESS_REC];
-       union {
-               u16 Rec[MAX_DSP_SESS_REC];
-               u32 MagRec[MAX_DSP_SESS_REC/2];
-       } DSPSess;
        unsigned short tempbuf[32];
-       char netdevname[IFNAMSIZ];
-       struct proc_dir_entry *ft1000_proc_dir;
-};
+} __packed;
 
 
 struct dpram_blk {
@@ -141,21 +103,21 @@ struct dpram_blk {
        u16 *pbuffer;
 } __packed;
 
-int ft1000_read_register(struct ft1000_device *ft1000dev,
+int ft1000_read_register(struct ft1000_usb *ft1000dev,
                        u16 *Data, u16 nRegIndx);
-int ft1000_write_register(struct ft1000_device *ft1000dev,
+int ft1000_write_register(struct ft1000_usb *ft1000dev,
                        u16 value, u16 nRegIndx);
-int ft1000_read_dpram32(struct ft1000_device *ft1000dev,
+int ft1000_read_dpram32(struct ft1000_usb *ft1000dev,
                        u16 indx, u8 *buffer, u16 cnt);
-int ft1000_write_dpram32(struct ft1000_device *ft1000dev,
+int ft1000_write_dpram32(struct ft1000_usb *ft1000dev,
                        u16 indx, u8 *buffer, u16 cnt);
-int ft1000_read_dpram16(struct ft1000_device *ft1000dev,
+int ft1000_read_dpram16(struct ft1000_usb *ft1000dev,
                        u16 indx, u8 *buffer, u8 highlow);
-int ft1000_write_dpram16(struct ft1000_device *ft1000dev,
+int ft1000_write_dpram16(struct ft1000_usb *ft1000dev,
                        u16 indx, u16 value, u8 highlow);
-int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev,
+int fix_ft1000_read_dpram32(struct ft1000_usb *ft1000dev,
                        u16 indx, u8 *buffer);
-int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev,
+int fix_ft1000_write_dpram32(struct ft1000_usb *ft1000dev,
                        u16 indx, u8 *buffer);
 
 extern void *pFileStart;
@@ -163,25 +125,25 @@ extern size_t FileLength;
 extern int numofmsgbuf;
 
 int ft1000_close(struct net_device *dev);
-u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
+u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                u32  FileLength);
 
 extern struct list_head freercvpool;
 
 extern spinlock_t free_buff_lock;   /* lock to arbitrate free buffer list for receive command data */
 
-int ft1000_create_dev(struct ft1000_device *dev);
+int ft1000_create_dev(struct ft1000_usb *dev);
 void ft1000_destroy_dev(struct net_device *dev);
-extern void card_send_command(struct ft1000_device *ft1000dev,
+extern void card_send_command(struct ft1000_usb *ft1000dev,
                                void *ptempbuffer, int size);
 
 struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);
 void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist);
 
-int dsp_reload(struct ft1000_device *ft1000dev);
-int init_ft1000_netdev(struct ft1000_device *ft1000dev);
+int dsp_reload(struct ft1000_usb *ft1000dev);
+int init_ft1000_netdev(struct ft1000_usb *ft1000dev);
 struct usb_interface;
-int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
+int reg_ft1000_netdev(struct ft1000_usb *ft1000dev,
                        struct usb_interface *intf);
 int ft1000_poll(void *dev_id);
 
index 03baa5779234da8c4541db4791fa854463ad24ac..175abfa7682e260d94d74f92fd5a398321d8c654 100644 (file)
@@ -250,3 +250,38 @@ struct prov_record {
        struct list_head list;
        u8 *pprov_data;
 };
+
+struct ft1000_info {
+       void *priv;
+       struct net_device_stats stats;
+       u16 DrvErrNum;
+       u16 AsicID;
+       int CardReady;
+       int registered;
+       int mediastate;
+       u8 squeseqnum;                  /* sequence number on slow queue */
+       spinlock_t dpram_lock;
+       u16 fifo_cnt;
+       u8 DspVer[DSPVERSZ];            /* DSP version number */
+       u8 HwSerNum[HWSERNUMSZ];        /* Hardware Serial Number */
+       u8 Sku[SKUSZ];                  /* SKU */
+       u8 eui64[EUISZ];                /* EUI64 */
+       time_t ConTm;                   /* Connection Time */
+       u8 ProductMode[MODESZ];
+       u8 RfCalVer[CALVERSZ];
+       u8 RfCalDate[CALDATESZ];
+       u16 DSP_TIME[4];
+       u16 LedStat;
+       u16 ConStat;
+       u16 ProgConStat;
+       struct list_head prov_list;
+       u16 DSPInfoBlklen;
+       int (*ft1000_reset)(void *);
+       u16 DSPInfoBlk[MAX_DSP_SESS_REC];
+       union {
+               u16 Rec[MAX_DSP_SESS_REC];
+               u32 MagRec[MAX_DSP_SESS_REC/2];
+       } DSPSess;
+       struct proc_dir_entry *ft1000_proc_dir;
+       char netdevname[IFNAMSIZ];
+};
diff --git a/drivers/staging/goldfish/Kconfig b/drivers/staging/goldfish/Kconfig
new file mode 100644 (file)
index 0000000..d6c98d0
--- /dev/null
@@ -0,0 +1,12 @@
+config GOLDFISH_AUDIO
+       tristate "Goldfish AVD Audio Device"
+       depends on GOLDFISH
+       ---help---
+         Emulated audio channel for the Goldfish Android Virtual Device
+
+config MTD_GOLDFISH_NAND
+       tristate "Goldfish NAND device"
+       depends on GOLDFISH
+       help
+         Drives the emulated NAND flash device on the Google Goldfish
+         Android virtual device.
diff --git a/drivers/staging/goldfish/Makefile b/drivers/staging/goldfish/Makefile
new file mode 100644 (file)
index 0000000..dec34ad
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# Makefile for the Goldfish audio driver
+#
+
+obj-$(CONFIG_GOLDFISH_AUDIO) += goldfish_audio.o
+obj-$(CONFIG_MTD_GOLDFISH_NAND)        += goldfish_nand.o
diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README
new file mode 100644 (file)
index 0000000..93d65b0
--- /dev/null
@@ -0,0 +1,12 @@
+Audio
+-----
+- Move to using the ALSA framework not faking it
+- Fix the wrong user page DMA (moving to ALSA may fix that too)
+
+NAND
+----
+- Switch from spinlock to mutex
+- Remove excess checking of parameters in calls
+- Use dma coherent memory not kmalloc/__pa for the memory (this is just
+  a cleanliness issue not a correctness one)
+
diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c
new file mode 100644 (file)
index 0000000..d3bed21
--- /dev/null
@@ -0,0 +1,363 @@
+/* drivers/misc/goldfish_audio.c
+ *
+ * Copyright (C) 2007 Google, Inc.
+ * Copyright (C) 2012 Intel, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/miscdevice.h>
+#include <linux/fs.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/sched.h>
+#include <linux/dma-mapping.h>
+#include <linux/uaccess.h>
+
+MODULE_AUTHOR("Google, Inc.");
+MODULE_DESCRIPTION("Android QEMU Audio Driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("1.0");
+
+struct goldfish_audio {
+       char __iomem *reg_base;
+       int irq;
+       spinlock_t lock;
+       wait_queue_head_t wait;
+
+       char __iomem *buffer_virt;      /* combined buffer virtual address */
+       unsigned long buffer_phys;      /* combined buffer physical address */
+
+       char __iomem *write_buffer1;    /* write buffer 1 virtual address */
+       char __iomem *write_buffer2;    /* write buffer 2 virtual address */
+       char __iomem *read_buffer;      /* read buffer virtual address */
+       int buffer_status;
+       int read_supported;         /* true if we have audio input support */
+};
+
+/* We will allocate two read buffers and two write buffers.
+   Having two read buffers facilitate stereo -> mono conversion.
+   Having two write buffers facilitate interleaved IO.
+*/
+#define READ_BUFFER_SIZE        16384
+#define WRITE_BUFFER_SIZE       16384
+#define COMBINED_BUFFER_SIZE    ((2 * READ_BUFFER_SIZE) + \
+                                       (2 * WRITE_BUFFER_SIZE))
+
+#define AUDIO_READ(data, addr)         (readl(data->reg_base + addr))
+#define AUDIO_WRITE(data, addr, x)     (writel(x, data->reg_base + addr))
+
+/* temporary variable used between goldfish_audio_probe() and
+   goldfish_audio_open() */
+static struct goldfish_audio *audio_data;
+
+enum {
+       /* audio status register */
+       AUDIO_INT_STATUS        = 0x00,
+       /* set this to enable IRQ */
+       AUDIO_INT_ENABLE        = 0x04,
+       /* set these to specify buffer addresses */
+       AUDIO_SET_WRITE_BUFFER_1 = 0x08,
+       AUDIO_SET_WRITE_BUFFER_2 = 0x0C,
+       /* set number of bytes in buffer to write */
+       AUDIO_WRITE_BUFFER_1  = 0x10,
+       AUDIO_WRITE_BUFFER_2  = 0x14,
+
+       /* true if audio input is supported */
+       AUDIO_READ_SUPPORTED = 0x18,
+       /* buffer to use for audio input */
+       AUDIO_SET_READ_BUFFER = 0x1C,
+
+       /* driver writes number of bytes to read */
+       AUDIO_START_READ  = 0x20,
+
+       /* number of bytes available in read buffer */
+       AUDIO_READ_BUFFER_AVAILABLE  = 0x24,
+
+       /* AUDIO_INT_STATUS bits */
+
+       /* this bit set when it is safe to write more bytes to the buffer */
+       AUDIO_INT_WRITE_BUFFER_1_EMPTY  = 1U << 0,
+       AUDIO_INT_WRITE_BUFFER_2_EMPTY  = 1U << 1,
+       AUDIO_INT_READ_BUFFER_FULL      = 1U << 2,
+
+       AUDIO_INT_MASK                  = AUDIO_INT_WRITE_BUFFER_1_EMPTY |
+                                         AUDIO_INT_WRITE_BUFFER_2_EMPTY |
+                                         AUDIO_INT_READ_BUFFER_FULL,
+};
+
+
+static atomic_t open_count = ATOMIC_INIT(0);
+
+
+static ssize_t goldfish_audio_read(struct file *fp, char __user *buf,
+                                               size_t count, loff_t *pos)
+{
+       struct goldfish_audio *data = fp->private_data;
+       int length;
+       int result = 0;
+
+       if (!data->read_supported)
+               return -ENODEV;
+
+       while (count > 0) {
+               length = (count > READ_BUFFER_SIZE ? READ_BUFFER_SIZE : count);
+               AUDIO_WRITE(data, AUDIO_START_READ, length);
+
+               wait_event_interruptible(data->wait,
+                       (data->buffer_status & AUDIO_INT_READ_BUFFER_FULL));
+
+               length = AUDIO_READ(data,
+                                               AUDIO_READ_BUFFER_AVAILABLE);
+
+               /* copy data to user space */
+               if (copy_to_user(buf, data->read_buffer, length))
+                       return -EFAULT;
+
+               result += length;
+               buf += length;
+               count -= length;
+       }
+       return result;
+}
+
+static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf,
+                                                size_t count, loff_t *pos)
+{
+       struct goldfish_audio *data = fp->private_data;
+       unsigned long irq_flags;
+       ssize_t result = 0;
+       char __iomem *kbuf;
+
+       while (count > 0) {
+               ssize_t copy = count;
+               if (copy > WRITE_BUFFER_SIZE)
+                       copy = WRITE_BUFFER_SIZE;
+               wait_event_interruptible(data->wait, (data->buffer_status &
+                                       (AUDIO_INT_WRITE_BUFFER_1_EMPTY |
+                                       AUDIO_INT_WRITE_BUFFER_2_EMPTY)));
+
+               if ((data->buffer_status & AUDIO_INT_WRITE_BUFFER_1_EMPTY) != 0)
+                       kbuf = data->write_buffer1;
+               else
+                       kbuf = data->write_buffer2;
+
+               /* copy from user space to the appropriate buffer */
+               if (copy_from_user(kbuf, buf, copy)) {
+                       result = -EFAULT;
+                       break;
+               }
+
+               spin_lock_irqsave(&data->lock, irq_flags);
+               /* clear the buffer empty flag, and signal the emulator
+                * to start writing the buffer */
+               if (kbuf == data->write_buffer1) {
+                       data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_1_EMPTY;
+                       AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_1, copy);
+               } else {
+                       data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_2_EMPTY;
+                       AUDIO_WRITE(data, AUDIO_WRITE_BUFFER_2, copy);
+               }
+               spin_unlock_irqrestore(&data->lock, irq_flags);
+
+               buf += copy;
+               result += copy;
+               count -= copy;
+       }
+       return result;
+}
+
+static int goldfish_audio_open(struct inode *ip, struct file *fp)
+{
+       if (!audio_data)
+               return -ENODEV;
+
+       if (atomic_inc_return(&open_count) == 1) {
+               fp->private_data = audio_data;
+               audio_data->buffer_status = (AUDIO_INT_WRITE_BUFFER_1_EMPTY |
+                                            AUDIO_INT_WRITE_BUFFER_2_EMPTY);
+               AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, AUDIO_INT_MASK);
+               return 0;
+       } else {
+               atomic_dec(&open_count);
+               return -EBUSY;
+       }
+}
+
+static int goldfish_audio_release(struct inode *ip, struct file *fp)
+{
+       atomic_dec(&open_count);
+       /* FIXME: surely this is wrong for the multi-opened case */
+       AUDIO_WRITE(audio_data, AUDIO_INT_ENABLE, 0);
+       return 0;
+}
+
+static long goldfish_audio_ioctl(struct file *fp, unsigned int cmd,
+                                                       unsigned long arg)
+{
+       /* temporary workaround, until we switch to the ALSA API */
+       if (cmd == 315)
+               return -1;
+       else
+               return 0;
+}
+
+static irqreturn_t goldfish_audio_interrupt(int irq, void *dev_id)
+{
+       unsigned long irq_flags;
+       struct goldfish_audio   *data = dev_id;
+       u32 status;
+
+       spin_lock_irqsave(&data->lock, irq_flags);
+
+       /* read buffer status flags */
+       status = AUDIO_READ(data, AUDIO_INT_STATUS);
+       status &= AUDIO_INT_MASK;
+       /* if buffers are newly empty, wake up blocked
+          goldfish_audio_write() call */
+       if (status) {
+               data->buffer_status = status;
+               wake_up(&data->wait);
+       }
+
+       spin_unlock_irqrestore(&data->lock, irq_flags);
+       return status ? IRQ_HANDLED : IRQ_NONE;
+}
+
+/* file operations for /dev/eac */
+static const struct file_operations goldfish_audio_fops = {
+       .owner = THIS_MODULE,
+       .read = goldfish_audio_read,
+       .write = goldfish_audio_write,
+       .open = goldfish_audio_open,
+       .release = goldfish_audio_release,
+       .unlocked_ioctl = goldfish_audio_ioctl,
+};
+
+static struct miscdevice goldfish_audio_device = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "eac",
+       .fops = &goldfish_audio_fops,
+};
+
+static int goldfish_audio_probe(struct platform_device *pdev)
+{
+       int ret;
+       struct resource *r;
+       struct goldfish_audio *data;
+       dma_addr_t buf_addr;
+
+       data = kzalloc(sizeof(*data), GFP_KERNEL);
+       if (data == NULL) {
+               ret = -ENOMEM;
+               goto err_data_alloc_failed;
+       }
+       spin_lock_init(&data->lock);
+       init_waitqueue_head(&data->wait);
+       platform_set_drvdata(pdev, data);
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (r == NULL) {
+               dev_err(&pdev->dev, "platform_get_resource failed\n");
+               ret = -ENODEV;
+               goto err_no_io_base;
+       }
+       data->reg_base = ioremap(r->start, PAGE_SIZE);
+       if (data->reg_base == NULL) {
+               ret = -ENOMEM;
+               goto err_no_io_base;
+       }
+
+       data->irq = platform_get_irq(pdev, 0);
+       if (data->irq < 0) {
+               dev_err(&pdev->dev, "platform_get_irq failed\n");
+               ret = -ENODEV;
+               goto err_no_irq;
+       }
+       data->buffer_virt = dma_alloc_coherent(&pdev->dev,
+                               COMBINED_BUFFER_SIZE, &buf_addr, GFP_KERNEL);
+       if (data->buffer_virt == 0) {
+               ret = -ENOMEM;
+               dev_err(&pdev->dev, "allocate buffer failed\n");
+               goto err_alloc_write_buffer_failed;
+       }
+       data->buffer_phys = buf_addr;
+       data->write_buffer1 = data->buffer_virt;
+       data->write_buffer2 = data->buffer_virt + WRITE_BUFFER_SIZE;
+       data->read_buffer = data->buffer_virt + 2 * WRITE_BUFFER_SIZE;
+
+       ret = request_irq(data->irq, goldfish_audio_interrupt,
+                                       IRQF_SHARED, pdev->name, data);
+       if (ret) {
+               dev_err(&pdev->dev, "request_irq failed\n");
+               goto err_request_irq_failed;
+       }
+
+       ret = misc_register(&goldfish_audio_device);
+       if (ret) {
+               dev_err(&pdev->dev,
+                       "misc_register returned %d in goldfish_audio_init\n",
+                                                               ret);
+               goto err_misc_register_failed;
+       }
+
+       AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_1, buf_addr);
+       AUDIO_WRITE(data, AUDIO_SET_WRITE_BUFFER_2,
+                                               buf_addr + WRITE_BUFFER_SIZE);
+
+       data->read_supported = AUDIO_READ(data, AUDIO_READ_SUPPORTED);
+       if (data->read_supported)
+               AUDIO_WRITE(data, AUDIO_SET_READ_BUFFER,
+                                       buf_addr + 2 * WRITE_BUFFER_SIZE);
+
+       audio_data = data;
+       return 0;
+
+err_misc_register_failed:
+err_request_irq_failed:
+       dma_free_coherent(&pdev->dev, COMBINED_BUFFER_SIZE,
+                                       data->buffer_virt, data->buffer_phys);
+err_alloc_write_buffer_failed:
+err_no_irq:
+       iounmap(data->reg_base);
+err_no_io_base:
+       kfree(data);
+err_data_alloc_failed:
+       return ret;
+}
+
+static int goldfish_audio_remove(struct platform_device *pdev)
+{
+       struct goldfish_audio *data = platform_get_drvdata(pdev);
+
+       misc_deregister(&goldfish_audio_device);
+       free_irq(data->irq, data);
+       dma_free_coherent(&pdev->dev, COMBINED_BUFFER_SIZE,
+                                       data->buffer_virt, data->buffer_phys);
+       iounmap(data->reg_base);
+       kfree(data);
+       audio_data = NULL;
+       return 0;
+}
+
+static struct platform_driver goldfish_audio_driver = {
+       .probe          = goldfish_audio_probe,
+       .remove         = goldfish_audio_remove,
+       .driver = {
+               .name = "goldfish_audio"
+       }
+};
+
+module_platform_driver(goldfish_audio_driver);
diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c
new file mode 100644 (file)
index 0000000..1891d89
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * drivers/mtd/devices/goldfish_nand.c
+ *
+ * Copyright (C) 2007 Google, Inc.
+ * Copyright (C) 2012 Intel, Inc.
+ * Copyright (C) 2013 Intel, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/io.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/vmalloc.h>
+#include <linux/init.h>
+#include <linux/mtd/mtd.h>
+#include <linux/platform_device.h>
+
+#include <asm/div64.h>
+
+#include "goldfish_nand_reg.h"
+
+struct goldfish_nand {
+       spinlock_t              lock;
+       unsigned char __iomem  *base;
+       struct cmd_params       *cmd_params;
+       size_t                  mtd_count;
+       struct mtd_info         mtd[0];
+};
+
+static u32 goldfish_nand_cmd_with_params(struct mtd_info *mtd,
+                       enum nand_cmd cmd, u64 addr, u32 len,
+                       void *ptr, u32 *rv)
+{
+       u32 cmdp;
+       struct goldfish_nand *nand = mtd->priv;
+       struct cmd_params *cps = nand->cmd_params;
+       unsigned char __iomem  *base = nand->base;
+
+       if (cps == NULL)
+               return -1;
+
+       switch (cmd) {
+       case NAND_CMD_ERASE:
+               cmdp = NAND_CMD_ERASE_WITH_PARAMS;
+               break;
+       case NAND_CMD_READ:
+               cmdp = NAND_CMD_READ_WITH_PARAMS;
+               break;
+       case NAND_CMD_WRITE:
+               cmdp = NAND_CMD_WRITE_WITH_PARAMS;
+               break;
+       default:
+               return -1;
+       }
+       cps->dev = mtd - nand->mtd;
+       cps->addr_high = (u32)(addr >> 32);
+       cps->addr_low = (u32)addr;
+       cps->transfer_size = len;
+       cps->data = (u32)ptr;
+       writel(cmdp, base + NAND_COMMAND);
+       *rv = cps->result;
+       return 0;
+}
+
+static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
+                               u64 addr, u32 len, void *ptr)
+{
+       struct goldfish_nand *nand = mtd->priv;
+       u32 rv;
+       unsigned long irq_flags;
+       unsigned char __iomem  *base = nand->base;
+
+       spin_lock_irqsave(&nand->lock, irq_flags);
+       if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) {
+               writel(mtd - nand->mtd, base + NAND_DEV);
+               writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
+               writel((u32)addr, base + NAND_ADDR_LOW);
+               writel(len, base + NAND_TRANSFER_SIZE);
+               writel((u32)ptr, base + NAND_DATA);
+               writel(cmd, base + NAND_COMMAND);
+               rv = readl(base + NAND_RESULT);
+       }
+       spin_unlock_irqrestore(&nand->lock, irq_flags);
+       return rv;
+}
+
+static int goldfish_nand_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+       loff_t ofs = instr->addr;
+       u32 len = instr->len;
+       u32 rem;
+
+       if (ofs + len > mtd->size)
+               goto invalid_arg;
+       rem = do_div(ofs, mtd->writesize);
+       if (rem)
+               goto invalid_arg;
+       ofs *= (mtd->writesize + mtd->oobsize);
+
+       if (len % mtd->writesize)
+               goto invalid_arg;
+       len = len / mtd->writesize * (mtd->writesize + mtd->oobsize);
+
+       if (goldfish_nand_cmd(mtd, NAND_CMD_ERASE, ofs, len, NULL) != len) {
+               pr_err("goldfish_nand_erase: erase failed, start %llx, len %x, dev_size %llx, erase_size %x\n",
+                       ofs, len, mtd->size, mtd->erasesize);
+               return -EIO;
+       }
+
+       instr->state = MTD_ERASE_DONE;
+       mtd_erase_callback(instr);
+
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_erase: invalid erase, start %llx, len %x, dev_size %llx, erase_size %x\n",
+               ofs, len, mtd->size, mtd->erasesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_read_oob(struct mtd_info *mtd, loff_t ofs,
+                               struct mtd_oob_ops *ops)
+{
+       u32 rem;
+
+       if (ofs + ops->len > mtd->size)
+               goto invalid_arg;
+       if (ops->datbuf && ops->len && ops->len != mtd->writesize)
+               goto invalid_arg;
+       if (ops->ooblen + ops->ooboffs > mtd->oobsize)
+               goto invalid_arg;
+
+       rem = do_div(ofs, mtd->writesize);
+       if (rem)
+               goto invalid_arg;
+       ofs *= (mtd->writesize + mtd->oobsize);
+
+       if (ops->datbuf)
+               ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs,
+                                               ops->len, ops->datbuf);
+       ofs += mtd->writesize + ops->ooboffs;
+       if (ops->oobbuf)
+               ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, ofs,
+                                               ops->ooblen, ops->oobbuf);
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_read_oob: invalid read, start %llx, len %x, ooblen %x, dev_size %llx, write_size %x\n",
+               ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_write_oob(struct mtd_info *mtd, loff_t ofs,
+                               struct mtd_oob_ops *ops)
+{
+       u32 rem;
+
+       if (ofs + ops->len > mtd->size)
+               goto invalid_arg;
+       if (ops->len && ops->len != mtd->writesize)
+               goto invalid_arg;
+       if (ops->ooblen + ops->ooboffs > mtd->oobsize)
+               goto invalid_arg;
+
+       rem = do_div(ofs, mtd->writesize);
+       if (rem)
+               goto invalid_arg;
+       ofs *= (mtd->writesize + mtd->oobsize);
+
+       if (ops->datbuf)
+               ops->retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs,
+                                               ops->len, ops->datbuf);
+       ofs += mtd->writesize + ops->ooboffs;
+       if (ops->oobbuf)
+               ops->oobretlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, ofs,
+                                               ops->ooblen, ops->oobbuf);
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_write_oob: invalid write, start %llx, len %x, ooblen %x, dev_size %llx, write_size %x\n",
+               ofs, ops->len, ops->ooblen, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_read(struct mtd_info *mtd, loff_t from, size_t len,
+                               size_t *retlen, u_char *buf)
+{
+       u32 rem;
+
+       if (from + len > mtd->size)
+               goto invalid_arg;
+       if (len != mtd->writesize)
+               goto invalid_arg;
+
+       rem = do_div(from, mtd->writesize);
+       if (rem)
+               goto invalid_arg;
+       from *= (mtd->writesize + mtd->oobsize);
+
+       *retlen = goldfish_nand_cmd(mtd, NAND_CMD_READ, from, len, buf);
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_read: invalid read, start %llx, len %x, dev_size %llx, write_size %x\n",
+               from, len, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
+                               size_t *retlen, const u_char *buf)
+{
+       u32 rem;
+
+       if (to + len > mtd->size)
+               goto invalid_arg;
+       if (len != mtd->writesize)
+               goto invalid_arg;
+
+       rem = do_div(to, mtd->writesize);
+       if (rem)
+               goto invalid_arg;
+       to *= (mtd->writesize + mtd->oobsize);
+
+       *retlen = goldfish_nand_cmd(mtd, NAND_CMD_WRITE, to, len, (void *)buf);
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_write: invalid write, start %llx, len %x, dev_size %llx, write_size %x\n",
+               to, len, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+       u32 rem;
+
+       if (ofs >= mtd->size)
+               goto invalid_arg;
+
+       rem = do_div(ofs, mtd->erasesize);
+       if (rem)
+               goto invalid_arg;
+       ofs *= mtd->erasesize / mtd->writesize;
+       ofs *= (mtd->writesize + mtd->oobsize);
+
+       return goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_GET, ofs, 0, NULL);
+
+invalid_arg:
+       pr_err("goldfish_nand_block_isbad: invalid arg, ofs %llx, dev_size %llx, write_size %x\n",
+               ofs, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int goldfish_nand_block_markbad(struct mtd_info *mtd, loff_t ofs)
+{
+       u32 rem;
+
+       if (ofs >= mtd->size)
+               goto invalid_arg;
+
+       rem = do_div(ofs, mtd->erasesize);
+       if (rem)
+               goto invalid_arg;
+       ofs *= mtd->erasesize / mtd->writesize;
+       ofs *= (mtd->writesize + mtd->oobsize);
+
+       if (goldfish_nand_cmd(mtd, NAND_CMD_BLOCK_BAD_SET, ofs, 0, NULL) != 1)
+               return -EIO;
+       return 0;
+
+invalid_arg:
+       pr_err("goldfish_nand_block_markbad: invalid arg, ofs %llx, dev_size %llx, write_size %x\n",
+               ofs, mtd->size, mtd->writesize);
+       return -EINVAL;
+}
+
+static int nand_setup_cmd_params(struct platform_device *pdev,
+                                               struct goldfish_nand *nand)
+{
+       u64 paddr;
+       unsigned char __iomem  *base = nand->base;
+
+       nand->cmd_params = devm_kzalloc(&pdev->dev,
+                                       sizeof(struct cmd_params), GFP_KERNEL);
+       if (!nand->cmd_params)
+               return -1;
+
+       paddr = __pa(nand->cmd_params);
+       writel((u32)(paddr >> 32), base + NAND_CMD_PARAMS_ADDR_HIGH);
+       writel((u32)paddr, base + NAND_CMD_PARAMS_ADDR_LOW);
+       return 0;
+}
+
+static int goldfish_nand_init_device(struct platform_device *pdev,
+                                       struct goldfish_nand *nand, int id)
+{
+       u32 name_len;
+       u32 result;
+       u32 flags;
+       unsigned long irq_flags;
+       unsigned char __iomem  *base = nand->base;
+       struct mtd_info *mtd = &nand->mtd[id];
+       char *name;
+
+       spin_lock_irqsave(&nand->lock, irq_flags);
+       writel(id, base + NAND_DEV);
+       flags = readl(base + NAND_DEV_FLAGS);
+       name_len = readl(base + NAND_DEV_NAME_LEN);
+       mtd->writesize = readl(base + NAND_DEV_PAGE_SIZE);
+       mtd->size = readl(base + NAND_DEV_SIZE_LOW);
+       mtd->size |= (u64)readl(base + NAND_DEV_SIZE_HIGH) << 32;
+       mtd->oobsize = readl(base + NAND_DEV_EXTRA_SIZE);
+       mtd->oobavail = mtd->oobsize;
+       mtd->erasesize = readl(base + NAND_DEV_ERASE_SIZE) /
+                       (mtd->writesize + mtd->oobsize) * mtd->writesize;
+       do_div(mtd->size, mtd->writesize + mtd->oobsize);
+       mtd->size *= mtd->writesize;
+       dev_dbg(&pdev->dev, 
+               "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n",
+                      id, mtd->size, mtd->writesize, mtd->oobsize, mtd->erasesize);
+       spin_unlock_irqrestore(&nand->lock, irq_flags);
+
+       mtd->priv = nand;
+
+       mtd->name = name = devm_kzalloc(&pdev->dev, name_len + 1, GFP_KERNEL);
+       if (name == NULL)
+               return -ENOMEM;
+
+       result = goldfish_nand_cmd(mtd, NAND_CMD_GET_DEV_NAME, 0, name_len,
+                                                                       name);
+       if (result != name_len) {
+               dev_err(&pdev->dev, 
+                       "goldfish_nand_init_device failed to get dev name %d != %d\n",
+                              result, name_len);
+               return -ENODEV;
+       }
+       ((char *) mtd->name)[name_len] = '\0';
+
+       /* Setup the MTD structure */
+       mtd->type = MTD_NANDFLASH;
+       mtd->flags = MTD_CAP_NANDFLASH;
+       if (flags & NAND_DEV_FLAG_READ_ONLY)
+               mtd->flags &= ~MTD_WRITEABLE;
+       if (flags & NAND_DEV_FLAG_CMD_PARAMS_CAP)
+               nand_setup_cmd_params(pdev, nand);
+
+       mtd->owner = THIS_MODULE;
+       mtd->_erase = goldfish_nand_erase;
+       mtd->_read = goldfish_nand_read;
+       mtd->_write = goldfish_nand_write;
+       mtd->_read_oob = goldfish_nand_read_oob;
+       mtd->_write_oob = goldfish_nand_write_oob;
+       mtd->_block_isbad = goldfish_nand_block_isbad;
+       mtd->_block_markbad = goldfish_nand_block_markbad;
+
+       if (mtd_device_register(mtd, NULL, 0))
+               return -EIO;
+
+       return 0;
+}
+
+static int goldfish_nand_probe(struct platform_device *pdev)
+{
+       u32 num_dev;
+       int i;
+       int err;
+       u32 num_dev_working;
+       u32 version;
+       struct resource *r;
+       struct goldfish_nand *nand;
+       unsigned char __iomem  *base;
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (r == NULL)
+               return -ENODEV;
+
+       base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
+       if (base == NULL)
+               return -ENOMEM;
+
+       version = readl(base + NAND_VERSION);
+       if (version != NAND_VERSION_CURRENT) {
+               dev_err(&pdev->dev, 
+                       "goldfish_nand_init: version mismatch, got %d, expected %d\n",
+                               version, NAND_VERSION_CURRENT);
+               return -ENODEV;
+       }
+       num_dev = readl(base + NAND_NUM_DEV);
+       if (num_dev == 0)
+               return -ENODEV;
+
+       nand = devm_kzalloc(&pdev->dev, sizeof(*nand) + 
+                               sizeof(struct mtd_info) * num_dev, GFP_KERNEL);
+       if (nand == NULL)
+               return -ENOMEM;
+
+       spin_lock_init(&nand->lock);
+       nand->base = base;
+       nand->mtd_count = num_dev;
+       platform_set_drvdata(pdev, nand);
+
+       num_dev_working = 0;
+       for (i = 0; i < num_dev; i++) {
+               err = goldfish_nand_init_device(pdev, nand, i);
+               if (err == 0)
+                       num_dev_working++;
+       }
+       if (num_dev_working == 0)
+               return -ENODEV;
+       return 0;
+}
+
+static int goldfish_nand_remove(struct platform_device *pdev)
+{
+       struct goldfish_nand *nand = platform_get_drvdata(pdev);
+       int i;
+       for (i = 0; i < nand->mtd_count; i++) {
+               if (nand->mtd[i].name)
+                       mtd_device_unregister(&nand->mtd[i]);
+       }
+       return 0;
+}
+
+static struct platform_driver goldfish_nand_driver = {
+       .probe          = goldfish_nand_probe,
+       .remove         = goldfish_nand_remove,
+       .driver = {
+               .name = "goldfish_nand"
+       }
+};
+
+module_platform_driver(goldfish_nand_driver);
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/goldfish/goldfish_nand_reg.h b/drivers/staging/goldfish/goldfish_nand_reg.h
new file mode 100644 (file)
index 0000000..956c6c3
--- /dev/null
@@ -0,0 +1,72 @@
+/* drivers/mtd/devices/goldfish_nand_reg.h
+**
+** Copyright (C) 2007 Google, Inc.
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+*/
+
+#ifndef GOLDFISH_NAND_REG_H
+#define GOLDFISH_NAND_REG_H
+
+enum nand_cmd {
+       NAND_CMD_GET_DEV_NAME,  /* Write device name for NAND_DEV to NAND_DATA (vaddr) */
+       NAND_CMD_READ,
+       NAND_CMD_WRITE,
+       NAND_CMD_ERASE,
+       NAND_CMD_BLOCK_BAD_GET, /* NAND_RESULT is 1 if block is bad, 0 if it is not */
+       NAND_CMD_BLOCK_BAD_SET,
+       NAND_CMD_READ_WITH_PARAMS,
+       NAND_CMD_WRITE_WITH_PARAMS,
+       NAND_CMD_ERASE_WITH_PARAMS
+};
+
+enum nand_dev_flags {
+       NAND_DEV_FLAG_READ_ONLY = 0x00000001,
+       NAND_DEV_FLAG_CMD_PARAMS_CAP = 0x00000002,
+};
+
+#define NAND_VERSION_CURRENT (1)
+
+enum nand_reg {
+       /* Global */
+       NAND_VERSION        = 0x000,
+       NAND_NUM_DEV        = 0x004,
+       NAND_DEV            = 0x008,
+
+       /* Dev info */
+       NAND_DEV_FLAGS      = 0x010,
+       NAND_DEV_NAME_LEN   = 0x014,
+       NAND_DEV_PAGE_SIZE  = 0x018,
+       NAND_DEV_EXTRA_SIZE = 0x01c,
+       NAND_DEV_ERASE_SIZE = 0x020,
+       NAND_DEV_SIZE_LOW   = 0x028,
+       NAND_DEV_SIZE_HIGH  = 0x02c,
+
+       /* Command */
+       NAND_RESULT         = 0x040,
+       NAND_COMMAND        = 0x044,
+       NAND_DATA           = 0x048,
+       NAND_TRANSFER_SIZE  = 0x04c,
+       NAND_ADDR_LOW       = 0x050,
+       NAND_ADDR_HIGH      = 0x054,
+       NAND_CMD_PARAMS_ADDR_LOW = 0x058,
+       NAND_CMD_PARAMS_ADDR_HIGH = 0x05c,
+};
+
+struct cmd_params {
+       uint32_t dev;
+       uint32_t addr_low;
+       uint32_t addr_high;
+       uint32_t transfer_size;
+       uint32_t data;
+       uint32_t result;
+};
+#endif
index c5ceb9d90ea83a696a4ca4518dc379a2c6a82831..eca07045f4de26d00e5cb228ccb203021bbf6174 100644 (file)
@@ -75,11 +75,6 @@ static const char * const mxs_lradc_irq_name[] = {
        "mxs-lradc-button1",
 };
 
-struct mxs_lradc_chan {
-       uint8_t                         slot;
-       uint8_t                         flags;
-};
-
 struct mxs_lradc {
        struct device           *dev;
        void __iomem            *base;
@@ -90,8 +85,6 @@ struct mxs_lradc {
 
        struct mutex            lock;
 
-       uint8_t                 enable;
-
        struct completion       completion;
 };
 
index a865adf819389438ecf2147ecffc1566774e7fd3..aee76c710a3b5def2f2110b4fcf36f39f2a713de 100644 (file)
@@ -54,7 +54,7 @@ struct iio_dummy_accel_calibscale {
 static const struct iio_dummy_accel_calibscale dummy_scales[] = {
        { 0, 100, 0x8 }, /* 0.000100 */
        { 0, 133, 0x7 }, /* 0.000133 */
-       { 733, 13, 0x9 }, /* 733.00013 */
+       { 733, 13, 0x9 }, /* 733.000013 */
 };
 
 /*
@@ -284,7 +284,7 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev,
 /**
  * iio_dummy_write_raw() - data write function.
  * @indio_dev: the struct iio_dev associated with this device instance
- * @chan:      the channel whose data is to be read
+ * @chan:      the channel whose data is to be written
  * @val:       first element of value to set (typically INT)
  * @val2:      second element of value to set (typically MICRO)
  * @mask:      what we actually want to write. 0 is the channel, everything else
index dee16f0e7570bf1335479d3133a4d9d5007e4348..72f400c3cbcbbdc88391a02ae14cb87fc589d2da 100644 (file)
@@ -155,7 +155,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev,
         * occurs, this function is run. Typically this grabs data
         * from the device.
         *
-        * NULL for the top half. This is normally implemented only if we
+        * NULL for the bottom half. This is normally implemented only if we
         * either want to ping a capture now pin (no sleeping) or grab
         * a timestamp as close as possible to a data ready trigger firing.
         *
index f7059cddd7fdb2da864ff19975d4ca99fbb0664f..366f259e3756abc4052287bdeafeabda640c3fa3 100644 (file)
@@ -1142,9 +1142,6 @@ failed_ioremap:
 static int ipu_remove(struct platform_device *pdev)
 {
        struct ipu_soc *ipu = platform_get_drvdata(pdev);
-       struct resource *res;
-
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
        platform_device_unregister_children(pdev);
        ipu_submodules_exit(ipu);
index 67d974f7be36abbc89e6c9fa57589a53b90c9748..ec340da968ac56c8a87dbc7766cfb700a72e4fd3 100644 (file)
@@ -677,7 +677,7 @@ int ipu_di_init(struct ipu_soc *ipu, struct device *dev, int id,
                goto failed_clk_register;
        }
 
-       dev_info(dev, "DI%d base: 0x%08lx remapped to %p\n",
+       dev_dbg(dev, "DI%d base: 0x%08lx remapped to %p\n",
                        id, base, di->base);
        di->inuse = false;
        di->ipu = ipu;
index 55a0b82c6391b7eb92c67c98d3f9474b7e6b225e..4dec93d046fae3e82f12ef52ce911cd2ca945449 100644 (file)
@@ -42,19 +42,12 @@ static int eucr_suspend(struct usb_interface *iface, pm_message_t message)
        /* Wait until no command is running */
        mutex_lock(&us->dev_mutex);
 
-       //US_DEBUGP("%s\n", __func__);
        if (us->suspend_resume_hook)
                (us->suspend_resume_hook)(us, US_SUSPEND);
 
-       /* When runtime PM is working, we'll set a flag to indicate
-        * whether we should autoresume when a SCSI request arrives. */
-       // us->Power_IsResum = true;
-       //us->SD_Status.Ready = 0;
-
        mutex_unlock(&us->dev_mutex);
        return 0;
 }
-//EXPORT_SYMBOL_GPL(eucr_suspend);
 
 static int eucr_resume(struct usb_interface *iface)
 {
@@ -64,43 +57,40 @@ static int eucr_resume(struct usb_interface *iface)
        pr_info("--- eucr_resume---\n");
        mutex_lock(&us->dev_mutex);
 
-       //US_DEBUGP("%s\n", __func__);
        if (us->suspend_resume_hook)
                (us->suspend_resume_hook)(us, US_RESUME);
 
 
        mutex_unlock(&us->dev_mutex);
 
-       
-         us->Power_IsResum = true;
-       //
-       //us->SD_Status.Ready = 0; //??
-       us->SM_Status = *(PSM_STATUS)&tmp;
-       
+       us->Power_IsResum = true;
+
+       us->SM_Status = *(PSM_STATUS)&tmp;
+
        return 0;
 }
-//EXPORT_SYMBOL_GPL(eucr_resume);
+
 static int eucr_reset_resume(struct usb_interface *iface)
 {
        BYTE    tmp = 0;
        struct us_data *us = usb_get_intfdata(iface);
 
        pr_info("--- eucr_reset_resume---\n");
-       //US_DEBUGP("%s\n", __func__);
 
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
 
-       /* FIXME: Notify the subdrivers that they need to reinitialize
-        * the device */
-       //ENE_InitMedia(us);
+       /*
+        * FIXME: Notify the subdrivers that they need to reinitialize
+        * the device
+        */
+
        us->Power_IsResum = true;
-       //
-       //us->SD_Status.Ready = 0; //??
-       us->SM_Status = *(PSM_STATUS)&tmp;
+
+       us->SM_Status = *(PSM_STATUS)&tmp;
+
        return 0;
 }
-//EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
 
 #else
 
@@ -110,7 +100,6 @@ static int eucr_reset_resume(struct usb_interface *iface)
 
 #endif
 
-//----- eucr_pre_reset() ---------------------
 static int eucr_pre_reset(struct usb_interface *iface)
 {
        struct us_data *us = usb_get_intfdata(iface);
@@ -122,7 +111,6 @@ static int eucr_pre_reset(struct usb_interface *iface)
        return 0;
 }
 
-//----- eucr_post_reset() ---------------------
 static int eucr_post_reset(struct usb_interface *iface)
 {
        struct us_data *us = usb_get_intfdata(iface);
@@ -136,19 +124,15 @@ static int eucr_post_reset(struct usb_interface *iface)
        return 0;
 }
 
-//----- fill_inquiry_response() ---------------------
 void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len)
 {
        pr_info("usb --- fill_inquiry_response\n");
-       if (data_len<36) // You lose.
+       if (data_len < 36) /* You lose. */
                return;
 
-       if (data[0]&0x20)
-       {
+       if (data[0]&0x20) {
                memset(data+8,0,28);
-       }
-       else
-       {
+       } else {
                u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
                memcpy(data+8, us->unusual_dev->vendorName,
                        strlen(us->unusual_dev->vendorName) > 8 ? 8 :
@@ -164,18 +148,16 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int
        usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF);
 }
 
-//----- usb_stor_control_thread() ---------------------
 static int usb_stor_control_thread(void * __us)
 {
        struct us_data *us = (struct us_data *)__us;
        struct Scsi_Host *host = us_to_host(us);
 
        pr_info("usb --- usb_stor_control_thread\n");
-       for(;;)
-       {
+       for (;;) {
                if (wait_for_completion_interruptible(&us->cmnd_ready))
                        break;
-                       
+
                /* lock the device pointers */
                mutex_lock(&(us->dev_mutex));
 
@@ -189,44 +171,34 @@ static int usb_stor_control_thread(void * __us)
                scsi_lock(host);
 
                /* When we are called with no command pending, we're done */
-               if (us->srb == NULL)
-               {
+               if (us->srb == NULL) {
                        scsi_unlock(host);
                        mutex_unlock(&us->dev_mutex);
-                       //US_DEBUGP("-- exiting\n");
                        break;
                }
 
                /* has the command timed out *already* ? */
-               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
-               {
+               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
                        us->srb->result = DID_ABORT << 16;
                        goto SkipForAbort;
                }
 
                scsi_unlock(host);
 
-               if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL)
-               {
+               if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
                        us->srb->result = DID_ERROR << 16;
-               }
-               else if (us->srb->device->id && !(us->fflags & US_FL_SCM_MULT_TARG))
-               {
+               } else if (us->srb->device->id
+                          && !(us->fflags & US_FL_SCM_MULT_TARG)) {
                        us->srb->result = DID_BAD_TARGET << 16;
-               }
-               else if (us->srb->device->lun > us->max_lun)
-               {
+               } else if (us->srb->device->lun > us->max_lun) {
                        us->srb->result = DID_BAD_TARGET << 16;
-               }
-               else if ((us->srb->cmnd[0] == INQUIRY) && (us->fflags & US_FL_FIX_INQUIRY))
-               {
+               } else if ((us->srb->cmnd[0] == INQUIRY)
+                          && (us->fflags & US_FL_FIX_INQUIRY)) {
                        unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00};
 
                        fill_inquiry_response(us, data_ptr, 36);
                        us->srb->result = SAM_STAT_GOOD;
-               }
-               else
-               {
+               } else {
                        us->proto_handler(us->srb, us);
                }
 
@@ -234,18 +206,14 @@ static int usb_stor_control_thread(void * __us)
                scsi_lock(host);
 
                /* indicate that the command is done */
-               if (us->srb->result != DID_ABORT << 16)
-               {
+               if (us->srb->result != DID_ABORT << 16) {
                        us->srb->scsi_done(us->srb);
-               }
-               else
-               {
+               } else {
 SkipForAbort:
                        pr_info("scsi command aborted\n");
                }
 
-               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags))
-               {
+               if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
                        complete(&(us->notify));
 
                        /* Allow USB transfers to resume */
@@ -262,8 +230,7 @@ SkipForAbort:
        } /* for (;;) */
 
        /* Wait until we are told to stop */
-       for (;;)
-       {
+       for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (kthread_should_stop())
                        break;
@@ -271,9 +238,8 @@ SkipForAbort:
        }
        __set_current_state(TASK_RUNNING);
        return 0;
-}      
+}
 
-//----- associate_dev() ---------------------
 static int associate_dev(struct us_data *us, struct usb_interface *intf)
 {
        pr_info("usb --- associate_dev\n");
@@ -288,29 +254,25 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
 
        /* Allocate the device-related DMA-mapped buffers */
        us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma);
-       if (!us->cr)
-       {
+       if (!us->cr) {
                pr_info("usb_ctrlrequest allocation failed\n");
                return -ENOMEM;
        }
 
        us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma);
-       if (!us->iobuf)
-       {
+       if (!us->iobuf) {
                pr_info("I/O buffer allocation failed\n");
                return -ENOMEM;
        }
 
        us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
-       if (!us->sensebuf)
-       {
+       if (!us->sensebuf) {
                pr_info("Sense buffer allocation failed\n");
                return -ENOMEM;
        }
        return 0;
 }
 
-//----- get_device_info() ---------------------
 static int get_device_info(struct us_data *us, const struct usb_device_id *id)
 {
        struct usb_device *dev = us->pusb_dev;
@@ -323,8 +285,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
        us->fflags = id->driver_info;
        us->Power_IsResum = false;
 
-       if (us->fflags & US_FL_IGNORE_DEVICE)
-       {
+       if (us->fflags & US_FL_IGNORE_DEVICE) {
                pr_info("device ignored\n");
                return -ENODEV;
        }
@@ -335,7 +296,6 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
        return 0;
 }
 
-//----- get_transport() ---------------------
 static int get_transport(struct us_data *us)
 {
        pr_info("usb --- get_transport\n");
@@ -349,7 +309,6 @@ static int get_transport(struct us_data *us)
        default:
                return -EIO;
        }
-       /* pr_info("Transport: %s\n", us->transport_name); */
 
        /* fix for single-lun devices */
        if (us->fflags & US_FL_SINGLE_LUN)
@@ -357,7 +316,6 @@ static int get_transport(struct us_data *us)
        return 0;
 }
 
-//----- get_protocol() ---------------------
 static int get_protocol(struct us_data *us)
 {
        pr_info("usb --- get_protocol\n");
@@ -368,7 +326,8 @@ static int get_protocol(struct us_data *us)
        switch (us->subclass) {
        case USB_SC_SCSI:
                us->protocol_name = "Transparent SCSI";
-               if( (us->pusb_dev->descriptor.idVendor == 0x0CF2) && (us->pusb_dev->descriptor.idProduct == 0x6250) )
+               if ((us->pusb_dev->descriptor.idVendor == 0x0CF2)
+                   && (us->pusb_dev->descriptor.idProduct == 0x6250))
                        us->proto_handler = ENE_stor_invoke_transport;
                else
                        us->proto_handler = usb_stor_invoke_transport;
@@ -377,11 +336,9 @@ static int get_protocol(struct us_data *us)
        default:
                return -EIO;
        }
-       /* pr_info("Protocol: %s\n", us->protocol_name); */
        return 0;
 }
 
-//----- get_pipes() ---------------------
 static int get_pipes(struct us_data *us)
 {
        struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
@@ -393,32 +350,24 @@ static int get_pipes(struct us_data *us)
 
        pr_info("usb --- get_pipes\n");
 
-       for (i = 0; i < altsetting->desc.bNumEndpoints; i++)
-       {
+       for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
                ep = &altsetting->endpoint[i].desc;
 
-               if (usb_endpoint_xfer_bulk(ep))
-               {
-                       if (usb_endpoint_dir_in(ep))
-                       {
+               if (usb_endpoint_xfer_bulk(ep)) {
+                       if (usb_endpoint_dir_in(ep)) {
                                if (!ep_in)
                                        ep_in = ep;
-                       }
-                       else
-                       {
+                       } else {
                                if (!ep_out)
                                        ep_out = ep;
                        }
-               }
-               else if (usb_endpoint_is_int_in(ep))
-               {
+               } else if (usb_endpoint_is_int_in(ep)) {
                        if (!ep_int)
                                ep_int = ep;
                }
        }
 
-       if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int))
-       {
+       if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
                pr_info("Endpoint sanity check failed! Rejecting dev.\n");
                return -EIO;
        }
@@ -428,31 +377,27 @@ static int get_pipes(struct us_data *us)
        us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
        us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
        us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-       if (ep_int)
-       {
+       if (ep_int) {
                us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
                us->ep_bInterval = ep_int->bInterval;
        }
        return 0;
 }
 
-//----- usb_stor_acquire_resources() ---------------------
 static int usb_stor_acquire_resources(struct us_data *us)
 {
        struct task_struct *th;
 
        pr_info("usb --- usb_stor_acquire_resources\n");
        us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
-       if (!us->current_urb)
-       {
+       if (!us->current_urb) {
                pr_info("URB allocation failed\n");
                return -ENOMEM;
        }
 
        /* Start up our control thread */
        th = kthread_run(usb_stor_control_thread, us, "eucr-storage");
-       if (IS_ERR(th))
-       {
+       if (IS_ERR(th)) {
                pr_info("Unable to start control thread\n");
                return PTR_ERR(th);
        }
@@ -461,7 +406,6 @@ static int usb_stor_acquire_resources(struct us_data *us)
        return 0;
 }
 
-//----- usb_stor_release_resources() ---------------------
 static void usb_stor_release_resources(struct us_data *us)
 {
        pr_info("usb --- usb_stor_release_resources\n");
@@ -473,8 +417,7 @@ static void usb_stor_release_resources(struct us_data *us)
                kthread_stop(us->ctl_thread);
 
        /* Call the destructor routine, if it exists */
-       if (us->extra_destructor)
-       {
+       if (us->extra_destructor) {
                pr_info("-- calling extra_destructor()\n");
                us->extra_destructor(us->extra);
        }
@@ -484,7 +427,6 @@ static void usb_stor_release_resources(struct us_data *us)
        usb_free_urb(us->current_urb);
 }
 
-//----- dissociate_dev() ---------------------
 static void dissociate_dev(struct us_data *us)
 {
        pr_info("usb --- dissociate_dev\n");
@@ -501,7 +443,6 @@ static void dissociate_dev(struct us_data *us)
        usb_set_intfdata(us->pusb_intf, NULL);
 }
 
-//----- quiesce_and_remove_host() ---------------------
 static void quiesce_and_remove_host(struct us_data *us)
 {
        struct Scsi_Host *host = us_to_host(us);
@@ -512,19 +453,22 @@ static void quiesce_and_remove_host(struct us_data *us)
        if (us->pusb_dev->state == USB_STATE_NOTATTACHED)
                set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
 
-       /* Prevent SCSI-scanning (if it hasn't started yet)
+       /*
+        * Prevent SCSI-scanning (if it hasn't started yet)
         * and wait for the SCSI-scanning thread to stop.
         */
        set_bit(US_FLIDX_DONT_SCAN, &us->dflags);
        wake_up(&us->delay_wait);
        wait_for_completion(&us->scanning_done);
 
-       /* Removing the host will perform an orderly shutdown: caches
+       /*
+        * Removing the host will perform an orderly shutdown: caches
         * synchronized, disks spun down, etc.
         */
        scsi_remove_host(host);
 
-       /* Prevent any new commands from being accepted and cut short
+       /*
+        * Prevent any new commands from being accepted and cut short
         * reset delays.
         */
        scsi_lock(host);
@@ -533,7 +477,6 @@ static void quiesce_and_remove_host(struct us_data *us)
        wake_up(&us->delay_wait);
 }
 
-//----- release_everything() ---------------------
 static void release_everything(struct us_data *us)
 {
        pr_info("usb --- release_everything\n");
@@ -543,7 +486,6 @@ static void release_everything(struct us_data *us)
        scsi_host_put(us_to_host(us));
 }
 
-//----- usb_stor_scan_thread() ---------------------
 static int usb_stor_scan_thread(void * __us)
 {
        struct us_data *us = (struct us_data *)__us;
@@ -560,11 +502,10 @@ static int usb_stor_scan_thread(void * __us)
        }
 
        /* If the device is still connected, perform the scanning */
-       if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags))
-       {
+       if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
                /* For bulk-only devices, determine the max LUN value */
-               if (us->protocol == USB_PR_BULK && !(us->fflags & US_FL_SINGLE_LUN))
-               {
+               if (us->protocol == USB_PR_BULK
+                   && !(us->fflags & US_FL_SINGLE_LUN)) {
                        mutex_lock(&us->dev_mutex);
                        us->max_lun = usb_stor_Bulk_max_lun(us);
                        mutex_unlock(&us->dev_mutex);
@@ -575,7 +516,6 @@ static int usb_stor_scan_thread(void * __us)
        complete_and_exit(&us->scanning_done, 0);
 }
 
-//----- eucr_probe() ---------------------
 static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
        struct Scsi_Host *host;
@@ -587,8 +527,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
        pr_info("usb --- eucr_probe\n");
 
       host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
-       if (!host)
-       {
+       if (!host) {
                pr_info("Unable to allocate the scsi host\n");
                return -ENOMEM;
        }
@@ -630,8 +569,7 @@ static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id
                goto BadDevice;
 
        result = scsi_add_host(host, &intf->dev);
-       if (result)
-       {
+       if (result) {
                pr_info("Unable to add the scsi host\n");
                goto BadDevice;
        }
@@ -673,7 +611,6 @@ BadDevice:
        return result;
 }
 
-//----- eucr_disconnect() ---------------------
 static void eucr_disconnect(struct usb_interface *intf)
 {
        struct us_data *us = usb_get_intfdata(intf);
@@ -683,11 +620,7 @@ static void eucr_disconnect(struct usb_interface *intf)
        release_everything(us);
 }
 
-/***********************************************************************
- * Initialization and registration
- ***********************************************************************/
-
-//----- usb_storage_driver() ---------------------
+/* Initialization and registration */
 static struct usb_driver usb_storage_driver = {
        .name =         "eucr",
        .probe =                eucr_probe,
index b63543658b2efe5eabad4741b4e31c6dec843841..4f1219b4c692f65bf725c2c243ca2906297e9315 100644 (file)
@@ -23,16 +23,6 @@ menuconfig LINE6_USB
 
 if LINE6_USB
 
-config LINE6_USB_DUMP_PCM
-       bool "dump PCM data"
-       default n
-       help
-         Say Y here to write PCM data sent to and received from Line6
-         devices to the syslog. This will produce a huge amount of
-         syslog data during playback and capture.
-
-         If unsure, say N.
-
 config LINE6_USB_IMPULSE_RESPONSE
        bool "measure impulse response"
        default n
index 389c41fd1b748d8d0a8095489a83e2db77d3f92f..f8316b71f13d458b9706a9a870a78e3aae6250ab 100644 (file)
@@ -216,16 +216,6 @@ static void audio_in_callback(struct urb *urb)
                if (urb == line6pcm->urb_audio_in[index])
                        break;
 
-#ifdef CONFIG_LINE6_USB_DUMP_PCM
-       for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
-               struct usb_iso_packet_descriptor *fout =
-                   &urb->iso_frame_desc[i];
-               line6_write_hexdump(line6pcm->line6, 'C',
-                                   urb->transfer_buffer + fout->offset,
-                                   fout->length);
-       }
-#endif
-
        spin_lock_irqsave(&line6pcm->lock_audio_in, flags);
 
        for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
index 1e4ce50069a9913a644da817b142cbf974d348db..9f9a21a7413929fa6721efa29f0c1933c9b87a18 100644 (file)
@@ -135,47 +135,6 @@ static void line6_stop_listen(struct usb_line6 *line6)
        usb_kill_urb(line6->urb_listen);
 }
 
-#ifdef CONFIG_LINE6_USB_DUMP_ANY
-/*
-       Write hexdump to syslog.
-*/
-void line6_write_hexdump(struct usb_line6 *line6, char dir,
-                        const unsigned char *buffer, int size)
-{
-       static const int BYTES_PER_LINE = 8;
-       char hexdump[100];
-       char asc[BYTES_PER_LINE + 1];
-       int i, j;
-
-       for (i = 0; i < size; i += BYTES_PER_LINE) {
-               int hexdumpsize = sizeof(hexdump);
-               char *p = hexdump;
-               int n = min(size - i, BYTES_PER_LINE);
-               asc[n] = 0;
-
-               for (j = 0; j < BYTES_PER_LINE; ++j) {
-                       int bytes;
-
-                       if (j < n) {
-                               unsigned char val = buffer[i + j];
-                               bytes = snprintf(p, hexdumpsize, " %02X", val);
-                               asc[j] = ((val >= 0x20)
-                                         && (val < 0x7f)) ? val : '.';
-                       } else
-                               bytes = snprintf(p, hexdumpsize, "   ");
-
-                       if (bytes > hexdumpsize)
-                               break;  /* buffer overflow */
-
-                       p += bytes;
-                       hexdumpsize -= bytes;
-               }
-
-               dev_info(line6->ifcdev, "%c%04X:%s %s\n", dir, i, hexdump, asc);
-       }
-}
-#endif
-
 /*
        Send raw message in pieces of wMaxPacketSize bytes.
 */
@@ -307,14 +266,13 @@ int line6_version_request_async(struct usb_line6 *line6)
        char *buffer;
        int retval;
 
-       buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC);
+       buffer = kmemdup(line6_request_version,
+                       sizeof(line6_request_version), GFP_ATOMIC);
        if (buffer == NULL) {
                dev_err(line6->ifcdev, "Out of memory");
                return -ENOMEM;
        }
 
-       memcpy(buffer, line6_request_version, sizeof(line6_request_version));
-
        retval = line6_send_raw_message_async(line6, buffer,
                                              sizeof(line6_request_version));
        kfree(buffer);
@@ -332,17 +290,6 @@ int line6_send_sysex_message(struct usb_line6 *line6, const char *buffer,
            SYSEX_EXTRA_SIZE;
 }
 
-/*
-       Send sysex message in pieces of wMaxPacketSize bytes.
-*/
-int line6_send_sysex_message_async(struct usb_line6 *line6, const char *buffer,
-                                  int size)
-{
-       return line6_send_raw_message_async(line6, buffer,
-                                           size + SYSEX_EXTRA_SIZE) -
-           SYSEX_EXTRA_SIZE;
-}
-
 /*
        Allocate buffer for sysex message and prepare header.
        @param code sysex message code
@@ -372,7 +319,7 @@ char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2,
 static void line6_data_received(struct urb *urb)
 {
        struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
-       struct MidiBuffer *mb = &line6->line6midi->midibuf_in;
+       struct midi_buffer *mb = &line6->line6midi->midibuf_in;
        int done;
 
        if (urb->status == -ESHUTDOWN)
@@ -532,7 +479,7 @@ int line6_read_data(struct usb_line6 *line6, int address, void *data,
                return ret;
        }
 
-       /* Wait for data length. We'll get a couple of 0xff until length arrives. */
+       /* Wait for data length. We'll get 0xff until length arrives. */
        do {
                ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
                                      USB_TYPE_VENDOR | USB_RECIP_DEVICE |
index f0be5a2adaba1d4ae383e9fd0f50ba84b9953360..a8341f9fdb981926d7c6132e2ebf11c2a9a552c2 100644 (file)
 
 #define DRIVER_NAME "line6usb"
 
-#if defined(CONFIG_LINE6_USB_DUMP_PCM)
-#define CONFIG_LINE6_USB_DUMP_ANY
-#endif
-
 #define LINE6_TIMEOUT 1
 #define LINE6_BUFSIZE_LISTEN 32
 #define LINE6_MESSAGE_MAXLEN 256
@@ -53,7 +49,7 @@
 #define LINE6_CHANNEL_MASK 0x0f
 
 #define MISSING_CASE   \
-       printk(KERN_ERR "line6usb driver bug: missing case in %s:%d\n", \
+       pr_err("line6usb driver bug: missing case in %s:%d\n", \
                __FILE__, __LINE__)
 
 #define CHECK_RETURN(x)                \
@@ -208,8 +204,6 @@ extern int line6_send_raw_message_async(struct usb_line6 *line6,
                                        const char *buffer, int size);
 extern int line6_send_sysex_message(struct usb_line6 *line6,
                                    const char *buffer, int size);
-extern int line6_send_sysex_message_async(struct usb_line6 *line6,
-                                         const char *buffer, int size);
 extern ssize_t line6_set_raw(struct device *dev, struct device_attribute *attr,
                             const char *buf, size_t count);
 extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
@@ -221,9 +215,4 @@ extern int line6_version_request_async(struct usb_line6 *line6);
 extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
                            size_t datalen);
 
-#ifdef CONFIG_LINE6_USB_DUMP_ANY
-extern void line6_write_hexdump(struct usb_line6 *line6, char dir,
-                               const unsigned char *buffer, int size);
-#endif
-
 #endif
index 6982eca661bd715f4a26a08007ac0a07e9dfec91..e3f9a53dbd96604ee5c6ab6e9eccd06511a96be7 100644 (file)
@@ -45,7 +45,7 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
        struct usb_line6 *line6 =
            line6_rawmidi_substream_midi(substream)->line6;
        struct snd_line6_midi *line6midi = line6->line6midi;
-       struct MidiBuffer *mb = &line6midi->midibuf_out;
+       struct midi_buffer *mb = &line6midi->midibuf_out;
        unsigned long flags;
        unsigned char chunk[line6->max_packet_size];
        int req, done;
index 19dabd54051afe0bbb31fe11e5b4206e36f790c8..78f903fb4d415a98969a8132b7bc0687faf42837 100644 (file)
@@ -57,12 +57,12 @@ struct snd_line6_midi {
        /**
                 Buffer for incoming MIDI stream.
        */
-       struct MidiBuffer midibuf_in;
+       struct midi_buffer midibuf_in;
 
        /**
                 Buffer for outgoing MIDI stream.
        */
-       struct MidiBuffer midibuf_out;
+       struct midi_buffer midibuf_out;
 };
 
 extern int line6_init_midi(struct usb_line6 *line6);
index 968e0de83dabba50cbb8a1ffcb324844310106bc..f0adb7baa603b3ae060cf6e0397a628af6b980e3 100644 (file)
@@ -33,23 +33,23 @@ static int midibuf_message_length(unsigned char code)
        }
 }
 
-static int midibuf_is_empty(struct MidiBuffer *this)
+static int midibuf_is_empty(struct midi_buffer *this)
 {
        return (this->pos_read == this->pos_write) && !this->full;
 }
 
-static int midibuf_is_full(struct MidiBuffer *this)
+static int midibuf_is_full(struct midi_buffer *this)
 {
        return this->full;
 }
 
-void line6_midibuf_reset(struct MidiBuffer *this)
+void line6_midibuf_reset(struct midi_buffer *this)
 {
        this->pos_read = this->pos_write = this->full = 0;
        this->command_prev = -1;
 }
 
-int line6_midibuf_init(struct MidiBuffer *this, int size, int split)
+int line6_midibuf_init(struct midi_buffer *this, int size, int split)
 {
        this->buf = kmalloc(size, GFP_KERNEL);
 
@@ -62,14 +62,14 @@ int line6_midibuf_init(struct MidiBuffer *this, int size, int split)
        return 0;
 }
 
-void line6_midibuf_status(struct MidiBuffer *this)
+void line6_midibuf_status(struct midi_buffer *this)
 {
        pr_debug("midibuf size=%d split=%d pos_read=%d pos_write=%d full=%d command_prev=%02x\n",
                 this->size, this->split, this->pos_read, this->pos_write,
                 this->full, this->command_prev);
 }
 
-int line6_midibuf_bytes_free(struct MidiBuffer *this)
+int line6_midibuf_bytes_free(struct midi_buffer *this)
 {
        return
            midibuf_is_full(this) ?
@@ -78,7 +78,7 @@ int line6_midibuf_bytes_free(struct MidiBuffer *this)
            1;
 }
 
-int line6_midibuf_bytes_used(struct MidiBuffer *this)
+int line6_midibuf_bytes_used(struct midi_buffer *this)
 {
        return
            midibuf_is_empty(this) ?
@@ -87,7 +87,7 @@ int line6_midibuf_bytes_used(struct MidiBuffer *this)
            1;
 }
 
-int line6_midibuf_write(struct MidiBuffer *this, unsigned char *data,
+int line6_midibuf_write(struct midi_buffer *this, unsigned char *data,
                        int length)
 {
        int bytes_free;
@@ -130,7 +130,8 @@ int line6_midibuf_write(struct MidiBuffer *this, unsigned char *data,
        return length + skip_active_sense;
 }
 
-int line6_midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
+int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
+                      int length)
 {
        int bytes_used;
        int length1, length2;
@@ -234,7 +235,7 @@ int line6_midibuf_read(struct MidiBuffer *this, unsigned char *data, int length)
        return length + repeat;
 }
 
-int line6_midibuf_ignore(struct MidiBuffer *this, int length)
+int line6_midibuf_ignore(struct midi_buffer *this, int length)
 {
        int bytes_used = line6_midibuf_bytes_used(this);
 
@@ -246,7 +247,7 @@ int line6_midibuf_ignore(struct MidiBuffer *this, int length)
        return length;
 }
 
-int line6_midibuf_skip_message(struct MidiBuffer *this, unsigned short mask)
+int line6_midibuf_skip_message(struct midi_buffer *this, unsigned short mask)
 {
        int cmd = this->command_prev;
 
@@ -257,7 +258,7 @@ int line6_midibuf_skip_message(struct MidiBuffer *this, unsigned short mask)
        return 0;
 }
 
-void line6_midibuf_destroy(struct MidiBuffer *this)
+void line6_midibuf_destroy(struct midi_buffer *this)
 {
        kfree(this->buf);
        this->buf = NULL;
index 444cb3a12d722ac3e4b9ced76548ee4c703fa2dd..707482b940e4d401dc1d5f9511b5e90aa93ae51c 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef MIDIBUF_H
 #define MIDIBUF_H
 
-struct MidiBuffer {
+struct midi_buffer {
        unsigned char *buf;
        int size;
        int split;
@@ -21,18 +21,18 @@ struct MidiBuffer {
        int command_prev;
 };
 
-extern int line6_midibuf_bytes_used(struct MidiBuffer *mb);
-extern int line6_midibuf_bytes_free(struct MidiBuffer *mb);
-extern void line6_midibuf_destroy(struct MidiBuffer *mb);
-extern int line6_midibuf_ignore(struct MidiBuffer *mb, int length);
-extern int line6_midibuf_init(struct MidiBuffer *mb, int size, int split);
-extern int line6_midibuf_read(struct MidiBuffer *mb, unsigned char *data,
+extern int line6_midibuf_bytes_used(struct midi_buffer *mb);
+extern int line6_midibuf_bytes_free(struct midi_buffer *mb);
+extern void line6_midibuf_destroy(struct midi_buffer *mb);
+extern int line6_midibuf_ignore(struct midi_buffer *mb, int length);
+extern int line6_midibuf_init(struct midi_buffer *mb, int size, int split);
+extern int line6_midibuf_read(struct midi_buffer *mb, unsigned char *data,
                              int length);
-extern void line6_midibuf_reset(struct MidiBuffer *mb);
-extern int line6_midibuf_skip_message(struct MidiBuffer *mb,
+extern void line6_midibuf_reset(struct midi_buffer *mb);
+extern int line6_midibuf_skip_message(struct midi_buffer *mb,
                                      unsigned short mask);
-extern void line6_midibuf_status(struct MidiBuffer *mb);
-extern int line6_midibuf_write(struct MidiBuffer *mb, unsigned char *data,
+extern void line6_midibuf_status(struct midi_buffer *mb);
+extern int line6_midibuf_write(struct midi_buffer *mb, unsigned char *data,
                               int length);
 
 #endif
index 6c1e31335d196b529c8e5094373e45226de42a29..17969c656648ee8c8c8b0c20356e95d3370e5bed 100644 (file)
@@ -49,11 +49,11 @@ static ssize_t pcm_set_impulse_volume(struct device *dev,
 {
        struct snd_line6_pcm *line6pcm = dev2pcm(dev);
        int value;
-       int rv;
+       int ret;
 
-       rv = kstrtoint(buf, 10, &value);
-       if (rv < 0)
-               return rv;
+       ret = kstrtoint(buf, 10, &value);
+       if (ret < 0)
+               return ret;
 
        line6pcm->impulse_volume = value;
 
@@ -81,7 +81,14 @@ static ssize_t pcm_set_impulse_period(struct device *dev,
                                      struct device_attribute *attr,
                                      const char *buf, size_t count)
 {
-       dev2pcm(dev)->impulse_period = simple_strtoul(buf, NULL, 10);
+       int value;
+       int ret;
+
+       ret = kstrtoint(buf, 10, &value);
+       if (ret < 0)
+               return ret;
+
+       dev2pcm(dev)->impulse_period = value;
        return count;
 }
 
@@ -455,13 +462,12 @@ int line6_init_pcm(struct usb_line6 *line6,
                ep_write = 0x01;
                break;
 
-               /* this is for interface_number == 1:
-                  case LINE6_DEVID_TONEPORT_UX2:
-                  case LINE6_DEVID_PODSTUDIO_UX2:
-                  ep_read  = 0x87;
-                  ep_write = 0x00;
-                  break;
-                */
+       /* this is for interface_number == 1:
+       case LINE6_DEVID_TONEPORT_UX2:
+       case LINE6_DEVID_PODSTUDIO_UX2:
+               ep_read  = 0x87;
+               ep_write = 0x00;
+               break; */
 
        default:
                MISSING_CASE;
index 4cf23af9c627d28a60b342e42b74be7c47dcfea9..f9135c7cb19534bd909b14fce55d3fa5d8d79f0c 100644 (file)
@@ -264,15 +264,6 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
                }
 #endif
        }
-#ifdef CONFIG_LINE6_USB_DUMP_PCM
-       for (i = 0; i < LINE6_ISO_PACKETS; ++i) {
-               struct usb_iso_packet_descriptor *fout =
-                   &urb_out->iso_frame_desc[i];
-               line6_write_hexdump(line6pcm->line6, 'P',
-                                   urb_out->transfer_buffer + fout->offset,
-                                   fout->length);
-       }
-#endif
 
        ret = usb_submit_urb(urb_out, GFP_ATOMIC);
 
index e542540d0db39c040f4f2610edcbe62d772f9f74..74898c3c9f90b4b6c862b48aa028f6f7f2c71c26 100644 (file)
@@ -34,12 +34,14 @@ enum {
        POD_SYSEX_DUMPMEM   = 0x73,
        POD_SYSEX_DUMP      = 0x74,
        POD_SYSEX_DUMPREQ   = 0x75
-       /* POD_SYSEX_DUMPMEM2  = 0x76 */   /* dumps entire internal memory of PODxt Pro */
+
+       /* dumps entire internal memory of PODxt Pro */
+       /* POD_SYSEX_DUMPMEM2  = 0x76 */
 };
 
 enum {
-       POD_monitor_level  = 0x04,
-       POD_system_invalid = 0x10000
+       POD_MONITOR_LEVEL  = 0x04,
+       POD_SYSTEM_INVALID = 0x10000
 };
 
 /* *INDENT-ON* */
@@ -133,84 +135,27 @@ void line6_pod_process_message(struct usb_line6_pod *pod)
 {
        const unsigned char *buf = pod->line6.buffer_message;
 
-       /* filter messages by type */
-       switch (buf[0] & 0xf0) {
-       case LINE6_PARAM_CHANGE:
-       case LINE6_PROGRAM_CHANGE:
-       case LINE6_SYSEX_BEGIN:
-               break;          /* handle these further down */
+       if (memcmp(buf, pod_version_header, sizeof(pod_version_header)) == 0) {
+               pod->firmware_version = buf[13] * 100 + buf[14] * 10 + buf[15];
+               pod->device_id = ((int)buf[8] << 16) | ((int)buf[9] << 8) |
+                                (int) buf[10];
+               pod_startup3(pod);
+               return;
+       }
 
-       default:
-               return;         /* ignore all others */
+       /* Only look for sysex messages from this device */
+       if (buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE) &&
+           buf[0] != (LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN)) {
+               return;
+       }
+       if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) != 0) {
+               return;
        }
 
-       /* process all remaining messages */
-       switch (buf[0]) {
-       case LINE6_PARAM_CHANGE | LINE6_CHANNEL_DEVICE:
-       case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST:
-               break;
-
-       case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
-       case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
-               break;
-
-       case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_DEVICE:
-       case LINE6_SYSEX_BEGIN | LINE6_CHANNEL_UNKNOWN:
-               if (memcmp(buf + 1, line6_midi_id, sizeof(line6_midi_id)) == 0) {
-                       switch (buf[5]) {
-                       case POD_SYSEX_DUMP:
-                               break;
-
-                       case POD_SYSEX_SYSTEM:{
-                                       short value =
-                                           ((int)buf[7] << 12) | ((int)buf[8]
-                                                                  << 8) |
-                                           ((int)buf[9] << 4) | (int)buf[10];
-
-                                       if (buf[6] == POD_monitor_level)
-                                               pod->monitor_level = value;
-                                       break;
-                               }
-
-                       case POD_SYSEX_FINISH:
-                               /* do we need to respond to this? */
-                               break;
-
-                       case POD_SYSEX_SAVE:
-                               break;
-
-                       case POD_SYSEX_STORE:
-                               dev_dbg(pod->line6.ifcdev,
-                                       "message %02X not yet implemented\n",
-                                       buf[5]);
-                               break;
-
-                       default:
-                               dev_dbg(pod->line6.ifcdev,
-                                       "unknown sysex message %02X\n",
-                                       buf[5]);
-                       }
-               } else
-                   if (memcmp
-                       (buf, pod_version_header,
-                        sizeof(pod_version_header)) == 0) {
-                       pod->firmware_version =
-                           buf[13] * 100 + buf[14] * 10 + buf[15];
-                       pod->device_id =
-                           ((int)buf[8] << 16) | ((int)buf[9] << 8) | (int)
-                           buf[10];
-                       pod_startup3(pod);
-               } else
-                       dev_dbg(pod->line6.ifcdev, "unknown sysex header\n");
-
-               break;
-
-       case LINE6_SYSEX_END:
-               break;
-
-       default:
-               dev_dbg(pod->line6.ifcdev, "POD: unknown message %02X\n",
-                       buf[0]);
+       if (buf[5] == POD_SYSEX_SYSTEM && buf[6] == POD_MONITOR_LEVEL) {
+               short value = ((int)buf[7] << 12) | ((int)buf[8] << 8) |
+                             ((int)buf[9] << 4) | (int)buf[10];
+               pod->monitor_level = value;
        }
 }
 
@@ -369,7 +314,7 @@ static int snd_pod_control_monitor_put(struct snd_kcontrol *kcontrol,
 
        pod->monitor_level = ucontrol->value.integer.value[0];
        pod_set_system_param_int(pod, ucontrol->value.integer.value[0],
-                                POD_monitor_level);
+                                POD_MONITOR_LEVEL);
        return 1;
 }
 
@@ -460,7 +405,7 @@ static int pod_try_init(struct usb_interface *interface,
         */
 
        if (pod->line6.properties->capabilities & LINE6_BIT_CONTROL) {
-               pod->monitor_level = POD_system_invalid;
+               pod->monitor_level = POD_SYSTEM_INVALID;
 
                /* initiate startup procedure: */
                pod_startup1(pod);
index a529dd3d604e7b69a9254fb395dfb8f46c4654dd..2f44d56700af1eabe13625777b3cc3ce8c94cf20 100644 (file)
@@ -87,12 +87,10 @@ static struct line6_pcm_properties toneport_pcm_properties = {
 static int led_red = 0x00;
 static int led_green = 0x26;
 
-struct ToneportSourceInfo {
+static const struct {
        const char *name;
        int code;
-};
-
-static const struct ToneportSourceInfo toneport_source_info[] = {
+} toneport_source_info[] = {
        {"Microphone", 0x0a01},
        {"Line", 0x0801},
        {"Instrument", 0x0b01},
index 4fca58f112455d99c643c1054c791ea5299a0d8c..bd0f694fa8d8288daac34b1934a2a9e31ae888a6 100644 (file)
@@ -133,13 +133,6 @@ void line6_variax_process_message(struct usb_line6_variax *variax)
        const unsigned char *buf = variax->line6.buffer_message;
 
        switch (buf[0]) {
-       case LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST:
-               break;
-
-       case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_DEVICE:
-       case LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST:
-               break;
-
        case LINE6_RESET:
                dev_info(variax->line6.ifcdev, "VARIAX reset\n");
                break;
@@ -154,13 +147,6 @@ void line6_variax_process_message(struct usb_line6_variax *variax)
                        variax_startup4((unsigned long)variax);
                }
                break;
-
-       case LINE6_SYSEX_END:
-               break;
-
-       default:
-               dev_dbg(variax->line6.ifcdev,
-                       "Variax: unknown message %02X\n", buf[0]);
        }
 }
 
index 8346e3450f837474ccbe0326772db66d2541e470..89f7180b5e013a1a30f9be4374d7007c3aef842a 100644 (file)
@@ -568,8 +568,6 @@ int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id,
 
        tsr = bg_ptr->conf->sensors[id].registers;
        time = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
-       if (ret)
-               return ret;
        time = (time & tsr->counter_mask) >> __ffs(tsr->counter_mask);
        time = time * 1000 / bg_ptr->clk_rate;
 
index 61f1070c666777db427d2267dc1ab76d046ce29b..79a55aaae5a3aef7e9682dfb2b3543611dd97e1f 100644 (file)
@@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
 
        data = omap_bandgap_get_sensor_data(bg_ptr, id);
 
-       if (!data)
+       if (IS_ERR(data))
                data = omap_thermal_build_data(bg_ptr, id);
 
        if (!data)
@@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
        struct omap_thermal_data *data;
 
        data = omap_bandgap_get_sensor_data(bg_ptr, id);
-       if (!data)
+       if (IS_ERR(data))
                data = omap_thermal_build_data(bg_ptr, id);
 
        if (!data)
index 273ec12c028abd13f3257cbdc7bb24628b156bf1..58bcd6ae0255dace4ae845c366af35cf62be4f20 100644 (file)
@@ -118,6 +118,11 @@ struct pat {
 #define DESCR_SIZE 128
 #define REFILL_BUFFER_SIZE ((4 * 128 * 256) + (3 * DESCR_SIZE))
 
+/* For OMAP5, a fixed offset is added to all Y coordinates for 1D buffers.
+ * This is used in programming to address the upper portion of the LUT
+*/
+#define OMAP5_LUT_OFFSET       128
+
 struct dmm;
 
 struct dmm_txn {
index 59bf43899fc09d20ac5c01a0c1894f4b166bc189..3910215371053037aff61580939cd8596298e9eb 100644 (file)
@@ -213,6 +213,11 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
                txn->last_pat->next_pa = (uint32_t)pat_pa;
 
        pat->area = *area;
+
+       /* adjust Y coordinates based off of container parameters */
+       pat->area.y0 += engine->tcm->y_offset;
+       pat->area.y1 += engine->tcm->y_offset;
+
        pat->ctrl = (struct pat_ctrl){
                        .start = 1,
                        .lut_id = engine->tcm->lut_id,
@@ -622,6 +627,11 @@ static int omap_dmm_probe(struct platform_device *dev)
        omap_dmm->lut_width = ((pat_geom >> 16) & 0xF) << 5;
        omap_dmm->lut_height = ((pat_geom >> 24) & 0xF) << 5;
 
+       /* increment LUT by one if on OMAP5 */
+       /* LUT has twice the height, and is split into a separate container */
+       if (omap_dmm->lut_height != omap_dmm->container_height)
+               omap_dmm->num_lut++;
+
        /* initialize DMM registers */
        writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__0);
        writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__1);
@@ -701,6 +711,9 @@ static int omap_dmm_probe(struct platform_device *dev)
        }
 
        /* init containers */
+       /* Each LUT is associated with a TCM (container manager).  We use the
+          lut_id to denote the lut_id used to identify the correct LUT for
+          programming during reill operations */
        for (i = 0; i < omap_dmm->num_lut; i++) {
                omap_dmm->tcm[i] = sita_init(omap_dmm->container_width,
                                                omap_dmm->container_height,
@@ -717,13 +730,23 @@ static int omap_dmm_probe(struct platform_device *dev)
 
        /* assign access mode containers to applicable tcm container */
        /* OMAP 4 has 1 container for all 4 views */
+       /* OMAP 5 has 2 containers, 1 for 2D and 1 for 1D */
        containers[TILFMT_8BIT] = omap_dmm->tcm[0];
        containers[TILFMT_16BIT] = omap_dmm->tcm[0];
        containers[TILFMT_32BIT] = omap_dmm->tcm[0];
-       containers[TILFMT_PAGE] = omap_dmm->tcm[0];
+
+       if (omap_dmm->container_height != omap_dmm->lut_height) {
+               /* second LUT is used for PAGE mode.  Programming must use
+                  y offset that is added to all y coordinates.  LUT id is still
+                  0, because it is the same LUT, just the upper 128 lines */
+               containers[TILFMT_PAGE] = omap_dmm->tcm[1];
+               omap_dmm->tcm[1]->y_offset = OMAP5_LUT_OFFSET;
+               omap_dmm->tcm[1]->lut_id = 0;
+       } else {
+               containers[TILFMT_PAGE] = omap_dmm->tcm[0];
+       }
 
        area = (struct tcm_area) {
-               .is2d = true,
                .tcm = NULL,
                .p1.x = omap_dmm->container_width - 1,
                .p1.y = omap_dmm->container_height - 1,
@@ -835,64 +858,81 @@ int tiler_map_show(struct seq_file *s, void *arg)
        int h_adj;
        int w_adj;
        unsigned long flags;
+       int lut_idx;
+
 
        if (!omap_dmm) {
                /* early return if dmm/tiler device is not initialized */
                return 0;
        }
 
-       h_adj = omap_dmm->lut_height / ydiv;
-       w_adj = omap_dmm->lut_width / xdiv;
+       h_adj = omap_dmm->container_height / ydiv;
+       w_adj = omap_dmm->container_width / xdiv;
 
-       map = kzalloc(h_adj * sizeof(*map), GFP_KERNEL);
-       global_map = kzalloc((w_adj + 1) * h_adj, GFP_KERNEL);
+       map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
+       global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
 
        if (!map || !global_map)
                goto error;
 
-       memset(global_map, ' ', (w_adj + 1) * h_adj);
-       for (i = 0; i < omap_dmm->lut_height; i++) {
-               map[i] = global_map + i * (w_adj + 1);
-               map[i][w_adj] = 0;
-       }
-       spin_lock_irqsave(&list_lock, flags);
+       for (lut_idx = 0; lut_idx < omap_dmm->num_lut; lut_idx++) {
+               memset(map, 0, sizeof(h_adj * sizeof(*map)));
+               memset(global_map, ' ', (w_adj + 1) * h_adj);
 
-       list_for_each_entry(block, &omap_dmm->alloc_head, alloc_node) {
-               if (block->fmt != TILFMT_PAGE) {
-                       fill_map(map, xdiv, ydiv, &block->area, *m2dp, true);
-                       if (!*++a2dp)
-                               a2dp = a2d;
-                       if (!*++m2dp)
-                               m2dp = m2d;
-                       map_2d_info(map, xdiv, ydiv, nice, &block->area);
-               } else {
-                       bool start = read_map_pt(map, xdiv, ydiv,
-                                                       &block->area.p0)
-                                                                       == ' ';
-                       bool end = read_map_pt(map, xdiv, ydiv, &block->area.p1)
-                                                                       == ' ';
-                       tcm_for_each_slice(a, block->area, p)
-                               fill_map(map, xdiv, ydiv, &a, '=', true);
-                       fill_map_pt(map, xdiv, ydiv, &block->area.p0,
+               for (i = 0; i < omap_dmm->container_height; i++) {
+                       map[i] = global_map + i * (w_adj + 1);
+                       map[i][w_adj] = 0;
+               }
+
+               spin_lock_irqsave(&list_lock, flags);
+
+               list_for_each_entry(block, &omap_dmm->alloc_head, alloc_node) {
+                       if (block->area.tcm == omap_dmm->tcm[lut_idx]) {
+                               if (block->fmt != TILFMT_PAGE) {
+                                       fill_map(map, xdiv, ydiv, &block->area,
+                                               *m2dp, true);
+                                       if (!*++a2dp)
+                                               a2dp = a2d;
+                                       if (!*++m2dp)
+                                               m2dp = m2d;
+                                       map_2d_info(map, xdiv, ydiv, nice,
+                                                       &block->area);
+                               } else {
+                                       bool start = read_map_pt(map, xdiv,
+                                               ydiv, &block->area.p0) == ' ';
+                                       bool end = read_map_pt(map, xdiv, ydiv,
+                                                       &block->area.p1) == ' ';
+
+                                       tcm_for_each_slice(a, block->area, p)
+                                               fill_map(map, xdiv, ydiv, &a,
+                                                       '=', true);
+                                       fill_map_pt(map, xdiv, ydiv,
+                                                       &block->area.p0,
                                                        start ? '<' : 'X');
-                       fill_map_pt(map, xdiv, ydiv, &block->area.p1,
+                                       fill_map_pt(map, xdiv, ydiv,
+                                                       &block->area.p1,
                                                        end ? '>' : 'X');
-                       map_1d_info(map, xdiv, ydiv, nice, &block->area);
+                                       map_1d_info(map, xdiv, ydiv, nice,
+                                                       &block->area);
+                               }
+                       }
                }
-       }
 
-       spin_unlock_irqrestore(&list_lock, flags);
+               spin_unlock_irqrestore(&list_lock, flags);
 
-       if (s) {
-               seq_printf(s, "BEGIN DMM TILER MAP\n");
-               for (i = 0; i < 128; i++)
-                       seq_printf(s, "%03d:%s\n", i, map[i]);
-               seq_printf(s, "END TILER MAP\n");
-       } else {
-               dev_dbg(omap_dmm->dev, "BEGIN DMM TILER MAP\n");
-               for (i = 0; i < 128; i++)
-                       dev_dbg(omap_dmm->dev, "%03d:%s\n", i, map[i]);
-               dev_dbg(omap_dmm->dev, "END TILER MAP\n");
+               if (s) {
+                       seq_printf(s, "CONTAINER %d DUMP BEGIN\n", lut_idx);
+                       for (i = 0; i < 128; i++)
+                               seq_printf(s, "%03d:%s\n", i, map[i]);
+                       seq_printf(s, "CONTAINER %d DUMP END\n", lut_idx);
+               } else {
+                       dev_dbg(omap_dmm->dev, "CONTAINER %d DUMP BEGIN\n",
+                               lut_idx);
+                       for (i = 0; i < 128; i++)
+                               dev_dbg(omap_dmm->dev, "%03d:%s\n", i, map[i]);
+                       dev_dbg(omap_dmm->dev, "CONTAINER %d DUMP END\n",
+                               lut_idx);
+               }
        }
 
 error:
@@ -903,12 +943,45 @@ error:
 }
 #endif
 
+#ifdef CONFIG_PM
+static int omap_dmm_resume(struct device *dev)
+{
+       struct tcm_area area;
+       int i;
+
+       if (!omap_dmm)
+               return -ENODEV;
+
+       area = (struct tcm_area) {
+               .tcm = NULL,
+               .p1.x = omap_dmm->container_width - 1,
+               .p1.y = omap_dmm->container_height - 1,
+       };
+
+       /* initialize all LUTs to dummy page entries */
+       for (i = 0; i < omap_dmm->num_lut; i++) {
+               area.tcm = omap_dmm->tcm[i];
+               if (fill(&area, NULL, 0, 0, true))
+                       dev_err(dev, "refill failed");
+       }
+
+       return 0;
+}
+
+static const struct dev_pm_ops omap_dmm_pm_ops = {
+       .resume = omap_dmm_resume,
+};
+#endif
+
 struct platform_driver omap_dmm_driver = {
        .probe = omap_dmm_probe,
        .remove = omap_dmm_remove,
        .driver = {
                .owner = THIS_MODULE,
                .name = DMM_DRIVER_NAME,
+#ifdef CONFIG_PM
+               .pm = &omap_dmm_pm_ops,
+#endif
        },
 };
 
index ae5ecc2efbc758268d692d732482d1f49f13c352..d246f8543d2ee20b8fe5df7a9386d969da1dba95 100644 (file)
@@ -368,6 +368,9 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
                /* well, limp along without an fbdev.. maybe X11 will work? */
        }
 
+       /* store off drm_device for use in pm ops */
+       dev_set_drvdata(dev->dev, dev);
+
        drm_kms_helper_poll_init(dev);
 
        return 0;
@@ -393,6 +396,8 @@ static int dev_unload(struct drm_device *dev)
        kfree(dev->dev_private);
        dev->dev_private = NULL;
 
+       dev_set_drvdata(dev->dev, NULL);
+
        return 0;
 }
 
@@ -558,10 +563,19 @@ static int pdev_remove(struct platform_device *device)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static const struct dev_pm_ops omapdrm_pm_ops = {
+       .resume = omap_gem_resume,
+};
+#endif
+
 struct platform_driver pdev = {
                .driver = {
                        .name = DRIVER_NAME,
                        .owner = THIS_MODULE,
+#ifdef CONFIG_PM
+                       .pm = &omapdrm_pm_ops,
+#endif
                },
                .probe = pdev_probe,
                .remove = pdev_remove,
index cd1f22b0b124ddbf9eb1eff0efe5b77ddb7fd061..f921027e7500efb8de4fc350f330ec34ea552044 100644 (file)
@@ -135,6 +135,10 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
 #endif
 
+#ifdef CONFIG_PM
+int omap_gem_resume(struct device *dev);
+#endif
+
 int omap_irq_enable_vblank(struct drm_device *dev, int crtc);
 void omap_irq_disable_vblank(struct drm_device *dev, int crtc);
 irqreturn_t omap_irq_handler(DRM_IRQ_ARGS);
index c38992b76fc9f86bf9a4664dfc2e90516041b422..08f1e292ed201c57a65bddf67e84de6695a5bf0a 100644 (file)
@@ -964,6 +964,34 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
        return omap_obj->vaddr;
 }
 
+#ifdef CONFIG_PM
+/* re-pin objects in DMM in resume path: */
+int omap_gem_resume(struct device *dev)
+{
+       struct drm_device *drm_dev = dev_get_drvdata(dev);
+       struct omap_drm_private *priv = drm_dev->dev_private;
+       struct omap_gem_object *omap_obj;
+       int ret = 0;
+
+       list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
+               if (omap_obj->block) {
+                       struct drm_gem_object *obj = &omap_obj->base;
+                       uint32_t npages = obj->size >> PAGE_SHIFT;
+                       WARN_ON(!omap_obj->pages);  /* this can't happen */
+                       ret = tiler_pin(omap_obj->block,
+                                       omap_obj->pages, npages,
+                                       omap_obj->roll, true);
+                       if (ret) {
+                               dev_err(dev, "could not repin: %d\n", ret);
+                               return ret;
+                       }
+               }
+       }
+
+       return 0;
+}
+#endif
+
 #ifdef CONFIG_DEBUG_FS
 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
 {
index b6c5b5c6c8c53dbd39e84baa91cd43e1b81ebfb7..a3236abfca3d3b9a6450c3f15eca211945f5bfc1 100644 (file)
@@ -53,10 +53,10 @@ static struct sg_table *omap_gem_map_dma_buf(
        /* this should be after _get_paddr() to ensure we have pages attached */
        omap_gem_dma_sync(obj, dir);
 
-out:
-       if (ret)
-               return ERR_PTR(ret);
        return sg;
+out:
+       kfree(sg);
+       return ERR_PTR(ret);
 }
 
 static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
index d273e3ee0b4c7d64737b1e52fbbcb068a0be089a..a8d5ce47686f791981b96b401d701ae83abab585 100644 (file)
@@ -59,6 +59,8 @@ struct tcm {
        u16 width, height;      /* container dimensions */
        int lut_id;             /* Lookup table identifier */
 
+       unsigned int y_offset;  /* offset to use for y coordinates */
+
        /* 'pvt' structure shall contain any tcm details (attr) along with
        linked list of allocated areas and mutex for mutually exclusive access
        to the list.  It may also contain copies of width and height to notice
index b5db2456bffa5241113bd6e7dafece42c38cbbc1..b4febd79a68dbff6c938c035095917fc38c99c85 100644 (file)
@@ -10,6 +10,5 @@ TODO:
        - testing with as many devices as possible.
 
 Please send any patches for this driver to
-Rupesh Gujare <rgujare@ozmodevices.com>
-Chris Kelly <ckelly@ozmodevices.com>
+Rupesh Gujare <rupesh.gujare@atmel.com>
 and Greg Kroah-Hartman <gregkh@linuxfoundation.org>.
diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig
deleted file mode 100644 (file)
index 3abf661..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-config ZCACHE2
-       bool "Dynamic compression of swap pages and clean pagecache pages"
-       depends on CRYPTO=y && SWAP=y && CLEANCACHE && FRONTSWAP && !ZCACHE 
-       select CRYPTO_LZO
-       default n
-       help
-         Zcache2 doubles RAM efficiency while providing a significant
-         performance boosts on many workloads.  Zcache2 uses
-         compression and an in-kernel implementation of transcendent
-         memory to store clean page cache pages and swap in RAM,
-         providing a noticeable reduction in disk I/O.  Zcache2
-         is a complete rewrite of the older zcache; it was intended to
-         be a merge but that has been blocked due to political and
-         technical disagreements.  It is intended that they will merge
-         again in the future.  Until then, zcache2 is a single-node
-         version of ramster.
-
-config RAMSTER
-       bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
-       depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE2=y
-       depends on NET
-       # must ensure struct page is 8-byte aligned
-       select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT
-       default n
-       help
-         RAMster allows RAM on other machines in a cluster to be utilized
-         dynamically and symmetrically instead of swapping to a local swap
-         disk, thus improving performance on memory-constrained workloads
-         while minimizing total RAM across the cluster.  RAMster, like
-         zcache2, compresses swap pages into local RAM, but then remotifies
-         the compressed pages to another node in the RAMster cluster.
diff --git a/drivers/staging/ramster/Makefile b/drivers/staging/ramster/Makefile
deleted file mode 100644 (file)
index 2d8b9d0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-zcache-y       :=              zcache-main.o tmem.o zbud.o
-zcache-$(CONFIG_RAMSTER)       +=      ramster/ramster.o ramster/r2net.o
-zcache-$(CONFIG_RAMSTER)       +=      ramster/nodemanager.o ramster/tcp.o
-zcache-$(CONFIG_RAMSTER)       +=      ramster/heartbeat.o ramster/masklog.o
-
-obj-$(CONFIG_ZCACHE2)  +=      zcache.o
diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
deleted file mode 100644 (file)
index a2b7e03..0000000
+++ /dev/null
@@ -1,894 +0,0 @@
-/*
- * In-kernel transcendent memory (generic implementation)
- *
- * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp.
- *
- * The primary purpose of Transcedent Memory ("tmem") is to map object-oriented
- * "handles" (triples containing a pool id, and object id, and an index), to
- * pages in a page-accessible memory (PAM).  Tmem references the PAM pages via
- * an abstract "pampd" (PAM page-descriptor), which can be operated on by a
- * set of functions (pamops).  Each pampd contains some representation of
- * PAGE_SIZE bytes worth of data. For those familiar with key-value stores,
- * the tmem handle is a three-level hierarchical key, and the value is always
- * reconstituted (but not necessarily stored) as PAGE_SIZE bytes and is
- * referenced in the datastore by the pampd.  The hierarchy is required
- * to ensure that certain invalidation functions can be performed efficiently
- * (i.e. flush all indexes associated with this object_id, or
- * flush all objects associated with this pool).
- *
- * Tmem must support potentially millions of pages and must be able to insert,
- * find, and delete these pages at a potential frequency of thousands per
- * second concurrently across many CPUs, (and, if used with KVM, across many
- * vcpus across many guests).  Tmem is tracked with a hierarchy of data
- * structures, organized by the elements in the handle-tuple: pool_id,
- * object_id, and page index.  One or more "clients" (e.g. guests) each
- * provide one or more tmem_pools.  Each pool, contains a hash table of
- * rb_trees of tmem_objs.  Each tmem_obj contains a radix-tree-like tree
- * of pointers, with intermediate nodes called tmem_objnodes.  Each leaf
- * pointer in this tree points to a pampd, which is accessible only through
- * a small set of callbacks registered by the PAM implementation (see
- * tmem_register_pamops). Tmem only needs to memory allocation for objs
- * and objnodes and this is done via a set of callbacks that must be
- * registered by the tmem host implementation (e.g. see tmem_register_hostops).
- */
-
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/atomic.h>
-#ifdef CONFIG_RAMSTER
-#include <linux/delay.h>
-#endif
-
-#include "tmem.h"
-
-/* data structure sentinels used for debugging... see tmem.h */
-#define POOL_SENTINEL 0x87658765
-#define OBJ_SENTINEL 0x12345678
-#define OBJNODE_SENTINEL 0xfedcba09
-
-/*
- * A tmem host implementation must use this function to register callbacks
- * for memory allocation.
- */
-static struct tmem_hostops tmem_hostops;
-
-static void tmem_objnode_tree_init(void);
-
-void tmem_register_hostops(struct tmem_hostops *m)
-{
-       tmem_objnode_tree_init();
-       tmem_hostops = *m;
-}
-
-/*
- * A tmem host implementation must use this function to register
- * callbacks for a page-accessible memory (PAM) implementation.
- */
-static struct tmem_pamops tmem_pamops;
-
-void tmem_register_pamops(struct tmem_pamops *m)
-{
-       tmem_pamops = *m;
-}
-
-/*
- * Oid's are potentially very sparse and tmem_objs may have an indeterminately
- * short life, being added and deleted at a relatively high frequency.
- * So an rb_tree is an ideal data structure to manage tmem_objs.  But because
- * of the potentially huge number of tmem_objs, each pool manages a hashtable
- * of rb_trees to reduce search, insert, delete, and rebalancing time.
- * Each hashbucket also has a lock to manage concurrent access and no
- * searches, inserts, or deletions can be performed unless the lock is held.
- * As a result, care must be taken to ensure tmem routines are not called
- * recursively; the vast majority of the time, a recursive call may work
- * but a deadlock will occur a small fraction of the time due to the
- * hashbucket lock.
- *
- * The following routines manage tmem_objs.  In all of these routines,
- * the hashbucket lock is already held.
- */
-
-/* Search for object==oid in pool, returns object if found. */
-static struct tmem_obj *__tmem_obj_find(struct tmem_hashbucket *hb,
-                                       struct tmem_oid *oidp,
-                                       struct rb_node **parent,
-                                       struct rb_node ***link)
-{
-       struct rb_node *_parent = NULL, **rbnode;
-       struct tmem_obj *obj = NULL;
-
-       rbnode = &hb->obj_rb_root.rb_node;
-       while (*rbnode) {
-               BUG_ON(RB_EMPTY_NODE(*rbnode));
-               _parent = *rbnode;
-               obj = rb_entry(*rbnode, struct tmem_obj,
-                              rb_tree_node);
-               switch (tmem_oid_compare(oidp, &obj->oid)) {
-               case 0: /* equal */
-                       goto out;
-               case -1:
-                       rbnode = &(*rbnode)->rb_left;
-                       break;
-               case 1:
-                       rbnode = &(*rbnode)->rb_right;
-                       break;
-               }
-       }
-
-       if (parent)
-               *parent = _parent;
-       if (link)
-               *link = rbnode;
-       obj = NULL;
-out:
-       return obj;
-}
-
-static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb,
-                                       struct tmem_oid *oidp)
-{
-       return __tmem_obj_find(hb, oidp, NULL, NULL);
-}
-
-static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *, bool);
-
-/* Free an object that has no more pampds in it. */
-static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb)
-{
-       struct tmem_pool *pool;
-
-       BUG_ON(obj == NULL);
-       ASSERT_SENTINEL(obj, OBJ);
-       BUG_ON(obj->pampd_count > 0);
-       pool = obj->pool;
-       BUG_ON(pool == NULL);
-       if (obj->objnode_tree_root != NULL) /* may be "stump" with no leaves */
-               tmem_pampd_destroy_all_in_obj(obj, false);
-       BUG_ON(obj->objnode_tree_root != NULL);
-       BUG_ON((long)obj->objnode_count != 0);
-       atomic_dec(&pool->obj_count);
-       BUG_ON(atomic_read(&pool->obj_count) < 0);
-       INVERT_SENTINEL(obj, OBJ);
-       obj->pool = NULL;
-       tmem_oid_set_invalid(&obj->oid);
-       rb_erase(&obj->rb_tree_node, &hb->obj_rb_root);
-}
-
-/*
- * Initialize, and insert an tmem_object_root (called only if find failed).
- */
-static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
-                                       struct tmem_pool *pool,
-                                       struct tmem_oid *oidp)
-{
-       struct rb_root *root = &hb->obj_rb_root;
-       struct rb_node **new = NULL, *parent = NULL;
-
-       BUG_ON(pool == NULL);
-       atomic_inc(&pool->obj_count);
-       obj->objnode_tree_height = 0;
-       obj->objnode_tree_root = NULL;
-       obj->pool = pool;
-       obj->oid = *oidp;
-       obj->objnode_count = 0;
-       obj->pampd_count = 0;
-#ifdef CONFIG_RAMSTER
-       if (tmem_pamops.new_obj != NULL)
-               (*tmem_pamops.new_obj)(obj);
-#endif
-       SET_SENTINEL(obj, OBJ);
-
-       if (__tmem_obj_find(hb, oidp, &parent, &new))
-               BUG();
-
-       rb_link_node(&obj->rb_tree_node, parent, new);
-       rb_insert_color(&obj->rb_tree_node, root);
-}
-
-/*
- * Tmem is managed as a set of tmem_pools with certain attributes, such as
- * "ephemeral" vs "persistent".  These attributes apply to all tmem_objs
- * and all pampds that belong to a tmem_pool.  A tmem_pool is created
- * or deleted relatively rarely (for example, when a filesystem is
- * mounted or unmounted).
- */
-
-/* flush all data from a pool and, optionally, free it */
-static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
-{
-       struct rb_node *rbnode;
-       struct tmem_obj *obj;
-       struct tmem_hashbucket *hb = &pool->hashbucket[0];
-       int i;
-
-       BUG_ON(pool == NULL);
-       for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) {
-               spin_lock(&hb->lock);
-               rbnode = rb_first(&hb->obj_rb_root);
-               while (rbnode != NULL) {
-                       obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node);
-                       rbnode = rb_next(rbnode);
-                       tmem_pampd_destroy_all_in_obj(obj, true);
-                       tmem_obj_free(obj, hb);
-                       (*tmem_hostops.obj_free)(obj, pool);
-               }
-               spin_unlock(&hb->lock);
-       }
-       if (destroy)
-               list_del(&pool->pool_list);
-}
-
-/*
- * A tmem_obj contains a radix-tree-like tree in which the intermediate
- * nodes are called tmem_objnodes.  (The kernel lib/radix-tree.c implementation
- * is very specialized and tuned for specific uses and is not particularly
- * suited for use from this code, though some code from the core algorithms has
- * been reused, thus the copyright notices below).  Each tmem_objnode contains
- * a set of pointers which point to either a set of intermediate tmem_objnodes
- * or a set of of pampds.
- *
- * Portions Copyright (C) 2001 Momchil Velikov
- * Portions Copyright (C) 2001 Christoph Hellwig
- * Portions Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com>
- */
-
-struct tmem_objnode_tree_path {
-       struct tmem_objnode *objnode;
-       int offset;
-};
-
-/* objnode height_to_maxindex translation */
-static unsigned long tmem_objnode_tree_h2max[OBJNODE_TREE_MAX_PATH + 1];
-
-static void tmem_objnode_tree_init(void)
-{
-       unsigned int ht, tmp;
-
-       for (ht = 0; ht < ARRAY_SIZE(tmem_objnode_tree_h2max); ht++) {
-               tmp = ht * OBJNODE_TREE_MAP_SHIFT;
-               if (tmp >= OBJNODE_TREE_INDEX_BITS)
-                       tmem_objnode_tree_h2max[ht] = ~0UL;
-               else
-                       tmem_objnode_tree_h2max[ht] =
-                           (~0UL >> (OBJNODE_TREE_INDEX_BITS - tmp - 1)) >> 1;
-       }
-}
-
-static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
-{
-       struct tmem_objnode *objnode;
-
-       ASSERT_SENTINEL(obj, OBJ);
-       BUG_ON(obj->pool == NULL);
-       ASSERT_SENTINEL(obj->pool, POOL);
-       objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
-       if (unlikely(objnode == NULL))
-               goto out;
-       objnode->obj = obj;
-       SET_SENTINEL(objnode, OBJNODE);
-       memset(&objnode->slots, 0, sizeof(objnode->slots));
-       objnode->slots_in_use = 0;
-       obj->objnode_count++;
-out:
-       return objnode;
-}
-
-static void tmem_objnode_free(struct tmem_objnode *objnode)
-{
-       struct tmem_pool *pool;
-       int i;
-
-       BUG_ON(objnode == NULL);
-       for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++)
-               BUG_ON(objnode->slots[i] != NULL);
-       ASSERT_SENTINEL(objnode, OBJNODE);
-       INVERT_SENTINEL(objnode, OBJNODE);
-       BUG_ON(objnode->obj == NULL);
-       ASSERT_SENTINEL(objnode->obj, OBJ);
-       pool = objnode->obj->pool;
-       BUG_ON(pool == NULL);
-       ASSERT_SENTINEL(pool, POOL);
-       objnode->obj->objnode_count--;
-       objnode->obj = NULL;
-       (*tmem_hostops.objnode_free)(objnode, pool);
-}
-
-/*
- * Lookup index in object and return associated pampd (or NULL if not found).
- */
-static void **__tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index)
-{
-       unsigned int height, shift;
-       struct tmem_objnode **slot = NULL;
-
-       BUG_ON(obj == NULL);
-       ASSERT_SENTINEL(obj, OBJ);
-       BUG_ON(obj->pool == NULL);
-       ASSERT_SENTINEL(obj->pool, POOL);
-
-       height = obj->objnode_tree_height;
-       if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height])
-               goto out;
-       if (height == 0 && obj->objnode_tree_root) {
-               slot = &obj->objnode_tree_root;
-               goto out;
-       }
-       shift = (height-1) * OBJNODE_TREE_MAP_SHIFT;
-       slot = &obj->objnode_tree_root;
-       while (height > 0) {
-               if (*slot == NULL)
-                       goto out;
-               slot = (struct tmem_objnode **)
-                       ((*slot)->slots +
-                        ((index >> shift) & OBJNODE_TREE_MAP_MASK));
-               shift -= OBJNODE_TREE_MAP_SHIFT;
-               height--;
-       }
-out:
-       return slot != NULL ? (void **)slot : NULL;
-}
-
-static void *tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index)
-{
-       struct tmem_objnode **slot;
-
-       slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index);
-       return slot != NULL ? *slot : NULL;
-}
-
-#ifdef CONFIG_RAMSTER
-static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
-                                       void *new_pampd, bool no_free)
-{
-       struct tmem_objnode **slot;
-       void *ret = NULL;
-
-       slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index);
-       if ((slot != NULL) && (*slot != NULL)) {
-               void *old_pampd = *(void **)slot;
-               *(void **)slot = new_pampd;
-               if (!no_free)
-                       (*tmem_pamops.free)(old_pampd, obj->pool,
-                                               NULL, 0, false);
-               ret = new_pampd;
-       }
-       return ret;
-}
-#endif
-
-static int tmem_pampd_add_to_obj(struct tmem_obj *obj, uint32_t index,
-                                       void *pampd)
-{
-       int ret = 0;
-       struct tmem_objnode *objnode = NULL, *newnode, *slot;
-       unsigned int height, shift;
-       int offset = 0;
-
-       /* if necessary, extend the tree to be higher  */
-       if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height]) {
-               height = obj->objnode_tree_height + 1;
-               if (index > tmem_objnode_tree_h2max[height])
-                       while (index > tmem_objnode_tree_h2max[height])
-                               height++;
-               if (obj->objnode_tree_root == NULL) {
-                       obj->objnode_tree_height = height;
-                       goto insert;
-               }
-               do {
-                       newnode = tmem_objnode_alloc(obj);
-                       if (!newnode) {
-                               ret = -ENOMEM;
-                               goto out;
-                       }
-                       newnode->slots[0] = obj->objnode_tree_root;
-                       newnode->slots_in_use = 1;
-                       obj->objnode_tree_root = newnode;
-                       obj->objnode_tree_height++;
-               } while (height > obj->objnode_tree_height);
-       }
-insert:
-       slot = obj->objnode_tree_root;
-       height = obj->objnode_tree_height;
-       shift = (height-1) * OBJNODE_TREE_MAP_SHIFT;
-       while (height > 0) {
-               if (slot == NULL) {
-                       /* add a child objnode.  */
-                       slot = tmem_objnode_alloc(obj);
-                       if (!slot) {
-                               ret = -ENOMEM;
-                               goto out;
-                       }
-                       if (objnode) {
-
-                               objnode->slots[offset] = slot;
-                               objnode->slots_in_use++;
-                       } else
-                               obj->objnode_tree_root = slot;
-               }
-               /* go down a level */
-               offset = (index >> shift) & OBJNODE_TREE_MAP_MASK;
-               objnode = slot;
-               slot = objnode->slots[offset];
-               shift -= OBJNODE_TREE_MAP_SHIFT;
-               height--;
-       }
-       BUG_ON(slot != NULL);
-       if (objnode) {
-               objnode->slots_in_use++;
-               objnode->slots[offset] = pampd;
-       } else
-               obj->objnode_tree_root = pampd;
-       obj->pampd_count++;
-out:
-       return ret;
-}
-
-static void *tmem_pampd_delete_from_obj(struct tmem_obj *obj, uint32_t index)
-{
-       struct tmem_objnode_tree_path path[OBJNODE_TREE_MAX_PATH + 1];
-       struct tmem_objnode_tree_path *pathp = path;
-       struct tmem_objnode *slot = NULL;
-       unsigned int height, shift;
-       int offset;
-
-       BUG_ON(obj == NULL);
-       ASSERT_SENTINEL(obj, OBJ);
-       BUG_ON(obj->pool == NULL);
-       ASSERT_SENTINEL(obj->pool, POOL);
-       height = obj->objnode_tree_height;
-       if (index > tmem_objnode_tree_h2max[height])
-               goto out;
-       slot = obj->objnode_tree_root;
-       if (height == 0 && obj->objnode_tree_root) {
-               obj->objnode_tree_root = NULL;
-               goto out;
-       }
-       shift = (height - 1) * OBJNODE_TREE_MAP_SHIFT;
-       pathp->objnode = NULL;
-       do {
-               if (slot == NULL)
-                       goto out;
-               pathp++;
-               offset = (index >> shift) & OBJNODE_TREE_MAP_MASK;
-               pathp->offset = offset;
-               pathp->objnode = slot;
-               slot = slot->slots[offset];
-               shift -= OBJNODE_TREE_MAP_SHIFT;
-               height--;
-       } while (height > 0);
-       if (slot == NULL)
-               goto out;
-       while (pathp->objnode) {
-               pathp->objnode->slots[pathp->offset] = NULL;
-               pathp->objnode->slots_in_use--;
-               if (pathp->objnode->slots_in_use) {
-                       if (pathp->objnode == obj->objnode_tree_root) {
-                               while (obj->objnode_tree_height > 0 &&
-                                 obj->objnode_tree_root->slots_in_use == 1 &&
-                                 obj->objnode_tree_root->slots[0]) {
-                                       struct tmem_objnode *to_free =
-                                               obj->objnode_tree_root;
-
-                                       obj->objnode_tree_root =
-                                                       to_free->slots[0];
-                                       obj->objnode_tree_height--;
-                                       to_free->slots[0] = NULL;
-                                       to_free->slots_in_use = 0;
-                                       tmem_objnode_free(to_free);
-                               }
-                       }
-                       goto out;
-               }
-               tmem_objnode_free(pathp->objnode); /* 0 slots used, free it */
-               pathp--;
-       }
-       obj->objnode_tree_height = 0;
-       obj->objnode_tree_root = NULL;
-
-out:
-       if (slot != NULL)
-               obj->pampd_count--;
-       BUG_ON(obj->pampd_count < 0);
-       return slot;
-}
-
-/* Recursively walk the objnode_tree destroying pampds and objnodes. */
-static void tmem_objnode_node_destroy(struct tmem_obj *obj,
-                                       struct tmem_objnode *objnode,
-                                       unsigned int ht)
-{
-       int i;
-
-       if (ht == 0)
-               return;
-       for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++) {
-               if (objnode->slots[i]) {
-                       if (ht == 1) {
-                               obj->pampd_count--;
-                               (*tmem_pamops.free)(objnode->slots[i],
-                                               obj->pool, NULL, 0, true);
-                               objnode->slots[i] = NULL;
-                               continue;
-                       }
-                       tmem_objnode_node_destroy(obj, objnode->slots[i], ht-1);
-                       tmem_objnode_free(objnode->slots[i]);
-                       objnode->slots[i] = NULL;
-               }
-       }
-}
-
-static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
-                                               bool pool_destroy)
-{
-       if (obj->objnode_tree_root == NULL)
-               return;
-       if (obj->objnode_tree_height == 0) {
-               obj->pampd_count--;
-               (*tmem_pamops.free)(obj->objnode_tree_root,
-                                       obj->pool, NULL, 0, true);
-       } else {
-               tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
-                                       obj->objnode_tree_height);
-               tmem_objnode_free(obj->objnode_tree_root);
-               obj->objnode_tree_height = 0;
-       }
-       obj->objnode_tree_root = NULL;
-#ifdef CONFIG_RAMSTER
-       if (tmem_pamops.free_obj != NULL)
-               (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
-#endif
-}
-
-/*
- * Tmem is operated on by a set of well-defined actions:
- * "put", "get", "flush", "flush_object", "new pool" and "destroy pool".
- * (The tmem ABI allows for subpages and exchanges but these operations
- * are not included in this implementation.)
- *
- * These "tmem core" operations are implemented in the following functions.
- */
-
-/*
- * "Put" a page, e.g. associate the passed pampd with the passed handle.
- * Tmem_put is complicated by a corner case: What if a page with matching
- * handle already exists in tmem?  To guarantee coherency, one of two
- * actions is necessary: Either the data for the page must be overwritten,
- * or the page must be "flushed" so that the data is not accessible to a
- * subsequent "get".  Since these "duplicate puts" are relatively rare,
- * this implementation always flushes for simplicity.
- */
-int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
-               bool raw, void *pampd_to_use)
-{
-       struct tmem_obj *obj = NULL, *objfound = NULL, *objnew = NULL;
-       void *pampd = NULL, *pampd_del = NULL;
-       int ret = -ENOMEM;
-       struct tmem_hashbucket *hb;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = objfound = tmem_obj_find(hb, oidp);
-       if (obj != NULL) {
-               pampd = tmem_pampd_lookup_in_obj(objfound, index);
-               if (pampd != NULL) {
-                       /* if found, is a dup put, flush the old one */
-                       pampd_del = tmem_pampd_delete_from_obj(obj, index);
-                       BUG_ON(pampd_del != pampd);
-                       (*tmem_pamops.free)(pampd, pool, oidp, index, true);
-                       if (obj->pampd_count == 0) {
-                               objnew = obj;
-                               objfound = NULL;
-                       }
-                       pampd = NULL;
-               }
-       } else {
-               obj = objnew = (*tmem_hostops.obj_alloc)(pool);
-               if (unlikely(obj == NULL)) {
-                       ret = -ENOMEM;
-                       goto out;
-               }
-               tmem_obj_init(obj, hb, pool, oidp);
-       }
-       BUG_ON(obj == NULL);
-       BUG_ON(((objnew != obj) && (objfound != obj)) || (objnew == objfound));
-       pampd = pampd_to_use;
-       BUG_ON(pampd_to_use == NULL);
-       ret = tmem_pampd_add_to_obj(obj, index, pampd);
-       if (unlikely(ret == -ENOMEM))
-               /* may have partially built objnode tree ("stump") */
-               goto delete_and_free;
-       (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
-       goto out;
-
-delete_and_free:
-       (void)tmem_pampd_delete_from_obj(obj, index);
-       if (pampd)
-               (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
-       if (objnew) {
-               tmem_obj_free(objnew, hb);
-               (*tmem_hostops.obj_free)(objnew, pool);
-       }
-out:
-       spin_unlock(&hb->lock);
-       return ret;
-}
-
-#ifdef CONFIG_RAMSTER
-/*
- * For ramster only:  The following routines provide a two-step sequence
- * to allow the caller to replace a pampd in the tmem data structures with
- * another pampd. Here, we lookup the passed handle and, if found, return the
- * associated pampd and object, leaving the hashbucket locked and returning
- * a reference to it.  The caller is expected to immediately call the
- * matching tmem_localify_finish routine which will handles the replacement
- * and unlocks the hashbucket.
- */
-void *tmem_localify_get_pampd(struct tmem_pool *pool, struct tmem_oid *oidp,
-                               uint32_t index, struct tmem_obj **ret_obj,
-                               void **saved_hb)
-{
-       struct tmem_hashbucket *hb;
-       struct tmem_obj *obj = NULL;
-       void *pampd = NULL;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = tmem_obj_find(hb, oidp);
-       if (likely(obj != NULL))
-               pampd = tmem_pampd_lookup_in_obj(obj, index);
-       *ret_obj = obj;
-       *saved_hb = (void *)hb;
-       /* note, hashbucket remains locked */
-       return pampd;
-}
-
-void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
-                         void *pampd, void *saved_hb, bool delete)
-{
-       struct tmem_hashbucket *hb = (struct tmem_hashbucket *)saved_hb;
-
-       BUG_ON(!spin_is_locked(&hb->lock));
-       if (pampd != NULL) {
-               BUG_ON(obj == NULL);
-               (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
-               (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
-       } else if (delete) {
-               BUG_ON(obj == NULL);
-               (void)tmem_pampd_delete_from_obj(obj, index);
-       }
-       spin_unlock(&hb->lock);
-}
-
-/*
- * For ramster only.  Helper function to support asynchronous tmem_get.
- */
-static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
-                               struct tmem_pool *pool, struct tmem_oid *oidp,
-                               uint32_t index, bool free, char *data)
-{
-       void *old_pampd = *ppampd, *new_pampd = NULL;
-       bool intransit = false;
-       int ret = 0;
-
-       if (!is_ephemeral(pool))
-               new_pampd = (*tmem_pamops.repatriate_preload)(
-                               old_pampd, pool, oidp, index, &intransit);
-       if (intransit)
-               ret = -EAGAIN;
-       else if (new_pampd != NULL)
-               *ppampd = new_pampd;
-       /* must release the hb->lock else repatriate can't sleep */
-       spin_unlock(&hb->lock);
-       if (!intransit)
-               ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
-                                               oidp, index, free, data);
-       if (ret == -EAGAIN) {
-               /* rare I think, but should cond_resched()??? */
-               usleep_range(10, 1000);
-       } else if (ret == -ENOTCONN || ret == -EHOSTDOWN) {
-               ret = -1;
-       } else if (ret != 0 && ret != -ENOENT) {
-               ret = -1;
-       }
-       /* note hb->lock has now been unlocked */
-       return ret;
-}
-
-/*
- * For ramster only.  If a page in tmem matches the handle, replace the
- * page so that any subsequent "get" gets the new page.  Returns 0 if
- * there was a page to replace, else returns -1.
- */
-int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
-                       uint32_t index, void *new_pampd)
-{
-       struct tmem_obj *obj;
-       int ret = -1;
-       struct tmem_hashbucket *hb;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = tmem_obj_find(hb, oidp);
-       if (obj == NULL)
-               goto out;
-       new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
-       /* if we bug here, pamops wasn't properly set up for ramster */
-       BUG_ON(tmem_pamops.replace_in_obj == NULL);
-       ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
-out:
-       spin_unlock(&hb->lock);
-       return ret;
-}
-#endif
-
-/*
- * "Get" a page, e.g. if a pampd can be found matching the passed handle,
- * use a pamops callback to recreated the page from the pampd with the
- * matching handle.  By tmem definition, when a "get" is successful on
- * an ephemeral page, the page is "flushed", and when a "get" is successful
- * on a persistent page, the page is retained in tmem.  Note that to preserve
- * coherency, "get" can never be skipped if tmem contains the data.
- * That is, if a get is done with a certain handle and fails, any
- * subsequent "get" must also fail (unless of course there is a
- * "put" done with the same handle).
- */
-int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
-               char *data, size_t *sizep, bool raw, int get_and_free)
-{
-       struct tmem_obj *obj;
-       void *pampd = NULL;
-       bool ephemeral = is_ephemeral(pool);
-       int ret = -1;
-       struct tmem_hashbucket *hb;
-       bool free = (get_and_free == 1) || ((get_and_free == 0) && ephemeral);
-       bool lock_held = false;
-       void **ppampd;
-
-       do {
-               hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-               spin_lock(&hb->lock);
-               lock_held = true;
-               obj = tmem_obj_find(hb, oidp);
-               if (obj == NULL)
-                       goto out;
-               ppampd = __tmem_pampd_lookup_in_obj(obj, index);
-               if (ppampd == NULL)
-                       goto out;
-#ifdef CONFIG_RAMSTER
-               if ((tmem_pamops.is_remote != NULL) &&
-                    tmem_pamops.is_remote(*ppampd)) {
-                       ret = tmem_repatriate(ppampd, hb, pool, oidp,
-                                               index, free, data);
-                       /* tmem_repatriate releases hb->lock */
-                       lock_held = false;
-                       *sizep = PAGE_SIZE;
-                       if (ret != -EAGAIN)
-                               goto out;
-               }
-#endif
-       } while (ret == -EAGAIN);
-       if (free)
-               pampd = tmem_pampd_delete_from_obj(obj, index);
-       else
-               pampd = tmem_pampd_lookup_in_obj(obj, index);
-       if (pampd == NULL)
-               goto out;
-       if (free) {
-               if (obj->pampd_count == 0) {
-                       tmem_obj_free(obj, hb);
-                       (*tmem_hostops.obj_free)(obj, pool);
-                       obj = NULL;
-               }
-       }
-       if (free)
-               ret = (*tmem_pamops.get_data_and_free)(
-                               data, sizep, raw, pampd, pool, oidp, index);
-       else
-               ret = (*tmem_pamops.get_data)(
-                               data, sizep, raw, pampd, pool, oidp, index);
-       if (ret < 0)
-               goto out;
-       ret = 0;
-out:
-       if (lock_held)
-               spin_unlock(&hb->lock);
-       return ret;
-}
-
-/*
- * If a page in tmem matches the handle, "flush" this page from tmem such
- * that any subsequent "get" does not succeed (unless, of course, there
- * was another "put" with the same handle).
- */
-int tmem_flush_page(struct tmem_pool *pool,
-                               struct tmem_oid *oidp, uint32_t index)
-{
-       struct tmem_obj *obj;
-       void *pampd;
-       int ret = -1;
-       struct tmem_hashbucket *hb;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = tmem_obj_find(hb, oidp);
-       if (obj == NULL)
-               goto out;
-       pampd = tmem_pampd_delete_from_obj(obj, index);
-       if (pampd == NULL)
-               goto out;
-       (*tmem_pamops.free)(pampd, pool, oidp, index, true);
-       if (obj->pampd_count == 0) {
-               tmem_obj_free(obj, hb);
-               (*tmem_hostops.obj_free)(obj, pool);
-       }
-       ret = 0;
-
-out:
-       spin_unlock(&hb->lock);
-       return ret;
-}
-
-/*
- * "Flush" all pages in tmem matching this oid.
- */
-int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
-{
-       struct tmem_obj *obj;
-       struct tmem_hashbucket *hb;
-       int ret = -1;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = tmem_obj_find(hb, oidp);
-       if (obj == NULL)
-               goto out;
-       tmem_pampd_destroy_all_in_obj(obj, false);
-       tmem_obj_free(obj, hb);
-       (*tmem_hostops.obj_free)(obj, pool);
-       ret = 0;
-
-out:
-       spin_unlock(&hb->lock);
-       return ret;
-}
-
-/*
- * "Flush" all pages (and tmem_objs) from this tmem_pool and disable
- * all subsequent access to this tmem_pool.
- */
-int tmem_destroy_pool(struct tmem_pool *pool)
-{
-       int ret = -1;
-
-       if (pool == NULL)
-               goto out;
-       tmem_pool_flush(pool, 1);
-       ret = 0;
-out:
-       return ret;
-}
-
-static LIST_HEAD(tmem_global_pool_list);
-
-/*
- * Create a new tmem_pool with the provided flag and return
- * a pool id provided by the tmem host implementation.
- */
-void tmem_new_pool(struct tmem_pool *pool, uint32_t flags)
-{
-       int persistent = flags & TMEM_POOL_PERSIST;
-       int shared = flags & TMEM_POOL_SHARED;
-       struct tmem_hashbucket *hb = &pool->hashbucket[0];
-       int i;
-
-       for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) {
-               hb->obj_rb_root = RB_ROOT;
-               spin_lock_init(&hb->lock);
-       }
-       INIT_LIST_HEAD(&pool->pool_list);
-       atomic_set(&pool->obj_count, 0);
-       SET_SENTINEL(pool, POOL);
-       list_add_tail(&pool->pool_list, &tmem_global_pool_list);
-       pool->persistent = persistent;
-       pool->shared = shared;
-}
diff --git a/drivers/staging/ramster/tmem.h b/drivers/staging/ramster/tmem.h
deleted file mode 100644 (file)
index adbe5a8..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * tmem.h
- *
- * Transcendent memory
- *
- * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp.
- */
-
-#ifndef _TMEM_H_
-#define _TMEM_H_
-
-#include <linux/types.h>
-#include <linux/highmem.h>
-#include <linux/hash.h>
-#include <linux/atomic.h>
-
-/*
- * These are defined by the Xen<->Linux ABI so should remain consistent
- */
-#define TMEM_POOL_PERSIST              1
-#define TMEM_POOL_SHARED               2
-#define TMEM_POOL_PRECOMPRESSED                4
-#define TMEM_POOL_PAGESIZE_SHIFT       4
-#define TMEM_POOL_PAGESIZE_MASK                0xf
-#define TMEM_POOL_RESERVED_BITS                0x00ffff00
-
-/*
- * sentinels have proven very useful for debugging but can be removed
- * or disabled before final merge.
- */
-#undef SENTINELS
-#ifdef SENTINELS
-#define DECL_SENTINEL uint32_t sentinel;
-#define SET_SENTINEL(_x, _y) (_x->sentinel = _y##_SENTINEL)
-#define INVERT_SENTINEL(_x, _y) (_x->sentinel = ~_y##_SENTINEL)
-#define ASSERT_SENTINEL(_x, _y) WARN_ON(_x->sentinel != _y##_SENTINEL)
-#define ASSERT_INVERTED_SENTINEL(_x, _y) WARN_ON(_x->sentinel != ~_y##_SENTINEL)
-#else
-#define DECL_SENTINEL
-#define SET_SENTINEL(_x, _y) do { } while (0)
-#define INVERT_SENTINEL(_x, _y) do { } while (0)
-#define ASSERT_SENTINEL(_x, _y) do { } while (0)
-#define ASSERT_INVERTED_SENTINEL(_x, _y) do { } while (0)
-#endif
-
-#define ASSERT_SPINLOCK(_l)    lockdep_assert_held(_l)
-
-/*
- * A pool is the highest-level data structure managed by tmem and
- * usually corresponds to a large independent set of pages such as
- * a filesystem.  Each pool has an id, and certain attributes and counters.
- * It also contains a set of hash buckets, each of which contains an rbtree
- * of objects and a lock to manage concurrency within the pool.
- */
-
-#define TMEM_HASH_BUCKET_BITS  8
-#define TMEM_HASH_BUCKETS      (1<<TMEM_HASH_BUCKET_BITS)
-
-struct tmem_hashbucket {
-       struct rb_root obj_rb_root;
-       spinlock_t lock;
-};
-
-struct tmem_pool {
-       void *client; /* "up" for some clients, avoids table lookup */
-       struct list_head pool_list;
-       uint32_t pool_id;
-       bool persistent;
-       bool shared;
-       atomic_t obj_count;
-       atomic_t refcount;
-       struct tmem_hashbucket hashbucket[TMEM_HASH_BUCKETS];
-       DECL_SENTINEL
-};
-
-#define is_persistent(_p)  (_p->persistent)
-#define is_ephemeral(_p)   (!(_p->persistent))
-
-/*
- * An object id ("oid") is large: 192-bits (to ensure, for example, files
- * in a modern filesystem can be uniquely identified).
- */
-
-struct tmem_oid {
-       uint64_t oid[3];
-};
-
-static inline void tmem_oid_set_invalid(struct tmem_oid *oidp)
-{
-       oidp->oid[0] = oidp->oid[1] = oidp->oid[2] = -1UL;
-}
-
-static inline bool tmem_oid_valid(struct tmem_oid *oidp)
-{
-       return oidp->oid[0] != -1UL || oidp->oid[1] != -1UL ||
-               oidp->oid[2] != -1UL;
-}
-
-static inline int tmem_oid_compare(struct tmem_oid *left,
-                                       struct tmem_oid *right)
-{
-       int ret;
-
-       if (left->oid[2] == right->oid[2]) {
-               if (left->oid[1] == right->oid[1]) {
-                       if (left->oid[0] == right->oid[0])
-                               ret = 0;
-                       else if (left->oid[0] < right->oid[0])
-                               ret = -1;
-                       else
-                               return 1;
-               } else if (left->oid[1] < right->oid[1])
-                       ret = -1;
-               else
-                       ret = 1;
-       } else if (left->oid[2] < right->oid[2])
-               ret = -1;
-       else
-               ret = 1;
-       return ret;
-}
-
-static inline unsigned tmem_oid_hash(struct tmem_oid *oidp)
-{
-       return hash_long(oidp->oid[0] ^ oidp->oid[1] ^ oidp->oid[2],
-                               TMEM_HASH_BUCKET_BITS);
-}
-
-#ifdef CONFIG_RAMSTER
-struct tmem_xhandle {
-       uint8_t client_id;
-       uint8_t xh_data_cksum;
-       uint16_t xh_data_size;
-       uint16_t pool_id;
-       struct tmem_oid oid;
-       uint32_t index;
-       void *extra;
-};
-
-static inline struct tmem_xhandle tmem_xhandle_fill(uint16_t client_id,
-                                       struct tmem_pool *pool,
-                                       struct tmem_oid *oidp,
-                                       uint32_t index)
-{
-       struct tmem_xhandle xh;
-       xh.client_id = client_id;
-       xh.xh_data_cksum = (uint8_t)-1;
-       xh.xh_data_size = (uint16_t)-1;
-       xh.pool_id = pool->pool_id;
-       xh.oid = *oidp;
-       xh.index = index;
-       return xh;
-}
-#endif
-
-
-/*
- * A tmem_obj contains an identifier (oid), pointers to the parent
- * pool and the rb_tree to which it belongs, counters, and an ordered
- * set of pampds, structured in a radix-tree-like tree.  The intermediate
- * nodes of the tree are called tmem_objnodes.
- */
-
-struct tmem_objnode;
-
-struct tmem_obj {
-       struct tmem_oid oid;
-       struct tmem_pool *pool;
-       struct rb_node rb_tree_node;
-       struct tmem_objnode *objnode_tree_root;
-       unsigned int objnode_tree_height;
-       unsigned long objnode_count;
-       long pampd_count;
-#ifdef CONFIG_RAMSTER
-       /*
-        * for current design of ramster, all pages belonging to
-        * an object reside on the same remotenode and extra is
-        * used to record the number of the remotenode so a
-        * flush-object operation can specify it
-        */
-       void *extra; /* for private use by pampd implementation */
-#endif
-       DECL_SENTINEL
-};
-
-#define OBJNODE_TREE_MAP_SHIFT 6
-#define OBJNODE_TREE_MAP_SIZE (1UL << OBJNODE_TREE_MAP_SHIFT)
-#define OBJNODE_TREE_MAP_MASK (OBJNODE_TREE_MAP_SIZE-1)
-#define OBJNODE_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long))
-#define OBJNODE_TREE_MAX_PATH \
-               (OBJNODE_TREE_INDEX_BITS/OBJNODE_TREE_MAP_SHIFT + 2)
-
-struct tmem_objnode {
-       struct tmem_obj *obj;
-       DECL_SENTINEL
-       void *slots[OBJNODE_TREE_MAP_SIZE];
-       unsigned int slots_in_use;
-};
-
-struct tmem_handle {
-       struct tmem_oid oid; /* 24 bytes */
-       uint32_t index;
-       uint16_t pool_id;
-       uint16_t client_id;
-};
-
-
-/* pampd abstract datatype methods provided by the PAM implementation */
-struct tmem_pamops {
-       void (*create_finish)(void *, bool);
-       int (*get_data)(char *, size_t *, bool, void *, struct tmem_pool *,
-                               struct tmem_oid *, uint32_t);
-       int (*get_data_and_free)(char *, size_t *, bool, void *,
-                               struct tmem_pool *, struct tmem_oid *,
-                               uint32_t);
-       void (*free)(void *, struct tmem_pool *,
-                               struct tmem_oid *, uint32_t, bool);
-#ifdef CONFIG_RAMSTER
-       void (*new_obj)(struct tmem_obj *);
-       void (*free_obj)(struct tmem_pool *, struct tmem_obj *, bool);
-       void *(*repatriate_preload)(void *, struct tmem_pool *,
-                                       struct tmem_oid *, uint32_t, bool *);
-       int (*repatriate)(void *, void *, struct tmem_pool *,
-                               struct tmem_oid *, uint32_t, bool, void *);
-       bool (*is_remote)(void *);
-       int (*replace_in_obj)(void *, struct tmem_obj *);
-#endif
-};
-extern void tmem_register_pamops(struct tmem_pamops *m);
-
-/* memory allocation methods provided by the host implementation */
-struct tmem_hostops {
-       struct tmem_obj *(*obj_alloc)(struct tmem_pool *);
-       void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
-       struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
-       void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
-};
-extern void tmem_register_hostops(struct tmem_hostops *m);
-
-/* core tmem accessor functions */
-extern int tmem_put(struct tmem_pool *, struct tmem_oid *, uint32_t index,
-                       bool, void *);
-extern int tmem_get(struct tmem_pool *, struct tmem_oid *, uint32_t index,
-                       char *, size_t *, bool, int);
-extern int tmem_flush_page(struct tmem_pool *, struct tmem_oid *,
-                       uint32_t index);
-extern int tmem_flush_object(struct tmem_pool *, struct tmem_oid *);
-extern int tmem_destroy_pool(struct tmem_pool *);
-extern void tmem_new_pool(struct tmem_pool *, uint32_t);
-#ifdef CONFIG_RAMSTER
-extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index,
-                       void *);
-extern void *tmem_localify_get_pampd(struct tmem_pool *, struct tmem_oid *,
-                                  uint32_t index, struct tmem_obj **,
-                                  void **);
-extern void tmem_localify_finish(struct tmem_obj *, uint32_t index,
-                                void *, void *, bool);
-#endif
-#endif /* _TMEM_H */
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
deleted file mode 100644 (file)
index a09dd5c..0000000
+++ /dev/null
@@ -1,1820 +0,0 @@
-/*
- * zcache.c
- *
- * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp.
- * Copyright (c) 2010,2011, Nitin Gupta
- *
- * Zcache provides an in-kernel "host implementation" for transcendent memory
- * ("tmem") and, thus indirectly, for cleancache and frontswap.  Zcache uses
- * lzo1x compression to improve density and an embedded allocator called
- * "zbud" which "buddies" two compressed pages semi-optimally in each physical
- * pageframe.  Zbud is integrally tied into tmem to allow pageframes to
- * be "reclaimed" efficiently.
- */
-
-#include <linux/module.h>
-#include <linux/cpu.h>
-#include <linux/highmem.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/types.h>
-#include <linux/atomic.h>
-#include <linux/math64.h>
-#include <linux/crypto.h>
-
-#include <linux/cleancache.h>
-#include <linux/frontswap.h>
-#include "tmem.h"
-#include "zcache.h"
-#include "zbud.h"
-#include "ramster.h"
-#ifdef CONFIG_RAMSTER
-static int ramster_enabled;
-#else
-#define ramster_enabled 0
-#endif
-
-#ifndef __PG_WAS_ACTIVE
-static inline bool PageWasActive(struct page *page)
-{
-       return true;
-}
-
-static inline void SetPageWasActive(struct page *page)
-{
-}
-#endif
-
-#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS
-static bool frontswap_has_exclusive_gets __read_mostly = true;
-#else
-static bool frontswap_has_exclusive_gets __read_mostly;
-static inline void frontswap_tmem_exclusive_gets(bool b)
-{
-}
-#endif
-
-static int zcache_enabled __read_mostly;
-static int disable_cleancache __read_mostly;
-static int disable_frontswap __read_mostly;
-static int disable_frontswap_ignore_nonactive __read_mostly;
-static int disable_cleancache_ignore_nonactive __read_mostly;
-static char *namestr __read_mostly = "zcache";
-
-#define ZCACHE_GFP_MASK \
-       (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC)
-
-MODULE_LICENSE("GPL");
-
-/* crypto API for zcache  */
-#define ZCACHE_COMP_NAME_SZ CRYPTO_MAX_ALG_NAME
-static char zcache_comp_name[ZCACHE_COMP_NAME_SZ] __read_mostly;
-static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms __read_mostly;
-
-enum comp_op {
-       ZCACHE_COMPOP_COMPRESS,
-       ZCACHE_COMPOP_DECOMPRESS
-};
-
-static inline int zcache_comp_op(enum comp_op op,
-                               const u8 *src, unsigned int slen,
-                               u8 *dst, unsigned int *dlen)
-{
-       struct crypto_comp *tfm;
-       int ret = -1;
-
-       BUG_ON(!zcache_comp_pcpu_tfms);
-       tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu());
-       BUG_ON(!tfm);
-       switch (op) {
-       case ZCACHE_COMPOP_COMPRESS:
-               ret = crypto_comp_compress(tfm, src, slen, dst, dlen);
-               break;
-       case ZCACHE_COMPOP_DECOMPRESS:
-               ret = crypto_comp_decompress(tfm, src, slen, dst, dlen);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-       put_cpu();
-       return ret;
-}
-
-/*
- * policy parameters
- */
-
-/*
- * byte count defining poor compression; pages with greater zsize will be
- * rejected
- */
-static unsigned int zbud_max_zsize __read_mostly = (PAGE_SIZE / 8) * 7;
-/*
- * byte count defining poor *mean* compression; pages with greater zsize
- * will be rejected until sufficient better-compressed pages are accepted
- * driving the mean below this threshold
- */
-static unsigned int zbud_max_mean_zsize __read_mostly = (PAGE_SIZE / 8) * 5;
-
-/*
- * for now, used named slabs so can easily track usage; later can
- * either just use kmalloc, or perhaps add a slab-like allocator
- * to more carefully manage total memory utilization
- */
-static struct kmem_cache *zcache_objnode_cache;
-static struct kmem_cache *zcache_obj_cache;
-
-static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
-
-/* we try to keep these statistics SMP-consistent */
-static long zcache_obj_count;
-static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
-static long zcache_obj_count_max;
-static long zcache_objnode_count;
-static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
-static long zcache_objnode_count_max;
-static u64 zcache_eph_zbytes;
-static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
-static u64 zcache_eph_zbytes_max;
-static u64 zcache_pers_zbytes;
-static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
-static u64 zcache_pers_zbytes_max;
-static long zcache_eph_pageframes;
-static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
-static long zcache_eph_pageframes_max;
-static long zcache_pers_pageframes;
-static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
-static long zcache_pers_pageframes_max;
-static long zcache_pageframes_alloced;
-static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
-static long zcache_pageframes_freed;
-static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
-static long zcache_eph_zpages;
-static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
-static long zcache_eph_zpages_max;
-static long zcache_pers_zpages;
-static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
-static long zcache_pers_zpages_max;
-
-/* but for the rest of these, counting races are ok */
-static unsigned long zcache_flush_total;
-static unsigned long zcache_flush_found;
-static unsigned long zcache_flobj_total;
-static unsigned long zcache_flobj_found;
-static unsigned long zcache_failed_eph_puts;
-static unsigned long zcache_failed_pers_puts;
-static unsigned long zcache_failed_getfreepages;
-static unsigned long zcache_failed_alloc;
-static unsigned long zcache_put_to_flush;
-static unsigned long zcache_compress_poor;
-static unsigned long zcache_mean_compress_poor;
-static unsigned long zcache_eph_ate_tail;
-static unsigned long zcache_eph_ate_tail_failed;
-static unsigned long zcache_pers_ate_eph;
-static unsigned long zcache_pers_ate_eph_failed;
-static unsigned long zcache_evicted_eph_zpages;
-static unsigned long zcache_evicted_eph_pageframes;
-static unsigned long zcache_last_active_file_pageframes;
-static unsigned long zcache_last_inactive_file_pageframes;
-static unsigned long zcache_last_active_anon_pageframes;
-static unsigned long zcache_last_inactive_anon_pageframes;
-static unsigned long zcache_eph_nonactive_puts_ignored;
-static unsigned long zcache_pers_nonactive_puts_ignored;
-
-#ifdef CONFIG_DEBUG_FS
-#include <linux/debugfs.h>
-#define        zdfs    debugfs_create_size_t
-#define        zdfs64  debugfs_create_u64
-static int zcache_debugfs_init(void)
-{
-       struct dentry *root = debugfs_create_dir("zcache", NULL);
-       if (root == NULL)
-               return -ENXIO;
-
-       zdfs("obj_count", S_IRUGO, root, &zcache_obj_count);
-       zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max);
-       zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count);
-       zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max);
-       zdfs("flush_total", S_IRUGO, root, &zcache_flush_total);
-       zdfs("flush_found", S_IRUGO, root, &zcache_flush_found);
-       zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total);
-       zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found);
-       zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts);
-       zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts);
-       zdfs("failed_get_free_pages", S_IRUGO, root,
-                               &zcache_failed_getfreepages);
-       zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc);
-       zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush);
-       zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor);
-       zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor);
-       zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail);
-       zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed);
-       zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph);
-       zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed);
-       zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages);
-       zdfs("evicted_eph_pageframes", S_IRUGO, root,
-                               &zcache_evicted_eph_pageframes);
-       zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes);
-       zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max);
-       zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes);
-       zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max);
-       zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages);
-       zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max);
-       zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages);
-       zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max);
-       zdfs("last_active_file_pageframes", S_IRUGO, root,
-                               &zcache_last_active_file_pageframes);
-       zdfs("last_inactive_file_pageframes", S_IRUGO, root,
-                               &zcache_last_inactive_file_pageframes);
-       zdfs("last_active_anon_pageframes", S_IRUGO, root,
-                               &zcache_last_active_anon_pageframes);
-       zdfs("last_inactive_anon_pageframes", S_IRUGO, root,
-                               &zcache_last_inactive_anon_pageframes);
-       zdfs("eph_nonactive_puts_ignored", S_IRUGO, root,
-                               &zcache_eph_nonactive_puts_ignored);
-       zdfs("pers_nonactive_puts_ignored", S_IRUGO, root,
-                               &zcache_pers_nonactive_puts_ignored);
-       zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
-       zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
-       zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
-       zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
-       return 0;
-}
-#undef zdebugfs
-#undef zdfs64
-#endif
-
-#define ZCACHE_DEBUG
-#ifdef ZCACHE_DEBUG
-/* developers can call this in case of ooms, e.g. to find memory leaks */
-void zcache_dump(void)
-{
-       pr_info("zcache: obj_count=%lu\n", zcache_obj_count);
-       pr_info("zcache: obj_count_max=%lu\n", zcache_obj_count_max);
-       pr_info("zcache: objnode_count=%lu\n", zcache_objnode_count);
-       pr_info("zcache: objnode_count_max=%lu\n", zcache_objnode_count_max);
-       pr_info("zcache: flush_total=%lu\n", zcache_flush_total);
-       pr_info("zcache: flush_found=%lu\n", zcache_flush_found);
-       pr_info("zcache: flobj_total=%lu\n", zcache_flobj_total);
-       pr_info("zcache: flobj_found=%lu\n", zcache_flobj_found);
-       pr_info("zcache: failed_eph_puts=%lu\n", zcache_failed_eph_puts);
-       pr_info("zcache: failed_pers_puts=%lu\n", zcache_failed_pers_puts);
-       pr_info("zcache: failed_get_free_pages=%lu\n",
-                               zcache_failed_getfreepages);
-       pr_info("zcache: failed_alloc=%lu\n", zcache_failed_alloc);
-       pr_info("zcache: put_to_flush=%lu\n", zcache_put_to_flush);
-       pr_info("zcache: compress_poor=%lu\n", zcache_compress_poor);
-       pr_info("zcache: mean_compress_poor=%lu\n",
-                               zcache_mean_compress_poor);
-       pr_info("zcache: eph_ate_tail=%lu\n", zcache_eph_ate_tail);
-       pr_info("zcache: eph_ate_tail_failed=%lu\n",
-                               zcache_eph_ate_tail_failed);
-       pr_info("zcache: pers_ate_eph=%lu\n", zcache_pers_ate_eph);
-       pr_info("zcache: pers_ate_eph_failed=%lu\n",
-                               zcache_pers_ate_eph_failed);
-       pr_info("zcache: evicted_eph_zpages=%lu\n", zcache_evicted_eph_zpages);
-       pr_info("zcache: evicted_eph_pageframes=%lu\n",
-                               zcache_evicted_eph_pageframes);
-       pr_info("zcache: eph_pageframes=%lu\n", zcache_eph_pageframes);
-       pr_info("zcache: eph_pageframes_max=%lu\n", zcache_eph_pageframes_max);
-       pr_info("zcache: pers_pageframes=%lu\n", zcache_pers_pageframes);
-       pr_info("zcache: pers_pageframes_max=%lu\n",
-                               zcache_pers_pageframes_max);
-       pr_info("zcache: eph_zpages=%lu\n", zcache_eph_zpages);
-       pr_info("zcache: eph_zpages_max=%lu\n", zcache_eph_zpages_max);
-       pr_info("zcache: pers_zpages=%lu\n", zcache_pers_zpages);
-       pr_info("zcache: pers_zpages_max=%lu\n", zcache_pers_zpages_max);
-       pr_info("zcache: eph_zbytes=%llu\n",
-                               (unsigned long long)zcache_eph_zbytes);
-       pr_info("zcache: eph_zbytes_max=%llu\n",
-                               (unsigned long long)zcache_eph_zbytes_max);
-       pr_info("zcache: pers_zbytes=%llu\n",
-                               (unsigned long long)zcache_pers_zbytes);
-       pr_info("zcache: pers_zbytes_max=%llu\n",
-                       (unsigned long long)zcache_pers_zbytes_max);
-}
-#endif
-
-/*
- * zcache core code starts here
- */
-
-static struct zcache_client zcache_host;
-static struct zcache_client zcache_clients[MAX_CLIENTS];
-
-static inline bool is_local_client(struct zcache_client *cli)
-{
-       return cli == &zcache_host;
-}
-
-static struct zcache_client *zcache_get_client_by_id(uint16_t cli_id)
-{
-       struct zcache_client *cli = &zcache_host;
-
-       if (cli_id != LOCAL_CLIENT) {
-               if (cli_id >= MAX_CLIENTS)
-                       goto out;
-               cli = &zcache_clients[cli_id];
-       }
-out:
-       return cli;
-}
-
-/*
- * Tmem operations assume the poolid implies the invoking client.
- * Zcache only has one client (the kernel itself): LOCAL_CLIENT.
- * RAMster has each client numbered by cluster node, and a KVM version
- * of zcache would have one client per guest and each client might
- * have a poolid==N.
- */
-struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid)
-{
-       struct tmem_pool *pool = NULL;
-       struct zcache_client *cli = NULL;
-
-       cli = zcache_get_client_by_id(cli_id);
-       if (cli == NULL)
-               goto out;
-       if (!is_local_client(cli))
-               atomic_inc(&cli->refcount);
-       if (poolid < MAX_POOLS_PER_CLIENT) {
-               pool = cli->tmem_pools[poolid];
-               if (pool != NULL)
-                       atomic_inc(&pool->refcount);
-       }
-out:
-       return pool;
-}
-
-void zcache_put_pool(struct tmem_pool *pool)
-{
-       struct zcache_client *cli = NULL;
-
-       if (pool == NULL)
-               BUG();
-       cli = pool->client;
-       atomic_dec(&pool->refcount);
-       if (!is_local_client(cli))
-               atomic_dec(&cli->refcount);
-}
-
-int zcache_new_client(uint16_t cli_id)
-{
-       struct zcache_client *cli;
-       int ret = -1;
-
-       cli = zcache_get_client_by_id(cli_id);
-       if (cli == NULL)
-               goto out;
-       if (cli->allocated)
-               goto out;
-       cli->allocated = 1;
-       ret = 0;
-out:
-       return ret;
-}
-
-/*
- * zcache implementation for tmem host ops
- */
-
-static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool)
-{
-       struct tmem_objnode *objnode = NULL;
-       struct zcache_preload *kp;
-       int i;
-
-       kp = &__get_cpu_var(zcache_preloads);
-       for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
-               objnode = kp->objnodes[i];
-               if (objnode != NULL) {
-                       kp->objnodes[i] = NULL;
-                       break;
-               }
-       }
-       BUG_ON(objnode == NULL);
-       zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
-       if (zcache_objnode_count > zcache_objnode_count_max)
-               zcache_objnode_count_max = zcache_objnode_count;
-       return objnode;
-}
-
-static void zcache_objnode_free(struct tmem_objnode *objnode,
-                                       struct tmem_pool *pool)
-{
-       zcache_objnode_count =
-               atomic_dec_return(&zcache_objnode_atomic);
-       BUG_ON(zcache_objnode_count < 0);
-       kmem_cache_free(zcache_objnode_cache, objnode);
-}
-
-static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool)
-{
-       struct tmem_obj *obj = NULL;
-       struct zcache_preload *kp;
-
-       kp = &__get_cpu_var(zcache_preloads);
-       obj = kp->obj;
-       BUG_ON(obj == NULL);
-       kp->obj = NULL;
-       zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
-       if (zcache_obj_count > zcache_obj_count_max)
-               zcache_obj_count_max = zcache_obj_count;
-       return obj;
-}
-
-static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
-{
-       zcache_obj_count =
-               atomic_dec_return(&zcache_obj_atomic);
-       BUG_ON(zcache_obj_count < 0);
-       kmem_cache_free(zcache_obj_cache, obj);
-}
-
-static struct tmem_hostops zcache_hostops = {
-       .obj_alloc = zcache_obj_alloc,
-       .obj_free = zcache_obj_free,
-       .objnode_alloc = zcache_objnode_alloc,
-       .objnode_free = zcache_objnode_free,
-};
-
-static struct page *zcache_alloc_page(void)
-{
-       struct page *page = alloc_page(ZCACHE_GFP_MASK);
-
-       if (page != NULL)
-               zcache_pageframes_alloced =
-                       atomic_inc_return(&zcache_pageframes_alloced_atomic);
-       return page;
-}
-
-#ifdef FRONTSWAP_HAS_UNUSE
-static void zcache_unacct_page(void)
-{
-       zcache_pageframes_freed =
-               atomic_inc_return(&zcache_pageframes_freed_atomic);
-}
-#endif
-
-static void zcache_free_page(struct page *page)
-{
-       long curr_pageframes;
-       static long max_pageframes, min_pageframes;
-
-       if (page == NULL)
-               BUG();
-       __free_page(page);
-       zcache_pageframes_freed =
-               atomic_inc_return(&zcache_pageframes_freed_atomic);
-       curr_pageframes = zcache_pageframes_alloced -
-                       atomic_read(&zcache_pageframes_freed_atomic) -
-                       atomic_read(&zcache_eph_pageframes_atomic) -
-                       atomic_read(&zcache_pers_pageframes_atomic);
-       if (curr_pageframes > max_pageframes)
-               max_pageframes = curr_pageframes;
-       if (curr_pageframes < min_pageframes)
-               min_pageframes = curr_pageframes;
-#ifdef ZCACHE_DEBUG
-       if (curr_pageframes > 2L || curr_pageframes < -2L) {
-               /* pr_info here */
-       }
-#endif
-}
-
-/*
- * zcache implementations for PAM page descriptor ops
- */
-
-/* forward reference */
-static void zcache_compress(struct page *from,
-                               void **out_va, unsigned *out_len);
-
-static struct page *zcache_evict_eph_pageframe(void);
-
-static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
-                                       struct tmem_handle *th)
-{
-       void *pampd = NULL, *cdata = data;
-       unsigned clen = size;
-       struct page *page = (struct page *)(data), *newpage;
-
-       if (!raw) {
-               zcache_compress(page, &cdata, &clen);
-               if (clen > zbud_max_buddy_size()) {
-                       zcache_compress_poor++;
-                       goto out;
-               }
-       } else {
-               BUG_ON(clen > zbud_max_buddy_size());
-       }
-
-       /* look for space via an existing match first */
-       pampd = (void *)zbud_match_prep(th, true, cdata, clen);
-       if (pampd != NULL)
-               goto got_pampd;
-
-       /* no match, now we need to find (or free up) a full page */
-       newpage = zcache_alloc_page();
-       if (newpage != NULL)
-               goto create_in_new_page;
-
-       zcache_failed_getfreepages++;
-       /* can't allocate a page, evict an ephemeral page via LRU */
-       newpage = zcache_evict_eph_pageframe();
-       if (newpage == NULL) {
-               zcache_eph_ate_tail_failed++;
-               goto out;
-       }
-       zcache_eph_ate_tail++;
-
-create_in_new_page:
-       pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage);
-       BUG_ON(pampd == NULL);
-       zcache_eph_pageframes =
-               atomic_inc_return(&zcache_eph_pageframes_atomic);
-       if (zcache_eph_pageframes > zcache_eph_pageframes_max)
-               zcache_eph_pageframes_max = zcache_eph_pageframes;
-
-got_pampd:
-       zcache_eph_zbytes =
-               atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
-       if (zcache_eph_zbytes > zcache_eph_zbytes_max)
-               zcache_eph_zbytes_max = zcache_eph_zbytes;
-       zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
-       if (zcache_eph_zpages > zcache_eph_zpages_max)
-               zcache_eph_zpages_max = zcache_eph_zpages;
-       if (ramster_enabled && raw)
-               ramster_count_foreign_pages(true, 1);
-out:
-       return pampd;
-}
-
-static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
-                                       struct tmem_handle *th)
-{
-       void *pampd = NULL, *cdata = data;
-       unsigned clen = size;
-       struct page *page = (struct page *)(data), *newpage;
-       unsigned long zbud_mean_zsize;
-       unsigned long curr_pers_zpages, total_zsize;
-
-       if (data == NULL) {
-               BUG_ON(!ramster_enabled);
-               goto create_pampd;
-       }
-       curr_pers_zpages = zcache_pers_zpages;
-/* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */
-       if (!raw)
-               zcache_compress(page, &cdata, &clen);
-       /* reject if compression is too poor */
-       if (clen > zbud_max_zsize) {
-               zcache_compress_poor++;
-               goto out;
-       }
-       /* reject if mean compression is too poor */
-       if ((clen > zbud_max_mean_zsize) && (curr_pers_zpages > 0)) {
-               total_zsize = zcache_pers_zbytes;
-               if ((long)total_zsize < 0)
-                       total_zsize = 0;
-               zbud_mean_zsize = div_u64(total_zsize,
-                                       curr_pers_zpages);
-               if (zbud_mean_zsize > zbud_max_mean_zsize) {
-                       zcache_mean_compress_poor++;
-                       goto out;
-               }
-       }
-
-create_pampd:
-       /* look for space via an existing match first */
-       pampd = (void *)zbud_match_prep(th, false, cdata, clen);
-       if (pampd != NULL)
-               goto got_pampd;
-
-       /* no match, now we need to find (or free up) a full page */
-       newpage = zcache_alloc_page();
-       if (newpage != NULL)
-               goto create_in_new_page;
-       /*
-        * FIXME do the following only if eph is oversized?
-        * if (zcache_eph_pageframes >
-        * (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) +
-        * global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE)))
-        */
-       zcache_failed_getfreepages++;
-       /* can't allocate a page, evict an ephemeral page via LRU */
-       newpage = zcache_evict_eph_pageframe();
-       if (newpage == NULL) {
-               zcache_pers_ate_eph_failed++;
-               goto out;
-       }
-       zcache_pers_ate_eph++;
-
-create_in_new_page:
-       pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage);
-       BUG_ON(pampd == NULL);
-       zcache_pers_pageframes =
-               atomic_inc_return(&zcache_pers_pageframes_atomic);
-       if (zcache_pers_pageframes > zcache_pers_pageframes_max)
-               zcache_pers_pageframes_max = zcache_pers_pageframes;
-
-got_pampd:
-       zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
-       if (zcache_pers_zpages > zcache_pers_zpages_max)
-               zcache_pers_zpages_max = zcache_pers_zpages;
-       zcache_pers_zbytes =
-               atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
-       if (zcache_pers_zbytes > zcache_pers_zbytes_max)
-               zcache_pers_zbytes_max = zcache_pers_zbytes;
-       if (ramster_enabled && raw)
-               ramster_count_foreign_pages(false, 1);
-out:
-       return pampd;
-}
-
-/*
- * This is called directly from zcache_put_page to pre-allocate space
- * to store a zpage.
- */
-void *zcache_pampd_create(char *data, unsigned int size, bool raw,
-                                       int eph, struct tmem_handle *th)
-{
-       void *pampd = NULL;
-       struct zcache_preload *kp;
-       struct tmem_objnode *objnode;
-       struct tmem_obj *obj;
-       int i;
-
-       BUG_ON(!irqs_disabled());
-       /* pre-allocate per-cpu metadata */
-       BUG_ON(zcache_objnode_cache == NULL);
-       BUG_ON(zcache_obj_cache == NULL);
-       kp = &__get_cpu_var(zcache_preloads);
-       for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
-               objnode = kp->objnodes[i];
-               if (objnode == NULL) {
-                       objnode = kmem_cache_alloc(zcache_objnode_cache,
-                                                       ZCACHE_GFP_MASK);
-                       if (unlikely(objnode == NULL)) {
-                               zcache_failed_alloc++;
-                               goto out;
-                       }
-                       kp->objnodes[i] = objnode;
-               }
-       }
-       if (kp->obj == NULL) {
-               obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
-               kp->obj = obj;
-       }
-       if (unlikely(kp->obj == NULL)) {
-               zcache_failed_alloc++;
-               goto out;
-       }
-       /*
-        * ok, have all the metadata pre-allocated, now do the data
-        * but since how we allocate the data is dependent on ephemeral
-        * or persistent, we split the call here to different sub-functions
-        */
-       if (eph)
-               pampd = zcache_pampd_eph_create(data, size, raw, th);
-       else
-               pampd = zcache_pampd_pers_create(data, size, raw, th);
-out:
-       return pampd;
-}
-
-/*
- * This is a pamops called via tmem_put and is necessary to "finish"
- * a pampd creation.
- */
-void zcache_pampd_create_finish(void *pampd, bool eph)
-{
-       zbud_create_finish((struct zbudref *)pampd, eph);
-}
-
-/*
- * This is passed as a function parameter to zbud_decompress so that
- * zbud need not be familiar with the details of crypto. It assumes that
- * the bytes from_va and to_va through from_va+size-1 and to_va+size-1 are
- * kmapped.  It must be successful, else there is a logic bug somewhere.
- */
-static void zcache_decompress(char *from_va, unsigned int size, char *to_va)
-{
-       int ret;
-       unsigned int outlen = PAGE_SIZE;
-
-       ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size,
-                               to_va, &outlen);
-       BUG_ON(ret);
-       BUG_ON(outlen != PAGE_SIZE);
-}
-
-/*
- * Decompress from the kernel va to a pageframe
- */
-void zcache_decompress_to_page(char *from_va, unsigned int size,
-                                       struct page *to_page)
-{
-       char *to_va = kmap_atomic(to_page);
-       zcache_decompress(from_va, size, to_va);
-       kunmap_atomic(to_va);
-}
-
-/*
- * fill the pageframe corresponding to the struct page with the data
- * from the passed pampd
- */
-static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw,
-                                       void *pampd, struct tmem_pool *pool,
-                                       struct tmem_oid *oid, uint32_t index)
-{
-       int ret;
-       bool eph = !is_persistent(pool);
-
-       BUG_ON(preemptible());
-       BUG_ON(eph);    /* fix later if shared pools get implemented */
-       BUG_ON(pampd_is_remote(pampd));
-       if (raw)
-               ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd,
-                                               sizep, eph);
-       else {
-               ret = zbud_decompress((struct page *)(data),
-                                       (struct zbudref *)pampd, false,
-                                       zcache_decompress);
-               *sizep = PAGE_SIZE;
-       }
-       return ret;
-}
-
-/*
- * fill the pageframe corresponding to the struct page with the data
- * from the passed pampd
- */
-static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
-                                       void *pampd, struct tmem_pool *pool,
-                                       struct tmem_oid *oid, uint32_t index)
-{
-       int ret;
-       bool eph = !is_persistent(pool);
-       struct page *page = NULL;
-       unsigned int zsize, zpages;
-
-       BUG_ON(preemptible());
-       BUG_ON(pampd_is_remote(pampd));
-       if (raw)
-               ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd,
-                                               sizep, eph);
-       else {
-               ret = zbud_decompress((struct page *)(data),
-                                       (struct zbudref *)pampd, eph,
-                                       zcache_decompress);
-               *sizep = PAGE_SIZE;
-       }
-       page = zbud_free_and_delist((struct zbudref *)pampd, eph,
-                                       &zsize, &zpages);
-       if (eph) {
-               if (page)
-                       zcache_eph_pageframes =
-                           atomic_dec_return(&zcache_eph_pageframes_atomic);
-               zcache_eph_zpages =
-                   atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
-               zcache_eph_zbytes =
-                   atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
-       } else {
-               if (page)
-                       zcache_pers_pageframes =
-                           atomic_dec_return(&zcache_pers_pageframes_atomic);
-               zcache_pers_zpages =
-                   atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
-               zcache_pers_zbytes =
-                   atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
-       }
-       if (!is_local_client(pool->client))
-               ramster_count_foreign_pages(eph, -1);
-       if (page)
-               zcache_free_page(page);
-       return ret;
-}
-
-/*
- * free the pampd and remove it from any zcache lists
- * pampd must no longer be pointed to from any tmem data structures!
- */
-static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
-                             struct tmem_oid *oid, uint32_t index, bool acct)
-{
-       struct page *page = NULL;
-       unsigned int zsize, zpages;
-
-       BUG_ON(preemptible());
-       if (pampd_is_remote(pampd)) {
-               BUG_ON(!ramster_enabled);
-               pampd = ramster_pampd_free(pampd, pool, oid, index, acct);
-               if (pampd == NULL)
-                       return;
-       }
-       if (is_ephemeral(pool)) {
-               page = zbud_free_and_delist((struct zbudref *)pampd,
-                                               true, &zsize, &zpages);
-               if (page)
-                       zcache_eph_pageframes =
-                           atomic_dec_return(&zcache_eph_pageframes_atomic);
-               zcache_eph_zpages =
-                   atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
-               zcache_eph_zbytes =
-                   atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
-               /* FIXME CONFIG_RAMSTER... check acct parameter? */
-       } else {
-               page = zbud_free_and_delist((struct zbudref *)pampd,
-                                               false, &zsize, &zpages);
-               if (page)
-                       zcache_pers_pageframes =
-                           atomic_dec_return(&zcache_pers_pageframes_atomic);
-               zcache_pers_zpages =
-                    atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
-               zcache_pers_zbytes =
-                   atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
-       }
-       if (!is_local_client(pool->client))
-               ramster_count_foreign_pages(is_ephemeral(pool), -1);
-       if (page)
-               zcache_free_page(page);
-}
-
-static struct tmem_pamops zcache_pamops = {
-       .create_finish = zcache_pampd_create_finish,
-       .get_data = zcache_pampd_get_data,
-       .get_data_and_free = zcache_pampd_get_data_and_free,
-       .free = zcache_pampd_free,
-};
-
-/*
- * zcache compression/decompression and related per-cpu stuff
- */
-
-static DEFINE_PER_CPU(unsigned char *, zcache_dstmem);
-#define ZCACHE_DSTMEM_ORDER 1
-
-static void zcache_compress(struct page *from, void **out_va, unsigned *out_len)
-{
-       int ret;
-       unsigned char *dmem = __get_cpu_var(zcache_dstmem);
-       char *from_va;
-
-       BUG_ON(!irqs_disabled());
-       /* no buffer or no compressor so can't compress */
-       BUG_ON(dmem == NULL);
-       *out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER;
-       from_va = kmap_atomic(from);
-       mb();
-       ret = zcache_comp_op(ZCACHE_COMPOP_COMPRESS, from_va, PAGE_SIZE, dmem,
-                               out_len);
-       BUG_ON(ret);
-       *out_va = dmem;
-       kunmap_atomic(from_va);
-}
-
-static int zcache_comp_cpu_up(int cpu)
-{
-       struct crypto_comp *tfm;
-
-       tfm = crypto_alloc_comp(zcache_comp_name, 0, 0);
-       if (IS_ERR(tfm))
-               return NOTIFY_BAD;
-       *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = tfm;
-       return NOTIFY_OK;
-}
-
-static void zcache_comp_cpu_down(int cpu)
-{
-       struct crypto_comp *tfm;
-
-       tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu);
-       crypto_free_comp(tfm);
-       *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = NULL;
-}
-
-static int zcache_cpu_notifier(struct notifier_block *nb,
-                               unsigned long action, void *pcpu)
-{
-       int ret, i, cpu = (long)pcpu;
-       struct zcache_preload *kp;
-
-       switch (action) {
-       case CPU_UP_PREPARE:
-               ret = zcache_comp_cpu_up(cpu);
-               if (ret != NOTIFY_OK) {
-                       pr_err("%s: can't allocate compressor xform\n",
-                               namestr);
-                       return ret;
-               }
-               per_cpu(zcache_dstmem, cpu) = (void *)__get_free_pages(
-                       GFP_KERNEL | __GFP_REPEAT, ZCACHE_DSTMEM_ORDER);
-               if (ramster_enabled)
-                       ramster_cpu_up(cpu);
-               break;
-       case CPU_DEAD:
-       case CPU_UP_CANCELED:
-               zcache_comp_cpu_down(cpu);
-               free_pages((unsigned long)per_cpu(zcache_dstmem, cpu),
-                       ZCACHE_DSTMEM_ORDER);
-               per_cpu(zcache_dstmem, cpu) = NULL;
-               kp = &per_cpu(zcache_preloads, cpu);
-               for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
-                       if (kp->objnodes[i])
-                               kmem_cache_free(zcache_objnode_cache,
-                                               kp->objnodes[i]);
-               }
-               if (kp->obj) {
-                       kmem_cache_free(zcache_obj_cache, kp->obj);
-                       kp->obj = NULL;
-               }
-               if (ramster_enabled)
-                       ramster_cpu_down(cpu);
-               break;
-       default:
-               break;
-       }
-       return NOTIFY_OK;
-}
-
-static struct notifier_block zcache_cpu_notifier_block = {
-       .notifier_call = zcache_cpu_notifier
-};
-
-/*
- * The following code interacts with the zbud eviction and zbud
- * zombify code to access LRU pages
- */
-
-static struct page *zcache_evict_eph_pageframe(void)
-{
-       struct page *page;
-       unsigned int zsize = 0, zpages = 0;
-
-       page = zbud_evict_pageframe_lru(&zsize, &zpages);
-       if (page == NULL)
-               goto out;
-       zcache_eph_zbytes = atomic_long_sub_return(zsize,
-                                       &zcache_eph_zbytes_atomic);
-       zcache_eph_zpages = atomic_sub_return(zpages,
-                                       &zcache_eph_zpages_atomic);
-       zcache_evicted_eph_zpages++;
-       zcache_eph_pageframes =
-               atomic_dec_return(&zcache_eph_pageframes_atomic);
-       zcache_evicted_eph_pageframes++;
-out:
-       return page;
-}
-
-#ifdef FRONTSWAP_HAS_UNUSE
-static void unswiz(struct tmem_oid oid, u32 index,
-                               unsigned *type, pgoff_t *offset);
-
-/*
- *  Choose an LRU persistent pageframe and attempt to "unuse" it by
- *  calling frontswap_unuse on both zpages.
- *
- *  This is work-in-progress.
- */
-
-static int zcache_frontswap_unuse(void)
-{
-       struct tmem_handle th[2];
-       int ret = -ENOMEM;
-       int nzbuds, unuse_ret;
-       unsigned type;
-       struct page *newpage1 = NULL, *newpage2 = NULL;
-       struct page *evictpage1 = NULL, *evictpage2 = NULL;
-       pgoff_t offset;
-
-       newpage1 = alloc_page(ZCACHE_GFP_MASK);
-       newpage2 = alloc_page(ZCACHE_GFP_MASK);
-       if (newpage1 == NULL)
-               evictpage1 = zcache_evict_eph_pageframe();
-       if (newpage2 == NULL)
-               evictpage2 = zcache_evict_eph_pageframe();
-       if (evictpage1 == NULL || evictpage2 == NULL)
-               goto free_and_out;
-       /* ok, we have two pages pre-allocated */
-       nzbuds = zbud_make_zombie_lru(&th[0], NULL, NULL, false);
-       if (nzbuds == 0) {
-               ret = -ENOENT;
-               goto free_and_out;
-       }
-       unswiz(th[0].oid, th[0].index, &type, &offset);
-       unuse_ret = frontswap_unuse(type, offset,
-                               newpage1 != NULL ? newpage1 : evictpage1,
-                               ZCACHE_GFP_MASK);
-       if (unuse_ret != 0)
-               goto free_and_out;
-       else if (evictpage1 != NULL)
-               zcache_unacct_page();
-       newpage1 = NULL;
-       evictpage1 = NULL;
-       if (nzbuds == 2) {
-               unswiz(th[1].oid, th[1].index, &type, &offset);
-               unuse_ret = frontswap_unuse(type, offset,
-                               newpage2 != NULL ? newpage2 : evictpage2,
-                               ZCACHE_GFP_MASK);
-               if (unuse_ret != 0) {
-                       goto free_and_out;
-               } else if (evictpage2 != NULL) {
-                       zcache_unacct_page();
-               }
-       }
-       ret = 0;
-       goto out;
-
-free_and_out:
-       if (newpage1 != NULL)
-               __free_page(newpage1);
-       if (newpage2 != NULL)
-               __free_page(newpage2);
-       if (evictpage1 != NULL)
-               zcache_free_page(evictpage1);
-       if (evictpage2 != NULL)
-               zcache_free_page(evictpage2);
-out:
-       return ret;
-}
-#endif
-
-/*
- * When zcache is disabled ("frozen"), pools can be created and destroyed,
- * but all puts (and thus all other operations that require memory allocation)
- * must fail.  If zcache is unfrozen, accepts puts, then frozen again,
- * data consistency requires all puts while frozen to be converted into
- * flushes.
- */
-static bool zcache_freeze;
-
-/*
- * This zcache shrinker interface reduces the number of ephemeral pageframes
- * used by zcache to approximately the same as the total number of LRU_FILE
- * pageframes in use.
- */
-static int shrink_zcache_memory(struct shrinker *shrink,
-                               struct shrink_control *sc)
-{
-       static bool in_progress;
-       int ret = -1;
-       int nr = sc->nr_to_scan;
-       int nr_evict = 0;
-       int nr_unuse = 0;
-       struct page *page;
-#ifdef FRONTSWAP_HAS_UNUSE
-       int unuse_ret;
-#endif
-
-       if (nr <= 0)
-               goto skip_evict;
-
-       /* don't allow more than one eviction thread at a time */
-       if (in_progress)
-               goto skip_evict;
-
-       in_progress = true;
-
-       /* we are going to ignore nr, and target a different value */
-       zcache_last_active_file_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE);
-       zcache_last_inactive_file_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE);
-       nr_evict = zcache_eph_pageframes - zcache_last_active_file_pageframes +
-               zcache_last_inactive_file_pageframes;
-       while (nr_evict-- > 0) {
-               page = zcache_evict_eph_pageframe();
-               if (page == NULL)
-                       break;
-               zcache_free_page(page);
-       }
-
-       zcache_last_active_anon_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON);
-       zcache_last_inactive_anon_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON);
-       nr_unuse = zcache_pers_pageframes - zcache_last_active_anon_pageframes +
-               zcache_last_inactive_anon_pageframes;
-#ifdef FRONTSWAP_HAS_UNUSE
-       /* rate limit for testing */
-       if (nr_unuse > 32)
-               nr_unuse = 32;
-       while (nr_unuse-- > 0) {
-               unuse_ret = zcache_frontswap_unuse();
-               if (unuse_ret == -ENOMEM)
-                       break;
-       }
-#endif
-       in_progress = false;
-
-skip_evict:
-       /* resample: has changed, but maybe not all the way yet */
-       zcache_last_active_file_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE);
-       zcache_last_inactive_file_pageframes =
-               global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE);
-       ret = zcache_eph_pageframes - zcache_last_active_file_pageframes +
-               zcache_last_inactive_file_pageframes;
-       if (ret < 0)
-               ret = 0;
-       return ret;
-}
-
-static struct shrinker zcache_shrinker = {
-       .shrink = shrink_zcache_memory,
-       .seeks = DEFAULT_SEEKS,
-};
-
-/*
- * zcache shims between cleancache/frontswap ops and tmem
- */
-
-/* FIXME rename these core routines to zcache_tmemput etc? */
-int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
-                               uint32_t index, void *page,
-                               unsigned int size, bool raw, int ephemeral)
-{
-       struct tmem_pool *pool;
-       struct tmem_handle th;
-       int ret = -1;
-       void *pampd = NULL;
-
-       BUG_ON(!irqs_disabled());
-       pool = zcache_get_pool_by_id(cli_id, pool_id);
-       if (unlikely(pool == NULL))
-               goto out;
-       if (!zcache_freeze) {
-               ret = 0;
-               th.client_id = cli_id;
-               th.pool_id = pool_id;
-               th.oid = *oidp;
-               th.index = index;
-               pampd = zcache_pampd_create((char *)page, size, raw,
-                               ephemeral, &th);
-               if (pampd == NULL) {
-                       ret = -ENOMEM;
-                       if (ephemeral)
-                               zcache_failed_eph_puts++;
-                       else
-                               zcache_failed_pers_puts++;
-               } else {
-                       if (ramster_enabled)
-                               ramster_do_preload_flnode(pool);
-                       ret = tmem_put(pool, oidp, index, 0, pampd);
-                       if (ret < 0)
-                               BUG();
-               }
-               zcache_put_pool(pool);
-       } else {
-               zcache_put_to_flush++;
-               if (ramster_enabled)
-                       ramster_do_preload_flnode(pool);
-               if (atomic_read(&pool->obj_count) > 0)
-                       /* the put fails whether the flush succeeds or not */
-                       (void)tmem_flush_page(pool, oidp, index);
-               zcache_put_pool(pool);
-       }
-out:
-       return ret;
-}
-
-int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp,
-                               uint32_t index, void *page,
-                               size_t *sizep, bool raw, int get_and_free)
-{
-       struct tmem_pool *pool;
-       int ret = -1;
-       bool eph;
-
-       if (!raw) {
-               BUG_ON(irqs_disabled());
-               BUG_ON(in_softirq());
-       }
-       pool = zcache_get_pool_by_id(cli_id, pool_id);
-       eph = is_ephemeral(pool);
-       if (likely(pool != NULL)) {
-               if (atomic_read(&pool->obj_count) > 0)
-                       ret = tmem_get(pool, oidp, index, (char *)(page),
-                                       sizep, raw, get_and_free);
-               zcache_put_pool(pool);
-       }
-       WARN_ONCE((!is_ephemeral(pool) && (ret != 0)),
-                       "zcache_get fails on persistent pool, "
-                       "bad things are very likely to happen soon\n");
-#ifdef RAMSTER_TESTING
-       if (ret != 0 && ret != -1 && !(ret == -EINVAL && is_ephemeral(pool)))
-               pr_err("TESTING zcache_get tmem_get returns ret=%d\n", ret);
-#endif
-       return ret;
-}
-
-int zcache_flush_page(int cli_id, int pool_id,
-                               struct tmem_oid *oidp, uint32_t index)
-{
-       struct tmem_pool *pool;
-       int ret = -1;
-       unsigned long flags;
-
-       local_irq_save(flags);
-       zcache_flush_total++;
-       pool = zcache_get_pool_by_id(cli_id, pool_id);
-       if (ramster_enabled)
-               ramster_do_preload_flnode(pool);
-       if (likely(pool != NULL)) {
-               if (atomic_read(&pool->obj_count) > 0)
-                       ret = tmem_flush_page(pool, oidp, index);
-               zcache_put_pool(pool);
-       }
-       if (ret >= 0)
-               zcache_flush_found++;
-       local_irq_restore(flags);
-       return ret;
-}
-
-int zcache_flush_object(int cli_id, int pool_id,
-                               struct tmem_oid *oidp)
-{
-       struct tmem_pool *pool;
-       int ret = -1;
-       unsigned long flags;
-
-       local_irq_save(flags);
-       zcache_flobj_total++;
-       pool = zcache_get_pool_by_id(cli_id, pool_id);
-       if (ramster_enabled)
-               ramster_do_preload_flnode(pool);
-       if (likely(pool != NULL)) {
-               if (atomic_read(&pool->obj_count) > 0)
-                       ret = tmem_flush_object(pool, oidp);
-               zcache_put_pool(pool);
-       }
-       if (ret >= 0)
-               zcache_flobj_found++;
-       local_irq_restore(flags);
-       return ret;
-}
-
-static int zcache_client_destroy_pool(int cli_id, int pool_id)
-{
-       struct tmem_pool *pool = NULL;
-       struct zcache_client *cli = NULL;
-       int ret = -1;
-
-       if (pool_id < 0)
-               goto out;
-       if (cli_id == LOCAL_CLIENT)
-               cli = &zcache_host;
-       else if ((unsigned int)cli_id < MAX_CLIENTS)
-               cli = &zcache_clients[cli_id];
-       if (cli == NULL)
-               goto out;
-       atomic_inc(&cli->refcount);
-       pool = cli->tmem_pools[pool_id];
-       if (pool == NULL)
-               goto out;
-       cli->tmem_pools[pool_id] = NULL;
-       /* wait for pool activity on other cpus to quiesce */
-       while (atomic_read(&pool->refcount) != 0)
-               ;
-       atomic_dec(&cli->refcount);
-       local_bh_disable();
-       ret = tmem_destroy_pool(pool);
-       local_bh_enable();
-       kfree(pool);
-       if (cli_id == LOCAL_CLIENT)
-               pr_info("%s: destroyed local pool id=%d\n", namestr, pool_id);
-       else
-               pr_info("%s: destroyed pool id=%d, client=%d\n",
-                               namestr, pool_id, cli_id);
-out:
-       return ret;
-}
-
-int zcache_new_pool(uint16_t cli_id, uint32_t flags)
-{
-       int poolid = -1;
-       struct tmem_pool *pool;
-       struct zcache_client *cli = NULL;
-
-       if (cli_id == LOCAL_CLIENT)
-               cli = &zcache_host;
-       else if ((unsigned int)cli_id < MAX_CLIENTS)
-               cli = &zcache_clients[cli_id];
-       if (cli == NULL)
-               goto out;
-       atomic_inc(&cli->refcount);
-       pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC);
-       if (pool == NULL) {
-               pr_info("%s: pool creation failed: out of memory\n", namestr);
-               goto out;
-       }
-
-       for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++)
-               if (cli->tmem_pools[poolid] == NULL)
-                       break;
-       if (poolid >= MAX_POOLS_PER_CLIENT) {
-               pr_info("%s: pool creation failed: max exceeded\n", namestr);
-               kfree(pool);
-               poolid = -1;
-               goto out;
-       }
-       atomic_set(&pool->refcount, 0);
-       pool->client = cli;
-       pool->pool_id = poolid;
-       tmem_new_pool(pool, flags);
-       cli->tmem_pools[poolid] = pool;
-       if (cli_id == LOCAL_CLIENT)
-               pr_info("%s: created %s local tmem pool, id=%d\n", namestr,
-                       flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
-                       poolid);
-       else
-               pr_info("%s: created %s tmem pool, id=%d, client=%d\n", namestr,
-                       flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
-                       poolid, cli_id);
-out:
-       if (cli != NULL)
-               atomic_dec(&cli->refcount);
-       return poolid;
-}
-
-static int zcache_local_new_pool(uint32_t flags)
-{
-       return zcache_new_pool(LOCAL_CLIENT, flags);
-}
-
-int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph)
-{
-       struct tmem_pool *pool;
-       struct zcache_client *cli;
-       uint32_t flags = eph ? 0 : TMEM_POOL_PERSIST;
-       int ret = -1;
-
-       BUG_ON(!ramster_enabled);
-       if (cli_id == LOCAL_CLIENT)
-               goto out;
-       if (pool_id >= MAX_POOLS_PER_CLIENT)
-               goto out;
-       if (cli_id >= MAX_CLIENTS)
-               goto out;
-
-       cli = &zcache_clients[cli_id];
-       if ((eph && disable_cleancache) || (!eph && disable_frontswap)) {
-               pr_err("zcache_autocreate_pool: pool type disabled\n");
-               goto out;
-       }
-       if (!cli->allocated) {
-               if (zcache_new_client(cli_id)) {
-                       pr_err("zcache_autocreate_pool: can't create client\n");
-                       goto out;
-               }
-               cli = &zcache_clients[cli_id];
-       }
-       atomic_inc(&cli->refcount);
-       pool = cli->tmem_pools[pool_id];
-       if (pool != NULL) {
-               if (pool->persistent && eph) {
-                       pr_err("zcache_autocreate_pool: type mismatch\n");
-                       goto out;
-               }
-               ret = 0;
-               goto out;
-       }
-       pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL);
-       if (pool == NULL) {
-               pr_info("%s: pool creation failed: out of memory\n", namestr);
-               goto out;
-       }
-       atomic_set(&pool->refcount, 0);
-       pool->client = cli;
-       pool->pool_id = pool_id;
-       tmem_new_pool(pool, flags);
-       cli->tmem_pools[pool_id] = pool;
-       pr_info("%s: AUTOcreated %s tmem poolid=%d, for remote client=%d\n",
-               namestr, flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
-               pool_id, cli_id);
-       ret = 0;
-out:
-       if (cli != NULL)
-               atomic_dec(&cli->refcount);
-       return ret;
-}
-
-/**********
- * Two kernel functionalities currently can be layered on top of tmem.
- * These are "cleancache" which is used as a second-chance cache for clean
- * page cache pages; and "frontswap" which is used for swap pages
- * to avoid writes to disk.  A generic "shim" is provided here for each
- * to translate in-kernel semantics to zcache semantics.
- */
-
-static void zcache_cleancache_put_page(int pool_id,
-                                       struct cleancache_filekey key,
-                                       pgoff_t index, struct page *page)
-{
-       u32 ind = (u32) index;
-       struct tmem_oid oid = *(struct tmem_oid *)&key;
-
-       if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) {
-               zcache_eph_nonactive_puts_ignored++;
-               return;
-       }
-       if (likely(ind == index))
-               (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index,
-                                       page, PAGE_SIZE, false, 1);
-}
-
-static int zcache_cleancache_get_page(int pool_id,
-                                       struct cleancache_filekey key,
-                                       pgoff_t index, struct page *page)
-{
-       u32 ind = (u32) index;
-       struct tmem_oid oid = *(struct tmem_oid *)&key;
-       size_t size;
-       int ret = -1;
-
-       if (likely(ind == index)) {
-               ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index,
-                                       page, &size, false, 0);
-               BUG_ON(ret >= 0 && size != PAGE_SIZE);
-               if (ret == 0)
-                       SetPageWasActive(page);
-       }
-       return ret;
-}
-
-static void zcache_cleancache_flush_page(int pool_id,
-                                       struct cleancache_filekey key,
-                                       pgoff_t index)
-{
-       u32 ind = (u32) index;
-       struct tmem_oid oid = *(struct tmem_oid *)&key;
-
-       if (likely(ind == index))
-               (void)zcache_flush_page(LOCAL_CLIENT, pool_id, &oid, ind);
-}
-
-static void zcache_cleancache_flush_inode(int pool_id,
-                                       struct cleancache_filekey key)
-{
-       struct tmem_oid oid = *(struct tmem_oid *)&key;
-
-       (void)zcache_flush_object(LOCAL_CLIENT, pool_id, &oid);
-}
-
-static void zcache_cleancache_flush_fs(int pool_id)
-{
-       if (pool_id >= 0)
-               (void)zcache_client_destroy_pool(LOCAL_CLIENT, pool_id);
-}
-
-static int zcache_cleancache_init_fs(size_t pagesize)
-{
-       BUG_ON(sizeof(struct cleancache_filekey) !=
-                               sizeof(struct tmem_oid));
-       BUG_ON(pagesize != PAGE_SIZE);
-       return zcache_local_new_pool(0);
-}
-
-static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize)
-{
-       /* shared pools are unsupported and map to private */
-       BUG_ON(sizeof(struct cleancache_filekey) !=
-                               sizeof(struct tmem_oid));
-       BUG_ON(pagesize != PAGE_SIZE);
-       return zcache_local_new_pool(0);
-}
-
-static struct cleancache_ops zcache_cleancache_ops = {
-       .put_page = zcache_cleancache_put_page,
-       .get_page = zcache_cleancache_get_page,
-       .invalidate_page = zcache_cleancache_flush_page,
-       .invalidate_inode = zcache_cleancache_flush_inode,
-       .invalidate_fs = zcache_cleancache_flush_fs,
-       .init_shared_fs = zcache_cleancache_init_shared_fs,
-       .init_fs = zcache_cleancache_init_fs
-};
-
-struct cleancache_ops zcache_cleancache_register_ops(void)
-{
-       struct cleancache_ops old_ops =
-               cleancache_register_ops(&zcache_cleancache_ops);
-
-       return old_ops;
-}
-
-/* a single tmem poolid is used for all frontswap "types" (swapfiles) */
-static int zcache_frontswap_poolid __read_mostly = -1;
-
-/*
- * Swizzling increases objects per swaptype, increasing tmem concurrency
- * for heavy swaploads.  Later, larger nr_cpus -> larger SWIZ_BITS
- * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from
- * frontswap_get_page(), but has side-effects. Hence using 8.
- */
-#define SWIZ_BITS              8
-#define SWIZ_MASK              ((1 << SWIZ_BITS) - 1)
-#define _oswiz(_type, _ind)    ((_type << SWIZ_BITS) | (_ind & SWIZ_MASK))
-#define iswiz(_ind)            (_ind >> SWIZ_BITS)
-
-static inline struct tmem_oid oswiz(unsigned type, u32 ind)
-{
-       struct tmem_oid oid = { .oid = { 0 } };
-       oid.oid[0] = _oswiz(type, ind);
-       return oid;
-}
-
-#ifdef FRONTSWAP_HAS_UNUSE
-static void unswiz(struct tmem_oid oid, u32 index,
-                               unsigned *type, pgoff_t *offset)
-{
-       *type = (unsigned)(oid.oid[0] >> SWIZ_BITS);
-       *offset = (pgoff_t)((index << SWIZ_BITS) |
-                       (oid.oid[0] & SWIZ_MASK));
-}
-#endif
-
-static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
-                                       struct page *page)
-{
-       u64 ind64 = (u64)offset;
-       u32 ind = (u32)offset;
-       struct tmem_oid oid = oswiz(type, ind);
-       int ret = -1;
-       unsigned long flags;
-
-       BUG_ON(!PageLocked(page));
-       if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) {
-               zcache_pers_nonactive_puts_ignored++;
-               ret = -ERANGE;
-               goto out;
-       }
-       if (likely(ind64 == ind)) {
-               local_irq_save(flags);
-               ret = zcache_put_page(LOCAL_CLIENT, zcache_frontswap_poolid,
-                                       &oid, iswiz(ind),
-                                       page, PAGE_SIZE, false, 0);
-               local_irq_restore(flags);
-       }
-out:
-       return ret;
-}
-
-/* returns 0 if the page was successfully gotten from frontswap, -1 if
- * was not present (should never happen!) */
-static int zcache_frontswap_get_page(unsigned type, pgoff_t offset,
-                                       struct page *page)
-{
-       u64 ind64 = (u64)offset;
-       u32 ind = (u32)offset;
-       struct tmem_oid oid = oswiz(type, ind);
-       size_t size;
-       int ret = -1, get_and_free;
-
-       if (frontswap_has_exclusive_gets)
-               get_and_free = 1;
-       else
-               get_and_free = -1;
-       BUG_ON(!PageLocked(page));
-       if (likely(ind64 == ind)) {
-               ret = zcache_get_page(LOCAL_CLIENT, zcache_frontswap_poolid,
-                                       &oid, iswiz(ind),
-                                       page, &size, false, get_and_free);
-               BUG_ON(ret >= 0 && size != PAGE_SIZE);
-       }
-       return ret;
-}
-
-/* flush a single page from frontswap */
-static void zcache_frontswap_flush_page(unsigned type, pgoff_t offset)
-{
-       u64 ind64 = (u64)offset;
-       u32 ind = (u32)offset;
-       struct tmem_oid oid = oswiz(type, ind);
-
-       if (likely(ind64 == ind))
-               (void)zcache_flush_page(LOCAL_CLIENT, zcache_frontswap_poolid,
-                                       &oid, iswiz(ind));
-}
-
-/* flush all pages from the passed swaptype */
-static void zcache_frontswap_flush_area(unsigned type)
-{
-       struct tmem_oid oid;
-       int ind;
-
-       for (ind = SWIZ_MASK; ind >= 0; ind--) {
-               oid = oswiz(type, ind);
-               (void)zcache_flush_object(LOCAL_CLIENT,
-                                               zcache_frontswap_poolid, &oid);
-       }
-}
-
-static void zcache_frontswap_init(unsigned ignored)
-{
-       /* a single tmem poolid is used for all frontswap "types" (swapfiles) */
-       if (zcache_frontswap_poolid < 0)
-               zcache_frontswap_poolid =
-                       zcache_local_new_pool(TMEM_POOL_PERSIST);
-}
-
-static struct frontswap_ops zcache_frontswap_ops = {
-       .store = zcache_frontswap_put_page,
-       .load = zcache_frontswap_get_page,
-       .invalidate_page = zcache_frontswap_flush_page,
-       .invalidate_area = zcache_frontswap_flush_area,
-       .init = zcache_frontswap_init
-};
-
-struct frontswap_ops zcache_frontswap_register_ops(void)
-{
-       struct frontswap_ops old_ops =
-               frontswap_register_ops(&zcache_frontswap_ops);
-
-       return old_ops;
-}
-
-/*
- * zcache initialization
- * NOTE FOR NOW zcache or ramster MUST BE PROVIDED AS A KERNEL BOOT PARAMETER
- * OR NOTHING HAPPENS!
- */
-
-static int __init enable_zcache(char *s)
-{
-       zcache_enabled = 1;
-       return 1;
-}
-__setup("zcache", enable_zcache);
-
-static int __init enable_ramster(char *s)
-{
-       zcache_enabled = 1;
-#ifdef CONFIG_RAMSTER
-       ramster_enabled = 1;
-#endif
-       return 1;
-}
-__setup("ramster", enable_ramster);
-
-/* allow independent dynamic disabling of cleancache and frontswap */
-
-static int __init no_cleancache(char *s)
-{
-       disable_cleancache = 1;
-       return 1;
-}
-
-__setup("nocleancache", no_cleancache);
-
-static int __init no_frontswap(char *s)
-{
-       disable_frontswap = 1;
-       return 1;
-}
-
-__setup("nofrontswap", no_frontswap);
-
-static int __init no_frontswap_exclusive_gets(char *s)
-{
-       frontswap_has_exclusive_gets = false;
-       return 1;
-}
-
-__setup("nofrontswapexclusivegets", no_frontswap_exclusive_gets);
-
-static int __init no_frontswap_ignore_nonactive(char *s)
-{
-       disable_frontswap_ignore_nonactive = 1;
-       return 1;
-}
-
-__setup("nofrontswapignorenonactive", no_frontswap_ignore_nonactive);
-
-static int __init no_cleancache_ignore_nonactive(char *s)
-{
-       disable_cleancache_ignore_nonactive = 1;
-       return 1;
-}
-
-__setup("nocleancacheignorenonactive", no_cleancache_ignore_nonactive);
-
-static int __init enable_zcache_compressor(char *s)
-{
-       strncpy(zcache_comp_name, s, ZCACHE_COMP_NAME_SZ);
-       zcache_enabled = 1;
-       return 1;
-}
-__setup("zcache=", enable_zcache_compressor);
-
-
-static int __init zcache_comp_init(void)
-{
-       int ret = 0;
-
-       /* check crypto algorithm */
-       if (*zcache_comp_name != '\0') {
-               ret = crypto_has_comp(zcache_comp_name, 0, 0);
-               if (!ret)
-                       pr_info("zcache: %s not supported\n",
-                                       zcache_comp_name);
-       }
-       if (!ret)
-               strcpy(zcache_comp_name, "lzo");
-       ret = crypto_has_comp(zcache_comp_name, 0, 0);
-       if (!ret) {
-               ret = 1;
-               goto out;
-       }
-       pr_info("zcache: using %s compressor\n", zcache_comp_name);
-
-       /* alloc percpu transforms */
-       ret = 0;
-       zcache_comp_pcpu_tfms = alloc_percpu(struct crypto_comp *);
-       if (!zcache_comp_pcpu_tfms)
-               ret = 1;
-out:
-       return ret;
-}
-
-static int __init zcache_init(void)
-{
-       int ret = 0;
-
-       if (ramster_enabled) {
-               namestr = "ramster";
-               ramster_register_pamops(&zcache_pamops);
-       }
-#ifdef CONFIG_DEBUG_FS
-       zcache_debugfs_init();
-#endif
-       if (zcache_enabled) {
-               unsigned int cpu;
-
-               tmem_register_hostops(&zcache_hostops);
-               tmem_register_pamops(&zcache_pamops);
-               ret = register_cpu_notifier(&zcache_cpu_notifier_block);
-               if (ret) {
-                       pr_err("%s: can't register cpu notifier\n", namestr);
-                       goto out;
-               }
-               ret = zcache_comp_init();
-               if (ret) {
-                       pr_err("%s: compressor initialization failed\n",
-                               namestr);
-                       goto out;
-               }
-               for_each_online_cpu(cpu) {
-                       void *pcpu = (void *)(long)cpu;
-                       zcache_cpu_notifier(&zcache_cpu_notifier_block,
-                               CPU_UP_PREPARE, pcpu);
-               }
-       }
-       zcache_objnode_cache = kmem_cache_create("zcache_objnode",
-                               sizeof(struct tmem_objnode), 0, 0, NULL);
-       zcache_obj_cache = kmem_cache_create("zcache_obj",
-                               sizeof(struct tmem_obj), 0, 0, NULL);
-       ret = zcache_new_client(LOCAL_CLIENT);
-       if (ret) {
-               pr_err("%s: can't create client\n", namestr);
-               goto out;
-       }
-       zbud_init();
-       if (zcache_enabled && !disable_cleancache) {
-               struct cleancache_ops old_ops;
-
-               register_shrinker(&zcache_shrinker);
-               old_ops = zcache_cleancache_register_ops();
-               pr_info("%s: cleancache enabled using kernel transcendent "
-                       "memory and compression buddies\n", namestr);
-#ifdef ZCACHE_DEBUG
-               pr_info("%s: cleancache: ignorenonactive = %d\n",
-                       namestr, !disable_cleancache_ignore_nonactive);
-#endif
-               if (old_ops.init_fs != NULL)
-                       pr_warn("%s: cleancache_ops overridden\n", namestr);
-       }
-       if (zcache_enabled && !disable_frontswap) {
-               struct frontswap_ops old_ops;
-
-               old_ops = zcache_frontswap_register_ops();
-               if (frontswap_has_exclusive_gets)
-                       frontswap_tmem_exclusive_gets(true);
-               pr_info("%s: frontswap enabled using kernel transcendent "
-                       "memory and compression buddies\n", namestr);
-#ifdef ZCACHE_DEBUG
-               pr_info("%s: frontswap: excl gets = %d active only = %d\n",
-                       namestr, frontswap_has_exclusive_gets,
-                       !disable_frontswap_ignore_nonactive);
-#endif
-               if (old_ops.init != NULL)
-                       pr_warn("%s: frontswap_ops overridden\n", namestr);
-       }
-       if (ramster_enabled)
-               ramster_init(!disable_cleancache, !disable_frontswap,
-                               frontswap_has_exclusive_gets);
-out:
-       return ret;
-}
-
-late_initcall(zcache_init);
index 0e93eb0735a77767ffb7203abbaa8236e3ceca0e..9d2d5c58add2bfbe079466e501c6b01ef1d26aa9 100644 (file)
@@ -39,12 +39,11 @@ Dot11d_Reset(struct ieee80211_device *ieee)
        memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
        memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
        // Set new channel map
-       for (i=1; i<=11; i++) {
+       for (i = 1; i <= 11; i++)
                (pDot11dInfo->channel_map)[i] = 1;
-       }
-       for (i=12; i<=14; i++) {
+
+       for (i = 12; i <= 14; i++)
                (pDot11dInfo->channel_map)[i] = 2;
-       }
 
        pDot11dInfo->State = DOT11D_STATE_NONE;
        pDot11dInfo->CountryIeLen = 0;
@@ -68,17 +67,16 @@ Dot11d_Reset(struct ieee80211_device *ieee)
 void
 Dot11d_UpdateCountryIe(
        struct ieee80211_device *dev,
-       u8 *            pTaddr,
+       u8 *pTaddr,
        u16     CoutryIeLen,
-       u8 * pCoutryIe
+       u8 *pCoutryIe
        )
 {
        PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
        u8 i, j, NumTriples, MaxChnlNum;
        PCHNL_TXPOWER_TRIPLE pTriple;
 
-       if((CoutryIeLen - 3)%3 != 0)
-       {
+       if ((CoutryIeLen - 3)%3 != 0) {
                printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
                Dot11d_Reset(dev);
                return;
@@ -89,35 +87,33 @@ Dot11d_UpdateCountryIe(
        MaxChnlNum = 0;
        NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
        pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
-       for(i = 0; i < NumTriples; i++)
-       {
-               if(MaxChnlNum >= pTriple->FirstChnl)
-               { // It is not in a monotonically increasing order, so stop processing.
+       for (i = 0; i < NumTriples; i++) {
+               if (MaxChnlNum >= pTriple->FirstChnl) {
+               // It is not in a monotonically increasing order, so stop processing.
                        printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
                        Dot11d_Reset(dev);
                        return;
                }
-               if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls))
-               // It is not a valid set of channel id, so stop processing.
+               if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) {
+               // It is not a valid set of channel id, so stop processing.
                        printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
                        Dot11d_Reset(dev);
                        return;
                }
 
-               for(j = 0 ; j < pTriple->NumChnls; j++)
-               {
+               for (j = 0 ; j < pTriple->NumChnls; j++) {
                        pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
                        pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
                        MaxChnlNum = pTriple->FirstChnl + j;
                }
 
-               pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
+               pTriple = (PCHNL_TXPOWER_TRIPLE)((u8 *)pTriple + 3);
        }
 #if 1
        //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
        printk("Channel List:");
-       for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
-               if(pDot11dInfo->channel_map[i] > 0)
+       for (i = 1; i <= MAX_CHANNEL_NUMBER; i++)
+               if (pDot11dInfo->channel_map[i] > 0)
                        printk(" %d", i);
        printk("\n");
 #endif
@@ -125,7 +121,7 @@ Dot11d_UpdateCountryIe(
        UPDATE_CIE_SRC(dev, pTaddr);
 
        pDot11dInfo->CountryIeLen = CoutryIeLen;
-       memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen);
+       memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen);
        pDot11dInfo->State = DOT11D_STATE_LEARNED;
 }
 
@@ -138,13 +134,11 @@ DOT11D_GetMaxTxPwrInDbm(
        PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
        u8 MaxTxPwrInDbm = 255;
 
-       if(MAX_CHANNEL_NUMBER < Channel)
-       {
+       if (MAX_CHANNEL_NUMBER < Channel) {
                printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
                return MaxTxPwrInDbm;
        }
-       if(pDot11dInfo->channel_map[Channel])
-       {
+       if (pDot11dInfo->channel_map[Channel]) {
                MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
        }
 
@@ -154,20 +148,19 @@ DOT11D_GetMaxTxPwrInDbm(
 
 void
 DOT11D_ScanComplete(
-       struct ieee80211_device * dev
+       struct ieee80211_device *dev
        )
 {
        PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
 
-       switch(pDot11dInfo->State)
-       {
+       switch (pDot11dInfo->State) {
        case DOT11D_STATE_LEARNED:
                pDot11dInfo->State = DOT11D_STATE_DONE;
                break;
 
        case DOT11D_STATE_DONE:
-               if( GET_CIE_WATCHDOG(dev) == 0 )
-               // Reset country IE if previous one is gone.
+               if (GET_CIE_WATCHDOG(dev) == 0) {
+               // Reset country IE if previous one is gone.
                        Dot11d_Reset(dev);
                }
                break;
@@ -177,24 +170,23 @@ DOT11D_ScanComplete(
 }
 
 int IsLegalChannel(
-       struct ieee80211_device * dev,
+       struct ieee80211_device *dev,
        u8 channel
 )
 {
        PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
 
-       if(MAX_CHANNEL_NUMBER < channel)
-       {
+       if (MAX_CHANNEL_NUMBER < channel) {
                printk("IsLegalChannel(): Invalid Channel\n");
                return 0;
        }
-       if(pDot11dInfo->channel_map[channel] > 0)
+       if (pDot11dInfo->channel_map[channel] > 0)
                return 1;
        return 0;
 }
 
 int ToLegalChannel(
-       struct ieee80211_device * dev,
+       struct ieee80211_device *dev,
        u8 channel
 )
 {
@@ -202,22 +194,19 @@ int ToLegalChannel(
        u8 default_chn = 0;
        u32 i = 0;
 
-       for (i=1; i<= MAX_CHANNEL_NUMBER; i++)
-       {
-               if(pDot11dInfo->channel_map[i] > 0)
-               {
+       for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) {
+               if (pDot11dInfo->channel_map[i] > 0) {
                        default_chn = i;
                        break;
                }
        }
 
-       if(MAX_CHANNEL_NUMBER < channel)
-       {
+       if (MAX_CHANNEL_NUMBER < channel) {
                printk("IsLegalChannel(): Invalid Channel\n");
                return default_chn;
        }
 
-       if(pDot11dInfo->channel_map[channel] > 0)
+       if (pDot11dInfo->channel_map[channel] > 0)
                return channel;
 
        return default_chn;
index c7917b24425c67026d96da3e9df8e5d05e1993c4..e014f7e7439783d4f9caacdef59cc919115d7991 100644 (file)
@@ -41,9 +41,9 @@ static const char *ieee80211_modes[] = {
 
 #define MAX_CUSTOM_LEN 64
 static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
-                                          char *start, char *stop,
-                                           struct ieee80211_network *network,
-                                           struct iw_request_info *info)
+                                          char *start, char *stop,
+                                          struct ieee80211_network *network,
+                                          struct iw_request_info *info)
 {
        char custom[MAX_CUSTOM_LEN];
        char *p;
@@ -78,9 +78,9 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]);
        start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
 
-        /* Add mode */
-        iwe.cmd = SIOCGIWMODE;
-        if (network->capability &
+       /* Add mode */
+       iwe.cmd = SIOCGIWMODE;
+       if (network->capability &
            (WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) {
                if (network->capability & WLAN_CAPABILITY_BSS)
                        iwe.u.mode = IW_MODE_MASTER;
@@ -90,7 +90,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
                start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
        }
 
-        /* Add frequency/channel */
+       /* Add frequency/channel */
        iwe.cmd = SIOCGIWFREQ;
 /*     iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
        iwe.u.freq.e = 3; */
@@ -168,23 +168,23 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee,
        if (iwe.u.data.length)
                start = iwe_stream_add_point(info, start, stop, &iwe, custom);
 
-               memset(&iwe, 0, sizeof(iwe));
-        if (network->wpa_ie_len) {
+       memset(&iwe, 0, sizeof(iwe));
+       if (network->wpa_ie_len) {
        //      printk("wpa_ie_len:%d\n", network->wpa_ie_len);
-                char buf[MAX_WPA_IE_LEN];
-                memcpy(buf, network->wpa_ie, network->wpa_ie_len);
-                iwe.cmd = IWEVGENIE;
-                iwe.u.data.length = network->wpa_ie_len;
-                start = iwe_stream_add_point(info, start, stop, &iwe, buf);
-        }
-
-        memset(&iwe, 0, sizeof(iwe));
-        if (network->rsn_ie_len) {
+               char buf[MAX_WPA_IE_LEN];
+               memcpy(buf, network->wpa_ie, network->wpa_ie_len);
+               iwe.cmd = IWEVGENIE;
+               iwe.u.data.length = network->wpa_ie_len;
+               start = iwe_stream_add_point(info, start, stop, &iwe, buf);
+       }
+
+       memset(&iwe, 0, sizeof(iwe));
+       if (network->rsn_ie_len) {
        //      printk("=====>rsn_ie_len:\n", network->rsn_ie_len);
-                char buf[MAX_WPA_IE_LEN];
-                memcpy(buf, network->rsn_ie, network->rsn_ie_len);
-                iwe.cmd = IWEVGENIE;
-                iwe.u.data.length = network->rsn_ie_len;
+               char buf[MAX_WPA_IE_LEN];
+               memcpy(buf, network->rsn_ie, network->rsn_ie_len);
+               iwe.cmd = IWEVGENIE;
+               iwe.u.data.length = network->rsn_ie_len;
                start = iwe_stream_add_point(info, start, stop, &iwe, buf);
        }
 
@@ -217,22 +217,18 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
        down(&ieee->wx_sem);
        spin_lock_irqsave(&ieee->lock, flags);
 
-       if(!ieee->bHwRadioOff)
-       {
+       if (!ieee->bHwRadioOff) {
                list_for_each_entry(network, &ieee->network_list, list) {
                        i++;
 
-                       if((stop-ev)<200)
-                       {
+                       if ((stop-ev) < 200) {
                                err = -E2BIG;
                                break;
                        }
                        if (ieee->scan_age == 0 ||
-                           time_after(network->last_scanned + ieee->scan_age, jiffies))
-                       {
+                           time_after(network->last_scanned + ieee->scan_age, jiffies)) {
                                ev = rtl818x_translate_scan(ieee, ev, stop, network, info);
-                       }
-                       else
+                       } else
                                IEEE80211_DEBUG_SCAN(
                                        "Not showing network '%s ("
                                        "%pM)' due to age (%lums).\n",
@@ -340,9 +336,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
                        kfree(new_crypt);
                        new_crypt = NULL;
 
-                       printk(KERN_WARNING "%s: could not initialize WEP: "
-                              "load module ieee80211_crypt_wep\n",
-                              dev->name);
+                       netdev_warn(ieee->dev,
+                                   "could not initialize WEP: load module ieee80211_crypt_wep\n");
                        return -EOPNOTSUPP;
                }
                *crypt = new_crypt;
@@ -359,7 +354,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
                                   key, escape_essid(sec.keys[key], len),
                                   erq->length, len);
                sec.key_sizes[key] = len;
-               (*crypt)->ops->set_key(sec.keys[key], len, NULL,
+               (*crypt)->ops->set_key(sec.keys[key], len, NULL,
                                       (*crypt)->priv);
                sec.flags |= (1 << key);
                /* This ensures a key will be activated if no key is
@@ -414,7 +409,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
        if (ieee->reset_on_keychange &&
            ieee->iw_mode != IW_MODE_INFRA &&
            ieee->reset_port && ieee->reset_port(dev)) {
-               printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
+               netdev_dbg(ieee->dev, "reset_port failed\n");
                return -EINVAL;
        }
        return 0;
@@ -430,7 +425,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
 
        IEEE80211_DEBUG_WX("GET_ENCODE\n");
 
-       if(ieee->iw_mode == IW_MODE_MONITOR)
+       if (ieee->iw_mode == IW_MODE_MONITOR)
                return -1;
 
        key = erq->flags & IW_ENCODE_INDEX;
@@ -472,240 +467,240 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
 }
 
 int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
+                               struct iw_request_info *info,
+                               union iwreq_data *wrqu, char *extra)
 {
        struct net_device *dev = ieee->dev;
-        struct iw_point *encoding = &wrqu->encoding;
-        struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-        int i, idx, ret = 0;
-        int group_key = 0;
-        const char *alg;
-        struct ieee80211_crypto_ops *ops;
-        struct ieee80211_crypt_data **crypt;
-
-        struct ieee80211_security sec = {
-                .flags = 0,
-        };
+       struct iw_point *encoding = &wrqu->encoding;
+       struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
+       int i, idx, ret = 0;
+       int group_key = 0;
+       const char *alg;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
+
+       struct ieee80211_security sec = {
+               .flags = 0,
+       };
        //printk("======>encoding flag:%x,ext flag:%x, ext alg:%d\n", encoding->flags,ext->ext_flags, ext->alg);
-        idx = encoding->flags & IW_ENCODE_INDEX;
-        if (idx) {
-                if (idx < 1 || idx > WEP_KEYS)
-                        return -EINVAL;
-                idx--;
-        } else
-                idx = ieee->tx_keyidx;
-
-        if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-                crypt = &ieee->crypt[idx];
-                group_key = 1;
-        } else {
-                /* some Cisco APs use idx>0 for unicast in dynamic WEP */
+       idx = encoding->flags & IW_ENCODE_INDEX;
+       if (idx) {
+               if (idx < 1 || idx > WEP_KEYS)
+                       return -EINVAL;
+               idx--;
+       } else
+               idx = ieee->tx_keyidx;
+
+       if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
+               crypt = &ieee->crypt[idx];
+               group_key = 1;
+       } else {
+               /* some Cisco APs use idx>0 for unicast in dynamic WEP */
                //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg);
-                if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP)
-                        return -EINVAL;
-                if (ieee->iw_mode == IW_MODE_INFRA)
-                        crypt = &ieee->crypt[idx];
-                else
-                        return -EINVAL;
-        }
-
-        sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT;
-        if ((encoding->flags & IW_ENCODE_DISABLED) ||
-            ext->alg == IW_ENCODE_ALG_NONE) {
-                if (*crypt)
-                        ieee80211_crypt_delayed_deinit(ieee, crypt);
-
-                for (i = 0; i < WEP_KEYS; i++)
-                        if (ieee->crypt[i] != NULL)
-                                break;
-
-                if (i == WEP_KEYS) {
-                        sec.enabled = 0;
-                      //  sec.encrypt = 0;
-                        sec.level = SEC_LEVEL_0;
-                        sec.flags |= SEC_LEVEL;
-                }
+               if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP)
+                       return -EINVAL;
+               if (ieee->iw_mode == IW_MODE_INFRA)
+                       crypt = &ieee->crypt[idx];
+               else
+                       return -EINVAL;
+       }
+
+       sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT;
+       if ((encoding->flags & IW_ENCODE_DISABLED) ||
+           ext->alg == IW_ENCODE_ALG_NONE) {
+               if (*crypt)
+                       ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+               for (i = 0; i < WEP_KEYS; i++)
+                       if (ieee->crypt[i] != NULL)
+                               break;
+
+               if (i == WEP_KEYS) {
+                       sec.enabled = 0;
+                       // sec.encrypt = 0;
+                       sec.level = SEC_LEVEL_0;
+                       sec.flags |= SEC_LEVEL;
+               }
                //printk("disabled: flag:%x\n", encoding->flags);
-                goto done;
-        }
+               goto done;
+       }
 
        sec.enabled = 1;
     //    sec.encrypt = 1;
 
-        switch (ext->alg) {
-        case IW_ENCODE_ALG_WEP:
-                alg = "WEP";
-                break;
-        case IW_ENCODE_ALG_TKIP:
-                alg = "TKIP";
-                break;
-        case IW_ENCODE_ALG_CCMP:
-                alg = "CCMP";
-                break;
-        default:
-                IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
-                                   dev->name, ext->alg);
-                ret = -EINVAL;
-                goto done;
-        }
+       switch (ext->alg) {
+       case IW_ENCODE_ALG_WEP:
+               alg = "WEP";
+               break;
+       case IW_ENCODE_ALG_TKIP:
+               alg = "TKIP";
+               break;
+       case IW_ENCODE_ALG_CCMP:
+               alg = "CCMP";
+               break;
+       default:
+               IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
+                                  dev->name, ext->alg);
+               ret = -EINVAL;
+               goto done;
+       }
 //     printk("8-09-08-9=====>%s, alg name:%s\n",__func__, alg);
 
-        ops = ieee80211_get_crypto_ops(alg);
-        if (ops == NULL)
-                ops = ieee80211_get_crypto_ops(alg);
-        if (ops == NULL) {
-                IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
-                                   dev->name, ext->alg);
+       ops = ieee80211_get_crypto_ops(alg);
+       if (ops == NULL)
+               ops = ieee80211_get_crypto_ops(alg);
+       if (ops == NULL) {
+               IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
+                                  dev->name, ext->alg);
                printk("========>unknown crypto alg %d\n", ext->alg);
-                ret = -EINVAL;
-                goto done;
-        }
-
-        if (*crypt == NULL || (*crypt)->ops != ops) {
-                struct ieee80211_crypt_data *new_crypt;
-
-                ieee80211_crypt_delayed_deinit(ieee, crypt);
-
-                new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
-                if (new_crypt == NULL) {
-                        ret = -ENOMEM;
-                        goto done;
-                }
-                new_crypt->ops = ops;
-                if (new_crypt->ops)
-                        new_crypt->priv = new_crypt->ops->init(idx);
-                if (new_crypt->priv == NULL) {
-                        kfree(new_crypt);
-                        ret = -EINVAL;
-                        goto done;
-                }
-                *crypt = new_crypt;
-
-       }
-
-        if (ext->key_len > 0 && (*crypt)->ops->set_key &&
-            (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
-                                   (*crypt)->priv) < 0) {
-                IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name);
+               ret = -EINVAL;
+               goto done;
+       }
+
+       if (*crypt == NULL || (*crypt)->ops != ops) {
+               struct ieee80211_crypt_data *new_crypt;
+
+               ieee80211_crypt_delayed_deinit(ieee, crypt);
+
+               new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
+               if (new_crypt == NULL) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
+               new_crypt->ops = ops;
+               if (new_crypt->ops)
+                       new_crypt->priv = new_crypt->ops->init(idx);
+               if (new_crypt->priv == NULL) {
+                       kfree(new_crypt);
+                       ret = -EINVAL;
+                       goto done;
+               }
+               *crypt = new_crypt;
+
+       }
+
+       if (ext->key_len > 0 && (*crypt)->ops->set_key &&
+           (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
+                                  (*crypt)->priv) < 0) {
+               IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name);
                printk("key setting failed\n");
-                ret = -EINVAL;
-                goto done;
-        }
+               ret = -EINVAL;
+               goto done;
+       }
 #if 1
  //skip_host_crypt:
        //printk("skip_host_crypt:ext_flags:%x\n", ext->ext_flags);
-        if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                ieee->tx_keyidx = idx;
-                sec.active_key = idx;
-                sec.flags |= SEC_ACTIVE_KEY;
-        }
-
-        if (ext->alg != IW_ENCODE_ALG_NONE) {
-                memcpy(sec.keys[idx], ext->key, ext->key_len);
-                sec.key_sizes[idx] = ext->key_len;
-                sec.flags |= (1 << idx);
-                if (ext->alg == IW_ENCODE_ALG_WEP) {
-                      //  sec.encode_alg[idx] = SEC_ALG_WEP;
-                        sec.flags |= SEC_LEVEL;
-                        sec.level = SEC_LEVEL_1;
-                } else if (ext->alg == IW_ENCODE_ALG_TKIP) {
-                      //  sec.encode_alg[idx] = SEC_ALG_TKIP;
-                        sec.flags |= SEC_LEVEL;
-                        sec.level = SEC_LEVEL_2;
-                } else if (ext->alg == IW_ENCODE_ALG_CCMP) {
-                       // sec.encode_alg[idx] = SEC_ALG_CCMP;
-                        sec.flags |= SEC_LEVEL;
-                        sec.level = SEC_LEVEL_3;
-                }
-                /* Don't set sec level for group keys. */
-                if (group_key)
-                        sec.flags &= ~SEC_LEVEL;
-        }
+       if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
+               ieee->tx_keyidx = idx;
+               sec.active_key = idx;
+               sec.flags |= SEC_ACTIVE_KEY;
+       }
+
+       if (ext->alg != IW_ENCODE_ALG_NONE) {
+               memcpy(sec.keys[idx], ext->key, ext->key_len);
+               sec.key_sizes[idx] = ext->key_len;
+               sec.flags |= (1 << idx);
+               if (ext->alg == IW_ENCODE_ALG_WEP) {
+                     //  sec.encode_alg[idx] = SEC_ALG_WEP;
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_1;
+               } else if (ext->alg == IW_ENCODE_ALG_TKIP) {
+                     //  sec.encode_alg[idx] = SEC_ALG_TKIP;
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_2;
+               } else if (ext->alg == IW_ENCODE_ALG_CCMP) {
+                      // sec.encode_alg[idx] = SEC_ALG_CCMP;
+                       sec.flags |= SEC_LEVEL;
+                       sec.level = SEC_LEVEL_3;
+               }
+               /* Don't set sec level for group keys. */
+               if (group_key)
+                       sec.flags &= ~SEC_LEVEL;
+       }
 #endif
 done:
-        if (ieee->set_security)
-                ieee->set_security(ieee->dev, &sec);
+       if (ieee->set_security)
+               ieee->set_security(ieee->dev, &sec);
 
         if (ieee->reset_on_keychange &&
-            ieee->iw_mode != IW_MODE_INFRA &&
-            ieee->reset_port && ieee->reset_port(dev)) {
-                IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
-                return -EINVAL;
-        }
+           ieee->iw_mode != IW_MODE_INFRA &&
+           ieee->reset_port && ieee->reset_port(dev)) {
+               IEEE80211_DEBUG_WX("%s: reset_port failed\n", dev->name);
+               return -EINVAL;
+       }
 
-        return ret;
+       return ret;
 }
 int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
-                               struct iw_request_info *info,
-                               union iwreq_data *wrqu, char *extra)
+                              struct iw_request_info *info,
+                              union iwreq_data *wrqu, char *extra)
 {
        struct iw_mlme *mlme = (struct iw_mlme *) extra;
 //     printk("\ndkgadfslkdjgalskdf===============>%s(), cmd:%x\n", __func__, mlme->cmd);
 #if 1
        switch (mlme->cmd) {
-        case IW_MLME_DEAUTH:
+       case IW_MLME_DEAUTH:
        case IW_MLME_DISASSOC:
        //      printk("disassoc now\n");
                ieee80211_disassociate(ieee);
                break;
         default:
-                return -EOPNOTSUPP;
-        }
+               return -EOPNOTSUPP;
+       }
 #endif
        return 0;
 }
 
 int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
-                               struct iw_request_info *info,
-                               struct iw_param *data, char *extra)
+                              struct iw_request_info *info,
+                              struct iw_param *data, char *extra)
 {
 /*
         struct ieee80211_security sec = {
-                .flags = SEC_AUTH_MODE,
+               .flags = SEC_AUTH_MODE,
        }
 */
        //printk("set auth:flag:%x, data value:%x\n", data->flags, data->value);
        switch (data->flags & IW_AUTH_INDEX) {
-        case IW_AUTH_WPA_VERSION:
+       case IW_AUTH_WPA_VERSION:
             /*need to support wpa2 here*/
                //printk("wpa version:%x\n", data->value);
                break;
-        case IW_AUTH_CIPHER_PAIRWISE:
-        case IW_AUTH_CIPHER_GROUP:
-        case IW_AUTH_KEY_MGMT:
-                /*
+       case IW_AUTH_CIPHER_PAIRWISE:
+       case IW_AUTH_CIPHER_GROUP:
+       case IW_AUTH_KEY_MGMT:
+               /*
  *                  * Host AP driver does not use these parameters and allows
  *                                   * wpa_supplicant to control them internally.
  *                                                    */
-                break;
-        case IW_AUTH_TKIP_COUNTERMEASURES:
-                ieee->tkip_countermeasures = data->value;
-                break;
-        case IW_AUTH_DROP_UNENCRYPTED:
-                ieee->drop_unencrypted = data->value;
+               break;
+       case IW_AUTH_TKIP_COUNTERMEASURES:
+               ieee->tkip_countermeasures = data->value;
+               break;
+       case IW_AUTH_DROP_UNENCRYPTED:
+               ieee->drop_unencrypted = data->value;
                break;
 
        case IW_AUTH_80211_AUTH_ALG:
-               ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM)?1:0;
+               ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM) ? 1 : 0;
                //printk("open_wep:%d\n", ieee->open_wep);
                break;
 
 #if 1
        case IW_AUTH_WPA_ENABLED:
-               ieee->wpa_enabled = (data->value)?1:0;
+               ieee->wpa_enabled = (data->value) ? 1 : 0;
                //printk("enable wpa:%d\n", ieee->wpa_enabled);
                break;
 
 #endif
        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-                ieee->ieee802_1x = data->value;
+               ieee->ieee802_1x = data->value;
                break;
        case IW_AUTH_PRIVACY_INVOKED:
                ieee->privacy_invoked = data->value;
                break;
        default:
-                return -EOPNOTSUPP;
+               return -EOPNOTSUPP;
        }
        return 0;
 }
@@ -715,15 +710,13 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
 {
        u8 *buf = NULL;
 
-       if (len>MAX_WPA_IE_LEN || (len && ie == NULL))
-       {
+       if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) {
                printk("return error out, len:%zu\n", len);
        return -EINVAL;
        }
 
-       if (len)
-       {
-               if (len != ie[1]+2){
+       if (len) {
+               if (len != ie[1]+2) {
                        printk("len:%zu, ie:%d\n", len, ie[1]);
                        return -EINVAL;
                }
@@ -733,8 +726,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
                kfree(ieee->wpa_ie);
                ieee->wpa_ie = buf;
                ieee->wpa_ie_len = len;
-       }
-       else{
+       } else {
                kfree(ieee->wpa_ie);
                ieee->wpa_ie = NULL;
                ieee->wpa_ie_len = 0;
index 87c33fdb95267e5ca9a5429e039aae1802a10c5a..0485d6eec7b5f2fc9572ecce2d27d0f09d75955d 100644 (file)
@@ -2,4 +2,3 @@ v 0.1
 
 First version.
 This is based on the rtl8180-sa2400 pre-0.22-CVS code..
-
index 51effd6412acfda41636b6dfe9efee4b4297fe97..b5d0c2eb045b99350d6b9cb40dbf7cfd6fa5d97d 100644 (file)
@@ -25,4 +25,3 @@ obj-m +=ieee80211_crypt-rsl.o
 obj-m +=ieee80211_crypt_wep-rsl.o
 obj-m +=ieee80211_crypt_tkip-rsl.o
 obj-m +=ieee80211_crypt_ccmp-rsl.o
-
index a6bb6c9207d32e2c6242ef4fceeba071d38e96d9..abc1023cef65bb8b71f437d4a02a0f86e5a8cbeb 100644 (file)
@@ -443,7 +443,7 @@ static struct crypto_alg aes_alg = {
                .cipher = {
                        .cia_min_keysize        =       AES_MIN_KEY_SIZE,
                        .cia_max_keysize        =       AES_MAX_KEY_SIZE,
-                       .cia_setkey             =       aes_set_key,
+                       .cia_setkey             =       aes_set_key,
                        .cia_encrypt            =       aes_encrypt,
                        .cia_decrypt            =       aes_decrypt
                }
@@ -466,4 +466,3 @@ module_exit(aes_fini);
 
 MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");
 MODULE_LICENSE("Dual BSD/GPL");
-
index e3ad8d2f415e802255b283353a5dd2288dde2dd2..b790e9ad104c025c131eddf9dd6027d0d88619f5 100644 (file)
@@ -79,7 +79,7 @@ static struct crypto_alg arc4_alg = {
        .cra_u                  =       { .cipher = {
        .cia_min_keysize        =       ARC4_MIN_KEY_SIZE,
        .cia_max_keysize        =       ARC4_MAX_KEY_SIZE,
-       .cia_setkey             =       arc4_set_key,
+       .cia_setkey             =       arc4_set_key,
        .cia_encrypt            =       arc4_crypt,
        .cia_decrypt            =       arc4_crypt } }
 };
index da486588f1c03c96fed4472da6c05e12bcd5edda..2ba374a64178bb661d63621e957b3c603876b65b 100644 (file)
@@ -56,5 +56,3 @@ static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
 }
 //EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
 //EXPORT_SYMBOL_GPL(crypto_free_tfm);
-
-
index ce63fc341c6ea4c3745d667d350303f9b830faf8..f10fd5a93c386d3c74723563795e5485aadf308a 100644 (file)
@@ -218,4 +218,3 @@ EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm);
 EXPORT_SYMBOL(DOT11D_ScanComplete);
 EXPORT_SYMBOL(IsLegalChannel);
 EXPORT_SYMBOL(ToLegalChannel);
-
index 502bfdbcc84ba0dd2dfff085c567830f7effe36d..210898c8e66c149f5cbb661026dff5dae103821a 100644 (file)
@@ -64,7 +64,7 @@
 #endif
 
 #define KEY_TYPE_NA            0x0
-#define KEY_TYPE_WEP40                 0x1
+#define KEY_TYPE_WEP40         0x1
 #define KEY_TYPE_TKIP          0x2
 #define KEY_TYPE_CCMP          0x4
 #define KEY_TYPE_WEP104                0x5
@@ -195,21 +195,21 @@ enum      _ReasonCode{
        auth_not_valid  = 0x2,
        deauth_lv_ss    = 0x3,
        inactivity              = 0x4,
-       ap_overload     = 0x5,
+       ap_overload     = 0x5,
        class2_err              = 0x6,
        class3_err              = 0x7,
-       disas_lv_ss     = 0x8,
+       disas_lv_ss     = 0x8,
        asoc_not_auth   = 0x9,
 
        //----MIC_CHECK
-       mic_failure     = 0xe,
+       mic_failure     = 0xe,
        //----END MIC_CHECK
 
        // Reason code defined in 802.11i D10.0 p.28.
        invalid_IE              = 0x0d,
        four_way_tmout  = 0x0f,
        two_way_tmout   = 0x10,
-       IE_dismatch     = 0x11,
+       IE_dismatch     = 0x11,
        invalid_Gcipher = 0x12,
        invalid_Pcipher = 0x13,
        invalid_AKMP    = 0x14,
@@ -222,7 +222,7 @@ enum        _ReasonCode{
        QoS_unspec              = 0x20, // 32
        QAP_bandwidth   = 0x21, // 33
        poor_condition  = 0x22, // 34
-       no_facility     = 0x23, // 35
+       no_facility     = 0x23, // 35
                                                        // Where is 36???
        req_declined    = 0x25, // 37
        invalid_param   = 0x26, // 38
@@ -265,7 +265,7 @@ enum        _ReasonCode{
 #define IEEE_WPAX_USEGROUP                     0
 #define IEEE_WPAX_WEP40                                1
 #define IEEE_WPAX_TKIP                         2
-#define IEEE_WPAX_WRAP                         3
+#define IEEE_WPAX_WRAP                         3
 #define IEEE_WPAX_CCMP                         4
 #define IEEE_WPAX_WEP104                       5
 
@@ -289,12 +289,12 @@ enum      _ReasonCode{
 #define MAX_IE_LEN  0xff
 
 // added for kernel conflict
-#define ieee80211_crypt_deinit_entries         ieee80211_crypt_deinit_entries_rsl
-#define ieee80211_crypt_deinit_handler         ieee80211_crypt_deinit_handler_rsl
-#define ieee80211_crypt_delayed_deinit         ieee80211_crypt_delayed_deinit_rsl
-#define ieee80211_register_crypto_ops          ieee80211_register_crypto_ops_rsl
+#define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl
+#define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl
+#define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl
+#define ieee80211_register_crypto_ops  ieee80211_register_crypto_ops_rsl
 #define ieee80211_unregister_crypto_ops ieee80211_unregister_crypto_ops_rsl
-#define ieee80211_get_crypto_ops       ieee80211_get_crypto_ops_rsl
+#define ieee80211_get_crypto_ops       ieee80211_get_crypto_ops_rsl
 
 #define ieee80211_ccmp_null            ieee80211_ccmp_null_rsl
 
@@ -302,10 +302,10 @@ enum      _ReasonCode{
 
 #define ieee80211_wep_null             ieee80211_wep_null_rsl
 
-#define free_ieee80211                 free_ieee80211_rsl
-#define alloc_ieee80211                        alloc_ieee80211_rsl
+#define free_ieee80211                 free_ieee80211_rsl
+#define alloc_ieee80211                        alloc_ieee80211_rsl
 
-#define ieee80211_rx                   ieee80211_rx_rsl
+#define ieee80211_rx                   ieee80211_rx_rsl
 #define ieee80211_rx_mgt               ieee80211_rx_mgt_rsl
 
 #define ieee80211_get_beacon           ieee80211_get_beacon_rsl
@@ -450,7 +450,7 @@ typedef struct ieee_param {
 
 /* management */
 #define IEEE80211_STYPE_ASSOC_REQ      0x0000
-#define IEEE80211_STYPE_ASSOC_RESP     0x0010
+#define IEEE80211_STYPE_ASSOC_RESP     0x0010
 #define IEEE80211_STYPE_REASSOC_REQ    0x0020
 #define IEEE80211_STYPE_REASSOC_RESP   0x0030
 #define IEEE80211_STYPE_PROBE_REQ      0x0040
@@ -536,7 +536,7 @@ do { if (ieee80211_debug_level & (level)) \
 //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
 #define IEEE80211_DEBUG_DATA(level, data, datalen)     \
        do{ if ((ieee80211_debug_level & (level)) == (level))   \
-               {       \
+               {       \
                        int i;                                  \
                        u8* pdata = (u8*) data;                 \
                        printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__);   \
@@ -623,20 +623,20 @@ do { if (ieee80211_debug_level & (level)) \
 #define MAX_STR_LEN     64
 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/
 #define PRINTABLE(_ch)  (_ch>'!' && _ch<'~')
-#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len)                                   \
-                       if((_Comp) & level)                                                     \
+#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len)                                   \
+                       if((_Comp) & level)                                                     \
                        {                                                                       \
                                int             __i;                                            \
-                               u8  buffer[MAX_STR_LEN];                                        \
-                               int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ;       \
-                               memset(buffer, 0, MAX_STR_LEN);                                 \
-                               memcpy(buffer, (u8 *)_Ptr, length );                            \
+                               u8  buffer[MAX_STR_LEN];                                        \
+                               int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ;       \
+                               memset(buffer, 0, MAX_STR_LEN);                                 \
+                               memcpy(buffer, (u8 *)_Ptr, length );                            \
                                for( __i=0; __i<MAX_STR_LEN; __i++ )                            \
                                {                                                               \
-                                    if( !PRINTABLE(buffer[__i]) )   buffer[__i] = '?';         \
+                                    if( !PRINTABLE(buffer[__i]) )   buffer[__i] = '?';         \
                                }                                                               \
                                buffer[length] = '\0';                                          \
-                               printk("Rtl819x: ");                                            \
+                               printk("Rtl819x: ");                                            \
                                printk(_TitleString);                                         \
                                printk(": %d, <%s>\n", _Len, buffer);                         \
                        }
@@ -785,12 +785,12 @@ enum ieee80211_reasoncode {
 #define IEEE80211_24GHZ_BAND     (1<<0)
 #define IEEE80211_52GHZ_BAND     (1<<1)
 
-#define IEEE80211_CCK_RATE_LEN                 4
+#define IEEE80211_CCK_RATE_LEN                 4
 #define IEEE80211_CCK_RATE_1MB                 0x02
 #define IEEE80211_CCK_RATE_2MB                 0x04
 #define IEEE80211_CCK_RATE_5MB                 0x0B
 #define IEEE80211_CCK_RATE_11MB                        0x16
-#define IEEE80211_OFDM_RATE_LEN                8
+#define IEEE80211_OFDM_RATE_LEN                        8
 #define IEEE80211_OFDM_RATE_6MB                        0x0C
 #define IEEE80211_OFDM_RATE_9MB                        0x12
 #define IEEE80211_OFDM_RATE_12MB               0x18
@@ -919,10 +919,10 @@ struct ieee80211_rx_stats {
        u16          fraglength;                        // FragLength should equal to PacketLength in non-fragment case
        u16          fragoffset;                        // Data offset for this fragment
        u16          ntotalfrag;
-       bool              bisrxaggrsubframe;
+       bool              bisrxaggrsubframe;
        bool              bPacketBeacon;        //cosa add for rssi
        bool              bToSelfBA;            //cosa add for rssi
-       char      cck_adc_pwdb[4];      //cosa add for rx path selection
+       char      cck_adc_pwdb[4];      //cosa add for rx path selection
        u16               Seq_Num;
 
 };
@@ -992,7 +992,7 @@ struct ieee80211_device;
 #define SEC_ALG_TKIP            2
 #define SEC_ALG_CCMP            3
 
-#define WEP_KEYS               4
+#define WEP_KEYS               4
 #define WEP_KEY_LEN            13
 #define SCM_KEY_LEN             32
 #define SCM_TEMPORAL_KEY_LENGTH 16
@@ -1205,7 +1205,7 @@ struct ieee80211_drv_agg_txb {
        struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
 }__attribute__((packed));
 
-#define MAX_SUBFRAME_COUNT               64
+#define MAX_SUBFRAME_COUNT               64
 struct ieee80211_rxb {
        u8 nr_subframes;
        struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
@@ -1534,7 +1534,7 @@ struct ieee80211_network {
        bool    bWithAironetIE;
        bool    bCkipSupported;
        bool    bCcxRmEnable;
-       u16     CcxRmState[2];
+       u16     CcxRmState[2];
        // CCXv4 S59, MBSSID.
        bool    bMBssidValid;
        u8      MBssidMask;
@@ -1655,8 +1655,7 @@ typedef struct tx_pending_t{
        struct ieee80211_txb *txb;
 }tx_pending_t;
 
-typedef struct _bandwidth_autoswitch
-{
+typedef struct _bandwidth_autoswitch {
        long threshold_20Mhzto40Mhz;
        long    threshold_40Mhzto20Mhz;
        bool bforced_tx20Mhz;
@@ -1668,8 +1667,7 @@ typedef struct _bandwidth_autoswitch
 
 #define REORDER_WIN_SIZE       128
 #define REORDER_ENTRY_NUM      128
-typedef struct _RX_REORDER_ENTRY
-{
+typedef struct _RX_REORDER_ENTRY {
        struct list_head        List;
        u16                     SeqNum;
        struct ieee80211_rxb* prxb;
@@ -1709,15 +1707,13 @@ typedef struct _IbssParms{
 #define MAX_NUM_RATES  264 // Max num of support rates element: 8,  Max num of ext. support rate: 255. 061122, by rcnjko.
 
 // RF state.
-typedef        enum _RT_RF_POWER_STATE
-{
+typedef        enum _RT_RF_POWER_STATE {
        eRfOn,
        eRfSleep,
        eRfOff
 }RT_RF_POWER_STATE;
 
-typedef struct _RT_POWER_SAVE_CONTROL
-{
+typedef struct _RT_POWER_SAVE_CONTROL {
 
        //
        // Inactive Power Save(IPS) : Disable RF when disconnected
@@ -1726,7 +1722,7 @@ typedef struct _RT_POWER_SAVE_CONTROL
        bool                            bIPSModeBackup;
        bool                            bSwRfProcessing;
        RT_RF_POWER_STATE       eInactivePowerState;
-       struct work_struct      InactivePsWorkItem;
+       struct work_struct      InactivePsWorkItem;
        struct timer_list       InactivePsTimer;
 
        // Return point for join action
@@ -1837,11 +1833,11 @@ struct ieee80211_device {
        u8                              HTHighestOperaRate;
        //wb added for rate operation mode to firmware
        u8      bTxDisableRateFallBack;
-       u8      bTxUseDriverAssingedRate;
+       u8      bTxUseDriverAssingedRate;
        atomic_t        atm_chnlop;
        atomic_t        atm_swbw;
 //     u8      HTHighestOperaRate;
-//     u8      HTCurrentOperaRate;
+//     u8      HTCurrentOperaRate;
 
        // 802.11e and WMM Traffic Stream Info (TX)
        struct list_head                Tx_TS_Admit_List;
@@ -2055,9 +2051,9 @@ struct ieee80211_device {
        bool    bdynamic_txpower_enable;
 
        bool bCTSToSelfEnable;
-       u8      CTSToSelfTH;
+       u8      CTSToSelfTH;
 
-       u32     fsync_time_interval;
+       u32     fsync_time_interval;
        u32     fsync_rate_bitmap;
        u8      fsync_rssi_threshold;
        bool    bfsync_enable;
@@ -2092,10 +2088,10 @@ struct ieee80211_device {
         struct delayed_work start_ibss_wq;
        struct work_struct wx_sync_scan_wq;
        struct workqueue_struct *wq;
-        // Qos related. Added by Annie, 2005-11-01.
-        //STA_QOS  StaQos;
+       // Qos related. Added by Annie, 2005-11-01.
+       //STA_QOS  StaQos;
 
-        //u32 STA_EDCA_PARAM[4];
+       //u32 STA_EDCA_PARAM[4];
        //CHANNEL_ACCESS_SETTING ChannelAccessSetting;
 
 
@@ -2111,11 +2107,11 @@ struct ieee80211_device {
                               struct net_device *dev);
 
        int (*reset_port)(struct net_device *dev);
-        int (*is_queue_full) (struct net_device * dev, int pri);
+       int (*is_queue_full) (struct net_device * dev, int pri);
 
-        int (*handle_management) (struct net_device * dev,
-                                  struct ieee80211_network * network, u16 type);
-        int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
+       int (*handle_management) (struct net_device * dev,
+                                 struct ieee80211_network * network, u16 type);
+       int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb);
 
        /* Softmac-generated frames (management) are TXed via this
         * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
@@ -2214,7 +2210,7 @@ struct ieee80211_device {
 #define IEEE_A            (1<<0)
 #define IEEE_B            (1<<1)
 #define IEEE_G            (1<<2)
-#define IEEE_N_24G               (1<<4)
+#define IEEE_N_24G               (1<<4)
 #define        IEEE_N_5G                 (1<<5)
 #define IEEE_MODE_MASK    (IEEE_A|IEEE_B|IEEE_G)
 
index 82d4bf6a86a5b8366552add6e9072843695906f1..76c56e5aed79cda4e648831b71ea81590da41482 100644 (file)
@@ -220,7 +220,7 @@ void free_ieee80211(struct net_device *dev)
 
 #ifdef CONFIG_IEEE80211_DEBUG
 
-u32 ieee80211_debug_level = 0;
+u32 ieee80211_debug_level;
 static int debug = \
        //                  IEEE80211_DL_INFO   |
        //                  IEEE80211_DL_WX     |
@@ -233,15 +233,15 @@ static int debug = \
        //                  IEEE80211_DL_TX     |
        //                  IEEE80211_DL_RX     |
                            //IEEE80211_DL_QOS    |
-       //                  IEEE80211_DL_HT     |
+       //                  IEEE80211_DL_HT     |
        //                  IEEE80211_DL_TS     |
-//                         IEEE80211_DL_BA     |
+//                         IEEE80211_DL_BA     |
        //                  IEEE80211_DL_REORDER|
 //                         IEEE80211_DL_TRACE  |
                            //IEEE80211_DL_DATA |
                            IEEE80211_DL_ERR      //awayls open this flags to show error out
                            ;
-struct proc_dir_entry *ieee80211_proc = NULL;
+struct proc_dir_entry *ieee80211_proc;
 
 static int show_debug_level(char *page, char **start, off_t offset,
                            int count, int *eof, void *data)
index e3cf7a45b90073d37dfa319699c12f93dc8acf4e..ee7ce5fca4628e35d6921625dfaecc95de676d4a 100644 (file)
@@ -52,7 +52,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
        u16 fc = le16_to_cpu(hdr->frame_ctl);
 
        skb->dev = ieee->dev;
-        skb_reset_mac_header(skb);
+       skb_reset_mac_header(skb);
 
        skb_pull(skb, ieee80211_get_hdrlen(fc));
        skb->pkt_type = PACKET_OTHERHOST;
@@ -218,16 +218,16 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
         * this is not mandatory.... but seems that the probe
         * response parser uses it
         */
-        struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data;
+       struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data;
 
        rx_stats->len = skb->len;
        ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
-        //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
-        if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
-        {
-                dev_kfree_skb_any(skb);
-                return 0;
-        }
+       //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
+       if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
+       {
+               dev_kfree_skb_any(skb);
+               return 0;
+       }
 
        ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
 
@@ -608,7 +608,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
                u16                     SeqNum)
 {
        PRT_HIGH_THROUGHPUT     pHTInfo = ieee->pHTInfo;
-       PRX_REORDER_ENTRY       pReorderEntry = NULL;
+       PRX_REORDER_ENTRY       pReorderEntry = NULL;
        struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE];
        u8                      WinSize = pHTInfo->RxReorderWinSize;
        u16                     WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096;
@@ -773,7 +773,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
 }
 
 u8 parse_subframe(struct sk_buff *skb,
-                  struct ieee80211_rx_stats *rx_stats,
+                 struct ieee80211_rx_stats *rx_stats,
                  struct ieee80211_rxb *rxb,u8* src,u8* dst)
 {
        struct ieee80211_hdr_3addr  *hdr = (struct ieee80211_hdr_3addr* )skb->data;
@@ -1043,7 +1043,7 @@ 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",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
-                       if(     (fc & (1<<11))  &&
+                       if(     (fc & (1<<11))  &&
                                        (frag == pRxTS->RxLastFragNum) &&
                                        (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum)   )
                        {
@@ -1154,8 +1154,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                                type, stype, skb->len);
                goto rx_dropped;
        }
-        if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
-                goto rx_dropped;
+       if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
+               goto rx_dropped;
 
        /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
 
@@ -1402,19 +1402,19 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
 * the right values
 */
 static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
-                                     *info_element, int sub_type)
+                                    *info_element, int sub_type)
 {
 
-        if (info_element->qui_subtype != sub_type)
-                return -1;
-        if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
-                return -1;
-        if (info_element->qui_type != QOS_OUI_TYPE)
-                return -1;
-        if (info_element->version != QOS_VERSION_1)
-                return -1;
+       if (info_element->qui_subtype != sub_type)
+               return -1;
+       if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
+               return -1;
+       if (info_element->qui_type != QOS_OUI_TYPE)
+               return -1;
+       if (info_element->version != QOS_VERSION_1)
+               return -1;
 
-        return 0;
+       return 0;
 }
 
 
@@ -1422,56 +1422,56 @@ static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
  * Parse a QoS parameter element
  */
 static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
-                                            *element_param, struct ieee80211_info_element
-                                            *info_element)
+                                           *element_param, struct ieee80211_info_element
+                                           *info_element)
 {
-        int ret = 0;
-        u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
-
-        if ((info_element == NULL) || (element_param == NULL))
-                return -1;
-
-        if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
-                memcpy(element_param->info_element.qui, info_element->data,
-                       info_element->len);
-                element_param->info_element.elementID = info_element->id;
-                element_param->info_element.length = info_element->len;
-        } else
-                ret = -1;
-        if (ret == 0)
-                ret = ieee80211_verify_qos_info(&element_param->info_element,
-                                                QOS_OUI_PARAM_SUB_TYPE);
-        return ret;
+       int ret = 0;
+       u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
+
+       if ((info_element == NULL) || (element_param == NULL))
+               return -1;
+
+       if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
+               memcpy(element_param->info_element.qui, info_element->data,
+                      info_element->len);
+               element_param->info_element.elementID = info_element->id;
+               element_param->info_element.length = info_element->len;
+       } else
+               ret = -1;
+       if (ret == 0)
+               ret = ieee80211_verify_qos_info(&element_param->info_element,
+                                               QOS_OUI_PARAM_SUB_TYPE);
+       return ret;
 }
 
 /*
  * Parse a QoS information element
  */
 static int ieee80211_read_qos_info_element(struct
-                                           ieee80211_qos_information_element
-                                           *element_info, struct ieee80211_info_element
-                                           *info_element)
+                                          ieee80211_qos_information_element
+                                          *element_info, struct ieee80211_info_element
+                                          *info_element)
 {
-        int ret = 0;
-        u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
-
-        if (element_info == NULL)
-                return -1;
-        if (info_element == NULL)
-                return -1;
-
-        if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
-                memcpy(element_info->qui, info_element->data,
-                       info_element->len);
-                element_info->elementID = info_element->id;
-                element_info->length = info_element->len;
-        } else
-                ret = -1;
-
-        if (ret == 0)
-                ret = ieee80211_verify_qos_info(element_info,
-                                                QOS_OUI_INFO_SUB_TYPE);
-        return ret;
+       int ret = 0;
+       u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
+
+       if (element_info == NULL)
+               return -1;
+       if (info_element == NULL)
+               return -1;
+
+       if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
+               memcpy(element_info->qui, info_element->data,
+                      info_element->len);
+               element_info->elementID = info_element->id;
+               element_info->length = info_element->len;
+       } else
+               ret = -1;
+
+       if (ret == 0)
+               ret = ieee80211_verify_qos_info(element_info,
+                                               QOS_OUI_INFO_SUB_TYPE);
+       return ret;
 }
 
 
@@ -1479,39 +1479,39 @@ static int ieee80211_read_qos_info_element(struct
  * Write QoS parameters from the ac parameters.
  */
 static int ieee80211_qos_convert_ac_to_parameters(struct
-                                                  ieee80211_qos_parameter_info
-                                                  *param_elm, struct
-                                                  ieee80211_qos_parameters
-                                                  *qos_param)
+                                                 ieee80211_qos_parameter_info
+                                                 *param_elm, struct
+                                                 ieee80211_qos_parameters
+                                                 *qos_param)
 {
-        int rc = 0;
-        int i;
-        struct ieee80211_qos_ac_parameter *ac_params;
+       int rc = 0;
+       int i;
+       struct ieee80211_qos_ac_parameter *ac_params;
        u8 aci;
-        //u8 cw_min;
-        //u8 cw_max;
+       //u8 cw_min;
+       //u8 cw_max;
 
-        for (i = 0; i < QOS_QUEUE_NUM; i++) {
-                ac_params = &(param_elm->ac_params_record[i]);
+       for (i = 0; i < QOS_QUEUE_NUM; i++) {
+               ac_params = &(param_elm->ac_params_record[i]);
 
                aci = (ac_params->aci_aifsn & 0x60) >> 5;
 
                if(aci >= QOS_QUEUE_NUM)
                        continue;
-                qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
+               qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
 
                /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
-                qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
+               qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
 
-                qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
+               qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
 
-                qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
+               qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
 
-                qos_param->flag[aci] =
-                    (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
-                qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
-        }
-        return rc;
+               qos_param->flag[aci] =
+                   (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
+               qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
+       }
+       return rc;
 }
 
 /*
@@ -1520,38 +1520,38 @@ static int ieee80211_qos_convert_ac_to_parameters(struct
  * which type to read
  */
 static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
-                                             *info_element,
-                                             struct ieee80211_network *network)
+                                            *info_element,
+                                            struct ieee80211_network *network)
 {
-        int rc = 0;
-        struct ieee80211_qos_parameters *qos_param = NULL;
-        struct ieee80211_qos_information_element qos_info_element;
-
-        rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
-
-        if (rc == 0) {
-                network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
-                network->flags |= NETWORK_HAS_QOS_INFORMATION;
-        } else {
-                struct ieee80211_qos_parameter_info param_element;
-
-                rc = ieee80211_read_qos_param_element(&param_element,
-                                                      info_element);
-                if (rc == 0) {
-                        qos_param = &(network->qos_data.parameters);
-                        ieee80211_qos_convert_ac_to_parameters(&param_element,
-                                                               qos_param);
-                        network->flags |= NETWORK_HAS_QOS_PARAMETERS;
-                        network->qos_data.param_count =
-                            param_element.info_element.ac_info & 0x0F;
-                }
-        }
-
-        if (rc == 0) {
-                IEEE80211_DEBUG_QOS("QoS is supported\n");
-                network->qos_data.supported = 1;
-        }
-        return rc;
+       int rc = 0;
+       struct ieee80211_qos_parameters *qos_param = NULL;
+       struct ieee80211_qos_information_element qos_info_element;
+
+       rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
+
+       if (rc == 0) {
+               network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
+               network->flags |= NETWORK_HAS_QOS_INFORMATION;
+       } else {
+               struct ieee80211_qos_parameter_info param_element;
+
+               rc = ieee80211_read_qos_param_element(&param_element,
+                                                     info_element);
+               if (rc == 0) {
+                       qos_param = &(network->qos_data.parameters);
+                       ieee80211_qos_convert_ac_to_parameters(&param_element,
+                                                              qos_param);
+                       network->flags |= NETWORK_HAS_QOS_PARAMETERS;
+                       network->qos_data.param_count =
+                           param_element.info_element.ac_info & 0x0F;
+               }
+       }
+
+       if (rc == 0) {
+               IEEE80211_DEBUG_QOS("QoS is supported\n");
+               network->qos_data.supported = 1;
+       }
+       return rc;
 }
 
 #ifdef CONFIG_IEEE80211_DEBUG
@@ -1559,37 +1559,37 @@ static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
 
 static const char *get_info_element_string(u16 id)
 {
-        switch (id) {
-                MFIE_STRING(SSID);
-                MFIE_STRING(RATES);
-                MFIE_STRING(FH_SET);
-                MFIE_STRING(DS_SET);
-                MFIE_STRING(CF_SET);
-                MFIE_STRING(TIM);
-                MFIE_STRING(IBSS_SET);
-                MFIE_STRING(COUNTRY);
-                MFIE_STRING(HOP_PARAMS);
-                MFIE_STRING(HOP_TABLE);
-                MFIE_STRING(REQUEST);
-                MFIE_STRING(CHALLENGE);
-                MFIE_STRING(POWER_CONSTRAINT);
-                MFIE_STRING(POWER_CAPABILITY);
-                MFIE_STRING(TPC_REQUEST);
-                MFIE_STRING(TPC_REPORT);
-                MFIE_STRING(SUPP_CHANNELS);
-                MFIE_STRING(CSA);
-                MFIE_STRING(MEASURE_REQUEST);
-                MFIE_STRING(MEASURE_REPORT);
-                MFIE_STRING(QUIET);
-                MFIE_STRING(IBSS_DFS);
-               // MFIE_STRING(ERP_INFO);
-                MFIE_STRING(RSN);
-                MFIE_STRING(RATES_EX);
-                MFIE_STRING(GENERIC);
-                MFIE_STRING(QOS_PARAMETER);
-        default:
-                return "UNKNOWN";
-        }
+       switch (id) {
+               MFIE_STRING(SSID);
+               MFIE_STRING(RATES);
+               MFIE_STRING(FH_SET);
+               MFIE_STRING(DS_SET);
+               MFIE_STRING(CF_SET);
+               MFIE_STRING(TIM);
+               MFIE_STRING(IBSS_SET);
+               MFIE_STRING(COUNTRY);
+               MFIE_STRING(HOP_PARAMS);
+               MFIE_STRING(HOP_TABLE);
+               MFIE_STRING(REQUEST);
+               MFIE_STRING(CHALLENGE);
+               MFIE_STRING(POWER_CONSTRAINT);
+               MFIE_STRING(POWER_CAPABILITY);
+               MFIE_STRING(TPC_REQUEST);
+               MFIE_STRING(TPC_REPORT);
+               MFIE_STRING(SUPP_CHANNELS);
+               MFIE_STRING(CSA);
+               MFIE_STRING(MEASURE_REQUEST);
+               MFIE_STRING(MEASURE_REPORT);
+               MFIE_STRING(QUIET);
+               MFIE_STRING(IBSS_DFS);
+              // MFIE_STRING(ERP_INFO);
+               MFIE_STRING(RSN);
+               MFIE_STRING(RATES_EX);
+               MFIE_STRING(GENERIC);
+               MFIE_STRING(QOS_PARAMETER);
+       default:
+               return "UNKNOWN";
+       }
 }
 #endif
 
@@ -1634,7 +1634,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 {
        u8 i;
        short offset;
-        u16    tmp_htcap_len=0;
+       u16     tmp_htcap_len=0;
        u16     tmp_htinfo_len=0;
        u16 ht_realtek_agg_len=0;
        u8  ht_realtek_agg_buf[MAX_IE_LEN];
@@ -1752,34 +1752,34 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                        network->tim.tim_count = info_element->data[0];
                        network->tim.tim_period = info_element->data[1];
 
-                        network->dtim_period = info_element->data[1];
-                        if(ieee->state != IEEE80211_LINKED)
-                                break;
+                       network->dtim_period = info_element->data[1];
+                       if(ieee->state != IEEE80211_LINKED)
+                               break;
 
-                        network->last_dtim_sta_time[0] = stats->mac_time[0];
-                        network->last_dtim_sta_time[1] = stats->mac_time[1];
+                       network->last_dtim_sta_time[0] = stats->mac_time[0];
+                       network->last_dtim_sta_time[1] = stats->mac_time[1];
 
-                        network->dtim_data = IEEE80211_DTIM_VALID;
+                       network->dtim_data = IEEE80211_DTIM_VALID;
 
-                        if(info_element->data[0] != 0)
-                                break;
+                       if(info_element->data[0] != 0)
+                               break;
 
-                        if(info_element->data[2] & 1)
-                                network->dtim_data |= IEEE80211_DTIM_MBCAST;
+                       if(info_element->data[2] & 1)
+                               network->dtim_data |= IEEE80211_DTIM_MBCAST;
 
-                        offset = (info_element->data[2] >> 1)*2;
+                       offset = (info_element->data[2] >> 1)*2;
 
-                        //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
+                       //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
 
-                        if(ieee->assoc_id < 8*offset ||
-                                ieee->assoc_id > 8*(offset + info_element->len -3))
+                       if(ieee->assoc_id < 8*offset ||
+                               ieee->assoc_id > 8*(offset + info_element->len -3))
 
-                                break;
+                               break;
 
-                        offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ;
+                       offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ;
 
-                        if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
-                                network->dtim_data |= IEEE80211_DTIM_UCAST;
+                       if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
+                               network->dtim_data |= IEEE80211_DTIM_UCAST;
 
                        //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
                        break;
@@ -1820,17 +1820,17 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                        }
 
 #ifdef THOMAS_TURBO
-                        if (info_element->len == 7 &&
-                            info_element->data[0] == 0x00 &&
-                            info_element->data[1] == 0xe0 &&
-                            info_element->data[2] == 0x4c &&
-                            info_element->data[3] == 0x01 &&
-                            info_element->data[4] == 0x02) {
-                                network->Turbo_Enable = 1;
-                        }
+                       if (info_element->len == 7 &&
+                           info_element->data[0] == 0x00 &&
+                           info_element->data[1] == 0xe0 &&
+                           info_element->data[2] == 0x4c &&
+                           info_element->data[3] == 0x01 &&
+                           info_element->data[4] == 0x02) {
+                               network->Turbo_Enable = 1;
+                       }
 #endif
 
-                        //for HTcap and HTinfo parameters
+                       //for HTcap and HTinfo parameters
                        if(tmp_htcap_len == 0){
                                if(info_element->len >= 4 &&
                                   info_element->data[0] == 0x00 &&
@@ -1839,12 +1839,12 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                   info_element->data[3] == 0x033){
 
                                                tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
-                                               if(tmp_htcap_len != 0){
-                                                       network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+                                               if(tmp_htcap_len != 0){
+                                                       network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
                                                        network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
                                                                sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
                                                        memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
-                                               }
+                                               }
                                }
                                if(tmp_htcap_len != 0)
                                        network->bssht.bdSupportHT = true;
@@ -1856,9 +1856,9 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                        if(tmp_htinfo_len == 0){
                                if(info_element->len >= 4 &&
                                        info_element->data[0] == 0x00 &&
-                                       info_element->data[1] == 0x90 &&
-                                       info_element->data[2] == 0x4c &&
-                                       info_element->data[3] == 0x034){
+                                       info_element->data[1] == 0x90 &&
+                                       info_element->data[2] == 0x4c &&
+                                       info_element->data[3] == 0x034){
 
                                                tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
                                                if(tmp_htinfo_len != 0){
@@ -2014,7 +2014,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                               network->rsn_ie_len);
                        break;
 
-                        //HT related element.
+                       //HT related element.
                case MFIE_TYPE_HT_CAP:
                        IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
                                             info_element->len);
@@ -2027,7 +2027,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 
                                //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
                                // windows driver will update WMM parameters each beacon received once connected
-                                // Linux driver is a bit different.
+                               // Linux driver is a bit different.
                                network->bssht.bdSupportHT = true;
                        }
                        else
@@ -2060,7 +2060,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                if(     (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC)   ||
                                        (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK)    )
                                {
-                                       network->bCkipSupported = true;
+                                       network->bCkipSupported = true;
                                }
                                else
                                {
@@ -2070,7 +2070,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                        else
                        {
                                network->bWithAironetIE = false;
-                               network->bCkipSupported = false;
+                               network->bCkipSupported = false;
                        }
                        break;
                case MFIE_TYPE_QOS_PARAMETER:
@@ -2189,10 +2189,10 @@ static inline int ieee80211_network_init(
        //char *p;
 #endif
 
-        network->qos_data.active = 0;
-        network->qos_data.supported = 0;
-        network->qos_data.param_count = 0;
-        network->qos_data.old_param_count = 0;
+       network->qos_data.active = 0;
+       network->qos_data.supported = 0;
+       network->qos_data.param_count = 0;
+       network->qos_data.old_param_count = 0;
 
        /* Pull out fixed field data */
        memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
@@ -2209,9 +2209,9 @@ static inline int ieee80211_network_init(
        network->flags = 0;
        network->atim_window = 0;
        network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
-            0x3 : 0x0;
+           0x3 : 0x0;
        network->berp_info_valid = false;
-        network->broadcom_cap_exist = false;
+       network->broadcom_cap_exist = false;
        network->ralink_cap_exist = false;
        network->atheros_cap_exist = false;
        network->cisco_cap_exist = false;
@@ -2230,12 +2230,12 @@ static inline int ieee80211_network_init(
        } else
                network->flags |= NETWORK_HAS_CCK;
 
-       network->wpa_ie_len = 0;
-       network->rsn_ie_len = 0;
+       network->wpa_ie_len = 0;
+       network->rsn_ie_len = 0;
 
-        if (ieee80211_parse_info_param
-            (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats))
-                return 1;
+       if (ieee80211_parse_info_param
+           (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats))
+               return 1;
 
        network->mode = 0;
        if (stats->freq == IEEE80211_52GHZ_BAND)
@@ -2329,7 +2329,7 @@ static inline void update_network(struct ieee80211_network *dst,
        dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
        memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters));
 
-        dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
+       dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
        dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
        dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen;
        memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen);
index 7a0707810fd02922ae772433e89414f54f1ad1ff..454f8895d211927efdda4334725f6047677f67c9 100644 (file)
@@ -498,7 +498,7 @@ void ieee80211_softmac_scan_wq(struct work_struct *work)
 {
        struct delayed_work *dwork = container_of(work, struct delayed_work, work);
        struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
-       static short watchdog = 0;
+       static short watchdog;
        u8 channel_map[MAX_CHANNEL_NUMBER+1];
        memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
        if(!ieee->ieee_up)
@@ -1948,166 +1948,166 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
 
        switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
 
-               case IEEE80211_STYPE_ASSOC_RESP:
-               case IEEE80211_STYPE_REASSOC_RESP:
-
-                       IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
-                                       WLAN_FC_GET_STYPE(header->frame_ctl));
-                       if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
-                               ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
-                               ieee->iw_mode == IW_MODE_INFRA){
-                               struct ieee80211_network network_resp;
-                               struct ieee80211_network *network = &network_resp;
-
-                               if (0 == (errcode=assoc_parse(ieee,skb, &aid))){
-                                       ieee->state=IEEE80211_LINKED;
-                                       ieee->assoc_id = aid;
-                                       ieee->softmac_stats.rx_ass_ok++;
-                                       /* station support qos */
-                                       /* Let the register setting defaultly with Legacy station */
-                                       if(ieee->qos_support) {
-                                               assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data;
-                                               memset(network, 0, sizeof(*network));
-                                               if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\
-                                                                       rx_stats->len - sizeof(*assoc_resp),\
-                                                                       network,rx_stats)){
-                                                       return 1;
-                                               }
-                                               else
-                                               {       //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network.
-                                                       memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen);
-                                                       memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen);
-                                               }
-                                               if (ieee->handle_assoc_response != NULL)
-                                                       ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network);
+       case IEEE80211_STYPE_ASSOC_RESP:
+       case IEEE80211_STYPE_REASSOC_RESP:
+
+               IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
+                               WLAN_FC_GET_STYPE(header->frame_ctl));
+               if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+                       ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
+                       ieee->iw_mode == IW_MODE_INFRA){
+                       struct ieee80211_network network_resp;
+                       struct ieee80211_network *network = &network_resp;
+
+                       if (0 == (errcode=assoc_parse(ieee,skb, &aid))){
+                               ieee->state=IEEE80211_LINKED;
+                               ieee->assoc_id = aid;
+                               ieee->softmac_stats.rx_ass_ok++;
+                               /* station support qos */
+                               /* Let the register setting defaultly with Legacy station */
+                               if(ieee->qos_support) {
+                                       assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data;
+                                       memset(network, 0, sizeof(*network));
+                                       if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\
+                                                               rx_stats->len - sizeof(*assoc_resp),\
+                                                               network,rx_stats)){
+                                               return 1;
                                        }
-                                       ieee80211_associate_complete(ieee);
-                               } else {
-                                       /* aid could not been allocated */
-                                       ieee->softmac_stats.rx_ass_err++;
-                                       printk(
-                                               "Association response status code 0x%x\n",
-                                               errcode);
-                                       IEEE80211_DEBUG_MGMT(
-                                               "Association response status code 0x%x\n",
-                                               errcode);
-                                       if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) {
-                                               queue_work(ieee->wq, &ieee->associate_procedure_wq);
-                                       } else {
-                                               ieee80211_associate_abort(ieee);
+                                       else
+                                       {       //filling the PeerHTCap. //maybe not necessary as we can get its info from current_network.
+                                               memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen);
+                                               memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen);
                                        }
+                                       if (ieee->handle_assoc_response != NULL)
+                                               ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame*)header, network);
+                               }
+                               ieee80211_associate_complete(ieee);
+                       } else {
+                               /* aid could not been allocated */
+                               ieee->softmac_stats.rx_ass_err++;
+                               printk(
+                                       "Association response status code 0x%x\n",
+                                       errcode);
+                               IEEE80211_DEBUG_MGMT(
+                                       "Association response status code 0x%x\n",
+                                       errcode);
+                               if(ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) {
+                                       queue_work(ieee->wq, &ieee->associate_procedure_wq);
+                               } else {
+                                       ieee80211_associate_abort(ieee);
                                }
                        }
-                       break;
+               }
+               break;
 
-               case IEEE80211_STYPE_ASSOC_REQ:
-               case IEEE80211_STYPE_REASSOC_REQ:
+       case IEEE80211_STYPE_ASSOC_REQ:
+       case IEEE80211_STYPE_REASSOC_REQ:
 
-                       if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
-                               ieee->iw_mode == IW_MODE_MASTER)
+               if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+                       ieee->iw_mode == IW_MODE_MASTER)
 
-                               ieee80211_rx_assoc_rq(ieee, skb);
-                       break;
+                       ieee80211_rx_assoc_rq(ieee, skb);
+               break;
 
-               case IEEE80211_STYPE_AUTH:
+       case IEEE80211_STYPE_AUTH:
 
-                       if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
-                               if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
-                               ieee->iw_mode == IW_MODE_INFRA){
+               if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
+                       if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
+                       ieee->iw_mode == IW_MODE_INFRA){
 
-                                               IEEE80211_DEBUG_MGMT("Received authentication response");
+                                       IEEE80211_DEBUG_MGMT("Received authentication response");
 
-                                               if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
-                                                       if(ieee->open_wep || !challenge){
-                                                               ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
-                                                               ieee->softmac_stats.rx_auth_rs_ok++;
-                                                               if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE))
+                                       if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
+                                               if(ieee->open_wep || !challenge){
+                                                       ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
+                                                       ieee->softmac_stats.rx_auth_rs_ok++;
+                                                       if(!(ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE))
+                                                       {
+                                                               if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
                                                                {
-                                                                       if (!ieee->GetNmodeSupportBySecCfg(ieee->dev))
+                                                                                       // WEP or TKIP encryption
+                                                                       if(IsHTHalfNmodeAPs(ieee))
                                                                        {
-                                                                                               // WEP or TKIP encryption
-                                                                               if(IsHTHalfNmodeAPs(ieee))
-                                                                               {
-                                                                                       bSupportNmode = true;
-                                                                                       bHalfSupportNmode = true;
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       bSupportNmode = false;
-                                                                                       bHalfSupportNmode = false;
-                                                                               }
-                                                                       printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode);
+                                                                               bSupportNmode = true;
+                                                                               bHalfSupportNmode = true;
                                                                        }
+                                                                       else
+                                                                       {
+                                                                               bSupportNmode = false;
+                                                                               bHalfSupportNmode = false;
+                                                                       }
+                                                               printk("==========>to link with AP using SEC(%d, %d)", bSupportNmode, bHalfSupportNmode);
                                                                }
-                                                               /* Dummy wirless mode setting to avoid encryption issue */
-                                                               if(bSupportNmode) {
-                                                                       //N mode setting
-                                                                       ieee->SetWirelessMode(ieee->dev, \
-                                                                                       ieee->current_network.mode);
-                                                               }else{
-                                                                       //b/g mode setting
-                                                                       /*TODO*/
-                                                                       ieee->SetWirelessMode(ieee->dev, IEEE_G);
-                                                               }
-
-                                                               if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true)
-                                                               {
-                                                                       printk("===============>entern half N mode\n");
-                                                                       ieee->bHalfWirelessN24GMode = true;
-                                                               }
-                                                               else
-                                                                       ieee->bHalfWirelessN24GMode = false;
-
-                                                               ieee80211_associate_step2(ieee);
+                                                       }
+                                                       /* Dummy wirless mode setting to avoid encryption issue */
+                                                       if(bSupportNmode) {
+                                                               //N mode setting
+                                                               ieee->SetWirelessMode(ieee->dev, \
+                                                                               ieee->current_network.mode);
                                                        }else{
-                                                               ieee80211_auth_challenge(ieee, challenge, chlen);
+                                                               //b/g mode setting
+                                                               /*TODO*/
+                                                               ieee->SetWirelessMode(ieee->dev, IEEE_G);
                                                        }
+
+                                                       if (ieee->current_network.mode == IEEE_N_24G && bHalfSupportNmode == true)
+                                                       {
+                                                               printk("===============>entern half N mode\n");
+                                                               ieee->bHalfWirelessN24GMode = true;
+                                                       }
+                                                       else
+                                                               ieee->bHalfWirelessN24GMode = false;
+
+                                                       ieee80211_associate_step2(ieee);
                                                }else{
-                                                       ieee->softmac_stats.rx_auth_rs_err++;
-                                                       IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode);
-                                                       ieee80211_associate_abort(ieee);
+                                                       ieee80211_auth_challenge(ieee, challenge, chlen);
                                                }
-
-                                       }else if (ieee->iw_mode == IW_MODE_MASTER){
-                                               ieee80211_rx_auth_rq(ieee, skb);
+                                       }else{
+                                               ieee->softmac_stats.rx_auth_rs_err++;
+                                               IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode);
+                                               ieee80211_associate_abort(ieee);
                                        }
+
+                               }else if (ieee->iw_mode == IW_MODE_MASTER){
+                                       ieee80211_rx_auth_rq(ieee, skb);
                                }
-                       break;
+                       }
+               break;
 
-               case IEEE80211_STYPE_PROBE_REQ:
+       case IEEE80211_STYPE_PROBE_REQ:
 
-                       if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
-                               ((ieee->iw_mode == IW_MODE_ADHOC ||
-                               ieee->iw_mode == IW_MODE_MASTER) &&
-                               ieee->state == IEEE80211_LINKED)){
-                               ieee80211_rx_probe_rq(ieee, skb);
-                       }
-                       break;
+               if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
+                       ((ieee->iw_mode == IW_MODE_ADHOC ||
+                       ieee->iw_mode == IW_MODE_MASTER) &&
+                       ieee->state == IEEE80211_LINKED)){
+                       ieee80211_rx_probe_rq(ieee, skb);
+               }
+               break;
 
-               case IEEE80211_STYPE_DISASSOC:
-               case IEEE80211_STYPE_DEAUTH:
-                       /* FIXME for now repeat all the association procedure
-                       * both for disassociation and deauthentication
-                       */
-                       if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
-                               ieee->state == IEEE80211_LINKED &&
-                               ieee->iw_mode == IW_MODE_INFRA){
-
-                               ieee->state = IEEE80211_ASSOCIATING;
-                               ieee->softmac_stats.reassoc++;
-
-                               notify_wx_assoc_event(ieee);
-                               //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
-                               RemovePeerTS(ieee, header->addr2);
-                               queue_work(ieee->wq, &ieee->associate_procedure_wq);
-                       }
-                       break;
-               case IEEE80211_STYPE_MANAGE_ACT:
-                       ieee80211_process_action(ieee,skb);
-                       break;
-               default:
-                       return -1;
-                       break;
+       case IEEE80211_STYPE_DISASSOC:
+       case IEEE80211_STYPE_DEAUTH:
+               /* FIXME for now repeat all the association procedure
+               * both for disassociation and deauthentication
+               */
+               if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
+                       ieee->state == IEEE80211_LINKED &&
+                       ieee->iw_mode == IW_MODE_INFRA){
+
+                       ieee->state = IEEE80211_ASSOCIATING;
+                       ieee->softmac_stats.reassoc++;
+
+                       notify_wx_assoc_event(ieee);
+                       //HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
+                       RemovePeerTS(ieee, header->addr2);
+                       queue_work(ieee->wq, &ieee->associate_procedure_wq);
+               }
+               break;
+       case IEEE80211_STYPE_MANAGE_ACT:
+               ieee80211_process_action(ieee,skb);
+               break;
+       default:
+               return -1;
+               break;
        }
 
        //dev_kfree_skb_any(skb);
@@ -2503,8 +2503,8 @@ void ieee80211_disassociate(struct ieee80211_device *ieee)
 }
 void ieee80211_associate_retry_wq(struct work_struct *work)
 {
-        struct delayed_work *dwork = container_of(work, struct delayed_work, work);
-        struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
+       struct delayed_work *dwork = container_of(work, struct delayed_work, work);
+       struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
        unsigned long flags;
 
        down(&ieee->wx_sem);
@@ -3124,7 +3124,7 @@ inline struct sk_buff *ieee80211_disassociate_skb(
 void
 SendDisassociation(
                struct ieee80211_device *ieee,
-               u8*                                     asSta,
+               u8*                                     asSta,
                u8                                              asRsn
 )
 {
index 421da8a076973d386bfa51f628f5464f8ad63758..45422db81488f8ddfe848376a55e26be16c9c247 100644 (file)
@@ -302,7 +302,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work)
        HT_EXTCHNL_OFFSET chan_offset=0;
        HT_CHANNEL_WIDTH bandwidth=0;
        int b40M = 0;
-       static int count = 0;
+       static int count;
        chan = ieee->current_network.channel;
        netif_carrier_off(ieee->dev);
 
index 3f5ceeb88b6cbcdf3da6b6fcd1c3a54648a2e57f..c39e680bb0ac2a2ec9df403f25280c9ca4d3488f 100644 (file)
@@ -70,7 +70,7 @@ val  | 0  |  0  |  0  |  1  |  x  |  0  |  0  |  0  |  1  |  0  |  x  |  x  |  x
 desc | ^-ver-^  |  ^type-^  |  ^-----subtype-----^  | to  |from |more |retry| pwr |more |wep   |
      |          |           | x=0 data,x=1 data+ack | DS  | DS  |frag |     | mgm |data |      |
      '-----------------------------------------------------------------------------------------'
-                                                   /\
+                                                    /\
                                                     |
 802.11 Data Frame                                   |
            ,--------- 'ctrl' expands to >-----------'
@@ -283,22 +283,22 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
 //     IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
        ip = ip_hdr(skb);
        switch (ip->tos & 0xfc) {
-               case 0x20:
-                       return 2;
-               case 0x40:
-                       return 1;
-               case 0x60:
-                       return 3;
-               case 0x80:
-                       return 4;
-               case 0xa0:
-                       return 5;
-               case 0xc0:
-                       return 6;
-               case 0xe0:
-                       return 7;
-               default:
-                       return 0;
+       case 0x20:
+               return 2;
+       case 0x40:
+               return 1;
+       case 0x60:
+               return 3;
+       case 0x80:
+               return 4;
+       case 0xa0:
+               return 5;
+       case 0xc0:
+               return 6;
+       case 0xe0:
+               return 7;
+       default:
+               return 0;
        }
 }
 
@@ -395,7 +395,7 @@ ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, cb_desc *tcb_desc)
 {
        PRT_HIGH_THROUGHPUT             pHTInfo = ieee->pHTInfo;
 
-       tcb_desc->bUseShortGI           = false;
+       tcb_desc->bUseShortGI           = false;
 
        if(!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
                return;
@@ -514,7 +514,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_
                        if(pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF)
                        {
                                tcb_desc->bCTSEnable    = true;
-                               tcb_desc->rts_rate  =   MGN_24M;
+                               tcb_desc->rts_rate  =   MGN_24M;
                                tcb_desc->bRTSEnable = true;
                                break;
                        }
@@ -527,7 +527,7 @@ void ieee80211_query_protectionmode(struct ieee80211_device* ieee, cb_desc* tcb_
        {
                tcb_desc->bCTSEnable    = true;
                tcb_desc->rts_rate = MGN_24M;
-               tcb_desc->bRTSEnable    = true;
+               tcb_desc->bRTSEnable    = true;
        }
        if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
                tcb_desc->bUseShortPreamble = true;
@@ -656,17 +656,17 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
                memcpy(&dest, skb->data, ETH_ALEN);
                memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
 
-                /* Advance the SKB to the start of the payload */
-                skb_pull(skb, sizeof(struct ethhdr));
+               /* Advance the SKB to the start of the payload */
+               skb_pull(skb, sizeof(struct ethhdr));
 
-                /* Determine total amount of storage required for TXB packets */
-                bytes = skb->len + SNAP_SIZE + sizeof(u16);
+               /* Determine total amount of storage required for TXB packets */
+               bytes = skb->len + SNAP_SIZE + sizeof(u16);
 
                if (encrypt)
                        fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_WEP;
                else
 
-                        fc = IEEE80211_FTYPE_DATA;
+                       fc = IEEE80211_FTYPE_DATA;
 
                //if(ieee->current_network.QoS_Enable)
                if(qos_actived)
@@ -689,7 +689,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
                        memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
                }
 
-                header.frame_ctl = cpu_to_le16(fc);
+               header.frame_ctl = cpu_to_le16(fc);
 
                /* Determine fragmentation size based on destination (multicast
                * and broadcast are not fragmented) */
@@ -833,7 +833,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
                  else
                        ieee->seq_ctrl[UP2AC(skb->priority) + 1]++;
                } else {
-                 if (ieee->seq_ctrl[0] == 0xFFF)
+                 if (ieee->seq_ctrl[0] == 0xFFF)
                        ieee->seq_ctrl[0] = 0;
                  else
                        ieee->seq_ctrl[0]++;
index f0ba7f467493770ce4e59ec7125051e6e00d5529..e1fe54acb4b8b97cabc77e07c89c6954682b586c 100644 (file)
@@ -761,7 +761,7 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
        case IW_MLME_DISASSOC:
                ieee80211_disassociate(ieee);
                break;
-        default:
+       default:
                return -EOPNOTSUPP;
        }
        return 0;
index bebe13ac53b71629e03675dad5c28e433c8b60bd..6f54cfe8a4679c28829bf2ed3e8190ab812a92d9 100644 (file)
@@ -79,4 +79,3 @@ void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
 void crypto_exit_compress_ops(struct crypto_tfm *tfm);
 
 #endif /* _CRYPTO_INTERNAL_H */
-
index 8ddc8bf9dc268332b43bf47b152411fe0ff31b48..2c398ca9a8ac6f29327e341050e52c73b400330f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _BATYPE_H_
 #define _BATYPE_H_
 
-#define        TOTAL_TXBA_NUM  16
+#define                TOTAL_TXBA_NUM  16
 #define        TOTAL_RXBA_NUM  16
 
 #define        BA_SETUP_TIMEOUT        200
@@ -28,8 +28,7 @@ struct ieee80211_ADDBA_Req{
 //Is this need?I put here just to make it easier to define structure BA_RECORD //WB
 typedef union _SEQUENCE_CONTROL{
        u16 ShortData;
-       struct
-       {
+       struct {
                u16     FragNum:4;
                u16     SeqNum:12;
        }field;
@@ -66,4 +65,3 @@ typedef struct _BA_RECORD {
 } BA_RECORD, *PBA_RECORD;
 
 #endif //end _BATYPE_H_
-
index 1ebea3daea2dbad2cd4a114528bba9fa6bd75159..69735d3203158f2ea1bbc537b24e4d3db9c990ca 100644 (file)
@@ -9,8 +9,8 @@
 
 /********************************************************************************************************************
  *function:  Activate BA entry. And if Time is nozero, start timer.
- *   input:  PBA_RECORD                pBA  //BA entry to be enabled
- *          u16                        Time //indicate time delay.
+ *   input:  PBA_RECORD                        pBA  //BA entry to be enabled
+ *          u16                        Time //indicate time delay.
  *  output:  none
 ********************************************************************************************************************/
 void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
@@ -22,7 +22,7 @@ void ActivateBAEntry(struct ieee80211_device* ieee, PBA_RECORD pBA, u16 Time)
 
 /********************************************************************************************************************
  *function:  deactivate BA entry, including its timer.
- *   input:  PBA_RECORD                pBA  //BA entry to be disabled
+ *   input:  PBA_RECORD                        pBA  //BA entry to be disabled
  *  output:  none
 ********************************************************************************************************************/
 void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
@@ -33,7 +33,7 @@ void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
 /********************************************************************************************************************
  *function: deactivete BA entry in Tx Ts, and send DELBA.
  *   input:
- *          PTX_TS_RECORD              pTxTs //Tx Ts which is to deactivate BA entry.
+ *          PTX_TS_RECORD              pTxTs //Tx Ts which is to deactivate BA entry.
  *  output:  none
  *  notice:  As PTX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME
 ********************************************************************************************************************/
@@ -63,7 +63,7 @@ u8 TxTsDeleteBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTxTs)
 /********************************************************************************************************************
  *function: deactivete BA entry in Tx Ts, and send DELBA.
  *   input:
- *          PRX_TS_RECORD              pRxTs //Rx Ts which is to deactivate BA entry.
+ *          PRX_TS_RECORD              pRxTs //Rx Ts which is to deactivate BA entry.
  *  output:  none
  *  notice:  As PRX_TS_RECORD structure will be defined in QOS, so wait to be merged. //FIXME, same with above
 ********************************************************************************************************************/
@@ -84,7 +84,7 @@ u8 RxTsDeleteBA( struct ieee80211_device* ieee, PRX_TS_RECORD pRxTs)
 /********************************************************************************************************************
  *function: reset BA entry
  *   input:
- *          PBA_RECORD         pBA //entry to be reset
+ *          PBA_RECORD         pBA //entry to be reset
  *  output:  none
 ********************************************************************************************************************/
 void ResetBaEntry( PBA_RECORD pBA)
@@ -98,12 +98,12 @@ void ResetBaEntry( PBA_RECORD pBA)
 //These functions need porting here or not?
 /*******************************************************************************************************************************
  *function:  construct ADDBAREQ and ADDBARSP frame here together.
- *   input:  u8*               Dst     //ADDBA frame's destination
- *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA.
- *          u16                StatusCode  //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
- *          u8                 type    //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
+ *   input:  u8*               Dst     //ADDBA frame's destination
+ *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA.
+ *          u16                StatusCode  //status code in RSP and I will use it to indicate whether it's RSP or REQ(will I?)
+ *          u8                 type    //indicate whether it's RSP(ACT_ADDBARSP) ow REQ(ACT_ADDBAREQ)
  *  output:  none
- *  return:  sk_buff*          skb     //return constructed skb to xmit
+ *  return:  sk_buff*          skb     //return constructed skb to xmit
 *******************************************************************************************************************************/
 static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
 {
@@ -126,7 +126,7 @@ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, P
                return NULL;
        }
 
-       memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr));      //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
+       memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr));      //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
        skb_reserve(skb, ieee->tx_headroom);
 
        BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
@@ -177,12 +177,12 @@ static struct sk_buff* ieee80211_ADDBA(struct ieee80211_device* ieee, u8* Dst, P
 
 /********************************************************************************************************************
  *function:  construct DELBA frame
- *   input:  u8*               dst     //DELBA frame's destination
- *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
- *          TR_SELECT          TxRxSelect  //TX RX direction
- *          u16                ReasonCode  //status code.
+ *   input:  u8*               dst     //DELBA frame's destination
+ *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
+ *          TR_SELECT          TxRxSelect  //TX RX direction
+ *          u16                ReasonCode  //status code.
  *  output:  none
- *  return:  sk_buff*          skb     //return constructed skb to xmit
+ *  return:  sk_buff*          skb     //return constructed skb to xmit
 ********************************************************************************************************************/
 static struct sk_buff* ieee80211_DELBA(
        struct ieee80211_device* ieee,
@@ -246,8 +246,8 @@ static struct sk_buff* ieee80211_DELBA(
 
 /********************************************************************************************************************
  *function: send ADDBAReq frame out
- *   input:  u8*               dst     //ADDBAReq frame's destination
- *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
+ *   input:  u8*               dst     //ADDBAReq frame's destination
+ *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
  *  output:  none
  *  notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
 ********************************************************************************************************************/
@@ -272,9 +272,9 @@ void ieee80211_send_ADDBAReq(struct ieee80211_device* ieee, u8*     dst, PBA_RECORD
 
 /********************************************************************************************************************
  *function: send ADDBARSP frame out
- *   input:  u8*               dst     //DELBA frame's destination
- *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
- *          u16                StatusCode //RSP StatusCode
+ *   input:  u8*               dst     //DELBA frame's destination
+ *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
+ *          u16                StatusCode //RSP StatusCode
  *  output:  none
  *  notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
 ********************************************************************************************************************/
@@ -297,10 +297,10 @@ void ieee80211_send_ADDBARsp(struct ieee80211_device* ieee, u8* dst, PBA_RECORD
 }
 /********************************************************************************************************************
  *function: send ADDBARSP frame out
- *   input:  u8*               dst     //DELBA frame's destination
- *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
- *          TR_SELECT          TxRxSelect //TX or RX
- *          u16                ReasonCode //DEL ReasonCode
+ *   input:  u8*               dst     //DELBA frame's destination
+ *          PBA_RECORD         pBA     //BA_RECORD entry which stores the necessary information for BA
+ *          TR_SELECT          TxRxSelect //TX or RX
+ *          u16                ReasonCode //DEL ReasonCode
  *  output:  none
  *  notice: If any possible, please hide pBA in ieee. And temporarily use Manage Queue as softmac_mgmt_xmit() usually does
 ********************************************************************************************************************/
@@ -340,7 +340,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
 
@@ -439,7 +439,7 @@ int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
        rsp = ( struct ieee80211_hdr_3addr*)skb->data;
@@ -569,7 +569,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 6));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 6));
                return -1;
        }
 
@@ -589,7 +589,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
 
        if(pDelBaParamSet->field.Initiator == 1)
        {
-               PRX_TS_RECORD   pRxTs;
+               PRX_TS_RECORD   pRxTs;
 
                if( !GetTs(
                                ieee,
@@ -657,7 +657,7 @@ TsInitAddBA(
        // BufferSize: This need to be set according to A-MPDU vector
        pBA->BaParamSet.field.BufferSize = 32;          // BufferSize: This need to be set according to A-MPDU vector
        pBA->BaTimeoutValue = 0;                                        // Timeout value: Set 0 to disable Timer
-       pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096;  // Block Ack will start after 3 packets later.
+       pBA->BaStartSeqCtrl.field.SeqNum = (pTS->TxCurSeq + 3) % 4096;  // Block Ack will start after 3 packets later.
 
        ActivateBAEntry(ieee, pBA, BA_SETUP_TIMEOUT);
 
@@ -734,4 +734,3 @@ void RxBaInactTimeout(unsigned long data)
                DELBA_REASON_TIMEOUT);
        return ;
 }
-
index a60b39cdb4723c1972220dfe4a6e6d541517ffaf..2b8283534be49d8b8a2b3f5063961244a2d00ae0 100644 (file)
@@ -121,7 +121,7 @@ typedef     union _HT_CAPABILITY_MACPARA{
 
 typedef enum _HT_ACTION{
        ACT_RECOMMAND_WIDTH             = 0,
-       ACT_MIMO_PWR_SAVE               = 1,
+       ACT_MIMO_PWR_SAVE               = 1,
        ACT_PSMP                                        = 2,
        ACT_SET_PCO_PHASE               = 3,
        ACT_MIMO_CHL_MEASURE    = 4,
@@ -398,9 +398,9 @@ typedef struct _BSS_HT{
 typedef struct _MIMO_RSSI{
        u32     EnableAntenna;
        u32     AntennaA;
-       u32     AntennaB;
-       u32     AntennaC;
-       u32     AntennaD;
+       u32     AntennaB;
+       u32     AntennaC;
+       u32     AntennaD;
        u32     Average;
 }MIMO_RSSI, *PMIMO_RSSI;
 
@@ -436,11 +436,11 @@ extern u8 MCS_FILTER_1SS[16];
 
 
 // MCS Bw 40 {1~7, 12~15,32}
-#define        RATE_ADPT_1SS_MASK              0xFF
+#define        RATE_ADPT_1SS_MASK              0xFF
 #define        RATE_ADPT_2SS_MASK              0xF0 //Skip MCS8~11 because mcs7 > mcs6, 9, 10, 11. 2007.01.16 by Emily
 #define        RATE_ADPT_MCS32_MASK            0x01
 
-#define        IS_11N_MCS_RATE(rate)           (rate&0x80)
+#define                IS_11N_MCS_RATE(rate)           (rate&0x80)
 
 typedef enum _HT_AGGRE_SIZE{
        HT_AGG_SIZE_8K = 0,
@@ -478,4 +478,3 @@ typedef enum _HT_IOT_ACTION{
 }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
 
 #endif //_RTL819XU_HTTYPE_H_
-
index ebb523904edc1ce527113995e2e1ee4c85253246..268b270e94956af704494073dbd792d8f812f5ce 100644 (file)
@@ -21,7 +21,7 @@ u16 MCS_DATA_RATE[2][2][77] =
                        81, 162, 243, 324, 486, 648, 729, 810, 108, 216, 324, 432, 648, 864, 972, 1080,
                        12, 162, 216, 270, 243, 324, 405, 216, 270, 270, 324, 378, 378, 432, 324, 405,
                        405, 486, 567, 567, 648, 270, 324, 378, 324, 378, 432, 486, 432, 486, 540, 540,
-                       594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891},       // Long GI, 40MHz
+                       594, 405, 486, 567, 486, 567, 648, 729, 648, 729, 810, 810, 891},       // Long GI, 40MHz
                        {30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
                        90, 180, 270, 360, 540, 720, 810, 900, 120, 240, 360, 480, 720, 960, 1080, 1200,
                        13, 180, 240, 300, 270, 360, 450, 240, 300, 300, 360, 420, 420, 480, 360, 450,
@@ -88,7 +88,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
        ieee->bTxDisableRateFallBack = 0;
        ieee->bTxUseDriverAssingedRate = 0;
 
-#ifdef         TO_DO_LIST
+#ifdef TO_DO_LIST
        // 8190 only. Assign duration operation mode to firmware
        pMgntInfo->bTxEnableFwCalcDur = (BOOLEAN)pNdisCommon->bRegTxEnableFwCalcDur;
 #endif
@@ -116,7 +116,7 @@ void HTUpdateDefaultSetting(struct ieee80211_device* ieee)
 /********************************************************************************************************************
  *function:  This function print out each field on HT capability IE mainly from (Beacon/ProbeRsp/AssocReq)
  *   input:  u8*       CapIE       //Capability IE to be printed out
- *          u8*        TitleString //mainly print out caller function
+ *          u8*        TitleString //mainly print out caller function
  *  output:  none
  *  return:  none
  *  notice:  Driver should not print out this message by default.
@@ -125,7 +125,7 @@ void HTDebugHTCapability(u8* CapIE, u8* TitleString )
 {
 
        static u8       EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};       // For 11n EWC definition, 2007.07.17, by Emily
-       PHT_CAPABILITY_ELE              pCapELE;
+       PHT_CAPABILITY_ELE              pCapELE;
 
        if(!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap)))
        {
@@ -153,7 +153,7 @@ void HTDebugHTCapability(u8* CapIE, u8* TitleString )
 /********************************************************************************************************************
  *function:  This function print out each field on HT Information IE mainly from (Beacon/ProbeRsp)
  *   input:  u8*       InfoIE       //Capability IE to be printed out
- *          u8*        TitleString //mainly print out caller function
+ *          u8*        TitleString //mainly print out caller function
  *  output:  none
  *  return:  none
  *  notice:  Driver should not print out this message by default.
@@ -217,7 +217,7 @@ void HTDebugHTInfo(u8*      InfoIE, u8* TitleString)
 }
 
 /*
-*      Return:         true if station in half n mode and AP supports 40 bw
+*      Return:         true if station in half n mode and AP supports 40 bw
 */
 bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
 {
@@ -228,7 +228,7 @@ bool IsHTHalfNmode40Bandwidth(struct ieee80211_device* ieee)
                retValue = false;
        else if(pHTInfo->bRegBW40MHz == false)  // station supports 40 bw
                retValue = false;
-       else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))      // station in half n mode
+       else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))      // station in half n mode
                retValue = false;
        else if(((PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf))->ChlWidth) // ap support 40 bw
                retValue = true;
@@ -245,7 +245,7 @@ bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
 
        if(pHTInfo->bCurrentHTSupport == false )        // wireless is n mode
                retValue = false;
-       else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))      // station in half n mode
+       else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))      // station in half n mode
                retValue = false;
        else if(is40MHz) // ap support 40 bw
        {
@@ -265,7 +265,7 @@ bool IsHTHalfNmodeSGI(struct ieee80211_device* ieee, bool is40MHz)
        return retValue;
 }
 
-u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee,         u8      nMcsRate)
+u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8      nMcsRate)
 {
 
        u8      is40MHz;
@@ -291,8 +291,8 @@ u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate)
 
 /********************************************************************************************************************
  *function:  This function returns current datarate.
- *   input:  struct ieee80211_device*  ieee
- *          u8                         nDataRate
+ *   input:  struct ieee80211_device*  ieee
+ *          u8                         nDataRate
  *  output:  none
  *  return:  tx rate
  *  notice:  quite unsure about how to use this function //wb
@@ -371,7 +371,7 @@ bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee)
 
 /********************************************************************************************************************
  *function:  This function returns peer IOT.
- *   input:  struct ieee80211_device*  ieee
+ *   input:  struct ieee80211_device*  ieee
  *  output:  none
  *  return:
  *  notice:
@@ -408,8 +408,8 @@ void HTIOTPeerDetermine(struct ieee80211_device* ieee)
 /********************************************************************************************************************
  *function:  Check whether driver should declare received rate up to MCS13 only since some chipset is not good
  *          at receiving MCS14~15 frame from some AP.
- *   input:  struct ieee80211_device*  ieee
- *          u8 *                       PeerMacAddr
+ *   input:  struct ieee80211_device*  ieee
+ *          u8 *                       PeerMacAddr
  *  output:  none
  *  return:  return 1 if driver should declare MCS13 only(otherwise return 0)
   * *****************************************************************************************************************/
@@ -429,7 +429,7 @@ u8 HTIOTActIsDisableMCS14(struct ieee80211_device* ieee, u8* PeerMacAddr)
 *                      PADAPTER                Adapter,
 *
 * Output:              None
-* Return:      true if driver should disable MCS15
+* Return:      true if driver should disable MCS15
 * 2008.04.15   Emily
 */
 bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
@@ -466,7 +466,7 @@ bool HTIOTActIsDisableMCS15(struct ieee80211_device* ieee)
 *                      PADAPTER                Adapter,
 *
 * Output:              None
-* Return:      true if driver should disable all two spatial stream packet
+* Return:      true if driver should disable all two spatial stream packet
 * 2008.04.21   Emily
 */
 bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *PeerMacAddr)
@@ -481,12 +481,12 @@ bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device* ieee, u8 *Pee
 
 /********************************************************************************************************************
  *function:  Check whether driver should disable EDCA turbo mode
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        PeerMacAddr
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        PeerMacAddr
  *  output:  none
  *  return:  return 1 if driver should disable EDCA turbo mode(otherwise return 0)
   * *****************************************************************************************************************/
-u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device*         ieee, u8* PeerMacAddr)
+u8 HTIOTActIsDisableEDCATurbo(struct ieee80211_device* ieee, u8* PeerMacAddr)
 {
        u8      retValue = false;       // default enable EDCA Turbo mode.
        // Set specific EDCA parameter for different AP in DM handler.
@@ -539,10 +539,10 @@ void HTResetIOTSetting(
 
 /********************************************************************************************************************
  *function:  Construct Capablility Element in Beacon... if HTEnable is turned on
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        posHTCap //pointer to store Capability Ele
- *          u8*                        len //store length of CE
- *          u8                         IsEncrypt //whether encrypt, needed further
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        posHTCap //pointer to store Capability Ele
+ *          u8*                        len //store length of CE
+ *          u8                         IsEncrypt //whether encrypt, needed further
  *  output:  none
  *  return:  none
  *  notice:  posHTCap can't be null and should be initialized before.
@@ -550,7 +550,7 @@ void HTResetIOTSetting(
 void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 IsEncrypt)
 {
        PRT_HIGH_THROUGHPUT     pHT = ieee->pHTInfo;
-       PHT_CAPABILITY_ELE      pCapELE = NULL;
+       PHT_CAPABILITY_ELE      pCapELE = NULL;
        //u8 bIsDeclareMCS13;
 
        if ((posHTCap == NULL) || (pHT == NULL))
@@ -571,7 +571,7 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u
 
 
        //HT capability info
-       pCapELE->AdvCoding              = 0; // This feature is not supported now!!
+       pCapELE->AdvCoding              = 0; // This feature is not supported now!!
        if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
        {
                pCapELE->ChlWidth = 0;
@@ -581,18 +581,18 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u
                pCapELE->ChlWidth = (pHT->bRegBW40MHz?1:0);
        }
 
-//     pCapELE->ChlWidth               = (pHT->bRegBW40MHz?1:0);
-       pCapELE->MimoPwrSave            = pHT->SelfMimoPs;
+//     pCapELE->ChlWidth               = (pHT->bRegBW40MHz?1:0);
+       pCapELE->MimoPwrSave            = pHT->SelfMimoPs;
        pCapELE->GreenField             = 0; // This feature is not supported now!!
        pCapELE->ShortGI20Mhz           = 1; // We can receive Short GI!!
        pCapELE->ShortGI40Mhz           = 1; // We can receive Short GI!!
        //DbgPrint("TX HT cap/info ele BW=%d SG20=%d SG40=%d\n\r",
                //pCapELE->ChlWidth, pCapELE->ShortGI20Mhz, pCapELE->ShortGI40Mhz);
-       pCapELE->TxSTBC                 = 1;
-       pCapELE->RxSTBC                 = 0;
+       pCapELE->TxSTBC                 = 1;
+       pCapELE->RxSTBC                 = 0;
        pCapELE->DelayBA                = 0;    // Do not support now!!
        pCapELE->MaxAMSDUSize   = (MAX_RECEIVE_BUFFER_SIZE>=7935)?1:0;
-       pCapELE->DssCCk                 = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
+       pCapELE->DssCCk                 = ((pHT->bRegBW40MHz)?(pHT->bRegSuppCCK?1:0):0);
        pCapELE->PSMP                   = 0; // Do not support now!!
        pCapELE->LSigTxopProtect        = 0; // Do not support now!!
 
@@ -603,13 +603,13 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u
 
        if( IsEncrypt)
        {
-               pCapELE->MPDUDensity    = 7; // 8us
-               pCapELE->MaxRxAMPDUFactor       = 2; // 2 is for 32 K and 3 is 64K
+               pCapELE->MPDUDensity    = 7; // 8us
+               pCapELE->MaxRxAMPDUFactor       = 2; // 2 is for 32 K and 3 is 64K
        }
        else
        {
-               pCapELE->MaxRxAMPDUFactor       = 3; // 2 is for 32 K and 3 is 64K
-               pCapELE->MPDUDensity    = 0; // no density
+               pCapELE->MaxRxAMPDUFactor       = 3; // 2 is for 32 K and 3 is 64K
+               pCapELE->MPDUDensity    = 0; // no density
        }
 
        //Supported MCS set
@@ -658,10 +658,10 @@ void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u
 }
 /********************************************************************************************************************
  *function:  Construct  Information Element in Beacon... if HTEnable is turned on
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        posHTCap //pointer to store Information Ele
- *          u8*                        len   //store len of
- *          u8                         IsEncrypt //whether encrypt, needed further
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        posHTCap //pointer to store Information Ele
+ *          u8*                        len   //store len of
+ *          u8                         IsEncrypt //whether encrypt, needed further
  *  output:  none
  *  return:  none
  *  notice:  posHTCap can't be null and be initialized before. only AP and IBSS sta should do this
@@ -679,12 +679,12 @@ void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* le
        memset(posHTInfo, 0, *len);
        if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported
        {
-               pHTInfoEle->ControlChl                  = ieee->current_network.channel;
-               pHTInfoEle->ExtChlOffset                        = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
+               pHTInfoEle->ControlChl                  = ieee->current_network.channel;
+               pHTInfoEle->ExtChlOffset                        = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT:
                                                                                        (ieee->current_network.channel<=6)?
                                                                                                HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER);
                pHTInfoEle->RecommemdedTxWidth  = pHT->bRegBW40MHz;
-               pHTInfoEle->RIFS                                        = 0;
+               pHTInfoEle->RIFS                                        = 0;
                pHTInfoEle->PSMPAccessOnly              = 0;
                pHTInfoEle->SrvIntGranularity           = 0;
                pHTInfoEle->OptMode                             = pHT->CurrentOpMode;
@@ -723,17 +723,17 @@ void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* le
   *  Element ID                Length          OUI                     Type1           Reserved
   *  1 byte                    1 byte          3 bytes         1 byte          1 byte
   *
-  *  OUI               = 0x00, 0xe0, 0x4c,
-  *  Type      = 0x02
-  *  Reserved  = 0x00
+  *  OUI               = 0x00, 0xe0, 0x4c,
+  *  Type      = 0x02
+  *  Reserved  = 0x00
   *
   *  2007.8.21 by Emily
 */
 /********************************************************************************************************************
  *function:  Construct  Information Element in Beacon... in RT2RT condition
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        posRT2RTAgg //pointer to store Information Ele
- *          u8*                        len   //store len
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        posRT2RTAgg //pointer to store Information Ele
+ *          u8*                        len   //store len
  *  output:  none
  *  return:  none
  *  notice:
@@ -787,8 +787,8 @@ void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg,
 
 /********************************************************************************************************************
  *function:  Pick the right Rate Adaptive table to use
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        pOperateMCS //A pointer to MCS rate bitmap
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        pOperateMCS //A pointer to MCS rate bitmap
  *  return:  always we return true
  *  notice:
   * *****************************************************************************************************************/
@@ -840,7 +840,7 @@ u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
 *      Description:
 *              This function will get the highest speed rate in input MCS set.
 *
-*      /param  Adapter                 Pionter to Adapter entity
+*      /param  Adapter                 Pionter to Adapter entity
 *                      pMCSRateSet             Pointer to MCS rate bitmap
 *                      pMCSFilter              Pointer to MCS rate filter
 *
@@ -849,9 +849,9 @@ u8 HT_PickMCSRate(struct ieee80211_device* ieee, u8* pOperateMCS)
 */
 /********************************************************************************************************************
  *function:  This function will get the highest speed rate in input MCS set.
- *   input:  struct ieee80211_device*  ieee
- *          u8*                        pMCSRateSet //Pointer to MCS rate bitmap
- *          u8*                        pMCSFilter //Pointer to MCS rate filter
+ *   input:  struct ieee80211_device*  ieee
+ *          u8*                        pMCSRateSet //Pointer to MCS rate bitmap
+ *          u8*                        pMCSFilter //Pointer to MCS rate filter
  *  return:  Highest MCS rate included in pMCSRateSet and filtered by pMCSFilter
  *  notice:
   * *****************************************************************************************************************/
@@ -1062,7 +1062,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
        else
                pHTInfo->CurrentMPDUDensity = pPeerHTCap->MPDUDensity;
        if(ieee->pairwise_key_type != KEY_TYPE_NA )
-               pHTInfo->CurrentMPDUDensity     = 7; // 8us
+               pHTInfo->CurrentMPDUDensity     = 7; // 8us
        // Force TX AMSDU
 
        // Lanhsin: mark for tmp to avoid deauth by ap from  s3
@@ -1118,7 +1118,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 void HTSetConnectBwModeCallback(struct ieee80211_device* ieee);
 /********************************************************************************************************************
  *function:  initialize HT info(struct PRT_HIGH_THROUGHPUT)
- *   input:  struct ieee80211_device*  ieee
+ *   input:  struct ieee80211_device*  ieee
  *  output:  none
  *  return:  none
  *  notice: This function is called when *  (1) MPInitialization Phase *  (2) Receiving of Deauthentication from AP
@@ -1208,13 +1208,13 @@ void HTInitializeBssDesc(PBSS_HT pBssHT)
 }
 /********************************************************************************************************************
  *function:  initialize Bss HT structure(struct PBSS_HT)
- *   input:  struct ieee80211_device   *ieee
- *          struct ieee80211_network   *pNetwork //usually current network we are live in
+ *   input:  struct ieee80211_device   *ieee
+ *          struct ieee80211_network   *pNetwork //usually current network we are live in
  *  output:  none
  *  return:  none
  *  notice: This function should ONLY be called before association
 ********************************************************************************************************************/
-void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee,      struct ieee80211_network * pNetwork)
+void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee,      struct ieee80211_network * pNetwork)
 {
        PRT_HIGH_THROUGHPUT             pHTInfo = ieee->pHTInfo;
 //     u16                                             nMaxAMSDUSize;
@@ -1235,7 +1235,7 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee,         struct ieee80
                pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
 
                // Save HTCap and HTInfo information Element
-               if(pNetwork->bssht.bdHTCapLen > 0 &&    pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
+               if(pNetwork->bssht.bdHTCapLen > 0 &&    pNetwork->bssht.bdHTCapLen <= sizeof(pHTInfo->PeerHTCapBuf))
                        memcpy(pHTInfo->PeerHTCapBuf, pNetwork->bssht.bdHTCapBuf, pNetwork->bssht.bdHTCapLen);
 
                if(pNetwork->bssht.bdHTInfoLen > 0 && pNetwork->bssht.bdHTInfoLen <= sizeof(pHTInfo->PeerHTInfoBuf))
@@ -1297,7 +1297,7 @@ void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee,         struct ieee80
 
 }
 
-void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee,         struct ieee80211_network * pNetwork)
+void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork)
 {
        PRT_HIGH_THROUGHPUT     pHTInfo = ieee->pHTInfo;
 //     PHT_CAPABILITY_ELE              pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
@@ -1364,8 +1364,8 @@ void HTUseDefaultSetting(struct ieee80211_device* ieee)
 }
 /********************************************************************************************************************
  *function:  check whether HT control field exists
- *   input:  struct ieee80211_device   *ieee
- *          u8*                        pFrame //coming skb->data
+ *   input:  struct ieee80211_device   *ieee
+ *          u8*                        pFrame //coming skb->data
  *  output:  none
  *  return:  return true if HT control field exists(false otherwise)
  *  notice:
index 9e4ced15edf5ae06247a848d04e923a9156df0f4..2348ccd70be05ee862e22774b69cb4278c7f3cba 100644 (file)
@@ -81,8 +81,7 @@ typedef       union _QOS_CTRL_FIELD{
        u16     shortData;
 
        // WMM spec
-       struct
-       {
+       struct {
                u8              UP:3;
                u8              usRsvd1:1;
                u8              EOSP:1;
@@ -92,8 +91,7 @@ typedef       union _QOS_CTRL_FIELD{
        }WMM;
 
        // 802.11e: QoS data type frame sent by non-AP QSTAs.
-       struct
-       {
+       struct {
                u8              TID:4;
                u8              bIsQsize:1;// 0: BIT[8:15] is TXOP Duration Requested, 1: BIT[8:15] is Queue Size.
                u8              AckPolicy:2;
@@ -102,8 +100,7 @@ typedef     union _QOS_CTRL_FIELD{
        }BySta;
 
        // 802.11e: QoS data, QoS Null, and QoS Data+CF-Ack frames sent by HC.
-       struct
-       {
+       struct {
                u8              TID:4;
                u8              EOSP:1;
                u8              AckPolicy:2;
@@ -112,8 +109,7 @@ typedef     union _QOS_CTRL_FIELD{
        }ByHc_Data;
 
        // 802.11e: QoS (+) CF-Poll frames sent by HC.
-       struct
-       {
+       struct {
                u8              TID:4;
                u8              EOSP:1;
                u8              AckPolicy:2;
@@ -133,14 +129,12 @@ typedef   union _QOS_CTRL_FIELD{
 typedef        union _QOS_INFO_FIELD{
        u8      charData;
 
-       struct
-       {
+       struct {
                u8              ucParameterSetCount:4;
                u8              ucReserved:4;
        }WMM;
 
-       struct
-       {
+       struct {
                //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
                u8              ucAC_VO_UAPSD:1;
                u8              ucAC_VI_UAPSD:1;
@@ -152,16 +146,14 @@ typedef   union _QOS_INFO_FIELD{
 
        }ByWmmPsSta;
 
-       struct
-       {
+       struct {
                //Ref WMM_Specification_1-1.pdf, 2006-06-13 Isaiah
                u8              ucParameterSetCount:4;
                u8              ucReserved:3;
                u8              ucApUapsd:1;
        }ByWmmPsAp;
 
-       struct
-       {
+       struct {
                u8              ucAC3_UAPSD:1;
                u8              ucAC2_UAPSD:1;
                u8              ucAC1_UAPSD:1;
@@ -171,8 +163,7 @@ typedef     union _QOS_INFO_FIELD{
                u8              ucMoreDataAck:1;
        } By11eSta;
 
-       struct
-       {
+       struct {
                u8              ucParameterSetCount:4;
                u8              ucQAck:1;
                u8              ucQueueReq:1;
@@ -180,16 +171,14 @@ typedef   union _QOS_INFO_FIELD{
                u8              ucReserved:1;
        } By11eAp;
 
-       struct
-       {
+       struct {
                u8              ucReserved1:4;
                u8              ucQAck:1;
                u8              ucReserved2:2;
                u8              ucMoreDataAck:1;
        } ByWmmsaSta;
 
-       struct
-       {
+       struct {
                u8              ucReserved1:4;
                u8              ucQAck:1;
                u8              ucQueueReq:1;
@@ -197,8 +186,7 @@ typedef     union _QOS_INFO_FIELD{
                u8              ucReserved2:1;
        } ByWmmsaAp;
 
-       struct
-       {
+       struct {
                u8              ucAC3_UAPSD:1;
                u8              ucAC2_UAPSD:1;
                u8              ucAC1_UAPSD:1;
@@ -208,8 +196,7 @@ typedef     union _QOS_INFO_FIELD{
                u8              ucMoreDataAck:1;
        } ByAllSta;
 
-       struct
-       {
+       struct {
                u8              ucParameterSetCount:4;
                u8              ucQAck:1;
                u8              ucQueueReq:1;
@@ -246,8 +233,7 @@ typedef u32 AC_CODING;
 typedef        union _ACI_AIFSN{
        u8      charData;
 
-       struct
-       {
+       struct {
                u8      AIFSN:4;
                u8      ACM:1;
                u8      ACI:2;
@@ -261,8 +247,7 @@ typedef     union _ACI_AIFSN{
 //
 typedef        union _ECW{
        u8      charData;
-       struct
-       {
+       struct {
                u8      ECWmin:4;
                u8      ECWmax:4;
        }f;     // Field
@@ -276,8 +261,7 @@ typedef     union _AC_PARAM{
        u32     longData;
        u8      charData[4];
 
-       struct
-       {
+       struct {
                ACI_AIFSN       AciAifsn;
                ECW             Ecw;
                u16             TXOPLimit;
@@ -336,8 +320,7 @@ typedef union _QOS_TSINFO{
 typedef union _TSPEC_BODY{
        u8              charData[55];
 
-       struct
-       {
+       struct {
                QOS_TSINFO      TSInfo; //u8    TSInfo[3];
                u16     NominalMSDUsize;
                u16     MaxMSDUsize;
@@ -412,14 +395,14 @@ typedef union _QOS_TCLAS{
 
        struct _TYPE_GENERAL{
                u8              Priority;
-               u8              ClassifierType;
-               u8              Mask;
+               u8              ClassifierType;
+               u8              Mask;
        } TYPE_GENERAL;
 
        struct _TYPE0_ETH{
                u8              Priority;
-               u8              ClassifierType;
-               u8              Mask;
+               u8              ClassifierType;
+               u8              Mask;
                u8              SrcAddr[6];
                u8              DstAddr[6];
                u16             Type;
@@ -427,9 +410,9 @@ typedef union _QOS_TCLAS{
 
        struct _TYPE1_IPV4{
                u8              Priority;
-               u8              ClassifierType;
-               u8              Mask;
-               u8              Version;
+               u8              ClassifierType;
+               u8              Mask;
+               u8              Version;
                u8              SrcIP[4];
                u8              DstIP[4];
                u16             SrcPort;
@@ -441,9 +424,9 @@ typedef union _QOS_TCLAS{
 
        struct _TYPE1_IPV6{
                u8              Priority;
-               u8              ClassifierType;
-               u8              Mask;
-               u8              Version;
+               u8              ClassifierType;
+               u8              Mask;
+               u8              Version;
                u8              SrcIP[16];
                u8              DstIP[16];
                u16             SrcPort;
@@ -453,8 +436,8 @@ typedef union _QOS_TCLAS{
 
        struct _TYPE2_8021Q{
                u8              Priority;
-               u8              ClassifierType;
-               u8              Mask;
+               u8              ClassifierType;
+               u8              Mask;
                u16             TagType;
        } TYPE2_8021Q;
 } QOS_TCLAS, *PQOS_TCLAS;
@@ -481,7 +464,7 @@ typedef struct _QOS_TSTREAM{
 //     "Qos control field" and "Qos info field"
 //typedef struct _QOS_UAPSD{
 //     u8                      bTriggerEnable[4];
-//     u8                      MaxSPLength;
+//     u8                      MaxSPLength;
 //     u8                      HighestBufAC;
 //} QOS_UAPSD, *PQOS_APSD;
 
@@ -489,7 +472,7 @@ typedef struct _QOS_TSTREAM{
 //      802.11 Management frame Status Code field
 //----------------------------------------------------------------------------
 typedef struct _OCTET_STRING{
-       u8              *Octet;
+       u8              *Octet;
        u16             Length;
 }OCTET_STRING, *POCTET_STRING;
 
@@ -512,7 +495,7 @@ typedef struct _STA_QOS{
        AC_UAPSD                        Curr4acUapsd;
        u8                              bInServicePeriod;
        u8                              MaxSPLength;
-       int                             NumBcnBeforeTrigger;
+       int                             NumBcnBeforeTrigger;
 
        // Part 2. EDCA Parameter (perAC)
        u8 *                            pWMMInfoEle;
@@ -523,7 +506,7 @@ typedef struct _STA_QOS{
        //2 ToDo: remove the Qos Info Field and replace it by the above WMM Info element.
        // By Bruce, 2008-01-30.
        // Part 2. EDCA Parameter (perAC)
-       QOS_INFO_FIELD                  QosInfoField_STA;       // Maintained by STA
+       QOS_INFO_FIELD                  QosInfoField_STA;       // Maintained by STA
        QOS_INFO_FIELD                  QosInfoField_AP;        // Retrieved from AP
 
        AC_PARAM                        CurAcParameters[4];
index e7e26fd96395559e447e03b82465f3f2a64c6fa1..7ed7243b1fb07e69b5edfe7e559e955d1c01a880 100644 (file)
@@ -28,7 +28,7 @@ typedef struct _TS_COMMON_INFO{
 typedef struct _TX_TS_RECORD{
        TS_COMMON_INFO          TsCommonInfo;
        u16                             TxCurSeq;
-       BA_RECORD                       TxPendingBARecord;      // For BA Originator
+       BA_RECORD                       TxPendingBARecord;      // For BA Originator
        BA_RECORD                       TxAdmittedBARecord;     // For BA Originator
 //     QOS_DL_RECORD           DLRecord;
        u8                              bAddBaReqInProgress;
@@ -53,4 +53,3 @@ typedef struct _RX_TS_RECORD {
 
 
 #endif
-
index 06a9824bbff10da2930d3e98513f846e2fb3194e..0310d07287a198e2e834a396fad47421b777dc92 100644 (file)
@@ -27,7 +27,7 @@ void RxPktPendingTimeout(unsigned long data)
        PRX_TS_RECORD   pRxTs = (PRX_TS_RECORD)data;
        struct ieee80211_device *ieee = container_of(pRxTs, struct ieee80211_device, RxTsRecord[pRxTs->num]);
 
-       PRX_REORDER_ENTRY       pReorderEntry = NULL;
+       PRX_REORDER_ENTRY       pReorderEntry = NULL;
 
        //u32 flags = 0;
        unsigned long flags = 0;
@@ -236,8 +236,8 @@ void AdmitTS(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, u32 I
 
 PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8* Addr, u8 TID, TR_SELECT TxRxSelect)
 {
-       //DIRECTION_VALUE       dir;
-       u8      dir;
+       //DIRECTION_VALUE       dir;
+       u8      dir;
        bool                            search_dir[4] = {0, 0, 0, 0};
        struct list_head*               psearch_list; //FIXME
        PTS_COMMON_INFO pRet = NULL;
@@ -250,14 +250,14 @@ PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8*    Addr, u8
                }
                else
                {
-                       search_dir[DIR_UP]      = true;
+                       search_dir[DIR_UP]      = true;
                        search_dir[DIR_BI_DIR]= true;
                }
        }
        else if(ieee->iw_mode == IW_MODE_ADHOC)
        {
                if(TxRxSelect == TX_DIR)
-                       search_dir[DIR_UP]      = true;
+                       search_dir[DIR_UP]      = true;
                else
                        search_dir[DIR_DOWN] = true;
        }
@@ -265,7 +265,7 @@ PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee, u8*      Addr, u8
        {
                if(TxRxSelect == TX_DIR)
                {
-                       search_dir[DIR_UP]      = true;
+                       search_dir[DIR_UP]      = true;
                        search_dir[DIR_BI_DIR]= true;
                        search_dir[DIR_DIRECT]= true;
                }
@@ -450,8 +450,8 @@ bool GetTs(
                                pTSInfo->field.ucTSID = UP;                     // TSID
                                pTSInfo->field.ucDirection = Dir;                       // Direction: if there is DirectLink, this need additional consideration.
                                pTSInfo->field.ucAccessPolicy = 1;              // Access policy
-                               pTSInfo->field.ucAggregation = 0;               // Aggregation
-                               pTSInfo->field.ucPSB = 0;                               // Aggregation
+                               pTSInfo->field.ucAggregation = 0;               // Aggregation
+                               pTSInfo->field.ucPSB = 0;                               // Aggregation
                                pTSInfo->field.ucUP = UP;                               // User priority
                                pTSInfo->field.ucTSInfoAckPolicy = 0;           // Ack policy
                                pTSInfo->field.ucSchedule = 0;                  // Schedule
@@ -488,7 +488,7 @@ void RemoveTsEntry(
        {
 //#ifdef TO_DO_LIST
                PRX_REORDER_ENTRY       pRxReorderEntry;
-               PRX_TS_RECORD           pRxTS = (PRX_TS_RECORD)pTs;
+               PRX_TS_RECORD           pRxTS = (PRX_TS_RECORD)pTs;
                if(timer_pending(&pRxTS->RxPktPendingTimer))
                        del_timer_sync(&pRxTS->RxPktPendingTimer);
 
index ccf6ae76357285686d62027574b867b1b324113e..c3c87108ee9ed9f35ee5e2dee2515bb19cf1ce23 100644 (file)
 
 #define CRYPTO_TFM_REQ_WEAK_KEY                0x00000100
 #define CRYPTO_TFM_RES_WEAK_KEY                0x00100000
-#define CRYPTO_TFM_RES_BAD_KEY_LEN     0x00200000
-#define CRYPTO_TFM_RES_BAD_KEY_SCHED   0x00400000
-#define CRYPTO_TFM_RES_BAD_BLOCK_LEN   0x00800000
-#define CRYPTO_TFM_RES_BAD_FLAGS       0x01000000
+#define CRYPTO_TFM_RES_BAD_KEY_LEN     0x00200000
+#define CRYPTO_TFM_RES_BAD_KEY_SCHED   0x00400000
+#define CRYPTO_TFM_RES_BAD_BLOCK_LEN   0x00800000
+#define CRYPTO_TFM_RES_BAD_FLAGS       0x01000000
 
 /*
  * Miscellaneous stuff.
@@ -73,7 +73,7 @@ struct cipher_alg {
        unsigned int cia_min_keysize;
        unsigned int cia_max_keysize;
        int (*cia_setkey)(void *ctx, const u8 *key,
-                         unsigned int keylen, u32 *flags);
+                         unsigned int keylen, u32 *flags);
        void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
        void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
 };
@@ -84,16 +84,16 @@ struct digest_alg {
        void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
        void (*dia_final)(void *ctx, u8 *out);
        int (*dia_setkey)(void *ctx, const u8 *key,
-                         unsigned int keylen, u32 *flags);
+                         unsigned int keylen, u32 *flags);
 };
 
 struct compress_alg {
        int (*coa_init)(void *ctx);
        void (*coa_exit)(void *ctx);
        int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
-                           u8 *dst, unsigned int *dlen);
+                           u8 *dst, unsigned int *dlen);
        int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
-                             u8 *dst, unsigned int *dlen);
+                             u8 *dst, unsigned int *dlen);
 };
 
 #define cra_cipher     cra_u.cipher
@@ -139,15 +139,15 @@ struct cipher_tfm {
        unsigned int cit_ivsize;
        u32 cit_mode;
        int (*cit_setkey)(struct crypto_tfm *tfm,
-                         const u8 *key, unsigned int keylen);
+                         const u8 *key, unsigned int keylen);
        int (*cit_encrypt)(struct crypto_tfm *tfm,
                           struct scatterlist *dst,
                           struct scatterlist *src,
                           unsigned int nbytes);
        int (*cit_encrypt_iv)(struct crypto_tfm *tfm,
-                             struct scatterlist *dst,
-                             struct scatterlist *src,
-                             unsigned int nbytes, u8 *iv);
+                             struct scatterlist *dst,
+                             struct scatterlist *src,
+                             unsigned int nbytes, u8 *iv);
        int (*cit_decrypt)(struct crypto_tfm *tfm,
                           struct scatterlist *dst,
                           struct scatterlist *src,
@@ -162,12 +162,12 @@ struct cipher_tfm {
 struct digest_tfm {
        void (*dit_init)(struct crypto_tfm *tfm);
        void (*dit_update)(struct crypto_tfm *tfm,
-                          struct scatterlist *sg, unsigned int nsg);
+                          struct scatterlist *sg, unsigned int nsg);
        void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
        void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
-                          unsigned int nsg, u8 *out);
+                          unsigned int nsg, u8 *out);
        int (*dit_setkey)(struct crypto_tfm *tfm,
-                         const u8 *key, unsigned int keylen);
+                         const u8 *key, unsigned int keylen);
 #ifdef CONFIG_CRYPTO_HMAC
        void *dit_hmac_block;
 #endif
@@ -175,11 +175,11 @@ struct digest_tfm {
 
 struct compress_tfm {
        int (*cot_compress)(struct crypto_tfm *tfm,
-                           const u8 *src, unsigned int slen,
-                           u8 *dst, unsigned int *dlen);
+                           const u8 *src, unsigned int slen,
+                           u8 *dst, unsigned int *dlen);
        int (*cot_decompress)(struct crypto_tfm *tfm,
-                             const u8 *src, unsigned int slen,
-                             u8 *dst, unsigned int *dlen);
+                             const u8 *src, unsigned int slen,
+                             u8 *dst, unsigned int *dlen);
 };
 
 #define crt_cipher     crt_u.cipher
@@ -277,8 +277,8 @@ static inline void crypto_digest_init(struct crypto_tfm *tfm)
 }
 
 static inline void crypto_digest_update(struct crypto_tfm *tfm,
-                                        struct scatterlist *sg,
-                                        unsigned int nsg)
+                                       struct scatterlist *sg,
+                                       unsigned int nsg)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
        tfm->crt_digest.dit_update(tfm, sg, nsg);
@@ -291,15 +291,15 @@ static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
 }
 
 static inline void crypto_digest_digest(struct crypto_tfm *tfm,
-                                        struct scatterlist *sg,
-                                        unsigned int nsg, u8 *out)
+                                       struct scatterlist *sg,
+                                       unsigned int nsg, u8 *out)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
        tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
 }
 
 static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
-                                       const u8 *key, unsigned int keylen)
+                                      const u8 *key, unsigned int keylen)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
        if (tfm->crt_digest.dit_setkey == NULL)
@@ -308,25 +308,25 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
 }
 
 static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
-                                       const u8 *key, unsigned int keylen)
+                                      const u8 *key, unsigned int keylen)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
 }
 
 static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
-                                        struct scatterlist *dst,
-                                        struct scatterlist *src,
-                                        unsigned int nbytes)
+                                       struct scatterlist *dst,
+                                       struct scatterlist *src,
+                                       unsigned int nbytes)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
 }
 
 static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
-                                           struct scatterlist *dst,
-                                           struct scatterlist *src,
-                                           unsigned int nbytes, u8 *iv)
+                                          struct scatterlist *dst,
+                                          struct scatterlist *src,
+                                          unsigned int nbytes, u8 *iv)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
@@ -334,18 +334,18 @@ static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
 }
 
 static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
-                                        struct scatterlist *dst,
-                                        struct scatterlist *src,
-                                        unsigned int nbytes)
+                                       struct scatterlist *dst,
+                                       struct scatterlist *src,
+                                       unsigned int nbytes)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
 }
 
 static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
-                                           struct scatterlist *dst,
-                                           struct scatterlist *src,
-                                           unsigned int nbytes, u8 *iv)
+                                          struct scatterlist *dst,
+                                          struct scatterlist *src,
+                                          unsigned int nbytes, u8 *iv)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
@@ -353,30 +353,30 @@ static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
 }
 
 static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
-                                        const u8 *src, unsigned int len)
+                                       const u8 *src, unsigned int len)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        memcpy(tfm->crt_cipher.cit_iv, src, len);
 }
 
 static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
-                                        u8 *dst, unsigned int len)
+                                       u8 *dst, unsigned int len)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
        memcpy(dst, tfm->crt_cipher.cit_iv, len);
 }
 
 static inline int crypto_comp_compress(struct crypto_tfm *tfm,
-                                       const u8 *src, unsigned int slen,
-                                       u8 *dst, unsigned int *dlen)
+                                      const u8 *src, unsigned int slen,
+                                      u8 *dst, unsigned int *dlen)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
        return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen);
 }
 
 static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
-                                         const u8 *src, unsigned int slen,
-                                         u8 *dst, unsigned int *dlen)
+                                        const u8 *src, unsigned int slen,
+                                        u8 *dst, unsigned int *dlen)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
        return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen);
@@ -388,12 +388,11 @@ static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
 #ifdef CONFIG_CRYPTO_HMAC
 void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen);
 void crypto_hmac_update(struct crypto_tfm *tfm,
-                        struct scatterlist *sg, unsigned int nsg);
+                       struct scatterlist *sg, unsigned int nsg);
 void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
-                       unsigned int *keylen, u8 *out);
+                      unsigned int *keylen, u8 *out);
 void crypto_hmac(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen,
-                 struct scatterlist *sg, unsigned int nsg, u8 *out);
+                struct scatterlist *sg, unsigned int nsg, u8 *out);
 #endif /* CONFIG_CRYPTO_HMAC */
 
 #endif /* _LINUX_CRYPTO_H */
-
index 3c515b7bc542ea7cea7083d4fc31accb85e1a899..7e49ad8f48f6aabfcee755c20caeb14ff48a734d 100644 (file)
@@ -95,7 +95,7 @@ u32 eprom_read(struct net_device *dev, u32 addr)
        u32 ret;
 
        ret=0;
-        //enable EPROM programming
+       //enable EPROM programming
        write_nic_byte_E(dev, EPROM_CMD,
                       (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT));
        force_pci_posting(dev);
index c7d18a8b79a12268a7fcb380b519031c70bae24d..52d6fba99debf01bd46d5f22bd106810428bca21 100644 (file)
@@ -1,5 +1,5 @@
 /*
-        Power management interface routines.
+       Power management interface routines.
        Written by Mariusz Matuszek.
        This code is currently just a placeholder for later work and
        does not do anything useful.
index 74ff337b0583500a5e6922f1077d76b27191b209..cf9713fa8b9d4a1ec20631884ed55efbfe7fed94 100644 (file)
@@ -16,9 +16,9 @@
 #include "r8190_rtl8256.h"
 
 /*--------------------------------------------------------------------------
- * Overview:           set RF band width (20M or 40M)
+ * Overview:   set RF band width (20M or 40M)
  * Input:       struct net_device*     dev
- *             WIRELESS_BANDWIDTH_E    Bandwidth       //20M or 40M
+ *             WIRELESS_BANDWIDTH_E    Bandwidth       //20M or 40M
  * Output:      NONE
  * Return:      NONE
  * Note:       8226 support both 20M  and 40 MHz
@@ -106,16 +106,16 @@ void PHY_RF8256_Config(struct net_device* dev)
  *---------------------------------------------------------------------------*/
 void phy_RF8256_Config_ParaFile(struct net_device* dev)
 {
-       u32     u4RegValue = 0;
+       u32     u4RegValue = 0;
        //static s1Byte                         szRadioAFile[] = RTL819X_PHY_RADIO_A;
        //static s1Byte                         szRadioBFile[] = RTL819X_PHY_RADIO_B;
        //static s1Byte                         szRadioCFile[] = RTL819X_PHY_RADIO_C;
        //static s1Byte                         szRadioDFile[] = RTL819X_PHY_RADIO_D;
-       u8      eRFPath;
+       u8      eRFPath;
        BB_REGISTER_DEFINITION_T        *pPhyReg;
        struct r8192_priv *priv = ieee80211_priv(dev);
        u32     RegOffSetToBeCheck = 0x3;
-       u32     RegValueToBeCheck = 0x7f1;
+       u32     RegValueToBeCheck = 0x7f1;
        u32     RF3_Final_Value = 0;
        u8      ConstRetryTimes = 5, RetryTimes = 5;
        u8 ret = 0;
@@ -152,7 +152,7 @@ void phy_RF8256_Config_ParaFile(struct net_device* dev)
                rtl8192_setBBreg(dev, pPhyReg->rfintfo, bRFSI_RFENV, 0x1);
 
                /* Set bit number of Address and Data for RF register */
-               rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0);  // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258
+               rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0);  // Set 0 to 4 bits for Z-serial and set 1 to 6 bits for 8258
                rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0);     // Set 0 to 12 bits for Z-serial and 8258, and set 1 to 14 bits for ???
 
                rtl8192_phy_SetRFReg(dev, (RF90_RADIO_PATH_E) eRFPath, 0x0, bMask12Bits, 0xbf);
@@ -309,4 +309,3 @@ void PHY_SetRF8256OFDMTxPower(struct net_device* dev, u8 powerlevel)
        return;
 
 }
-
index 57e3383cc9359709d3f8b9cf9101e12d54bf6ffa..e538e026b512e0e526ee8fb9ac1c25bd8c566a8b 100644 (file)
@@ -110,7 +110,7 @@ do { if(rt_global_debug_component & component) \
 #define COMP_RATE                              BIT12   // For Rate Adaptive mechanism, 2006.07.02, by rcnjko.
 #define COMP_RM                                        BIT13   // For Radio Measurement.
 #define COMP_DIG                               BIT14   // For DIG, 2006.09.25, by rcnjko.
-#define COMP_PHY                               BIT15
+#define COMP_PHY                               BIT15
 #define COMP_CH                                        BIT16   //channel setting debug
 #define COMP_TXAGC                             BIT17   // For Tx power, 060928, by rcnjko.
 #define COMP_HIPWR                             BIT18   // For High Power Mechanism, 060928, by rcnjko.
@@ -136,26 +136,26 @@ do { if(rt_global_debug_component & component) \
 #define RTL819x_DEBUG
 #ifdef RTL819x_DEBUG
 #define assert(expr) \
-        if (!(expr)) {                                  \
-                printk( "Assertion failed! %s,%s,%s,line=%d\n", \
-                #expr,__FILE__,__FUNCTION__,__LINE__);          \
-        }
+       if (!(expr)) {                                  \
+               printk( "Assertion failed! %s,%s,%s,line=%d\n", \
+               #expr,__FILE__,__FUNCTION__,__LINE__);          \
+       }
 //wb added to debug out data buf
 //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA
 #define RT_DEBUG_DATA(level, data, datalen)      \
-        do{ if ((rt_global_debug_component & (level)) == (level))   \
-                {       \
-                        int i;                                  \
-                        u8* pdata = (u8*) data;                 \
-                        printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__);   \
-                        for(i=0; i<(int)(datalen); i++)                 \
-                        {                                               \
-                                printk("%2x ", pdata[i]);               \
-                                if ((i+1)%16 == 0) printk("\n");        \
-                        }                               \
-                        printk("\n");                   \
-                }                                       \
-        } while (0)
+       do{ if ((rt_global_debug_component & (level)) == (level))   \
+               {       \
+                       int i;                                  \
+                       u8* pdata = (u8*) data;                 \
+                       printk(KERN_DEBUG RTL819xU_MODULE_NAME ": %s()\n", __FUNCTION__);   \
+                       for(i=0; i<(int)(datalen); i++)                 \
+                       {                                               \
+                               printk("%2x ", pdata[i]);               \
+                               if ((i+1)%16 == 0) printk("\n");        \
+                       }                               \
+                       printk("\n");                   \
+               }                                       \
+       } while (0)
 #else
 #define assert(expr) do {} while (0)
 #define RT_DEBUG_DATA(level, data, datalen) do {} while(0)
@@ -209,47 +209,47 @@ do { if(rt_global_debug_component & component) \
 #define IEEE80211_WATCH_DOG_TIME    2000
 #define                PHY_Beacon_RSSI_SLID_WIN_MAX            10
 //for txpowertracking by amy
-#define        OFDM_Table_Length       19
+#define                OFDM_Table_Length       19
 #define        CCK_Table_length        12
 
 /* for rtl819x */
 typedef struct _tx_desc_819x_usb {
-        //DWORD 0
-        u16    PktSize;
-        u8     Offset;
-        u8     Reserved0:3;
-        u8     CmdInit:1;
-        u8     LastSeg:1;
-        u8     FirstSeg:1;
-        u8     LINIP:1;
-        u8     OWN:1;
-
-        //DWORD 1
-        u8     TxFWInfoSize;
-        u8     RATid:3;
-        u8     DISFB:1;
-        u8     USERATE:1;
-        u8     MOREFRAG:1;
-        u8     NoEnc:1;
-        u8     PIFS:1;
-        u8     QueueSelect:5;
-        u8     NoACM:1;
-        u8     Reserved1:2;
-        u8     SecCAMID:5;
-        u8     SecDescAssign:1;
-        u8     SecType:2;
-
-        //DWORD 2
-        u16    TxBufferSize;
-        //u16 Reserved2;
-        u8     ResvForPaddingLen:7;
-        u8     Reserved3:1;
-        u8     Reserved4;
-
-        //DWORD 3, 4, 5
-        u32    Reserved5;
-        u32    Reserved6;
-        u32    Reserved7;
+       //DWORD 0
+       u16     PktSize;
+       u8      Offset;
+       u8      Reserved0:3;
+       u8      CmdInit:1;
+       u8      LastSeg:1;
+       u8      FirstSeg:1;
+       u8      LINIP:1;
+       u8      OWN:1;
+
+       //DWORD 1
+       u8      TxFWInfoSize;
+       u8      RATid:3;
+       u8      DISFB:1;
+       u8      USERATE:1;
+       u8      MOREFRAG:1;
+       u8      NoEnc:1;
+       u8      PIFS:1;
+       u8      QueueSelect:5;
+       u8      NoACM:1;
+       u8      Reserved1:2;
+       u8      SecCAMID:5;
+       u8      SecDescAssign:1;
+       u8      SecType:2;
+
+       //DWORD 2
+       u16     TxBufferSize;
+       //u16 Reserved2;
+       u8      ResvForPaddingLen:7;
+       u8      Reserved3:1;
+       u8      Reserved4;
+
+       //DWORD 3, 4, 5
+       u32     Reserved5;
+       u32     Reserved6;
+       u32     Reserved7;
 }tx_desc_819x_usb, *ptx_desc_819x_usb;
 
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
@@ -280,7 +280,7 @@ typedef struct _tx_desc_819x_usb_aggr_subframe {
 
 
 typedef struct _tx_desc_cmd_819x_usb {
-        //DWORD 0
+       //DWORD 0
        u16     Reserved0;
        u8      Reserved1;
        u8      Reserved2:3;
@@ -290,15 +290,15 @@ typedef struct _tx_desc_cmd_819x_usb {
        u8      LINIP:1;
        u8      OWN:1;
 
-        //DOWRD 1
+       //DOWRD 1
        //u32   Reserved3;
        u8      TxFWInfoSize;
        u8      Reserved3;
        u8      QueueSelect;
        u8      Reserved4;
 
-        //DOWRD 2
-       u16     TxBufferSize;
+       //DOWRD 2
+       u16     TxBufferSize;
        u16     Reserved5;
 
        //DWORD 3,4,5
@@ -311,34 +311,34 @@ typedef struct _tx_desc_cmd_819x_usb {
 
 
 typedef struct _tx_fwinfo_819x_usb {
-        //DOWRD 0
-        u8             TxRate:7;
-        u8             CtsEnable:1;
-        u8             RtsRate:7;
-        u8             RtsEnable:1;
-        u8             TxHT:1;
-        u8             Short:1;                //Short PLCP for CCK, or short GI for 11n MCS
-        u8             TxBandwidth:1;          // This is used for HT MCS rate only.
-        u8             TxSubCarrier:2;         // This is used for legacy OFDM rate only.
-        u8             STBC:2;
-        u8             AllowAggregation:1;
-        u8             RtsHT:1;                //Interpret RtsRate field as high throughput data rate
-        u8             RtsShort:1;             //Short PLCP for CCK, or short GI for 11n MCS
-        u8             RtsBandwidth:1;         // This is used for HT MCS rate only.
-        u8             RtsSubcarrier:2;        // This is used for legacy OFDM rate only.
-        u8             RtsSTBC:2;
-        u8             EnableCPUDur:1;         //Enable firmware to recalculate and assign packet duration
-
-        //DWORD 1
-        u32            RxMF:2;
-        u32            RxAMD:3;
-        u32            TxPerPktInfoFeedback:1;//1 indicate Tx info gathtered by firmware and returned by Rx Cmd
-        u32            Reserved1:2;
-        u32            TxAGCOffSet:4;
-        u32            TxAGCSign:1;
-        u32            Tx_INFO_RSVD:6;
+       //DOWRD 0
+       u8              TxRate:7;
+       u8              CtsEnable:1;
+       u8              RtsRate:7;
+       u8              RtsEnable:1;
+       u8              TxHT:1;
+       u8              Short:1;                //Short PLCP for CCK, or short GI for 11n MCS
+       u8              TxBandwidth:1;          // This is used for HT MCS rate only.
+       u8              TxSubCarrier:2;         // This is used for legacy OFDM rate only.
+       u8              STBC:2;
+       u8              AllowAggregation:1;
+       u8              RtsHT:1;                //Interpret RtsRate field as high throughput data rate
+       u8              RtsShort:1;             //Short PLCP for CCK, or short GI for 11n MCS
+       u8              RtsBandwidth:1;         // This is used for HT MCS rate only.
+       u8              RtsSubcarrier:2;        // This is used for legacy OFDM rate only.
+       u8              RtsSTBC:2;
+       u8              EnableCPUDur:1;         //Enable firmware to recalculate and assign packet duration
+
+       //DWORD 1
+       u32             RxMF:2;
+       u32             RxAMD:3;
+       u32             TxPerPktInfoFeedback:1;//1 indicate Tx info gathtered by firmware and returned by Rx Cmd
+       u32             Reserved1:2;
+       u32             TxAGCOffSet:4;
+       u32             TxAGCSign:1;
+       u32             Tx_INFO_RSVD:6;
        u32             PacketID:13;
-        //u32                Reserved;
+       //u32                Reserved;
 }tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb;
 
 typedef struct rtl8192_rx_info {
@@ -391,7 +391,7 @@ typedef struct _rx_desc_819x_usb_aggr_subframe{
        //DWORD 2
        //u4Byte                Reserved3;
        //DWORD 3
-       //u4Byte                BufferAddress;
+       //u4Byte                BufferAddress;
 }rx_desc_819x_usb_aggr_subframe, *prx_desc_819x_usb_aggr_subframe;
 #endif
 
@@ -424,7 +424,7 @@ typedef struct rx_drvinfo_819x_usb{
 #define MAX_802_11_HEADER_LENGTH        (40 + MAX_FIRMWARE_INFORMATION_SIZE)
 #define ENCRYPTION_MAX_OVERHEAD                128
 #define        USB_HWDESC_HEADER_LEN           sizeof(tx_desc_819x_usb)
-#define TX_PACKET_SHIFT_BYTES          (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
+#define TX_PACKET_SHIFT_BYTES          (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
 #define MAX_FRAGMENT_COUNT             8
 #ifdef RTL8192U
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
@@ -433,7 +433,7 @@ typedef struct rx_drvinfo_819x_usb{
 #define MAX_TRANSMIT_BUFFER_SIZE                       8000
 #endif
 #else
-#define MAX_TRANSMIT_BUFFER_SIZE       (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT)
+#define MAX_TRANSMIT_BUFFER_SIZE       (1600+(MAX_802_11_HEADER_LENGTH+ENCRYPTION_MAX_OVERHEAD)*MAX_FRAGMENT_COUNT)
 #endif
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
 #define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb))
@@ -559,22 +559,21 @@ typedef enum _WIRELESS_MODE {
 
 #define RTL_IOCTL_WPA_SUPPLICANT               SIOCIWFIRSTPRIV+30
 
-typedef struct buffer
-{
+typedef struct buffer {
        struct buffer *next;
        u32 *buf;
 
 } buffer;
 
 typedef struct rtl_reg_debug{
-        unsigned int  cmd;
-        struct {
-                unsigned char type;
-                unsigned char addr;
-                unsigned char page;
-                unsigned char length;
-        } head;
-        unsigned char buf[0xff];
+       unsigned int  cmd;
+       struct {
+               unsigned char type;
+               unsigned char addr;
+               unsigned char page;
+               unsigned char length;
+       } head;
+       unsigned char buf[0xff];
 }rtl_reg_debug;
 
 
@@ -600,8 +599,7 @@ typedef struct _RT_SMOOTH_DATA_4RF {
 
 #define MAX_8192U_RX_SIZE                      8192    // This maybe changed for D-cut larger aggregation size
 //stats seems messed up, clean it ASAP
-typedef struct Stats
-{
+typedef struct Stats {
        unsigned long txrdu;
 //     unsigned long rxrdu;
        //unsigned long rxnolast;
@@ -711,7 +709,7 @@ typedef struct Stats
 
 //+by amy 080507
 
-typedef struct         ChnlAccessSetting {
+typedef struct ChnlAccessSetting {
        u16 SIFS_Timer;
        u16 DIFS_Timer;
        u16 SlotTimeTimer;
@@ -721,35 +719,34 @@ typedef struct    ChnlAccessSetting {
 }*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING;
 
 typedef struct _BB_REGISTER_DEFINITION{
-       u32 rfintfs;                    // set software control: //             0x870~0x877[8 bytes]
-       u32 rfintfi;                    // readback data: //            0x8e0~0x8e7[8 bytes]
-       u32 rfintfo;                    // output data: //              0x860~0x86f [16 bytes]
-       u32 rfintfe;                    // output enable: //            0x860~0x86f [16 bytes]
-       u32 rf3wireOffset;              // LSSI data: //                0x840~0x84f [16 bytes]
-       u32 rfLSSI_Select;              // BB Band Select: //           0x878~0x87f [8 bytes]
+       u32 rfintfs;                    // set software control: //             0x870~0x877[8 bytes]
+       u32 rfintfi;                    // readback data: //            0x8e0~0x8e7[8 bytes]
+       u32 rfintfo;                    // output data: //              0x860~0x86f [16 bytes]
+       u32 rfintfe;                    // output enable: //            0x860~0x86f [16 bytes]
+       u32 rf3wireOffset;              // LSSI data: //                0x840~0x84f [16 bytes]
+       u32 rfLSSI_Select;              // BB Band Select: //           0x878~0x87f [8 bytes]
        u32 rfTxGainStage;              // Tx gain stage: //            0x80c~0x80f [4 bytes]
-       u32 rfHSSIPara1;                // wire parameter control1 : //         0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes]
-       u32 rfHSSIPara2;                // wire parameter control2 : //         0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
-       u32 rfSwitchControl;    //Tx Rx antenna control : //            0x858~0x85f [16 bytes]
-       u32 rfAGCControl1;      //AGC parameter control1 : //           0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes]
-       u32 rfAGCControl2;      //AGC parameter control2 : //           0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
-       u32 rfRxIQImbalance;    //OFDM Rx IQ imbalance matrix : //              0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
-       u32 rfRxAFE;                    //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : //         0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes]
-       u32 rfTxIQImbalance;    //OFDM Tx IQ imbalance matrix //                0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes]
-       u32 rfTxAFE;                    //Tx IQ DC Offset and Tx DFIR type //           0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
-       u32 rfLSSIReadBack;     //LSSI RF readback data //              0x8a0~0x8af [16 bytes]
+       u32 rfHSSIPara1;                // wire parameter control1 : //         0x820~0x823,0x828~0x82b, 0x830~0x833, 0x838~0x83b [16 bytes]
+       u32 rfHSSIPara2;                // wire parameter control2 : //         0x824~0x827,0x82c~0x82f, 0x834~0x837, 0x83c~0x83f [16 bytes]
+       u32 rfSwitchControl;    //Tx Rx antenna control : //            0x858~0x85f [16 bytes]
+       u32 rfAGCControl1;      //AGC parameter control1 : //           0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, 0xc68~0xc6b [16 bytes]
+       u32 rfAGCControl2;      //AGC parameter control2 : //           0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, 0xc6c~0xc6f [16 bytes]
+       u32 rfRxIQImbalance;    //OFDM Rx IQ imbalance matrix : //              0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, 0xc2c~0xc2f [16 bytes]
+       u32 rfRxAFE;                    //Rx IQ DC ofset and Rx digital filter, Rx DC notch filter : //         0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, 0xc28~0xc2b [16 bytes]
+       u32 rfTxIQImbalance;    //OFDM Tx IQ imbalance matrix //                0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, 0xc98~0xc9b [16 bytes]
+       u32 rfTxAFE;                    //Tx IQ DC Offset and Tx DFIR type //           0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, 0xc9c~0xc9f [16 bytes]
+       u32 rfLSSIReadBack;     //LSSI RF readback data //              0x8a0~0x8af [16 bytes]
 }BB_REGISTER_DEFINITION_T, *PBB_REGISTER_DEFINITION_T;
 
 typedef enum _RT_RF_TYPE_819xU{
-        RF_TYPE_MIN = 0,
-        RF_8225,
-        RF_8256,
-        RF_8258,
-        RF_PSEUDO_11N = 4,
+       RF_TYPE_MIN = 0,
+       RF_8225,
+       RF_8256,
+       RF_8258,
+       RF_PSEUDO_11N = 4,
 }RT_RF_TYPE_819xU, *PRT_RF_TYPE_819xU;
 
-typedef struct _rate_adaptive
-{
+typedef struct _rate_adaptive {
        u8                              rate_adaptive_disabled;
        u8                              ratr_state;
        u16                             reserve;
@@ -775,21 +772,18 @@ typedef struct _rate_adaptive
 #define TxBBGainTableLength 37
 #define        CCKTxBBGainTableLength 23
 
-typedef struct _txbbgain_struct
-{
+typedef struct _txbbgain_struct {
        long    txbb_iq_amplifygain;
        u32     txbbgain_value;
 } txbbgain_struct, *ptxbbgain_struct;
 
-typedef struct _ccktxbbgain_struct
-{
+typedef struct _ccktxbbgain_struct {
        //The Value is from a22 to a29 one Byte one time is much Safer
        u8      ccktxbb_valuearray[8];
 } ccktxbbgain_struct,*pccktxbbgain_struct;
 
 
-typedef struct _init_gain
-{
+typedef struct _init_gain {
        u8                              xaagccore1;
        u8                              xbagccore1;
        u8                              xcagccore1;
@@ -799,8 +793,7 @@ typedef struct _init_gain
 } init_gain, *pinit_gain;
 //by amy 0606
 
-typedef struct _phy_ofdm_rx_status_report_819xusb
-{
+typedef struct _phy_ofdm_rx_status_report_819xusb {
        u8      trsw_gain_X[4];
        u8      pwdb_all;
        u8      cfosho_X[4];
@@ -816,8 +809,7 @@ typedef struct _phy_ofdm_rx_status_report_819xusb
        u8  rxsc_sgien_exflg;
 }phy_sts_ofdm_819xusb_t;
 
-typedef struct _phy_cck_rx_status_report_819xusb
-{
+typedef struct _phy_cck_rx_status_report_819xusb {
        /* For CCK rate descriptor. This is a unsigned 8:1 variable. LSB bit presend
           0.5. And MSB 7 bts presend a signed value. Range from -64~+63.5. */
        u8      adc_pwdb_X[4];
@@ -881,8 +873,7 @@ typedef enum _tag_TxCmd_Config_Index{
        TXCMD_XXXX_CTRL,
 }DCMD_TXCMD_OP;
 
-typedef struct r8192_priv
-{
+typedef struct r8192_priv {
        struct usb_device *udev;
        //added for maintain info from eeprom
        short epromtype;
@@ -907,7 +898,7 @@ typedef struct r8192_priv
        spinlock_t irq_lock;
 //     spinlock_t irq_th_lock;
        spinlock_t tx_lock;
-        struct mutex mutex;
+       struct mutex mutex;
        //spinlock_t rf_lock; //used to lock rf write operation added by wb
 
        u16 irq_mask;
@@ -970,8 +961,8 @@ typedef struct r8192_priv
        atomic_t irt_counter;//count for irq_rx_tasklet
 #endif
 #ifdef JACKSON_NEW_RX
-        struct sk_buff **pp_rxskb;
-        int     rx_inx;
+       struct sk_buff **pp_rxskb;
+       int     rx_inx;
 #endif
 
 /* modified by davad for Rx process */
@@ -1006,7 +997,7 @@ typedef struct r8192_priv
        u8 retry_rts;
        u16 rts;
 
-       struct  ChnlAccessSetting  ChannelAccessSetting;
+       struct  ChnlAccessSetting  ChannelAccessSetting;
        struct work_struct reset_wq;
 
 /**********************************************************/
@@ -1014,7 +1005,7 @@ typedef struct r8192_priv
        u16     basic_rate;
        u8      short_preamble;
        u8      slot_time;
-       bool    bDcut;
+       bool    bDcut;
        bool bCurrentRxAggrEnable;
        u8 Rf_Mode; //add for Firmware RF -R/W switch
        prt_firmware            pFirmware;
@@ -1050,7 +1041,7 @@ typedef struct r8192_priv
 
        //for set channel
        u8      SwChnlInProgress;
-       u8      SwChnlStage;
+       u8      SwChnlStage;
        u8      SwChnlStep;
        u8      SetBWModeInProgress;
        HT_CHANNEL_WIDTH                CurrentChannelBW;
@@ -1062,8 +1053,8 @@ typedef struct r8192_priv
        // We save RF reg0 in this variable to reduce RF reading.
        //
        u32                                     RfReg0Value[4];
-       u8                                      NumTotalRFPath;
-       bool                            brfpath_rxenable[4];
+       u8                                      NumTotalRFPath;
+       bool                            brfpath_rxenable[4];
        //RF set related
        bool                            SetRFPowerStateInProgress;
 //+by amy 080507
@@ -1104,7 +1095,7 @@ typedef struct r8192_priv
        bool btxpower_tracking;
        bool bcck_in_ch14;
        bool btxpowerdata_readfromEEPORM;
-       u16     TSSI_13dBm;
+       u16     TSSI_13dBm;
        //For Backup Initial Gain
        init_gain initgain_backup;
        u8 DefaultInitialGain[4];
@@ -1114,17 +1105,17 @@ typedef struct r8192_priv
        bool            bis_cur_rdlstate;
        struct timer_list fsync_timer;
        bool bfsync_processing; // 500ms Fsync timer is active or not
-       u32     rate_record;
-       u32     rateCountDiffRecord;
+       u32     rate_record;
+       u32     rateCountDiffRecord;
        u32     ContinueDiffCount;
        bool bswitch_fsync;
 
        u8      framesync;
-       u32     framesyncC34;
-       u8      framesyncMonitor;
-               //Added by amy 080516  for RX related
-       u16     nrxAMPDU_size;
-       u8      nrxAMPDU_aggr_num;
+       u32     framesyncC34;
+       u8      framesyncMonitor;
+               //Added by amy 080516  for RX related
+       u16     nrxAMPDU_size;
+       u8      nrxAMPDU_aggr_num;
 
        //by amy for gpio
         bool bHwRadioOff;
@@ -1204,7 +1195,7 @@ typedef enum{
 #ifdef JOHN_HWSEC
 struct ssid_thread {
        struct net_device *dev;
-               u8 name[IW_ESSID_MAX_SIZE + 1];
+       u8 name[IW_ESSID_MAX_SIZE + 1];
 };
 #endif
 
index 56367f23112fddeaf06174dc5ac320fbd9f7dff9..f7de2f6d49a5e7c86ac98bbdfc1961fd8d467164 100644 (file)
@@ -80,9 +80,9 @@ double __extendsfdf2(float a) {return a;}
 #include "dot11d.h"
 //set here to open your trace code. //WB
 u32 rt_global_debug_component = \
-                       //      COMP_INIT       |
+                       //      COMP_INIT       |
 //                             COMP_DBG        |
-                       //      COMP_EPROM      |
+                       //      COMP_EPROM      |
 //                             COMP_PHY        |
                        //      COMP_RF         |
 //                             COMP_FIRMWARE   |
@@ -159,23 +159,22 @@ static struct usb_driver rtl8192_usb_driver = {
        .resume         = rtl8192_resume,                 /* PM resume fn  */
 #else
        .suspend        = NULL,                           /* PM suspend fn */
-       .resume         = NULL,                           /* PM resume fn  */
+       .resume         = NULL,                           /* PM resume fn  */
 #endif
 };
 
 
-typedef struct _CHANNEL_LIST
-{
+typedef struct _CHANNEL_LIST {
        u8      Channel[32];
        u8      Len;
 }CHANNEL_LIST, *PCHANNEL_LIST;
 
 static CHANNEL_LIST ChannelPlan[] = {
-       {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24},             //FCC
-       {{1,2,3,4,5,6,7,8,9,10,11},11},                                                 //IC
-       {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21},   //ETSI
+       {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24},             //FCC
+       {{1,2,3,4,5,6,7,8,9,10,11},11},                                                 //IC
+       {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21},   //ETSI
        {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},    //Spain. Change to ETSI.
-       {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},   //France. Change to ETSI.
+       {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},   //France. Change to ETSI.
        {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},        //MKK                                   //MKK
        {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1
        {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},   //Israel.
@@ -190,57 +189,51 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
        struct ieee80211_device* ieee = priv->ieee80211;
        switch (channel_plan)
        {
-               case COUNTRY_CODE_FCC:
-               case COUNTRY_CODE_IC:
-               case COUNTRY_CODE_ETSI:
-               case COUNTRY_CODE_SPAIN:
-               case COUNTRY_CODE_FRANCE:
-               case COUNTRY_CODE_MKK:
-               case COUNTRY_CODE_MKK1:
-               case COUNTRY_CODE_ISRAEL:
-               case COUNTRY_CODE_TELEC:
-               case COUNTRY_CODE_MIC:
-               {
-                       Dot11d_Init(ieee);
-                       ieee->bGlobalDomain = false;
-                       //actually 8225 & 8256 rf chips only support B,G,24N mode
-                       if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256))
-                       {
-                               min_chan = 1;
-                               max_chan = 14;
-                       }
-                       else
-                       {
-                               RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__);
-                       }
-                       if (ChannelPlan[channel_plan].Len != 0){
-                               // Clear old channel map
-                               memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map));
-                               // Set new channel map
-                               for (i=0;i<ChannelPlan[channel_plan].Len;i++)
-                               {
-                                       if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
+       case COUNTRY_CODE_FCC:
+       case COUNTRY_CODE_IC:
+       case COUNTRY_CODE_ETSI:
+       case COUNTRY_CODE_SPAIN:
+       case COUNTRY_CODE_FRANCE:
+       case COUNTRY_CODE_MKK:
+       case COUNTRY_CODE_MKK1:
+       case COUNTRY_CODE_ISRAEL:
+       case COUNTRY_CODE_TELEC:
+       case COUNTRY_CODE_MIC:  
+               Dot11d_Init(ieee);
+               ieee->bGlobalDomain = false;
+               //actually 8225 & 8256 rf chips only support B,G,24N mode
+               if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256)) {
+                       min_chan = 1;
+                       max_chan = 14;
+               }
+               else {
+                       RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__);
+               }
+               if (ChannelPlan[channel_plan].Len != 0) {
+                       // Clear old channel map
+                       memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map));
+                       // Set new channel map
+                       for (i=0;i<ChannelPlan[channel_plan].Len;i++) {
+                               if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan)
                                        break;
-                                       GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
-                               }
+                               GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1;
                        }
-                       break;
                }
-               case COUNTRY_CODE_GLOBAL_DOMAIN:
-               {
-                       GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings.
-                       Dot11d_Reset(ieee);
-                       ieee->bGlobalDomain = true;
-                       break;
-               }
-               default:
-                       break;
+               break;
+
+       case COUNTRY_CODE_GLOBAL_DOMAIN:
+               GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings.
+               Dot11d_Reset(ieee);
+               ieee->bGlobalDomain = true;
+               break;
+       
+       default:
+               break;
        }
-       return;
 }
 
 
-#define        rx_hal_is_cck_rate(_pdrvinfo)\
+#define                rx_hal_is_cck_rate(_pdrvinfo)\
                        (_pdrvinfo->RxRate == DESC90_RATE1M ||\
                        _pdrvinfo->RxRate == DESC90_RATE2M ||\
                        _pdrvinfo->RxRate == DESC90_RATE5_5M ||\
@@ -516,55 +509,50 @@ static int proc_get_registers(char *page, char **start,
        int max=0xff;
 
        /* This dump the current register page */
-len += snprintf(page + len, count - len,
+       len += snprintf(page + len, count - len,
                        "\n####################page 0##################\n ");
 
-       for(n=0;n<=max;)
-       {
+       for (n=0;n<=max;) {
                //printk( "\nD: %2x> ", n);
                len += snprintf(page + len, count - len,
                        "\nD:  %2x > ",n);
 
-               for(i=0;i<16 && n<=max;i++,n++)
-               len += snprintf(page + len, count - len,
-                       "%2x ",read_nic_byte(dev,0x000|n));
+               for (i=0;i<16 && n<=max;i++,n++)
+                       len += snprintf(page + len, count - len,
+                                       "%2x ",read_nic_byte(dev,0x000|n));
 
                //      printk("%2x ",read_nic_byte(dev,n));
        }
-len += snprintf(page + len, count - len,
+       len += snprintf(page + len, count - len,
                        "\n####################page 1##################\n ");
-       for(n=0;n<=max;)
-       {
+       for (n=0;n<=max;) {
                //printk( "\nD: %2x> ", n);
                len += snprintf(page + len, count - len,
-                       "\nD:  %2x > ",n);
+                               "\nD:  %2x > ",n);
 
-               for(i=0;i<16 && n<=max;i++,n++)
-               len += snprintf(page + len, count - len,
-                       "%2x ",read_nic_byte(dev,0x100|n));
+               for (i=0;i<16 && n<=max;i++,n++)
+                       len += snprintf(page + len, count - len,
+                                       "%2x ",read_nic_byte(dev,0x100|n));
 
                //      printk("%2x ",read_nic_byte(dev,n));
        }
-len += snprintf(page + len, count - len,
+       len += snprintf(page + len, count - len,
                        "\n####################page 3##################\n ");
-       for(n=0;n<=max;)
-       {
+       for (n=0;n<=max;) {
                //printk( "\nD: %2x> ", n);
                len += snprintf(page + len, count - len,
                        "\nD:  %2x > ",n);
 
                for(i=0;i<16 && n<=max;i++,n++)
-               len += snprintf(page + len, count - len,
-                       "%2x ",read_nic_byte(dev,0x300|n));
+                       len += snprintf(page + len, count - len,
+                                       "%2x ",read_nic_byte(dev,0x300|n));
 
                //      printk("%2x ",read_nic_byte(dev,n));
        }
 
-
        len += snprintf(page + len, count - len,"\n");
        *eof = 1;
        return len;
-
 }
 
 
@@ -1272,8 +1260,8 @@ struct sk_buff *DrvAggr_Aggregation(struct net_device *dev, struct ieee80211_drv
 {
        struct ieee80211_device *ieee = netdev_priv(dev);
        struct r8192_priv *priv = ieee80211_priv(dev);
-       cb_desc         *tcb_desc = NULL;
-       u8              i;
+       cb_desc         *tcb_desc = NULL;
+       u8              i;
        u32             TotalLength;
        struct sk_buff  *skb;
        struct sk_buff  *agg_skb;
@@ -1444,7 +1432,7 @@ u8 DrvAggr_GetAggregatibleList(struct net_device *dev, struct sk_buff *skb,
        struct ieee80211_device *ieee = netdev_priv(dev);
        PRT_HIGH_THROUGHPUT     pHTInfo = ieee->pHTInfo;
        u16             nMaxAggrNum = pHTInfo->UsbTxAggrNum;
-       cb_desc         *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+       cb_desc         *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
        u8              QueueID = tcb_desc->queue_index;
 
        do {
@@ -1812,7 +1800,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb)
        int                     status;
        struct urb              *tx_urb;
        //int                   urb_buf_len;
-       unsigned int            idx_pipe;
+       unsigned int            idx_pipe;
        tx_desc_cmd_819x_usb *pdesc = (tx_desc_cmd_819x_usb *)skb->data;
        cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
        u8 queue_index = tcb_desc->queue_index;
@@ -1876,43 +1864,43 @@ u8 MapHwQueueToFirmwareQueue(u8 QueueID)
        u8 QueueSelect = 0x0;       //defualt set to
 
        switch(QueueID) {
-               case BE_QUEUE:
-                       QueueSelect = QSLT_BE;  //or QSelect = pTcb->priority;
-                       break;
+       case BE_QUEUE:
+               QueueSelect = QSLT_BE;  //or QSelect = pTcb->priority;
+               break;
 
-               case BK_QUEUE:
-                       QueueSelect = QSLT_BK;  //or QSelect = pTcb->priority;
-                       break;
+       case BK_QUEUE:
+               QueueSelect = QSLT_BK;  //or QSelect = pTcb->priority;
+               break;
 
-               case VO_QUEUE:
-                       QueueSelect = QSLT_VO;  //or QSelect = pTcb->priority;
-                       break;
+       case VO_QUEUE:
+               QueueSelect = QSLT_VO;  //or QSelect = pTcb->priority;
+               break;
 
-               case VI_QUEUE:
-                       QueueSelect = QSLT_VI;  //or QSelect = pTcb->priority;
-                       break;
-               case MGNT_QUEUE:
-                       QueueSelect = QSLT_MGNT;
-                       break;
+       case VI_QUEUE:
+               QueueSelect = QSLT_VI;  //or QSelect = pTcb->priority;
+               break;
+       case MGNT_QUEUE:
+               QueueSelect = QSLT_MGNT;
+               break;
 
-               case BEACON_QUEUE:
-                       QueueSelect = QSLT_BEACON;
-                       break;
+       case BEACON_QUEUE:
+               QueueSelect = QSLT_BEACON;
+               break;
 
-                       // TODO: 2006.10.30 mark other queue selection until we verify it is OK
-                       // TODO: Remove Assertions
+               // TODO: 2006.10.30 mark other queue selection until we verify it is OK
+               // TODO: Remove Assertions
 //#if (RTL819X_FPGA_VER & RTL819X_FPGA_GUANGAN_070502)
-               case TXCMD_QUEUE:
-                       QueueSelect = QSLT_CMD;
-                       break;
+       case TXCMD_QUEUE:
+               QueueSelect = QSLT_CMD;
+               break;
 //#endif
-               case HIGH_QUEUE:
-                       QueueSelect = QSLT_HIGH;
-                       break;
+       case HIGH_QUEUE:
+               QueueSelect = QSLT_HIGH;
+               break;
 
-               default:
-                       RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID);
-                       break;
+       default:
+               RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID);
+               break;
        }
        return QueueSelect;
 }
@@ -1922,39 +1910,39 @@ u8 MRateToHwRate8190Pci(u8 rate)
        u8  ret = DESC90_RATE1M;
 
        switch(rate) {
-               case MGN_1M:    ret = DESC90_RATE1M;    break;
-               case MGN_2M:    ret = DESC90_RATE2M;    break;
-               case MGN_5_5M:  ret = DESC90_RATE5_5M;  break;
-               case MGN_11M:   ret = DESC90_RATE11M;   break;
-               case MGN_6M:    ret = DESC90_RATE6M;    break;
-               case MGN_9M:    ret = DESC90_RATE9M;    break;
-               case MGN_12M:   ret = DESC90_RATE12M;   break;
-               case MGN_18M:   ret = DESC90_RATE18M;   break;
-               case MGN_24M:   ret = DESC90_RATE24M;   break;
-               case MGN_36M:   ret = DESC90_RATE36M;   break;
-               case MGN_48M:   ret = DESC90_RATE48M;   break;
-               case MGN_54M:   ret = DESC90_RATE54M;   break;
-
-               // HT rate since here
-               case MGN_MCS0:  ret = DESC90_RATEMCS0;  break;
-               case MGN_MCS1:  ret = DESC90_RATEMCS1;  break;
-               case MGN_MCS2:  ret = DESC90_RATEMCS2;  break;
-               case MGN_MCS3:  ret = DESC90_RATEMCS3;  break;
-               case MGN_MCS4:  ret = DESC90_RATEMCS4;  break;
-               case MGN_MCS5:  ret = DESC90_RATEMCS5;  break;
-               case MGN_MCS6:  ret = DESC90_RATEMCS6;  break;
-               case MGN_MCS7:  ret = DESC90_RATEMCS7;  break;
-               case MGN_MCS8:  ret = DESC90_RATEMCS8;  break;
-               case MGN_MCS9:  ret = DESC90_RATEMCS9;  break;
-               case MGN_MCS10: ret = DESC90_RATEMCS10; break;
-               case MGN_MCS11: ret = DESC90_RATEMCS11; break;
-               case MGN_MCS12: ret = DESC90_RATEMCS12; break;
-               case MGN_MCS13: ret = DESC90_RATEMCS13; break;
-               case MGN_MCS14: ret = DESC90_RATEMCS14; break;
-               case MGN_MCS15: ret = DESC90_RATEMCS15; break;
-               case (0x80|0x20): ret = DESC90_RATEMCS32; break;
-
-               default:       break;
+       case MGN_1M:    ret = DESC90_RATE1M;    break;
+       case MGN_2M:    ret = DESC90_RATE2M;    break;
+       case MGN_5_5M:  ret = DESC90_RATE5_5M;  break;
+       case MGN_11M:   ret = DESC90_RATE11M;   break;
+       case MGN_6M:    ret = DESC90_RATE6M;    break;
+       case MGN_9M:    ret = DESC90_RATE9M;    break;
+       case MGN_12M:   ret = DESC90_RATE12M;   break;
+       case MGN_18M:   ret = DESC90_RATE18M;   break;
+       case MGN_24M:   ret = DESC90_RATE24M;   break;
+       case MGN_36M:   ret = DESC90_RATE36M;   break;
+       case MGN_48M:   ret = DESC90_RATE48M;   break;
+       case MGN_54M:   ret = DESC90_RATE54M;   break;
+
+       // HT rate since here
+       case MGN_MCS0:  ret = DESC90_RATEMCS0;  break;
+       case MGN_MCS1:  ret = DESC90_RATEMCS1;  break;
+       case MGN_MCS2:  ret = DESC90_RATEMCS2;  break;
+       case MGN_MCS3:  ret = DESC90_RATEMCS3;  break;
+       case MGN_MCS4:  ret = DESC90_RATEMCS4;  break;
+       case MGN_MCS5:  ret = DESC90_RATEMCS5;  break;
+       case MGN_MCS6:  ret = DESC90_RATEMCS6;  break;
+       case MGN_MCS7:  ret = DESC90_RATEMCS7;  break;
+       case MGN_MCS8:  ret = DESC90_RATEMCS8;  break;
+       case MGN_MCS9:  ret = DESC90_RATEMCS9;  break;
+       case MGN_MCS10: ret = DESC90_RATEMCS10; break;
+       case MGN_MCS11: ret = DESC90_RATEMCS11; break;
+       case MGN_MCS12: ret = DESC90_RATEMCS12; break;
+       case MGN_MCS13: ret = DESC90_RATEMCS13; break;
+       case MGN_MCS14: ret = DESC90_RATEMCS14; break;
+       case MGN_MCS15: ret = DESC90_RATEMCS15; break;
+       case (0x80|0x20): ret = DESC90_RATEMCS32; break;
+
+       default:       break;
        }
        return ret;
 }
@@ -2182,7 +2170,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff* skb)
                dev->trans_start = jiffies;
                atomic_inc(&priv->tx_pending[tcb_desc->queue_index]);
                return 0;
-       }else{
+       } else {
                RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]),
                                status);
                return -1;
@@ -2320,33 +2308,33 @@ void rtl8192_link_change(struct net_device *dev)
 //     RT_TRACE(COMP_CH, "========>%s(), chan:%d\n", __FUNCTION__, priv->chan);
 //     rtl8192_set_chan(dev, priv->chan);
         if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC)
-        {
-                u32 reg = 0;
-                reg = read_nic_dword(dev, RCR);
-                if (priv->ieee80211->state == IEEE80211_LINKED)
-                        priv->ReceiveConfig = reg |= RCR_CBSSID;
-                else
-                        priv->ReceiveConfig = reg &= ~RCR_CBSSID;
-                write_nic_dword(dev, RCR, reg);
-        }
+       {
+               u32 reg = 0;
+               reg = read_nic_dword(dev, RCR);
+               if (priv->ieee80211->state == IEEE80211_LINKED)
+                       priv->ReceiveConfig = reg |= RCR_CBSSID;
+               else
+                       priv->ReceiveConfig = reg &= ~RCR_CBSSID;
+               write_nic_dword(dev, RCR, reg);
+       }
 
 //     rtl8192_set_rxconf(dev);
 }
 
 static struct ieee80211_qos_parameters def_qos_parameters = {
-        {3,3,3,3},/* cw_min */
-        {7,7,7,7},/* cw_max */
-        {2,2,2,2},/* aifs */
-        {0,0,0,0},/* flags */
-        {0,0,0,0} /* tx_op_limit */
+       {3,3,3,3},/* cw_min */
+       {7,7,7,7},/* cw_max */
+       {2,2,2,2},/* aifs */
+       {0,0,0,0},/* flags */
+       {0,0,0,0} /* tx_op_limit */
 };
 
 
 void rtl8192_update_beacon(struct work_struct * work)
 {
-        struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
-        struct net_device *dev = priv->ieee80211->dev;
-       struct ieee80211_device* ieee = priv->ieee80211;
+       struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work);
+       struct net_device *dev = priv->ieee80211->dev;
+       struct ieee80211_device* ieee = priv->ieee80211;
        struct ieee80211_network* net = &ieee->current_network;
 
        if (ieee->pHTInfo->bCurrentHTSupport)
@@ -2717,7 +2705,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
        priv->bDisableNormalResetCheck = false;
        priv->force_reset = false;
 
-       priv->ieee80211->FwRWRF = 0;    //we don't use FW read/write RF until stable firmware is available.
+       priv->ieee80211->FwRWRF = 0;    //we don't use FW read/write RF until stable firmware is available.
        priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
        priv->ieee80211->iw_mode = IW_MODE_INFRA;
        priv->ieee80211->softmac_features  = IEEE_SOFTMAC_SCAN |
@@ -2778,11 +2766,11 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
 #ifdef TO_DO_LIST
        if(Adapter->bInHctTest)
                pHalData->ReceiveConfig =       pHalData->CSMethod |
-                                               RCR_AMF | RCR_ADF |     //RCR_AAP |     //accept management/data
+                                               RCR_AMF | RCR_ADF |     //RCR_AAP |     //accept management/data
                                                //guangan200710
                                                RCR_ACF |       //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
                                                RCR_AB | RCR_AM | RCR_APM |             //accept BC/MC/UC
-                                               RCR_AICV | RCR_ACRC32 |                 //accept ICV/CRC error packet
+                                               RCR_AICV | RCR_ACRC32 |                 //accept ICV/CRC error packet
                                                ((u32)7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
                                                (pHalData->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold.
                                                (pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt:0);
@@ -2793,7 +2781,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
                RCR_AMF | RCR_ADF |             //accept management/data
                RCR_ACF |                       //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
                RCR_AB | RCR_AM | RCR_APM |     //accept BC/MC/UC
-               //RCR_AICV | RCR_ACRC32 |       //accept ICV/CRC error packet
+               //RCR_AICV | RCR_ACRC32 |       //accept ICV/CRC error packet
                ((u32)7<<RCR_MXDMA_OFFSET)| // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
                (priv->EarlyRxThreshold<<RX_FIFO_THRESHOLD_SHIFT) | // Rx FIFO Threshold, 7: No Rx threshold.
                (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0);
@@ -3549,7 +3537,7 @@ HalTxCheckStuck819xUsb(
        )
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       u16             RegTxCounter = read_nic_word(dev, 0x128);
+       u16             RegTxCounter = read_nic_word(dev, 0x128);
        bool            bStuck = FALSE;
        RT_TRACE(COMP_RESET,"%s():RegTxCounter is %d,TxCounter is %d\n",__FUNCTION__,RegTxCounter,priv->TxCounter);
        if(priv->TxCounter==RegTxCounter)
@@ -3583,16 +3571,16 @@ TxCheckStuck(struct net_device *dev)
 //          spin_lock_irqsave(&priv->ieee80211->lock,flags);
             for (QueueID = 0; QueueID<=BEACON_QUEUE;QueueID ++)
             {
-                       if(QueueID == TXCMD_QUEUE)
-                        continue;
+                       if(QueueID == TXCMD_QUEUE)
+                        continue;
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
                        if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_drv_aggQ[QueueID]) == 0))
 #else
-                       if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0)  && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
+                       if((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0)  && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0))
 #endif
-                               continue;
+                               continue;
 
-                    bCheckFwTxCnt = true;
+                    bCheckFwTxCnt = true;
             }
 //          PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
 //     spin_unlock_irqrestore(&priv->ieee80211->lock,flags);
@@ -3611,10 +3599,10 @@ TxCheckStuck(struct net_device *dev)
 bool
 HalRxCheckStuck819xUsb(struct net_device *dev)
 {
-       u16     RegRxCounter = read_nic_word(dev, 0x130);
+       u16     RegRxCounter = read_nic_word(dev, 0x130);
        struct r8192_priv *priv = ieee80211_priv(dev);
        bool bStuck = FALSE;
-       static u8       rx_chk_cnt = 0;
+       static u8       rx_chk_cnt;
        RT_TRACE(COMP_RESET,"%s(): RegRxCounter is %d,RxCounter is %d\n",__FUNCTION__,RegRxCounter,priv->RxCounter);
        // If rssi is small, we should check rx for long time because of bad rx.
        // or maybe it will continuous silent reset every 2 seconds.
@@ -3718,7 +3706,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev)
        struct r8192_priv *priv = ieee80211_priv(dev);
        RESET_TYPE      TxResetType = RESET_TYPE_NORESET;
        RESET_TYPE      RxResetType = RESET_TYPE_NORESET;
-       RT_RF_POWER_STATE       rfState;
+       RT_RF_POWER_STATE       rfState;
 
        rfState = priv->ieee80211->eRFPowerState;
 
@@ -4006,18 +3994,18 @@ RESET_START:
 
 void CAM_read_entry(
        struct net_device *dev,
-       u32                     iIndex
+       u32                     iIndex
 )
 {
-       u32 target_command=0;
+       u32 target_command=0;
         u32 target_content=0;
         u8 entry_i=0;
         u32 ulStatus;
        s32 i=100;
 //     printk("=======>start read CAM\n");
-       for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++)
-       {
-       // polling bit, and No Write enable, and address
+       for(entry_i=0;entry_i<CAM_CONTENT_COUNT;entry_i++)
+       {
+       // polling bit, and No Write enable, and address
                target_command= entry_i+CAM_CONTENT_COUNT*iIndex;
                target_command= target_command | BIT31;
 
@@ -4049,7 +4037,7 @@ void rtl819x_update_rxcounts(
        u32* TotalRxDataNum
 )
 {
-       u16                     SlotIndex;
+       u16                     SlotIndex;
        u8                      i;
 
        *TotalRxBcnNum = 0;
@@ -4072,7 +4060,7 @@ extern    void    rtl819x_watchdog_wqcallback(struct work_struct *work)
        struct net_device *dev = priv->ieee80211->dev;
        struct ieee80211_device* ieee = priv->ieee80211;
        RESET_TYPE      ResetType = RESET_TYPE_NORESET;
-       static u8       check_reset_cnt=0;
+       static u8       check_reset_cnt;
        bool bBusyTraffic = false;
 
        if(!priv->up)
@@ -4111,7 +4099,7 @@ extern    void    rtl819x_watchdog_wqcallback(struct work_struct *work)
                                notify_wx_assoc_event(priv->ieee80211);
                                RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid);
                                priv->ieee80211->link_change(dev);
-                                queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
+                               queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq);
 
                        }
                }
@@ -4122,7 +4110,7 @@ extern    void    rtl819x_watchdog_wqcallback(struct work_struct *work)
        //check if reset the driver
        if(check_reset_cnt++ >= 3)
        {
-               ResetType = rtl819x_ifcheck_resetornot(dev);
+               ResetType = rtl819x_ifcheck_resetornot(dev);
                check_reset_cnt = 3;
                //DbgPrint("Start to check silent reset\n");
        }
@@ -4365,66 +4353,66 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        }
 
        switch (cmd) {
-           case RTL_IOCTL_WPA_SUPPLICANT:
+       case RTL_IOCTL_WPA_SUPPLICANT:
        //parse here for HW security
-                       if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION)
+               if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION)
+               {
+                       if (ipw->u.crypt.set_tx)
                        {
-                               if (ipw->u.crypt.set_tx)
+                               if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
+                                       ieee->pairwise_key_type = KEY_TYPE_CCMP;
+                               else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
+                                       ieee->pairwise_key_type = KEY_TYPE_TKIP;
+                               else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
                                {
-                                       if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
-                                               ieee->pairwise_key_type = KEY_TYPE_CCMP;
-                                       else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
-                                               ieee->pairwise_key_type = KEY_TYPE_TKIP;
-                                       else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
-                                       {
-                                               if (ipw->u.crypt.key_len == 13)
-                                                       ieee->pairwise_key_type = KEY_TYPE_WEP104;
-                                               else if (ipw->u.crypt.key_len == 5)
-                                                       ieee->pairwise_key_type = KEY_TYPE_WEP40;
-                                       }
-                                       else
-                                               ieee->pairwise_key_type = KEY_TYPE_NA;
-
-                                       if (ieee->pairwise_key_type)
-                                       {
-                                               memcpy((u8*)key, ipw->u.crypt.key, 16);
-                                               EnableHWSecurityConfig8192(dev);
-                                       //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching!
-                                       //added by WB.
-                                               setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
-                                               if (ieee->auth_mode != 2)
-                                               setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
-                                       }
+                                       if (ipw->u.crypt.key_len == 13)
+                                               ieee->pairwise_key_type = KEY_TYPE_WEP104;
+                                       else if (ipw->u.crypt.key_len == 5)
+                                               ieee->pairwise_key_type = KEY_TYPE_WEP40;
                                }
-                               else //if (ipw->u.crypt.idx) //group key use idx > 0
+                               else
+                                       ieee->pairwise_key_type = KEY_TYPE_NA;
+
+                               if (ieee->pairwise_key_type)
                                {
                                        memcpy((u8*)key, ipw->u.crypt.key, 16);
-                                       if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
-                                               ieee->group_key_type= KEY_TYPE_CCMP;
-                                       else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
-                                               ieee->group_key_type = KEY_TYPE_TKIP;
-                                       else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
-                                       {
-                                               if (ipw->u.crypt.key_len == 13)
-                                                       ieee->group_key_type = KEY_TYPE_WEP104;
-                                               else if (ipw->u.crypt.key_len == 5)
-                                                       ieee->group_key_type = KEY_TYPE_WEP40;
-                                       }
-                                       else
-                                               ieee->group_key_type = KEY_TYPE_NA;
+                                       EnableHWSecurityConfig8192(dev);
+                               //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching!
+                               //added by WB.
+                                       setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
+                                       if (ieee->auth_mode != 2)
+                                       setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8*)ieee->ap_mac_addr, 0, key);
+                               }
+                       }
+                       else //if (ipw->u.crypt.idx) //group key use idx > 0
+                       {
+                               memcpy((u8*)key, ipw->u.crypt.key, 16);
+                               if (strcmp(ipw->u.crypt.alg, "CCMP") == 0)
+                                       ieee->group_key_type= KEY_TYPE_CCMP;
+                               else if (strcmp(ipw->u.crypt.alg, "TKIP") == 0)
+                                       ieee->group_key_type = KEY_TYPE_TKIP;
+                               else if (strcmp(ipw->u.crypt.alg, "WEP") == 0)
+                               {
+                                       if (ipw->u.crypt.key_len == 13)
+                                               ieee->group_key_type = KEY_TYPE_WEP104;
+                                       else if (ipw->u.crypt.key_len == 5)
+                                               ieee->group_key_type = KEY_TYPE_WEP40;
+                               }
+                               else
+                                       ieee->group_key_type = KEY_TYPE_NA;
 
-                                       if (ieee->group_key_type)
-                                       {
-                                                       setKey( dev,
-                                                               ipw->u.crypt.idx,
-                                                               ipw->u.crypt.idx,               //KeyIndex
-                                                               ieee->group_key_type,   //KeyType
-                                                               broadcast_addr, //MacAddr
-                                                               0,              //DefaultKey
-                                                               key);           //KeyContent
-                                       }
+                               if (ieee->group_key_type)
+                               {
+                                               setKey( dev,
+                                                       ipw->u.crypt.idx,
+                                                       ipw->u.crypt.idx,               //KeyIndex
+                                                       ieee->group_key_type,   //KeyType
+                                                       broadcast_addr, //MacAddr
+                                                       0,              //DefaultKey
+                                                       key);           //KeyContent
                                }
                        }
+               }
 #ifdef JOHN_HWSEC_DEBUG
                //john's test 0711
                printk("@@ wrq->u pointer = ");
@@ -4437,7 +4425,7 @@ int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
                break;
 
-           default:
+       default:
                ret = -EOPNOTSUPP;
                break;
        }
@@ -4454,49 +4442,49 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate)
 
        if(!bIsHT) {
                switch(rate) {
-                       case DESC90_RATE1M:   ret_rate = MGN_1M;         break;
-                       case DESC90_RATE2M:   ret_rate = MGN_2M;         break;
-                       case DESC90_RATE5_5M: ret_rate = MGN_5_5M;       break;
-                       case DESC90_RATE11M:  ret_rate = MGN_11M;        break;
-                       case DESC90_RATE6M:   ret_rate = MGN_6M;         break;
-                       case DESC90_RATE9M:   ret_rate = MGN_9M;         break;
-                       case DESC90_RATE12M:  ret_rate = MGN_12M;        break;
-                       case DESC90_RATE18M:  ret_rate = MGN_18M;        break;
-                       case DESC90_RATE24M:  ret_rate = MGN_24M;        break;
-                       case DESC90_RATE36M:  ret_rate = MGN_36M;        break;
-                       case DESC90_RATE48M:  ret_rate = MGN_48M;        break;
-                       case DESC90_RATE54M:  ret_rate = MGN_54M;        break;
-
-                       default:
-                               ret_rate = 0xff;
-                               RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
-                               break;
+               case DESC90_RATE1M:   ret_rate = MGN_1M;         break;
+               case DESC90_RATE2M:   ret_rate = MGN_2M;         break;
+               case DESC90_RATE5_5M: ret_rate = MGN_5_5M;       break;
+               case DESC90_RATE11M:  ret_rate = MGN_11M;        break;
+               case DESC90_RATE6M:   ret_rate = MGN_6M;         break;
+               case DESC90_RATE9M:   ret_rate = MGN_9M;         break;
+               case DESC90_RATE12M:  ret_rate = MGN_12M;        break;
+               case DESC90_RATE18M:  ret_rate = MGN_18M;        break;
+               case DESC90_RATE24M:  ret_rate = MGN_24M;        break;
+               case DESC90_RATE36M:  ret_rate = MGN_36M;        break;
+               case DESC90_RATE48M:  ret_rate = MGN_48M;        break;
+               case DESC90_RATE54M:  ret_rate = MGN_54M;        break;
+
+               default:
+                       ret_rate = 0xff;
+                       RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+                       break;
                }
 
        } else {
                switch(rate) {
-                       case DESC90_RATEMCS0:   ret_rate = MGN_MCS0;    break;
-                       case DESC90_RATEMCS1:   ret_rate = MGN_MCS1;    break;
-                       case DESC90_RATEMCS2:   ret_rate = MGN_MCS2;    break;
-                       case DESC90_RATEMCS3:   ret_rate = MGN_MCS3;    break;
-                       case DESC90_RATEMCS4:   ret_rate = MGN_MCS4;    break;
-                       case DESC90_RATEMCS5:   ret_rate = MGN_MCS5;    break;
-                       case DESC90_RATEMCS6:   ret_rate = MGN_MCS6;    break;
-                       case DESC90_RATEMCS7:   ret_rate = MGN_MCS7;    break;
-                       case DESC90_RATEMCS8:   ret_rate = MGN_MCS8;    break;
-                       case DESC90_RATEMCS9:   ret_rate = MGN_MCS9;    break;
-                       case DESC90_RATEMCS10:  ret_rate = MGN_MCS10;   break;
-                       case DESC90_RATEMCS11:  ret_rate = MGN_MCS11;   break;
-                       case DESC90_RATEMCS12:  ret_rate = MGN_MCS12;   break;
-                       case DESC90_RATEMCS13:  ret_rate = MGN_MCS13;   break;
-                       case DESC90_RATEMCS14:  ret_rate = MGN_MCS14;   break;
-                       case DESC90_RATEMCS15:  ret_rate = MGN_MCS15;   break;
-                       case DESC90_RATEMCS32:  ret_rate = (0x80|0x20); break;
-
-                       default:
-                               ret_rate = 0xff;
-                               RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT);
-                               break;
+               case DESC90_RATEMCS0:   ret_rate = MGN_MCS0;    break;
+               case DESC90_RATEMCS1:   ret_rate = MGN_MCS1;    break;
+               case DESC90_RATEMCS2:   ret_rate = MGN_MCS2;    break;
+               case DESC90_RATEMCS3:   ret_rate = MGN_MCS3;    break;
+               case DESC90_RATEMCS4:   ret_rate = MGN_MCS4;    break;
+               case DESC90_RATEMCS5:   ret_rate = MGN_MCS5;    break;
+               case DESC90_RATEMCS6:   ret_rate = MGN_MCS6;    break;
+               case DESC90_RATEMCS7:   ret_rate = MGN_MCS7;    break;
+               case DESC90_RATEMCS8:   ret_rate = MGN_MCS8;    break;
+               case DESC90_RATEMCS9:   ret_rate = MGN_MCS9;    break;
+               case DESC90_RATEMCS10:  ret_rate = MGN_MCS10;   break;
+               case DESC90_RATEMCS11:  ret_rate = MGN_MCS11;   break;
+               case DESC90_RATEMCS12:  ret_rate = MGN_MCS12;   break;
+               case DESC90_RATEMCS13:  ret_rate = MGN_MCS13;   break;
+               case DESC90_RATEMCS14:  ret_rate = MGN_MCS14;   break;
+               case DESC90_RATEMCS15:  ret_rate = MGN_MCS15;   break;
+               case DESC90_RATEMCS32:  ret_rate = (0x80|0x20); break;
+
+               default:
+                       ret_rate = 0xff;
+                       RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT);
+                       break;
                }
        }
 
@@ -4555,12 +4543,12 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee802
        u8      rfpath;
        u32     nspatial_stream, tmp_val;
        //u8    i;
-       static u32 slide_rssi_index=0, slide_rssi_statistics=0;
-       static u32 slide_evm_index=0, slide_evm_statistics=0;
-       static u32 last_rssi=0, last_evm=0;
+       static u32 slide_rssi_index, slide_rssi_statistics;
+       static u32 slide_evm_index, slide_evm_statistics;
+       static u32 last_rssi, last_evm;
 
-       static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0;
-       static u32 last_beacon_adc_pwdb=0;
+       static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics;
+       static u32 last_beacon_adc_pwdb;
 
        struct ieee80211_hdr_3addr *hdr;
        u16 sc ;
@@ -4578,11 +4566,8 @@ void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee802
        {
                // if previous packet is not aggregated packet
                bcheck = true;
-       }else
-       {
        }
 
-
        if(slide_rssi_statistics++ >= PHY_RSSI_SLID_WIN_MAX)
        {
                slide_rssi_statistics = PHY_RSSI_SLID_WIN_MAX;
@@ -4808,9 +4793,9 @@ rtl819x_evm_dbtopercentage(
     ret_val = value;
 
     if(ret_val >= 0)
-        ret_val = 0;
+       ret_val = 0;
     if(ret_val <= -33)
-        ret_val = -33;
+       ret_val = -33;
     ret_val = 0 - ret_val;
     ret_val*=3;
        if(ret_val == 99)
@@ -4819,7 +4804,7 @@ rtl819x_evm_dbtopercentage(
 }
 //
 //     Description:
-//     We want good-looking for signal strength/quality
+//     We want good-looking for signal strength/quality
 //     2007/7/19 01:09, by cosa.
 //
 long
@@ -5203,7 +5188,7 @@ void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
 * Overview:    Record the received data rate
 *
 * Input:
-*      struct net_device *dev
+*      struct net_device *dev
 *      struct ieee80211_rx_stats *stats
 *
 * Output:
@@ -5581,7 +5566,7 @@ rtl819xusb_process_received_packet(
        )
 {
 //     bool bfreerfd=false, bqueued=false;
-       u8*     frame;
+       u8*     frame;
        u16     frame_len=0;
        struct r8192_priv *priv = ieee80211_priv(dev);
 //     u8                      index = 0;
@@ -5682,10 +5667,6 @@ void rtl8192_rx_cmd(struct sk_buff *skb)
 
                dev_kfree_skb_any(skb);
        }
-       else
-               ;
-
-
 }
 
 void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
@@ -5697,25 +5678,25 @@ void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
                info = (struct rtl8192_rx_info *)skb->cb;
                switch (info->out_pipe) {
                /* Nomal packet pipe */
-                       case 3:
-                               //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe);
-                               priv->IrpPendingCount--;
-                               rtl8192_rx_nomal(skb);
-                               break;
+               case 3:
+                       //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe);
+                       priv->IrpPendingCount--;
+                       rtl8192_rx_nomal(skb);
+                       break;
 
-                               /* Command packet pipe */
-                       case 9:
-                               RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\
-                                               info->out_pipe);
+                       /* Command packet pipe */
+               case 9:
+                       RT_TRACE(COMP_RECV, "command in-pipe index(%d)\n",\
+                                       info->out_pipe);
 
-                               rtl8192_rx_cmd(skb);
-                               break;
+                       rtl8192_rx_cmd(skb);
+                       break;
 
-                       default: /* should never get here! */
-                               RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\
-                                               info->out_pipe);
-                               dev_kfree_skb(skb);
-                               break;
+               default: /* should never get here! */
+                       RT_TRACE(COMP_ERR, "Unknown in-pipe index(%d)\n",\
+                                       info->out_pipe);
+                       dev_kfree_skb(skb);
+                       break;
 
                }
        }
@@ -6007,7 +5988,7 @@ void setKey(      struct net_device *dev,
        //              printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo));
                }
                else if(i==1){//MAC
-                       TargetContent = (u32)(*(MacAddr+2))      |
+                       TargetContent = (u32)(*(MacAddr+2))      |
                                        (u32)(*(MacAddr+3)) <<  8|
                                        (u32)(*(MacAddr+4)) << 16|
                                        (u32)(*(MacAddr+5)) << 24;
index cd8dc85e9c0f7399319f63528a0423dafa9e4bbd..ea46717f1fadfa2ce2801d325c6534fa22e27203 100644 (file)
@@ -8,7 +8,7 @@ Abstract:
        HW dynamic mechanism.
 
 Major Change History:
-       When            Who                             What
+       When            Who                             What
        ----------      --------------- -------------------------------
        2008-05-14      amy                     create version 0 porting from windows code.
 
@@ -25,9 +25,9 @@ Major Change History:
 // Indicate different AP vendor for IOT issue.
 //
 static u32 edca_setting_DL[HT_IOT_PEER_MAX] =
-               { 0x5e4322,     0x5e4322,       0x5e4322,       0x604322,       0xa44f,         0x5ea44f};
+               { 0x5e4322,     0x5e4322,       0x5e4322,       0x604322,       0xa44f,         0x5ea44f};
 static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
-               { 0x5e4322,     0xa44f,         0x5e4322,       0x604322,       0x5ea44f,       0x5ea44f};
+               { 0x5e4322,     0xa44f,         0x5e4322,       0x604322,       0x5ea44f,       0x5ea44f};
 
 
 #define RTK_UL_EDCA 0xa44f
@@ -134,7 +134,7 @@ static      void dm_check_pbc_gpio(struct net_device *dev);
 
 // DM --> Check current RX RF path state
 static void    dm_check_rx_path_selection(struct net_device *dev);
-static         void dm_init_rxpath_selection(struct net_device *dev);
+static void dm_init_rxpath_selection(struct net_device *dev);
 static void dm_rxpath_sel_byrssi(struct net_device *dev);
 
 
@@ -201,8 +201,8 @@ extern void deinit_hal_dm(struct net_device *dev)
 void dm_CheckRxAggregation(struct net_device *dev) {
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
-       static unsigned long    lastTxOkCnt = 0;
-       static unsigned long    lastRxOkCnt = 0;
+       static unsigned long    lastTxOkCnt;
+       static unsigned long    lastRxOkCnt;
        unsigned long           curTxOkCnt = 0;
        unsigned long           curRxOkCnt = 0;
 
@@ -259,7 +259,7 @@ extern  void    hal_dm_watchdog(struct net_device *dev)
 {
        //struct r8192_priv *priv = ieee80211_priv(dev);
 
-       //static u8     previous_bssid[6] ={0};
+       //static u8     previous_bssid[6] ={0};
 
        /*Add by amy 2008/05/15 ,porting from windows code.*/
        dm_check_rate_adaptive(dev);
@@ -315,21 +315,21 @@ extern void init_rate_adaptive(struct net_device * dev)
        {
                // 07/10/08 MH Modify for RA smooth scheme.
                /* 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code.*/
-               pra->upper_rssi_threshold_ratr          =       0x8f0f0000;
-               pra->middle_rssi_threshold_ratr         =       0x8f0ff000;
-               pra->low_rssi_threshold_ratr            =       0x8f0ff001;
-               pra->low_rssi_threshold_ratr_40M        =       0x8f0ff005;
-               pra->low_rssi_threshold_ratr_20M        =       0x8f0ff001;
-               pra->ping_rssi_ratr     =       0x0000000d;//cosa add for test
+               pra->upper_rssi_threshold_ratr          =       0x8f0f0000;
+               pra->middle_rssi_threshold_ratr         =       0x8f0ff000;
+               pra->low_rssi_threshold_ratr            =       0x8f0ff001;
+               pra->low_rssi_threshold_ratr_40M        =       0x8f0ff005;
+               pra->low_rssi_threshold_ratr_20M        =       0x8f0ff001;
+               pra->ping_rssi_ratr     =       0x0000000d;//cosa add for test
        }
        else if (priv->rf_type == RF_1T2R)
        {
-               pra->upper_rssi_threshold_ratr          =       0x000f0000;
-               pra->middle_rssi_threshold_ratr         =       0x000ff000;
-               pra->low_rssi_threshold_ratr            =       0x000ff001;
-               pra->low_rssi_threshold_ratr_40M        =       0x000ff005;
-               pra->low_rssi_threshold_ratr_20M        =       0x000ff001;
-               pra->ping_rssi_ratr     =       0x0000000d;//cosa add for test
+               pra->upper_rssi_threshold_ratr          =       0x000f0000;
+               pra->middle_rssi_threshold_ratr         =       0x000ff000;
+               pra->low_rssi_threshold_ratr            =       0x000ff001;
+               pra->low_rssi_threshold_ratr_40M        =       0x000ff005;
+               pra->low_rssi_threshold_ratr_20M        =       0x000ff001;
+               pra->ping_rssi_ratr     =       0x0000000d;//cosa add for test
        }
 
 }      // InitRateAdaptive
@@ -348,7 +348,7 @@ extern void init_rate_adaptive(struct net_device * dev)
  *
  * Revised History:
  *     When            Who             Remark
- *     05/26/08        amy     Create version 0 porting from windows code.
+ *     05/26/08        amy     Create version 0 porting from windows code.
  *
  *---------------------------------------------------------------------------*/
 static void dm_check_rate_adaptive(struct net_device * dev)
@@ -359,7 +359,7 @@ static void dm_check_rate_adaptive(struct net_device * dev)
        u32                                             currentRATR, targetRATR = 0;
        u32                                             LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
        bool                                            bshort_gi_enabled = false;
-       static u8                                       ping_rssi_state=0;
+       static u8                                       ping_rssi_state;
 
 
        if(!priv->up)
@@ -413,14 +413,14 @@ static void dm_check_rate_adaptive(struct net_device * dev)
                   to prevent jumping frequently. */
                if (pra->ratr_state == DM_RATR_STA_HIGH)
                {
-                       HighRSSIThreshForRA     = pra->high2low_rssi_thresh_for_ra;
+                       HighRSSIThreshForRA     = pra->high2low_rssi_thresh_for_ra;
                        LowRSSIThreshForRA      = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
                                        (pra->low_rssi_thresh_for_ra40M):(pra->low_rssi_thresh_for_ra20M);
                }
                else if (pra->ratr_state == DM_RATR_STA_LOW)
                {
                        HighRSSIThreshForRA     = pra->high_rssi_thresh_for_ra;
-                       LowRSSIThreshForRA      = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
+                       LowRSSIThreshForRA      = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)?
                                        (pra->low2high_rssi_thresh_for_ra40M):(pra->low2high_rssi_thresh_for_ra20M);
                }
                else
@@ -599,7 +599,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev)
        u32                                             Value;
        u8                                              Pwr_Flag;
        u16                                             Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver=0;
-       //RT_STATUS                             rtStatus = RT_STATUS_SUCCESS;
+       //RT_STATUS                             rtStatus = RT_STATUS_SUCCESS;
        bool rtStatus = true;
        u32                                             delta=0;
 
@@ -954,79 +954,79 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
        struct r8192_priv *priv = ieee80211_priv(dev);
 
        //Initial the Tx BB index and mapping value
-       priv->txbbgain_table[0].txbb_iq_amplifygain =                   12;
+       priv->txbbgain_table[0].txbb_iq_amplifygain =                   12;
        priv->txbbgain_table[0].txbbgain_value=0x7f8001fe;
-       priv->txbbgain_table[1].txbb_iq_amplifygain =                   11;
+       priv->txbbgain_table[1].txbb_iq_amplifygain =                   11;
        priv->txbbgain_table[1].txbbgain_value=0x788001e2;
-       priv->txbbgain_table[2].txbb_iq_amplifygain =                   10;
+       priv->txbbgain_table[2].txbb_iq_amplifygain =                   10;
        priv->txbbgain_table[2].txbbgain_value=0x71c001c7;
-       priv->txbbgain_table[3].txbb_iq_amplifygain =                   9;
+       priv->txbbgain_table[3].txbb_iq_amplifygain =                   9;
        priv->txbbgain_table[3].txbbgain_value=0x6b8001ae;
-       priv->txbbgain_table[4].txbb_iq_amplifygain =                  8;
+       priv->txbbgain_table[4].txbb_iq_amplifygain =                  8;
        priv->txbbgain_table[4].txbbgain_value=0x65400195;
-       priv->txbbgain_table[5].txbb_iq_amplifygain =                  7;
+       priv->txbbgain_table[5].txbb_iq_amplifygain =                  7;
        priv->txbbgain_table[5].txbbgain_value=0x5fc0017f;
-       priv->txbbgain_table[6].txbb_iq_amplifygain =                  6;
+       priv->txbbgain_table[6].txbb_iq_amplifygain =                  6;
        priv->txbbgain_table[6].txbbgain_value=0x5a400169;
-       priv->txbbgain_table[7].txbb_iq_amplifygain =                  5;
+       priv->txbbgain_table[7].txbb_iq_amplifygain =                  5;
        priv->txbbgain_table[7].txbbgain_value=0x55400155;
-       priv->txbbgain_table[8].txbb_iq_amplifygain =                  4;
+       priv->txbbgain_table[8].txbb_iq_amplifygain =                  4;
        priv->txbbgain_table[8].txbbgain_value=0x50800142;
-       priv->txbbgain_table[9].txbb_iq_amplifygain =                  3;
+       priv->txbbgain_table[9].txbb_iq_amplifygain =                  3;
        priv->txbbgain_table[9].txbbgain_value=0x4c000130;
-       priv->txbbgain_table[10].txbb_iq_amplifygain =                 2;
+       priv->txbbgain_table[10].txbb_iq_amplifygain =                 2;
        priv->txbbgain_table[10].txbbgain_value=0x47c0011f;
-       priv->txbbgain_table[11].txbb_iq_amplifygain =                 1;
+       priv->txbbgain_table[11].txbb_iq_amplifygain =                 1;
        priv->txbbgain_table[11].txbbgain_value=0x43c0010f;
-       priv->txbbgain_table[12].txbb_iq_amplifygain =                 0;
+       priv->txbbgain_table[12].txbb_iq_amplifygain =                 0;
        priv->txbbgain_table[12].txbbgain_value=0x40000100;
-       priv->txbbgain_table[13].txbb_iq_amplifygain =                 -1;
+       priv->txbbgain_table[13].txbb_iq_amplifygain =                 -1;
        priv->txbbgain_table[13].txbbgain_value=0x3c8000f2;
-       priv->txbbgain_table[14].txbb_iq_amplifygain =               -2;
+       priv->txbbgain_table[14].txbb_iq_amplifygain =               -2;
        priv->txbbgain_table[14].txbbgain_value=0x390000e4;
-       priv->txbbgain_table[15].txbb_iq_amplifygain =               -3;
+       priv->txbbgain_table[15].txbb_iq_amplifygain =               -3;
        priv->txbbgain_table[15].txbbgain_value=0x35c000d7;
-       priv->txbbgain_table[16].txbb_iq_amplifygain =               -4;
+       priv->txbbgain_table[16].txbb_iq_amplifygain =               -4;
        priv->txbbgain_table[16].txbbgain_value=0x32c000cb;
-       priv->txbbgain_table[17].txbb_iq_amplifygain =               -5;
+       priv->txbbgain_table[17].txbb_iq_amplifygain =               -5;
        priv->txbbgain_table[17].txbbgain_value=0x300000c0;
-       priv->txbbgain_table[18].txbb_iq_amplifygain =                      -6;
+       priv->txbbgain_table[18].txbb_iq_amplifygain =                      -6;
        priv->txbbgain_table[18].txbbgain_value=0x2d4000b5;
-       priv->txbbgain_table[19].txbb_iq_amplifygain =               -7;
+       priv->txbbgain_table[19].txbb_iq_amplifygain =               -7;
        priv->txbbgain_table[19].txbbgain_value=0x2ac000ab;
-       priv->txbbgain_table[20].txbb_iq_amplifygain =               -8;
+       priv->txbbgain_table[20].txbb_iq_amplifygain =               -8;
        priv->txbbgain_table[20].txbbgain_value=0x288000a2;
-       priv->txbbgain_table[21].txbb_iq_amplifygain =               -9;
+       priv->txbbgain_table[21].txbb_iq_amplifygain =               -9;
        priv->txbbgain_table[21].txbbgain_value=0x26000098;
-       priv->txbbgain_table[22].txbb_iq_amplifygain =               -10;
+       priv->txbbgain_table[22].txbb_iq_amplifygain =               -10;
        priv->txbbgain_table[22].txbbgain_value=0x24000090;
-       priv->txbbgain_table[23].txbb_iq_amplifygain =               -11;
+       priv->txbbgain_table[23].txbb_iq_amplifygain =               -11;
        priv->txbbgain_table[23].txbbgain_value=0x22000088;
-       priv->txbbgain_table[24].txbb_iq_amplifygain =               -12;
+       priv->txbbgain_table[24].txbb_iq_amplifygain =               -12;
        priv->txbbgain_table[24].txbbgain_value=0x20000080;
-       priv->txbbgain_table[25].txbb_iq_amplifygain =               -13;
+       priv->txbbgain_table[25].txbb_iq_amplifygain =               -13;
        priv->txbbgain_table[25].txbbgain_value=0x1a00006c;
-       priv->txbbgain_table[26].txbb_iq_amplifygain =               -14;
+       priv->txbbgain_table[26].txbb_iq_amplifygain =               -14;
        priv->txbbgain_table[26].txbbgain_value=0x1c800072;
-       priv->txbbgain_table[27].txbb_iq_amplifygain =               -15;
+       priv->txbbgain_table[27].txbb_iq_amplifygain =               -15;
        priv->txbbgain_table[27].txbbgain_value=0x18000060;
-       priv->txbbgain_table[28].txbb_iq_amplifygain =               -16;
+       priv->txbbgain_table[28].txbb_iq_amplifygain =               -16;
        priv->txbbgain_table[28].txbbgain_value=0x19800066;
-       priv->txbbgain_table[29].txbb_iq_amplifygain =               -17;
+       priv->txbbgain_table[29].txbb_iq_amplifygain =               -17;
        priv->txbbgain_table[29].txbbgain_value=0x15800056;
-       priv->txbbgain_table[30].txbb_iq_amplifygain =               -18;
+       priv->txbbgain_table[30].txbb_iq_amplifygain =               -18;
        priv->txbbgain_table[30].txbbgain_value=0x26c0005b;
-       priv->txbbgain_table[31].txbb_iq_amplifygain =               -19;
+       priv->txbbgain_table[31].txbb_iq_amplifygain =               -19;
        priv->txbbgain_table[31].txbbgain_value=0x14400051;
-       priv->txbbgain_table[32].txbb_iq_amplifygain =               -20;
+       priv->txbbgain_table[32].txbb_iq_amplifygain =               -20;
        priv->txbbgain_table[32].txbbgain_value=0x24400051;
-       priv->txbbgain_table[33].txbb_iq_amplifygain =               -21;
+       priv->txbbgain_table[33].txbb_iq_amplifygain =               -21;
        priv->txbbgain_table[33].txbbgain_value=0x1300004c;
-       priv->txbbgain_table[34].txbb_iq_amplifygain =               -22;
+       priv->txbbgain_table[34].txbb_iq_amplifygain =               -22;
        priv->txbbgain_table[34].txbbgain_value=0x12000048;
-       priv->txbbgain_table[35].txbb_iq_amplifygain =               -23;
+       priv->txbbgain_table[35].txbb_iq_amplifygain =               -23;
        priv->txbbgain_table[35].txbbgain_value=0x11000044;
-       priv->txbbgain_table[36].txbb_iq_amplifygain =               -24;
+       priv->txbbgain_table[36].txbb_iq_amplifygain =               -24;
        priv->txbbgain_table[36].txbbgain_value=0x10000040;
 
        //ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29
@@ -1486,7 +1486,7 @@ void dm_initialize_txpower_tracking(struct net_device *dev)
 static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u32 tx_power_track_counter = 0;
+       static u32 tx_power_track_counter;
 
        if(!priv->btxpower_tracking)
                return;
@@ -1505,7 +1505,7 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
 static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u8       TM_Trigger=0;
+       static u8       TM_Trigger;
        //DbgPrint("dm_CheckTXPowerTracking() \n");
        if(!priv->btxpower_tracking)
                return;
@@ -1564,40 +1564,40 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
        TempVal = 0;
        if(!bInCH14){
                //Write 0xa22 0xa23
-               TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
+               TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1,bMaskHWord, TempVal);
                //Write 0xa24 ~ 0xa27
                TempVal = 0;
-               TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[2] +
+               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] +
+               TempVal =       priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[6] +
                                        (priv->cck_txbbgain_table[priv->cck_present_attentuation].ccktxbb_valuearray[7]<<8) ;
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
        }
        else
        {
-               TempVal =       priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
+               TempVal =       priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[0] +
                                        (priv->cck_txbbgain_ch14_table[priv->cck_present_attentuation].ccktxbb_valuearray[1]<<8) ;
 
                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] +
+               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] +
+               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) ;
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort,bMaskLWord, TempVal);
@@ -1615,14 +1615,14 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,    bool  bInCH
        if(!bInCH14)
        {
                //Write 0xa22 0xa23
-               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
+               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ;
                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);
                //Write 0xa24 ~ 0xa27
                TempVal = 0;
-               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
+               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16 )+
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24);
@@ -1631,7 +1631,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                        rCCK0_TxFilter2, TempVal);
                //Write 0xa28  0xa29
                TempVal = 0;
-               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
+               TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
@@ -1642,7 +1642,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
        {
 //             priv->CCKTxPowerAdjustCntNotCh14++;     //cosa add for debug.
                //Write 0xa22 0xa23
-               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][0] +
+               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][0] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ;
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
@@ -1650,7 +1650,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                        rCCK0_TxFilter1, TempVal);
                //Write 0xa24 ~ 0xa27
                TempVal = 0;
-               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][2] +
+               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][2] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
                                        (CCKSwingTable_Ch14[priv->CCK_index][4]<<16 )+
                                        (CCKSwingTable_Ch14[priv->CCK_index][5]<<24);
@@ -1659,7 +1659,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                        rCCK0_TxFilter2, TempVal);
                //Write 0xa28  0xa29
                TempVal = 0;
-               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
+               TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
                                        (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
@@ -1713,7 +1713,7 @@ static void dm_txpower_reset_recovery(
 extern void dm_restore_dynamic_mechanism_state(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       u32     reg_ratr = priv->rate_adaptive.last_ratr;
+       u32     reg_ratr = priv->rate_adaptive.last_ratr;
 
        if(!priv->up)
        {
@@ -1934,7 +1934,7 @@ dm_change_rxpath_selection_setting(
        s32             DM_Value)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       prate_adaptive  pRA = (prate_adaptive)&(priv->rate_adaptive);
+       prate_adaptive  pRA = (prate_adaptive)&(priv->rate_adaptive);
 
 
        if(DM_Type == 0)
@@ -2036,8 +2036,8 @@ static void dm_dig_init(struct net_device *dev)
        dm_digtable.dig_highpwr_state   = DM_STA_DIG_MAX;
        dm_digtable.initialgain_lowerbound_state = false;
 
-       dm_digtable.rssi_low_thresh     = DM_DIG_THRESH_LOW;
-       dm_digtable.rssi_high_thresh    = DM_DIG_THRESH_HIGH;
+       dm_digtable.rssi_low_thresh     = DM_DIG_THRESH_LOW;
+       dm_digtable.rssi_high_thresh    = DM_DIG_THRESH_HIGH;
 
        dm_digtable.rssi_high_power_lowthresh = DM_DIG_HIGH_PWR_THRESH_LOW;
        dm_digtable.rssi_high_power_highthresh = DM_DIG_HIGH_PWR_THRESH_HIGH;
@@ -2091,7 +2091,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi(
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u8 i;
-       static u8       fw_dig=0;
+       static u8       fw_dig;
 
        if (dm_digtable.dig_enable_flag == false)
                return;
@@ -2131,7 +2131,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
        struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u32 reset_cnt = 0;
+       static u32 reset_cnt;
        u8 i;
 
        if (dm_digtable.dig_enable_flag == false)
@@ -2319,7 +2319,7 @@ static void dm_ctrl_initgain_byrssi_highpwr(
        struct net_device * dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u32 reset_cnt_highpwr = 0;
+       static u32 reset_cnt_highpwr;
 
        // For smooth, we can not change high power DIG state in the range.
        if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) &&
@@ -2395,8 +2395,8 @@ static void dm_initial_gain(
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u8                                      initial_gain=0;
-       static u8                               initialized=0, force_write=0;
-       static u32                      reset_cnt=0;
+       static u8                               initialized, force_write;
+       static u32                      reset_cnt;
 
        if(dm_digtable.dig_algorithm_switch)
        {
@@ -2462,8 +2462,8 @@ static void dm_pd_th(
        struct net_device * dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u8                               initialized=0, force_write=0;
-       static u32                      reset_cnt = 0;
+       static u8                               initialized, force_write;
+       static u32                      reset_cnt;
 
        if(dm_digtable.dig_algorithm_switch)
        {
@@ -2574,8 +2574,8 @@ static    void dm_cs_ratio(
        struct net_device * dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       static u8                               initialized=0,force_write=0;
-       static u32                      reset_cnt = 0;
+       static u8                               initialized,force_write;
+       static u32                      reset_cnt;
 
        if(dm_digtable.dig_algorithm_switch)
        {
@@ -2651,8 +2651,8 @@ static void dm_check_edca_turbo(
        //PSTA_QOS                      pStaQos = pMgntInfo->pStaQos;
 
        // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
-       static unsigned long                    lastTxOkCnt = 0;
-       static unsigned long                    lastRxOkCnt = 0;
+       static unsigned long                    lastTxOkCnt;
+       static unsigned long                    lastRxOkCnt;
        unsigned long                           curTxOkCnt = 0;
        unsigned long                           curRxOkCnt = 0;
 
@@ -2785,8 +2785,8 @@ static void dm_ctstoself(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
        PRT_HIGH_THROUGHPUT     pHTInfo = priv->ieee80211->pHTInfo;
-       static unsigned long                            lastTxOkCnt = 0;
-       static unsigned long                            lastRxOkCnt = 0;
+       static unsigned long                            lastTxOkCnt;
+       static unsigned long                            lastRxOkCnt;
        unsigned long                                           curTxOkCnt = 0;
        unsigned long                                           curRxOkCnt = 0;
 
@@ -2871,7 +2871,7 @@ static void dm_check_rfctrl_gpio(struct net_device * dev)
  *
  * Revised History:
  *     When            Who             Remark
- *     05/28/2008      amy     Create Version 0 porting from windows code.
+ *     05/28/2008      amy     Create Version 0 porting from windows code.
  *
  *---------------------------------------------------------------------------*/
 static void    dm_check_pbc_gpio(struct net_device *dev)
@@ -3044,7 +3044,7 @@ static void dm_rxpath_sel_byrssi(struct net_device * dev)
        u8                              cck_rx_ver2_max_index=0, cck_rx_ver2_min_index=0, cck_rx_ver2_sec_index=0;
        u8                              cur_rf_rssi;
        long                            cur_cck_pwdb;
-       static u8                       disabled_rf_cnt=0, cck_Rx_Path_initialized=0;
+       static u8                       disabled_rf_cnt, cck_Rx_Path_initialized;
        u8                              update_cck_rx_path;
 
        if(priv->rf_type != RF_2T4R)
@@ -3517,8 +3517,8 @@ static void dm_EndSWFsync(struct net_device *dev)
 static void dm_StartSWFsync(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       u32                     rateIndex;
-       u32                     rateBitmap;
+       u32                     rateIndex;
+       u32                     rateBitmap;
 
        RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
        // Initial rate record to zero, start to record.
@@ -3569,9 +3569,9 @@ void dm_check_fsync(struct net_device *dev)
 #define        RegC38_NonFsync_Other_AP        1
 #define        RegC38_Fsync_AP_BCM             2
        struct r8192_priv *priv = ieee80211_priv(dev);
-       //u32                   framesyncC34;
+       //u32                   framesyncC34;
        static u8               reg_c38_State=RegC38_Default;
-       static u32      reset_cnt=0;
+       static u32      reset_cnt;
 
        RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval %d\n", priv->ieee80211->fsync_rssi_threshold, priv->ieee80211->fsync_time_interval, priv->ieee80211->fsync_multiple_timeinterval);
        RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n", priv->ieee80211->fsync_rate_bitmap, priv->ieee80211->fsync_firstdiff_ratethreshold, priv->ieee80211->fsync_seconddiff_ratethreshold);
@@ -3887,4 +3887,3 @@ static void dm_send_rssi_tofw(struct net_device *dev)
 }
 
 /*---------------------------Define function prototype------------------------*/
-
index 3ceb59b9eca78a5c4ddc611afb830ffa26a1fc05..ffb083c958ad52de919fc0b4b97850a7dcf9ba9d 100644 (file)
@@ -13,7 +13,7 @@
  *
  * History:
  *     Data            Who             Remark
- *     10/04/2007  MHC         Create initial version.
+ *     10/04/2007  MHC         Create initial version.
  *
  *****************************************************************************/
  /* Check to see if the file has been included already.  */
 #define                TX_POWER_NEAR_FIELD_THRESH_LOW          62
 //added by amy for atheros AP
 #define         TX_POWER_ATHEROAP_THRESH_HIGH           78
-#define        TX_POWER_ATHEROAP_THRESH_LOW            72
+#define                TX_POWER_ATHEROAP_THRESH_LOW            72
 
 //defined by vivi, for showing on UI
-#define                Current_Tx_Rate_Reg         0x1b8
-#define                Initial_Tx_Rate_Reg               0x1b9
-#define                Tx_Retry_Count_Reg         0x1ac
+#define                        Current_Tx_Rate_Reg         0x1b8
+#define                        Initial_Tx_Rate_Reg               0x1b9
+#define                        Tx_Retry_Count_Reg         0x1ac
 #define                RegC38_TH                                20
 /*--------------------------Define Parameters-------------------------------*/
 
 
 /*------------------------------Define structure----------------------------*/
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
-typedef struct _dynamic_initial_gain_threshold_
-{
+typedef struct _dynamic_initial_gain_threshold_ {
        u8              dig_enable_flag;
        u8              dig_algorithm;
        u8              dbg_mode;
@@ -132,8 +131,8 @@ typedef enum tag_dynamic_init_gain_operation_type_definition
        DIG_TYPE_PWDB_FACTOR                    = 8,
        DIG_TYPE_RX_GAIN_MIN                            = 9,
        DIG_TYPE_RX_GAIN_MAX                            = 10,
-       DIG_TYPE_ENABLE                 = 20,
-       DIG_TYPE_DISABLE                = 30,
+       DIG_TYPE_ENABLE                 = 20,
+       DIG_TYPE_DISABLE                = 30,
        DIG_OP_TYPE_MAX
 }dm_dig_op_e;
 
@@ -172,8 +171,7 @@ typedef enum tag_dig_cck_cs_ratio_state_definition
        DIG_CS_RATIO_HIGHER = 1,
        DIG_CS_MAX
 }dm_dig_cs_ratio_e;
-typedef struct _Dynamic_Rx_Path_Selection_
-{
+typedef struct _Dynamic_Rx_Path_Selection_ {
        u8              Enable;
        u8              DbgMode;
        u8              cck_method;
@@ -203,8 +201,7 @@ typedef enum tag_DM_DbgMode_Definition
        DM_DBG_MAX
 }DM_DBG_E;
 
-typedef struct tag_Tx_Config_Cmd_Format
-{
+typedef struct tag_Tx_Config_Cmd_Format {
        u32     Op;                                                                             /* Command packet type. */
        u32     Length;                                                                 /* Command packet length. */
        u32     Value;
@@ -251,4 +248,3 @@ extern void dm_initialize_txpower_tracking(struct net_device *dev);
 
 
 /* End of r8192U_dm.h */
-
index 1bfe871dcfb287e26cef98536ce268f2b6224cc0..15b0423356f8705597204c2cb2470cdb14b5999f 100644 (file)
@@ -122,7 +122,7 @@ enum _RTL8192Usb_HW {
        SIFS                    = 0x03E, // SIFS register
        TCR                     = 0x040, // Transmit Configuration Register
 
-#define TCR_MXDMA_2048                 7
+#define TCR_MXDMA_2048         7
 #define TCR_LRL_OFFSET         0
 #define TCR_SRL_OFFSET         8
 #define TCR_MXDMA_OFFSET       21
@@ -379,7 +379,7 @@ enum _RTL8192Usb_HW {
 //     IMR_POLL                = 0x360,
        MacBlkCtrl              = 0x403, // Mac block on/off control register
 
-       EPROM_CMD               = 0xfe58,
+       EPROM_CMD               = 0xfe58,
 #define Cmd9346CR_9356SEL      (1<<4)
 #define EPROM_CMD_RESERVED_MASK (1<<5)
 #define EPROM_CMD_OPERATING_MODE_SHIFT 6
@@ -392,12 +392,12 @@ enum _RTL8192Usb_HW {
 #define EPROM_CK_SHIFT 2
 #define EPROM_W_SHIFT 1
 #define EPROM_R_SHIFT 0
-       MAC0                    = 0x000,
-       MAC1                    = 0x001,
-       MAC2                    = 0x002,
-       MAC3                    = 0x003,
-       MAC4                    = 0x004,
-       MAC5                    = 0x005,
+       MAC0                    = 0x000,
+       MAC1                    = 0x001,
+       MAC2                    = 0x002,
+       MAC3                    = 0x003,
+       MAC4                    = 0x004,
+       MAC5                    = 0x005,
 
 };
 //----------------------------------------------------------------------------
index 71f2d2349c38610ad7641c533f1b871f8399fec7..c904aa8cc0a605028695c86b2c09ca9dbccd6b58 100644 (file)
@@ -354,8 +354,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
        return ret;
 }
 
-struct  iw_range_with_scan_capa
-{
+struct  iw_range_with_scan_capa {
        /* Informative stuff (to choose between different interface) */
        __u32           throughput;     /* To give an idea... */
        /* In theory this value should be the maximum benchmarked
@@ -711,12 +710,12 @@ static int r8192_wx_set_enc(struct net_device *dev,
                #define CONF_WEP104 0x14
 
                switch(wrqu->encoding.flags & IW_ENCODE_INDEX){
-                       case 0: key_idx = ieee->tx_keyidx; break;
-                       case 1: key_idx = 0; break;
-                       case 2: key_idx = 1; break;
-                       case 3: key_idx = 2; break;
-                       case 4: key_idx = 3; break;
-                       default: break;
+               case 0: key_idx = ieee->tx_keyidx; break;
+               case 1: key_idx = 0; break;
+               case 2: key_idx = 1; break;
+               case 3: key_idx = 2; break;
+               case 4: key_idx = 3; break;
+               default: break;
                }
 
                if(wrqu->encoding.length==0x5){
@@ -1021,7 +1020,7 @@ static int dummy(struct net_device *dev, struct iw_request_info *a,
 static iw_handler r8192_wx_handlers[] =
 {
        NULL,                     /* SIOCSIWCOMMIT */
-       r8192_wx_get_name,        /* SIOCGIWNAME */
+       r8192_wx_get_name,        /* SIOCGIWNAME */
        dummy,                    /* SIOCSIWNWID */
        dummy,                    /* SIOCGIWNWID */
        r8192_wx_set_freq,        /* SIOCSIWFREQ */
@@ -1040,7 +1039,7 @@ static iw_handler r8192_wx_handlers[] =
        dummy,                    /* SIOCGIWSPY */
        NULL,                     /* SIOCGIWTHRSPY */
        NULL,                     /* SIOCWIWTHRSPY */
-       r8192_wx_set_wap,         /* SIOCSIWAP */
+       r8192_wx_set_wap,         /* SIOCSIWAP */
        r8192_wx_get_wap,         /* SIOCGIWAP */
 #if (WIRELESS_EXT >= 18)
        r8192_wx_set_mlme,                     /* MLME-- */
@@ -1071,23 +1070,23 @@ static iw_handler r8192_wx_handlers[] =
        r8192_wx_set_power,                    /* SIOCSIWPOWER */
        r8192_wx_get_power,                    /* SIOCGIWPOWER */
        NULL,                   /*---hole---*/
-       NULL,                   /*---hole---*/
-       r8192_wx_set_gen_ie,//NULL,                     /* SIOCSIWGENIE */
-       NULL,                   /* SIOCSIWGENIE */
+       NULL,                   /*---hole---*/
+       r8192_wx_set_gen_ie,//NULL,                     /* SIOCSIWGENIE */
+       NULL,                   /* SIOCSIWGENIE */
 
 #if (WIRELESS_EXT >= 18)
-       r8192_wx_set_auth,//NULL,                       /* SIOCSIWAUTH */
-       NULL,//r8192_wx_get_auth,//NULL,                        /* SIOCSIWAUTH */
-       r8192_wx_set_enc_ext,                   /* SIOCSIWENCODEEXT */
-       NULL,//r8192_wx_get_enc_ext,//NULL,                     /* SIOCSIWENCODEEXT */
+       r8192_wx_set_auth,//NULL,                       /* SIOCSIWAUTH */
+       NULL,//r8192_wx_get_auth,//NULL,                        /* SIOCSIWAUTH */
+       r8192_wx_set_enc_ext,                   /* SIOCSIWENCODEEXT */
+       NULL,//r8192_wx_get_enc_ext,//NULL,                     /* SIOCSIWENCODEEXT */
 #else
        NULL,
        NULL,
        NULL,
        NULL,
 #endif
-       NULL,                   /* SIOCSIWPMKSA */
-       NULL,                    /*---hole---*/
+       NULL,                   /* SIOCSIWPMKSA */
+       NULL,                    /*---hole---*/
 
 };
 
index f37b6d69b4046cf11fe53cd31021c8df97c0b0e0..6a4678f7da5ffc4cfa2088ce298e0bbe0c51548b 100644 (file)
@@ -10,4 +10,3 @@ typedef enum _HT_IOT_ACTION{
        HT_IOT_ACT_CDD_FSYNC = 0x00000020,
        HT_IOT_ACT_PURE_N_MODE = 0x00000040,
 }HT_IOT_ACTION_E, *PHT_IOT_ACTION_E;
-
index 6c1d05e1e820eefb866e23af03e4a04a10f1a348..19a7bdd1973ad3bdc02c61657cb891362141dbec 100644 (file)
@@ -89,7 +89,7 @@ typedef enum _CHNLOP{
 
 typedef enum _HT_ACTION{
        ACT_RECOMMAND_WIDTH             = 0,
-       ACT_MIMO_PWR_SAVE               = 1,
+       ACT_MIMO_PWR_SAVE               = 1,
        ACT_PSMP                                        = 2,
        ACT_SET_PCO_PHASE               = 3,
        ACT_MIMO_CHL_MEASURE    = 4,
@@ -367,9 +367,9 @@ typedef struct _BSS_HT{
 typedef struct _MIMO_RSSI{
        u32     EnableAntenna;
        u32     AntennaA;
-       u32     AntennaB;
-       u32     AntennaC;
-       u32     AntennaD;
+       u32     AntennaB;
+       u32     AntennaC;
+       u32     AntennaD;
        u32     Average;
 }MIMO_RSSI, *PMIMO_RSSI;
 
@@ -388,4 +388,3 @@ typedef struct _FALSE_ALARM_STATISTICS{
 
 
 #endif //__INC_HTTYPE_H
-
index a8a6dc2c365f692fb7a70caa0a4deee3596263f9..b755eb46341fd519205d42eb96df3dd702e7bb8b 100644 (file)
@@ -18,7 +18,7 @@
  History:
        Data            Who             Remark
 
-       05/06/2008  amy         Create initial version porting from windows driver.
+       05/06/2008  amy         Create initial version porting from windows driver.
 
 ******************************************************************************/
 #include "r8192U.h"
@@ -41,7 +41,7 @@
 rt_status
 SendTxCommandPacket(
        struct net_device *dev,
-       void*                   pData,
+       void*                   pData,
        u32                             DataLen
        )
 {
@@ -106,7 +106,7 @@ SendTxCommandPacket(
        u32     buffer_len)
 {
 
-       bool        rt_status = true;
+       bool        rt_status = true;
 #ifdef RTL8192U
        return rt_status;
 #else
@@ -188,7 +188,7 @@ SendTxCommandPacket(
  *
  * Overview:
  *
- * Input:       PADAPTER       pAdapter                -       .
+ * Input:       PADAPTER       pAdapter                -       .
  *                             CMPK_TXFB_T *psTx_FB    -       .
  *
  * Output:      NONE
@@ -197,7 +197,7 @@ SendTxCommandPacket(
  *
  * Revised History:
  *  When               Who             Remark
- *  05/12/2008 amy     Create Version 0 porting from windows code.
+ *  05/12/2008 amy     Create Version 0 porting from windows code.
  *
  *---------------------------------------------------------------------------*/
 static void
@@ -289,7 +289,7 @@ cmpk_count_txstatistic(
  *                             in the command packet.
  *
  * Input:       struct net_device *    dev
- *                             u8      *       pmsg            -       Msg Ptr of the command packet.
+ *                             u8      *       pmsg            -       Msg Ptr of the command packet.
  *
  * Output:      NONE
  *
@@ -369,7 +369,7 @@ cmdpkt_beacontimerinterrupt_819xusb(
  * Overview:    The function is responsible for extract the message from
  *                             firmware. It will contain dedicated info in
  *                             ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc.
- *                             Please refer to chapter "Interrupt Status Element".
+ *                             Please refer to chapter "Interrupt Status Element".
  *
  * Input:       struct net_device *dev,
  *                     u8*     pmsg            -       Message Pointer of the command packet.
@@ -400,8 +400,8 @@ cmpk_handle_interrupt_status(
        /* It seems that FW use big endian(MIPS) and DRV use little endian in
           windows OS. So we have to read the content byte by byte or transfer
           endian type before copy the message copy. */
-       //rx_bcn_state.Element_ID       = pMsg[0];
-       //rx_bcn_state.Length           = pMsg[1];
+       //rx_bcn_state.Element_ID       = pMsg[0];
+       //rx_bcn_state.Length           = pMsg[1];
        rx_intr_status.length = pmsg[1];
        if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2))
        {
@@ -478,16 +478,16 @@ cmpk_handle_query_config_rx(
        /* It seems that FW use big endian(MIPS) and DRV use little endian in
           windows OS. So we have to read the content byte by byte or transfer
           endian type before copy the message copy. */
-       //rx_query_cfg.Element_ID       = pMsg[0];
-       //rx_query_cfg.Length           = pMsg[1];
-       rx_query_cfg.cfg_action         = (pmsg[4] & 0x80000000)>>31;
-       rx_query_cfg.cfg_type           = (pmsg[4] & 0x60) >> 5;
-       rx_query_cfg.cfg_size           = (pmsg[4] & 0x18) >> 3;
-       rx_query_cfg.cfg_page           = (pmsg[6] & 0x0F) >> 0;
-       rx_query_cfg.cfg_offset                 = pmsg[7];
-       rx_query_cfg.value                      = (pmsg[8] << 24) | (pmsg[9] << 16) |
+       //rx_query_cfg.Element_ID       = pMsg[0];
+       //rx_query_cfg.Length           = pMsg[1];
+       rx_query_cfg.cfg_action         = (pmsg[4] & 0x80000000)>>31;
+       rx_query_cfg.cfg_type           = (pmsg[4] & 0x60) >> 5;
+       rx_query_cfg.cfg_size           = (pmsg[4] & 0x18) >> 3;
+       rx_query_cfg.cfg_page           = (pmsg[6] & 0x0F) >> 0;
+       rx_query_cfg.cfg_offset                 = pmsg[7];
+       rx_query_cfg.value                      = (pmsg[8] << 24) | (pmsg[9] << 16) |
                                                                  (pmsg[10] << 8) | (pmsg[11] << 0);
-       rx_query_cfg.mask                       = (pmsg[12] << 24) | (pmsg[13] << 16) |
+       rx_query_cfg.mask                       = (pmsg[12] << 24) | (pmsg[13] << 16) |
                                                                  (pmsg[14] << 8) | (pmsg[15] << 0);
 
 }      /* cmpk_Handle_Query_Config_Rx */
@@ -511,7 +511,7 @@ cmpk_handle_query_config_rx(
  *
  *---------------------------------------------------------------------------*/
 static void    cmpk_count_tx_status(   struct net_device *dev,
-                                                                       cmpk_tx_status_t        *pstx_status)
+                                                                       cmpk_tx_status_t        *pstx_status)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 
index a8855e61b0e53756fadcfeeb26014f7edad254c1..59caa4e05323c949e0c32b73b49f1506c1ca9203 100644 (file)
@@ -19,8 +19,7 @@
 /*------------------------------Define structure----------------------------*/
 /* Define different command packet structure. */
 /* 1. RX side: TX feedback packet. */
-typedef struct tag_cmd_pkt_tx_feedback
-{
+typedef struct tag_cmd_pkt_tx_feedback {
        // DWORD 0
        u8      element_id;                     /* Command packet type. */
        u8      length;                         /* Command packet length. */
@@ -57,8 +56,7 @@ typedef struct tag_cmd_pkt_tx_feedback
 
 /* 2. RX side: Interrupt status packet. It includes Beacon State,
          Beacon Timer Interrupt and other useful informations in MAC ISR Reg. */
-typedef struct tag_cmd_pkt_interrupt_status
-{
+typedef struct tag_cmd_pkt_interrupt_status {
        u8      element_id;                     /* Command packet type. */
        u8      length;                         /* Command packet length. */
        u16     reserve;
@@ -67,12 +65,11 @@ typedef struct tag_cmd_pkt_interrupt_status
 
 
 /* 3. TX side: Set configuration packet. */
-typedef struct tag_cmd_pkt_set_configuration
-{
+typedef struct tag_cmd_pkt_set_configuration {
        u8      element_id;                     /* Command packet type. */
        u8      length;                         /* Command packet length. */
        u16     reserve1;                       /* */
-       u8      cfg_reserve1:3;
+       u8      cfg_reserve1:3;
        u8      cfg_size:2;                     /* Configuration info. */
        u8      cfg_type:2;                     /* Configuration info. */
        u8      cfg_action:1;           /* Configuration info. */
@@ -89,25 +86,24 @@ typedef struct tag_cmd_pkt_set_configuration
 #define                cmpk_query_cfg_t        cmpk_set_cfg_t
 
 /* 5. Multi packet feedback status. */
-typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007
-{
+typedef struct tag_tx_stats_feedback { // PJ quick rxcmd 09042007
        // For endian transfer --> Driver will not the same as firmware structure.
        // DW 0
        u16     reserve1;
-       u8      length;                         // Command packet length
-       u8      element_id;                     // Command packet type
+       u8      length;                         // Command packet length
+       u8      element_id;                     // Command packet type
 
        // DW 1
        u16     txfail;                         // Tx Fail count
-       u16     txok;                           // Tx ok count
+       u16     txok;                           // Tx ok count
 
        // DW 2
-       u16     txmcok;                         // tx multicast
-       u16     txretry;                        // Tx Retry count
+       u16     txmcok;                         // tx multicast
+       u16     txretry;                        // Tx Retry count
 
        // DW 3
        u16  txucok;                            // tx unicast
-       u16     txbcok;                         // tx broadcast
+       u16     txbcok;                         // tx broadcast
 
        // DW 4
        u16     txbcfail;                       //
@@ -130,13 +126,12 @@ typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007
 
 /* 6. Debug feedback message. */
 /* 2007/10/23 MH Define RX debug message  */
-typedef struct tag_rx_debug_message_feedback
-{
+typedef struct tag_rx_debug_message_feedback {
        // For endian transfer --> for driver
        // DW 0
        u16     reserve1;
-       u8      length;                         // Command packet length
-       u8      element_id;                     // Command packet type
+       u8      length;                         // Command packet length
+       u8      element_id;                     // Command packet type
 
        // DW 1-??
        // Variable debug message.
@@ -144,19 +139,18 @@ typedef struct tag_rx_debug_message_feedback
 }cmpk_rx_dbginfo_t;
 
 /* 2008/03/20 MH Define transmit rate history. For big endian format. */
-typedef struct tag_tx_rate_history
-{
+typedef struct tag_tx_rate_history {
        // For endian transfer --> for driver
        // DW 0
-       u8      element_id;                     // Command packet type
-       u8      length;                         // Command packet length
+       u8      element_id;                     // Command packet type
+       u8      length;                         // Command packet length
        u16     reserved1;
 
        // DW 1-2       CCK rate counter
-       u16     cck[4];
+       u16     cck[4];
 
        // DW 3-6
-       u16     ofdm[8];
+       u16     ofdm[8];
 
        // DW 7-14
        //UINT16        MCS_BW0_SG0[16];
index b12d190797984930dbe592fbe4a25851bebd150f..573e9cd68509dc16b7bf0ae274a7a58ef54b1138 100644 (file)
@@ -2,7 +2,7 @@
  * Procedure:    Init boot code/firmware code/data session
  *
  * Description: This routine will initialize firmware. If any error occurs during the initialization
- *             process, the routine shall terminate immediately and return fail.
+ *             process, the routine shall terminate immediately and return fail.
  *             NIC driver should call NdisOpenFile only from MiniportInitialize.
  *
  * Arguments:   The pointer of the adapter
@@ -19,7 +19,7 @@
 #include <linux/firmware.h>
 void firmware_init_param(struct net_device *dev)
 {
-       struct r8192_priv       *priv = ieee80211_priv(dev);
+       struct r8192_priv       *priv = ieee80211_priv(dev);
        rt_firmware             *pfirmware = priv->pFirmware;
 
        pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE);
@@ -32,7 +32,7 @@ void firmware_init_param(struct net_device *dev)
 bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, u32 buffer_len)
 {
        struct r8192_priv   *priv = ieee80211_priv(dev);
-       bool                rt_status = true;
+       bool                rt_status = true;
        u16                 frag_threshold;
        u16                 frag_length, frag_offset = 0;
        //u16               total_size;
@@ -241,17 +241,17 @@ CPUCheckFirmwareReady_Fail:
 
 bool init_firmware(struct net_device *dev)
 {
-       struct r8192_priv       *priv = ieee80211_priv(dev);
+       struct r8192_priv       *priv = ieee80211_priv(dev);
        bool                    rt_status = TRUE;
 
        u32                     file_length = 0;
        u8                      *mapped_file = NULL;
        u32                     init_step = 0;
        opt_rst_type_e  rst_opt = OPT_SYSTEM_RESET;
-       firmware_init_step_e    starting_state = FW_INIT_STEP0_BOOT;
+       firmware_init_step_e    starting_state = FW_INIT_STEP0_BOOT;
 
        rt_firmware             *pfirmware = priv->pFirmware;
-       const struct firmware   *fw_entry;
+       const struct firmware   *fw_entry;
        const char *fw_name[3] = { "RTL8192U/boot.img",
                           "RTL8192U/main.img",
                           "RTL8192U/data.img"};
@@ -334,56 +334,56 @@ bool init_firmware(struct net_device *dev)
                }
 
                switch(init_step) {
-                       case FW_INIT_STEP0_BOOT:
-                               /* Download boot
-                                * initialize command descriptor.
-                                * will set polling bit when firmware code is also configured
-                                */
-                               pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
+               case FW_INIT_STEP0_BOOT:
+                       /* Download boot
+                        * initialize command descriptor.
+                        * will set polling bit when firmware code is also configured
+                        */
+                       pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
 #ifdef RTL8190P
-                               // To initialize IMEM, CPU move code  from 0x80000080, hence, we send 0x80 byte packet
-                               rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET);
-                               if(rt_status != true)
-                               {
-                                       RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n");
-                                       goto  download_firmware_fail;
-                               }
+                       // To initialize IMEM, CPU move code  from 0x80000080, hence, we send 0x80 byte packet
+                       rt_status = fwSendNullPacket(dev, RTL8190_CPU_START_OFFSET);
+                       if(rt_status != true)
+                       {
+                               RT_TRACE(COMP_INIT, "fwSendNullPacket() fail ! \n");
+                               goto  download_firmware_fail;
+                       }
 #endif
-                               //mdelay(1000);
-                               /*
-                                * To initialize IMEM, CPU move code  from 0x80000080,
-                                * hence, we send 0x80 byte packet
-                                */
-                               break;
-
-                       case FW_INIT_STEP1_MAIN:
-                               /* Download firmware code. Wait until Boot Ready and Turn on CPU */
-                               pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE;
-
-                               /* Check Put Code OK and Turn On CPU */
-                               rt_status = CPUcheck_maincodeok_turnonCPU(dev);
-                               if(rt_status != TRUE) {
-                                       RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
-                                       goto download_firmware_fail;
-                               }
-
-                               pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
-                               break;
-
-                       case FW_INIT_STEP2_DATA:
-                               /* download initial data code */
-                               pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE;
-                               mdelay(1);
-
-                               rt_status = CPUcheck_firmware_ready(dev);
-                               if(rt_status != TRUE) {
-                                       RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status);
-                                       goto download_firmware_fail;
-                               }
-
-                               /* wait until data code is initialized ready.*/
-                               pfirmware->firmware_status = FW_STATUS_5_READY;
-                               break;
+                       //mdelay(1000);
+                       /*
+                        * To initialize IMEM, CPU move code  from 0x80000080,
+                        * hence, we send 0x80 byte packet
+                        */
+                       break;
+
+               case FW_INIT_STEP1_MAIN:
+                       /* Download firmware code. Wait until Boot Ready and Turn on CPU */
+                       pfirmware->firmware_status = FW_STATUS_2_MOVE_MAIN_CODE;
+
+                       /* Check Put Code OK and Turn On CPU */
+                       rt_status = CPUcheck_maincodeok_turnonCPU(dev);
+                       if(rt_status != TRUE) {
+                               RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
+                               goto download_firmware_fail;
+                       }
+
+                       pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
+                       break;
+
+               case FW_INIT_STEP2_DATA:
+                       /* download initial data code */
+                       pfirmware->firmware_status = FW_STATUS_4_MOVE_DATA_CODE;
+                       mdelay(1);
+
+                       rt_status = CPUcheck_firmware_ready(dev);
+                       if(rt_status != TRUE) {
+                               RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status);
+                               goto download_firmware_fail;
+                       }
+
+                       /* wait until data code is initialized ready.*/
+                       pfirmware->firmware_status = FW_STATUS_5_READY;
+                       break;
                }
        }
 
@@ -402,4 +402,3 @@ download_firmware_fail:
 MODULE_FIRMWARE("RTL8192U/boot.img");
 MODULE_FIRMWARE("RTL8192U/main.img");
 MODULE_FIRMWARE("RTL8192U/data.img");
-
index a4bceeef33d31cfbf24efe9fb29700451d030948..c48c884aa1afa4dd408824c5151bce0bdb7ba28e 100644 (file)
@@ -24,4 +24,3 @@ typedef enum _opt_rst_type{
 }opt_rst_type_e;
 
 #endif
-
index dd1954daea2df7a98c754bd770d7aa7462ee2f7c..17fac41c12d9a81eb7b9513406742b54b664d981 100644 (file)
@@ -124,10 +124,10 @@ static void phy_FwRFSerialWrite( struct net_device* dev, RF90_RADIO_PATH_E
 /******************************************************************************
  *function:  This function read register from RF chip
  *   input:  net_device dev
- *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
  *           u32       Offset     //target address to be read
  *  output:  none
- *  return:  u32       readback value
+ *  return:  u32       readback value
  *  notice:  There are three types of serial operations:(1) Software serial write.(2)Hardware LSSI-Low Speed Serial Interface.(3)Hardware HSSI-High speed serial write. Driver here need to implement (1) and (2)---need more spec for this information.
  * ****************************************************************************/
 u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath, u32 Offset)
@@ -201,7 +201,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath,
 /******************************************************************************
  *function:  This function write data to RF register
  *   input:  net_device dev
- *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
  *           u32       Offset     //target address to be written
  *           u32       Data    //The new register data to be written
  *  output:  none
@@ -283,7 +283,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath
 /******************************************************************************
  *function:  This function set specific bits to RF register
  *   input:  net_device dev
- *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
+ *          RF90_RADIO_PATH_E eRFPath //radio path of A/B/C/D
  *           u32       RegAddr  //target addr to be modified
  *           u32       BitMask  //taget bit pos in the addr to be modified
  *           u32       Data     //value to be write
@@ -684,8 +684,8 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev)
 /******************************************************************************
  *function:  This function is to write register and then readback to make sure whether BB and RF is OK
  *   input:  net_device dev
- *          HW90_BLOCK_E CheckBlock
- *          RF90_RADIO_PATH_E eRFPath  //only used when checkblock is HW90_BLOCK_RF
+ *          HW90_BLOCK_E CheckBlock
+ *          RF90_RADIO_PATH_E eRFPath  //only used when checkblock is HW90_BLOCK_RF
  *  output:  none
  *  return:  return whether BB and RF is ok(0:OK; 1:Fail)
  *  notice:  This function may be removed in the ASIC
@@ -957,56 +957,56 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E
        u8 ret = 0;
 
        switch(eRFPath){
-               case RF90_PATH_A:
-                       for(i = 0;i<RadioA_ArrayLength; i=i+2){
-
-                               if(rtl819XRadioA_Array[i] == 0xfe){
-                                               mdelay(100);
-                                               continue;
-                               }
-                               rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioA_Array[i], bMask12Bits, rtl819XRadioA_Array[i+1]);
-                               mdelay(1);
+       case RF90_PATH_A:
+               for(i = 0;i<RadioA_ArrayLength; i=i+2){
 
+                       if(rtl819XRadioA_Array[i] == 0xfe){
+                                       mdelay(100);
+                                       continue;
                        }
-                       break;
-               case RF90_PATH_B:
-                       for(i = 0;i<RadioB_ArrayLength; i=i+2){
+                       rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioA_Array[i], bMask12Bits, rtl819XRadioA_Array[i+1]);
+                       mdelay(1);
 
-                               if(rtl819XRadioB_Array[i] == 0xfe){
-                                               mdelay(100);
-                                               continue;
-                               }
-                               rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioB_Array[i], bMask12Bits, rtl819XRadioB_Array[i+1]);
-                               mdelay(1);
+               }
+               break;
+       case RF90_PATH_B:
+               for(i = 0;i<RadioB_ArrayLength; i=i+2){
 
+                       if(rtl819XRadioB_Array[i] == 0xfe){
+                                       mdelay(100);
+                                       continue;
                        }
-                       break;
-               case RF90_PATH_C:
-                       for(i = 0;i<RadioC_ArrayLength; i=i+2){
+                       rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioB_Array[i], bMask12Bits, rtl819XRadioB_Array[i+1]);
+                       mdelay(1);
 
-                               if(rtl819XRadioC_Array[i] == 0xfe){
-                                               mdelay(100);
-                                               continue;
-                               }
-                               rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioC_Array[i], bMask12Bits, rtl819XRadioC_Array[i+1]);
-                               mdelay(1);
+               }
+               break;
+       case RF90_PATH_C:
+               for(i = 0;i<RadioC_ArrayLength; i=i+2){
 
+                       if(rtl819XRadioC_Array[i] == 0xfe){
+                                       mdelay(100);
+                                       continue;
                        }
-                       break;
-               case RF90_PATH_D:
-                       for(i = 0;i<RadioD_ArrayLength; i=i+2){
+                       rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioC_Array[i], bMask12Bits, rtl819XRadioC_Array[i+1]);
+                       mdelay(1);
 
-                               if(rtl819XRadioD_Array[i] == 0xfe){
-                                               mdelay(100);
-                                               continue;
-                               }
-                               rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioD_Array[i], bMask12Bits, rtl819XRadioD_Array[i+1]);
-                               mdelay(1);
+               }
+               break;
+       case RF90_PATH_D:
+               for(i = 0;i<RadioD_ArrayLength; i=i+2){
 
+                       if(rtl819XRadioD_Array[i] == 0xfe){
+                                       mdelay(100);
+                                       continue;
                        }
-                       break;
-               default:
-                       break;
+                       rtl8192_phy_SetRFReg(dev, eRFPath, rtl819XRadioD_Array[i], bMask12Bits, rtl819XRadioD_Array[i+1]);
+                       mdelay(1);
+
+               }
+               break;
+       default:
+               break;
        }
 
        return ret;
@@ -1015,7 +1015,7 @@ u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device* dev, RF90_RADIO_PATH_E
 /******************************************************************************
  *function:  This function set Tx Power of the channel
  *   input:  struct net_device *dev
- *          u8                 channel
+ *          u8                 channel
  *  output:  none
  *  return:  none
  *    Note:
@@ -1052,7 +1052,7 @@ void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
 /******************************************************************************
  *function:  This function set RF state on or off
  *   input:  struct net_device *dev
- *          RT_RF_POWER_STATE eRFPowerState  //Power State to set
+ *          RT_RF_POWER_STATE eRFPowerState  //Power State to set
  *  output:  none
  *  return:  none
  *    Note:
@@ -1183,10 +1183,10 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerS
 
 /****************************************************************************************
  *function:  This function set command table variable(struct SwChnlCmd).
- *   input:  SwChnlCmd*                CmdTable        //table to be set.
- *          u32                CmdTableIdx     //variable index in table to be set
- *          u32                CmdTableSz      //table size.
- *          SwChnlCmdID        CmdID           //command ID to set.
+ *   input:  SwChnlCmd*                CmdTable        //table to be set.
+ *          u32                CmdTableIdx     //variable index in table to be set
+ *          u32                CmdTableSz      //table size.
+ *          SwChnlCmdID        CmdID           //command ID to set.
  *          u32                Para1
  *          u32                Para2
  *          u32                msDelay
@@ -1229,10 +1229,10 @@ u8 rtl8192_phy_SetSwChnlCmdArray(
 /******************************************************************************
  *function:  This function set channel step by step
  *   input:  struct net_device *dev
- *          u8                 channel
- *          u8*                stage //3 stages
- *          u8*                step  //
- *          u32*               delay //whether need to delay
+ *          u8                 channel
+ *          u8*                stage //3 stages
+ *          u8*                step  //
+ *          u32*               delay //whether need to delay
  *  output:  store new stage, step and delay for next step(combine with function above)
  *  return:  true if finished, false otherwise
  *    Note:  Wait for simpler function to replace it //wb
@@ -1386,7 +1386,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u
 /******************************************************************************
  *function:  This function does actually set channel work
  *   input:  struct net_device *dev
- *          u8                 channel
+ *          u8                 channel
  *  output:  none
  *  return:  noin
  *    Note:  We should not call this function directly
@@ -1427,7 +1427,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
 /******************************************************************************
  *function:  This function scheduled actual work item to set channel
  *   input:  net_device dev
- *          u8         channel //channel to set
+ *          u8         channel //channel to set
  *  output:  none
  *  return:  return code show if workitem is scheduled(1:pass, 0:fail)
  *    Note:  Delay may be required for RF configuration
@@ -1501,12 +1501,12 @@ if (0) //to test current channel from RF reg 0x7.
 /******************************************************************************
  *function:  Callback routine of the work item for set bandwidth mode.
  *   input:  struct net_device *dev
- *          HT_CHANNEL_WIDTH   Bandwidth  //20M or 40M
- *          HT_EXTCHNL_OFFSET Offset      //Upper, Lower, or Don't care
+ *          HT_CHANNEL_WIDTH   Bandwidth  //20M or 40M
+ *          HT_EXTCHNL_OFFSET Offset      //Upper, Lower, or Don't care
  *  output:  none
  *  return:  none
  *    Note:  I doubt whether SetBWModeInProgress flag is necessary as we can
- *          test whether current work in the queue or not.//do I?
+ *          test whether current work in the queue or not.//do I?
  * ***************************************************************************/
 void rtl8192_SetBWModeWorkItem(struct net_device *dev)
 {
@@ -1649,12 +1649,12 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
 /******************************************************************************
  *function:  This function schedules bandwidth switch work.
  *   input:  struct net_device *dev
- *          HT_CHANNEL_WIDTH   Bandwidth  //20M or 40M
- *          HT_EXTCHNL_OFFSET Offset      //Upper, Lower, or Don't care
+ *          HT_CHANNEL_WIDTH   Bandwidth  //20M or 40M
+ *          HT_EXTCHNL_OFFSET Offset      //Upper, Lower, or Don't care
  *  output:  none
  *  return:  none
  *    Note:  I doubt whether SetBWModeInProgress flag is necessary as we can
- *          test whether current work in the queue or not.//do I?
+ *          test whether current work in the queue or not.//do I?
  * ***************************************************************************/
 void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH        Bandwidth, HT_EXTCHNL_OFFSET Offset)
 {
@@ -1770,4 +1770,3 @@ extern void InitialGainOperateWorkItemCallBack(struct work_struct *work)
                        break;
        }
 }
-
index cca34c05f6a597c0e7fd6777330b53ebdf208052..64285d6a33f86a0e9b5a19bad52eafa04ce1c262 100644 (file)
 
 //Register   //duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
 //page 1
-#define rPMAC_Reset                            0x100
-#define rPMAC_TxStart                          0x104
-#define rPMAC_TxLegacySIG                      0x108
-#define rPMAC_TxHTSIG1                         0x10c
-#define rPMAC_TxHTSIG2                         0x110
-#define rPMAC_PHYDebug                         0x114
-#define rPMAC_TxPacketNum                      0x118
-#define rPMAC_TxIdle                           0x11c
-#define rPMAC_TxMACHeader0             0x120
-#define rPMAC_TxMACHeader1             0x124
-#define rPMAC_TxMACHeader2             0x128
-#define rPMAC_TxMACHeader3             0x12c
-#define rPMAC_TxMACHeader4             0x130
-#define rPMAC_TxMACHeader5             0x134
-#define rPMAC_TxDataType                       0x138
-#define rPMAC_TxRandomSeed                     0x13c
-#define rPMAC_CCKPLCPPreamble                  0x140
-#define rPMAC_CCKPLCPHeader                    0x144
-#define rPMAC_CCKCRC16                         0x148
-#define rPMAC_OFDMRxCRC32OK            0x170
-#define rPMAC_OFDMRxCRC32Er            0x174
-#define rPMAC_OFDMRxParityEr                   0x178
-#define rPMAC_OFDMRxCRC8Er                     0x17c
-#define rPMAC_CCKCRxRC16Er                     0x180
-#define rPMAC_CCKCRxRC32Er                     0x184
-#define rPMAC_CCKCRxRC32OK                     0x188
-#define rPMAC_TxStatus                         0x18c
+#define rPMAC_Reset                            0x100
+#define rPMAC_TxStart                          0x104
+#define rPMAC_TxLegacySIG                      0x108
+#define rPMAC_TxHTSIG1                         0x10c
+#define rPMAC_TxHTSIG2                         0x110
+#define rPMAC_PHYDebug                         0x114
+#define rPMAC_TxPacketNum                      0x118
+#define rPMAC_TxIdle                           0x11c
+#define rPMAC_TxMACHeader0             0x120
+#define rPMAC_TxMACHeader1             0x124
+#define rPMAC_TxMACHeader2             0x128
+#define rPMAC_TxMACHeader3             0x12c
+#define rPMAC_TxMACHeader4             0x130
+#define rPMAC_TxMACHeader5             0x134
+#define rPMAC_TxDataType                       0x138
+#define rPMAC_TxRandomSeed                     0x13c
+#define rPMAC_CCKPLCPPreamble          0x140
+#define rPMAC_CCKPLCPHeader                    0x144
+#define rPMAC_CCKCRC16                         0x148
+#define rPMAC_OFDMRxCRC32OK            0x170
+#define rPMAC_OFDMRxCRC32Er            0x174
+#define rPMAC_OFDMRxParityEr                   0x178
+#define rPMAC_OFDMRxCRC8Er             0x17c
+#define rPMAC_CCKCRxRC16Er                     0x180
+#define rPMAC_CCKCRxRC32Er                     0x184
+#define rPMAC_CCKCRxRC32OK                     0x188
+#define rPMAC_TxStatus                         0x18c
 
 //page8
-#define rFPGA0_RFMOD                           0x800  //RF mode & CCK TxSC
-#define rFPGA0_TxInfo                          0x804
-#define rFPGA0_PSDFunction                     0x808
-#define rFPGA0_TxGainStage                     0x80c
-#define rFPGA0_RFTiming1                       0x810
-#define rFPGA0_RFTiming2                       0x814
-//#define rFPGA0_XC_RFTiming                   0x818
-//#define rFPGA0_XD_RFTiming                   0x81c
-#define rFPGA0_XA_HSSIParameter1       0x820
-#define rFPGA0_XA_HSSIParameter2       0x824
-#define rFPGA0_XB_HSSIParameter1       0x828
-#define rFPGA0_XB_HSSIParameter2       0x82c
-#define rFPGA0_XC_HSSIParameter1       0x830
-#define rFPGA0_XC_HSSIParameter2       0x834
-#define rFPGA0_XD_HSSIParameter1       0x838
-#define rFPGA0_XD_HSSIParameter2       0x83c
-#define rFPGA0_XA_LSSIParameter        0x840
-#define rFPGA0_XB_LSSIParameter        0x844
-#define rFPGA0_XC_LSSIParameter        0x848
-#define rFPGA0_XD_LSSIParameter        0x84c
-#define rFPGA0_RFWakeUpParameter       0x850
-#define rFPGA0_RFSleepUpParameter      0x854
-#define rFPGA0_XAB_SwitchControl       0x858
-#define rFPGA0_XCD_SwitchControl       0x85c
-#define rFPGA0_XA_RFInterfaceOE        0x860
-#define rFPGA0_XB_RFInterfaceOE        0x864
-#define rFPGA0_XC_RFInterfaceOE        0x868
-#define rFPGA0_XD_RFInterfaceOE        0x86c
-#define rFPGA0_XAB_RFInterfaceSW       0x870
-#define rFPGA0_XCD_RFInterfaceSW       0x874
-#define rFPGA0_XAB_RFParameter         0x878
-#define rFPGA0_XCD_RFParameter         0x87c
-#define rFPGA0_AnalogParameter1        0x880
-#define rFPGA0_AnalogParameter2        0x884
-#define rFPGA0_AnalogParameter3        0x888
-#define rFPGA0_AnalogParameter4        0x88c
-#define rFPGA0_XA_LSSIReadBack         0x8a0
-#define rFPGA0_XB_LSSIReadBack         0x8a4
-#define rFPGA0_XC_LSSIReadBack         0x8a8
-#define rFPGA0_XD_LSSIReadBack         0x8ac
-#define rFPGA0_PSDReport                       0x8b4
-#define rFPGA0_XAB_RFInterfaceRB       0x8e0
-#define rFPGA0_XCD_RFInterfaceRB       0x8e4
+#define rFPGA0_RFMOD                           0x800  //RF mode & CCK TxSC
+#define rFPGA0_TxInfo                          0x804
+#define rFPGA0_PSDFunction                     0x808
+#define rFPGA0_TxGainStage                     0x80c
+#define rFPGA0_RFTiming1                       0x810
+#define rFPGA0_RFTiming2                       0x814
+//#define rFPGA0_XC_RFTiming                   0x818
+//#define rFPGA0_XD_RFTiming                   0x81c
+#define rFPGA0_XA_HSSIParameter1       0x820
+#define rFPGA0_XA_HSSIParameter2       0x824
+#define rFPGA0_XB_HSSIParameter1       0x828
+#define rFPGA0_XB_HSSIParameter2       0x82c
+#define rFPGA0_XC_HSSIParameter1       0x830
+#define rFPGA0_XC_HSSIParameter2       0x834
+#define rFPGA0_XD_HSSIParameter1       0x838
+#define rFPGA0_XD_HSSIParameter2       0x83c
+#define rFPGA0_XA_LSSIParameter                0x840
+#define rFPGA0_XB_LSSIParameter                0x844
+#define rFPGA0_XC_LSSIParameter                0x848
+#define rFPGA0_XD_LSSIParameter                0x84c
+#define rFPGA0_RFWakeUpParameter       0x850
+#define rFPGA0_RFSleepUpParameter      0x854
+#define rFPGA0_XAB_SwitchControl       0x858
+#define rFPGA0_XCD_SwitchControl       0x85c
+#define rFPGA0_XA_RFInterfaceOE                0x860
+#define rFPGA0_XB_RFInterfaceOE                0x864
+#define rFPGA0_XC_RFInterfaceOE                0x868
+#define rFPGA0_XD_RFInterfaceOE                0x86c
+#define rFPGA0_XAB_RFInterfaceSW       0x870
+#define rFPGA0_XCD_RFInterfaceSW       0x874
+#define rFPGA0_XAB_RFParameter         0x878
+#define rFPGA0_XCD_RFParameter         0x87c
+#define rFPGA0_AnalogParameter1                0x880
+#define rFPGA0_AnalogParameter2                0x884
+#define rFPGA0_AnalogParameter3                0x888
+#define rFPGA0_AnalogParameter4                0x88c
+#define rFPGA0_XA_LSSIReadBack         0x8a0
+#define rFPGA0_XB_LSSIReadBack         0x8a4
+#define rFPGA0_XC_LSSIReadBack         0x8a8
+#define rFPGA0_XD_LSSIReadBack         0x8ac
+#define rFPGA0_PSDReport                       0x8b4
+#define rFPGA0_XAB_RFInterfaceRB       0x8e0
+#define rFPGA0_XCD_RFInterfaceRB       0x8e4
 
 //page 9
-#define rFPGA1_RFMOD                           0x900  //RF mode & OFDM TxSC
-#define rFPGA1_TxBlock                         0x904
-#define rFPGA1_DebugSelect                     0x908
-#define rFPGA1_TxInfo                          0x90c
+#define rFPGA1_RFMOD                           0x900  //RF mode & OFDM TxSC
+#define rFPGA1_TxBlock                         0x904
+#define rFPGA1_DebugSelect                     0x908
+#define rFPGA1_TxInfo                          0x90c
 
 //page a
-#define rCCK0_System                           0xa00
-#define rCCK0_AFESetting                       0xa04
-#define rCCK0_CCA                                      0xa08
-#define rCCK0_RxAGC1                           0xa0c  //AGC default value, saturation level
-#define rCCK0_RxAGC2                           0xa10  //AGC & DAGC
-#define rCCK0_RxHP                             0xa14
-#define rCCK0_DSPParameter1            0xa18  //Timing recovery & Channel estimation threshold
-#define rCCK0_DSPParameter2            0xa1c  //SQ threshold
-#define rCCK0_TxFilter1                        0xa20
-#define rCCK0_TxFilter2                        0xa24
-#define rCCK0_DebugPort                        0xa28  //debug port and Tx filter3
-#define rCCK0_FalseAlarmReport         0xa2c  //0xa2d
-#define rCCK0_TRSSIReport                      0xa50
-#define rCCK0_RxReport                         0xa54  //0xa57
-#define rCCK0_FACounterLower           0xa5c  //0xa5b
-#define rCCK0_FACounterUpper           0xa58  //0xa5c
+#define rCCK0_System                           0xa00
+#define rCCK0_AFESetting                       0xa04
+#define rCCK0_CCA                                      0xa08
+#define rCCK0_RxAGC1                           0xa0c  //AGC default value, saturation level
+#define rCCK0_RxAGC2                           0xa10  //AGC & DAGC
+#define rCCK0_RxHP                             0xa14
+#define rCCK0_DSPParameter1            0xa18  //Timing recovery & Channel estimation threshold
+#define rCCK0_DSPParameter2            0xa1c  //SQ threshold
+#define rCCK0_TxFilter1                                0xa20
+#define rCCK0_TxFilter2                                0xa24
+#define rCCK0_DebugPort                                0xa28  //debug port and Tx filter3
+#define rCCK0_FalseAlarmReport         0xa2c  //0xa2d
+#define rCCK0_TRSSIReport                      0xa50
+#define rCCK0_RxReport                         0xa54  //0xa57
+#define rCCK0_FACounterLower           0xa5c  //0xa5b
+#define rCCK0_FACounterUpper           0xa58  //0xa5c
 
 //page c
-#define rOFDM0_LSTF                            0xc00
-#define rOFDM0_TRxPathEnable           0xc04
-#define rOFDM0_TRMuxPar                        0xc08
-#define rOFDM0_TRSWIsolation                   0xc0c
-#define rOFDM0_XARxAFE                         0xc10  //RxIQ DC offset, Rx digital filter, DC notch filter
-#define rOFDM0_XARxIQImbalance         0xc14  //RxIQ imblance matrix
-#define rOFDM0_XBRxAFE                         0xc18
-#define rOFDM0_XBRxIQImbalance         0xc1c
-#define rOFDM0_XCRxAFE                         0xc20
-#define rOFDM0_XCRxIQImbalance         0xc24
-#define rOFDM0_XDRxAFE                         0xc28
-#define rOFDM0_XDRxIQImbalance         0xc2c
-#define rOFDM0_RxDetector1                     0xc30  //PD,BW & SBD
-#define rOFDM0_RxDetector2                     0xc34  //SBD & Fame Sync.
-#define rOFDM0_RxDetector3                     0xc38  //Frame Sync.
-#define rOFDM0_RxDetector4                     0xc3c  //PD, SBD, Frame Sync & Short-GI
-#define rOFDM0_RxDSP                           0xc40  //Rx Sync Path
-#define rOFDM0_CFOandDAGC              0xc44  //CFO & DAGC
-#define rOFDM0_CCADropThreshold        0xc48 //CCA Drop threshold
-#define rOFDM0_ECCAThreshold           0xc4c // energy CCA
-#define rOFDM0_XAAGCCore1              0xc50
-#define rOFDM0_XAAGCCore2              0xc54
-#define rOFDM0_XBAGCCore1              0xc58
-#define rOFDM0_XBAGCCore2              0xc5c
-#define rOFDM0_XCAGCCore1              0xc60
-#define rOFDM0_XCAGCCore2              0xc64
-#define rOFDM0_XDAGCCore1              0xc68
-#define rOFDM0_XDAGCCore2              0xc6c
-#define rOFDM0_AGCParameter1           0xc70
-#define rOFDM0_AGCParameter2           0xc74
-#define rOFDM0_AGCRSSITable            0xc78
-#define rOFDM0_HTSTFAGC                        0xc7c
-#define rOFDM0_XATxIQImbalance         0xc80
-#define rOFDM0_XATxAFE                         0xc84
-#define rOFDM0_XBTxIQImbalance         0xc88
-#define rOFDM0_XBTxAFE                         0xc8c
-#define rOFDM0_XCTxIQImbalance         0xc90
-#define rOFDM0_XCTxAFE                         0xc94
-#define rOFDM0_XDTxIQImbalance         0xc98
-#define rOFDM0_XDTxAFE                         0xc9c
-#define rOFDM0_RxHPParameter           0xce0
-#define rOFDM0_TxPseudoNoiseWgt        0xce4
-#define rOFDM0_FrameSync                       0xcf0
-#define rOFDM0_DFSReport                       0xcf4
-#define rOFDM0_TxCoeff1                        0xca4
-#define rOFDM0_TxCoeff2                        0xca8
-#define rOFDM0_TxCoeff3                        0xcac
-#define rOFDM0_TxCoeff4                        0xcb0
-#define rOFDM0_TxCoeff5                        0xcb4
-#define rOFDM0_TxCoeff6                        0xcb8
+#define rOFDM0_LSTF                            0xc00
+#define rOFDM0_TRxPathEnable           0xc04
+#define rOFDM0_TRMuxPar                                0xc08
+#define rOFDM0_TRSWIsolation                   0xc0c
+#define rOFDM0_XARxAFE                         0xc10  //RxIQ DC offset, Rx digital filter, DC notch filter
+#define rOFDM0_XARxIQImbalance         0xc14  //RxIQ imblance matrix
+#define rOFDM0_XBRxAFE                         0xc18
+#define rOFDM0_XBRxIQImbalance         0xc1c
+#define rOFDM0_XCRxAFE                         0xc20
+#define rOFDM0_XCRxIQImbalance         0xc24
+#define rOFDM0_XDRxAFE                         0xc28
+#define rOFDM0_XDRxIQImbalance         0xc2c
+#define rOFDM0_RxDetector1                     0xc30  //PD,BW & SBD
+#define rOFDM0_RxDetector2                     0xc34  //SBD & Fame Sync.
+#define rOFDM0_RxDetector3                     0xc38  //Frame Sync.
+#define rOFDM0_RxDetector4                     0xc3c  //PD, SBD, Frame Sync & Short-GI
+#define rOFDM0_RxDSP                           0xc40  //Rx Sync Path
+#define rOFDM0_CFOandDAGC              0xc44  //CFO & DAGC
+#define rOFDM0_CCADropThreshold                0xc48 //CCA Drop threshold
+#define rOFDM0_ECCAThreshold           0xc4c // energy CCA
+#define rOFDM0_XAAGCCore1              0xc50
+#define rOFDM0_XAAGCCore2              0xc54
+#define rOFDM0_XBAGCCore1              0xc58
+#define rOFDM0_XBAGCCore2              0xc5c
+#define rOFDM0_XCAGCCore1              0xc60
+#define rOFDM0_XCAGCCore2              0xc64
+#define rOFDM0_XDAGCCore1              0xc68
+#define rOFDM0_XDAGCCore2              0xc6c
+#define rOFDM0_AGCParameter1           0xc70
+#define rOFDM0_AGCParameter2           0xc74
+#define rOFDM0_AGCRSSITable            0xc78
+#define rOFDM0_HTSTFAGC                                0xc7c
+#define rOFDM0_XATxIQImbalance         0xc80
+#define rOFDM0_XATxAFE                         0xc84
+#define rOFDM0_XBTxIQImbalance         0xc88
+#define rOFDM0_XBTxAFE                         0xc8c
+#define rOFDM0_XCTxIQImbalance         0xc90
+#define rOFDM0_XCTxAFE                         0xc94
+#define rOFDM0_XDTxIQImbalance         0xc98
+#define rOFDM0_XDTxAFE                         0xc9c
+#define rOFDM0_RxHPParameter           0xce0
+#define rOFDM0_TxPseudoNoiseWgt                0xce4
+#define rOFDM0_FrameSync                       0xcf0
+#define rOFDM0_DFSReport                       0xcf4
+#define rOFDM0_TxCoeff1                                0xca4
+#define rOFDM0_TxCoeff2                                0xca8
+#define rOFDM0_TxCoeff3                                0xcac
+#define rOFDM0_TxCoeff4                                0xcb0
+#define rOFDM0_TxCoeff5                                0xcb4
+#define rOFDM0_TxCoeff6                                0xcb8
 
 
 //page d
-#define rOFDM1_LSTF                            0xd00
-#define rOFDM1_TRxPathEnable           0xd04
-#define rOFDM1_CFO                             0xd08
-#define rOFDM1_CSI1                            0xd10
-#define rOFDM1_SBD                             0xd14
-#define rOFDM1_CSI2                            0xd18
-#define rOFDM1_CFOTracking                     0xd2c
-#define rOFDM1_TRxMesaure1             0xd34
-#define rOFDM1_IntfDet                         0xd3c
+#define rOFDM1_LSTF                            0xd00
+#define rOFDM1_TRxPathEnable           0xd04
+#define rOFDM1_CFO                             0xd08
+#define rOFDM1_CSI1                            0xd10
+#define rOFDM1_SBD                             0xd14
+#define rOFDM1_CSI2                            0xd18
+#define rOFDM1_CFOTracking                     0xd2c
+#define rOFDM1_TRxMesaure1             0xd34
+#define rOFDM1_IntfDet                         0xd3c
 #define rOFDM1_PseudoNoiseStateAB 0xd50
 #define rOFDM1_PseudoNoiseStateCD 0xd54
 #define rOFDM1_RxPseudoNoiseWgt   0xd58
-#define rOFDM_PHYCounter1                      0xda0  //cca, parity fail
-#define rOFDM_PHYCounter2                      0xda4  //rate illegal, crc8 fail
-#define rOFDM_PHYCounter3                      0xda8  //MCS not support
-#define rOFDM_ShortCFOAB                       0xdac
-#define rOFDM_ShortCFOCD                       0xdb0
-#define rOFDM_LongCFOAB                        0xdb4
-#define rOFDM_LongCFOCD                        0xdb8
-#define rOFDM_TailCFOAB                        0xdbc
-#define rOFDM_TailCFOCD                        0xdc0
-#define rOFDM_PWMeasure1               0xdc4
-#define rOFDM_PWMeasure2               0xdc8
-#define rOFDM_BWReport                         0xdcc
-#define rOFDM_AGCReport                        0xdd0
-#define rOFDM_RxSNR                            0xdd4
-#define rOFDM_RxEVMCSI                         0xdd8
-#define rOFDM_SIGReport                        0xddc
+#define rOFDM_PHYCounter1                      0xda0  //cca, parity fail
+#define rOFDM_PHYCounter2                      0xda4  //rate illegal, crc8 fail
+#define rOFDM_PHYCounter3                      0xda8  //MCS not support
+#define rOFDM_ShortCFOAB                       0xdac
+#define rOFDM_ShortCFOCD                       0xdb0
+#define rOFDM_LongCFOAB                                0xdb4
+#define rOFDM_LongCFOCD                                0xdb8
+#define rOFDM_TailCFOAB                                0xdbc
+#define rOFDM_TailCFOCD                                0xdc0
+#define rOFDM_PWMeasure1               0xdc4
+#define rOFDM_PWMeasure2               0xdc8
+#define rOFDM_BWReport                         0xdcc
+#define rOFDM_AGCReport                                0xdd0
+#define rOFDM_RxSNR                            0xdd4
+#define rOFDM_RxEVMCSI                         0xdd8
+#define rOFDM_SIGReport                                0xddc
 
 //page e
 #define rTxAGC_Rate18_06                       0xe00
 
 //RF
 //Zebra1
-#define rZebra1_HSSIEnable             0x0
-#define rZebra1_TRxEnable1             0x1
-#define rZebra1_TRxEnable2             0x2
-#define rZebra1_AGC                            0x4
-#define rZebra1_ChargePump             0x5
-#define rZebra1_Channel                        0x7
-#define rZebra1_TxGain                         0x8
-#define rZebra1_TxLPF                          0x9
-#define rZebra1_RxLPF                          0xb
-#define rZebra1_RxHPFCorner            0xc
+#define rZebra1_HSSIEnable             0x0
+#define rZebra1_TRxEnable1             0x1
+#define rZebra1_TRxEnable2             0x2
+#define rZebra1_AGC                            0x4
+#define rZebra1_ChargePump             0x5
+#define rZebra1_Channel                                0x7
+#define rZebra1_TxGain                         0x8
+#define rZebra1_TxLPF                          0x9
+#define rZebra1_RxLPF                          0xb
+#define rZebra1_RxHPFCorner            0xc
 
 //Zebra4
-#define rGlobalCtrl                            0
-#define rRTL8256_TxLPF                         19
-#define rRTL8256_RxLPF                         11
+#define rGlobalCtrl                            0
+#define rRTL8256_TxLPF                         19
+#define rRTL8256_RxLPF                         11
 
 //RTL8258
-#define rRTL8258_TxLPF                         0x11
-#define rRTL8258_RxLPF                         0x13
-#define rRTL8258_RSSILPF               0xa
+#define rRTL8258_TxLPF                         0x11
+#define rRTL8258_RxLPF                         0x13
+#define rRTL8258_RSSILPF               0xa
 
 //Bit Mask
 //page-1
-#define bBBResetB                                      0x100
-#define bGlobalResetB                          0x200
-#define bOFDMTxStart                           0x4
-#define bCCKTxStart                                    0x8
-#define bCRC32Debug                            0x100
-#define bPMACLoopback                          0x10
-#define bTxLSIG                                        0xffffff
-#define bOFDMTxRate                            0xf
-#define bOFDMTxReserved                        0x10
-#define bOFDMTxLength                          0x1ffe0
-#define bOFDMTxParity                          0x20000
-#define bTxHTSIG1                                      0xffffff
-#define bTxHTMCSRate                           0x7f
-#define bTxHTBW                                        0x80
-#define bTxHTLength                            0xffff00
-#define bTxHTSIG2                                      0xffffff
-#define bTxHTSmoothing                         0x1
-#define bTxHTSounding                          0x2
-#define bTxHTReserved                          0x4
-#define bTxHTAggreation                        0x8
-#define bTxHTSTBC                                      0x30
-#define bTxHTAdvanceCoding                     0x40
-#define bTxHTShortGI                           0x80
-#define bTxHTNumberHT_LTF                      0x300
-#define bTxHTCRC8                                      0x3fc00
-#define bCounterReset                          0x10000
-#define bNumOfOFDMTx                           0xffff
-#define bNumOfCCKTx                            0xffff0000
-#define bTxIdleInterval                                0xffff
-#define bOFDMService                           0xffff0000
-#define bTxMACHeader                           0xffffffff
-#define bTxDataInit                                    0xff
-#define bTxHTMode                              0x100
-#define bTxDataType                            0x30000
-#define bTxRandomSeed                          0xffffffff
-#define bCCKTxPreamble                         0x1
-#define bCCKTxSFD                                      0xffff0000
-#define bCCKTxSIG                                      0xff
-#define bCCKTxService                          0xff00
-#define bCCKLengthExt                          0x8000
-#define bCCKTxLength                           0xffff0000
-#define bCCKTxCRC16                            0xffff
-#define bCCKTxStatus                           0x1
-#define bOFDMTxStatus                          0x2
+#define bBBResetB                                      0x100
+#define bGlobalResetB                          0x200
+#define bOFDMTxStart                           0x4
+#define bCCKTxStart                                    0x8
+#define bCRC32Debug                            0x100
+#define bPMACLoopback                          0x10
+#define bTxLSIG                                                0xffffff
+#define bOFDMTxRate                            0xf
+#define bOFDMTxReserved                                0x10
+#define bOFDMTxLength                          0x1ffe0
+#define bOFDMTxParity                          0x20000
+#define bTxHTSIG1                                      0xffffff
+#define bTxHTMCSRate                           0x7f
+#define bTxHTBW                                                0x80
+#define bTxHTLength                            0xffff00
+#define bTxHTSIG2                                      0xffffff
+#define bTxHTSmoothing                         0x1
+#define bTxHTSounding                          0x2
+#define bTxHTReserved                          0x4
+#define bTxHTAggreation                                0x8
+#define bTxHTSTBC                                      0x30
+#define bTxHTAdvanceCoding                     0x40
+#define bTxHTShortGI                           0x80
+#define bTxHTNumberHT_LTF                      0x300
+#define bTxHTCRC8                                      0x3fc00
+#define bCounterReset                          0x10000
+#define bNumOfOFDMTx                           0xffff
+#define bNumOfCCKTx                            0xffff0000
+#define bTxIdleInterval                                        0xffff
+#define bOFDMService                           0xffff0000
+#define bTxMACHeader                           0xffffffff
+#define bTxDataInit                                    0xff
+#define bTxHTMode                              0x100
+#define bTxDataType                            0x30000
+#define bTxRandomSeed                          0xffffffff
+#define bCCKTxPreamble                         0x1
+#define bCCKTxSFD                                      0xffff0000
+#define bCCKTxSIG                                      0xff
+#define bCCKTxService                          0xff00
+#define bCCKLengthExt                          0x8000
+#define bCCKTxLength                           0xffff0000
+#define bCCKTxCRC16                            0xffff
+#define bCCKTxStatus                           0x1
+#define bOFDMTxStatus                          0x2
 
 //page-8
-#define bRFMOD                                         0x1
-#define bJapanMode                             0x2
-#define bCCKTxSC                                       0x30
-#define bCCKEn                                         0x1000000
-#define bOFDMEn                                        0x2000000
-#define bOFDMRxADCPhase                        0x10000
-#define bOFDMTxDACPhase                        0x40000
-#define bXATxAGC                                       0x3f
-#define bXBTxAGC                                       0xf00
-#define bXCTxAGC                                       0xf000
-#define bXDTxAGC                                       0xf0000
-#define bPAStart                                       0xf0000000
-#define bTRStart                                       0x00f00000
-#define bRFStart                                       0x0000f000
-#define bBBStart                                       0x000000f0
-#define bBBCCKStart                            0x0000000f
-#define bPAEnd                                         0xf          //Reg0x814
-#define bTREnd                                         0x0f000000
-#define bRFEnd                                         0x000f0000
-#define bCCAMask                                       0x000000f0   //T2R
-#define bR2RCCAMask                            0x00000f00
-#define bHSSI_R2TDelay                         0xf8000000
-#define bHSSI_T2RDelay                         0xf80000
-#define bContTxHSSI                            0x400     //chane gain at continue Tx
-#define bIGFromCCK                             0x200
-#define bAGCAddress                            0x3f
-#define bRxHPTx                                        0x7000
-#define bRxHPT2R                                       0x38000
-#define bRxHPCCKIni                            0xc0000
-#define bAGCTxCode                             0xc00000
-#define bAGCRxCode                             0x300000
-#define b3WireDataLength                       0x800
-#define b3WireAddressLength                    0x400
-#define b3WireRFPowerDown                      0x1
-//#define bHWSISelect                          0x8
-#define b5GPAPEPolarity                        0x40000000
-#define b2GPAPEPolarity                        0x80000000
-#define bRFSW_TxDefaultAnt                     0x3
-#define bRFSW_TxOptionAnt                      0x30
-#define bRFSW_RxDefaultAnt                     0x300
-#define bRFSW_RxOptionAnt                      0x3000
-#define bRFSI_3WireData                        0x1
-#define bRFSI_3WireClock                       0x2
-#define bRFSI_3WireLoad                        0x4
-#define bRFSI_3WireRW                          0x8
-#define bRFSI_3Wire                                    0xf  //3-wire total control
-#define bRFSI_RFENV                            0x10
-#define bRFSI_TRSW                             0x20
-#define bRFSI_TRSWB                            0x40
-#define bRFSI_ANTSW                            0x100
-#define bRFSI_ANTSWB                           0x200
-#define bRFSI_PAPE                                     0x400
-#define bRFSI_PAPE5G                           0x800
-#define bBandSelect                                    0x1
-#define bHTSIG2_GI                                     0x80
-#define bHTSIG2_Smoothing                      0x01
-#define bHTSIG2_Sounding                       0x02
-#define bHTSIG2_Aggreaton                      0x08
-#define bHTSIG2_STBC                           0x30
-#define bHTSIG2_AdvCoding                      0x40
-#define bHTSIG2_NumOfHTLTF             0x300
-#define bHTSIG2_CRC8                           0x3fc
-#define bHTSIG1_MCS                            0x7f
-#define bHTSIG1_BandWidth                      0x80
-#define bHTSIG1_HTLength                       0xffff
-#define bLSIG_Rate                                     0xf
-#define bLSIG_Reserved                         0x10
-#define bLSIG_Length                           0x1fffe
-#define bLSIG_Parity                                   0x20
-#define bCCKRxPhase                            0x4
-#define bLSSIReadAddress                       0x3f000000   //LSSI "Read" Address
-#define bLSSIReadEdge                          0x80000000   //LSSI "Read" edge signal
-#define bLSSIReadBackData                      0xfff
-#define bLSSIReadOKFlag                        0x1000
-#define bCCKSampleRate                         0x8       //0: 44MHz, 1:88MHz
-
-#define bRegulator0Standby                     0x1
-#define bRegulatorPLLStandby                   0x2
-#define bRegulator1Standby                     0x4
-#define bPLLPowerUp                            0x8
-#define bDPLLPowerUp                           0x10
-#define bDA10PowerUp                           0x20
-#define bAD7PowerUp                            0x200
-#define bDA6PowerUp                            0x2000
-#define bXtalPowerUp                           0x4000
-#define b40MDClkPowerUP                        0x8000
-#define bDA6DebugMode                          0x20000
-#define bDA6Swing                                      0x380000
-#define bADClkPhase                            0x4000000
-#define b80MClkDelay                           0x18000000
-#define bAFEWatchDogEnable                     0x20000000
-#define bXtalCap                                       0x0f000000
-#define bIntDifClkEnable                       0x400
-#define bExtSigClkEnable                       0x800
-#define bBandgapMbiasPowerUp           0x10000
-#define bAD11SHGain                            0xc0000
-#define bAD11InputRange                        0x700000
-#define bAD11OPCurrent                         0x3800000
-#define bIPathLoopback                         0x4000000
-#define bQPathLoopback                         0x8000000
-#define bAFELoopback                           0x10000000
-#define bDA10Swing                             0x7e0
-#define bDA10Reverse                           0x800
-#define bDAClkSource                           0x1000
-#define bAD7InputRange                         0x6000
-#define bAD7Gain                                       0x38000
-#define bAD7OutputCMMode                       0x40000
-#define bAD7InputCMMode                        0x380000
-#define bAD7Current                                    0xc00000
-#define bRegulatorAdjust                       0x7000000
-#define bAD11PowerUpAtTx                       0x1
-#define bDA10PSAtTx                            0x10
-#define bAD11PowerUpAtRx                       0x100
-#define bDA10PSAtRx                            0x1000
-
-#define bCCKRxAGCFormat                        0x200
-
-#define bPSDFFTSamplepPoint                    0xc000
-#define bPSDAverageNum                         0x3000
-#define bIQPathControl                         0xc00
-#define bPSDFreq                                       0x3ff
-#define bPSDAntennaPath                        0x30
-#define bPSDIQSwitch                           0x40
-#define bPSDRxTrigger                          0x400000
-#define bPSDTxTrigger                          0x80000000
-#define bPSDSineToneScale                      0x7f000000
-#define bPSDReport                                     0xffff
+#define bRFMOD                                         0x1
+#define bJapanMode                             0x2
+#define bCCKTxSC                                       0x30
+#define bCCKEn                                         0x1000000
+#define bOFDMEn                                                0x2000000
+#define bOFDMRxADCPhase                                0x10000
+#define bOFDMTxDACPhase                                0x40000
+#define bXATxAGC                                       0x3f
+#define bXBTxAGC                                       0xf00
+#define bXCTxAGC                                       0xf000
+#define bXDTxAGC                                       0xf0000
+#define bPAStart                                       0xf0000000
+#define bTRStart                                       0x00f00000
+#define bRFStart                                       0x0000f000
+#define bBBStart                                       0x000000f0
+#define bBBCCKStart                            0x0000000f
+#define bPAEnd                                         0xf          //Reg0x814
+#define bTREnd                                         0x0f000000
+#define bRFEnd                                         0x000f0000
+#define bCCAMask                                       0x000000f0   //T2R
+#define bR2RCCAMask                            0x00000f00
+#define bHSSI_R2TDelay                         0xf8000000
+#define bHSSI_T2RDelay                         0xf80000
+#define bContTxHSSI                            0x400     //chane gain at continue Tx
+#define bIGFromCCK                             0x200
+#define bAGCAddress                            0x3f
+#define bRxHPTx                                                0x7000
+#define bRxHPT2R                                       0x38000
+#define bRxHPCCKIni                            0xc0000
+#define bAGCTxCode                             0xc00000
+#define bAGCRxCode                             0x300000
+#define b3WireDataLength                       0x800
+#define b3WireAddressLength                    0x400
+#define b3WireRFPowerDown                      0x1
+//#define bHWSISelect                          0x8
+#define b5GPAPEPolarity                                0x40000000
+#define b2GPAPEPolarity                                0x80000000
+#define bRFSW_TxDefaultAnt                     0x3
+#define bRFSW_TxOptionAnt                      0x30
+#define bRFSW_RxDefaultAnt                     0x300
+#define bRFSW_RxOptionAnt                      0x3000
+#define bRFSI_3WireData                                0x1
+#define bRFSI_3WireClock                       0x2
+#define bRFSI_3WireLoad                                0x4
+#define bRFSI_3WireRW                          0x8
+#define bRFSI_3Wire                                    0xf  //3-wire total control
+#define bRFSI_RFENV                            0x10
+#define bRFSI_TRSW                             0x20
+#define bRFSI_TRSWB                            0x40
+#define bRFSI_ANTSW                            0x100
+#define bRFSI_ANTSWB                           0x200
+#define bRFSI_PAPE                                     0x400
+#define bRFSI_PAPE5G                           0x800
+#define bBandSelect                                    0x1
+#define bHTSIG2_GI                                     0x80
+#define bHTSIG2_Smoothing                      0x01
+#define bHTSIG2_Sounding                       0x02
+#define bHTSIG2_Aggreaton                      0x08
+#define bHTSIG2_STBC                           0x30
+#define bHTSIG2_AdvCoding                      0x40
+#define bHTSIG2_NumOfHTLTF             0x300
+#define bHTSIG2_CRC8                           0x3fc
+#define bHTSIG1_MCS                            0x7f
+#define bHTSIG1_BandWidth                      0x80
+#define bHTSIG1_HTLength                       0xffff
+#define bLSIG_Rate                                     0xf
+#define bLSIG_Reserved                         0x10
+#define bLSIG_Length                           0x1fffe
+#define bLSIG_Parity                                   0x20
+#define bCCKRxPhase                            0x4
+#define bLSSIReadAddress                       0x3f000000   //LSSI "Read" Address
+#define bLSSIReadEdge                          0x80000000   //LSSI "Read" edge signal
+#define bLSSIReadBackData                      0xfff
+#define bLSSIReadOKFlag                                0x1000
+#define bCCKSampleRate                         0x8       //0: 44MHz, 1:88MHz
+
+#define bRegulator0Standby                     0x1
+#define bRegulatorPLLStandby                   0x2
+#define bRegulator1Standby                     0x4
+#define bPLLPowerUp                            0x8
+#define bDPLLPowerUp                           0x10
+#define bDA10PowerUp                           0x20
+#define bAD7PowerUp                            0x200
+#define bDA6PowerUp                            0x2000
+#define bXtalPowerUp                           0x4000
+#define b40MDClkPowerUP                                0x8000
+#define bDA6DebugMode                          0x20000
+#define bDA6Swing                                      0x380000
+#define bADClkPhase                            0x4000000
+#define b80MClkDelay                           0x18000000
+#define bAFEWatchDogEnable                     0x20000000
+#define bXtalCap                                       0x0f000000
+#define bIntDifClkEnable                       0x400
+#define bExtSigClkEnable                       0x800
+#define bBandgapMbiasPowerUp           0x10000
+#define bAD11SHGain                            0xc0000
+#define bAD11InputRange                                0x700000
+#define bAD11OPCurrent                         0x3800000
+#define bIPathLoopback                         0x4000000
+#define bQPathLoopback                         0x8000000
+#define bAFELoopback                           0x10000000
+#define bDA10Swing                             0x7e0
+#define bDA10Reverse                           0x800
+#define bDAClkSource                           0x1000
+#define bAD7InputRange                         0x6000
+#define bAD7Gain                                       0x38000
+#define bAD7OutputCMMode                       0x40000
+#define bAD7InputCMMode                                0x380000
+#define bAD7Current                                    0xc00000
+#define bRegulatorAdjust                       0x7000000
+#define bAD11PowerUpAtTx                       0x1
+#define bDA10PSAtTx                            0x10
+#define bAD11PowerUpAtRx                       0x100
+#define bDA10PSAtRx                            0x1000
+
+#define bCCKRxAGCFormat                                0x200
+
+#define bPSDFFTSamplepPoint                    0xc000
+#define bPSDAverageNum                         0x3000
+#define bIQPathControl                         0xc00
+#define bPSDFreq                                       0x3ff
+#define bPSDAntennaPath                                0x30
+#define bPSDIQSwitch                           0x40
+#define bPSDRxTrigger                          0x400000
+#define bPSDTxTrigger                          0x80000000
+#define bPSDSineToneScale                      0x7f000000
+#define bPSDReport                                     0xffff
 
 //page-9
-#define bOFDMTxSC                              0x30000000
-#define bCCKTxOn                                       0x1
-#define bOFDMTxOn                              0x2
-#define bDebugPage                             0xfff  //reset debug page and also HWord, LWord
-#define bDebugItem                             0xff   //reset debug page and LWord
-#define bAntL                                  0x10
-#define bAntNonHT                                      0x100
-#define bAntHT1                                0x1000
-#define bAntHT2                                        0x10000
-#define bAntHT1S1                                      0x100000
-#define bAntNonHTS1                            0x1000000
+#define bOFDMTxSC                              0x30000000
+#define bCCKTxOn                                       0x1
+#define bOFDMTxOn                              0x2
+#define bDebugPage                             0xfff  //reset debug page and also HWord, LWord
+#define bDebugItem                             0xff   //reset debug page and LWord
+#define bAntL                                  0x10
+#define bAntNonHT                                      0x100
+#define bAntHT1                                        0x1000
+#define bAntHT2                                                0x10000
+#define bAntHT1S1                                      0x100000
+#define bAntNonHTS1                            0x1000000
 
 //page-a
-#define bCCKBBMode                             0x3
-#define bCCKTxPowerSaving                      0x80
-#define bCCKRxPowerSaving                      0x40
-#define bCCKSideBand                           0x10
-#define bCCKScramble                           0x8
-#define bCCKAntDiversity                       0x8000
-#define bCCKCarrierRecovery            0x4000
-#define bCCKTxRate                             0x3000
-#define bCCKDCCancel                           0x0800
-#define bCCKISICancel                          0x0400
-#define bCCKMatchFilter                        0x0200
-#define bCCKEqualizer                          0x0100
-#define bCCKPreambleDetect                     0x800000
-#define bCCKFastFalseCCA                       0x400000
-#define bCCKChEstStart                         0x300000
-#define bCCKCCACount                           0x080000
-#define bCCKcs_lim                                     0x070000
-#define bCCKBistMode                           0x80000000
-#define bCCKCCAMask                            0x40000000
-#define bCCKTxDACPhase                         0x4
-#define bCCKRxADCPhase                         0x20000000   //r_rx_clk
-#define bCCKr_cp_mode0                         0x0100
-#define bCCKTxDCOffset                         0xf0
-#define bCCKRxDCOffset                         0xf
-#define bCCKCCAMode                            0xc000
-#define bCCKFalseCS_lim                        0x3f00
-#define bCCKCS_ratio                           0xc00000
-#define bCCKCorgBit_sel                        0x300000
-#define bCCKPD_lim                                     0x0f0000
-#define bCCKNewCCA                             0x80000000
-#define bCCKRxHPofIG                           0x8000
-#define bCCKRxIG                                       0x7f00
-#define bCCKLNAPolarity                        0x800000
-#define bCCKRx1stGain                          0x7f0000
-#define bCCKRFExtend                           0x20000000 //CCK Rx initial gain polarity
-#define bCCKRxAGCSatLevel                      0x1f000000
-#define bCCKRxAGCSatCount                      0xe0
-#define bCCKRxRFSettle                         0x1f       //AGCsamp_dly
-#define bCCKFixedRxAGC                         0x8000
-//#define bCCKRxAGCFormat                      0x4000   //remove to HSSI register 0x824
-#define bCCKAntennaPolarity                    0x2000
-#define bCCKTxFilterType                       0x0c00
-#define bCCKRxAGCReportType            0x0300
-#define bCCKRxDAGCEn                           0x80000000
-#define bCCKRxDAGCPeriod                       0x20000000
-#define bCCKRxDAGCSatLevel                     0x1f000000
-#define bCCKTimingRecovery                     0x800000
-#define bCCKTxC0                                       0x3f0000
-#define bCCKTxC1                                       0x3f000000
-#define bCCKTxC2                                       0x3f
-#define bCCKTxC3                                       0x3f00
-#define bCCKTxC4                                       0x3f0000
-#define bCCKTxC5                                       0x3f000000
-#define bCCKTxC6                                       0x3f
-#define bCCKTxC7                                       0x3f00
-#define bCCKDebugPort                          0xff0000
-#define bCCKDACDebug                           0x0f000000
-#define bCCKFalseAlarmEnable                   0x8000
-#define bCCKFalseAlarmRead                     0x4000
-#define bCCKTRSSI                                      0x7f
-#define bCCKRxAGCReport                        0xfe
-#define bCCKRxReport_AntSel                    0x80000000
-#define bCCKRxReport_MFOff                     0x40000000
-#define bCCKRxRxReport_SQLoss          0x20000000
-#define bCCKRxReport_Pktloss                   0x10000000
-#define bCCKRxReport_Lockedbit         0x08000000
-#define bCCKRxReport_RateError         0x04000000
-#define bCCKRxReport_RxRate                    0x03000000
-#define bCCKRxFACounterLower           0xff
-#define bCCKRxFACounterUpper           0xff000000
-#define bCCKRxHPAGCStart                       0xe000
-#define bCCKRxHPAGCFinal                       0x1c00
-
-#define bCCKRxFalseAlarmEnable         0x8000
-#define bCCKFACounterFreeze                    0x4000
-
-#define bCCKTxPathSel                          0x10000000
-#define bCCKDefaultRxPath                      0xc000000
-#define bCCKOptionRxPath                       0x3000000
+#define bCCKBBMode                             0x3
+#define bCCKTxPowerSaving                      0x80
+#define bCCKRxPowerSaving                      0x40
+#define bCCKSideBand                           0x10
+#define bCCKScramble                           0x8
+#define bCCKAntDiversity                       0x8000
+#define bCCKCarrierRecovery            0x4000
+#define bCCKTxRate                             0x3000
+#define bCCKDCCancel                           0x0800
+#define bCCKISICancel                          0x0400
+#define bCCKMatchFilter                                0x0200
+#define bCCKEqualizer                          0x0100
+#define bCCKPreambleDetect                     0x800000
+#define bCCKFastFalseCCA                       0x400000
+#define bCCKChEstStart                         0x300000
+#define bCCKCCACount                           0x080000
+#define bCCKcs_lim                                     0x070000
+#define bCCKBistMode                           0x80000000
+#define bCCKCCAMask                            0x40000000
+#define bCCKTxDACPhase                 0x4
+#define bCCKRxADCPhase                 0x20000000   //r_rx_clk
+#define bCCKr_cp_mode0                 0x0100
+#define bCCKTxDCOffset                         0xf0
+#define bCCKRxDCOffset                         0xf
+#define bCCKCCAMode                            0xc000
+#define bCCKFalseCS_lim                                0x3f00
+#define bCCKCS_ratio                           0xc00000
+#define bCCKCorgBit_sel                                0x300000
+#define bCCKPD_lim                                     0x0f0000
+#define bCCKNewCCA                             0x80000000
+#define bCCKRxHPofIG                           0x8000
+#define bCCKRxIG                                       0x7f00
+#define bCCKLNAPolarity                                0x800000
+#define bCCKRx1stGain                          0x7f0000
+#define bCCKRFExtend                           0x20000000 //CCK Rx initial gain polarity
+#define bCCKRxAGCSatLevel                      0x1f000000
+#define bCCKRxAGCSatCount                      0xe0
+#define bCCKRxRFSettle                         0x1f       //AGCsamp_dly
+#define bCCKFixedRxAGC                         0x8000
+//#define bCCKRxAGCFormat                      0x4000   //remove to HSSI register 0x824
+#define bCCKAntennaPolarity                    0x2000
+#define bCCKTxFilterType                       0x0c00
+#define bCCKRxAGCReportType            0x0300
+#define bCCKRxDAGCEn                           0x80000000
+#define bCCKRxDAGCPeriod                       0x20000000
+#define bCCKRxDAGCSatLevel             0x1f000000
+#define bCCKTimingRecovery                     0x800000
+#define bCCKTxC0                                       0x3f0000
+#define bCCKTxC1                                       0x3f000000
+#define bCCKTxC2                                       0x3f
+#define bCCKTxC3                                       0x3f00
+#define bCCKTxC4                                       0x3f0000
+#define bCCKTxC5                                       0x3f000000
+#define bCCKTxC6                                       0x3f
+#define bCCKTxC7                                       0x3f00
+#define bCCKDebugPort                          0xff0000
+#define bCCKDACDebug                           0x0f000000
+#define bCCKFalseAlarmEnable                   0x8000
+#define bCCKFalseAlarmRead                     0x4000
+#define bCCKTRSSI                                      0x7f
+#define bCCKRxAGCReport                                0xfe
+#define bCCKRxReport_AntSel                    0x80000000
+#define bCCKRxReport_MFOff                     0x40000000
+#define bCCKRxRxReport_SQLoss          0x20000000
+#define bCCKRxReport_Pktloss                   0x10000000
+#define bCCKRxReport_Lockedbit         0x08000000
+#define bCCKRxReport_RateError         0x04000000
+#define bCCKRxReport_RxRate                    0x03000000
+#define bCCKRxFACounterLower           0xff
+#define bCCKRxFACounterUpper           0xff000000
+#define bCCKRxHPAGCStart                       0xe000
+#define bCCKRxHPAGCFinal                       0x1c00
+
+#define bCCKRxFalseAlarmEnable         0x8000
+#define bCCKFACounterFreeze                    0x4000
+
+#define bCCKTxPathSel                          0x10000000
+#define bCCKDefaultRxPath                      0xc000000
+#define bCCKOptionRxPath                       0x3000000
 
 //page c
-#define bNumOfSTF                                      0x3
-#define bShift_L                                       0xc0
-#define bGI_TH                                         0xc
-#define bRxPathA                                       0x1
-#define bRxPathB                                       0x2
-#define bRxPathC                                       0x4
-#define bRxPathD                                       0x8
-#define bTxPathA                                       0x1
-#define bTxPathB                                       0x2
-#define bTxPathC                                       0x4
-#define bTxPathD                                       0x8
-#define bTRSSIFreq                                     0x200
-#define bADCBackoff                                    0x3000
-#define bDFIRBackoff                                   0xc000
-#define bTRSSILatchPhase                       0x10000
-#define bRxIDCOffset                                   0xff
-#define bRxQDCOffset                                   0xff00
-#define bRxDFIRMode                            0x1800000
-#define bRxDCNFType                            0xe000000
-#define bRXIQImb_A                                     0x3ff
-#define bRXIQImb_B                                     0xfc00
-#define bRXIQImb_C                                     0x3f0000
-#define bRXIQImb_D                                     0xffc00000
-#define bDC_dc_Notch                           0x60000
-#define bRxNBINotch                                    0x1f000000
-#define bPD_TH                                         0xf
-#define bPD_TH_Opt2                            0xc000
-#define bPWED_TH                                       0x700
-#define bIfMF_Win_L                                    0x800
-#define bPD_Option                                     0x1000
-#define bMF_Win_L                                      0xe000
-#define bBW_Search_L                           0x30000
-#define bwin_enh_L                                     0xc0000
-#define bBW_TH                                         0x700000
-#define bED_TH2                                        0x3800000
-#define bBW_option                                     0x4000000
-#define bRatio_TH                                      0x18000000
-#define bWindow_L                                      0xe0000000
-#define bSBD_Option                                    0x1
-#define bFrame_TH                                      0x1c
-#define bFS_Option                                     0x60
-#define bDC_Slope_check                        0x80
-#define bFGuard_Counter_DC_L                   0xe00
-#define bFrame_Weight_Short                    0x7000
-#define bSub_Tune                                      0xe00000
-#define bFrame_DC_Length                       0xe000000
-#define bSBD_start_offset                      0x30000000
-#define bFrame_TH_2                            0x7
-#define bFrame_GI2_TH                          0x38
-#define bGI2_Sync_en                           0x40
-#define bSarch_Short_Early                     0x300
-#define bSarch_Short_Late                      0xc00
-#define bSarch_GI2_Late                        0x70000
-#define bCFOAntSum                             0x1
-#define bCFOAcc                                        0x2
-#define bCFOStartOffset                        0xc
-#define bCFOLookBack                           0x70
-#define bCFOSumWeight                          0x80
-#define bDAGCEnable                                    0x10000
-#define bTXIQImb_A                                     0x3ff
-#define bTXIQImb_B                                     0xfc00
-#define bTXIQImb_C                                     0x3f0000
-#define bTXIQImb_D                                     0xffc00000
-#define bTxIDCOffset                                   0xff
-#define bTxQDCOffset                                   0xff00
-#define bTxDFIRMode                            0x10000
-#define bTxPesudoNoiseOn                       0x4000000
-#define bTxPesudoNoise_A                       0xff
-#define bTxPesudoNoise_B                       0xff00
-#define bTxPesudoNoise_C                       0xff0000
-#define bTxPesudoNoise_D                       0xff000000
-#define bCCADropOption                         0x20000
-#define bCCADropThres                          0xfff00000
-#define bEDCCA_H                                       0xf
-#define bEDCCA_L                                       0xf0
+#define bNumOfSTF                                      0x3
+#define bShift_L                                       0xc0
+#define bGI_TH                                         0xc
+#define bRxPathA                                       0x1
+#define bRxPathB                                       0x2
+#define bRxPathC                                       0x4
+#define bRxPathD                                       0x8
+#define bTxPathA                                       0x1
+#define bTxPathB                                       0x2
+#define bTxPathC                                       0x4
+#define bTxPathD                                       0x8
+#define bTRSSIFreq                                     0x200
+#define bADCBackoff                                    0x3000
+#define bDFIRBackoff                                   0xc000
+#define bTRSSILatchPhase                       0x10000
+#define bRxIDCOffset                                   0xff
+#define bRxQDCOffset                                   0xff00
+#define bRxDFIRMode                            0x1800000
+#define bRxDCNFType                            0xe000000
+#define bRXIQImb_A                                     0x3ff
+#define bRXIQImb_B                                     0xfc00
+#define bRXIQImb_C                                     0x3f0000
+#define bRXIQImb_D                                     0xffc00000
+#define bDC_dc_Notch                           0x60000
+#define bRxNBINotch                                    0x1f000000
+#define bPD_TH                                         0xf
+#define bPD_TH_Opt2                            0xc000
+#define bPWED_TH                                       0x700
+#define bIfMF_Win_L                                    0x800
+#define bPD_Option                                     0x1000
+#define bMF_Win_L                                      0xe000
+#define bBW_Search_L                           0x30000
+#define bwin_enh_L                                     0xc0000
+#define bBW_TH                                         0x700000
+#define bED_TH2                                                0x3800000
+#define bBW_option                                     0x4000000
+#define bRatio_TH                                      0x18000000
+#define bWindow_L                                      0xe0000000
+#define bSBD_Option                                    0x1
+#define bFrame_TH                                      0x1c
+#define bFS_Option                                     0x60
+#define bDC_Slope_check                                0x80
+#define bFGuard_Counter_DC_L                   0xe00
+#define bFrame_Weight_Short                    0x7000
+#define bSub_Tune                                      0xe00000
+#define bFrame_DC_Length                       0xe000000
+#define bSBD_start_offset                      0x30000000
+#define bFrame_TH_2                            0x7
+#define bFrame_GI2_TH                          0x38
+#define bGI2_Sync_en                           0x40
+#define bSarch_Short_Early                     0x300
+#define bSarch_Short_Late                      0xc00
+#define bSarch_GI2_Late                                0x70000
+#define bCFOAntSum                             0x1
+#define bCFOAcc                                                0x2
+#define bCFOStartOffset                                0xc
+#define bCFOLookBack                           0x70
+#define bCFOSumWeight                          0x80
+#define bDAGCEnable                                    0x10000
+#define bTXIQImb_A                                     0x3ff
+#define bTXIQImb_B                                     0xfc00
+#define bTXIQImb_C                                     0x3f0000
+#define bTXIQImb_D                                     0xffc00000
+#define bTxIDCOffset                                   0xff
+#define bTxQDCOffset                                   0xff00
+#define bTxDFIRMode                            0x10000
+#define bTxPesudoNoiseOn                       0x4000000
+#define bTxPesudoNoise_A                       0xff
+#define bTxPesudoNoise_B                       0xff00
+#define bTxPesudoNoise_C                       0xff0000
+#define bTxPesudoNoise_D                       0xff000000
+#define bCCADropOption                         0x20000
+#define bCCADropThres                          0xfff00000
+#define bEDCCA_H                                       0xf
+#define bEDCCA_L                                       0xf0
 #define bLambda_ED               0x300
 #define bRxInitialGain           0x7f
 #define bRxAntDivEn              0x80
 #define PathD                     0x3
 
 #define        rRTL8256RxMixerPole             0xb
-#define        bZebraRxMixerPole               0x6
-#define        rRTL8256TxBBOPBias        0x9
-#define        bRTL8256TxBBOPBias       0x400
-#define        rRTL8256TxBBBW             19
-#define        bRTL8256TxBBBW                  0x18
+#define                bZebraRxMixerPole               0x6
+#define                rRTL8256TxBBOPBias        0x9
+#define                bRTL8256TxBBOPBias       0x400
+#define                rRTL8256TxBBBW             19
+#define                bRTL8256TxBBBW                  0x18
 
 #endif //__INC_HAL8190PCIPHYREG_H
index 90954203776d3ab8e522298d4165c077774c6e3a..fad173f4097ea0f704cc887744f120c2f3913d41 100644 (file)
 #ifndef __INC_ETHERNET_H
 #define __INC_ETHERNET_H
 
-#define ETHERNET_ADDRESS_LENGTH                6       /*!< Ethernet Address Length*/
 #define ETHERNET_HEADER_SIZE           14      /*!< Ethernet Header Length*/
 #define LLC_HEADER_SIZE                        6       /*!< LLC Header Length*/
-#define TYPE_LENGTH_FIELD_SIZE         2       /*!< Type/Length Size*/
-#define MINIMUM_ETHERNET_PACKET_SIZE   60      /*!< Min Ethernet Packet Size*/
-#define MAXIMUM_ETHERNET_PACKET_SIZE   1514    /*!< Max Ethernet Packet Size*/
-
-/*!< Is Multicast Address? */
-#define RT_ETH_IS_MULTICAST(_pAddr)    ((((u8 *)(_pAddr))[0]&0x01) != 0)
 
 #endif /* #ifndef __INC_ETHERNET_H */
 
index cb9d4cfe8fe48787bc2baed0b8d1349b1cd8d919..d801c5af006ab53f9d26d6b437581cc467d2a4e9 100644 (file)
@@ -49,7 +49,7 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
        if (!firmware) {
                struct usb_device *udev = padapter->dvobjpriv.pusbdev;
                struct usb_interface *pusb_intf = padapter->pusb_intf;
-               printk(KERN_ERR "r8712u: Firmware request failed\n");
+               dev_err(&udev->dev, "r8712u: Firmware request failed\n");
                padapter->fw_found = false;
                usb_put_dev(udev);
                usb_set_intfdata(pusb_intf, NULL);
@@ -69,12 +69,11 @@ int rtl871x_load_fw(struct _adapter *padapter)
        int rc;
 
        init_completion(&padapter->rtl8712_fw_ready);
-       printk(KERN_INFO "r8712u: Loading firmware from \"%s\"\n",
-              firmware_file);
+       dev_info(dev, "r8712u: Loading firmware from \"%s\"\n", firmware_file);
        rc = request_firmware_nowait(THIS_MODULE, 1, firmware_file, dev,
                                     GFP_KERNEL, padapter, rtl871x_load_fw_cb);
        if (rc)
-               printk(KERN_ERR "r8712u: Firmware request error %d\n", rc);
+               dev_err(dev, "r8712u: Firmware request error %d\n", rc);
        return rc;
 }
 MODULE_FIRMWARE("rtlwifi/rtl8712u.bin");
@@ -84,8 +83,8 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw)
        const struct firmware **praw = &padapter->fw;
 
        if (padapter->fw->size > 200000) {
-               printk(KERN_ERR "r8172u: Badfw->size of %d\n",
-                      (int)padapter->fw->size);
+               dev_err(&padapter->pnetdev->dev, "r8172u: Badfw->size of %d\n",
+                       (int)padapter->fw->size);
                return 0;
        }
        *ppmappedfw = (u8 *)((*praw)->data);
@@ -334,11 +333,13 @@ uint rtl8712_hal_init(struct _adapter *padapter)
        if (rtl8712_dl_fw(padapter) != _SUCCESS)
                return _FAIL;
 
-       printk(KERN_INFO "r8712u: 1 RCR=0x%x\n",  r8712_read32(padapter, RCR));
+       netdev_info(padapter->pnetdev, "1 RCR=0x%x\n",
+                   r8712_read32(padapter, RCR));
        val32 = r8712_read32(padapter, RCR);
        r8712_write32(padapter, RCR, (val32 | BIT(26))); /* Enable RX TCP
                                                            Checksum offload */
-       printk(KERN_INFO "r8712u: 2 RCR=0x%x\n", r8712_read32(padapter, RCR));
+       netdev_info(padapter->pnetdev, "2 RCR=0x%x\n",
+                   r8712_read32(padapter, RCR));
        val32 = r8712_read32(padapter, RCR);
        r8712_write32(padapter, RCR, (val32|BIT(25))); /* Append PHY status */
        val32 = 0;
index 21515c31b3731de2031ec680a63921fcbc3313bd..da4000e49da61a1a2dd660ca4f80ef37861ea51d 100644 (file)
@@ -777,7 +777,7 @@ extern inline int ieee80211_get_hdrlen(u16 fc)
 struct registry_priv;
 
 u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
-u8 *r8712_get_ie(u8*pbuf, sint index, sint *len, sint limit);
+u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit);
 unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
 unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len,
                                 int limit);
index 7279854c86aa4e1dccccbd6d363d6ab3c28bec79..f569a7081be599ddd645fb55f928a3067340a9f7 100644 (file)
@@ -106,8 +106,6 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
                 * disconnect with AP for 60 seconds.
                 */
 
-               memset(&backupPMKIDList[0], 0x00, sizeof(
-                       struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
                memcpy(&backupPMKIDList[0], &adapter->securitypriv.
                        PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
                        NUM_PMKID_CACHE);
index e00f7918d261e57ad47ac2b6c219edf9b2a7a7f9..b65bf5e177a84efc1aac4f63c2be7d0b58a52cd9 100644 (file)
@@ -224,8 +224,7 @@ struct net_device *r8712_init_netdev(void)
        }
        padapter = (struct _adapter *) netdev_priv(pnetdev);
        padapter->pnetdev = pnetdev;
-       printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to"
-              " netdev_ops\n");
+       pr_info("r8712u: register rtl8712_netdev_ops to netdev_ops\n");
        pnetdev->netdev_ops = &rtl8712_netdev_ops;
        pnetdev->watchdog_timeo = HZ; /* 1 second timeout */
        pnetdev->wireless_handlers = (struct iw_handler_def *)
index c76732cdb183f0a9653f7b4e3d1248707997d9f7..d59a74aa30489f2bf70c9f6b8a450d8ddaf4b484 100644 (file)
@@ -115,11 +115,11 @@ void r8712_free_recv_priv(struct recv_priv *precvpriv)
        kfree(precvpriv->pallocated_recv_buf);
        skb_queue_purge(&precvpriv->rx_skb_queue);
        if (skb_queue_len(&precvpriv->rx_skb_queue))
-               printk(KERN_WARNING "r8712u: rx_skb_queue not empty\n");
+               netdev_warn(padapter->pnetdev, "r8712u: rx_skb_queue not empty\n");
        skb_queue_purge(&precvpriv->free_recv_skb_queue);
        if (skb_queue_len(&precvpriv->free_recv_skb_queue))
-               printk(KERN_WARNING "r8712u: free_recv_skb_queue not empty "
-                      "%d\n", skb_queue_len(&precvpriv->free_recv_skb_queue));
+               netdev_warn(padapter->pnetdev, "r8712u: free_recv_skb_queue not empty %d\n",
+                           skb_queue_len(&precvpriv->free_recv_skb_queue));
 }
 
 int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf)
@@ -364,9 +364,8 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe)
                nSubframe_Length = (nSubframe_Length >> 8) +
                                   (nSubframe_Length << 8);
                if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
-                       printk(KERN_WARNING "r8712u: nRemain_Length is %d and"
-                           " nSubframe_Length is: %d\n",
-                           a_len, nSubframe_Length);
+                       netdev_warn(padapter->pnetdev, "r8712u: nRemain_Length is %d and nSubframe_Length is: %d\n",
+                                   a_len, nSubframe_Length);
                        goto exit;
                }
                /* move the data point to data content */
@@ -381,8 +380,7 @@ static int amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe)
                memcpy(data_ptr, pdata, nSubframe_Length);
                subframes[nr_subframes++] = sub_skb;
                if (nr_subframes >= MAX_SUBFRAME_COUNT) {
-                       printk(KERN_WARNING "r8712u: ParseSubframe(): Too"
-                           " many Subframes! Packets dropped!\n");
+                       netdev_warn(padapter->pnetdev, "r8712u: ParseSubframe(): Too many Subframes! Packets dropped!\n");
                        break;
                }
                pdata += nSubframe_Length;
index 31f31dbf7f3166654c068ca83c46dcc2d287d3e9..f16307f5d827e72707996c1299c8636e3448e000 100644 (file)
@@ -525,7 +525,6 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
                kfree(pcmd);
                return _FAIL;
        }
-       memset(psecnetwork, 0, t_len);
        memcpy(psecnetwork, &pnetwork->network, t_len);
        auth = &psecuritypriv->authenticator_ie[0];
        psecuritypriv->authenticator_ie[0] = (unsigned char)
index 9d93189d87000fafb39e40037f6869e864baf73a..0ce79b1c4ee278c52bd52c34382c5eb47c285839 100644 (file)
@@ -749,7 +749,7 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter,
 u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
 u8 r8712_set_chplan_cmd(struct _adapter  *padapter, int chplan);
 u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset);
-u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval);
+u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval);
 u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode);
 u8 r8712_setrfreg_cmd(struct _adapter  *padapter, u8 offset, u32 val);
 u8 r8712_setrttbl_cmd(struct _adapter  *padapter,
index 3a6479064519aafea0cce74b53e6b156451e7c47..f034567122d975a911799c2d03aad6ae734afbe0 100644 (file)
@@ -188,8 +188,7 @@ static inline char *translate_scan(struct _adapter *padapter,
        /* Add the ESSID */
        iwe.cmd = SIOCGIWESSID;
        iwe.u.data.flags = 1;
-       iwe.u.data.length = (u16)min((u16)pnetwork->network.Ssid.SsidLength,
-                           (u16)32);
+       iwe.u.data.length = min_t(u32, pnetwork->network.Ssid.SsidLength, 32);
        start = iwe_stream_add_point(info, start, stop, &iwe,
                                     pnetwork->network.Ssid.Ssid);
        /* parsing HT_CAP_IE */
@@ -415,8 +414,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
        } else
                return -EINVAL;
        if (strcmp(param->u.crypt.alg, "WEP") == 0) {
-               printk(KERN_INFO "r8712u: wpa_set_encryption, crypt.alg ="
-                      " WEP\n");
+               netdev_info(dev, "r8712u: %s: crypt.alg = WEP\n", __func__);
                padapter->securitypriv.ndisencryptstatus =
                             Ndis802_11Encryption1Enabled;
                padapter->securitypriv.PrivacyAlgrthm = _WEP40_;
@@ -608,8 +606,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
 
                                if ((eid == _VENDOR_SPECIFIC_IE_) &&
                                    (!memcmp(&buf[cnt+2], wps_oui, 4))) {
-                                       printk(KERN_INFO "r8712u: "
-                                              "SET WPS_IE\n");
+                                       netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE\n");
                                        padapter->securitypriv.wps_ie_len =
                                            ((buf[cnt+1] + 2) <
                                            (MAX_WPA_IE_LEN << 2)) ?
@@ -620,8 +617,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                                            padapter->securitypriv.wps_ie_len);
                                        padapter->securitypriv.wps_phase =
                                                                 true;
-                                       printk(KERN_INFO "r8712u: SET WPS_IE,"
-                                           " wps_phase==true\n");
+                                       netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n");
                                        cnt += buf[cnt+1]+2;
                                        break;
                                } else
@@ -829,8 +825,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                            strIssueBssid, ETH_ALEN)) {
                                /* BSSID is matched, the same AP => rewrite
                                 * with new PMKID. */
-                               printk(KERN_INFO "r8712u: r871x_wx_set_pmkid:"
-                                   " BSSID exists in the PMKList.\n");
+                               netdev_info(dev, "r8712u: %s: BSSID exists in the PMKList.\n",
+                                           __func__);
                                memcpy(psecuritypriv->PMKIDList[j].PMKID,
                                        pPMK->pmkid, IW_PMKID_LEN);
                                psecuritypriv->PMKIDList[j].bUsed = true;
@@ -841,9 +837,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                }
                if (!blInserted) {
                        /* Find a new entry */
-                       printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: Use the"
-                           " new entry index = %d for this PMKID.\n",
-                           psecuritypriv->PMKIDIndex);
+                       netdev_info(dev, "r8712u: %s: Use the new entry index = %d for this PMKID.\n",
+                                   __func__, psecuritypriv->PMKIDIndex);
                        memcpy(psecuritypriv->PMKIDList[psecuritypriv->
                                PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN);
                        memcpy(psecuritypriv->PMKIDList[psecuritypriv->
@@ -876,8 +871,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                intReturn = true;
                break;
        default:
-               printk(KERN_INFO "r8712u: r871x_wx_set_pmkid: "
-                      "unknown Command\n");
+               netdev_info(dev, "r8712u: %s: unknown Command\n", __func__);
                intReturn = false;
                break;
        }
@@ -1045,8 +1039,8 @@ static int r871x_wx_set_priv(struct net_device *dev,
                );
                sprintf(ext, "OK");
        } else {
-               printk(KERN_INFO "r8712u: r871x_wx_set_priv: unknown Command"
-                      " %s.\n", ext);
+               netdev_info(dev, "r8712u: %s: unknown Command %s.\n",
+                           __func__, ext);
                goto FREE_EXT;
        }
        if (copy_to_user(dwrq->pointer, ext,
@@ -1131,11 +1125,11 @@ static int r8711_wx_get_wap(struct net_device *dev,
        struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
-       memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
-       if (check_fwstate(pmlmepriv, _FW_LINKED |
-           WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) {
+       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
+                                    WIFI_AP_STATE))
                memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
-       }
+       else
+               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
        return 0;
 }
 
@@ -1183,8 +1177,8 @@ static int r8711_wx_set_scan(struct net_device *dev,
        u8 status = true;
 
        if (padapter->bDriverStopped == true) {
-               printk(KERN_WARNING "r8712u: in r8711_wx_set_scan: "
-                   "bDriverStopped=%d\n", padapter->bDriverStopped);
+               netdev_info(dev, "In %s: bDriverStopped=%d\n",
+                           __func__, padapter->bDriverStopped);
                return -1;
        }
        if (padapter->bup == false)
@@ -1199,8 +1193,7 @@ static int r8711_wx_set_scan(struct net_device *dev,
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                        struct ndis_802_11_ssid ssid;
                        unsigned long irqL;
-                       u32 len = (u32) min((u8)req->essid_len,
-                                 (u8)IW_ESSID_MAX_SIZE);
+                       u32 len = min_t(u8, req->essid_len, IW_ESSID_MAX_SIZE);
                        memset((unsigned char *)&ssid, 0,
                                 sizeof(struct ndis_802_11_ssid));
                        memcpy(ssid.Ssid, req->essid, len);
@@ -1556,8 +1549,7 @@ static int r8711_wx_set_enc(struct net_device *dev,
        key = erq->flags & IW_ENCODE_INDEX;
        memset(&wep, 0, sizeof(struct NDIS_802_11_WEP));
        if (erq->flags & IW_ENCODE_DISABLED) {
-               printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
-                      "EncryptionDisabled\n");
+               netdev_info(dev, "r8712u: %s: EncryptionDisabled\n", __func__);
                padapter->securitypriv.ndisencryptstatus =
                                 Ndis802_11EncryptionDisabled;
                padapter->securitypriv.PrivacyAlgrthm = _NO_PRIVACY_;
@@ -1578,8 +1570,7 @@ static int r8711_wx_set_enc(struct net_device *dev,
        }
        /* set authentication mode */
        if (erq->flags & IW_ENCODE_OPEN) {
-               printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
-                      "IW_ENCODE_OPEN\n");
+               netdev_info(dev, "r8712u: %s: IW_ENCODE_OPEN\n", __func__);
                padapter->securitypriv.ndisencryptstatus =
                                 Ndis802_11Encryption1Enabled;
                padapter->securitypriv.AuthAlgrthm = 0; /* open system */
@@ -1588,8 +1579,7 @@ static int r8711_wx_set_enc(struct net_device *dev,
                authmode = Ndis802_11AuthModeOpen;
                padapter->securitypriv.ndisauthtype = authmode;
        } else if (erq->flags & IW_ENCODE_RESTRICTED) {
-               printk(KERN_INFO "r8712u: r8711_wx_set_enc: "
-                      "IW_ENCODE_RESTRICTED\n");
+               netdev_info(dev, "r8712u: %s: IW_ENCODE_RESTRICTED\n", __func__);
                padapter->securitypriv.ndisencryptstatus =
                                 Ndis802_11Encryption1Enabled;
                padapter->securitypriv.AuthAlgrthm = 1; /* shared system */
@@ -1977,9 +1967,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
                status = phandler->handler(&oid_par);
                /* todo:check status, BytesNeeded, etc. */
        } else {
-               printk(KERN_INFO "r8712u: r871x_mp_ioctl_hdl(): err!,"
-                   " subcode=%d, oid=%d, handler=%p\n",
-                   poidparam->subcode, phandler->oid, phandler->handler);
+               netdev_info(dev, "r8712u: %s: err!, subcode=%d, oid=%d, handler=%p\n",
+                           __func__, poidparam->subcode, phandler->oid,
+                           phandler->handler);
                ret = -EFAULT;
                goto _r871x_mp_ioctl_hdl_exit;
        }
@@ -2034,13 +2024,13 @@ static int r871x_get_ap_info(struct net_device *dev,
                        break;
                pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
                if (hwaddr_aton_i(data, bssid)) {
-                       printk(KERN_INFO "r8712u: Invalid BSSID '%s'.\n",
-                              (u8 *)data);
+                       netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n",
+                                   (u8 *)data);
                        spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock),
-                                                                       irqL);
+                                              irqL);
                        return -EINVAL;
                }
-               printk(KERN_INFO "r8712u: BSSID:%pM\n", bssid);
+               netdev_info(dev, "r8712u: BSSID:%pM\n", bssid);
                if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) {
                        /* BSSID match, then check if supporting wpa/wpa2 */
                        pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12],
index 9a33eaee879bb370201929f9114179e4fb6bb559..5d6d55e7b38909d316b4ffa4528b5037170072ed 100644 (file)
@@ -28,6 +28,7 @@
 
 #define  _RTL871X_IOCTL_RTL_C_
 
+#include <linux/rndis.h>
 #include "osdep_service.h"
 #include "drv_types.h"
 #include "wlan_bssdef.h"
@@ -42,8 +43,8 @@
 uint oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
@@ -52,14 +53,14 @@ uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >=  sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                padapter->recvpriv.rx_smallpacket_crcerr;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
@@ -68,14 +69,14 @@ uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >=  sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                padapter->recvpriv.rx_middlepacket_crcerr;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
@@ -84,29 +85,29 @@ uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >=  sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                 padapter->recvpriv.rx_largepacket_crcerr;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv)
@@ -115,29 +116,29 @@ uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv)
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >=  sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                         padapter->recvpriv.rx_pkts +
                                         padapter->recvpriv.rx_drop;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv)
@@ -146,22 +147,22 @@ uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv)
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                *(uint *)poid_par_priv->information_buf =
                                         padapter->recvpriv.rx_icv_err;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH ;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH ;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv
                                                *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv)
@@ -171,7 +172,7 @@ uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv)
        u32 preamblemode = 0 ;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                if (padapter->registrypriv.preamble == PREAMBLE_LONG)
                        preamblemode = 0;
@@ -182,15 +183,15 @@ uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv)
                *(u32 *)poid_par_priv->information_buf = preamblemode;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv)
@@ -200,10 +201,10 @@ uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv)
        struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        *(u16 *)poid_par_priv->information_buf = peeprompriv->channel_plan;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_set_channelplan_hdl(struct oid_par_priv
@@ -214,9 +215,9 @@ uint oid_rt_set_channelplan_hdl(struct oid_par_priv
        struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        peeprompriv->channel_plan = *(u16 *)poid_par_priv->information_buf;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv
@@ -227,7 +228,7 @@ uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv
        u32 preamblemode = 0;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                preamblemode = *(u32 *)poid_par_priv->information_buf;
                if (preamblemode == 0)
@@ -239,21 +240,21 @@ uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv
                *(u32 *)poid_par_priv->information_buf = preamblemode;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_dedicate_probe_hdl(struct oid_par_priv
                                      *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv
@@ -263,14 +264,14 @@ uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                                 padapter->xmitpriv.tx_bytes;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv
@@ -280,37 +281,37 @@ uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv
                                    (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                *(u32 *)poid_par_priv->information_buf =
                                           padapter->recvpriv.rx_bytes;
                *poid_par_priv->bytes_rw = poid_par_priv->
                                           information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_current_tx_power_level_hdl(struct oid_par_priv
                                              *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv
                                                  *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv
                                               *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv)
@@ -322,7 +323,7 @@ uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv)
        u32   channelnum;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
            (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
                pnic_Config = &pmlmepriv->cur_network.network.Configuration;
@@ -332,22 +333,22 @@ uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv)
        channelnum = pnic_Config->DSConfig;
        *(u32 *)poid_par_priv->information_buf = channelnum;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv
                         *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv
@@ -356,7 +357,7 @@ uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv
        u32 ulInfo = 0;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len >= sizeof(u32)) {
                ulInfo |= 0x0100; /* WIRELESS_MODE_B */
                ulInfo |= 0x0200; /* WIRELESS_MODE_G */
@@ -364,108 +365,108 @@ uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv
                *(u32 *) poid_par_priv->information_buf = ulInfo;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               return NDIS_STATUS_INVALID_LENGTH;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_INVALID_LENGTH;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 
 uint oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv
                                                   *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv
                                             *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv
                                              *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv
                                                      *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv*
                                              poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv*
                                             poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                        (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len ==
           (sizeof(unsigned long) * 3)) {
                if (!r8712_setrfreg_cmd(Adapter,
                        *(unsigned char *)poid_par_priv->information_buf,
                        (unsigned long)(*((unsigned long *)
                                        poid_par_priv->information_buf + 2))))
-                       status = NDIS_STATUS_NOT_ACCEPTED;
+                       status = RNDIS_STATUS_NOT_ACCEPTED;
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
 uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                        (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) {
                if (Adapter->mppriv.act_in_progress == true)
-                       status = NDIS_STATUS_NOT_ACCEPTED;
+                       status = RNDIS_STATUS_NOT_ACCEPTED;
                else {
                        /* init workparam */
                        Adapter->mppriv.act_in_progress = true;
@@ -486,10 +487,10 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv)
                            *(unsigned char *)poid_par_priv->information_buf,
                            (unsigned char *)&Adapter->mppriv.workparam.
                            io_value))
-                               status = NDIS_STATUS_NOT_ACCEPTED;
+                               status = RNDIS_STATUS_NOT_ACCEPTED;
                }
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
@@ -508,7 +509,7 @@ uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv)
        u32 ulInfo;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        /* nStatus==0   CheckingStatus
         * nStatus==1   Associated
         * nStatus==2   AdHocMode
@@ -524,12 +525,12 @@ uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv)
                ulInfo = NOTASSOCIATED ;
        *(u32 *)poid_par_priv->information_buf = ulInfo;
        *poid_par_priv->bytes_rw =  poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
index d3ab24e34e3d704d60bcebf1c7308b1a5195a10f..53a7c8c1bb40184d12e539a78cd9503b2f1a1af2 100644 (file)
@@ -97,8 +97,6 @@ static u8 do_join(struct _adapter *padapter)
                                pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
                                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));
index c51ad9ed4b52372144895cf48b003a3c5746050b..659615481f6f4c1b8d387c572cc063a11cd9492c 100644 (file)
@@ -604,9 +604,6 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
                                                 adapter->registrypriv.
                                                        dev_network.MacAddress;
                                        pmlmepriv->fw_state ^= _FW_UNDER_SURVEY;
-                                       memset(&pdev_network->Ssid, 0,
-                                               sizeof(struct
-                                                      ndis_802_11_ssid));
                                        memcpy(&pdev_network->Ssid,
                                                &pmlmepriv->assoc_ssid,
                                                sizeof(struct
@@ -1006,8 +1003,6 @@ void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf)
                        memcpy(pdev_network, &tgt_network->network,
                                r8712_get_ndis_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));
@@ -1048,8 +1043,8 @@ void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf)
        struct  sta_priv *pstapriv = &adapter->stapriv;
        struct  recv_reorder_ctrl *precvreorder_ctrl = NULL;
 
-       printk(KERN_INFO "r8712u: [%s] mac = %pM, seq = %d, tid = %d\n",
-            __func__, pAddbareq_pram->MacAddress,
+       netdev_info(adapter->pnetdev, "%s: mac = %pM, seq = %d, tid = %d\n",
+                   __func__, pAddbareq_pram->MacAddress,
            pAddbareq_pram->StartSeqNum, pAddbareq_pram->tid);
        psta = r8712_get_stainfo(pstapriv, pAddbareq_pram->MacAddress);
        if (psta) {
index 255dc94f090125fa814ed1e5b07063bea04333f8..51395d1a3c7e0d5f4b6e59ffff2f637f5e5424ed 100644 (file)
 #ifndef __RTL871X_MP_H_
 #define __RTL871X_MP_H_
 
-/*     00 - Success */
-/*     11 - Error */
-#define STATUS_SUCCESS                 (0x00000000L)
-#define STATUS_PENDING                 (0x00000103L)
-#define STATUS_UNSUCCESSFUL            (0xC0000001L)
-#define STATUS_INSUFFICIENT_RESOURCES  (0xC000009AL)
-#define STATUS_NOT_SUPPORTED           (0xC00000BBL)
-#define NDIS_STATUS_SUCCESS            ((uint)STATUS_SUCCESS)
-#define NDIS_STATUS_PENDING            ((uint) STATUS_PENDING)
-#define NDIS_STATUS_NOT_RECOGNIZED     ((uint)0x00010001L)
-#define NDIS_STATUS_NOT_COPIED         ((uint)0x00010002L)
-#define NDIS_STATUS_NOT_ACCEPTED       ((uint)0x00010003L)
-#define NDIS_STATUS_CALL_ACTIVE                ((uint)0x00010007L)
-#define NDIS_STATUS_FAILURE            ((uint) STATUS_UNSUCCESSFUL)
-#define NDIS_STATUS_RESOURCES          ((uint)\
-                                       STATUS_INSUFFICIENT_RESOURCES)
-#define NDIS_STATUS_CLOSING            ((uint)0xC0010002L)
-#define NDIS_STATUS_BAD_VERSION                ((uint)0xC0010004L)
-#define NDIS_STATUS_BAD_CHARACTERISTICS        ((uint)0xC0010005L)
-#define NDIS_STATUS_ADAPTER_NOT_FOUND  ((uint)0xC0010006L)
-#define NDIS_STATUS_OPEN_FAILED                ((uint)0xC0010007L)
-#define NDIS_STATUS_DEVICE_FAILED      ((uint)0xC0010008L)
-#define NDIS_STATUS_MULTICAST_FULL     ((uint)0xC0010009L)
-#define NDIS_STATUS_MULTICAST_EXISTS   ((uint)0xC001000AL)
-#define NDIS_STATUS_MULTICAST_NOT_FOUND        ((uint)0xC001000BL)
-#define NDIS_STATUS_REQUEST_ABORTED    ((uint)0xC001000CL)
-#define NDIS_STATUS_RESET_IN_PROGRESS  ((uint)0xC001000DL)
-#define NDIS_STATUS_CLOSING_INDICATING ((uint)0xC001000EL)
-#define NDIS_STATUS_NOT_SUPPORTED      ((uint)STATUS_NOT_SUPPORTED)
-#define NDIS_STATUS_INVALID_PACKET     ((uint)0xC001000FL)
-#define NDIS_STATUS_OPEN_LIST_FULL     ((uint)0xC0010010L)
-#define NDIS_STATUS_ADAPTER_NOT_READY  ((uint)0xC0010011L)
-#define NDIS_STATUS_ADAPTER_NOT_OPEN   ((uint)0xC0010012L)
-#define NDIS_STATUS_NOT_INDICATING     ((uint)0xC0010013L)
-#define NDIS_STATUS_INVALID_LENGTH     ((uint)0xC0010014L)
-#define NDIS_STATUS_INVALID_DATA       ((uint)0xC0010015L)
-#define NDIS_STATUS_BUFFER_TOO_SHORT   ((uint)0xC0010016L)
-#define NDIS_STATUS_INVALID_OID                ((uint)0xC0010017L)
-#define NDIS_STATUS_ADAPTER_REMOVED    ((uint)0xC0010018L)
-#define NDIS_STATUS_UNSUPPORTED_MEDIA  ((uint)0xC0010019L)
-#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((uint)0xC001001AL)
-#define NDIS_STATUS_FILE_NOT_FOUND     ((uint)0xC001001BL)
-#define NDIS_STATUS_ERROR_READING_FILE ((uint)0xC001001CL)
-#define NDIS_STATUS_ALREADY_MAPPED     ((uint)0xC001001DL)
-#define NDIS_STATUS_RESOURCE_CONFLICT  ((uint)0xC001001EL)
-#define NDIS_STATUS_NO_CABLE           ((uint)0xC001001FL)
-#define NDIS_STATUS_INVALID_SAP                ((uint)0xC0010020L)
-#define NDIS_STATUS_SAP_IN_USE         ((uint)0xC0010021L)
-#define NDIS_STATUS_INVALID_ADDRESS    ((uint)0xC0010022L)
-#define NDIS_STATUS_VC_NOT_ACTIVATED   ((uint)0xC0010023L)
-#define NDIS_STATUS_DEST_OUT_OF_ORDER  ((uint)0xC0010024L) /* cause 27*/
-#define NDIS_STATUS_VC_NOT_AVAILABLE   ((uint)0xC0010025L) /* 35,45*/
-#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((uint)0xC0010026L) /* 37*/
-#define NDIS_STATUS_INCOMPATABLE_QOS   ((uint)0xC0010027L)  /* 49*/
-#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((uint)0xC0010028L)  /*  93*/
-#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((uint)0xC0010029L)  /*  3*/
 #define MPT_NOOP                       0
 #define MPT_READ_MAC_1BYTE             1
 #define MPT_READ_MAC_2BYTE             2
index 5eb461b4a491387446b518982454fd024a36cf68..5bd42966fd5c39228ba8debb69099115ee9870ea 100644 (file)
@@ -26,6 +26,7 @@
  *
  ******************************************************************************/
 
+#include <linux/rndis.h>
 #include "osdep_service.h"
 #include "drv_types.h"
 #include "mlme_osdep.h"
 
 uint oid_null_function(struct oid_par_priv *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
@@ -48,7 +49,7 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
                        Adapter->registrypriv.wireless_mode =
                                        *(u8 *)poid_par_priv->information_buf;
                else
-                       status = NDIS_STATUS_INVALID_LENGTH;
+                       status = RNDIS_STATUS_INVALID_LENGTH;
        } else if (poid_par_priv->type_of_oid == QUERY_OID) {
                if (poid_par_priv->information_buf_len >= sizeof(u8)) {
                        *(u8 *)poid_par_priv->information_buf =
@@ -56,16 +57,16 @@ uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv)
                        *poid_par_priv->bytes_rw =
                                        poid_par_priv->information_buf_len;
                } else
-                       status = NDIS_STATUS_INVALID_LENGTH;
+                       status = RNDIS_STATUS_INVALID_LENGTH;
        } else {
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        }
        return status;
 }
 
 uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
        struct bb_reg_param *pbbreg;
@@ -73,9 +74,9 @@ uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
        u32 value;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
        offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
        if (offset < BB_REG_BASE_ADDR)
@@ -87,7 +88,7 @@ uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
 
 uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
        struct bb_reg_param *pbbreg;
@@ -95,9 +96,9 @@ uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
        u32 value;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf);
        offset = (u16)(pbbreg->offset) & 0xFFF; /*0ffset :0x800~0xfff*/
        if (offset < BB_REG_BASE_ADDR)
@@ -110,7 +111,7 @@ uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv)
 
 uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
        struct rf_reg_param *pbbreg;
@@ -119,13 +120,13 @@ uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
        u32 value;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
        path = (u8)pbbreg->path;
        if (path > RF_PATH_B)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        offset = (u8)pbbreg->offset;
        value = pbbreg->value;
        r8712_rf_reg_write(Adapter, path, offset, value);
@@ -136,20 +137,20 @@ uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct rf_reg_param *pbbreg;
        u8 path;
        u8 offset;
        u32 value;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf);
        path = (u8)pbbreg->path;
        if (path > RF_PATH_B) /* 1T2R  path_a /path_b */
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        offset = (u8)pbbreg->offset;
        value = r8712_rf_reg_read(Adapter, path, offset);
        pbbreg->value = value;
@@ -265,16 +266,16 @@ uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32 ratevalue;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        ratevalue = *((u32 *)poid_par_priv->information_buf);
        if (ratevalue >= MPT_RATE_LAST)
-               return NDIS_STATUS_INVALID_DATA;
+               return RNDIS_STATUS_INVALID_DATA;
        Adapter->mppriv.curr_rateidx = ratevalue;
        r8712_SetDataRate(Adapter);
        return status;
@@ -284,16 +285,16 @@ uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32 mode;
        u8 val8;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return  NDIS_STATUS_NOT_ACCEPTED;
+               return  RNDIS_STATUS_NOT_ACCEPTED;
        mode = *((u32 *)poid_par_priv->information_buf);
        Adapter->mppriv.mode = mode;/* 1 for loopback*/
        if (mp_start_test(Adapter) == _FAIL)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */
        r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */
        /* RCR disable Check BSSID, 0x1025004a */
@@ -313,12 +314,12 @@ uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (mp_stop_test(Adapter) == _FAIL)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 
@@ -327,16 +328,16 @@ uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32             Channel;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        Channel = *((u32 *)poid_par_priv->information_buf);
        if (Channel > 14)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        Adapter->mppriv.curr_ch = Channel;
        r8712_SetChannel(Adapter);
        return status;
@@ -346,13 +347,13 @@ uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32 antenna;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        antenna = *((u32 *)poid_par_priv->information_buf);
        Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16);
        Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF);
@@ -365,16 +366,16 @@ uint oid_rt_pro_set_tx_power_control_hdl(
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32 tx_pwr_idx;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        tx_pwr_idx = *((u32 *)poid_par_priv->information_buf);
        if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        Adapter->mppriv.curr_txpoweridx = (u8)tx_pwr_idx;
        r8712_SetTxPower(Adapter);
        return status;
@@ -383,12 +384,12 @@ uint oid_rt_pro_set_tx_power_control_hdl(
 uint oid_rt_pro_query_tx_packet_sent_hdl(
                                        struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID) {
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
                return status;
        }
        if (poid_par_priv->information_buf_len == sizeof(u32)) {
@@ -396,19 +397,19 @@ uint oid_rt_pro_query_tx_packet_sent_hdl(
                                        Adapter->mppriv.tx_pktcount;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
 uint oid_rt_pro_query_rx_packet_received_hdl(
                                        struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID) {
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
                return status;
        }
        if (poid_par_priv->information_buf_len == sizeof(u32)) {
@@ -416,19 +417,19 @@ uint oid_rt_pro_query_rx_packet_received_hdl(
                                        Adapter->mppriv.rx_pktcount;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
 uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
                                        struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID) {
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
                return status;
        }
        if (poid_par_priv->information_buf_len == sizeof(u32)) {
@@ -436,7 +437,7 @@ uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
                                        Adapter->mppriv.rx_crcerrpktcount;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
@@ -447,25 +448,25 @@ uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        Adapter->mppriv.tx_pktcount = 0;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv
                                                    *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len == sizeof(u32)) {
                Adapter->mppriv.rx_pktcount = 0;
                Adapter->mppriv.rx_crcerrpktcount = 0;
        } else
-               status = NDIS_STATUS_INVALID_LENGTH;
+               status = RNDIS_STATUS_INVALID_LENGTH;
        return status;
 }
 
@@ -476,9 +477,9 @@ uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        r8712_ResetPhyRxPktCount(Adapter);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv
@@ -488,13 +489,13 @@ uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        *(u32 *)poid_par_priv->information_buf =
                                         r8712_GetPhyRxPktReceived(Adapter);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv
@@ -504,13 +505,13 @@ uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len != sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        *(u32 *)poid_par_priv->information_buf =
                                         r8712_GetPhyRxPktCRC32Error(Adapter);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv
@@ -520,10 +521,10 @@ uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        Adapter->mppriv.curr_modem = *((u8 *)poid_par_priv->information_buf);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv
@@ -534,10 +535,10 @@ uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv
        u32             bStartTest;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        bStartTest = *((u32 *)poid_par_priv->information_buf);
        r8712_SetContinuousTx(Adapter, (u8)bStartTest);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv
@@ -548,10 +549,10 @@ uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv
        u32             bStartTest;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        bStartTest = *((u32 *)poid_par_priv->information_buf);
        r8712_SetSingleCarrierTx(Adapter, (u8)bStartTest);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv
@@ -562,10 +563,10 @@ uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv
        u32             bStartTest;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        bStartTest = *((u32 *)poid_par_priv->information_buf);
        r8712_SetCarrierSuppressionTx(Adapter, (u8)bStartTest);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv
@@ -576,28 +577,28 @@ uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv
        u32             bStartTest;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        bStartTest = *((u32 *)poid_par_priv->information_buf);
        r8712_SetSingleToneTx(Adapter, (u8)bStartTest);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct ndis_802_11_ssid *pssid;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_needed = (u32)sizeof(struct ndis_802_11_ssid);
        *poid_par_priv->bytes_rw = 0;
        if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pssid = (struct ndis_802_11_ssid *)poid_par_priv->information_buf;
        if (mp_start_joinbss(Adapter, pssid) == _FAIL)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_rw = sizeof(struct ndis_802_11_ssid);
        return status;
 }
@@ -607,12 +608,12 @@ uint oid_rt_pro_read_register_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct mp_rw_reg *RegRWStruct;
        u16             offset;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
        if ((RegRWStruct->offset >= 0x10250800) &&
            (RegRWStruct->offset <= 0x10250FFF)) {
@@ -635,7 +636,7 @@ uint oid_rt_pro_read_register_hdl(struct oid_par_priv
                                                    RegRWStruct->offset);
                        break;
                default:
-                       status = NDIS_STATUS_NOT_ACCEPTED;
+                       status = RNDIS_STATUS_NOT_ACCEPTED;
                        break;
                }
        }
@@ -647,14 +648,14 @@ uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct mp_rw_reg *RegRWStruct;
        u16             offset;
        u32             value;
        u32 oldValue = 0;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf;
        if ((RegRWStruct->offset >= 0x10250800) &&
            (RegRWStruct->offset <= 0x10250FFF)) {
@@ -691,11 +692,11 @@ uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv)
                                (unsigned int)RegRWStruct->value);
                        break;
                default:
-                       status = NDIS_STATUS_NOT_ACCEPTED;
+                       status = RNDIS_STATUS_NOT_ACCEPTED;
                        break;
                }
 
-               if ((status == NDIS_STATUS_SUCCESS) &&
+               if ((status == RNDIS_STATUS_SUCCESS) &&
                    (RegRWStruct->offset == HIMR) &&
                    (RegRWStruct->width == 4))
                        Adapter->ImrContent = RegRWStruct->value;
@@ -711,12 +712,12 @@ uint oid_rt_pro_burst_read_register_hdl(struct oid_par_priv
        struct burst_rw_reg *pBstRwReg;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf;
        r8712_read_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len,
                 pBstRwReg->Data);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv
@@ -727,16 +728,16 @@ uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv
        struct burst_rw_reg *pBstRwReg;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        pBstRwReg = (struct burst_rw_reg *)poid_par_priv->information_buf;
        r8712_write_mem(Adapter, pBstRwReg->offset, (u32)pBstRwReg->len,
                  pBstRwReg->Data);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
@@ -746,12 +747,12 @@ uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
        struct eeprom_rw_param *pEEPROM;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf;
        pEEPROM->value = r8712_eeprom_read16(Adapter,
                                             (u16)(pEEPROM->offset >> 1));
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
@@ -761,12 +762,12 @@ uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv)
        struct eeprom_rw_param *pEEPROM;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        pEEPROM = (struct eeprom_rw_param *)poid_par_priv->information_buf;
        r8712_eeprom_write16(Adapter, (u16)(pEEPROM->offset >> 1),
                             pEEPROM->value);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv)
@@ -776,17 +777,17 @@ uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv)
        struct mp_wiparam *pwi_param;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(struct mp_wiparam))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        if (Adapter->mppriv.workparam.bcompleted == false)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        pwi_param = (struct mp_wiparam *)poid_par_priv->information_buf;
        memcpy(pwi_param, &Adapter->mppriv.workparam,
                sizeof(struct mp_wiparam));
        Adapter->mppriv.act_in_progress = false;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv)
@@ -795,42 +796,42 @@ uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(uint) * 2)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        if (*(uint *)poid_par_priv->information_buf == 1)
                Adapter->mppriv.rx_pktloss = 0;
        *((uint *)poid_par_priv->information_buf+1) =
                                         Adapter->mppriv.rx_pktloss;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (r8712_setrfintfs_cmd(Adapter, *(unsigned char *)
            poid_par_priv->information_buf) == _FAIL)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 
@@ -838,10 +839,10 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        memcpy(poid_par_priv->information_buf,
                (unsigned char *)&Adapter->mppriv.rxstat,
                sizeof(struct recv_stat));
@@ -852,7 +853,7 @@ uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv)
 uint oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv
                                             *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv
@@ -860,13 +861,13 @@ uint oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (r8712_setdatarate_cmd(Adapter,
            poid_par_priv->information_buf) != _SUCCESS)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 
@@ -874,16 +875,16 @@ uint oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        if (Adapter->mppriv.act_in_progress == true)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        if (poid_par_priv->information_buf_len < sizeof(u8))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        /*init workparam*/
        Adapter->mppriv.act_in_progress = true;
        Adapter->mppriv.workparam.bcompleted = false;
@@ -904,14 +905,14 @@ uint oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u8))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        if (!r8712_setptm_cmd(Adapter, *((u8 *)poid_par_priv->information_buf)))
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 
@@ -920,13 +921,13 @@ uint oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv)
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
        u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32 ratevalue;
        u8 datarates[NumRates];
        int i;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        ratevalue = *((u32 *)poid_par_priv->information_buf);
        for (i = 0; i < NumRates; i++) {
                if (ratevalue == mpdatarate[i])
@@ -935,7 +936,7 @@ uint oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv)
                        datarates[i] = 0xff;
        }
        if (r8712_setbasicrate_cmd(Adapter, datarates) != _SUCCESS)
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 
@@ -945,14 +946,14 @@ uint oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < 8)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        *poid_par_priv->bytes_rw = 8;
        memcpy(poid_par_priv->information_buf,
                &(Adapter->pwrctrlpriv.pwr_mode), 8);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
@@ -962,18 +963,18 @@ uint oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv)
        uint pwr_mode, smart_ps;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_rw = 0;
        *poid_par_priv->bytes_needed = 8;
        if (poid_par_priv->information_buf_len < 8)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pwr_mode = *(uint *)(poid_par_priv->information_buf);
        smart_ps = *(uint *)((addr_t)poid_par_priv->information_buf + 4);
        if (pwr_mode != Adapter->pwrctrlpriv.pwr_mode || smart_ps !=
                        Adapter->pwrctrlpriv.smart_ps)
                r8712_set_ps_mode(Adapter, pwr_mode, smart_ps);
        *poid_par_priv->bytes_rw = 8;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv
@@ -981,20 +982,20 @@ uint oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct setratable_parm *prate_table;
        u8 res;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_needed  = sizeof(struct setratable_parm);
        if (poid_par_priv->information_buf_len <
            sizeof(struct setratable_parm))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        prate_table = (struct setratable_parm *)poid_par_priv->information_buf;
        res = r8712_setrttbl_cmd(Adapter, prate_table);
        if (res == _FAIL)
-               status = NDIS_STATUS_FAILURE;
+               status = RNDIS_STATUS_FAILURE;
        return status;
 }
 
@@ -1002,8 +1003,8 @@ uint oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv
                                              *poid_par_priv)
 {
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
-       return NDIS_STATUS_SUCCESS;
+               return RNDIS_STATUS_NOT_ACCEPTED;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv
@@ -1016,7 +1017,7 @@ uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv
 
        *poid_par_priv->bytes_needed = sizeof(u8);
        if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
 
        if (poid_par_priv->type_of_oid == SET_OID) {
                encry_mode = *((u8 *)poid_par_priv->information_buf);
@@ -1054,7 +1055,7 @@ uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv
                *(u8 *)poid_par_priv->information_buf =  encry_mode;
                *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        }
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 /*----------------------------------------------------------------------*/
 uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv)
@@ -1062,24 +1063,24 @@ uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv)
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        struct sta_info *psta = NULL;
        u8      *macaddr;
 
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        *poid_par_priv->bytes_needed = ETH_ALEN;
        if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        macaddr = (u8 *) poid_par_priv->information_buf;
        psta = r8712_get_stainfo(&Adapter->stapriv, macaddr);
        if (psta == NULL) { /* the sta in sta_info_queue => do nothing*/
                psta = r8712_alloc_stainfo(&Adapter->stapriv, macaddr);
                if (psta == NULL)
-                       status = NDIS_STATUS_FAILURE;
+                       status = RNDIS_STATUS_FAILURE;
        }
        return status;
 }
@@ -1090,18 +1091,18 @@ uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv)
                                   (poid_par_priv->adapter_context);
 
        unsigned long                   irqL;
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        struct sta_info         *psta = NULL;
        u8                      *macaddr;
 
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        *poid_par_priv->bytes_needed = ETH_ALEN;
        if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
 
        macaddr = (u8 *)poid_par_priv->information_buf;
 
@@ -1125,15 +1126,15 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv)
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        struct DR_VARIABLE_STRUCT *pdrv_var;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        *poid_par_priv->bytes_needed = sizeof(struct DR_VARIABLE_STRUCT);
        if (poid_par_priv->information_buf_len < *poid_par_priv->bytes_needed)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pdrv_var = (struct DR_VARIABLE_STRUCT *)poid_par_priv->information_buf;
        pdrv_var->variable = mp_query_drv_var(Adapter, pdrv_var->offset,
                                              pdrv_var->variable);
@@ -1144,7 +1145,7 @@ uint oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv)
 /*--------------------------------------------------------------------------*/
 uint oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv)
 {
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 /*------------------------------------------------------------------------*/
 uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
@@ -1152,17 +1153,17 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        struct EFUSE_ACCESS_STRUCT *pefuse;
        u8 *data;
        u16 addr = 0, cnts = 0;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len <
            sizeof(struct EFUSE_ACCESS_STRUCT))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
        addr = pefuse->start_addr;
        cnts = pefuse->cnts;
@@ -1170,9 +1171,9 @@ uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv)
        memset(data, 0xFF, cnts);
        if ((addr > 511) || (cnts < 1) || (cnts > 512) || (addr + cnts) >
             EFUSE_MAX_SIZE)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (r8712_efuse_access(Adapter, true, addr, cnts, data) == false)
-               status = NDIS_STATUS_FAILURE;
+               status = RNDIS_STATUS_FAILURE;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
        return status;
 }
@@ -1182,14 +1183,14 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
 
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        struct EFUSE_ACCESS_STRUCT *pefuse;
        u8 *data;
        u16 addr = 0, cnts = 0;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        pefuse = (struct EFUSE_ACCESS_STRUCT *)poid_par_priv->information_buf;
        addr = pefuse->start_addr;
@@ -1198,9 +1199,9 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv)
 
        if ((addr > 511) || (cnts < 1) || (cnts > 512) ||
            (addr + cnts) > r8712_efuse_get_max_size(Adapter))
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (r8712_efuse_access(Adapter, false, addr, cnts, data) == false)
-               status = NDIS_STATUS_FAILURE;
+               status = RNDIS_STATUS_FAILURE;
        return status;
 }
 /*----------------------------------------------------------------------*/
@@ -1208,12 +1209,12 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct PGPKT_STRUCT     *ppgpkt;
 
        *poid_par_priv->bytes_rw = 0;
        if (poid_par_priv->information_buf_len < sizeof(struct PGPKT_STRUCT))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        ppgpkt = (struct PGPKT_STRUCT *)poid_par_priv->information_buf;
        if (poid_par_priv->type_of_oid == QUERY_OID) {
                if (r8712_efuse_pg_packet_read(Adapter, ppgpkt->offset,
@@ -1221,7 +1222,7 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv)
                        *poid_par_priv->bytes_rw =
                                 poid_par_priv->information_buf_len;
                else
-                       status = NDIS_STATUS_FAILURE;
+                       status = RNDIS_STATUS_FAILURE;
        } else {
                if (r8712_efuse_reg_init(Adapter) == true) {
                        if (r8712_efuse_pg_packet_write(Adapter, ppgpkt->offset,
@@ -1229,10 +1230,10 @@ uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv)
                                *poid_par_priv->bytes_rw =
                                         poid_par_priv->information_buf_len;
                        else
-                               status = NDIS_STATUS_FAILURE;
+                               status = RNDIS_STATUS_FAILURE;
                        r8712_efuse_reg_uninit(Adapter);
                } else
-                       status = NDIS_STATUS_FAILURE;
+                       status = RNDIS_STATUS_FAILURE;
        }
        return status;
 }
@@ -1242,12 +1243,12 @@ uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(int))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        r8712_efuse_reg_init(Adapter);
        *(int *)poid_par_priv->information_buf =
                                 r8712_efuse_get_current_size(Adapter);
@@ -1260,12 +1261,12 @@ uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        *(int *)poid_par_priv->information_buf =
                                         r8712_efuse_get_max_size(Adapter);
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
@@ -1274,7 +1275,7 @@ uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv)
 
 uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv)
 {
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
 
        if (poid_par_priv->type_of_oid == QUERY_OID)
                status = oid_rt_pro_read_efuse_hdl(poid_par_priv);
@@ -1287,18 +1288,18 @@ uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u8              *data;
 
        *poid_par_priv->bytes_rw = 0;
        if (poid_par_priv->information_buf_len < EFUSE_MAP_MAX_SIZE)
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        data = (u8 *)poid_par_priv->information_buf;
        if (poid_par_priv->type_of_oid == QUERY_OID) {
                if (r8712_efuse_map_read(Adapter, 0, EFUSE_MAP_MAX_SIZE, data))
                        *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
                else
-                       status = NDIS_STATUS_FAILURE;
+                       status = RNDIS_STATUS_FAILURE;
        } else {
                /* SET_OID */
                if (r8712_efuse_reg_init(Adapter) == true) {
@@ -1306,10 +1307,10 @@ uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv)
                            EFUSE_MAP_MAX_SIZE, data))
                                *poid_par_priv->bytes_rw = EFUSE_MAP_MAX_SIZE;
                        else
-                               status = NDIS_STATUS_FAILURE;
+                               status = RNDIS_STATUS_FAILURE;
                        r8712_efuse_reg_uninit(Adapter);
                } else {
-                       status = NDIS_STATUS_FAILURE;
+                       status = RNDIS_STATUS_FAILURE;
                }
        }
        return status;
@@ -1319,13 +1320,13 @@ uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32             bandwidth;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        bandwidth = *((u32 *)poid_par_priv->information_buf);/*4*/
        if (bandwidth != HT_CHANNEL_WIDTH_20)
                bandwidth = HT_CHANNEL_WIDTH_40;
@@ -1338,16 +1339,16 @@ uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv)
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        u32             crystal_cap = 0;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        crystal_cap = *((u32 *)poid_par_priv->information_buf);/*4*/
        if (crystal_cap > 0xf)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        Adapter->mppriv.curr_crystalcap = crystal_cap;
        r8712_SetCrystalCap(Adapter);
        return status;
@@ -1362,9 +1363,9 @@ uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv
        u32             rcr_val32;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u8))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/*4*/
        rcr_val32 = r8712_read32(Adapter, RCR);/*RCR = 0x10250048*/
        rcr_val32 &= ~(RCR_CBSSID | RCR_AB | RCR_AM | RCR_APM | RCR_AAP);
@@ -1391,7 +1392,7 @@ uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv
        else
                Adapter->mppriv.check_mp_pkt = 0;
        r8712_write32(Adapter, RCR, rcr_val32);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv
@@ -1402,12 +1403,12 @@ uint oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv
        u32 txagc;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        txagc = *(u32 *)poid_par_priv->information_buf;
        r8712_SetTxAGCOffset(Adapter, txagc);
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv
@@ -1415,16 +1416,16 @@ uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv
 {
        struct _adapter *Adapter = (struct _adapter *)
                                   (poid_par_priv->adapter_context);
-       uint status = NDIS_STATUS_SUCCESS;
+       uint status = RNDIS_STATUS_SUCCESS;
        struct mlme_priv        *pmlmepriv = &Adapter->mlmepriv;
        struct mp_priv          *pmppriv = &Adapter->mppriv;
        u32                     type;
 
        if (poid_par_priv->type_of_oid != SET_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
 
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
 
        type = *(u32 *)poid_par_priv->information_buf;
 
@@ -1435,7 +1436,7 @@ uint oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv
                pmppriv->mode = type;
                _clr_fwstate_(pmlmepriv, WIFI_MP_LPBK_STATE);
        } else
-               status = NDIS_STATUS_NOT_ACCEPTED;
+               status = RNDIS_STATUS_NOT_ACCEPTED;
        return status;
 }
 /*--------------------------------------------------------------------------*/
@@ -1450,10 +1451,10 @@ 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 NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        bpwrup = *(u8 *)poid_par_priv->information_buf;
        /*CALL  the power_down function*/
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
 
 /*-------------------------------------------------------------------------- */
@@ -1463,11 +1464,11 @@ uint oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv)
                                   (poid_par_priv->adapter_context);
 
        if (poid_par_priv->type_of_oid != QUERY_OID)
-               return NDIS_STATUS_NOT_ACCEPTED;
+               return RNDIS_STATUS_NOT_ACCEPTED;
        if (poid_par_priv->information_buf_len < sizeof(u32))
-               return NDIS_STATUS_INVALID_LENGTH;
+               return RNDIS_STATUS_INVALID_LENGTH;
        *(int *)poid_par_priv->information_buf =
                 Adapter->registrypriv.low_power ? POWER_LOW : POWER_NORMAL;
        *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
-       return NDIS_STATUS_SUCCESS;
+       return RNDIS_STATUS_SUCCESS;
 }
index a13395fe21d7f73eba485dea8385ce7bdf049590..c732aeab8d2c67049900abce4fb48c150bb5605a 100644 (file)
@@ -207,9 +207,9 @@ void seccalctkipmic(
        u8  *Miccode,
        u8   priority);
 
-void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
-void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes);
-void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst);
+void r8712_secmicsetkey(struct mic_data *pmicdata, u8 *key);
+void r8712_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes);
+void r8712_secgetmic(struct mic_data *pmicdata, u8 *dst);
 u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe);
 u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe);
 void r8712_wep_encrypt(struct _adapter *padapter, u8  *pxmitframe);
index f8016e9abffd0719b78f6dfc9805d04c19443db1..c4e0ef2f52c68d6abc200ac03df99f368e944bf8 100644 (file)
@@ -140,7 +140,7 @@ void r8712_free_all_stainfo(struct _adapter *padapter);
 struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
 void r8712_init_bcmc_stainfo(struct _adapter *padapter);
 struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
-u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 * mac_addr);
+u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr);
 
 #endif /* _STA_INFO_H_ */
 
index a96cd06d69dd7fc9ed78d71ec920763b8c33c022..c812d6c7dc31d48b8c9fc320ce59fba2d735f89a 100644 (file)
@@ -205,9 +205,9 @@ static int r871x_suspend(struct usb_interface *pusb_intf, pm_message_t state)
 {
        struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
 
-       printk(KERN_INFO "r8712: suspending...\n");
+       netdev_info(pnetdev, "Suspending...\n");
        if (!pnetdev || !netif_running(pnetdev)) {
-               printk(KERN_INFO "r8712: unable to suspend\n");
+               netdev_info(pnetdev, "Unable to suspend\n");
                return 0;
        }
        if (pnetdev->netdev_ops->ndo_stop)
@@ -221,9 +221,9 @@ static int r871x_resume(struct usb_interface *pusb_intf)
 {
        struct net_device *pnetdev = usb_get_intfdata(pusb_intf);
 
-       printk(KERN_INFO "r8712: resuming...\n");
+       netdev_info(pnetdev,  "Resuming...\n");
        if (!pnetdev || !netif_running(pnetdev)) {
-               printk(KERN_INFO "r8712: unable to resume\n");
+               netdev_info(pnetdev, "Unable to resume\n");
                return 0;
        }
        netif_device_attach(pnetdev);
@@ -273,12 +273,12 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter)
        pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
        if (pusbd->speed == USB_SPEED_HIGH) {
                pdvobjpriv->ishighspeed = true;
-               printk(KERN_INFO "r8712u: USB_SPEED_HIGH with %d endpoints\n",
-                      pdvobjpriv->nr_endpoint);
+               dev_info(&pusbd->dev, "r8712u: USB_SPEED_HIGH with %d endpoints\n",
+                        pdvobjpriv->nr_endpoint);
        } else {
                pdvobjpriv->ishighspeed = false;
-               printk(KERN_INFO "r8712u: USB_SPEED_LOW with %d endpoints\n",
-                      pdvobjpriv->nr_endpoint);
+               dev_info(&pusbd->dev, "r8712u: USB_SPEED_LOW with %d endpoints\n",
+                        pdvobjpriv->nr_endpoint);
        }
        if ((r8712_alloc_io_queue(padapter)) == _FAIL)
                status = _FAIL;
@@ -423,9 +423,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
                tmpU1b = r8712_read8(padapter, EE_9346CR);/*CR9346*/
 
                /* To check system boot selection.*/
-               printk(KERN_INFO "r8712u: Boot from %s: Autoload %s\n",
-                      (tmpU1b & _9356SEL) ? "EEPROM" : "EFUSE",
-                      (tmpU1b & _EEPROM_EN) ? "OK" : "Failed");
+               dev_info(&udev->dev, "r8712u: Boot from %s: Autoload %s\n",
+                        (tmpU1b & _9356SEL) ? "EEPROM" : "EFUSE",
+                        (tmpU1b & _EEPROM_EN) ? "OK" : "Failed");
 
                /* To check autoload success or not.*/
                if (tmpU1b & _EEPROM_EN) {
@@ -533,8 +533,8 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
                                                 RT_CID_DEFAULT;
                                break;
                        }
-                       printk(KERN_INFO "r8712u: CustomerID = 0x%.4x\n",
-                            padapter->eeprompriv.CustomerID);
+                       dev_info(&udev->dev, "r8712u: CustomerID = 0x%.4x\n",
+                                padapter->eeprompriv.CustomerID);
                        /* Led mode */
                        switch (padapter->eeprompriv.CustomerID) {
                        case RT_CID_DEFAULT:
@@ -590,11 +590,9 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
                         * address by setting bit 1 of first octet.
                         */
                        mac[0] &= 0xFE;
-                       printk(KERN_INFO "r8712u: MAC Address from user = "
-                              "%pM\n", mac);
+                       dev_info(&udev->dev, "r8712u: MAC Address from user = %pM\n", mac);
                } else
-                       printk(KERN_INFO "r8712u: MAC Address from efuse = "
-                              "%pM\n", mac);
+                       dev_info(&udev->dev, "r8712u: MAC Address from efuse = %pM\n", mac);
                memcpy(pnetdev->dev_addr, mac, ETH_ALEN);
        }
        /* step 6. Load the firmware asynchronously */
@@ -661,7 +659,6 @@ static void __exit r8712u_drv_halt(void)
 {
        drvpriv.drv_registered = false;
        usb_deregister(&drvpriv.r871xu_drv);
-       printk(KERN_INFO "r8712u: Driver unloaded\n");
 }
 
 module_init(r8712u_drv_entry);
index 24e1ec5f0060f16b50be0931641351a72f5e3929..dca398a0656b12ef89f25c0197dc5356649cdb1b 100644 (file)
@@ -45,9 +45,6 @@ struct zero_bulkout_context {
        void *padapter;
 };
 
-#define usb_write_cmd r8712_usb_write_mem
-#define usb_write_cmd_complete usb_write_mem_complete
-
 uint r8712_usb_init_intf_priv(struct intf_priv *pintfpriv)
 {
        pintfpriv->piorw_urb = usb_alloc_urb(0, GFP_ATOMIC);
@@ -243,8 +240,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
                                  (unsigned char *)precvbuf);
                        break;
                case -EINPROGRESS:
-                       printk(KERN_ERR "r8712u: ERROR: URB IS IN"
-                              " PROGRESS!/n");
+                       netdev_err(padapter->pnetdev, "ERROR: URB IS IN PROGRESS!\n");
                        break;
                default:
                        break;
@@ -336,8 +332,7 @@ void r8712_xmit_bh(void *priv)
 
        if ((padapter->bDriverStopped == true) ||
            (padapter->bSurpriseRemoved == true)) {
-               printk(KERN_ERR "r8712u: xmit_bh => bDriverStopped"
-                      " or bSurpriseRemoved\n");
+               netdev_err(padapter->pnetdev, "xmit_bh => bDriverStopped or bSurpriseRemoved\n");
                return;
        }
        ret = r8712_xmitframe_complete(padapter, pxmitpriv, NULL);
@@ -387,7 +382,7 @@ static void usb_write_port_complete(struct urb *purb)
        case 0:
                break;
        default:
-               printk(KERN_WARNING "r8712u: pipe error: (%d)\n", purb->status);
+               netdev_warn(padapter->pnetdev, "r8712u: pipe error: (%d)\n", purb->status);
                break;
        }
        /* not to consider tx fragment */
@@ -502,8 +497,8 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
 
        palloc_buf = _malloc((u32) len + 16);
        if (palloc_buf == NULL) {
-               printk(KERN_ERR "r8712u: [%s] Can't alloc memory for vendor"
-                      " request\n", __func__);
+               dev_err(&udev->dev, "%s: Can't alloc memory for vendor request\n",
+                       __func__);
                return -1;
        }
        pIo_buf = palloc_buf + 16 - ((addr_t)(palloc_buf) & 0x0f);
index 793443e758acc1915c474d91541857404b1a314e..73d7cd28060750e5114b9df332a8b3dea40c46bb 100644 (file)
@@ -159,99 +159,85 @@ enum WIFI_REG_DOMAIN {
 #define _PRIVACY_      BIT(14)
 #define _ORDER_                BIT(15)
 
-#define SetToDs(pbuf)  \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \
-       } while (0)
+#define SetToDs(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_TO_DS_); \
+})
 
 #define GetToDs(pbuf)  (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_TO_DS_)) != 0)
 
-#define ClearToDs(pbuf)        \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
-       } while (0)
+#define ClearToDs(pbuf)        ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_TO_DS_)); \
+})
 
-#define SetFrDs(pbuf)  \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
-       } while (0)
+#define SetFrDs(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_FROM_DS_); \
+})
 
 #define GetFrDs(pbuf)  (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_FROM_DS_)) != 0)
 
-#define ClearFrDs(pbuf)        \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
-       } while (0)
+#define ClearFrDs(pbuf)        ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)); \
+})
 
 #define get_tofr_ds(pframe)    ((GetToDs(pframe) << 1) | GetFrDs(pframe))
 
 
-#define SetMFrag(pbuf) \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
-       } while (0)
+#define SetMFrag(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_FRAG_); \
+})
 
 #define GetMFrag(pbuf) (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_MORE_FRAG_)) != 0)
 
-#define ClearMFrag(pbuf)       \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
-       } while (0)
+#define ClearMFrag(pbuf) ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)); \
+})
 
-#define SetRetry(pbuf) \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \
-       } while (0)
+#define SetRetry(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_RETRY_); \
+})
 
 #define GetRetry(pbuf) (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_RETRY_)) != 0)
 
-#define ClearRetry(pbuf)       \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
-       } while (0)
+#define ClearRetry(pbuf) ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_RETRY_)); \
+})
 
-#define SetPwrMgt(pbuf)        \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
-       } while (0)
+#define SetPwrMgt(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_PWRMGT_); \
+})
 
 #define GetPwrMgt(pbuf)        (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_PWRMGT_)) != 0)
 
-#define ClearPwrMgt(pbuf)      \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
-       } while (0)
+#define ClearPwrMgt(pbuf) ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)); \
+})
 
-#define SetMData(pbuf) \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
-       } while (0)
+#define SetMData(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_MORE_DATA_); \
+})
 
 #define GetMData(pbuf) (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_MORE_DATA_)) != 0)
 
-#define ClearMData(pbuf)       \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
-       } while (0)
+#define ClearMData(pbuf) ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)); \
+})
 
-#define SetPrivacy(pbuf)       \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
-       } while (0)
+#define SetPrivacy(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_PRIVACY_); \
+})
 
 #define GetPrivacy(pbuf)       (((*(unsigned short *)(pbuf)) & \
                                le16_to_cpu(_PRIVACY_)) != 0)
 
-#define ClearPrivacy(pbuf)     \
-       do      {       \
-               *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
-       } while (0)
+#define ClearPrivacy(pbuf) ({ \
+       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
+})
 
 
 #define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
@@ -287,48 +273,42 @@ enum WIFI_REG_DOMAIN {
 #define GetTupleCache(pbuf)    (cpu_to_le16(*(unsigned short *)\
                                ((addr_t)(pbuf) + 22)))
 
-#define SetFragNum(pbuf, num) \
-       do {    \
-               *(unsigned short *)((addr_t)(pbuf) + 22) = \
-                       ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
-                       le16_to_cpu(~(0x000f))) | \
-                       cpu_to_le16(0x0f & (num));     \
-       } while (0)
-
-#define SetSeqNum(pbuf, num) \
-       do {    \
-               *(unsigned short *)((addr_t)(pbuf) + 22) = \
-                       ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
-                       le16_to_cpu((unsigned short)0x000f)) | \
-                       le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
-       } while (0)
-
-#define SetDuration(pbuf, dur) \
-       do {    \
-               *(unsigned short *)((addr_t)(pbuf) + 2) |= \
-                       cpu_to_le16(0xffff & (dur)); \
-       } while (0)
-
-#define SetPriority(pbuf, tid) \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \
-       } while (0)
+#define SetFragNum(pbuf, num) ({ \
+       *(unsigned short *)((addr_t)(pbuf) + 22) = \
+       ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
+       le16_to_cpu(~(0x000f))) | \
+       cpu_to_le16(0x0f & (num));     \
+})
+
+#define SetSeqNum(pbuf, num) ({ \
+       *(unsigned short *)((addr_t)(pbuf) + 22) = \
+       ((*(unsigned short *)((addr_t)(pbuf) + 22)) & \
+       le16_to_cpu((unsigned short)0x000f)) | \
+       le16_to_cpu((unsigned short)(0xfff0 & (num << 4))); \
+})
+
+#define SetDuration(pbuf, dur) ({ \
+       *(unsigned short *)((addr_t)(pbuf) + 2) |= \
+       cpu_to_le16(0xffff & (dur)); \
+})
+
+#define SetPriority(pbuf, tid) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(tid & 0xf); \
+})
 
 #define GetPriority(pbuf)      ((le16_to_cpu(*(unsigned short *)(pbuf))) & 0xf)
 
-#define SetAckpolicy(pbuf, ack)        \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
-       } while (0)
+#define SetAckpolicy(pbuf, ack) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16((ack & 3) << 5); \
+})
 
 #define GetAckpolicy(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 5) & 0x3)
 
 #define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1)
 
-#define SetAMsdu(pbuf, amsdu)  \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \
-       } while (0)
+#define SetAMsdu(pbuf, amsdu) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7); \
+})
 
 #define GetAid(pbuf)   (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + 2)) \
                        & 0x3fff)
@@ -457,11 +437,7 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 #define _SSID_IE_              0
 #define _SUPPORTEDRATES_IE_    1
 #define _DSSET_IE_             3
-#define _TIM_IE_               5
 #define _IBSS_PARA_IE_         6
-#define _CHLGETXT_IE_          16
-#define _RSN_IE_2_             48`
-#define _SSN_IE_1_             221
 #define _ERPINFO_IE_           42
 #define _EXT_SUPPORTEDRATES_IE_        50
 
@@ -526,10 +502,9 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
 
-#define SetOrderBit(pbuf)      \
-       do      {       \
-               *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \
-       } while (0)
+#define SetOrderBit(pbuf) ({ \
+       *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \
+})
 
 #define GetOrderBit(pbuf)      (((*(unsigned short *)(pbuf)) & \
                                le16_to_cpu(_ORDER_)) != 0)
index 65542cb7168f4f0576b7f22b8e6c1f7a06fe4e5e..4d22bb7008f8456e378c3568d3252be7ede9a79f 100644 (file)
@@ -134,8 +134,7 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter,
        for (i = 0; i < 8; i++) {
                pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
                if (pxmitbuf->pxmit_urb[i] == NULL) {
-                       printk(KERN_ERR "r8712u: pxmitbuf->pxmit_urb[i]"
-                           " == NULL");
+                       netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n");
                        return _FAIL;
                }
        }
index 5480ae11368f822c38c637929c6de5b61a83afea..a2087f5b0d1abdfbd03186f899556d50eda61528 100644 (file)
@@ -45,7 +45,7 @@
 #define IIR_RS232              0x00            /* RS232 type */
 #define IIR_RS422              0x10            /* RS422 type */
 #define IIR_RS485              0x20            /* RS485 type */
-#define IIR_UNKNOWN            0x30            /* unknown type */
+#define IIR_TYPE_MASK          0x30
 
 /* Interrrupt Mask Register */
 #define MP_OPTR_IMR0           0x0C    /* port0 ~ port8 */
index 9464f3874346eb141f115c65752b9bbe41fc4c7d..f75ee1dd475c6e1b9ead392a1e43e5ea6177747b 100644 (file)
@@ -1563,13 +1563,13 @@ static int mp_open(struct tty_struct *tty, struct file *filp)
 
        state = uart_get(drv, line);
 
-       mtpt  = (struct mp_port *)state->port;
-
        if (IS_ERR(state)) {
                retval = PTR_ERR(state);
                goto fail;
        }
 
+       mtpt  = (struct mp_port *)state->port;
+
        tty->driver_data = state;
        tty->low_latency = (state->port->flags & UPF_LOW_LATENCY) ? 1 : 0;
        tty->alt_speed = 0;
@@ -2851,18 +2851,12 @@ static void __init multi_init_ports(void)
                                printk("IIR_RET = %x\n",b_ret);
                        }
 
-                       if(IIR_RS232 == (b_ret & IIR_RS232))
-                       {
-                               mtpt->interface = RS232;
-                       }
-                       if(IIR_RS422 == (b_ret & IIR_RS422))
-                       {
+                       /* default to RS232 */
+                       mtpt->interface = RS232;
+                       if (IIR_RS422 == (b_ret & IIR_TYPE_MASK))
                                mtpt->interface = RS422PTP;
-                       }
-                       if(IIR_RS485 == (b_ret & IIR_RS485))
-                       {
+                       if (IIR_RS485 == (b_ret & IIR_TYPE_MASK))
                                mtpt->interface = RS485NE;
-                       }
                }
        }
 }
index 34710ce560046f3034ec039d980ea33c0f6beb02..861588f57d2bb38ecd1568bf87b1be718412603c 100644 (file)
@@ -3908,13 +3908,9 @@ int sep_crypto_setup(void)
                return -ENOMEM;
        }
 
-       i = 0;
-       j = 0;
-
        spin_lock_init(&queue_lock);
 
        err = 0;
-
        for (i = 0; i < ARRAY_SIZE(hash_algs); i++) {
                err = crypto_register_ahash(&hash_algs[i]);
                if (err)
index ebdcc6f91fdc1b771914278d6fcc84d46614217c..4c7822bd5358ac1d4ce31fe8239a613b286e8092 100644 (file)
 
 /* firmware stuff */
 #define OASIS_UCODE_VERS_STRING        "1.2"
-#define OASIS_UCODE_VERS_DATE          "2006/03/27 15:10:37"
-#define OASIS_UCODE_HOSTIF_ID          3
+#define OASIS_UCODE_VERS_DATE  "2006/03/27 15:10:37"
+#define OASIS_UCODE_HOSTIF_ID  3
 
 #define MOJAVE_UCODE_VERS_STRING       "1.2"
-#define MOJAVE_UCODE_VERS_DATE         "2006/03/27 15:12:22"
-#define MOJAVE_UCODE_HOSTIF_ID         3
+#define MOJAVE_UCODE_VERS_DATE         "2006/03/27 15:12:22"
+#define MOJAVE_UCODE_HOSTIF_ID         3
 
 #define GB_RCVUCODE_VERS_STRING        "1.2"
-#define GB_RCVUCODE_VERS_DATE          "2006/03/27 15:12:15"
+#define GB_RCVUCODE_VERS_DATE  "2006/03/27 15:12:15"
 static u32 OasisRcvUCodeLen = 512;
 static u32 GBRcvUCodeLen = 512;
 #define SECTION_SIZE 65536
@@ -65,12 +65,12 @@ struct slic_spinlock {
 #define SLIC_RSPQ_BUFSINPAGE      (PAGE_SIZE / SLIC_RSPBUF_SIZE)
 
 struct slic_rspqueue {
-    u32             offset;
-    u32             pageindex;
-    u32             num_pages;
-    struct slic_rspbuf *rspbuf;
-    u32 *vaddr[SLIC_RSPQ_PAGES_GB];
-    dma_addr_t          paddr[SLIC_RSPQ_PAGES_GB];
+       u32             offset;
+       u32             pageindex;
+       u32             num_pages;
+       struct slic_rspbuf *rspbuf;
+       u32 *vaddr[SLIC_RSPQ_PAGES_GB];
+       dma_addr_t          paddr[SLIC_RSPQ_PAGES_GB];
 };
 
 #define SLIC_RCVQ_EXPANSION         1
@@ -82,20 +82,20 @@ struct slic_rspqueue {
 #define SLIC_RCVQ_FILLTHRESH        (SLIC_RCVQ_ENTRIES - SLIC_RCVQ_FILLENTRIES)
 
 struct slic_rcvqueue {
-    struct sk_buff    *head;
-    struct sk_buff    *tail;
-    u32            count;
-    u32            size;
-    u32            errors;
+       struct sk_buff    *head;
+       struct sk_buff    *tail;
+       u32            count;
+       u32            size;
+       u32            errors;
 };
 
 struct slic_rcvbuf_info {
-    u32     id;
-    u32     starttime;
-    u32     stoptime;
-    u32     slicworld;
-    u32     lasttime;
-    u32     lastid;
+       u32     id;
+       u32     starttime;
+       u32     stoptime;
+       u32     slicworld;
+       u32     lasttime;
+       u32     lastid;
 };
 /*
  SLIC Handle structure.  Used to restrict handle values to
@@ -113,12 +113,12 @@ struct slic_handle_word {
 };
 
 struct slic_handle {
-    struct slic_handle_word  token;  /* token passed between host and card*/
-    ushort                      type;
-    void *address;    /* actual address of the object*/
-    ushort                      offset;
-    struct slic_handle       *other_handle;
-    struct slic_handle       *next;
+       struct slic_handle_word  token;  /* token passed between host and card*/
+       ushort                      type;
+       void *address;    /* actual address of the object*/
+       ushort                      offset;
+       struct slic_handle       *other_handle;
+       struct slic_handle       *next;
 };
 
 #define SLIC_HANDLE_FREE        0x0000
@@ -134,17 +134,17 @@ struct slic_handle {
 #define SLIC_HOSTCMD_SIZE    512
 
 struct slic_hostcmd {
-    struct slic_host64_cmd  cmd64;
-    u32                    type;
-    struct sk_buff            *skb;
-    u32                    paddrl;
-    u32                    paddrh;
-    u32                    busy;
-    u32                    cmdsize;
-    ushort                     numbufs;
-    struct slic_handle    *pslic_handle;/* handle associated with command */
-    struct slic_hostcmd    *next;
-    struct slic_hostcmd    *next_all;
+       struct slic_host64_cmd  cmd64;
+       u32                    type;
+       struct sk_buff            *skb;
+       u32                    paddrl;
+       u32                    paddrh;
+       u32                    busy;
+       u32                    cmdsize;
+       ushort                     numbufs;
+       struct slic_handle    *pslic_handle;/* handle associated with command */
+       struct slic_hostcmd    *next;
+       struct slic_hostcmd    *next_all;
 };
 
 #define SLIC_CMDQ_CMDSINPAGE    (PAGE_SIZE / SLIC_HOSTCMD_SIZE)
@@ -228,35 +228,35 @@ struct mcast_address {
 #define SLIC_CARD_STATE(x)    ((x == CARD_UP) ? "UP" : "Down")
 
 struct slic_iface_stats {
-    /*
-     * Stats
-     */
-    u64        xmt_bytes;
-    u64        xmt_ucast;
-    u64        xmt_mcast;
-    u64        xmt_bcast;
-    u64        xmt_errors;
-    u64        xmt_discards;
-    u64        xmit_collisions;
-    u64        xmit_excess_xmit_collisions;
-    u64        rcv_bytes;
-    u64        rcv_ucast;
-    u64        rcv_mcast;
-    u64        rcv_bcast;
-    u64        rcv_errors;
-    u64        rcv_discards;
+       /*
+       * Stats
+       */
+       u64        xmt_bytes;
+       u64        xmt_ucast;
+       u64        xmt_mcast;
+       u64        xmt_bcast;
+       u64        xmt_errors;
+       u64        xmt_discards;
+       u64        xmit_collisions;
+       u64        xmit_excess_xmit_collisions;
+       u64        rcv_bytes;
+       u64        rcv_ucast;
+       u64        rcv_mcast;
+       u64        rcv_bcast;
+       u64        rcv_errors;
+       u64        rcv_discards;
 };
 
 struct sliccp_stats {
-    u64        xmit_tcp_segs;
-    u64        xmit_tcp_bytes;
-    u64        rcv_tcp_segs;
-    u64        rcv_tcp_bytes;
+       u64        xmit_tcp_segs;
+       u64        xmit_tcp_bytes;
+       u64        rcv_tcp_segs;
+       u64        rcv_tcp_bytes;
 };
 
 struct slicnet_stats {
-    struct sliccp_stats        tcp;
-    struct slic_iface_stats      iface;
+       struct sliccp_stats        tcp;
+       struct slic_iface_stats      iface;
 };
 
 #define SLIC_LOADTIMER_PERIOD     1
@@ -285,51 +285,51 @@ struct slicnet_stats {
 #define SLIC_INTAGG_5GB           100
 
 struct ether_header {
-    unsigned char    ether_dhost[6];
-    unsigned char    ether_shost[6];
-    ushort   ether_type;
+       unsigned char    ether_dhost[6];
+       unsigned char    ether_shost[6];
+       ushort   ether_type;
 };
 
 struct sliccard {
-    uint              busnumber;
-    uint              slotnumber;
-    uint              state;
-    uint              cardnum;
-    uint              card_size;
-    uint              adapters_activated;
-    uint              adapters_allocated;
-    uint              adapters_sleeping;
-    uint              gennumber;
-    u32           events;
-    u32           loadlevel_current;
-    u32           load;
-    uint              reset_in_progress;
-    u32           pingstatus;
-    u32           bad_pingstatus;
-    struct timer_list loadtimer;
-    u32           loadtimerset;
-    uint              config_set;
-    struct slic_config  config;
-    struct dentry      *debugfs_dir;
-    struct dentry      *debugfs_cardinfo;
-    struct adapter  *master;
-    struct adapter  *adapter[SLIC_MAX_PORTS];
-    struct sliccard *next;
-    u32             error_interrupts;
-    u32             error_rmiss_interrupts;
-    u32             rcv_interrupts;
-    u32             xmit_interrupts;
-    u32             num_isrs;
-    u32             false_interrupts;
-    u32             max_isr_rcvs;
-    u32             max_isr_xmits;
-    u32             rcv_interrupt_yields;
-    u32             tx_packets;
-    u32             debug_ix;
-    ushort              reg_type[32];
-    ushort              reg_offset[32];
-    u32             reg_value[32];
-    u32             reg_valueh[32];
+       uint              busnumber;
+       uint              slotnumber;
+       uint              state;
+       uint              cardnum;
+       uint              card_size;
+       uint              adapters_activated;
+       uint              adapters_allocated;
+       uint              adapters_sleeping;
+       uint              gennumber;
+       u32           events;
+       u32           loadlevel_current;
+       u32           load;
+       uint              reset_in_progress;
+       u32           pingstatus;
+       u32           bad_pingstatus;
+       struct timer_list loadtimer;
+       u32           loadtimerset;
+       uint              config_set;
+       struct slic_config  config;
+       struct dentry      *debugfs_dir;
+       struct dentry      *debugfs_cardinfo;
+       struct adapter  *master;
+       struct adapter  *adapter[SLIC_MAX_PORTS];
+       struct sliccard *next;
+       u32             error_interrupts;
+       u32             error_rmiss_interrupts;
+       u32             rcv_interrupts;
+       u32             xmit_interrupts;
+       u32             num_isrs;
+       u32             false_interrupts;
+       u32             max_isr_rcvs;
+       u32             max_isr_xmits;
+       u32             rcv_interrupt_yields;
+       u32             tx_packets;
+       u32             debug_ix;
+       ushort              reg_type[32];
+       ushort              reg_offset[32];
+       u32             reg_value[32];
+       u32             reg_valueh[32];
 };
 
 #define NUM_CFG_SPACES      2
@@ -337,182 +337,182 @@ struct sliccard {
 #define NUM_CFG_REG_ULONGS  (NUM_CFG_REGS / sizeof(u32))
 
 struct physcard {
-    struct adapter  *adapter[SLIC_MAX_PORTS];
-    struct physcard *next;
-    uint                adapters_allocd;
+       struct adapter  *adapter[SLIC_MAX_PORTS];
+       struct physcard *next;
+       uint                adapters_allocd;
 
- /*  the following is not currently needed
-    u32               bridge_busnum;
-    u32               bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS];
- */
+/*  the following is not currently needed
+       u32              bridge_busnum;
+       u32              bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS];
+*/
 };
 
 struct base_driver {
-    struct slic_spinlock driver_lock;
-    u32              num_slic_cards;
-    u32              num_slic_ports;
-    u32              num_slic_ports_active;
-    u32              dynamic_intagg;
-    struct sliccard  *slic_card;
-    struct physcard  *phys_card;
-    uint                 cardnuminuse[SLIC_MAX_CARDS];
+       struct slic_spinlock driver_lock;
+       u32              num_slic_cards;
+       u32              num_slic_ports;
+       u32              num_slic_ports_active;
+       u32              dynamic_intagg;
+       struct sliccard  *slic_card;
+       struct physcard  *phys_card;
+       uint                 cardnuminuse[SLIC_MAX_CARDS];
 };
 
 struct slic_shmem {
-    volatile u32          isr;
-    volatile u32          linkstatus;
-    volatile struct slic_stats     inicstats;
+       volatile u32          isr;
+       volatile u32          linkstatus;
+       volatile struct slic_stats     inicstats;
 };
 
 struct slic_reg_params {
-    u32       linkspeed;
-    u32       linkduplex;
-    u32       fail_on_bad_eeprom;
+       u32       linkspeed;
+       u32       linkduplex;
+       u32       fail_on_bad_eeprom;
 };
 
 struct slic_upr {
-    uint               adapter;
-    u32            upr_request;
-    u32            upr_data;
-    u32            upr_data_h;
-    u32            upr_buffer;
-    u32            upr_buffer_h;
-    struct slic_upr *next;
+       uint               adapter;
+       u32            upr_request;
+       u32            upr_data;
+       u32            upr_data_h;
+       u32            upr_buffer;
+       u32            upr_buffer_h;
+       struct slic_upr *next;
 };
 
 struct slic_ifevents {
-    uint        oflow802;
-    uint        uflow802;
-    uint        Tprtoflow;
-    uint        rcvearly;
-    uint        Bufov;
-    uint        Carre;
-    uint        Longe;
-    uint        Invp;
-    uint        Crc;
-    uint        Drbl;
-    uint        Code;
-    uint        IpHlen;
-    uint        IpLen;
-    uint        IpCsum;
-    uint        TpCsum;
-    uint        TpHlen;
+       uint        oflow802;
+       uint        uflow802;
+       uint        Tprtoflow;
+       uint        rcvearly;
+       uint        Bufov;
+       uint        Carre;
+       uint        Longe;
+       uint        Invp;
+       uint        Crc;
+       uint        Drbl;
+       uint        Code;
+       uint        IpHlen;
+       uint        IpLen;
+       uint        IpCsum;
+       uint        TpCsum;
+       uint        TpHlen;
 };
 
 struct adapter {
-    void *ifp;
-    struct sliccard *card;
-    uint                port;
-    struct physcard *physcard;
-    uint                physport;
-    uint                cardindex;
-    uint                card_size;
-    uint                chipid;
-    struct net_device  *netdev;
-    struct net_device  *next_netdevice;
-    struct slic_spinlock     adapter_lock;
-    struct slic_spinlock     reset_lock;
-    struct pci_dev     *pcidev;
-    uint                busnumber;
-    uint                slotnumber;
-    uint                functionnumber;
-    ushort              vendid;
-    ushort              devid;
-    ushort              subsysid;
-    u32             irq;
-    void __iomem *memorybase;
-    u32             memorylength;
-    u32             drambase;
-    u32             dramlength;
-    uint                queues_initialized;
-    uint                allocated;
-    uint                activated;
-    u32             intrregistered;
-    uint                isp_initialized;
-    uint                gennumber;
-    u32             curaddrupper;
-    struct slic_shmem      *pshmem;
-    dma_addr_t          phys_shmem;
-    u32             isrcopy;
-    __iomem struct slic_regs       *slic_regs;
-    unsigned char               state;
-    unsigned char               linkstate;
-    unsigned char               linkspeed;
-    unsigned char               linkduplex;
-    uint                flags;
-    unsigned char               macaddr[6];
-    unsigned char               currmacaddr[6];
-    u32             macopts;
-    ushort              devflags_prev;
-    u64             mcastmask;
-    struct mcast_address   *mcastaddrs;
-    struct slic_upr   *upr_list;
-    uint                upr_busy;
-    struct timer_list   pingtimer;
-    u32             pingtimerset;
-    struct timer_list   loadtimer;
-    u32             loadtimerset;
-    struct dentry      *debugfs_entry;
-    struct slic_spinlock     upr_lock;
-    struct slic_spinlock     bit64reglock;
-    struct slic_rspqueue     rspqueue;
-    struct slic_rcvqueue     rcvqueue;
-    struct slic_cmdqueue     cmdq_free;
-    struct slic_cmdqueue     cmdq_done;
-    struct slic_cmdqueue     cmdq_all;
-    struct slic_cmdqmem      cmdqmem;
-    /*
-     *  SLIC Handles
-    */
-    struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/
-    struct slic_handle *pfree_slic_handles;          /* Free object handles*/
-    struct slic_spinlock     handle_lock;           /* Object handle list lock*/
-    ushort              slic_handle_ix;
-
-    u32             xmitq_full;
-    u32             all_reg_writes;
-    u32             icr_reg_writes;
-    u32             isr_reg_writes;
-    u32             error_interrupts;
-    u32             error_rmiss_interrupts;
-    u32             rx_errors;
-    u32             rcv_drops;
-    u32             rcv_interrupts;
-    u32             xmit_interrupts;
-    u32             linkevent_interrupts;
-    u32             upr_interrupts;
-    u32             num_isrs;
-    u32             false_interrupts;
-    u32             tx_packets;
-    u32             xmit_completes;
-    u32             tx_drops;
-    u32             rcv_broadcasts;
-    u32             rcv_multicasts;
-    u32             rcv_unicasts;
-    u32             max_isr_rcvs;
-    u32             max_isr_xmits;
-    u32             rcv_interrupt_yields;
-    u32             intagg_period;
-    struct inicpm_state    *inicpm_info;
-    void *pinicpm_info;
-    struct slic_reg_params   reg_params;
-    struct slic_ifevents  if_events;
-    struct slic_stats        inicstats_prev;
-    struct slicnet_stats     slic_stats;
+       void *ifp;
+       struct sliccard *card;
+       uint                port;
+       struct physcard *physcard;
+       uint                physport;
+       uint                cardindex;
+       uint                card_size;
+       uint                chipid;
+       struct net_device  *netdev;
+       struct net_device  *next_netdevice;
+       struct slic_spinlock     adapter_lock;
+       struct slic_spinlock     reset_lock;
+       struct pci_dev     *pcidev;
+       uint                busnumber;
+       uint                slotnumber;
+       uint                functionnumber;
+       ushort              vendid;
+       ushort              devid;
+       ushort              subsysid;
+       u32             irq;
+       void __iomem *memorybase;
+       u32             memorylength;
+       u32             drambase;
+       u32             dramlength;
+       uint                queues_initialized;
+       uint                allocated;
+       uint                activated;
+       u32             intrregistered;
+       uint                isp_initialized;
+       uint                gennumber;
+       u32             curaddrupper;
+       struct slic_shmem      *pshmem;
+       dma_addr_t          phys_shmem;
+       u32             isrcopy;
+       __iomem struct slic_regs       *slic_regs;
+       unsigned char               state;
+       unsigned char               linkstate;
+       unsigned char               linkspeed;
+       unsigned char               linkduplex;
+       uint                flags;
+       unsigned char               macaddr[6];
+       unsigned char               currmacaddr[6];
+       u32             macopts;
+       ushort              devflags_prev;
+       u64             mcastmask;
+       struct mcast_address   *mcastaddrs;
+       struct slic_upr   *upr_list;
+       uint                upr_busy;
+       struct timer_list   pingtimer;
+       u32             pingtimerset;
+       struct timer_list   loadtimer;
+       u32             loadtimerset;
+       struct dentry      *debugfs_entry;
+       struct slic_spinlock     upr_lock;
+       struct slic_spinlock     bit64reglock;
+       struct slic_rspqueue     rspqueue;
+       struct slic_rcvqueue     rcvqueue;
+       struct slic_cmdqueue     cmdq_free;
+       struct slic_cmdqueue     cmdq_done;
+       struct slic_cmdqueue     cmdq_all;
+       struct slic_cmdqmem      cmdqmem;
+       /*
+       *  SLIC Handles
+       */
+       struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/
+       struct slic_handle *pfree_slic_handles;          /* Free object handles*/
+       struct slic_spinlock     handle_lock;           /* Object handle list lock*/
+       ushort              slic_handle_ix;
+
+       u32             xmitq_full;
+       u32             all_reg_writes;
+       u32             icr_reg_writes;
+       u32             isr_reg_writes;
+       u32             error_interrupts;
+       u32             error_rmiss_interrupts;
+       u32             rx_errors;
+       u32             rcv_drops;
+       u32             rcv_interrupts;
+       u32             xmit_interrupts;
+       u32             linkevent_interrupts;
+       u32             upr_interrupts;
+       u32             num_isrs;
+       u32             false_interrupts;
+       u32             tx_packets;
+       u32             xmit_completes;
+       u32             tx_drops;
+       u32             rcv_broadcasts;
+       u32             rcv_multicasts;
+       u32             rcv_unicasts;
+       u32             max_isr_rcvs;
+       u32             max_isr_xmits;
+       u32             rcv_interrupt_yields;
+       u32             intagg_period;
+       struct inicpm_state    *inicpm_info;
+       void *pinicpm_info;
+       struct slic_reg_params   reg_params;
+       struct slic_ifevents  if_events;
+       struct slic_stats        inicstats_prev;
+       struct slicnet_stats     slic_stats;
 };
 
 
 #define UPDATE_STATS(largestat, newstat, oldstat)                        \
 {                                                                        \
-    if ((newstat) < (oldstat))                                           \
-       (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1));         \
-    else                                                                 \
-       (largestat) += ((newstat) - (oldstat));                          \
+       if ((newstat) < (oldstat))                                       \
+               (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \
+       else                                                             \
+               (largestat) += ((newstat) - (oldstat));                  \
 }
 
 #define UPDATE_STATS_GB(largestat, newstat, oldstat)                     \
 {                                                                        \
-    (largestat) += ((newstat) - (oldstat));                              \
+       (largestat) += ((newstat) - (oldstat));                          \
 }
 
 #if BITS_PER_LONG == 64
index 6275d452967640fd701d7b29595bf02069d21ae3..21cd02b8b7ebcadc81e5e6fcffb71672255bb3a9 100644 (file)
@@ -450,7 +450,7 @@ struct slic_regs {
        u32     pad34;
 #define SLIC_DBAR64            0x0108
 
-       u32     slic_cbar64;    /* 64 bit Xmt Cmd buf addr regs. */
+       u32     slic_cbar64;    /* 64 bit Xmt Cmd buf addr regs. */
        u32     pad35;
 #define SLIC_CBAR64            0x0110
 
@@ -478,11 +478,11 @@ struct slic_regs {
 
        u32     slic_read_xf_info;      /* Read Transformer info */
        u32     pad41;
-#define SLIC_READ_XF_INFO      0x0140
+#define SLIC_READ_XF_INFO      0x0140
 
        u32     slic_write_xf_info;     /* Write Transformer info */
        u32     pad42;
-#define SLIC_WRITE_XF_INFO     0x0148
+#define SLIC_WRITE_XF_INFO     0x0148
 
        u32     RSVD1;          /* TOE Only */
        u32     pad43;
index 78578ee59557627a58b5369827b3442ddac3bea6..76fc2e554f3522453c2d1b9a3058a129d8e2f3a0 100644 (file)
@@ -144,24 +144,24 @@ MODULE_DEVICE_TABLE(pci, slic_pci_tbl);
 
 #define SLIC_GET_SLIC_HANDLE(_adapter, _pslic_handle)                   \
 {                                                                       \
-    spin_lock_irqsave(&_adapter->handle_lock.lock,                      \
+       spin_lock_irqsave(&_adapter->handle_lock.lock,                  \
                        _adapter->handle_lock.flags);                   \
-    _pslic_handle  =  _adapter->pfree_slic_handles;                     \
-    if (_pslic_handle) {                                                \
-       _adapter->pfree_slic_handles = _pslic_handle->next;             \
-    }                                                                   \
-    spin_unlock_irqrestore(&_adapter->handle_lock.lock,                 \
+       _pslic_handle  =  _adapter->pfree_slic_handles;                 \
+       if (_pslic_handle) {                                            \
+               _adapter->pfree_slic_handles = _pslic_handle->next;     \
+       }                                                               \
+       spin_unlock_irqrestore(&_adapter->handle_lock.lock,             \
                        _adapter->handle_lock.flags);                   \
 }
 
 #define SLIC_FREE_SLIC_HANDLE(_adapter, _pslic_handle)                  \
 {                                                                       \
-    _pslic_handle->type = SLIC_HANDLE_FREE;                             \
-    spin_lock_irqsave(&_adapter->handle_lock.lock,                      \
+       _pslic_handle->type = SLIC_HANDLE_FREE;                         \
+       spin_lock_irqsave(&_adapter->handle_lock.lock,                  \
                        _adapter->handle_lock.flags);                   \
-    _pslic_handle->next = _adapter->pfree_slic_handles;                 \
-    _adapter->pfree_slic_handles = _pslic_handle;                       \
-    spin_unlock_irqrestore(&_adapter->handle_lock.lock,                 \
+       _pslic_handle->next = _adapter->pfree_slic_handles;             \
+       _adapter->pfree_slic_handles = _pslic_handle;                   \
+       spin_unlock_irqrestore(&_adapter->handle_lock.lock,             \
                        _adapter->handle_lock.flags);                   \
 }
 
@@ -209,7 +209,7 @@ static u32 slic_crc_init;   /* Is table initialized */
  */
 static void slic_mcast_init_crc32(void)
 {
-       u32 c;          /*  CRC shit reg                 */
+       u32 c;                  /*  CRC reg                      */
        u32 e = 0;              /*  Poly X-or pattern            */
        int i;                  /*  counter                      */
        int k;                  /*  byte being shifted into crc  */
@@ -2930,11 +2930,14 @@ static int slic_if_init(struct adapter *adapter)
        }
 
        if (!adapter->queues_initialized) {
-               if ((rc = slic_rspqueue_init(adapter)))
+               rc = slic_rspqueue_init(adapter);
+               if (rc)
                        goto err;
-               if ((rc = slic_cmdq_init(adapter)))
+               rc = slic_cmdq_init(adapter);
+               if (rc)
                        goto err;
-               if ((rc = slic_rcvqueue_init(adapter)))
+               rc = slic_rcvqueue_init(adapter);
+               if (rc)
                        goto err;
                adapter->queues_initialized = 1;
        }
@@ -3437,7 +3440,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
                                               (eecodesize - 2));
                        /*
                            if the ucdoe chksum flag bit worked,
-                           we wouldn't need this shit
+                           we wouldn't need this
                        */
                        if (ee_chksum == calc_chksum)
                                card->config.EepromValid = true;
index d288cf03e14b83bcb1626ab515ab17c69644b036..b416aceb13f2759c64399bec491a0c49e3c9ab23 100644 (file)
@@ -8,7 +8,7 @@ config SPEAKUP
                video console for blind people.  If built in to the
                kernel, it can speak everything on the text console from
                boot up to shutdown.  For more information on Speakup,
-               point your browser at http://www.linux-speakup.org/.
+               point your browser at <http://www.linux-speakup.org/>.
                There is also a mailing list at the above url that you
                can subscribe to.
                
index a2db956edd54db0f81979bd038bcfc5d348a7232..382973e8b80f3e6001963a9ac36d52a77a88edb7 100644 (file)
@@ -5,12 +5,12 @@
 #include "speakup.h"
 #include "spk_priv.h"
 
-#define synthBufferSize 8192   /* currently 8K bytes */
+#define SYNTH_BUF_SIZE 8192    /* currently 8K bytes */
 
-static u_char synth_buffer[synthBufferSize];   /* guess what this is for! */
+static u_char synth_buffer[SYNTH_BUF_SIZE];    /* guess what this is for! */
 static u_char *buff_in = synth_buffer;
 static u_char *buff_out = synth_buffer;
-static u_char *buffer_end = synth_buffer+synthBufferSize-1;
+static u_char *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1;
 
 /* These try to throttle applications by stopping the TTYs
  * Note: we need to make sure that we will restart them eventually, which is
@@ -44,13 +44,13 @@ static void speakup_stop_ttys(void)
 
 static int synth_buffer_free(void)
 {
-       int bytesFree;
+       int bytes_free;
 
        if (buff_in >= buff_out)
-               bytesFree = synthBufferSize - (buff_in - buff_out);
+               bytes_free = SYNTH_BUF_SIZE - (buff_in - buff_out);
        else
-               bytesFree = buff_out - buff_in;
-       return bytesFree;
+               bytes_free = buff_out - buff_in;
+       return bytes_free;
 }
 
 int synth_buffer_empty(void)
index 1b34a87716418b8af6248d0540d9958f2b0cbd2e..4299cf45f947ded9433fa045c1cb54bc957a02c4 100644 (file)
@@ -28,7 +28,7 @@
 #define PRESSED 1
 #define RELEASED 0
 
-DEFINE_PER_CPU(bool, reporting_keystroke);
+static DEFINE_PER_CPU(bool, reporting_keystroke);
 
 static struct input_dev *virt_keyboard;
 
index 7c1658b971dc768958809e347f17b67ba753e428..2add1fcfd122a2ad23440a63fe1c9ef5f4b80bd1 100644 (file)
@@ -390,7 +390,7 @@ static struct msg_group_t all_groups[] = {
 
 static const  int num_groups = sizeof(all_groups) / sizeof(struct msg_group_t);
 
-char *msg_get(enum msg_index_t index)
+char *spk_msg_get(enum msg_index_t index)
 {
        char *ch;
 
@@ -540,7 +540,7 @@ static int fmt_validate(char *template, char *user)
  * -EINVAL -  Invalid format specifiers in formatted message or illegal index.
  * -ENOMEM -  Unable to allocate memory.
 */
-ssize_t msg_set(enum msg_index_t index, char *text, size_t length)
+ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length)
 {
        int rc = 0;
        char *newstr = NULL;
@@ -576,7 +576,7 @@ ssize_t msg_set(enum msg_index_t index, char *text, size_t length)
  * Find a message group, given its name.  Return a pointer to the structure
  * if found, or NULL otherwise.
 */
-struct msg_group_t *find_msg_group(const char *group_name)
+struct msg_group_t *spk_find_msg_group(const char *group_name)
 {
        struct msg_group_t *group = NULL;
        int i;
@@ -590,7 +590,7 @@ struct msg_group_t *find_msg_group(const char *group_name)
        return group;
 }
 
-void reset_msg_group(struct msg_group_t *group)
+void spk_reset_msg_group(struct msg_group_t *group)
 {
        unsigned long flags;
        enum msg_index_t i;
@@ -606,14 +606,14 @@ void reset_msg_group(struct msg_group_t *group)
 }
 
 /* Called at initialization time, to establish default messages. */
-void initialize_msgs(void)
+void spk_initialize_msgs(void)
 {
        memcpy(speakup_msgs, speakup_default_msgs,
                sizeof(speakup_default_msgs));
 }
 
 /* Free user-supplied strings when module is unloaded: */
-void free_user_msgs(void)
+void spk_free_user_msgs(void)
 {
        enum msg_index_t index;
        unsigned long flags;
index 65caa801077691f13ac135a92b33f8f8f06b6f11..dd338f4218de696b999ac34ff528efaa233cf087 100644 (file)
@@ -218,11 +218,11 @@ struct msg_group_t {
        enum msg_index_t end;
 };
 
-extern char *msg_get(enum msg_index_t index);
-extern ssize_t msg_set(enum msg_index_t index, char *text, size_t length);
-extern struct msg_group_t *find_msg_group(const char *group_name);
-extern void reset_msg_group(struct msg_group_t *group);
-extern void initialize_msgs(void);
-extern void free_user_msgs(void);
+extern char *spk_msg_get(enum msg_index_t index);
+extern ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length);
+extern struct msg_group_t *spk_find_msg_group(const char *group_name);
+extern void spk_reset_msg_group(struct msg_group_t *group);
+extern void spk_initialize_msgs(void);
+extern void spk_free_user_msgs(void);
 
 #endif
index 170f38815ffd777d60a3b4ebe552891c53b1b9ee..5091625a4901b94fd87113d6248c34a76152cf4f 100644 (file)
@@ -115,10 +115,11 @@ static void say_key(int key)
        key &= 0xff;
        for (i = 0; i < 6; i++) {
                if (state & masks[i])
-                       synth_printf(" %s", msg_get(MSG_STATES_START + i));
+                       synth_printf(" %s", spk_msg_get(MSG_STATES_START + i));
        }
        if ((key > 0) && (key <= num_key_names))
-               synth_printf(" %s\n", msg_get(MSG_KEYNAMES_START + (key - 1)));
+               synth_printf(" %s\n",
+                               spk_msg_get(MSG_KEYNAMES_START + (key - 1)));
 }
 
 static int help_init(void)
@@ -126,9 +127,9 @@ static int help_init(void)
        char start = SPACE;
        int i;
        int num_funcs = MSG_FUNCNAMES_END - MSG_FUNCNAMES_START + 1;
-state_tbl = our_keys[0]+SHIFT_TBL_SIZE+2;
+state_tbl = spk_our_keys[0]+SHIFT_TBL_SIZE+2;
        for (i = 0; i < num_funcs; i++) {
-               char *cur_funcname = msg_get(MSG_FUNCNAMES_START + i);
+               char *cur_funcname = spk_msg_get(MSG_FUNCNAMES_START + i);
                if (start == *cur_funcname)
                        continue;
                start = *cur_funcname;
@@ -137,7 +138,7 @@ state_tbl = our_keys[0]+SHIFT_TBL_SIZE+2;
        return 0;
 }
 
-int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
+int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
 {
        int i, n;
        char *name;
@@ -147,15 +148,15 @@ int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
                help_init();
        if (type == KT_LATIN) {
                if (ch == SPACE) {
-                       special_handler = NULL;
-                       synth_printf("%s\n", msg_get(MSG_LEAVING_HELP));
+                       spk_special_handler = NULL;
+                       synth_printf("%s\n", spk_msg_get(MSG_LEAVING_HELP));
                        return 1;
                }
                ch |= 32; /* lower case */
                if (ch < 'a' || ch > 'z')
                        return -1;
                if (letter_offsets[ch-'a'] == -1) {
-                       synth_printf(msg_get(MSG_NO_COMMAND), ch);
+                       synth_printf(spk_msg_get(MSG_NO_COMMAND), ch);
                        synth_printf("\n");
                        return 1;
                }
@@ -169,47 +170,49 @@ int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
                        cur_item--;
                else
                        return -1;
-       } else if (type == KT_SPKUP && ch == SPEAKUP_HELP && !special_handler) {
-               special_handler = handle_help;
-               synth_printf("%s\n", msg_get(MSG_HELP_INFO));
+       } else if (type == KT_SPKUP
+                       && ch == SPEAKUP_HELP
+                       && !spk_special_handler) {
+               spk_special_handler = spk_handle_help;
+               synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO));
                build_key_data(); /* rebuild each time in case new mapping */
                return 1;
        } else {
                name = NULL;
                if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) {
                        synth_printf("%s\n",
-                               msg_get(MSG_KEYNAMES_START + key-1));
+                               spk_msg_get(MSG_KEYNAMES_START + key-1));
                        return 1;
                }
                for (i = 0; funcvals[i] != 0 && !name; i++) {
                        if (ch == funcvals[i])
-                               name = msg_get(MSG_FUNCNAMES_START + i);
+                               name = spk_msg_get(MSG_FUNCNAMES_START + i);
                }
                if (!name)
                        return -1;
-               kp = our_keys[key]+1;
+               kp = spk_our_keys[key]+1;
                for (i = 0; i < nstates; i++) {
                        if (ch == kp[i])
                                break;
                }
                key += (state_tbl[i] << 8);
                say_key(key);
-               synth_printf(msg_get(MSG_KEYDESC), name);
+               synth_printf(spk_msg_get(MSG_KEYDESC), name);
                synth_printf("\n");
                return 1;
        }
-       name = msg_get(MSG_FUNCNAMES_START + cur_item);
+       name = spk_msg_get(MSG_FUNCNAMES_START + cur_item);
        func = funcvals[cur_item];
        synth_printf("%s", name);
        if (key_offsets[func] == 0) {
-               synth_printf(" %s\n", msg_get(MSG_IS_UNASSIGNED));
+               synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED));
                return 1;
        }
        p_keys = key_data + key_offsets[func];
        for (n = 0; p_keys[n]; n++) {
                val = p_keys[n];
                if (n > 0)
-                       synth_printf("%s ", msg_get(MSG_DISJUNCTION));
+                       synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION));
                say_key(val);
        }
        return 1;
index 2093896c546bde0f977f6e42a5425fa2f276da4f..35f647ce1f1e476763668dbeadc5936063ad87cf 100644 (file)
@@ -41,7 +41,7 @@ static ssize_t chars_chartab_show(struct kobject *kobj,
                        break;
                if (strcmp("characters", attr->attr.name) == 0) {
                        len = scnprintf(buf_pointer, bufsize, "%d\t%s\n",
-                                       i, characters[i]);
+                                       i, spk_characters[i]);
                } else {        /* show chartab entry */
                        if (IS_TYPE(i, B_CTL))
                                cp = "B_CTL";
@@ -185,12 +185,12 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
                outptr[desc_length] = '\0';
 
                if (do_characters) {
-                       if (characters[index] != default_chars[index])
-                               kfree(characters[index]);
-                       characters[index] = desc;
+                       if (spk_characters[index] != spk_default_chars[index])
+                               kfree(spk_characters[index]);
+                       spk_characters[index] = desc;
                        used++;
                } else {
-                       charclass = chartab_get_value(keyword);
+                       charclass = spk_chartab_get_value(keyword);
                        if (charclass == 0) {
                                rejected++;
                                cp = linefeed + 1;
@@ -206,9 +206,9 @@ static ssize_t chars_chartab_store(struct kobject *kobj,
 
        if (reset) {
                if (do_characters)
-                       reset_default_chars();
+                       spk_reset_default_chars();
                else
-                       reset_default_chartab();
+                       spk_reset_default_chartab();
        }
 
        spk_unlock(flags);
@@ -232,7 +232,7 @@ static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr,
        u_char ch;
        unsigned long flags;
        spk_lock(flags);
-       cp1 = key_buf + SHIFT_TBL_SIZE;
+       cp1 = spk_key_buf + SHIFT_TBL_SIZE;
        num_keys = (int)(*cp1);
        nstates = (int)cp1[1];
        cp += sprintf(cp, "%d, %d, %d,\n", KEY_MAP_VER, num_keys, nstates);
@@ -271,7 +271,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr,
                return -ENOMEM;
        }
        if (strchr("dDrR", *in_buff)) {
-               set_key_info(key_defaults, key_buf);
+               spk_set_key_info(spk_key_defaults, spk_key_buf);
                pr_info("keymap set to default values\n");
                kfree(in_buff);
                spk_unlock(flags);
@@ -282,14 +282,14 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr,
        cp = in_buff;
        cp1 = (u_char *)in_buff;
        for (i = 0; i < 3; i++) {
-               cp = s2uchar(cp, cp1);
+               cp = spk_s2uchar(cp, cp1);
                cp1++;
        }
        i = (int)cp1[-2]+1;
        i *= (int)cp1[-1]+1;
        i += 2; /* 0 and last map ver */
        if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 ||
-                       i+SHIFT_TBL_SIZE+4 >= sizeof(key_buf)) {
+                       i+SHIFT_TBL_SIZE+4 >= sizeof(spk_key_buf)) {
                pr_warn("i %d %d %d %d\n", i,
                                (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]);
                kfree(in_buff);
@@ -297,7 +297,7 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr,
                return -EINVAL;
        }
        while (--i >= 0) {
-               cp = s2uchar(cp, cp1);
+               cp = spk_s2uchar(cp, cp1);
                cp1++;
                if (!(*cp))
                        break;
@@ -307,8 +307,8 @@ static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr,
                pr_warn("end %d %d %d %d\n", i,
                                (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]);
        } else {
-               if (set_key_info(in_buff, key_buf)) {
-                       set_key_info(key_defaults, key_buf);
+               if (spk_set_key_info(in_buff, spk_key_buf)) {
+                       spk_set_key_info(spk_key_defaults, spk_key_buf);
                        ret = -EINVAL;
                        pr_warn("set key failed\n");
                }
@@ -343,7 +343,7 @@ static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr,
        spk_lock(flags);
        if (ch&2) {
                shut = 1;
-               do_flush();
+               spk_do_flush();
        } else {
                shut = 0;
        }
@@ -388,7 +388,7 @@ static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr,
        if (new_synth_name[len - 1] == '\n')
                len--;
        new_synth_name[len] = '\0';
-       strlwr(new_synth_name);
+       spk_strlwr(new_synth_name);
        if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) {
                pr_warn("%s already in use\n", new_synth_name);
        } else if (synth_init(new_synth_name) != 0) {
@@ -417,7 +417,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
                bytes = min_t(size_t, len, 250);
                strncpy(tmp, ptr, bytes);
                tmp[bytes] = '\0';
-               xlate(tmp);
+               spk_xlate(tmp);
                synth_printf("%s", tmp);
                ptr += bytes;
                len -= bytes;
@@ -455,14 +455,14 @@ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr,
        short mask;
        unsigned long flags;
 
-       p_header = var_header_by_name(attr->attr.name);
+       p_header = spk_var_header_by_name(attr->attr.name);
        if (p_header == NULL) {
                pr_warn("p_header is null, attr->attr.name is %s\n",
                        attr->attr.name);
                return -EINVAL;
        }
 
-       var = get_punc_var(p_header->var_id);
+       var = spk_get_punc_var(p_header->var_id);
        if (var == NULL) {
                pr_warn("var is null, p_header->var_id is %i\n",
                                p_header->var_id);
@@ -470,7 +470,7 @@ static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr,
        }
 
        spk_lock(flags);
-       pb = (struct st_bits_data *) &punc_info[var->value];
+       pb = (struct st_bits_data *) &spk_punc_info[var->value];
        mask = pb->mask;
        for (i = 33; i < 128; i++) {
                if (!(spk_chartab[i]&mask))
@@ -497,14 +497,14 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr,
        if (x < 1 || x > 99)
                return -EINVAL;
 
-       p_header = var_header_by_name(attr->attr.name);
+       p_header = spk_var_header_by_name(attr->attr.name);
        if (p_header == NULL) {
                pr_warn("p_header is null, attr->attr.name is %s\n",
                        attr->attr.name);
                return -EINVAL;
        }
 
-       var = get_punc_var(p_header->var_id);
+       var = spk_get_punc_var(p_header->var_id);
        if (var == NULL) {
                pr_warn("var is null, p_header->var_id is %i\n",
                                p_header->var_id);
@@ -520,9 +520,9 @@ static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr,
        spk_lock(flags);
 
        if (*punc_buf == 'd' || *punc_buf == 'r')
-               x = set_mask_bits(0, var->value, 3);
+               x = spk_set_mask_bits(0, var->value, 3);
        else
-               x = set_mask_bits(punc_buf, var->value, 3);
+               x = spk_set_mask_bits(punc_buf, var->value, 3);
 
        spk_unlock(flags);
        return count;
@@ -542,7 +542,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr,
        char ch;
        unsigned long flags;
 
-       param = var_header_by_name(attr->attr.name);
+       param = spk_var_header_by_name(attr->attr.name);
        if (param == NULL)
                return -EINVAL;
 
@@ -599,13 +599,13 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
        int value;
        unsigned long flags;
 
-       param = var_header_by_name(attr->attr.name);
+       param = spk_var_header_by_name(attr->attr.name);
        if (param == NULL)
                return -EINVAL;
        if (param->data == NULL)
                return 0;
        ret = 0;
-       cp = xlate((char *) buf);
+       cp = spk_xlate((char *) buf);
 
        spk_lock(flags);
        switch (param->var_type) {
@@ -618,7 +618,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
                else
                        len = E_SET;
                speakup_s2i(cp, &value);
-               ret = set_num_var(value, param, len);
+               ret = spk_set_num_var(value, param, len);
                if (ret == E_RANGE) {
                        var_data = param->data;
                        pr_warn("value for %s out of range, expect %d to %d\n",
@@ -636,7 +636,7 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
                }
                cp = (char *) buf;
                cp[len] = '\0';
-               ret = set_string_var(buf, param, len);
+               ret = spk_set_string_var(buf, param, len);
                if (ret == E_TOOLONG)
                        pr_warn("value too long for %s\n",
                                        attr->attr.name);
@@ -652,19 +652,19 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
         */
        if (strcmp(attr->attr.name, "voice") == 0) {
                if (synth && synth->default_pitch) {
-                       param = var_header_by_name("pitch");
+                       param = spk_var_header_by_name("pitch");
                        if (param)  {
-                               set_num_var(synth->default_pitch[value], param,
-                                       E_NEW_DEFAULT);
-                               set_num_var(0, param, E_DEFAULT);
+                               spk_set_num_var(synth->default_pitch[value],
+                                               param, E_NEW_DEFAULT);
+                               spk_set_num_var(0, param, E_DEFAULT);
                        }
                }
                if (synth && synth->default_vol) {
-                       param = var_header_by_name("vol");
+                       param = spk_var_header_by_name("vol");
                        if (param)  {
-                               set_num_var(synth->default_vol[value], param,
-                                       E_NEW_DEFAULT);
-                               set_num_var(0, param, E_DEFAULT);
+                               spk_set_num_var(synth->default_vol[value],
+                                               param, E_NEW_DEFAULT);
+                               spk_set_num_var(0, param, E_DEFAULT);
                        }
                }
        }
@@ -694,7 +694,7 @@ static ssize_t message_show_helper(char *buf, enum msg_index_t first,
                if (bufsize <= 1)
                        break;
                printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n",
-                       index, msg_get(cursor));
+                       index, spk_msg_get(cursor));
                buf_pointer += printed;
                bufsize -= printed;
        }
@@ -788,7 +788,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,
                        continue;
                }
 
-               msg_stored = msg_set(curmessage, temp, desc_length);
+               msg_stored = spk_msg_set(curmessage, temp, desc_length);
                if (msg_stored < 0) {
                        retval = msg_stored;
                        if (msg_stored == -ENOMEM)
@@ -802,7 +802,7 @@ static ssize_t message_store_helper(const char *buf, size_t count,
        }
 
        if (reset)
-               reset_msg_group(group);
+               spk_reset_msg_group(group);
 
        report_msg_status(reset, received, used, rejected, group->name);
        return retval;
@@ -812,7 +812,7 @@ static ssize_t message_show(struct kobject *kobj,
        struct kobj_attribute *attr, char *buf)
 {
        ssize_t retval = 0;
-       struct msg_group_t *group = find_msg_group(attr->attr.name);
+       struct msg_group_t *group = spk_find_msg_group(attr->attr.name);
        unsigned long flags;
 
        BUG_ON(!group);
@@ -826,7 +826,7 @@ static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr,
        const char *buf, size_t count)
 {
        ssize_t retval = 0;
-       struct msg_group_t *group = find_msg_group(attr->attr.name);
+       struct msg_group_t *group = spk_find_msg_group(attr->attr.name);
 
        BUG_ON(!group);
        retval = message_store_helper(buf, count, group);
index 40e2488b96791bd35a5da45d93db8b7f9281cefb..9916e94aa3612323f55206cb42c11b75ca56e5df 100644 (file)
@@ -65,23 +65,23 @@ MODULE_VERSION(SPEAKUP_VERSION);
 
 char *synth_name;
 module_param_named(synth, synth_name, charp, S_IRUGO);
-module_param_named(quiet, quiet_boot, bool, S_IRUGO);
+module_param_named(quiet, spk_quiet_boot, bool, S_IRUGO);
 
 MODULE_PARM_DESC(synth, "Synth to start if speakup is built in.");
 MODULE_PARM_DESC(quiet, "Do not announce when the synthesizer is found.");
 
-special_func special_handler;
+special_func spk_special_handler;
 
-short pitch_shift, synth_flags;
+short spk_pitch_shift, synth_flags;
 static char buf[256];
-int attrib_bleep, bleeps, bleep_time = 10;
-int no_intr, spell_delay;
-int key_echo, say_word_ctl;
-int say_ctrl, bell_pos;
-short punc_mask;
-int punc_level, reading_punc;
-char str_caps_start[MAXVARLEN + 1] = "\0", str_caps_stop[MAXVARLEN + 1] = "\0";
-const struct st_bits_data punc_info[] = {
+int spk_attrib_bleep, spk_bleeps, spk_bleep_time = 10;
+int spk_no_intr, spk_spell_delay;
+int spk_key_echo, spk_say_word_ctl;
+int spk_say_ctrl, spk_bell_pos;
+short spk_punc_mask;
+int spk_punc_level, spk_reading_punc;
+char spk_str_caps_start[MAXVARLEN + 1] = "\0", spk_str_caps_stop[MAXVARLEN + 1] = "\0";
+const struct st_bits_data spk_punc_info[] = {
        {"none", "", 0},
        {"some", "/$%&@", SOME},
        {"most", "$%&#()=+*/@^<>|\\", MOST},
@@ -95,9 +95,9 @@ const struct st_bits_data punc_info[] = {
 
 static char mark_cut_flag;
 #define MAX_KEY 160
-u_char *our_keys[MAX_KEY], *shift_table;
-u_char key_buf[600];
-const u_char key_defaults[] = {
+u_char *spk_our_keys[MAX_KEY], *spk_shift_table;
+u_char spk_key_buf[600];
+const u_char spk_key_defaults[] = {
 #include "speakupmap.h"
 };
 
@@ -129,9 +129,9 @@ static char *phonetic[] = {
 /* array of 256 char pointers (one for each character description)
  * initialized to default_chars and user selectable via
  * /proc/speakup/characters */
-char *characters[256];
+char *spk_characters[256];
 
-char *default_chars[256] = {
+char *spk_default_chars[256] = {
 /*000*/ "null", "^a", "^b", "^c", "^d", "^e", "^f", "^g",
 /*008*/ "^h", "^i", "^j", "^k", "^l", "^m", "^n", "^o",
 /*016*/ "^p", "^q", "^r", "^s", "^t", "^u", "^v", "^w",
@@ -238,7 +238,7 @@ static u_short default_chartab[256] = {
 };
 
 struct task_struct *speakup_task;
-struct bleep unprocessed_sound;
+struct bleep spk_unprocessed_sound;
 static int spk_keydown;
 static u_char spk_lastkey, spk_close_press, keymap_flags;
 static u_char last_keycode, this_speakup_key;
@@ -251,14 +251,14 @@ DEFINE_MUTEX(spk_mutex);
 static int keyboard_notifier_call(struct notifier_block *,
                                  unsigned long code, void *param);
 
-struct notifier_block keyboard_notifier_block = {
+static struct notifier_block keyboard_notifier_block = {
        .notifier_call = keyboard_notifier_call,
 };
 
 static int vt_notifier_call(struct notifier_block *,
                            unsigned long code, void *param);
 
-struct notifier_block vt_notifier_block = {
+static struct notifier_block vt_notifier_block = {
        .notifier_call = vt_notifier_call,
 };
 
@@ -282,13 +282,13 @@ static void bleep(u_short val)
                350, 370, 392, 414, 440, 466, 491, 523, 554, 587, 619, 659
        };
        short freq;
-       int time = bleep_time;
+       int time = spk_bleep_time;
        freq = vals[val % 12];
        if (val > 11)
                freq *= (1 << (val / 12));
-       unprocessed_sound.freq = freq;
-       unprocessed_sound.jiffies = msecs_to_jiffies(time);
-       unprocessed_sound.active = 1;
+       spk_unprocessed_sound.freq = freq;
+       spk_unprocessed_sound.jiffies = msecs_to_jiffies(time);
+       spk_unprocessed_sound.active = 1;
        /* We can only have 1 active sound at a time. */
 }
 
@@ -300,7 +300,7 @@ static void speakup_shut_up(struct vc_data *vc)
        spk_parked &= 0xfe;
        speakup_date(vc);
        if (synth != NULL)
-               do_flush();
+               spk_do_flush();
 }
 
 static void speech_kill(struct vc_data *vc)
@@ -313,9 +313,9 @@ static void speech_kill(struct vc_data *vc)
        if (val == 2 || spk_killed) {
                /* dead */
                spk_shut_up &= ~0x40;
-               synth_printf("%s\n", msg_get(MSG_IAM_ALIVE));
+               synth_printf("%s\n", spk_msg_get(MSG_IAM_ALIVE));
        } else {
-               synth_printf("%s\n", msg_get(MSG_YOU_KILLED_SPEAKUP));
+               synth_printf("%s\n", spk_msg_get(MSG_YOU_KILLED_SPEAKUP));
                spk_shut_up |= 0x40;
        }
 }
@@ -324,10 +324,10 @@ static void speakup_off(struct vc_data *vc)
 {
        if (spk_shut_up & 0x80) {
                spk_shut_up &= 0x7f;
-               synth_printf("%s\n", msg_get(MSG_HEY_THATS_BETTER));
+               synth_printf("%s\n", spk_msg_get(MSG_HEY_THATS_BETTER));
        } else {
                spk_shut_up |= 0x80;
-               synth_printf("%s\n", msg_get(MSG_YOU_TURNED_ME_OFF));
+               synth_printf("%s\n", spk_msg_get(MSG_YOU_TURNED_ME_OFF));
        }
        speakup_date(vc);
 }
@@ -336,10 +336,10 @@ static void speakup_parked(struct vc_data *vc)
 {
        if (spk_parked & 0x80) {
                spk_parked = 0;
-               synth_printf("%s\n", msg_get(MSG_UNPARKED));
+               synth_printf("%s\n", spk_msg_get(MSG_UNPARKED));
        } else {
                spk_parked |= 0x80;
-               synth_printf("%s\n", msg_get(MSG_PARKED));
+               synth_printf("%s\n", spk_msg_get(MSG_PARKED));
        }
 }
 
@@ -350,16 +350,16 @@ static void speakup_cut(struct vc_data *vc)
 
        if (!mark_cut_flag) {
                mark_cut_flag = 1;
-               xs = (u_short) spk_x;
-               ys = (u_short) spk_y;
+               spk_xs = (u_short) spk_x;
+               spk_ys = (u_short) spk_y;
                spk_sel_cons = vc;
-               synth_printf("%s\n", msg_get(MSG_MARK));
+               synth_printf("%s\n", spk_msg_get(MSG_MARK));
                return;
        }
-       xe = (u_short) spk_x;
-       ye = (u_short) spk_y;
+       spk_xe = (u_short) spk_x;
+       spk_ye = (u_short) spk_y;
        mark_cut_flag = 0;
-       synth_printf("%s\n", msg_get(MSG_CUT));
+       synth_printf("%s\n", spk_msg_get(MSG_CUT));
 
        speakup_clear_selection();
        ret = speakup_set_selection(tty);
@@ -383,9 +383,9 @@ static void speakup_paste(struct vc_data *vc)
 {
        if (mark_cut_flag) {
                mark_cut_flag = 0;
-               synth_printf("%s\n", msg_get(MSG_MARK_CLEARED));
+               synth_printf("%s\n", spk_msg_get(MSG_MARK_CLEARED));
        } else {
-               synth_printf("%s\n", msg_get(MSG_PASTE));
+               synth_printf("%s\n", spk_msg_get(MSG_PASTE));
                speakup_paste_selection(tty);
        }
 }
@@ -395,16 +395,16 @@ static void say_attributes(struct vc_data *vc)
        int fg = spk_attr & 0x0f;
        int bg = spk_attr >> 4;
        if (fg > 8) {
-               synth_printf("%s ", msg_get(MSG_BRIGHT));
+               synth_printf("%s ", spk_msg_get(MSG_BRIGHT));
                fg -= 8;
        }
-       synth_printf("%s", msg_get(MSG_COLORS_START + fg));
+       synth_printf("%s", spk_msg_get(MSG_COLORS_START + fg));
        if (bg > 7) {
-               synth_printf(" %s ", msg_get(MSG_ON_BLINKING));
+               synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING));
                bg -= 8;
        } else
-               synth_printf(" %s ", msg_get(MSG_ON));
-       synth_printf("%s\n", msg_get(MSG_COLORS_START + bg));
+               synth_printf(" %s ", spk_msg_get(MSG_ON));
+       synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
 enum {
@@ -417,24 +417,24 @@ enum {
 
 static void announce_edge(struct vc_data *vc, int msg_id)
 {
-       if (bleeps & 1)
+       if (spk_bleeps & 1)
                bleep(spk_y);
-       if ((bleeps & 2) && (msg_id < edge_quiet))
-               synth_printf("%s\n", msg_get(MSG_EDGE_MSGS_START + msg_id - 1));
+       if ((spk_bleeps & 2) && (msg_id < edge_quiet))
+               synth_printf("%s\n", spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1));
 }
 
 static void speak_char(u_char ch)
 {
-       char *cp = characters[ch];
-       struct var_t *direct = get_var(DIRECT);
+       char *cp = spk_characters[ch];
+       struct var_t *direct = spk_get_var(DIRECT);
        if (direct && direct->u.n.value) {
                if (IS_CHAR(ch, B_CAP)) {
-                       pitch_shift++;
-                       synth_printf("%s", str_caps_start);
+                       spk_pitch_shift++;
+                       synth_printf("%s", spk_str_caps_start);
                }
                synth_printf("%c", ch);
                if (IS_CHAR(ch, B_CAP))
-                       synth_printf("%s", str_caps_stop);
+                       synth_printf("%s", spk_str_caps_stop);
                return;
        }
        if (cp == NULL) {
@@ -443,13 +443,13 @@ static void speak_char(u_char ch)
        }
        synth_buffer_add(SPACE);
        if (IS_CHAR(ch, B_CAP)) {
-               pitch_shift++;
-               synth_printf("%s", str_caps_start);
+               spk_pitch_shift++;
+               synth_printf("%s", spk_str_caps_start);
                synth_printf("%s", cp);
-               synth_printf("%s", str_caps_stop);
+               synth_printf("%s", spk_str_caps_stop);
        } else {
                if (*cp == '^') {
-                       synth_printf("%s", msg_get(MSG_CTRL));
+                       synth_printf("%s", spk_msg_get(MSG_CTRL));
                        cp++;
                }
                synth_printf("%s", cp);
@@ -479,9 +479,9 @@ static void say_char(struct vc_data *vc)
        spk_old_attr = spk_attr;
        ch = get_char(vc, (u_short *) spk_pos, &spk_attr);
        if (spk_attr != spk_old_attr) {
-               if (attrib_bleep & 1)
+               if (spk_attrib_bleep & 1)
                        bleep(spk_y);
-               if (attrib_bleep & 2)
+               if (spk_attrib_bleep & 2)
                        say_attributes(vc);
        }
        speak_char(ch & 0xff);
@@ -497,7 +497,7 @@ static void say_phonetic_char(struct vc_data *vc)
                synth_printf("%s\n", phonetic[--ch]);
        } else {
                if (IS_CHAR(ch, B_NUM))
-                       synth_printf("%s ", msg_get(MSG_NUMBER));
+                       synth_printf("%s ", spk_msg_get(MSG_NUMBER));
                speak_char(ch);
        }
 }
@@ -527,8 +527,8 @@ static void say_next_char(struct vc_data *vc)
 }
 
 /* get_word - will first check to see if the character under the
- * reading cursor is a space and if say_word_ctl is true it will
- * return the word space.  If say_word_ctl is not set it will check to
+ * reading cursor is a space and if spk_say_word_ctl is true it will
+ * return the word space.  If spk_say_word_ctl is not set it will check to
  * see if there is a word starting on the next position to the right
  * and return that word if it exists.  If it does not exist it will
  * move left to the beginning of any previous word on the line or the
@@ -544,9 +544,9 @@ static u_long get_word(struct vc_data *vc)
        ch = (char)get_char(vc, (u_short *) tmp_pos, &temp);
 
 /* decided to take out the sayword if on a space (mis-information */
-       if (say_word_ctl && ch == SPACE) {
+       if (spk_say_word_ctl && ch == SPACE) {
                *buf = '\0';
-               synth_printf("%s\n", msg_get(MSG_SPACE));
+               synth_printf("%s\n", spk_msg_get(MSG_SPACE));
                return 0;
        } else if ((tmpx < vc->vc_cols - 2)
                   && (ch == SPACE || ch == 0 || IS_WDLM(ch))
@@ -582,13 +582,13 @@ static u_long get_word(struct vc_data *vc)
 static void say_word(struct vc_data *vc)
 {
        u_long cnt = get_word(vc);
-       u_short saved_punc_mask = punc_mask;
+       u_short saved_punc_mask = spk_punc_mask;
        if (cnt == 0)
                return;
-       punc_mask = PUNC;
+       spk_punc_mask = PUNC;
        buf[cnt++] = SPACE;
        spkup_write(buf, cnt);
-       punc_mask = saved_punc_mask;
+       spk_punc_mask = saved_punc_mask;
 }
 
 static void say_prev_word(struct vc_data *vc)
@@ -686,22 +686,22 @@ static void say_next_word(struct vc_data *vc)
 static void spell_word(struct vc_data *vc)
 {
        static char *delay_str[] = { "", ",", ".", ". .", ". . ." };
-       char *cp = buf, *str_cap = str_caps_stop;
-       char *cp1, *last_cap = str_caps_stop;
+       char *cp = buf, *str_cap = spk_str_caps_stop;
+       char *cp1, *last_cap = spk_str_caps_stop;
        u_char ch;
        if (!get_word(vc))
                return;
        while ((ch = (u_char) *cp)) {
                if (cp != buf)
-                       synth_printf(" %s ", delay_str[spell_delay]);
+                       synth_printf(" %s ", delay_str[spk_spell_delay]);
                if (IS_CHAR(ch, B_CAP)) {
-                       str_cap = str_caps_start;
-                       if (*str_caps_stop)
-                               pitch_shift++;
+                       str_cap = spk_str_caps_start;
+                       if (*spk_str_caps_stop)
+                               spk_pitch_shift++;
                        else    /* synth has no pitch */
-                               last_cap = str_caps_stop;
+                               last_cap = spk_str_caps_stop;
                } else
-                       str_cap = str_caps_stop;
+                       str_cap = spk_str_caps_stop;
                if (str_cap != last_cap) {
                        synth_printf("%s", str_cap);
                        last_cap = str_cap;
@@ -711,17 +711,17 @@ static void spell_word(struct vc_data *vc)
                        ch &= 31;
                        cp1 = phonetic[--ch];
                } else {
-                       cp1 = characters[ch];
+                       cp1 = spk_characters[ch];
                        if (*cp1 == '^') {
-                               synth_printf("%s", msg_get(MSG_CTRL));
+                               synth_printf("%s", spk_msg_get(MSG_CTRL));
                                cp1++;
                        }
                }
                synth_printf("%s", cp1);
                cp++;
        }
-       if (str_cap != str_caps_stop)
-               synth_printf("%s", str_caps_stop);
+       if (str_cap != spk_str_caps_stop)
+               synth_printf("%s", spk_str_caps_stop);
 }
 
 static int get_line(struct vc_data *vc)
@@ -746,9 +746,9 @@ static void say_line(struct vc_data *vc)
 {
        int i = get_line(vc);
        char *cp;
-       u_short saved_punc_mask = punc_mask;
+       u_short saved_punc_mask = spk_punc_mask;
        if (i == 0) {
-               synth_printf("%s\n", msg_get(MSG_BLANK));
+               synth_printf("%s\n", spk_msg_get(MSG_BLANK));
                return;
        }
        buf[i++] = '\n';
@@ -758,9 +758,9 @@ static void say_line(struct vc_data *vc)
                        cp++;
                synth_printf("%d, ", (cp - buf) + 1);
        }
-       punc_mask = punc_masks[reading_punc];
+       spk_punc_mask = spk_punc_masks[spk_reading_punc];
        spkup_write(buf, i);
-       punc_mask = saved_punc_mask;
+       spk_punc_mask = saved_punc_mask;
 }
 
 static void say_prev_line(struct vc_data *vc)
@@ -792,7 +792,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to,
 {
        int i = 0;
        u_char tmp;
-       u_short saved_punc_mask = punc_mask;
+       u_short saved_punc_mask = spk_punc_mask;
        spk_old_attr = spk_attr;
        spk_attr = get_attributes((u_short *) from);
        while (from < to) {
@@ -809,10 +809,10 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to,
        if (i < 1)
                return i;
        if (read_punc)
-               punc_mask = punc_info[reading_punc].mask;
+               spk_punc_mask = spk_punc_info[spk_reading_punc].mask;
        spkup_write(buf, i);
        if (read_punc)
-               punc_mask = saved_punc_mask;
+               spk_punc_mask = saved_punc_mask;
        return i - 1;
 }
 
@@ -824,7 +824,7 @@ static void say_line_from_to(struct vc_data *vc, u_long from, u_long to,
        start += from * 2;
        if (say_from_to(vc, start, end, read_punc) <= 0)
                if (cursor_track != read_all_mode)
-                       synth_printf("%s\n", msg_get(MSG_BLANK));
+                       synth_printf("%s\n", spk_msg_get(MSG_BLANK));
 }
 
 /* Sentence Reading Commands */
@@ -924,7 +924,7 @@ static void speakup_win_say(struct vc_data *vc)
 {
        u_long start, end, from, to;
        if (win_start < 2) {
-               synth_printf("%s\n", msg_get(MSG_NO_WINDOW));
+               synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW));
                return;
        }
        start = vc->vc_origin + (win_top * vc->vc_size_row);
@@ -975,7 +975,7 @@ static void say_first_char(struct vc_data *vc)
        u_char ch;
        spk_parked |= 0x01;
        if (len == 0) {
-               synth_printf("%s\n", msg_get(MSG_BLANK));
+               synth_printf("%s\n", spk_msg_get(MSG_BLANK));
                return;
        }
        for (i = 0; i < len; i++)
@@ -994,7 +994,7 @@ static void say_last_char(struct vc_data *vc)
        u_char ch;
        spk_parked |= 0x01;
        if (len == 0) {
-               synth_printf("%s\n", msg_get(MSG_BLANK));
+               synth_printf("%s\n", spk_msg_get(MSG_BLANK));
                return;
        }
        ch = buf[--len];
@@ -1006,7 +1006,7 @@ static void say_last_char(struct vc_data *vc)
 
 static void say_position(struct vc_data *vc)
 {
-       synth_printf(msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1,
+       synth_printf(spk_msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1,
                     vc->vc_num + 1);
        synth_printf("\n");
 }
@@ -1017,7 +1017,7 @@ static void say_char_num(struct vc_data *vc)
        u_char tmp;
        u_short ch = get_char(vc, (u_short *) spk_pos, &tmp);
        ch &= 0xff;
-       synth_printf(msg_get(MSG_CHAR_INFO), ch, ch);
+       synth_printf(spk_msg_get(MSG_CHAR_INFO), ch, ch);
 }
 
 /* these are stub functions to keep keyboard.c happy. */
@@ -1066,7 +1066,7 @@ static void spkup_write(const char *in_buf, int count)
                } else {
                        if ((last_type & CH_RPT) && rep_count > 2) {
                                synth_printf(" ");
-                               synth_printf(msg_get(MSG_REPEAT_DESC),
+                               synth_printf(spk_msg_get(MSG_REPEAT_DESC),
                                             ++rep_count);
                                synth_printf(" ");
                        }
@@ -1074,7 +1074,7 @@ static void spkup_write(const char *in_buf, int count)
                }
                if (ch == spk_lastkey) {
                        rep_count = 0;
-                       if (key_echo == 1 && ch >= MINECHOCHAR)
+                       if (spk_key_echo == 1 && ch >= MINECHOCHAR)
                                speak_char(ch);
                } else if (char_type & B_ALPHA) {
                        if ((synth_flags & SF_DEC) && (last_type & PUNC))
@@ -1083,7 +1083,7 @@ static void spkup_write(const char *in_buf, int count)
                } else if (char_type & B_NUM) {
                        rep_count = 0;
                        synth_printf("%c", ch);
-               } else if (char_type & punc_mask) {
+               } else if (char_type & spk_punc_mask) {
                        speak_char(ch);
                        char_type &= ~PUNC;     /* for dec nospell processing */
                } else if (char_type & SYNTH_OK) {
@@ -1111,7 +1111,7 @@ static void spkup_write(const char *in_buf, int count)
        if (in_count > 2 && rep_count > 2) {
                if (last_type & CH_RPT) {
                        synth_printf(" ");
-                       synth_printf(msg_get(MSG_REPEAT_DESC2), ++rep_count);
+                       synth_printf(spk_msg_get(MSG_REPEAT_DESC2), ++rep_count);
                        synth_printf(" ");
                }
                rep_count = 0;
@@ -1135,22 +1135,22 @@ static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag)
                case KVAL(K_SHIFT):
                        del_timer(&cursor_timer);
                        spk_shut_up &= 0xfe;
-                       do_flush();
+                       spk_do_flush();
                        read_all_doc(vc);
                        break;
                case KVAL(K_CTRL):
                        del_timer(&cursor_timer);
                        cursor_track = prev_cursor_track;
                        spk_shut_up &= 0xfe;
-                       do_flush();
+                       spk_do_flush();
                        break;
                }
        } else {
                spk_shut_up &= 0xfe;
-               do_flush();
+               spk_do_flush();
        }
-       if (say_ctrl && value < NUM_CTL_LABELS)
-               synth_printf("%s", msg_get(MSG_CTL_START + value));
+       if (spk_say_ctrl && value < NUM_CTL_LABELS)
+               synth_printf("%s", spk_msg_get(MSG_CTL_START + value));
        spk_unlock(flags);
 }
 
@@ -1171,12 +1171,12 @@ static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag)
        spk_lastkey = value;
        spk_keydown++;
        spk_parked &= 0xfe;
-       if (key_echo == 2 && value >= MINECHOCHAR)
+       if (spk_key_echo == 2 && value >= MINECHOCHAR)
                speak_char(value);
        spk_unlock(flags);
 }
 
-int set_key_info(const u_char *key_info, u_char *k_buffer)
+int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
 {
        int i = 0, states, key_data_len;
        const u_char *cp = key_info;
@@ -1188,12 +1188,12 @@ int set_key_info(const u_char *key_info, u_char *k_buffer)
        num_keys = *cp;
        states = (int)cp[1];
        key_data_len = (states + 1) * (num_keys + 1);
-       if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(key_buf))
+       if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf))
                return -2;
        memset(k_buffer, 0, SHIFT_TBL_SIZE);
-       memset(our_keys, 0, sizeof(our_keys));
-       shift_table = k_buffer;
-       our_keys[0] = shift_table;
+       memset(spk_our_keys, 0, sizeof(spk_our_keys));
+       spk_shift_table = k_buffer;
+       spk_our_keys[0] = spk_shift_table;
        cp1 += SHIFT_TBL_SIZE;
        memcpy(cp1, cp, key_data_len + 3);
        /* get num_keys, states and data */
@@ -1202,13 +1202,13 @@ int set_key_info(const u_char *key_info, u_char *k_buffer)
                ch = *cp1++;
                if (ch >= SHIFT_TBL_SIZE)
                        return -3;
-               shift_table[ch] = i;
+               spk_shift_table[ch] = i;
        }
        keymap_flags = *cp1++;
        while ((ch = *cp1)) {
                if (ch >= MAX_KEY)
                        return -4;
-               our_keys[ch] = cp1;
+               spk_our_keys[ch] = cp1;
                cp1 += states + 1;
        }
        return 0;
@@ -1237,24 +1237,24 @@ static void toggle_cursoring(struct vc_data *vc)
                cursor_track = prev_cursor_track;
        if (++cursor_track >= CT_Max)
                cursor_track = 0;
-       synth_printf("%s\n", msg_get(MSG_CURSOR_MSGS_START + cursor_track));
+       synth_printf("%s\n", spk_msg_get(MSG_CURSOR_MSGS_START + cursor_track));
 }
 
-void reset_default_chars(void)
+void spk_reset_default_chars(void)
 {
        int i;
 
        /* First, free any non-default */
        for (i = 0; i < 256; i++) {
-               if ((characters[i] != NULL)
-                   && (characters[i] != default_chars[i]))
-                       kfree(characters[i]);
+               if ((spk_characters[i] != NULL)
+                   && (spk_characters[i] != spk_default_chars[i]))
+                       kfree(spk_characters[i]);
        }
 
-       memcpy(characters, default_chars, sizeof(default_chars));
+       memcpy(spk_characters, spk_default_chars, sizeof(spk_default_chars));
 }
 
-void reset_default_chartab(void)
+void spk_reset_default_chartab(void)
 {
        memcpy(spk_chartab, default_chartab, sizeof(default_chartab));
 }
@@ -1267,8 +1267,8 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key)
        if (type != KT_LATIN || (ch_type & B_NUM) || ch < SPACE)
                return -1;
        if (ch == SPACE) {
-               synth_printf("%s\n", msg_get(MSG_EDIT_DONE));
-               special_handler = NULL;
+               synth_printf("%s\n", spk_msg_get(MSG_EDIT_DONE));
+               spk_special_handler = NULL;
                return 1;
        }
        if (mask < PUNC && !(ch_type & PUNC))
@@ -1276,8 +1276,8 @@ static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key)
        spk_chartab[ch] ^= mask;
        speak_char(ch);
        synth_printf(" %s\n",
-                    (spk_chartab[ch] & mask) ? msg_get(MSG_ON) :
-                    msg_get(MSG_OFF));
+                    (spk_chartab[ch] & mask) ? spk_msg_get(MSG_ON) :
+                    spk_msg_get(MSG_OFF));
        return 1;
 }
 
@@ -1346,7 +1346,7 @@ static void read_all_doc(struct vc_data *vc)
        if (cursor_track != read_all_mode)
                prev_cursor_track = cursor_track;
        cursor_track = read_all_mode;
-       reset_index_count(0);
+       spk_reset_index_count(0);
        if (get_sentence_buf(vc, 0) == -1)
                kbd_fakekey2(vc, RA_DOWN_ARROW);
        else {
@@ -1361,7 +1361,7 @@ static void stop_read_all(struct vc_data *vc)
        del_timer(&cursor_timer);
        cursor_track = prev_cursor_track;
        spk_shut_up &= 0xfe;
-       do_flush();
+       spk_do_flush();
 }
 
 static void start_read_all_timer(struct vc_data *vc, int command)
@@ -1370,7 +1370,7 @@ static void start_read_all_timer(struct vc_data *vc, int command)
 
        cursor_con = vc->vc_num;
        read_all_key = command;
-       cursor_timeout = get_var(CURSOR_TIME);
+       cursor_timeout = spk_get_var(CURSOR_TIME);
        mod_timer(&cursor_timer,
                  jiffies + msecs_to_jiffies(cursor_timeout->u.n.value));
 }
@@ -1382,9 +1382,9 @@ static void handle_cursor_read_all(struct vc_data *vc, int command)
        switch (command) {
        case RA_NEXT_SENT:
                /* Get Current Sentence */
-               get_index_count(&indcount, &sentcount);
+               spk_get_index_count(&indcount, &sentcount);
                /*printk("%d %d  ", indcount, sentcount); */
-               reset_index_count(sentcount + 1);
+               spk_reset_index_count(sentcount + 1);
                if (indcount == 1) {
                        if (!say_sentence_num(sentcount + 1, 0)) {
                                kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
@@ -1395,7 +1395,7 @@ static void handle_cursor_read_all(struct vc_data *vc, int command)
                        sn = 0;
                        if (!say_sentence_num(sentcount + 1, 1)) {
                                sn = 1;
-                               reset_index_count(sn);
+                               spk_reset_index_count(sn);
                        } else
                                synth_insert_next_index(0);
                        if (!say_sentence_num(sn, 0)) {
@@ -1437,7 +1437,7 @@ static void handle_cursor_read_all(struct vc_data *vc, int command)
        case RA_FIND_PREV_SENT:
                break;
        case RA_TIMER:
-               get_index_count(&indcount, &sentcount);
+               spk_get_index_count(&indcount, &sentcount);
                if (indcount < 2)
                        kbd_fakekey2(vc, RA_DOWN_ARROW);
                else
@@ -1458,7 +1458,7 @@ static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
                }
                del_timer(&cursor_timer);
                spk_shut_up &= 0xfe;
-               do_flush();
+               spk_do_flush();
                start_read_all_timer(vc, value + 1);
                spk_unlock(flags);
                return NOTIFY_STOP;
@@ -1479,8 +1479,8 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
                return;
        }
        spk_shut_up &= 0xfe;
-       if (no_intr)
-               do_flush();
+       if (spk_no_intr)
+               spk_do_flush();
 /* the key press flushes if !no_inter but we want to flush on cursor
  * moves regardless of no_inter state */
        is_cursor = value + 1;
@@ -1491,7 +1491,7 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
        cursor_con = vc->vc_num;
        if (cursor_track == CT_Highlight)
                reset_highlight_buffers(vc);
-       cursor_timeout = get_var(CURSOR_TIME);
+       cursor_timeout = spk_get_var(CURSOR_TIME);
        mod_timer(&cursor_timer,
                  jiffies + msecs_to_jiffies(cursor_timeout->u.n.value));
        spk_unlock(flags);
@@ -1603,7 +1603,7 @@ static int speak_highlight(struct vc_data *vc)
                        if (speakup_console[vc_num]->ht.ry[hc] != vc->vc_y)
                                return 0;
                spk_parked |= 0x01;
-               do_flush();
+               spk_do_flush();
                spkup_write(speakup_console[vc_num]->ht.highbuf[hc],
                            speakup_console[vc_num]->ht.highsize[hc]);
                spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc];
@@ -1685,7 +1685,7 @@ static void speakup_con_write(struct vc_data *vc, const char *str, int len)
        if (!spk_trylock(flags))
                /* Speakup output, discard */
                return;
-       if (bell_pos && spk_keydown && (vc->vc_x == bell_pos - 1))
+       if (spk_bell_pos && spk_keydown && (vc->vc_x == spk_bell_pos - 1))
                bleep(3);
        if ((is_cursor) || (cursor_track == read_all_mode)) {
                if (cursor_track == CT_Highlight)
@@ -1726,19 +1726,19 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag)
                return;
        spk_lock(flags);
        spk_shut_up &= 0xfe;
-       if (no_intr)
-               do_flush();
+       if (spk_no_intr)
+               spk_do_flush();
        switch (value) {
        case KVAL(K_CAPS):
-               label = msg_get(MSG_KEYNAME_CAPSLOCK);
+               label = spk_msg_get(MSG_KEYNAME_CAPSLOCK);
                on_off = vt_get_leds(fg_console, VC_CAPSLOCK);
                break;
        case KVAL(K_NUM):
-               label = msg_get(MSG_KEYNAME_NUMLOCK);
+               label = spk_msg_get(MSG_KEYNAME_NUMLOCK);
                on_off = vt_get_leds(fg_console, VC_NUMLOCK);
                break;
        case KVAL(K_HOLD):
-               label = msg_get(MSG_KEYNAME_SCROLLLOCK);
+               label = spk_msg_get(MSG_KEYNAME_SCROLLLOCK);
                on_off = vt_get_leds(fg_console, VC_SCROLLOCK);
                if (speakup_console[vc->vc_num])
                        speakup_console[vc->vc_num]->tty_stopped = on_off;
@@ -1750,7 +1750,7 @@ static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag)
        }
        if (on_off < 2)
                synth_printf("%s %s\n",
-                            label, msg_get(MSG_STATUS_START + on_off));
+                            label, spk_msg_get(MSG_STATUS_START + on_off));
        spk_unlock(flags);
 }
 
@@ -1764,13 +1764,13 @@ static int inc_dec_var(u_char value)
        int var_id = (int)value - VAR_START;
        int how = (var_id & 1) ? E_INC : E_DEC;
        var_id = var_id / 2 + FIRST_SET_VAR;
-       p_header = get_var_header(var_id);
+       p_header = spk_get_var_header(var_id);
        if (p_header == NULL)
                return -1;
        if (p_header->var_type != VAR_NUM)
                return -1;
        var_data = p_header->data;
-       if (set_num_var(1, p_header, how) != 0)
+       if (spk_set_num_var(1, p_header, how) != 0)
                return -1;
        if (!spk_close_press) {
                for (pn = p_header->name; *pn; pn++) {
@@ -1790,18 +1790,18 @@ static void speakup_win_set(struct vc_data *vc)
 {
        char info[40];
        if (win_start > 1) {
-               synth_printf("%s\n", msg_get(MSG_WINDOW_ALREADY_SET));
+               synth_printf("%s\n", spk_msg_get(MSG_WINDOW_ALREADY_SET));
                return;
        }
        if (spk_x < win_left || spk_y < win_top) {
-               synth_printf("%s\n", msg_get(MSG_END_BEFORE_START));
+               synth_printf("%s\n", spk_msg_get(MSG_END_BEFORE_START));
                return;
        }
        if (win_start && spk_x == win_left && spk_y == win_top) {
                win_left = 0;
                win_right = vc->vc_cols - 1;
                win_bottom = spk_y;
-               snprintf(info, sizeof(info), msg_get(MSG_WINDOW_LINE),
+               snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_LINE),
                         (int)win_top + 1);
        } else {
                if (!win_start) {
@@ -1811,8 +1811,8 @@ static void speakup_win_set(struct vc_data *vc)
                        win_bottom = spk_y;
                        win_right = spk_x;
                }
-               snprintf(info, sizeof(info), msg_get(MSG_WINDOW_BOUNDARY),
-                        (win_start) ? msg_get(MSG_END) : msg_get(MSG_START),
+               snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_BOUNDARY),
+                        (win_start) ? spk_msg_get(MSG_END) : spk_msg_get(MSG_START),
                         (int)spk_y + 1, (int)spk_x + 1);
        }
        synth_printf("%s\n", info);
@@ -1824,32 +1824,32 @@ static void speakup_win_clear(struct vc_data *vc)
        win_top = win_bottom = 0;
        win_left = win_right = 0;
        win_start = 0;
-       synth_printf("%s\n", msg_get(MSG_WINDOW_CLEARED));
+       synth_printf("%s\n", spk_msg_get(MSG_WINDOW_CLEARED));
 }
 
 static void speakup_win_enable(struct vc_data *vc)
 {
        if (win_start < 2) {
-               synth_printf("%s\n", msg_get(MSG_NO_WINDOW));
+               synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW));
                return;
        }
        win_enabled ^= 1;
        if (win_enabled)
-               synth_printf("%s\n", msg_get(MSG_WINDOW_SILENCED));
+               synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCED));
        else
-               synth_printf("%s\n", msg_get(MSG_WINDOW_SILENCE_DISABLED));
+               synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCE_DISABLED));
 }
 
 static void speakup_bits(struct vc_data *vc)
 {
        int val = this_speakup_key - (FIRST_EDIT_BITS - 1);
-       if (special_handler != NULL || val < 1 || val > 6) {
-               synth_printf("%s\n", msg_get(MSG_ERROR));
+       if (spk_special_handler != NULL || val < 1 || val > 6) {
+               synth_printf("%s\n", spk_msg_get(MSG_ERROR));
                return;
        }
-       pb_edit = &punc_info[val];
-       synth_printf(msg_get(MSG_EDIT_PROMPT), pb_edit->name);
-       special_handler = edit_bits;
+       pb_edit = &spk_punc_info[val];
+       synth_printf(spk_msg_get(MSG_EDIT_PROMPT), pb_edit->name);
+       spk_special_handler = edit_bits;
 }
 
 static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key)
@@ -1887,9 +1887,9 @@ static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key)
        if (ch < 'x' || ch > 'y') {
 oops:
                if (!spk_killed)
-                       synth_printf(" %s\n", msg_get(MSG_GOTO_CANCELED));
+                       synth_printf(" %s\n", spk_msg_get(MSG_GOTO_CANCELED));
                goto_buf[num = 0] = '\0';
-               special_handler = NULL;
+               spk_special_handler = NULL;
                return 1;
        }
        cp = speakup_s2i(goto_buf, &go_pos);
@@ -1917,7 +1917,7 @@ oops:
        }
        goto_buf[num = 0] = '\0';
 do_goto:
-       special_handler = NULL;
+       spk_special_handler = NULL;
        spk_parked |= 0x01;
        if (goto_x) {
                spk_pos -= spk_x * 2;
@@ -1934,18 +1934,18 @@ do_goto:
 
 static void speakup_goto(struct vc_data *vc)
 {
-       if (special_handler != NULL) {
-               synth_printf("%s\n", msg_get(MSG_ERROR));
+       if (spk_special_handler != NULL) {
+               synth_printf("%s\n", spk_msg_get(MSG_ERROR));
                return;
        }
-       synth_printf("%s\n", msg_get(MSG_GOTO));
-       special_handler = handle_goto;
+       synth_printf("%s\n", spk_msg_get(MSG_GOTO));
+       spk_special_handler = handle_goto;
        return;
 }
 
 static void speakup_help(struct vc_data *vc)
 {
-       handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0);
+       spk_handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0);
 }
 
 static void do_nothing(struct vc_data *vc)
@@ -1992,7 +1992,7 @@ static void do_spkup(struct vc_data *vc, u_char value)
        spk_shut_up &= 0xfe;
        this_speakup_key = value;
        if (value < SPKUP_MAX_FUNC && spkup_handler[value]) {
-               do_flush();
+               spk_do_flush();
                (*spkup_handler[value]) (vc);
        } else {
                if (inc_dec_var(value) < 0)
@@ -2032,7 +2032,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
        }
        if (keycode >= MAX_KEY)
                goto no_map;
-       key_info = our_keys[keycode];
+       key_info = spk_our_keys[keycode];
        if (key_info == 0)
                goto no_map;
        /* Check valid read all mode keys */
@@ -2051,7 +2051,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
                }
        }
        shift_info = (shift_state & 0x0f) + key_speakup;
-       offset = shift_table[shift_info];
+       offset = spk_shift_table[shift_info];
        if (offset) {
                new_key = key_info[offset];
                if (new_key) {
@@ -2062,7 +2062,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
                                if (up_flag || spk_killed)
                                        goto out;
                                spk_shut_up &= 0xfe;
-                               do_flush();
+                               spk_do_flush();
                                goto out;
                        }
                        if (up_flag)
@@ -2070,7 +2070,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
                        if (last_keycode == keycode &&
                            last_spk_jiffy + MAX_DELAY > jiffies) {
                                spk_close_press = 1;
-                               offset = shift_table[shift_info + 32];
+                               offset = spk_shift_table[shift_info + 32];
                                /* double press? */
                                if (offset && key_info[offset])
                                        new_key = key_info[offset];
@@ -2082,7 +2082,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym,
                }
        }
 no_map:
-       if (type == KT_SPKUP && special_handler == NULL) {
+       if (type == KT_SPKUP && spk_special_handler == NULL) {
                do_spkup(vc, new_key);
                spk_close_press = 0;
                ret = 1;
@@ -2096,9 +2096,9 @@ no_map:
            || (value == KVAL(K_LEFT))
            || (value == KVAL(K_RIGHT));
        if ((cursor_track != read_all_mode) || !kh)
-               if (!no_intr)
-                       do_flush();
-       if (special_handler) {
+               if (!spk_no_intr)
+                       spk_do_flush();
+       if (spk_special_handler) {
                if (type == KT_SPEC && value == 1) {
                        value = '\n';
                        type = KT_LATIN;
@@ -2106,7 +2106,7 @@ no_map:
                        type = KT_LATIN;
                else if (value == 0x7f)
                        value = 8;      /* make del = backspace */
-               ret = (*special_handler) (vc, type, value, keycode);
+               ret = (*spk_special_handler) (vc, type, value, keycode);
                spk_close_press = 0;
                if (ret < 0)
                        bleep(9);
@@ -2237,11 +2237,11 @@ static void __exit speakup_exit(void)
                speakup_unregister_var(i);
 
        for (i = 0; i < 256; i++) {
-               if (characters[i] != default_chars[i])
-                       kfree(characters[i]);
+               if (spk_characters[i] != spk_default_chars[i])
+                       kfree(spk_characters[i]);
        }
 
-       free_user_msgs();
+       spk_free_user_msgs();
 }
 
 /* call by: module_init() */
@@ -2254,20 +2254,20 @@ static int __init speakup_init(void)
        struct var_t *var;
 
        /* These first few initializations cannot fail. */
-       initialize_msgs();      /* Initialize arrays for i18n. */
-       reset_default_chars();
-       reset_default_chartab();
-       strlwr(synth_name);
+       spk_initialize_msgs();  /* Initialize arrays for i18n. */
+       spk_reset_default_chars();
+       spk_reset_default_chartab();
+       spk_strlwr(synth_name);
        spk_vars[0].u.n.high = vc->vc_cols;
        for (var = spk_vars; var->var_id != MAXVARS; var++)
                speakup_register_var(var);
        for (var = synth_time_vars;
             (var->var_id >= 0) && (var->var_id < MAXVARS); var++)
                speakup_register_var(var);
-       for (i = 1; punc_info[i].mask != 0; i++)
-               set_mask_bits(0, i, 2);
+       for (i = 1; spk_punc_info[i].mask != 0; i++)
+               spk_set_mask_bits(0, i, 2);
 
-       set_key_info(key_defaults, key_buf);
+       spk_set_key_info(spk_key_defaults, spk_key_buf);
 
        /* From here on out, initializations can fail. */
        err = speakup_add_virtual_keyboard();
@@ -2290,7 +2290,7 @@ static int __init speakup_init(void)
                                goto error_kobjects;
                }
 
-       if (quiet_boot)
+       if (spk_quiet_boot)
                spk_shut_up |= 0x01;
 
        err = speakup_kobj_init();
@@ -2352,11 +2352,11 @@ error_virtkeyboard:
                speakup_unregister_var(i);
 
        for (i = 0; i < 256; i++) {
-               if (characters[i] != default_chars[i])
-                       kfree(characters[i]);
+               if (spk_characters[i] != spk_default_chars[i])
+                       kfree(spk_characters[i]);
        }
 
-       free_user_msgs();
+       spk_free_user_msgs();
 
 out:
        return err;
index 0612df06a4bfd08d05499539d5adaa24853a51ad..d6558faea3e037ab94033b6fb723ff35f947c156 100644 (file)
@@ -10,7 +10,7 @@
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define ishardspace(c)      ((c) == ' ')
 
-unsigned short xs, ys, xe, ye; /* our region points */
+unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */
 
 /* Variables for selection control. */
 /* must not be disallocated */
@@ -51,12 +51,12 @@ int speakup_set_selection(struct tty_struct *tty)
        int i, ps, pe;
        struct vc_data *vc = vc_cons[fg_console].d;
 
-       xs = limit(xs, vc->vc_cols - 1);
-       ys = limit(ys, vc->vc_rows - 1);
-       xe = limit(xe, vc->vc_cols - 1);
-       ye = limit(ye, vc->vc_rows - 1);
-       ps = ys * vc->vc_size_row + (xs << 1);
-       pe = ye * vc->vc_size_row + (xe << 1);
+       spk_xs = limit(spk_xs, vc->vc_cols - 1);
+       spk_ys = limit(spk_ys, vc->vc_rows - 1);
+       spk_xe = limit(spk_xe, vc->vc_cols - 1);
+       spk_ye = limit(spk_ye, vc->vc_rows - 1);
+       ps = spk_ys * vc->vc_size_row + (spk_xs << 1);
+       pe = spk_ye * vc->vc_size_row + (spk_xe << 1);
 
        if (ps > pe) {
                /* make sel_start <= sel_end */
index a97d3d5b58a48f9665625518b8d4b27b5ab782a0..e4d27aa2898f451fa7f5c2e7e8a7b808e3d0cc07 100644 (file)
@@ -116,7 +116,7 @@ static void start_serial_interrupt(int irq)
        outb(1, speakup_info.port_tts + UART_FCR);      /* Turn FIFO On */
 }
 
-void stop_serial_interrupt(void)
+void spk_stop_serial_interrupt(void)
 {
        if (speakup_info.port_tts == 0)
                return;
@@ -130,7 +130,7 @@ void stop_serial_interrupt(void)
        free_irq(serstate->irq, (void *) synth_readbuf_handler);
 }
 
-int wait_for_xmitr(void)
+int spk_wait_for_xmitr(void)
 {
        int tmout = SPK_XMITR_TIMEOUT;
        if ((synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) {
@@ -195,7 +195,7 @@ EXPORT_SYMBOL_GPL(spk_serial_in_nowait);
 
 int spk_serial_out(const char ch)
 {
-       if (synth->alive && wait_for_xmitr()) {
+       if (synth->alive && spk_wait_for_xmitr()) {
                outb_p(ch, speakup_info.port_tts);
                return 1;
        }
index e66579e6147a5faa063ca0b0d74204b20e7de2a0..22f0fbb85f42da201c47a70040808278ecff7779 100644 (file)
 #define E_UNDEF -1
 
 extern int speakup_thread(void *data);
-extern void reset_default_chars(void);
-extern void reset_default_chartab(void);
+extern void spk_reset_default_chars(void);
+extern void spk_reset_default_chartab(void);
 extern void synth_start(void);
 void synth_insert_next_index(int sent_num);
-void reset_index_count(int sc);
-void get_index_count(int *linecount, int *sentcount);
-extern int set_key_info(const u_char *key_info, u_char *k_buffer);
-extern char *strlwr(char *s);
+void spk_reset_index_count(int sc);
+void spk_get_index_count(int *linecount, int *sentcount);
+extern int spk_set_key_info(const u_char *key_info, u_char *k_buffer);
+extern char *spk_strlwr(char *s);
 extern char *speakup_s2i(char *start, int *dest);
-extern char *s2uchar(char *start, char *dest);
-extern char *xlate(char *s);
+extern char *spk_s2uchar(char *start, char *dest);
+extern char *spk_xlate(char *s);
 extern int speakup_kobj_init(void);
 extern void speakup_kobj_exit(void);
-extern int chartab_get_value(char *keyword);
+extern int spk_chartab_get_value(char *keyword);
 extern void speakup_register_var(struct var_t *var);
 extern void speakup_unregister_var(enum var_id_t var_id);
-extern struct st_var_header *get_var_header(enum var_id_t var_id);
-extern struct st_var_header *var_header_by_name(const char *name);
-extern struct punc_var_t *get_punc_var(enum var_id_t var_id);
-extern int set_num_var(int val, struct st_var_header *var, int how);
-extern int set_string_var(const char *page, struct st_var_header *var, int len);
-extern int set_mask_bits(const char *input, const int which, const int how);
-extern special_func special_handler;
-extern int handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key);
+extern struct st_var_header *spk_get_var_header(enum var_id_t var_id);
+extern struct st_var_header *spk_var_header_by_name(const char *name);
+extern struct punc_var_t *spk_get_punc_var(enum var_id_t var_id);
+extern int spk_set_num_var(int val, struct st_var_header *var, int how);
+extern int spk_set_string_var(const char *page, struct st_var_header *var, int len);
+extern int spk_set_mask_bits(const char *input, const int which, const int how);
+extern special_func spk_special_handler;
+extern int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key);
 extern int synth_init(char *name);
 extern void synth_release(void);
 
-extern void do_flush(void);
+extern void spk_do_flush(void);
 extern void speakup_start_ttys(void);
 extern void synth_buffer_add(char ch);
 extern void synth_buffer_clear(void);
@@ -90,35 +90,35 @@ extern void synth_write(const char *buf, size_t count);
 extern int synth_supports_indexing(void);
 
 extern struct vc_data *spk_sel_cons;
-extern unsigned short xs, ys, xe, ye; /* our region points */
+extern unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */
 
 extern wait_queue_head_t speakup_event;
 extern struct kobject *speakup_kobj;
 extern struct task_struct *speakup_task;
-extern const u_char key_defaults[];
+extern const u_char spk_key_defaults[];
 
 /* Protect speakup synthesizer list */
 extern struct mutex spk_mutex;
 extern struct st_spk_t *speakup_console[];
 extern struct spk_synth *synth;
-extern char pitch_buff[];
-extern u_char *our_keys[];
-extern short punc_masks[];
-extern char str_caps_start[], str_caps_stop[];
-extern const struct st_bits_data punc_info[];
-extern u_char key_buf[600];
-extern char *characters[];
-extern char *default_chars[];
+extern char spk_pitch_buff[];
+extern u_char *spk_our_keys[];
+extern short spk_punc_masks[];
+extern char spk_str_caps_start[], spk_str_caps_stop[];
+extern const struct st_bits_data spk_punc_info[];
+extern u_char spk_key_buf[600];
+extern char *spk_characters[];
+extern char *spk_default_chars[];
 extern u_short spk_chartab[];
-extern int no_intr, say_ctrl, say_word_ctl, punc_level;
-extern int reading_punc, attrib_bleep, bleeps;
-extern int bleep_time, bell_pos;
-extern int spell_delay, key_echo;
-extern short punc_mask;
-extern short pitch_shift, synth_flags;
-extern bool quiet_boot;
+extern int spk_no_intr, spk_say_ctrl, spk_say_word_ctl, spk_punc_level;
+extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps;
+extern int spk_bleep_time, spk_bell_pos;
+extern int spk_spell_delay, spk_key_echo;
+extern short spk_punc_mask;
+extern short spk_pitch_shift, synth_flags;
+extern bool spk_quiet_boot;
 extern char *synth_name;
-extern struct bleep unprocessed_sound;
+extern struct bleep spk_unprocessed_sound;
 
 /* Prototypes from fakekey.c. */
 int speakup_add_virtual_keyboard(void);
index bbe28b6809e0707306debd18b79d4947e829427a..1c1f0d560449365af18ea46bd910e16afdafd0ea 100644 (file)
@@ -182,9 +182,9 @@ static void do_catch_up(struct spk_synth *synth)
        struct var_t *full_time;
        struct var_t *jiffy_delta;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
-       full_time = get_var(FULL);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
+       full_time = spk_get_var(FULL);
 
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
index 590fa6bb0ed49c585c29ccc7d89f3c33021c6ad1..22a8b72910986d986b5d41690ac1f81c8556bf03 100644 (file)
@@ -128,7 +128,7 @@ static int synth_probe(struct spk_synth *synth)
 {
        int failed;
 
-       failed = serial_synth_probe(synth);
+       failed = spk_serial_synth_probe(synth);
        if (failed == 0) {
                spk_synth_immediate(synth, "\033=R\r");
                mdelay(100);
index 00d5cedd00ab929354bddd8b03765afd077095c5..3e450ccbda6634a0ec7fc0bb09bdcbb59a0e7188 100644 (file)
@@ -112,7 +112,7 @@ static struct spk_synth synth_apollo = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = do_catch_up,
@@ -145,9 +145,9 @@ static void do_catch_up(struct spk_synth *synth)
        int delay_time_val = 0;
        int jiffy_delta_val = 0;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
-       full_time = get_var(FULL);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
+       full_time = spk_get_var(FULL);
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
        spk_unlock(flags);
index 94e509992c8b3e9e8bdd76fb7896e7f48afe9149..3508aee98ab0651e06b831c22d8e3dd80f975ce3 100644 (file)
@@ -162,7 +162,7 @@ static int synth_probe(struct spk_synth *synth)
 {
        int failed = 0;
 
-       failed = serial_synth_probe(synth);
+       failed = spk_serial_synth_probe(synth);
        if (failed == 0)
                synth_version(synth);
        synth->alive = !failed;
index 43e5b54f344cccc6c86f96cd8db0a0e51dd5d9bf..4bfe3d458dc0699b33057cd3fb3a0287e0c7e81c 100644 (file)
@@ -100,7 +100,7 @@ static struct spk_synth synth_bns = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = spk_do_catch_up,
index b4ef9153f42e10afea800aea912ccf52ae102cf9..d39a0de286fb205fc54f488b9951d3b9d3d1116a 100644 (file)
@@ -130,7 +130,7 @@ static struct spk_synth synth_decext = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = do_catch_up,
@@ -162,8 +162,8 @@ static void do_catch_up(struct spk_synth *synth)
        int jiffy_delta_val = 0;
        int delay_time_val = 0;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
 
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
index a09a0c9975dfabac75081f59f4a8beb456d0a791..6c88b55bdac8172190176776ae1bc52ec9c0e20a 100644 (file)
@@ -375,8 +375,8 @@ static void do_catch_up(struct spk_synth *synth)
        int jiffy_delta_val;
        int delay_time_val;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
        spk_unlock(flags);
index daff3b9a4a6df75e058cc033ffc0d0ae9ca1f2a3..0dd2eb96cb28680dd042ee7301a46e530320b732 100644 (file)
@@ -134,7 +134,7 @@ static struct spk_synth synth_dectlk = {
        .vars = vars,
        .default_pitch = ap_defaults,
        .default_vol = g5_defaults,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = do_catch_up,
@@ -214,8 +214,8 @@ static void do_catch_up(struct spk_synth *synth)
        int jiffy_delta_val;
        int delay_time_val;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
        spk_unlock(flags);
index 97bc476746cd511f37200e38def4c282e72b9ae5..a9cefbd3ea93f58ac8224e3fa3ed98650aed5a96 100644 (file)
@@ -198,8 +198,8 @@ static void do_catch_up(struct spk_synth *synth)
        int jiffy_delta_val;
        int delay_time_val;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
        spk_unlock(flags);
index c20f41188be12364d59dc1517f864723c7057a8e..4a24b9c1e8e3f099604f4704ddd45a85e2e7fc13 100644 (file)
@@ -102,7 +102,7 @@ static struct spk_synth synth_dummy = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = spk_do_catch_up,
index 496e01481f9ea1f7011f48780fdef0e6a86d2666..feb5f22cc169ab1e5a8477f8cf4db243abfcd950 100644 (file)
@@ -184,9 +184,9 @@ static void do_catch_up(struct spk_synth *synth)
        int full_time_val;
        int jiffy_delta_val;
 
-       jiffy_delta = get_var(JIFFY);
-       delay_time = get_var(DELAY);
-       full_time = get_var(FULL);
+       jiffy_delta = spk_get_var(JIFFY);
+       delay_time = spk_get_var(DELAY);
+       full_time = spk_get_var(FULL);
 spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
        spk_unlock(flags);
index 971de1a1371213f220485d1e0c6fdb8ad7bc2a6a..326f94d6b0798881780a4cc70ef600cbbd83d0aa 100644 (file)
@@ -161,7 +161,7 @@ static int synth_probe(struct spk_synth *synth)
 {
        int failed = 0;
 
-       failed = serial_synth_probe(synth);
+       failed = spk_serial_synth_probe(synth);
        if (failed == 0)
                synth_interrogate(synth);
        synth->alive = !failed;
index 9a3a80d9701e6e5bf20e3ac43dc4da447a9bc403..e74f85620c68b30bb753a2dcbea5ccbf75cae1af 100644 (file)
@@ -107,7 +107,7 @@ static struct spk_synth synth_spkout = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = spk_do_catch_up,
index 5d5bf7c3d0b13ea36b2da73f9665c63af53c852d..5a29b9fcc93035fa11edad15378b16f5896aabef 100644 (file)
@@ -100,7 +100,7 @@ static struct spk_synth synth_txprt = {
        .startup = SYNTH_START,
        .checkval = SYNTH_CHECK,
        .vars = vars,
-       .probe = serial_synth_probe,
+       .probe = spk_serial_synth_probe,
        .release = spk_serial_release,
        .synth_immediate = spk_synth_immediate,
        .catch_up = spk_do_catch_up,
index a47c5b78d57d78ff63d336f2d1a012f5dcdd9481..303105b46013a3c2b6c55f4f635df98b675168e2 100644 (file)
@@ -45,8 +45,8 @@
 #define KT_SPKUP 15
 
 extern const struct old_serial_port *spk_serial_init(int index);
-extern void stop_serial_interrupt(void);
-extern int wait_for_xmitr(void);
+extern void spk_stop_serial_interrupt(void);
+extern int spk_wait_for_xmitr(void);
 extern unsigned char spk_serial_in(void);
 extern unsigned char spk_serial_in_nowait(void);
 extern int spk_serial_out(const char ch);
@@ -55,13 +55,13 @@ extern void spk_serial_release(void);
 extern char synth_buffer_getc(void);
 extern char synth_buffer_peek(void);
 extern int synth_buffer_empty(void);
-extern struct var_t *get_var(enum var_id_t var_id);
+extern struct var_t *spk_get_var(enum var_id_t var_id);
 extern ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr,
        char *buf);
 extern ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
        const char *buf, size_t count);
 
-extern int serial_synth_probe(struct spk_synth *synth);
+extern int spk_serial_synth_probe(struct spk_synth *synth);
 extern const char *spk_synth_immediate(struct spk_synth *synth, const char *buff);
 extern void spk_do_catch_up(struct spk_synth *synth);
 extern void spk_synth_flush(struct spk_synth *synth);
index 7616f058a00b43ab4c1dd91d0384e6a5400b9a65..d867dd9109ed614fb2f0c183796aed84a8f0b2e2 100644 (file)
@@ -20,9 +20,9 @@
 #define MAXSYNTHS       16      /* Max number of synths in array. */
 static struct spk_synth *synths[MAXSYNTHS];
 struct spk_synth *synth;
-char pitch_buff[32] = "";
+char spk_pitch_buff[32] = "";
 static int module_status;
-bool quiet_boot;
+bool spk_quiet_boot;
 
 struct speakup_info_t speakup_info = {
        .spinlock = __SPIN_LOCK_UNLOCKED(speakup_info.spinlock),
@@ -32,7 +32,7 @@ EXPORT_SYMBOL_GPL(speakup_info);
 
 static int do_synth_init(struct spk_synth *in_synth);
 
-int serial_synth_probe(struct spk_synth *synth)
+int spk_serial_synth_probe(struct spk_synth *synth)
 {
        const struct old_serial_port *ser;
        int failed = 0;
@@ -59,7 +59,7 @@ int serial_synth_probe(struct spk_synth *synth)
        synth->alive = 1;
        return 0;
 }
-EXPORT_SYMBOL_GPL(serial_synth_probe);
+EXPORT_SYMBOL_GPL(spk_serial_synth_probe);
 
 /* Main loop of the progression thread: keep eating from the buffer
  * and push to the serial port, waiting as needed
@@ -79,9 +79,9 @@ void spk_do_catch_up(struct spk_synth *synth)
        int delay_time_val;
        int full_time_val;
 
-       jiffy_delta = get_var(JIFFY);
-       full_time = get_var(FULL);
-       delay_time = get_var(DELAY);
+       jiffy_delta = spk_get_var(JIFFY);
+       full_time = spk_get_var(FULL);
+       delay_time = spk_get_var(DELAY);
 
        spk_lock(flags);
        jiffy_delta_val = jiffy_delta->u.n.value;
@@ -139,7 +139,7 @@ const char *spk_synth_immediate(struct spk_synth *synth, const char *buff)
        while ((ch = *buff)) {
                if (ch == '\n')
                        ch = synth->procspeech;
-               if (wait_for_xmitr())
+               if (spk_wait_for_xmitr())
                        outb(ch, speakup_info.port_tts);
                else
                        return buff;
@@ -166,7 +166,7 @@ int spk_synth_is_alive_restart(struct spk_synth *synth)
 {
        if (synth->alive)
                return 1;
-       if (!synth->alive && wait_for_xmitr() > 0) {
+       if (!synth->alive && spk_wait_for_xmitr() > 0) {
                /* restart */
                synth->alive = 1;
                synth_printf("%s", synth->init);
@@ -192,20 +192,20 @@ void synth_start(void)
                synth_buffer_clear();
                return;
        }
-       trigger_time = get_var(TRIGGER);
+       trigger_time = spk_get_var(TRIGGER);
        if (!timer_pending(&thread_timer))
                mod_timer(&thread_timer, jiffies +
                        msecs_to_jiffies(trigger_time->u.n.value));
 }
 
-void do_flush(void)
+void spk_do_flush(void)
 {
        speakup_info.flushing = 1;
        synth_buffer_clear();
        if (synth->alive) {
-               if (pitch_shift) {
-                       synth_printf("%s", pitch_buff);
-                       pitch_shift = 0;
+               if (spk_pitch_shift) {
+                       synth_printf("%s", spk_pitch_buff);
+                       spk_pitch_shift = 0;
                }
        }
        wake_up_interruptible_all(&speakup_event);
@@ -241,7 +241,7 @@ EXPORT_SYMBOL_GPL(synth_printf);
 static int index_count;
 static int sentence_count;
 
-void reset_index_count(int sc)
+void spk_reset_index_count(int sc)
 {
        static int first = 1;
        if (first)
@@ -277,7 +277,7 @@ void synth_insert_next_index(int sent_num)
        }
 }
 
-void get_index_count(int *linecount, int *sentcount)
+void spk_get_index_count(int *linecount, int *sentcount)
 {
        int ind = synth->get_index();
        if (ind) {
@@ -384,7 +384,7 @@ static int do_synth_init(struct spk_synth *in_synth)
        for (var = synth->vars;
                (var->var_id >= 0) && (var->var_id < MAXVARS); var++)
                speakup_register_var(var);
-       if (!quiet_boot)
+       if (!spk_quiet_boot)
                synth_printf("%s found\n", synth->long_name);
        if (synth->attributes.name
        && sysfs_create_group(speakup_kobj, &(synth->attributes)) < 0)
@@ -412,7 +412,7 @@ void synth_release(void)
                sysfs_remove_group(speakup_kobj, &(synth->attributes));
        for (var = synth->vars; var->var_id != MAXVARS; var++)
                speakup_unregister_var(var->var_id);
-       stop_serial_interrupt();
+       spk_stop_serial_interrupt();
        synth->release();
        synth = NULL;
 }
@@ -460,4 +460,4 @@ void synth_remove(struct spk_synth *in_synth)
 }
 EXPORT_SYMBOL_GPL(synth_remove);
 
-short punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
+short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC|B_SYM };
index 103c5c81ee85a5c1640cfb3e95b673992653d3d0..42fa660a7e0db5fc65e21cdfad506e53dfad0185 100644 (file)
@@ -23,8 +23,8 @@ int speakup_thread(void *data)
                DEFINE_WAIT(wait);
                while (1) {
                        spk_lock(flags);
-                       our_sound = unprocessed_sound;
-                       unprocessed_sound.active = 0;
+                       our_sound = spk_unprocessed_sound;
+                       spk_unprocessed_sound.active = 0;
                        prepare_to_wait(&speakup_event, &wait,
                                TASK_INTERRUPTIBLE);
                        should_break = kthread_should_stop() ||
index ab7de9389dd6247adc7c17f98146e6ca8904a18c..f8c1e457d389c7ff626312dead450441fc5d55ca 100644 (file)
@@ -16,24 +16,24 @@ static struct st_var_header var_headers[] = {
        { "ex_num", EXNUMBER, VAR_PROC, NULL, NULL },
        { "characters", CHARS, VAR_PROC, NULL, NULL },
        { "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL },
-       { "caps_start", CAPS_START, VAR_STRING, str_caps_start, NULL },
-       { "caps_stop", CAPS_STOP, VAR_STRING, str_caps_stop, NULL },
+       { "caps_start", CAPS_START, VAR_STRING, spk_str_caps_start, NULL },
+       { "caps_stop", CAPS_STOP, VAR_STRING, spk_str_caps_stop, NULL },
        { "delay_time", DELAY, VAR_TIME, NULL, NULL },
        { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL },
        { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL },
        { "full_time", FULL, VAR_TIME, NULL, NULL },
-       { "spell_delay", SPELL_DELAY, VAR_NUM, &spell_delay, NULL },
-       { "bleeps", BLEEPS, VAR_NUM, &bleeps, NULL },
-       { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &attrib_bleep, NULL },
-       { "bleep_time", BLEEP_TIME, VAR_TIME, &bleep_time, NULL },
+       { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL },
+       { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL },
+       { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL },
+       { "bleep_time", BLEEP_TIME, VAR_TIME, &spk_bleep_time, NULL },
        { "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL },
-       { "punc_level", PUNC_LEVEL, VAR_NUM, &punc_level, NULL },
-       { "reading_punc", READING_PUNC, VAR_NUM, &reading_punc, NULL },
-       { "say_control", SAY_CONTROL, VAR_NUM, &say_ctrl, NULL },
-       { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &say_word_ctl, NULL },
-       { "no_interrupt", NO_INTERRUPT, VAR_NUM, &no_intr, NULL },
-       { "key_echo", KEY_ECHO, VAR_NUM, &key_echo, NULL },
-       { "bell_pos", BELL_POS, VAR_NUM, &bell_pos, NULL },
+       { "punc_level", PUNC_LEVEL, VAR_NUM, &spk_punc_level, NULL },
+       { "reading_punc", READING_PUNC, VAR_NUM, &spk_reading_punc, NULL },
+       { "say_control", SAY_CONTROL, VAR_NUM, &spk_say_ctrl, NULL },
+       { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &spk_say_word_ctl, NULL },
+       { "no_interrupt", NO_INTERRUPT, VAR_NUM, &spk_no_intr, NULL },
+       { "key_echo", KEY_ECHO, VAR_NUM, &spk_key_echo, NULL },
+       { "bell_pos", BELL_POS, VAR_NUM, &spk_bell_pos, NULL },
        { "rate", RATE, VAR_NUM, NULL, NULL },
        { "pitch", PITCH, VAR_NUM, NULL, NULL },
        { "vol", VOL, VAR_NUM, NULL, NULL },
@@ -58,7 +58,7 @@ static struct punc_var_t punc_vars[] = {
        { -1, -1 },
 };
 
-int chartab_get_value(char *keyword)
+int spk_chartab_get_value(char *keyword)
 {
        int value = 0;
 
@@ -103,11 +103,11 @@ void speakup_register_var(struct var_t *var)
        p_header->data = var;
        switch (p_header->var_type) {
        case VAR_STRING:
-               set_string_var(nothing, p_header, 0);
+               spk_set_string_var(nothing, p_header, 0);
                break;
        case VAR_NUM:
        case VAR_TIME:
-               set_num_var(0, p_header, E_DEFAULT);
+               spk_set_num_var(0, p_header, E_DEFAULT);
                break;
        default:
                break;
@@ -123,7 +123,7 @@ void speakup_unregister_var(enum var_id_t var_id)
        p_header->data = NULL;
 }
 
-struct st_var_header *get_var_header(enum var_id_t var_id)
+struct st_var_header *spk_get_var_header(enum var_id_t var_id)
 {
        struct st_var_header *p_header;
        if (var_id < 0 || var_id >= MAXVARS)
@@ -134,7 +134,7 @@ struct st_var_header *get_var_header(enum var_id_t var_id)
        return p_header;
 }
 
-struct st_var_header *var_header_by_name(const char *name)
+struct st_var_header *spk_var_header_by_name(const char *name)
 {
        int i;
        struct st_var_header *where = NULL;
@@ -151,15 +151,15 @@ struct st_var_header *var_header_by_name(const char *name)
        return where;
 }
 
-struct var_t *get_var(enum var_id_t var_id)
+struct var_t *spk_get_var(enum var_id_t var_id)
 {
        BUG_ON(var_id < 0 || var_id >= MAXVARS);
        BUG_ON(!var_ptrs[var_id]);
        return var_ptrs[var_id]->data;
 }
-EXPORT_SYMBOL_GPL(get_var);
+EXPORT_SYMBOL_GPL(spk_get_var);
 
-struct punc_var_t *get_punc_var(enum var_id_t var_id)
+struct punc_var_t *spk_get_punc_var(enum var_id_t var_id)
 {
        struct punc_var_t *rv = NULL;
        struct punc_var_t *where;
@@ -175,7 +175,7 @@ struct punc_var_t *get_punc_var(enum var_id_t var_id)
 }
 
 /* handlers for setting vars */
-int set_num_var(int input, struct st_var_header *var, int how)
+int spk_set_num_var(int input, struct st_var_header *var, int how)
 {
        int val;
        short ret = 0;
@@ -217,7 +217,7 @@ int set_num_var(int input, struct st_var_header *var, int how)
        if (p_val != NULL)
                *p_val = val;
        if (var->var_id == PUNC_LEVEL) {
-               punc_mask = punc_masks[val];
+               spk_punc_mask = spk_punc_masks[val];
                return ret;
        }
        if (var_data->u.n.multiplier != 0)
@@ -232,7 +232,7 @@ int set_num_var(int input, struct st_var_header *var, int how)
        if (!var_data->u.n.synth_fmt)
                return ret;
        if (var->var_id == PITCH)
-               cp = pitch_buff;
+               cp = spk_pitch_buff;
        else
                cp = buf;
        if (!var_data->u.n.out_str)
@@ -244,7 +244,7 @@ int set_num_var(int input, struct st_var_header *var, int how)
        return ret;
 }
 
-int set_string_var(const char *page, struct st_var_header *var, int len)
+int spk_set_string_var(const char *page, struct st_var_header *var, int len)
 {
        int ret = 0;
        struct var_t *var_data = var->data;
@@ -267,21 +267,21 @@ int set_string_var(const char *page, struct st_var_header *var, int len)
        return ret;
 }
 
-/* set_mask_bits sets or clears the punc/delim/repeat bits,
+/* spk_set_mask_bits sets or clears the punc/delim/repeat bits,
  * if input is null uses the defaults.
  * values for how: 0 clears bits of chars supplied,
  * 1 clears allk, 2 sets bits for chars */
-int set_mask_bits(const char *input, const int which, const int how)
+int spk_set_mask_bits(const char *input, const int which, const int how)
 {
        u_char *cp;
-       short mask = punc_info[which].mask;
+       short mask = spk_punc_info[which].mask;
        if (how&1) {
-               for (cp = (u_char *)punc_info[3].value; *cp; cp++)
+               for (cp = (u_char *)spk_punc_info[3].value; *cp; cp++)
                        spk_chartab[*cp] &= ~mask;
        }
        cp = (u_char *)input;
        if (cp == 0)
-               cp = punc_info[which].value;
+               cp = spk_punc_info[which].value;
        else {
                for ( ; *cp; cp++) {
                        if (*cp < SPACE)
@@ -308,7 +308,7 @@ int set_mask_bits(const char *input, const int which, const int how)
        return 0;
 }
 
-char *strlwr(char *s)
+char *spk_strlwr(char *s)
 {
        char *p;
        if (s == NULL)
@@ -341,7 +341,7 @@ char *speakup_s2i(char *start, int *dest)
        return start;
 }
 
-char *s2uchar(char *start, char *dest)
+char *spk_s2uchar(char *start, char *dest)
 {
        int val = 0;
        while (*start && *start <= SPACE)
@@ -357,7 +357,7 @@ char *s2uchar(char *start, char *dest)
        return start;
 }
 
-char *xlate(char *s)
+char *spk_xlate(char *s)
 {
        static const char finds[] = "nrtvafe";
        static const char subs[] = "\n\r\t\013\001\014\033";
index f619fb3c56d298334a615eb1b34203ccd1e5f5d3..b770b2281ce8c3c4c8bc4fe4b2ef1559ab8d23e3 100644 (file)
 #define PAGES_II_LVL_TABLE   512
 #define PHYS_TO_PAGE(phys)      pfn_to_page((phys) >> PAGE_SHIFT)
 
-/*
- * This is a totally ugly layer violation, but needed until
- * omap_ctrl_set_dsp_boot*() are provided.
- */
-#define OMAP3_IVA2_BOOTMOD_IDLE 1
-#define OMAP2_CONTROL_GENERAL 0x270
-#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
-#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
+/* IVA Boot modes */
+#define DIRECT         0
+#define IDLE           1
 
 /* Forward Declarations: */
 static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt);
@@ -423,29 +418,14 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
 
                /* Assert RST1 i.e only the RST only for DSP megacell */
                if (!status) {
-                       /*
-                        * XXX: OMAP343X_CTRL_BASE ioremapping  MUST be removed once ctrl
-                        * function is made available.
-                        */
-                       void __iomem *ctrl = ioremap(0x48002000, SZ_4K);
-                       if (!ctrl) {
-                               iounmap(sync_addr);
-                               return -ENOMEM;
-                       }
-
                        (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK,
                                        OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD,
                                        OMAP2_RM_RSTCTRL);
-                       /* Mask address with 1K for compatibility */
-                       __raw_writel(dsp_addr & OMAP3_IVA2_BOOTADDR_MASK,
-                                       ctrl + OMAP343X_CONTROL_IVA2_BOOTADDR);
-                       /*
-                        * Set bootmode to self loop if dsp_debug flag is true
-                        */
-                       __raw_writel((dsp_debug) ? OMAP3_IVA2_BOOTMOD_IDLE : 0,
-                                       ctrl + OMAP343X_CONTROL_IVA2_BOOTMOD);
 
-                       iounmap(ctrl);
+                       /* Mask address with 1K for compatibility */
+                       pdata->set_bootaddr(dsp_addr &
+                                               OMAP3_IVA2_BOOTADDR_MASK);
+                       pdata->set_bootmode(dsp_debug ? IDLE : DIRECT);
                }
        }
        if (!status) {
index 851b356d7a51a24f47ac5959f500bd0fad8a8454..774a3f6ff2011c4fb1a0c791855a463f6a8c92fb 100644 (file)
@@ -23,8 +23,6 @@
 #include <dspbridge/devdefs.h>
 #include <dspbridge/drv.h>
 
-extern char *iva_img;
-
 /*
  *  ======== proc_attach ========
  *  Purpose:
index 4007826f7abc5db50041d86ed0d03a9eb0fec996..6c29379baf60d2242a9a810b21b8c843136afe6f 100644 (file)
@@ -289,7 +289,7 @@ int cod_get_base_name(struct cod_manager *cod_mgr_obj, char *sz_name,
        int status = 0;
 
        if (usize <= COD_MAXPATHLENGTH)
-               strncpy(sz_name, cod_mgr_obj->sz_zl_file, usize);
+               strlcpy(sz_name, cod_mgr_obj->sz_zl_file, usize);
        else
                status = -EPERM;
 
index 9f07036cd411c1eef4294c38a39a991010243cf5..c191ae20356583a48aaba72526a64c92261c073b 100644 (file)
@@ -1382,7 +1382,7 @@ void find_symbol_callback(void *elem, void *user_data)
                offset < context->cur_best_offset) {
                context->cur_best_offset = offset;
                context->sym_addr = symbol_addr;
-               strncpy(context->name, symbol->name, sizeof(context->name));
+               strlcpy(context->name, symbol->name, sizeof(context->name));
        }
 
        return;
index 9ef1ad9527afe4c32a7f5653b9d62dde944c9853..5a18a9417ac27081a38948006fe6c179a1750dbf 100644 (file)
@@ -414,10 +414,13 @@ u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt)
        CP_FM_USR(&uuid_obj, args->args_mgr_registerobject.uuid_obj, status, 1);
        if (status)
                goto func_end;
-       /* path_size is increased by 1 to accommodate NULL */
        path_size = strlen_user((char *)
-                               args->args_mgr_registerobject.sz_path_name) +
-           1;
+                               args->args_mgr_registerobject.sz_path_name);
+       if (!path_size) {
+               status = -EINVAL;
+               goto func_end;
+       }
+
        psz_path_name = kmalloc(path_size, GFP_KERNEL);
        if (!psz_path_name) {
                status = -ENOMEM;
index 9d52c3cb92f03257393b99e0d5b0f5eff2d226df..3d2a26f1efe55a82c01b8bfd9f525e856e40227a 100644 (file)
@@ -852,8 +852,7 @@ int dcd_register_object(struct dsp_uuid *uuid_obj,
                                goto func_end;
                        }
 
-                       dcd_key->path = kmalloc(strlen(sz_reg_key) + 1,
-                                                               GFP_KERNEL);
+                       dcd_key->path = kmalloc(dw_path_size, GFP_KERNEL);
 
                        if (!dcd_key->path) {
                                kfree(dcd_key);
index e6f31d817d6b8b0988419b0d21f9c6851a84b9a1..df0f37ea1ee50bf765680edba66ac1292ccc4c6b 100644 (file)
@@ -65,7 +65,6 @@ static struct class *bridge_class;
 static u32 driver_context;
 static s32 driver_major;
 static char *base_img;
-char *iva_img;
 static s32 shm_size = 0x500000;        /* 5 MB */
 static int tc_wordswapon;      /* Default value is always false */
 #ifdef CONFIG_TIDSPBRIDGE_RECOVERY
index 6309221b64a5d9c1d053619866adee0ada0f3673..ca3805046a73c8b08a44d76fe0fd89eed07c7fe2 100644 (file)
@@ -1802,8 +1802,6 @@ int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr,
        bool status1 = false;
        s32 i = 0;
        struct lib_node root = { NULL, 0, NULL };
-       pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n", __func__, (u32) nldr_node,
-                       sym_addr, offset_range, (u32) offset_output, sym_name);
 
        if (nldr_node->dynamic && *nldr_node->phase_split) {
                switch (nldr_node->phase) {
@@ -1852,6 +1850,10 @@ int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr,
                pr_debug("%s: Address 0x%x not found in range %d.\n",
                                        __func__, sym_addr, offset_range);
                status = -ESPIPE;
+       } else {
+               pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n",
+                        __func__, (u32) nldr_node, sym_addr, offset_range,
+                        (u32) offset_output, sym_name);
        }
 
        return status;
index 737f4a9d86a33fb7fcb865c11f43453d15bd7ecd..87dfa92ab45b91665fdd27c9c9d838e1f48b48da 100644 (file)
@@ -3012,16 +3012,16 @@ int node_find_addr(struct node_mgr *node_mgr, u32 sym_addr,
        struct node_object *node_obj;
        int status = -ENOENT;
 
-       pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n", __func__,
-                       (unsigned int) node_mgr,
-                       sym_addr, offset_range,
-                       (unsigned int) sym_addr_output, sym_name);
-
        list_for_each_entry(node_obj, &node_mgr->node_list, list_elem) {
                status = nldr_find_addr(node_obj->nldr_node_obj, sym_addr,
                        offset_range, sym_addr_output, sym_name);
-               if (!status)
+               if (!status) {
+                       pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", __func__,
+                                (unsigned int) node_mgr,
+                                sym_addr, offset_range,
+                                (unsigned int) sym_addr_output, sym_name);
                        break;
+               }
        }
 
        return status;
index 5e43938ab7fa758170e34479992820cc361bddd4..e1bdf6eacb3a4996afeef38e3fc1ffcd4e82caba 100644 (file)
@@ -382,7 +382,6 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj,
                                u32 size, char *exec_file)
 {
        u8 dev_type;
-       s32 len;
        struct drv_data *drv_datap = dev_get_drvdata(bridge);
 
        dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
@@ -394,13 +393,10 @@ static int get_exec_file(struct cfg_devnode *dev_node_obj,
                if (!drv_datap || !drv_datap->base_img)
                        return -EFAULT;
 
-               if (strlen(drv_datap->base_img) > size)
+               if (strlen(drv_datap->base_img) >= size)
                        return -EINVAL;
 
                strcpy(exec_file, drv_datap->base_img);
-       } else if (dev_type == IVA_UNIT && iva_img) {
-               len = strlen(iva_img);
-               strncpy(exec_file, iva_img, len + 1);
        } else {
                return -ENOENT;
        }
index 199b1d4c0b854242600ae516b1f5788560d25611..886000980474a43b081cc6547a26a9fe12f76be2 100644 (file)
@@ -8,7 +8,7 @@ config USBIP_CORE
          USB/IP core that is required by both drivers.
 
          For more details, and to get the userspace utility
-         programs, please see http://usbip.sourceforge.net/.
+         programs, please see <http://usbip.sourceforge.net/>.
 
          To compile this as a module, choose M here: the module will
          be called usbip-core.
index ee36415eb26db02a543f9a5d75642b21bfe07712..d36c69e16d366aabfc9cc2bb82769bda7a11d192 100644 (file)
@@ -67,9 +67,9 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr,
                return -ENODEV;
        }
 
-       spin_lock(&sdev->ud.lock);
+       spin_lock_irq(&sdev->ud.lock);
        status = sdev->ud.status;
-       spin_unlock(&sdev->ud.lock);
+       spin_unlock_irq(&sdev->ud.lock);
 
        return snprintf(buf, PAGE_SIZE, "%d\n", status);
 }
@@ -97,39 +97,39 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
        if (sockfd != -1) {
                dev_info(dev, "stub up\n");
 
-               spin_lock(&sdev->ud.lock);
+               spin_lock_irq(&sdev->ud.lock);
 
                if (sdev->ud.status != SDEV_ST_AVAILABLE) {
                        dev_err(dev, "not ready\n");
-                       spin_unlock(&sdev->ud.lock);
+                       spin_unlock_irq(&sdev->ud.lock);
                        return -EINVAL;
                }
 
                socket = sockfd_to_socket(sockfd);
                if (!socket) {
-                       spin_unlock(&sdev->ud.lock);
+                       spin_unlock_irq(&sdev->ud.lock);
                        return -EINVAL;
                }
                sdev->ud.tcp_socket = socket;
 
-               spin_unlock(&sdev->ud.lock);
+               spin_unlock_irq(&sdev->ud.lock);
 
                sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, "stub_rx");
                sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, "stub_tx");
 
-               spin_lock(&sdev->ud.lock);
+               spin_lock_irq(&sdev->ud.lock);
                sdev->ud.status = SDEV_ST_USED;
-               spin_unlock(&sdev->ud.lock);
+               spin_unlock_irq(&sdev->ud.lock);
 
        } else {
                dev_info(dev, "stub down\n");
 
-               spin_lock(&sdev->ud.lock);
+               spin_lock_irq(&sdev->ud.lock);
                if (sdev->ud.status != SDEV_ST_USED) {
-                       spin_unlock(&sdev->ud.lock);
+                       spin_unlock_irq(&sdev->ud.lock);
                        return -EINVAL;
                }
-               spin_unlock(&sdev->ud.lock);
+               spin_unlock_irq(&sdev->ud.lock);
 
                usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN);
        }
@@ -241,9 +241,9 @@ static void stub_device_reset(struct usbip_device *ud)
        ret = usb_lock_device_for_reset(udev, sdev->interface);
        if (ret < 0) {
                dev_err(&udev->dev, "lock for reset\n");
-               spin_lock(&ud->lock);
+               spin_lock_irq(&ud->lock);
                ud->status = SDEV_ST_ERROR;
-               spin_unlock(&ud->lock);
+               spin_unlock_irq(&ud->lock);
                return;
        }
 
@@ -251,7 +251,7 @@ static void stub_device_reset(struct usbip_device *ud)
        ret = usb_reset_device(udev);
        usb_unlock_device(udev);
 
-       spin_lock(&ud->lock);
+       spin_lock_irq(&ud->lock);
        if (ret) {
                dev_err(&udev->dev, "device reset\n");
                ud->status = SDEV_ST_ERROR;
@@ -259,14 +259,14 @@ static void stub_device_reset(struct usbip_device *ud)
                dev_info(&udev->dev, "device reset\n");
                ud->status = SDEV_ST_AVAILABLE;
        }
-       spin_unlock(&ud->lock);
+       spin_unlock_irq(&ud->lock);
 }
 
 static void stub_device_unusable(struct usbip_device *ud)
 {
-       spin_lock(&ud->lock);
+       spin_lock_irq(&ud->lock);
        ud->status = SDEV_ST_ERROR;
-       spin_unlock(&ud->lock);
+       spin_unlock_irq(&ud->lock);
 }
 
 /**
index 0572a15242b5a7c85efb5dafff64645e6693d6da..e7458e1ad15118f13ccd49c798c132f01cb709d5 100644 (file)
@@ -307,12 +307,12 @@ static int valid_request(struct stub_device *sdev, struct usbip_header *pdu)
        int valid = 0;
 
        if (pdu->base.devid == sdev->devid) {
-               spin_lock(&ud->lock);
+               spin_lock_irq(&ud->lock);
                if (ud->status == SDEV_ST_USED) {
                        /* A request is valid. */
                        valid = 1;
                }
-               spin_unlock(&ud->lock);
+               spin_unlock_irq(&ud->lock);
        }
 
        return valid;
index 75189feac380c5cba44e7264811a94e40c3b46ae..75aa5bfcb8ddc8b7eb4c98d40542129da4a7a9bf 100644 (file)
@@ -672,9 +672,8 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
                return 0;
 
        /* my Bluetooth dongle gets ISO URBs which are np = 0 */
-       if (np == 0) {
+       if (np == 0)
                return 0;
-       }
 
        buff = kzalloc(size, GFP_KERNEL);
        if (!buff)
index d332a34ddb6d125f7e737d8abe146f12750f8faa..82123be8732d49861db86d11c8f6de895978b62d 100644 (file)
@@ -105,10 +105,12 @@ EXPORT_SYMBOL_GPL(usbip_stop_eh);
 
 void usbip_event_add(struct usbip_device *ud, unsigned long event)
 {
-       spin_lock(&ud->lock);
+       unsigned long flags;
+
+       spin_lock_irqsave(&ud->lock, flags);
        ud->event |= event;
        wake_up(&ud->eh_waitq);
-       spin_unlock(&ud->lock);
+       spin_unlock_irqrestore(&ud->lock, flags);
 }
 EXPORT_SYMBOL_GPL(usbip_event_add);
 
diff --git a/drivers/staging/usbip/userspace/.gitignore b/drivers/staging/usbip/userspace/.gitignore
new file mode 100644 (file)
index 0000000..9aad9e3
--- /dev/null
@@ -0,0 +1,28 @@
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache/
+config.guess
+config.h
+config.h.in
+config.log
+config.status
+config.sub
+configure
+depcomp
+install-sh
+libsrc/Makefile
+libsrc/Makefile.in
+libtool
+ltmain.sh
+missing
+src/Makefile
+src/Makefile.in
+stamp-h1
+libsrc/libusbip.la
+libsrc/libusbip_la-names.lo
+libsrc/libusbip_la-usbip_common.lo
+libsrc/libusbip_la-usbip_host_driver.lo
+libsrc/libusbip_la-vhci_driver.lo
+src/usbip
+src/usbipd
index 9ab19499fe00b3bfd81d2a1af22bdcb86492ce8b..66f8bf038c9f6a5d3ec5c8d41acc0f91313bf7c1 100644 (file)
@@ -3,4 +3,4 @@ includedir = @includedir@/usbip
 include_HEADERS := $(addprefix libsrc/, \
                     usbip_common.h vhci_driver.h usbip_host_driver.h)
 
-dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8 usbip_bind_driver.8)
+dist_man_MANS := $(addprefix doc/, usbip.8 usbipd.8)
index 63cd107190591d0ce2c7513335378df4a0a27d94..233d1d7aef928ff648597edd7be302b282b04ea1 100644 (file)
@@ -17,8 +17,6 @@
 
     - gcc >= 4.0
 
-    - libglib2.0-dev >= 2.6.0
-
     - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config
 
 
index 43e641e5ac0610cbc26d02bad98d2d97d5236077..2be4060f90363a693ffe635955ab462acef98eb8 100644 (file)
@@ -91,10 +91,22 @@ AC_ARG_WITH([usbids-dir],
            [USBIDS_DIR=$withval], [USBIDS_DIR="/usr/share/hwdata/"])
 AC_SUBST([USBIDS_DIR])
 
-GLIB2_REQUIRED=2.6.0
-PKG_CHECK_MODULES([PACKAGE], [glib-2.0 >= $GLIB2_REQUIRED])
-AC_SUBST([PACKAGE_CFLAGS])
-AC_SUBST([PACKAGE_LIBS])
+# use _FORTIFY_SOURCE
+AC_MSG_CHECKING([whether to use fortify])
+AC_ARG_WITH([fortify],
+           [AS_HELP_STRING([--with-fortify],
+                           [use _FORTIFY_SROUCE option when compiling)])],
+                           dnl [ACTION-IF-GIVEN]
+                           [if test "$withval" = "yes"; then
+                               AC_MSG_RESULT([yes])
+                               CFLAGS="$CFLAGS -D_FORTIFY_SOURCE -O"
+                            else
+                               AC_MSG_RESULT([no])
+                               CFLAGS="$CFLAGS -U_FORTIFY_SOURCE"
+                            fi
+                           ],
+                           dnl [ACTION-IF-NOT-GIVEN]
+                           [AC_MSG_RESULT([default])])
 
 AC_CONFIG_FILES([Makefile libsrc/Makefile src/Makefile])
 AC_OUTPUT
index c365a3fada904ff351d3bd39db7bc37b15562a79..a1130036139242b8b2bbca14812040f317d5537b 100644 (file)
@@ -1,6 +1,6 @@
 AM_CPPFLAGS = -I$(top_srcdir)/libsrc -DUSBIDS_FILE='"@USBIDS_DIR@/usb.ids"'
-AM_CFLAGS   = @EXTRA_CFLAGS@ @PACKAGE_CFLAGS@
-LDADD       = $(top_builddir)/libsrc/libusbip.la @PACKAGE_LIBS@
+AM_CFLAGS   = @EXTRA_CFLAGS@
+LDADD       = $(top_builddir)/libsrc/libusbip.la
 
 sbin_PROGRAMS := usbip usbipd
 
index bdf61c0fe699c466150604e0dc868cab26992ab9..2da4e44e16336cf55e5b65dc80b779f736eac7b2 100644 (file)
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "vhci_driver.h"
 #include "usbip_common.h"
@@ -52,8 +53,18 @@ static int record_connection(char *host, char *port, char *busid, int rhport)
        int ret;
 
        ret = mkdir(VHCI_STATE_PATH, 0700);
-       if (ret < 0)
-               return -1;
+       if (ret < 0) {
+               /* if VHCI_STATE_PATH exists, then it better be a directory */
+               if (errno == EEXIST) {
+                       struct stat s;
+                       ret = stat(VHCI_STATE_PATH, &s);
+                       if (ret < 0)
+                               return -1;
+                       if (!(s.st_mode & S_IFDIR))
+                               return -1;
+               } else
+                       return -1;
+       }
 
        snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", rhport);
 
index 8668a8092d4d0c9b3556b377c9999730eb14cf98..34760cc1d10e1777f234c3ac6e5102ce4b827163 100644 (file)
@@ -20,6 +20,7 @@
 #include "../config.h"
 #endif
 
+#define _GNU_SOURCE
 #include <errno.h>
 #include <unistd.h>
 #include <netdb.h>
 #include <tcpd.h>
 #endif
 
-#define _GNU_SOURCE
 #include <getopt.h>
-#include <glib.h>
 #include <signal.h>
+#include <poll.h>
 
 #include "usbip_host_driver.h"
 #include "usbip_common.h"
@@ -48,7 +48,7 @@
 #define PROGNAME "usbipd"
 #define MAXSOCKFD 20
 
-GMainLoop *main_loop;
+#define MAIN_LOOP_TIMEOUT 10
 
 static const char usbip_version_string[] = PACKAGE_STRING;
 
@@ -310,30 +310,22 @@ static int do_accept(int listenfd)
        return connfd;
 }
 
-gboolean process_request(GIOChannel *gio, GIOCondition condition,
-                        gpointer unused_data)
+int process_request(int listenfd)
 {
-       int listenfd;
+       pid_t childpid;
        int connfd;
 
-       (void) unused_data;
-
-       if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
-               err("unknown condition");
-               BUG();
-       }
-
-       if (condition & G_IO_IN) {
-               listenfd = g_io_channel_unix_get_fd(gio);
-               connfd = do_accept(listenfd);
-               if (connfd < 0)
-                       return TRUE;
-
+       connfd = do_accept(listenfd);
+       if (connfd < 0)
+               return -1;
+       childpid = fork();
+       if (childpid == 0) {
+               close(listenfd);
                recv_pdu(connfd);
-               close(connfd);
+               exit(0);
        }
-
-       return TRUE;
+       close(connfd);
+       return 0;
 }
 
 static void log_addrinfo(struct addrinfo *ai)
@@ -418,10 +410,7 @@ static struct addrinfo *do_getaddrinfo(char *host, int ai_family)
 
 static void signal_handler(int i)
 {
-       dbg("received signal: code %d", i);
-
-       if (main_loop)
-               g_main_loop_quit(main_loop);
+       dbg("received '%s' signal", strsignal(i));
 }
 
 static void set_signal(void)
@@ -433,14 +422,19 @@ static void set_signal(void)
        sigemptyset(&act.sa_mask);
        sigaction(SIGTERM, &act, NULL);
        sigaction(SIGINT, &act, NULL);
+       act.sa_handler = SIG_IGN;
+       sigaction(SIGCLD, &act, NULL);
 }
 
-static int do_standalone_mode(gboolean daemonize)
+static int do_standalone_mode(int daemonize)
 {
        struct addrinfo *ai_head;
        int sockfdlist[MAXSOCKFD];
        int nsockfd;
-       int i;
+       int i, terminate;
+       struct pollfd *fds;
+       struct timespec timeout;
+       sigset_t sigmask;
 
        if (usbip_names_init(USBIDS_FILE))
                err("failed to open %s", USBIDS_FILE);
@@ -456,7 +450,7 @@ static int do_standalone_mode(gboolean daemonize)
                        err("daemonizing failed: %s", strerror(errno));
                        return -1;
                }
-
+               umask(0);
                usbip_use_syslog = 1;
        }
        set_signal();
@@ -472,20 +466,40 @@ static int do_standalone_mode(gboolean daemonize)
                err("failed to open a listening socket");
                return -1;
        }
-
+       fds = calloc(nsockfd, sizeof(struct pollfd));
        for (i = 0; i < nsockfd; i++) {
-               GIOChannel *gio;
-
-               gio = g_io_channel_unix_new(sockfdlist[i]);
-               g_io_add_watch(gio, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
-                              process_request, NULL);
+               fds[i].fd = sockfdlist[i];
+               fds[i].events = POLLIN;
+       }
+       timeout.tv_sec = MAIN_LOOP_TIMEOUT;
+       timeout.tv_nsec = 0;
+
+       sigfillset(&sigmask);
+       sigdelset(&sigmask, SIGTERM);
+       sigdelset(&sigmask, SIGINT);
+
+       terminate = 0;
+       while (!terminate) {
+               int r;
+
+               r = ppoll(fds, nsockfd, &timeout, &sigmask);
+               if (r < 0) {
+                       dbg("%s", strerror(errno));
+                       terminate = 1;
+               } else if (r) {
+                       for (i = 0; i < nsockfd; i++) {
+                               if (fds[i].revents & POLLIN) {
+                                       dbg("read event on fd[%d]=%d",
+                                           i, sockfdlist[i]);
+                                       process_request(sockfdlist[i]);
+                               }
+                       }
+               } else
+                       dbg("heartbeat timeout on ppoll()");
        }
-
-       main_loop = g_main_loop_new(FALSE, FALSE);
-       g_main_loop_run(main_loop);
 
        info("shutting down " PROGNAME);
-
+       free(fds);
        freeaddrinfo(ai_head);
        usbip_host_driver_close();
        usbip_names_free();
@@ -509,7 +523,7 @@ int main(int argc, char *argv[])
                cmd_version
        } cmd;
 
-       gboolean daemonize = FALSE;
+       int daemonize = 0;
        int opt, rc = -1;
 
        usbip_use_stderr = 1;
@@ -527,7 +541,7 @@ int main(int argc, char *argv[])
 
                switch (opt) {
                case 'D':
-                       daemonize = TRUE;
+                       daemonize = 1;
                        break;
                case 'd':
                        usbip_use_debug = 1;
index c3aa2195f1a8b835ac00b5ebf32db8d130a3d4d0..216648d3c8fa7648c1358900c63d5d3569f9773c 100644 (file)
@@ -121,11 +121,9 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status)
 
 void rh_port_connect(int rhport, enum usb_device_speed speed)
 {
-       unsigned long   flags;
-
        usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock(&the_controller->lock);
 
        the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION
                | (1 << USB_PORT_FEAT_C_CONNECTION);
@@ -141,24 +139,22 @@ void rh_port_connect(int rhport, enum usb_device_speed speed)
                break;
        }
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
 
        usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
 }
 
 static void rh_port_disconnect(int rhport)
 {
-       unsigned long flags;
-
        usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock(&the_controller->lock);
 
        the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION;
        the_controller->port_status[rhport] |=
                                        (1 << USB_PORT_FEAT_C_CONNECTION);
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
        usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
 }
 
@@ -183,7 +179,6 @@ static void rh_port_disconnect(int rhport)
 static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
 {
        struct vhci_hcd *vhci;
-       unsigned long   flags;
        int             retval;
        int             rhport;
        int             changed = 0;
@@ -193,7 +188,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
 
        vhci = hcd_to_vhci(hcd);
 
-       spin_lock_irqsave(&vhci->lock, flags);
+       spin_lock(&vhci->lock);
        if (!HCD_HW_ACCESSIBLE(hcd)) {
                usbip_dbg_vhci_rh("hw accessible flag not on?\n");
                goto done;
@@ -216,7 +211,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
                usb_hcd_resume_root_hub(hcd);
 
 done:
-       spin_unlock_irqrestore(&vhci->lock, flags);
+       spin_unlock(&vhci->lock);
        return changed ? retval : 0;
 }
 
@@ -237,7 +232,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 {
        struct vhci_hcd *dum;
        int             retval = 0;
-       unsigned long   flags;
        int             rhport;
 
        u32 prev_port_status[VHCI_NPORTS];
@@ -257,7 +251,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
        dum = hcd_to_vhci(hcd);
 
-       spin_lock_irqsave(&dum->lock, flags);
+       spin_lock(&dum->lock);
 
        /* store old status and compare now and old later */
        if (usbip_dbg_flag_vhci_rh) {
@@ -410,7 +404,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        }
        usbip_dbg_vhci_rh(" bye\n");
 
-       spin_unlock_irqrestore(&dum->lock, flags);
+       spin_unlock(&dum->lock);
 
        return retval;
 }
@@ -433,7 +427,6 @@ static void vhci_tx_urb(struct urb *urb)
 {
        struct vhci_device *vdev = get_vdev(urb->dev);
        struct vhci_priv *priv;
-       unsigned long flag;
 
        if (!vdev) {
                pr_err("could not get virtual device");
@@ -442,11 +435,11 @@ static void vhci_tx_urb(struct urb *urb)
 
        priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC);
 
-       spin_lock_irqsave(&vdev->priv_lock, flag);
+       spin_lock(&vdev->priv_lock);
 
        if (!priv) {
                dev_err(&urb->dev->dev, "malloc vhci_priv\n");
-               spin_unlock_irqrestore(&vdev->priv_lock, flag);
+               spin_unlock(&vdev->priv_lock);
                usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
                return;
        }
@@ -463,7 +456,7 @@ static void vhci_tx_urb(struct urb *urb)
        list_add_tail(&priv->list, &vdev->priv_tx);
 
        wake_up(&vdev->waitq_tx);
-       spin_unlock_irqrestore(&vdev->priv_lock, flag);
+       spin_unlock(&vdev->priv_lock);
 }
 
 static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
@@ -471,7 +464,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 {
        struct device *dev = &urb->dev->dev;
        int ret = 0;
-       unsigned long flags;
        struct vhci_device *vdev;
 
        usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
@@ -480,11 +472,11 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
        /* patch to usb_sg_init() is in 2.5.60 */
        BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock(&the_controller->lock);
 
        if (urb->status != -EINPROGRESS) {
                dev_err(dev, "URB already unlinked!, status %d\n", urb->status);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock(&the_controller->lock);
                return urb->status;
        }
 
@@ -496,7 +488,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
            vdev->ud.status == VDEV_ST_ERROR) {
                dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport);
                spin_unlock(&vdev->ud.lock);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock(&the_controller->lock);
                return -ENODEV;
        }
        spin_unlock(&vdev->ud.lock);
@@ -571,14 +563,14 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
 
 out:
        vhci_tx_urb(urb);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
 
        return 0;
 
 no_need_xmit:
        usb_hcd_unlink_urb_from_ep(hcd, urb);
 no_need_unlink:
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
        usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
        return ret;
 }
@@ -631,19 +623,18 @@ no_need_unlink:
  */
 static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 {
-       unsigned long flags;
        struct vhci_priv *priv;
        struct vhci_device *vdev;
 
        pr_info("dequeue a urb %p\n", urb);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock(&the_controller->lock);
 
        priv = urb->hcpriv;
        if (!priv) {
                /* URB was never linked! or will be soon given back by
                 * vhci_rx. */
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock(&the_controller->lock);
                return 0;
        }
 
@@ -651,7 +642,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                int ret = 0;
                ret = usb_hcd_check_unlink_urb(hcd, urb, status);
                if (ret) {
-                       spin_unlock_irqrestore(&the_controller->lock, flags);
+                       spin_unlock(&the_controller->lock);
                        return ret;
                }
        }
@@ -661,16 +652,14 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
        if (!vdev->ud.tcp_socket) {
                /* tcp connection is closed */
-               unsigned long flags2;
-
-               spin_lock_irqsave(&vdev->priv_lock, flags2);
+               spin_lock(&vdev->priv_lock);
 
                pr_info("device %p seems to be disconnected\n", vdev);
                list_del(&priv->list);
                kfree(priv);
                urb->hcpriv = NULL;
 
-               spin_unlock_irqrestore(&vdev->priv_lock, flags2);
+               spin_unlock(&vdev->priv_lock);
 
                /*
                 * If tcp connection is alive, we have sent CMD_UNLINK.
@@ -681,24 +670,23 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 
                usb_hcd_unlink_urb_from_ep(hcd, urb);
 
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock(&the_controller->lock);
                usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
                                     urb->status);
-               spin_lock_irqsave(&the_controller->lock, flags);
+               spin_lock(&the_controller->lock);
 
        } else {
                /* tcp connection is alive */
-               unsigned long flags2;
                struct vhci_unlink *unlink;
 
-               spin_lock_irqsave(&vdev->priv_lock, flags2);
+               spin_lock(&vdev->priv_lock);
 
                /* setup CMD_UNLINK pdu */
                unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
                if (!unlink) {
                        pr_err("malloc vhci_unlink\n");
-                       spin_unlock_irqrestore(&vdev->priv_lock, flags2);
-                       spin_unlock_irqrestore(&the_controller->lock, flags);
+                       spin_unlock(&vdev->priv_lock);
+                       spin_unlock(&the_controller->lock);
                        usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
                        return -ENOMEM;
                }
@@ -716,10 +704,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
                list_add_tail(&unlink->list, &vdev->unlink_tx);
                wake_up(&vdev->waitq_tx);
 
-               spin_unlock_irqrestore(&vdev->priv_lock, flags2);
+               spin_unlock(&vdev->priv_lock);
        }
 
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
 
        usbip_dbg_vhci_hc("leave\n");
        return 0;
@@ -957,9 +945,9 @@ static int vhci_bus_suspend(struct usb_hcd *hcd)
 
        dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
 
-       spin_lock_irq(&vhci->lock);
+       spin_lock(&vhci->lock);
        hcd->state = HC_STATE_SUSPENDED;
-       spin_unlock_irq(&vhci->lock);
+       spin_unlock(&vhci->lock);
 
        return 0;
 }
@@ -971,13 +959,13 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
 
        dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
 
-       spin_lock_irq(&vhci->lock);
+       spin_lock(&vhci->lock);
        if (!HCD_HW_ACCESSIBLE(hcd)) {
                rc = -ESHUTDOWN;
        } else {
                hcd->state = HC_STATE_RUNNING;
        }
-       spin_unlock_irq(&vhci->lock);
+       spin_unlock(&vhci->lock);
 
        return rc;
 }
index ba5f1c079b69511bb206289a722076e4089ffa3f..faf8e607c5c6166f45a8c351e2ebe8d77b551a16 100644 (file)
@@ -68,7 +68,6 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
 {
        struct usbip_device *ud = &vdev->ud;
        struct urb *urb;
-       unsigned long flags;
 
        spin_lock(&vdev->priv_lock);
        urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
@@ -101,9 +100,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
 
        usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
 
-       spin_lock_irqsave(&the_controller->lock, flags);
+       spin_lock(&the_controller->lock);
        usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
-       spin_unlock_irqrestore(&the_controller->lock, flags);
+       spin_unlock(&the_controller->lock);
 
        usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
 
@@ -141,7 +140,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
 {
        struct vhci_unlink *unlink;
        struct urb *urb;
-       unsigned long flags;
 
        usbip_dump_header(pdu);
 
@@ -171,9 +169,9 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
                urb->status = pdu->u.ret_unlink.status;
                pr_info("urb->status %d\n", urb->status);
 
-               spin_lock_irqsave(&the_controller->lock, flags);
+               spin_lock(&the_controller->lock);
                usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
-               spin_unlock_irqrestore(&the_controller->lock, flags);
+               spin_unlock(&the_controller->lock);
 
                usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
                                     urb->status);
index b1f0dcd68f5592c28dd57997d7604c37ebf409c3..409fd99f3257f94bb7489b0d7aa7d971bf5e303b 100644 (file)
@@ -46,18 +46,17 @@ static void setup_cmd_submit_pdu(struct usbip_header *pdup,  struct urb *urb)
 
 static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev)
 {
-       unsigned long flags;
        struct vhci_priv *priv, *tmp;
 
-       spin_lock_irqsave(&vdev->priv_lock, flags);
+       spin_lock(&vdev->priv_lock);
 
        list_for_each_entry_safe(priv, tmp, &vdev->priv_tx, list) {
                list_move_tail(&priv->list, &vdev->priv_rx);
-               spin_unlock_irqrestore(&vdev->priv_lock, flags);
+               spin_unlock(&vdev->priv_lock);
                return priv;
        }
 
-       spin_unlock_irqrestore(&vdev->priv_lock, flags);
+       spin_unlock(&vdev->priv_lock);
 
        return NULL;
 }
@@ -136,18 +135,17 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
 
 static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev)
 {
-       unsigned long flags;
        struct vhci_unlink *unlink, *tmp;
 
-       spin_lock_irqsave(&vdev->priv_lock, flags);
+       spin_lock(&vdev->priv_lock);
 
        list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
                list_move_tail(&unlink->list, &vdev->unlink_rx);
-               spin_unlock_irqrestore(&vdev->priv_lock, flags);
+               spin_unlock(&vdev->priv_lock);
                return unlink;
        }
 
-       spin_unlock_irqrestore(&vdev->priv_lock, flags);
+       spin_unlock(&vdev->priv_lock);
 
        return NULL;
 }
index d0cab17661906724b1a085d1471056f91176c7b6..8e8bbb1dcd9be54fb915cd0ea064e96979261232 100644 (file)
@@ -6,7 +6,7 @@ config VME_USER
        help
          If you say Y here you want to be able to access a limited number of
          VME windows in a manner at least semi-compatible with the interface
-         provided with the original driver at http://vmelinux.org/.
+         provided with the original driver at <http://www.vmelinux.org/>.
 
 config VME_PIO2
        tristate "GE PIO2 VME"
index 47c156bb70a9ff934c2a624dab5225c7ae5f1c52..aa76e39a46f49e8aed182e8994b5fc8bf059b3d5 100644 (file)
@@ -749,9 +749,9 @@ bool get_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
                unsigned char *pbyChannelNumber, unsigned char *pbyMap)
 {
 
-       if (uChannelIndex > CB_MAX_CHANNEL) {
+       if (uChannelIndex > CB_MAX_CHANNEL)
                return false;
-       }
+
        *pbyChannelNumber = sChannelTbl[uChannelIndex].byChannelNumber;
        *pbyMap = sChannelTbl[uChannelIndex].byMAP;
        return sChannelTbl[uChannelIndex].bValid;
@@ -761,9 +761,9 @@ void set_channel_map_info(void *pDeviceHandler, unsigned int uChannelIndex,
                unsigned char byMap)
 {
 
-       if (uChannelIndex > CB_MAX_CHANNEL) {
+       if (uChannelIndex > CB_MAX_CHANNEL)
                return;
-       }
+
        sChannelTbl[uChannelIndex].byMAP |= byMap;
 }
 
@@ -771,9 +771,8 @@ void clear_channel_map_info(void *pDeviceHandler)
 {
        unsigned int ii = 0;
 
-       for (ii = 1; ii <=  CB_MAX_CHANNEL; ii++) {
+       for (ii = 1; ii <=  CB_MAX_CHANNEL; ii++)
                sChannelTbl[ii].byMAP = 0;
-       }
 }
 
 unsigned char auto_channel_select(void *pDeviceHandler, CARD_PHY_TYPE ePHYType)
index e54e00bc5665c911e62e1d9fdca404b9381cc2e4..e27244ce383e4f92865122027a5753e110ae47f9 100644 (file)
@@ -881,26 +881,14 @@ inline static bool device_get_ip(PSDevice pInfo) {
 
 
 
-static inline PDEVICE_RD_INFO alloc_rd_info(void) {
-    PDEVICE_RD_INFO  ptr;
-    ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC);
-    if (ptr == NULL)
-        return NULL;
-    else {
-        memset(ptr,0,sizeof(DEVICE_RD_INFO));
-        return ptr;
-    }
+static inline PDEVICE_RD_INFO alloc_rd_info(void)
+{
+       return kzalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC);
 }
 
-static inline PDEVICE_TD_INFO alloc_td_info(void) {
-    PDEVICE_TD_INFO  ptr;
-    ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC);
-    if (ptr == NULL)
-        return NULL;
-    else {
-        memset(ptr,0,sizeof(DEVICE_TD_INFO));
-        return ptr;
-    }
+static inline PDEVICE_TD_INFO alloc_td_info(void)
+{
+       return kzalloc(sizeof(DEVICE_TD_INFO), GFP_ATOMIC);
 }
 
 /*---------------------  Export Functions  --------------------------*/
index 875ee4442386c834b96e88b9e70cf9c29ca936ef..d66854f5b304ea27994a421e90d71039fb7fc34a 100644 (file)
@@ -2421,7 +2421,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) {
     pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)(cbMacHdLen << 10));
 
     // Notes:
-    // Although spec says MMPDU can be fragmented; In most case,
+    // 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
 
@@ -2510,7 +2510,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) {
         pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen);
 
         //Fill TXKEY
-        //Kyle: Need fix: TKIP and AES did't encryt Mnt Packet.
+        //Kyle: Need fix: TKIP and AES did't encrypt Mnt Packet.
         //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL);
 
         //Fill IV(ExtIV,RSNHDR)
@@ -2957,7 +2957,7 @@ vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un
     pTxBufHead->wFragCtl |= cpu_to_le16((unsigned short)cbMacHdLen << 10);
 
     // Notes:
-    // Although spec says MMPDU can be fragmented; In most casses,
+    // 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
 
index 6d0b87a14267b66b2e1c92a1f6d0ba91024d48fd..101c7359f414ebfab4147fd52c57121442b6f232 100644 (file)
@@ -720,7 +720,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
                       pDevice->nTxDataTimeCout = 0;
                 }
                 else {
-                  // printk("mike:-->First time triger TimerTxData InSleep\n");
+                  // printk("mike:-->First time trigger TimerTxData InSleep\n");
                 }
                pDevice->IsTxDataTrigger = true;
                 add_timer(&pDevice->sTimerTxData);
index b6f99ecbbeb5b15ccd1052c4c663dfb5a9980b3c..b08a611a184aa80a9bdd647ff7e027cc05acd810 100644 (file)
@@ -2068,7 +2068,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==true)
 
         if (pBSSList != NULL) {
 
-            // Compare PHY paramater setting
+            // Compare PHY parameter setting
             if (pMgmt->wCurrCapInfo != pBSSList->wCapInfo) {
                 bUpdatePhyParameter = true;
                 pMgmt->wCurrCapInfo = pBSSList->wCapInfo;
index e6ced95e6fa7c7b826b667a57b8a2f68b115249c..8221d65ccedcbee9c7ea22ff5bc1a5076f2f552b 100644 (file)
@@ -96,9 +96,10 @@ vMgrEncodeBeacon(
 {
     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
 
-    /* Fixed Fields */
-    pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                                    + WLAN_BEACON_OFF_TS);
+       /* Fixed Fields */
+       pFrame->pqwTimestamp =
+               (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
+                       WLAN_BEACON_OFF_TS);
     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
                                        + WLAN_BEACON_OFF_BCN_INT);
     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
@@ -130,9 +131,10 @@ vMgrDecodeBeacon(
 
     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
 
-    /* Fixed Fields */
-    pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                                    + WLAN_BEACON_OFF_TS);
+       /* Fixed Fields */
+       pFrame->pqwTimestamp =
+               (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
+                       WLAN_BEACON_OFF_TS);
     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
                                        + WLAN_BEACON_OFF_BCN_INT);
     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
@@ -671,9 +673,10 @@ vMgrEncodeProbeResponse(
 {
     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
 
-    /* Fixed Fields */
-    pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                                    + WLAN_PROBERESP_OFF_TS);
+       /* Fixed Fields */
+       pFrame->pqwTimestamp =
+               (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
+                       WLAN_PROBERESP_OFF_TS);
     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
                                        + WLAN_PROBERESP_OFF_BCN_INT);
     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
@@ -706,9 +709,10 @@ vMgrDecodeProbeResponse(
 
     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
 
-    /* Fixed Fields */
-    pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
-                                    + WLAN_PROBERESP_OFF_TS);
+       /* Fixed Fields */
+       pFrame->pqwTimestamp =
+               (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
+                       WLAN_PROBERESP_OFF_TS);
     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
                                        + WLAN_PROBERESP_OFF_BCN_INT);
     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
index e5db73be0e7157162e4ca5052cfed37bbf1de120..29fad08e97ccae4532b21da81f003a3b4d2670f1 100644 (file)
@@ -526,7 +526,7 @@ typedef struct tagWLAN_FR_BEACON {
     PBYTE                   pBuf;
     PUWLAN_80211HDR         pHdr;
     // fixed fields
-    PQWORD                  pqwTimestamp;
+       u64 *pqwTimestamp;
     PWORD                   pwBeaconInterval;
     PWORD                   pwCapInfo;
     /*-- info elements ----------*/
@@ -683,7 +683,7 @@ typedef struct tagWLAN_FR_PROBERESP {
     PBYTE                   pBuf;
     PUWLAN_80211HDR         pHdr;
     /*-- fixed fields -----------*/
-    PQWORD                  pqwTimestamp;
+       u64 *pqwTimestamp;
     PWORD                   pwBeaconInterval;
     PWORD                   pwCapInfo;
     /*-- info elements ----------*/
index 385501595b4dda43277cf80e2cf37af74167dabc..cccd8107627afe24ca69d832ea1cf613bee165de 100644 (file)
@@ -690,7 +690,7 @@ s_vClearSQ3Value(PSDevice pDevice);
  *
  */
 unsigned int
-BBuGetFrameTime (
+BBuGetFrameTime(
      BYTE byPreambleType,
      BYTE byPktType,
      unsigned int cbFrameLength,
@@ -756,23 +756,16 @@ BBuGetFrameTime (
  * Return Value: none
  *
  */
-void
-BBvCalculateParameter (
-      PSDevice pDevice,
-      unsigned int cbFrameLength,
-      WORD wRate,
-      BYTE byPacketType,
-     PWORD pwPhyLen,
-     PBYTE pbyPhySrv,
-     PBYTE pbyPhySgn
-    )
+void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength,
+       u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv,
+               u8 *pbyPhySgn)
 {
-    unsigned int cbBitCount;
-    unsigned int cbUsCount = 0;
-    unsigned int cbTmp;
-    BOOL bExtBit;
-    BYTE byPreambleType = pDevice->byPreambleType;
-    BOOL bCCK = pDevice->bCCK;
+       u32 cbBitCount;
+       u32 cbUsCount = 0;
+       u32 cbTmp;
+       int bExtBit;
+       u8 byPreambleType = pDevice->byPreambleType;
+       int bCCK = pDevice->bCCK;
 
     cbBitCount = cbFrameLength * 8;
     bExtBit = FALSE;
@@ -929,8 +922,7 @@ BBvCalculateParameter (
  * Return Value: none
  *
  */
-void
-BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)
+void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode)
 {
     switch (byAntennaMode) {
         case ANT_TXA:
@@ -968,7 +960,7 @@ BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)
  *
  */
 
-BOOL BBbVT3184Init(PSDevice pDevice)
+int BBbVT3184Init(struct vnt_private *pDevice)
 {
        int ntStatus;
     WORD                    wLength;
@@ -1161,7 +1153,7 @@ else {
  * Return Value: none
  *
  */
-void BBvLoopbackOn (PSDevice pDevice)
+void BBvLoopbackOn(struct vnt_private *pDevice)
 {
     BYTE      byData;
 
@@ -1214,9 +1206,9 @@ void BBvLoopbackOn (PSDevice pDevice)
  * Return Value: none
  *
  */
-void BBvLoopbackOff (PSDevice pDevice)
+void BBvLoopbackOff(struct vnt_private *pDevice)
 {
-    BYTE      byData;
+       u8 byData;
 
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, pDevice->byBBCRc9);//CR201
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, pDevice->byBBCR88);//CR136
@@ -1249,8 +1241,7 @@ void BBvLoopbackOff (PSDevice pDevice)
  * Return Value: none
  *
  */
-void
-BBvSetShortSlotTime (PSDevice pDevice)
+void BBvSetShortSlotTime(struct vnt_private *pDevice)
 {
     BYTE byBBVGA=0;
 
@@ -1267,7 +1258,7 @@ BBvSetShortSlotTime (PSDevice pDevice)
 }
 
 
-void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
+void BBvSetVGAGainOffset(struct vnt_private *pDevice, BYTE byData)
 {
 
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
@@ -1294,8 +1285,7 @@ void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
  * Return Value: none
  *
  */
-void
-BBvSoftwareReset (PSDevice pDevice)
+void BBvSoftwareReset(struct vnt_private *pDevice)
 {
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0x40);
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0);
@@ -1315,22 +1305,20 @@ BBvSoftwareReset (PSDevice pDevice)
  * Return Value: none
  *
  */
-void
-BBvSetDeepSleep (PSDevice pDevice)
+void BBvSetDeepSleep(struct vnt_private *pDevice)
 {
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
 }
 
-void
-BBvExitDeepSleep (PSDevice pDevice)
+void BBvExitDeepSleep(struct vnt_private *pDevice)
 {
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
     ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
 }
 
 
-static unsigned long s_ulGetLowSQ3(PSDevice pDevice)
+static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice)
 {
        int ii;
        unsigned long ulSQ3 = 0;
@@ -1349,7 +1337,7 @@ static unsigned long s_ulGetLowSQ3(PSDevice pDevice)
     return ulSQ3;
 }
 
-static unsigned long s_ulGetRatio(PSDevice pDevice)
+static unsigned long s_ulGetRatio(struct vnt_private *pDevice)
 {
        int ii, jj;
        unsigned long ulRatio = 0;
@@ -1377,9 +1365,7 @@ static unsigned long s_ulGetRatio(PSDevice pDevice)
 }
 
 
-static
-void
-s_vClearSQ3Value (PSDevice pDevice)
+static void s_vClearSQ3Value(struct vnt_private *pDevice)
 {
     int ii;
     pDevice->uDiversityCnt = 0;
@@ -1406,8 +1392,8 @@ s_vClearSQ3Value (PSDevice pDevice)
  *
  */
 
-void
-BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3)
+void BBvAntennaDiversity(struct vnt_private *pDevice,
+       u8 byRxRate, u8 bySQ3)
 {
 
     pDevice->uDiversityCnt++;
@@ -1541,9 +1527,8 @@ BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3)
  *
 -*/
 
-void TimerSQ3CallBack(void *hDeviceContext)
+void TimerSQ3CallBack(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
     spin_lock_irq(&pDevice->lock);
@@ -1579,9 +1564,8 @@ void TimerSQ3CallBack(void *hDeviceContext)
  *
 -*/
 
-void TimerSQ3Tmax3CallBack(void *hDeviceContext)
+void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
     spin_lock_irq(&pDevice->lock);
@@ -1607,10 +1591,7 @@ void TimerSQ3Tmax3CallBack(void *hDeviceContext)
     spin_unlock_irq(&pDevice->lock);
 }
 
-void
-BBvUpdatePreEDThreshold(
-      PSDevice    pDevice,
-      BOOL        bScanning)
+void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
 {
 
 
index 844d5a8b13e5d764b58fb72980352ff39a45202b..df5cf0d434c2e0df8efd86a863bf42328bbf78ac 100644 (file)
@@ -104,33 +104,26 @@ BBuGetFrameTime(
      WORD wRate
     );
 
-void BBvCalculateParameter(PSDevice pDevice,
-                         unsigned int cbFrameLength,
-                         WORD wRate,
-                         BYTE byPacketType,
-                         PWORD pwPhyLen,
-                         PBYTE pbyPhySrv,
-                         PBYTE pbyPhySgn);
+void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength,
+       u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv,
+       u8 *pbyPhySgn);
 
 // timer for antenna diversity
 
-void TimerSQ3CallBack(void *hDeviceContext);
-void TimerSQ3Tmax3CallBack(void *hDeviceContext);
-
-void BBvAntennaDiversity(PSDevice pDevice, BYTE byRxRate, BYTE bySQ3);
-void BBvLoopbackOn(PSDevice pDevice);
-void BBvLoopbackOff(PSDevice pDevice);
-void BBvSoftwareReset(PSDevice pDevice);
-
-void BBvSetShortSlotTime(PSDevice pDevice);
-void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData);
-void BBvSetAntennaMode(PSDevice pDevice, BYTE byAntennaMode);
-BOOL BBbVT3184Init(PSDevice pDevice);
-void BBvSetDeepSleep(PSDevice pDevice);
-void BBvExitDeepSleep(PSDevice pDevice);
-void BBvUpdatePreEDThreshold(
-       PSDevice    pDevice,
-       BOOL        bScanning
-     );
+void TimerSQ3CallBack(struct vnt_private *);
+void TimerSQ3Tmax3CallBack(struct vnt_private *);
+
+void BBvAntennaDiversity(struct vnt_private *, u8 byRxRate, u8 bySQ3);
+void BBvLoopbackOn(struct vnt_private *);
+void BBvLoopbackOff(struct vnt_private *);
+void BBvSoftwareReset(struct vnt_private *);
+
+void BBvSetShortSlotTime(struct vnt_private *);
+void BBvSetVGAGainOffset(struct vnt_private *, u8 byData);
+void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode);
+int BBbVT3184Init(struct vnt_private *);
+void BBvSetDeepSleep(struct vnt_private *);
+void BBvExitDeepSleep(struct vnt_private *);
+void BBvUpdatePreEDThreshold(struct vnt_private *, int bScanning);
 
 #endif /* __BASEBAND_H__ */
index 6a1394192248504ba69a9b5b832870ed999886bf..79339fd6e4ba44e8c08104406c63f7870fddd5d0 100644 (file)
@@ -91,9 +91,9 @@ const WORD             awHWRetry1[5][5] = {
 
 /*---------------------  Static Functions  --------------------------*/
 
-void s_vCheckSensitivity(void *hDeviceContext);
-void s_vCheckPreEDThreshold(void *hDeviceContext);
-void s_uCalculateLinkQual(void *hDeviceContext);
+static void s_vCheckSensitivity(struct vnt_private *pDevice);
+static void s_vCheckPreEDThreshold(struct vnt_private *pDevice);
+static void s_uCalculateLinkQual(struct vnt_private *pDevice);
 
 /*---------------------  Export Variables  --------------------------*/
 
@@ -114,20 +114,19 @@ void s_uCalculateLinkQual(void *hDeviceContext);
  *
 -*/
 
-PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
-                           PBYTE pbyDesireBSSID,
-                           PBYTE pbyDesireSSID,
-                           CARD_PHY_TYPE ePhyType)
+PKnownBSS BSSpSearchBSSList(struct vnt_private *pDevice,
+               u8 *pbyDesireBSSID, u8 *pbyDesireSSID,
+               CARD_PHY_TYPE ePhyType)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PBYTE           pbyBSSID = NULL;
-    PWLAN_IE_SSID   pSSID = NULL;
-    PKnownBSS       pCurrBSS = NULL;
-    PKnownBSS       pSelect = NULL;
-    BYTE                 ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
-    unsigned int ii = 0;
-    unsigned int jj = 0;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 *pbyBSSID = NULL;
+       PWLAN_IE_SSID pSSID = NULL;
+       PKnownBSS pCurrBSS = NULL;
+       PKnownBSS pSelect = NULL;
+       u8 ZeroBSSID[WLAN_BSSID_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+       int ii = 0;
+       int jj = 0;
+
     if (pbyDesireBSSID != NULL) {
                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
                        "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
@@ -240,7 +239,6 @@ pDevice->bSameBSSMaxNum = jj;
             pSelect->bSelected = TRUE;
                         if (pDevice->bRoaming == FALSE)  {
        //       Einsn Add @20070907
-                               memset(pbyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
                        memcpy(pbyDesireSSID,pCurrBSS->abySSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1) ;
                                                 }
 
@@ -263,11 +261,10 @@ pDevice->bSameBSSMaxNum = jj;
 -*/
 
 
-void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID)
+void BSSvClearBSSList(struct vnt_private *pDevice, int bKeepCurrBSSID)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ii;
 
     for (ii = 0; ii < MAX_BSS_NUM; ii++) {
         if (bKeepCurrBSSID) {
@@ -299,14 +296,12 @@ void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID)
  *    TRUE if found.
  *
 -*/
-PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,
-                             PBYTE abyBSSID,
-                             PWLAN_IE_SSID pSSID)
+PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *pDevice,
+       u8 *abyBSSID, PWLAN_IE_SSID pSSID)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PKnownBSS       pBSSList = NULL;
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PKnownBSS pBSSList = NULL;
+       int ii;
 
     for (ii = 0; ii < MAX_BSS_NUM; ii++) {
         pBSSList = &(pMgmt->sBSSList[ii]);
@@ -337,32 +332,30 @@ PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,
  *
 -*/
 
-BOOL BSSbInsertToBSSList(void *hDeviceContext,
-                        PBYTE abyBSSIDAddr,
-                        QWORD qwTimestamp,
-                        WORD wBeaconInterval,
-                        WORD wCapInfo,
-                        BYTE 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,
-                        PBYTE pbyIEs,
-                        void *pRxPacketContext)
+int BSSbInsertToBSSList(struct vnt_private *pDevice,
+                       u8 *abyBSSIDAddr,
+                       u64 qwTimestamp,
+                       u16 wBeaconInterval,
+                       u16 wCapInfo,
+                       u8 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,
+                       u32 uIELength,
+                       u8 *pbyIEs,
+                       void *pRxPacketContext)
 {
-
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PSRxMgmtPacket  pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
-    PKnownBSS       pBSSList = NULL;
-    unsigned int            ii;
-    BOOL            bParsingQuiet = FALSE;
-
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct vnt_rx_mgmt *pRxPacket =
+               (struct vnt_rx_mgmt *)pRxPacketContext;
+       PKnownBSS pBSSList = NULL;
+       unsigned int ii;
+       BOOL bParsingQuiet = FALSE;
 
 
     pBSSList = (PKnownBSS)&(pMgmt->sBSSList[0]);
@@ -380,8 +373,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext,
     // save the BSS info
     pBSSList->bActive = TRUE;
     memcpy( pBSSList->abyBSSID, abyBSSIDAddr, WLAN_BSSID_LEN);
-    HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
-    LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
+       pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp);
     pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
     pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
     pBSSList->uClearCount = 0;
@@ -518,38 +510,38 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext,
 -*/
 // TODO: input structure modify
 
-BOOL BSSbUpdateToBSSList(void *hDeviceContext,
-                        QWORD qwTimestamp,
-                        WORD wBeaconInterval,
-                        WORD wCapInfo,
-                        BYTE 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,
-                        PBYTE pbyIEs,
-                        void *pRxPacketContext)
+int BSSbUpdateToBSSList(struct vnt_private *pDevice,
+                       u64 qwTimestamp,
+                       u16 wBeaconInterval,
+                       u16 wCapInfo,
+                       u8 byCurrChannel,
+                       int 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,
+                       u32 uIELength,
+                       u8 *pbyIEs,
+                       void *pRxPacketContext)
 {
-    int             ii, jj;
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PSRxMgmtPacket  pRxPacket = (PSRxMgmtPacket)pRxPacketContext;
-    signed long            ldBm, ldBmSum;
-    BOOL            bParsingQuiet = FALSE;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct vnt_rx_mgmt *pRxPacket =
+               (struct vnt_rx_mgmt *)pRxPacketContext;
+       int ii, jj;
+       signed long ldBm, ldBmSum;
+       BOOL bParsingQuiet = FALSE;
 
     if (pBSSList == NULL)
         return FALSE;
 
 
-    HIDWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(HIDWORD(qwTimestamp));
-    LODWORD(pBSSList->qwBSSTimestamp) = cpu_to_le32(LODWORD(qwTimestamp));
+       pBSSList->qwBSSTimestamp = cpu_to_le64(qwTimestamp);
+
     pBSSList->wBeaconInterval = cpu_to_le16(wBeaconInterval);
     pBSSList->wCapInfo = cpu_to_le16(wCapInfo);
     pBSSList->uClearCount = 0;
@@ -660,13 +652,11 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext,
  *
 -*/
 
-BOOL BSSbIsSTAInNodeDB(void *hDeviceContext,
-                      PBYTE abyDstAddr,
-                      unsigned int *puNodeIndex)
+int BSSbIsSTAInNodeDB(struct vnt_private *pDevice,
+               u8 *abyDstAddr, u32 *puNodeIndex)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       unsigned int ii;
 
     // Index = 0 reserved for AP Node
     for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) {
@@ -694,15 +684,14 @@ BOOL BSSbIsSTAInNodeDB(void *hDeviceContext,
  *    None
  *
 -*/
-void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex)
+void BSSvCreateOneNode(struct vnt_private *pDevice, u32 *puNodeIndex)
 {
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int            ii;
+       u32 BigestCount = 0;
+       u32 SelectIndex;
+       struct sk_buff  *skb;
 
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    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;
@@ -755,13 +744,11 @@ void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex)
  *
 -*/
 
-void BSSvRemoveOneNode(void *hDeviceContext, unsigned int uNodeIndex)
+void BSSvRemoveOneNode(struct vnt_private *pDevice, u32 uNodeIndex)
 {
-
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    BYTE            byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-    struct sk_buff  *skb;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+       struct sk_buff  *skb;
 
 
     while ((skb = skb_dequeue(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue)) != NULL)
@@ -782,14 +769,11 @@ void BSSvRemoveOneNode(void *hDeviceContext, unsigned int uNodeIndex)
  *
 -*/
 
-void BSSvUpdateAPNode(void *hDeviceContext,
-                     PWORD pwCapInfo,
-                     PWLAN_IE_SUPP_RATES pSuppRates,
-                     PWLAN_IE_SUPP_RATES pExtSuppRates)
+void BSSvUpdateAPNode(struct vnt_private *pDevice, u16 *pwCapInfo,
+       PWLAN_IE_SUPP_RATES pSuppRates, PWLAN_IE_SUPP_RATES pExtSuppRates)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            uRateLen = WLAN_RATES_MAXLEN;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 uRateLen = WLAN_RATES_MAXLEN;
 
     memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
 
@@ -834,10 +818,9 @@ void BSSvUpdateAPNode(void *hDeviceContext,
  *
 -*/
 
-void BSSvAddMulticastNode(void *hDeviceContext)
+void BSSvAddMulticastNode(struct vnt_private *pDevice)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
     if (!pDevice->bEnableHostWEP)
         memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB));
@@ -873,15 +856,14 @@ void BSSvAddMulticastNode(void *hDeviceContext)
  *
 -*/
 
-void BSSvSecondCallBack(void *hDeviceContext)
+void BSSvSecondCallBack(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            ii;
-    PWLAN_IE_SSID   pItemSSID, pCurrSSID;
-    unsigned int            uSleepySTACnt = 0;
-    unsigned int            uNonShortSlotSTACnt = 0;
-    unsigned int            uLongPreambleSTACnt = 0;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ii;
+       PWLAN_IE_SSID pItemSSID, pCurrSSID;
+       u32 uSleepySTACnt = 0;
+       u32 uNonShortSlotSTACnt = 0;
+       u32 uLongPreambleSTACnt = 0;
 
     spin_lock_irq(&pDevice->lock);
 
@@ -927,7 +909,7 @@ if(pDevice->byReAssocCount > 0) {
 
  pMgmt->eLastState = pMgmt->eCurrState ;
 
-   s_uCalculateLinkQual((void *)pDevice);
+       s_uCalculateLinkQual(pDevice);
 
     for (ii = 0; ii < (MAX_NODE_NUM + 1); ii++) {
 
@@ -1067,8 +1049,8 @@ if(pDevice->byReAssocCount > 0) {
         if (pMgmt->sNodeDBTable[0].bActive) { // Assoc with BSS
 
             if (pDevice->bUpdateBBVGA) {
-               /* s_vCheckSensitivity((void *) pDevice); */
-               s_vCheckPreEDThreshold((void *) pDevice);
+               s_vCheckSensitivity(pDevice);
+               s_vCheckPreEDThreshold(pDevice);
             }
 
            if ((pMgmt->sNodeDBTable[0].uInActiveCount >= (LOST_BEACON_COUNT/2)) &&
@@ -1169,8 +1151,8 @@ else {
         if (pMgmt->eCurrState == WMAC_STATE_JOINTED) {
 
                if (pDevice->bUpdateBBVGA) {
-                       /* s_vCheckSensitivity((void *) pDevice); */
-                       s_vCheckPreEDThreshold((void *) pDevice);
+                       s_vCheckSensitivity(pDevice);
+                       s_vCheckPreEDThreshold(pDevice);
                }
                if (pMgmt->sNodeDBTable[0].uInActiveCount >=ADHOC_LOST_BEACON_COUNT) {
                    DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "Lost other STA beacon [%d] sec, started !\n", pMgmt->sNodeDBTable[0].uInActiveCount);
@@ -1207,22 +1189,19 @@ else {
  *
 -*/
 
-void BSSvUpdateNodeTxCounter(void *hDeviceContext,
-                            PSStatCounter pStatistic,
-                            BYTE byTSR,
-                            BYTE byPktNO)
+void BSSvUpdateNodeTxCounter(struct vnt_private *pDevice,
+       PSStatCounter pStatistic, u8 byTSR, u8 byPktNO)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            uNodeIndex = 0;
-    BYTE            byTxRetry;
-    WORD            wRate;
-    WORD            wFallBackRate = RATE_1M;
-    BYTE            byFallBack;
-    unsigned int            ii;
-    PBYTE           pbyDestAddr;
-    BYTE            byPktNum;
-    WORD            wFIFOCtl;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 uNodeIndex = 0;
+       u8 byTxRetry;
+       u16 wRate;
+       u16 wFallBackRate = RATE_1M;
+       u8 byFallBack;
+       int ii;
+       u8 *pbyDestAddr;
+       u8 byPktNum;
+       u16 wFIFOCtl;
 
     byPktNum = (byPktNO & 0x0F) >> 4;
     byTxRetry = (byTSR & 0xF0) >> 4;
@@ -1370,13 +1349,11 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext,
  *
 -*/
 
-void BSSvClearNodeDBTable(void *hDeviceContext,
-                         unsigned int uStartIndex)
+void BSSvClearNodeDBTable(struct vnt_private *pDevice, u32 uStartIndex)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    struct sk_buff  *skb;
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct sk_buff  *skb;
+       int ii;
 
     for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) {
         if (pMgmt->sNodeDBTable[ii].bActive) {
@@ -1392,12 +1369,11 @@ void BSSvClearNodeDBTable(void *hDeviceContext,
     }
 };
 
-void s_vCheckSensitivity(void *hDeviceContext)
+static void s_vCheckSensitivity(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PKnownBSS       pBSSList = NULL;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    int             ii;
+       PKnownBSS pBSSList = NULL;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ii;
 
     if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
         ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
@@ -1424,7 +1400,7 @@ void s_vCheckSensitivity(void *hDeviceContext)
                 if (pDevice->byBBVGANew != pDevice->byBBVGACurrent) {
                     pDevice->uBBVGADiffCount++;
                     if (pDevice->uBBVGADiffCount >= BB_VGA_CHANGE_THRESHOLD)
-                       bScheduleCommand((void *) pDevice,
+                       bScheduleCommand(pDevice,
                                         WLAN_CMD_CHANGE_BBSENSITIVITY,
                                         NULL);
                 } else {
@@ -1435,13 +1411,12 @@ void s_vCheckSensitivity(void *hDeviceContext)
     }
 }
 
-void s_uCalculateLinkQual(void *hDeviceContext)
+static void s_uCalculateLinkQual(struct vnt_private *pDevice)
 {
-   PSDevice        pDevice = (PSDevice)hDeviceContext;
-   unsigned long TxOkRatio, TxCnt;
-   unsigned long RxOkRatio, RxCnt;
-   unsigned long RssiRatio;
-   long ldBm;
+       unsigned long TxOkRatio, TxCnt;
+       unsigned long RxOkRatio, RxCnt;
+       unsigned long RssiRatio;
+       long ldBm;
 
 TxCnt = pDevice->scStatistic.TxNoRetryOkCount +
              pDevice->scStatistic.TxRetryOkCount +
@@ -1478,21 +1453,21 @@ else
    pDevice->scStatistic.TxRetryOkCount = 0;
 }
 
-void BSSvClearAnyBSSJoinRecord(void *hDeviceContext)
+void BSSvClearAnyBSSJoinRecord(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ii;
 
        for (ii = 0; ii < MAX_BSS_NUM; ii++)
-        pMgmt->sBSSList[ii].bSelected = FALSE;
+               pMgmt->sBSSList[ii].bSelected = FALSE;
+
+       return;
 }
 
-void s_vCheckPreEDThreshold(void *hDeviceContext)
+static void s_vCheckPreEDThreshold(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PKnownBSS       pBSSList = NULL;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       PKnownBSS pBSSList = NULL;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
     if ((pMgmt->eCurrState == WMAC_STATE_ASSOC) ||
         ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) && (pMgmt->eCurrState == WMAC_STATE_JOINTED))) {
index 806cbf72fb59b6f58eb1419d98af755475fed311..9ee37b9ede3cc961f3e317856d74e3a1f92fa0e8 100644 (file)
@@ -141,8 +141,8 @@ typedef struct tagKnownBSS {
     unsigned int            uClearCount;
 //    BYTE            abyIEs[WLAN_BEACON_FR_MAXLEN];
     unsigned int            uIELength;
-    QWORD           qwBSSTimestamp;
-    QWORD           qwLocalTSF;     // local TSF timer
+       u64 qwBSSTimestamp;
+       u64 qwLocalTSF;/* local TSF timer */
 
     CARD_PHY_TYPE   eNetworkTypeInUse;
 
@@ -225,80 +225,70 @@ typedef struct tagKnownNodeDB {
 
 /*---------------------  Export Functions  --------------------------*/
 
-PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
-                           PBYTE pbyDesireBSSID,
-                           PBYTE pbyDesireSSID,
-                           CARD_PHY_TYPE ePhyType);
-
-PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,
-                             PBYTE abyBSSID,
-                             PWLAN_IE_SSID pSSID);
-
-void BSSvClearBSSList(void *hDeviceContext, BOOL bKeepCurrBSSID);
-
-BOOL BSSbInsertToBSSList(void *hDeviceContext,
-                        PBYTE abyBSSIDAddr,
-                        QWORD qwTimestamp,
-                        WORD wBeaconInterval,
-                        WORD wCapInfo,
-                        BYTE 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,
-                        PBYTE pbyIEs,
-                        void *pRxPacketContext);
-
-BOOL BSSbUpdateToBSSList(void *hDeviceContext,
-                        QWORD qwTimestamp,
-                        WORD wBeaconInterval,
-                        WORD wCapInfo,
-                        BYTE 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,
-                        PBYTE pbyIEs,
-                        void *pRxPacketContext);
-
-BOOL BSSbIsSTAInNodeDB(void *hDeviceContext,
-                      PBYTE abyDstAddr,
-                      unsigned int *puNodeIndex);
-
-void BSSvCreateOneNode(void *hDeviceContext, unsigned int *puNodeIndex);
-
-void BSSvUpdateAPNode(void *hDeviceContext,
-                     PWORD pwCapInfo,
-                     PWLAN_IE_SUPP_RATES pItemRates,
-                     PWLAN_IE_SUPP_RATES pExtSuppRates);
-
-void BSSvSecondCallBack(void *hDeviceContext);
-
-void BSSvUpdateNodeTxCounter(void *hDeviceContext,
-                            PSStatCounter pStatistic,
-                            BYTE byTSR,
-                            BYTE byPktNO);
-
-void BSSvRemoveOneNode(void *hDeviceContext,
-                      unsigned int uNodeIndex);
-
-void BSSvAddMulticastNode(void *hDeviceContext);
-
-void BSSvClearNodeDBTable(void *hDeviceContext,
-                         unsigned int uStartIndex);
-
-void BSSvClearAnyBSSJoinRecord(void *hDeviceContext);
+PKnownBSS BSSpSearchBSSList(struct vnt_private *, u8 *pbyDesireBSSID,
+       u8 *pbyDesireSSID, CARD_PHY_TYPE ePhyType);
+
+PKnownBSS BSSpAddrIsInBSSList(struct vnt_private *, u8 *abyBSSID,
+       PWLAN_IE_SSID pSSID);
+
+void BSSvClearBSSList(struct vnt_private *, int bKeepCurrBSSID);
+
+int BSSbInsertToBSSList(struct vnt_private *,
+                       u8 *abyBSSIDAddr,
+                       u64 qwTimestamp,
+                       u16 wBeaconInterval,
+                       u16 wCapInfo,
+                       u8 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,
+                       u32 uIELength,
+                       u8 *pbyIEs,
+                       void *pRxPacketContext);
+
+int BSSbUpdateToBSSList(struct vnt_private *,
+                       u64 qwTimestamp,
+                       u16 wBeaconInterval,
+                       u16 wCapInfo,
+                       u8 byCurrChannel,
+                       int 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,
+                       u32 uIELength,
+                       u8 *pbyIEs,
+                       void *pRxPacketContext);
+
+int BSSbIsSTAInNodeDB(struct vnt_private *, PBYTE abyDstAddr,
+       u32 *puNodeIndex);
+
+void BSSvCreateOneNode(struct vnt_private *, u32 *puNodeIndex);
+
+void BSSvUpdateAPNode(struct vnt_private *, u16 *pwCapInfo,
+       PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates);
+
+void BSSvSecondCallBack(struct vnt_private *);
+
+void BSSvUpdateNodeTxCounter(struct vnt_private *, PSStatCounter pStatistic,
+       u8 byTSR, u8 byPktNO);
+
+void BSSvRemoveOneNode(struct vnt_private *, u32 uNodeIndex);
+
+void BSSvAddMulticastNode(struct vnt_private *);
+
+void BSSvClearNodeDBTable(struct vnt_private *, u32 uStartIndex);
+
+void BSSvClearAnyBSSJoinRecord(struct vnt_private *);
 
 #endif /* __BSSDB_H__ */
index 826520b03383af4322338154016b1a3276c76e0c..7d725bb1c683330abeb1e4c036156476a0b1b3d5 100644 (file)
@@ -45,6 +45,7 @@
  *
  */
 
+#include "device.h"
 #include "tmacro.h"
 #include "card.h"
 #include "baseband.h"
@@ -91,9 +92,8 @@ const WORD cwRXBCNTSFOff[MAX_RATE] =
  *  Out:
  *      none
  */
-void CARDbSetMediaChannel(void *pDeviceHandler, unsigned int uConnectionChannel)
+void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel)
 {
-PSDevice            pDevice = (PSDevice) pDeviceHandler;
 
     if (pDevice->byBBType == BB_TYPE_11A) { // 15 ~ 38
         if ((uConnectionChannel < (CB_MAX_CHANNEL_24G+1)) || (uConnectionChannel > CB_MAX_CHANNEL))
@@ -149,17 +149,17 @@ PSDevice            pDevice = (PSDevice) pDeviceHandler;
  * Return Value: response Control frame rate
  *
  */
-static WORD swGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx)
+static u16 swGetCCKControlRate(struct vnt_private *pDevice, u16 wRateIdx)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    unsigned int ui = (unsigned int)wRateIdx;
-    while (ui > RATE_1M) {
-        if (pDevice->wBasicRate & ((WORD)1 << ui)) {
-            return (WORD)ui;
-        }
-        ui --;
-    }
-    return (WORD)RATE_1M;
+       u16 ui = wRateIdx;
+
+       while (ui > RATE_1M) {
+               if (pDevice->wBasicRate & (1 << ui))
+                       return ui;
+               ui--;
+       }
+
+       return RATE_1M;
 }
 
 /*
@@ -175,28 +175,33 @@ static WORD swGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx)
  * Return Value: response Control frame rate
  *
  */
-static WORD swGetOFDMControlRate(void *pDeviceHandler, WORD wRateIdx)
+static u16 swGetOFDMControlRate(struct vnt_private *pDevice, u16 wRateIdx)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    unsigned int ui = (unsigned int)wRateIdx;
-
-    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate);
-
-    if (!CARDbIsOFDMinBasicRate(pDevice)) {
-        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
-        if (wRateIdx > RATE_24M)
-            wRateIdx = RATE_24M;
-        return wRateIdx;
-    }
-    while (ui > RATE_11M) {
-        if (pDevice->wBasicRate & ((WORD)1 << ui)) {
-            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate : %d\n", ui);
-            return (WORD)ui;
-        }
-        ui --;
-    }
-    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
-    return (WORD)RATE_24M;
+       u16 ui = wRateIdx;
+
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n",
+               pDevice->wBasicRate);
+
+       if (!CARDbIsOFDMinBasicRate(pDevice)) {
+               DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+                       "swGetOFDMControlRate:(NO OFDM) %d\n", wRateIdx);
+       if (wRateIdx > RATE_24M)
+               wRateIdx = RATE_24M;
+               return wRateIdx;
+       }
+
+       while (ui > RATE_11M) {
+               if (pDevice->wBasicRate & (1 << ui)) {
+                       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+                               "swGetOFDMControlRate: %d\n", ui);
+                       return ui;
+               }
+               ui--;
+       }
+
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"swGetOFDMControlRate: 6M\n");
+
+       return RATE_24M;
 }
 
 /*
@@ -325,16 +330,15 @@ CARDvCalculateOFDMRParameter (
  * Return Value: None.
  *
  */
-void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType)
+void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    BYTE    abyServ[4] = {0,0,0,0};             // For CCK
-    BYTE    abySignal[4] = {0,0,0,0};
-    WORD    awLen[4] = {0,0,0,0};
-    BYTE    abyTxRate[9] = {0,0,0,0,0,0,0,0,0}; // For OFDM
-    BYTE    abyRsvTime[9] = {0,0,0,0,0,0,0,0,0};
-    BYTE    abyData[34];
-    int     i;
+       u8 abyServ[4] = {0, 0, 0, 0}; /* For CCK */
+       u8 abySignal[4] = {0, 0, 0, 0};
+       u16 awLen[4] = {0, 0, 0, 0};
+       u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */
+       u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+       u8 abyData[34];
+       int i;
 
     //RSPINF_b_1
     BBvCalculateParameter(pDevice,
@@ -476,12 +480,10 @@ void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType)
  * Return Value: None.
  *
  */
-void vUpdateIFS(void *pDeviceHandler)
+void vUpdateIFS(struct vnt_private *pDevice)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    //Set SIFS, DIFS, EIFS, SlotTime, CwMin
-    BYTE byMaxMin = 0;
-    BYTE byData[4];
+       u8 byMaxMin = 0;
+       u8 byData[4];
 
     if (pDevice->byPacketType==PK_TYPE_11A) {//0000 0000 0000 0000,11a
         pDevice->uSlot = C_SLOT_SHORT;
@@ -511,7 +513,7 @@ void vUpdateIFS(void *pDeviceHandler)
         }
         pDevice->uDIFS = C_SIFS_BG + 2*pDevice->uSlot;
 
-        pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrSuppRates;
+       pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt.abyCurrSuppRates;
         for (ii = 0; ii < pItemRates->len; ii++) {
             byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
             if (RATEwGetRateIdx(byRate) > RATE_11M) {
@@ -520,7 +522,8 @@ void vUpdateIFS(void *pDeviceHandler)
             }
         }
         if (bOFDMRate == FALSE) {
-            pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->sMgmtObj.abyCurrExtSuppRates;
+               pItemRates = (PWLAN_IE_SUPP_RATES)pDevice->vnt_mgmt
+                       .abyCurrExtSuppRates;
             for (ii = 0; ii < pItemRates->len; ii++) {
                 byRate = (BYTE)(pItemRates->abyRates[ii]&0x7F);
                 if (RATEwGetRateIdx(byRate) > RATE_11M) {
@@ -561,11 +564,10 @@ void vUpdateIFS(void *pDeviceHandler)
                         &byMaxMin);
 }
 
-void CARDvUpdateBasicTopRate(void *pDeviceHandler)
+void CARDvUpdateBasicTopRate(struct vnt_private *pDevice)
 {
-PSDevice    pDevice = (PSDevice) pDeviceHandler;
-BYTE byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
-BYTE ii;
+       u8 byTopOFDM = RATE_24M, byTopCCK = RATE_1M;
+       u8 ii;
 
      //Determines the highest basic rate.
      for (ii = RATE_54M; ii >= RATE_6M; ii --) {
@@ -600,10 +602,9 @@ BYTE ii;
  * Return Value: TRUE if succeeded; FALSE if failed.
  *
  */
-void CARDbAddBasicRate(void *pDeviceHandler, WORD wRateIdx)
+void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx)
 {
-PSDevice    pDevice = (PSDevice) pDeviceHandler;
-WORD wRate = (WORD)(1<<wRateIdx);
+       u16 wRate = (1 << wRateIdx);
 
     pDevice->wBasicRate |= wRate;
 
@@ -611,10 +612,9 @@ WORD wRate = (WORD)(1<<wRateIdx);
     CARDvUpdateBasicTopRate(pDevice);
 }
 
-BOOL CARDbIsOFDMinBasicRate(void *pDeviceHandler)
+int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice)
 {
-PSDevice    pDevice = (PSDevice) pDeviceHandler;
-int ii;
+       int ii;
 
     for (ii = RATE_54M; ii >= RATE_6M; ii --) {
         if ((pDevice->wBasicRate) & ((WORD)(1<<ii)))
@@ -623,9 +623,8 @@ int ii;
     return FALSE;
 }
 
-BYTE CARDbyGetPktType(void *pDeviceHandler)
+u8 CARDbyGetPktType(struct vnt_private *pDevice)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
 
     if (pDevice->byBBType == BB_TYPE_11A || pDevice->byBBType == BB_TYPE_11B) {
         return (BYTE)pDevice->byBBType;
@@ -654,28 +653,18 @@ BYTE CARDbyGetPktType(void *pDeviceHandler)
  * Return Value: TSF Offset value
  *
  */
-QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
+u64 CARDqGetTSFOffset(BYTE byRxRate, u64 qwTSF1, u64 qwTSF2)
 {
-    QWORD   qwTSFOffset;
-    WORD    wRxBcnTSFOffst = 0;
+       u64 qwTSFOffset = 0;
+       WORD wRxBcnTSFOffst = 0;
 
-    HIDWORD(qwTSFOffset) = 0;
-    LODWORD(qwTSFOffset) = 0;
+       wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate % MAX_RATE];
 
-    wRxBcnTSFOffst = cwRXBCNTSFOff[byRxRate%MAX_RATE];
-    (qwTSF2).u.dwLowDword += (DWORD)(wRxBcnTSFOffst);
-    if ((qwTSF2).u.dwLowDword < (DWORD)(wRxBcnTSFOffst)) {
-        (qwTSF2).u.dwHighDword++;
-    }
-    LODWORD(qwTSFOffset) = LODWORD(qwTSF1) - LODWORD(qwTSF2);
-    if (LODWORD(qwTSF1) < LODWORD(qwTSF2)) {
-        // if borrow needed
-        HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2) - 1 ;
-    }
-    else {
-        HIDWORD(qwTSFOffset) = HIDWORD(qwTSF1) - HIDWORD(qwTSF2);
-    };
-    return (qwTSFOffset);
+       qwTSF2 += (u64)wRxBcnTSFOffst;
+
+       qwTSFOffset = qwTSF1 - qwTSF2;
+
+       return qwTSFOffset;
 }
 
 
@@ -695,33 +684,25 @@ QWORD CARDqGetTSFOffset (BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2)
  * Return Value: none
  *
  */
-void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate,
-                   QWORD qwBSSTimestamp, QWORD qwLocalTSF)
+void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate,
+               u64 qwBSSTimestamp, u64 qwLocalTSF)
 {
+       u64 qwTSFOffset = 0;
+       u8 pbyData[8];
 
-    PSDevice        pDevice = (PSDevice) pDeviceHandler;
-    QWORD           qwTSFOffset;
-    DWORD           dwTSFOffset1,dwTSFOffset2;
-    BYTE            pbyData[8];
-
-    HIDWORD(qwTSFOffset) = 0;
-    LODWORD(qwTSFOffset) = 0;
 
     qwTSFOffset = CARDqGetTSFOffset(byRxRate, qwBSSTimestamp, qwLocalTSF);
     // adjust TSF
     // HW's TSF add TSF Offset reg
-    dwTSFOffset1 = LODWORD(qwTSFOffset);
-    dwTSFOffset2 = HIDWORD(qwTSFOffset);
 
-
-    pbyData[0] = (BYTE)dwTSFOffset1;
-    pbyData[1] = (BYTE)(dwTSFOffset1>>8);
-    pbyData[2] = (BYTE)(dwTSFOffset1>>16);
-    pbyData[3] = (BYTE)(dwTSFOffset1>>24);
-    pbyData[4] = (BYTE)dwTSFOffset2;
-    pbyData[5] = (BYTE)(dwTSFOffset2>>8);
-    pbyData[6] = (BYTE)(dwTSFOffset2>>16);
-    pbyData[7] = (BYTE)(dwTSFOffset2>>24);
+       pbyData[0] = (u8)qwTSFOffset;
+       pbyData[1] = (u8)(qwTSFOffset >> 8);
+       pbyData[2] = (u8)(qwTSFOffset >> 16);
+       pbyData[3] = (u8)(qwTSFOffset >> 24);
+       pbyData[4] = (u8)(qwTSFOffset >> 32);
+       pbyData[5] = (u8)(qwTSFOffset >> 40);
+       pbyData[6] = (u8)(qwTSFOffset >> 48);
+       pbyData[7] = (u8)(qwTSFOffset >> 56);
 
     CONTROLnsRequestOut(pDevice,
                         MESSAGE_TYPE_SET_TSFTBTT,
@@ -745,14 +726,12 @@ void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate,
  * Return Value: TRUE if success; otherwise FALSE
  *
  */
-BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF)
+int CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
 
-    LODWORD(*pqwCurrTSF) = LODWORD(pDevice->qwCurrTSF);
-    HIDWORD(*pqwCurrTSF) = HIDWORD(pDevice->qwCurrTSF);
+       *pqwCurrTSF = pDevice->qwCurrTSF;
 
-    return(TRUE);
+       return TRUE;
 }
 
 
@@ -767,16 +746,14 @@ BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF)
  * Return Value: TRUE if success; otherwise FALSE
  *
  */
-BOOL CARDbClearCurrentTSF(void *pDeviceHandler)
+int CARDbClearCurrentTSF(struct vnt_private *pDevice)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
 
-    MACvRegBitsOn(pDevice,MAC_REG_TFTCTL,TFTCTL_TSFCNTRST);
+       MACvRegBitsOn(pDevice, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
 
-    LODWORD(pDevice->qwCurrTSF) = 0;
-    HIDWORD(pDevice->qwCurrTSF) = 0;
+       pDevice->qwCurrTSF = 0;
 
-    return(TRUE);
+       return TRUE;
 }
 
 /*
@@ -793,7 +770,7 @@ BOOL CARDbClearCurrentTSF(void *pDeviceHandler)
  * Return Value: TSF value of next Beacon
  *
  */
-QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
+u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval)
 {
 
     unsigned int    uLowNextTBTT;
@@ -802,18 +779,19 @@ QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
 
     uBeaconInterval = wBeaconInterval * 1024;
     // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval
-    uLowNextTBTT = (LODWORD(qwTSF) >> 10) << 10;
-    uLowRemain = (uLowNextTBTT) % uBeaconInterval;
-    uHighRemain = ((0x80000000 % uBeaconInterval)* 2 * HIDWORD(qwTSF))
-                  % uBeaconInterval;
-    uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
-    uLowRemain = uBeaconInterval - uLowRemain;
+       uLowNextTBTT = ((qwTSF & 0xffffffffU) >> 10) << 10;
+       uLowRemain = (uLowNextTBTT) % uBeaconInterval;
+       uHighRemain = ((0x80000000 % uBeaconInterval) * 2 * (u32)(qwTSF >> 32))
+               % uBeaconInterval;
+       uLowRemain = (uHighRemain + uLowRemain) % uBeaconInterval;
+       uLowRemain = uBeaconInterval - uLowRemain;
 
     // check if carry when add one beacon interval
-    if ((~uLowNextTBTT) < uLowRemain)
-        HIDWORD(qwTSF) ++ ;
+       if ((~uLowNextTBTT) < uLowRemain)
+               qwTSF = ((qwTSF >> 32) + 1) << 32;
 
-    LODWORD(qwTSF) = uLowNextTBTT + uLowRemain;
+       qwTSF = (qwTSF & 0xffffffff00000000U) |
+               (u64)(uLowNextTBTT + uLowRemain);
 
     return (qwTSF);
 }
@@ -833,32 +811,24 @@ QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval)
  * Return Value: none
  *
  */
-void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval)
+void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, WORD wBeaconInterval)
 {
+       u64 qwNextTBTT = 0;
+       u8 pbyData[8];
 
-    PSDevice        pDevice = (PSDevice) pDeviceHandler;
-    QWORD           qwNextTBTT;
-    DWORD           dwLoTBTT,dwHiTBTT;
-    BYTE            pbyData[8];
-
-    HIDWORD(qwNextTBTT) = 0;
-    LODWORD(qwNextTBTT) = 0;
-    CARDbClearCurrentTSF(pDevice);
+       CARDbClearCurrentTSF(pDevice);
     //CARDbGetCurrentTSF(pDevice, &qwNextTBTT); //Get Local TSF counter
-    qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
+       qwNextTBTT = CARDqGetNextTBTT(qwNextTBTT, wBeaconInterval);
     // Set NextTBTT
 
-    dwLoTBTT = LODWORD(qwNextTBTT);
-    dwHiTBTT = HIDWORD(qwNextTBTT);
-
-    pbyData[0] = (BYTE)dwLoTBTT;
-    pbyData[1] = (BYTE)(dwLoTBTT>>8);
-    pbyData[2] = (BYTE)(dwLoTBTT>>16);
-    pbyData[3] = (BYTE)(dwLoTBTT>>24);
-    pbyData[4] = (BYTE)dwHiTBTT;
-    pbyData[5] = (BYTE)(dwHiTBTT>>8);
-    pbyData[6] = (BYTE)(dwHiTBTT>>16);
-    pbyData[7] = (BYTE)(dwHiTBTT>>24);
+       pbyData[0] = (u8)qwNextTBTT;
+       pbyData[1] = (u8)(qwNextTBTT >> 8);
+       pbyData[2] = (u8)(qwNextTBTT >> 16);
+       pbyData[3] = (u8)(qwNextTBTT >> 24);
+       pbyData[4] = (u8)(qwNextTBTT >> 32);
+       pbyData[5] = (u8)(qwNextTBTT >> 40);
+       pbyData[6] = (u8)(qwNextTBTT >> 48);
+       pbyData[7] = (u8)(qwNextTBTT >> 56);
 
     CONTROLnsRequestOut(pDevice,
                         MESSAGE_TYPE_SET_TSFTBTT,
@@ -887,27 +857,23 @@ void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval)
  * Return Value: none
  *
  */
-void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF,
-                        WORD wBeaconInterval)
+void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF,
+                       u16 wBeaconInterval)
 {
-    PSDevice        pDevice = (PSDevice) pDeviceHandler;
-    DWORD           dwLoTBTT,dwHiTBTT;
-    BYTE            pbyData[8];
+       u8 pbyData[8];
 
     qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
 
     // Set NextTBTT
-    dwLoTBTT = LODWORD(qwTSF);
-    dwHiTBTT = HIDWORD(qwTSF);
-
-    pbyData[0] = (BYTE)dwLoTBTT;
-    pbyData[1] = (BYTE)(dwLoTBTT>>8);
-    pbyData[2] = (BYTE)(dwLoTBTT>>16);
-    pbyData[3] = (BYTE)(dwLoTBTT>>24);
-    pbyData[4] = (BYTE)dwHiTBTT;
-    pbyData[5] = (BYTE)(dwHiTBTT>>8);
-    pbyData[6] = (BYTE)(dwHiTBTT>>16);
-    pbyData[7] = (BYTE)(dwHiTBTT>>24);
+
+       pbyData[0] = (u8)qwTSF;
+       pbyData[1] = (u8)(qwTSF >> 8);
+       pbyData[2] = (u8)(qwTSF >> 16);
+       pbyData[3] = (u8)(qwTSF >> 24);
+       pbyData[4] = (u8)(qwTSF >> 32);
+       pbyData[5] = (u8)(qwTSF >> 40);
+       pbyData[6] = (u8)(qwTSF >> 48);
+       pbyData[7] = (u8)(qwTSF >> 56);
 
     CONTROLnsRequestOut(pDevice,
                         MESSAGE_TYPE_SET_TSFTBTT,
@@ -918,7 +884,8 @@ void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF,
                         );
 
 
-    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(int)HIDWORD(qwTSF), (int)LODWORD(qwTSF));
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+               "Card:Update Next TBTT[%8lx]\n", (unsigned long)qwTSF);
 
     return;
 }
@@ -935,10 +902,9 @@ void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF,
  * Return Value: TRUE if success; otherwise FALSE
  *
  */
-BOOL CARDbRadioPowerOff(void *pDeviceHandler)
+int CARDbRadioPowerOff(struct vnt_private *pDevice)
 {
-PSDevice    pDevice = (PSDevice) pDeviceHandler;
-BOOL bResult = TRUE;
+       int bResult = TRUE;
 
     //if (pDevice->bRadioOff == TRUE)
     //    return TRUE;
@@ -976,11 +942,9 @@ BOOL bResult = TRUE;
  * Return Value: TRUE if success; otherwise FALSE
  *
  */
-BOOL CARDbRadioPowerOn(void *pDeviceHandler)
+int CARDbRadioPowerOn(struct vnt_private *pDevice)
 {
-PSDevice    pDevice = (PSDevice) pDeviceHandler;
-BOOL bResult = TRUE;
-
+       int bResult = TRUE;
 
     if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
         return FALSE;
@@ -1009,9 +973,8 @@ BOOL bResult = TRUE;
     return bResult;
 }
 
-void CARDvSetBSSMode(void *pDeviceHandler)
+void CARDvSetBSSMode(struct vnt_private *pDevice)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
     // Set BB and packet type at the same time.//{{RobertYu:20050222, AL7230 have two TX PA output, only connet to b/g now
     // so in 11a mode need to set the MAC Reg0x4C to 11b/g mode to turn on PA
     if( (pDevice->byRFType == RF_AIROHA7230 ) && (pDevice->byBBType == BB_TYPE_11A) )
@@ -1068,23 +1031,16 @@ void CARDvSetBSSMode(void *pDeviceHandler)
  * Return Value: none.
  *
 -*/
-BOOL
-CARDbChannelSwitch (
-     void *pDeviceHandler,
-     BYTE             byMode,
-     BYTE             byNewChannel,
-     BYTE             byCount
-    )
+int CARDbChannelSwitch(struct vnt_private *pDevice, u8 byMode,
+       u8 byNewChannel, u8 byCount)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    BOOL        bResult = TRUE;
+       int bResult = TRUE;
 
-    if (byCount == 0) {
-        pDevice->sMgmtObj.uCurrChannel = byNewChannel;
-       CARDbSetMediaChannel(pDevice, byNewChannel);
-
-       return bResult;
-    }
+       if (byCount == 0) {
+               pDevice->vnt_mgmt.uCurrChannel = byNewChannel;
+               CARDbSetMediaChannel(pDevice, byNewChannel);
+               return bResult;
+       }
     pDevice->byChannelSwitchCount = byCount;
     pDevice->byNewChannel = byNewChannel;
     pDevice->bChannelSwitch = TRUE;
index 55962b1988317f4aea1fdb52d9ede78d31ae18d8..720643f4fcc2bf7ef367abf17cfb54533f73534a 100644 (file)
@@ -28,7 +28,7 @@
 
 #ifndef __CARD_H__
 #define __CARD_H__
-
+#include "device.h"
 #include "ttype.h"
 
 /*---------------------  Export Definitions -------------------------*/
@@ -58,31 +58,28 @@ typedef enum _CARD_OP_MODE {
 /*---------------------  Export Variables  --------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
+struct vnt_private;
 
-void CARDbSetMediaChannel(void *pDeviceHandler,
-                         unsigned int uConnectionChannel);
-void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType);
-void vUpdateIFS(void *pDeviceHandler);
-void CARDvUpdateBasicTopRate(void *pDeviceHandler);
-void CARDbAddBasicRate(void *pDeviceHandler, WORD wRateIdx);
-BOOL CARDbIsOFDMinBasicRate(void *pDeviceHandler);
-void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate,
-                   QWORD qwBSSTimestamp, QWORD qwLocalTSF);
-BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF);
-BOOL CARDbClearCurrentTSF(void *pDeviceHandler);
-void CARDvSetFirstNextTBTT(void *pDeviceHandler, WORD wBeaconInterval);
-void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF,
+void CARDbSetMediaChannel(struct vnt_private *pDevice, u32 uConnectionChannel);
+void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType);
+void vUpdateIFS(struct vnt_private *pDevice);
+void CARDvUpdateBasicTopRate(struct vnt_private *pDevice);
+void CARDbAddBasicRate(struct vnt_private *pDevice, u16 wRateIdx);
+int CARDbIsOFDMinBasicRate(struct vnt_private *pDevice);
+void CARDvAdjustTSF(struct vnt_private *pDevice, u8 byRxRate,
+               u64 qwBSSTimestamp, u64 qwLocalTSF);
+BOOL CARDbGetCurrentTSF(struct vnt_private *pDevice, u64 *pqwCurrTSF);
+BOOL CARDbClearCurrentTSF(struct vnt_private *pDevice);
+void CARDvSetFirstNextTBTT(struct vnt_private *pDevice, WORD wBeaconInterval);
+void CARDvUpdateNextTBTT(struct vnt_private *pDevice, u64 qwTSF,
                         WORD wBeaconInterval);
-QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval);
-QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2);
-BOOL CARDbRadioPowerOff(void *pDeviceHandler);
-BOOL CARDbRadioPowerOn(void *pDeviceHandler);
-BYTE CARDbyGetPktType(void *pDeviceHandler);
-void CARDvSetBSSMode(void *pDeviceHandler);
-
-BOOL CARDbChannelSwitch(void *pDeviceHandler,
-                       BYTE byMode,
-                       BYTE byNewChannel,
-                       BYTE byCount);
+u64 CARDqGetNextTBTT(u64 qwTSF, WORD wBeaconInterval);
+u64 CARDqGetTSFOffset(BYTE byRxRate, u64 qwTSF1, u64 qwTSF2);
+int CARDbRadioPowerOff(struct vnt_private *pDevice);
+int CARDbRadioPowerOn(struct vnt_private *pDevice);
+u8 CARDbyGetPktType(struct vnt_private *pDevice);
+void CARDvSetBSSMode(struct vnt_private *pDevice);
+int CARDbChannelSwitch(struct vnt_private *pDevice, u8 byMode,
+       u8 byNewChannel, u8 byCount);
 
 #endif /* __CARD_H__ */
index 65021760785857ba8a1de0703bed253a7ae900db..95f00ba1d3febc6d351bc93febcc280a3cdc22a9 100644 (file)
@@ -436,11 +436,10 @@ CHvChannelGetList (
 }
 
 
-void CHvInitChannelTable(void *pDeviceHandler)
+void CHvInitChannelTable(struct vnt_private *pDevice)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    BOOL        bMultiBand = FALSE;
-    unsigned int ii;
+       int bMultiBand = FALSE;
+       int ii;
 
     for (ii = 1; ii <= CB_MAX_CHANNEL; ii++)
        sChannelTbl[ii].bValid = FALSE;
index e7b3c1231825bec340d44b4d4e529700ff72a055..8031491b8109193b717deb23b70cf7ccab8d9e4d 100644 (file)
@@ -30,6 +30,7 @@
 #ifndef _CHANNEL_H_
 #define _CHANNEL_H_
 
+#include "device.h"
 #include "ttype.h"
 
 /*---------------------  Export Definitions -------------------------*/
@@ -47,7 +48,7 @@ typedef struct tagSChannelTblElement {
 /*---------------------  Export Functions  --------------------------*/
 
 BOOL    ChannelValid(unsigned int CountryCode, unsigned int ChannelNum);
-void    CHvInitChannelTable(void *pDeviceHandler);
+void    CHvInitChannelTable(struct vnt_private *pDevice);
 BYTE    CHbyGetChannelMapping(BYTE byChannelNumber);
 
 BOOL CHvChannelGetList(unsigned int uCountryCodeIdx, PBYTE pbyChannelTable);
index 5d8c5719419b09390530537daca8530eb06a56bf..743ef5fb7fe748f00cc5fd6f65163ecf179c0e80 100644 (file)
 
 /*---------------------  Export Functions  --------------------------*/
 
-void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs,
-                       BYTE byData)
+void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
+                       u8 data)
 {
-       BYTE    byData1;
-       byData1 = byData;
-       CONTROLnsRequestOut(pDevice,
-               MESSAGE_TYPE_WRITE,
-               byRegOfs,
-               byRegType,
-               1,
-               &byData1);
+
+       CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg,
+               sizeof(u8), &data);
+
+       return;
 }
 
-void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs,
-                       PBYTE pbyData)
+void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
+                       u8 *data)
 {
-       int ntStatus;
-       BYTE    byData1;
-       ntStatus = CONTROLnsRequestIn(pDevice,
-                                       MESSAGE_TYPE_READ,
-                                       byRegOfs,
-                                       byRegType,
-                                       1,
-                                       &byData1);
-       *pbyData = byData1;
+       CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ,
+                       reg_off, reg, sizeof(u8), data);
+       return;
 }
 
-void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs,
-                       BYTE byMask, BYTE byData)
+void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off,
+                       u8 reg_mask, u8 data)
 {
-       BYTE    pbyData[2];
-       pbyData[0] = byData;
-       pbyData[1] = byMask;
-       CONTROLnsRequestOut(pDevice,
-                               MESSAGE_TYPE_WRITE_MASK,
-                               byRegOfs,
-                               byRegType,
-                               2,
-                               pbyData);
+       u8 reg_data[2];
+
+       reg_data[0] = data;
+       reg_data[1] = reg_mask;
+
+       CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off,
+                       reg_type, ARRAY_SIZE(reg_data), reg_data);
+
+       return;
 }
index bbe610fd8b5a06608341424896a19ab05f9e6651..76ce0244e100525c7b3584f2219cf1b55cafa5e2 100644 (file)
 
 /*---------------------  Export Functions  --------------------------*/
 
-void ControlvWriteByte(
-     PSDevice pDevice,
-     BYTE byRegType,
-     BYTE byRegOfs,
-     BYTE byData
-    );
+void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
+                       u8 data);
 
+void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
+                       u8 *data);
 
-void ControlvReadByte(
-     PSDevice pDevice,
-     BYTE byRegType,
-     BYTE byRegOfs,
-     PBYTE pbyData
-    );
+void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off,
+                       u8 reg_mask, u8 data);
 
 
-void ControlvMaskByte(
-     PSDevice pDevice,
-     BYTE byRegType,
-     BYTE byRegOfs,
-     BYTE byMask,
-     BYTE byData
-    );
-
 #endif /* __CONTROL_H__ */
index 5c2719fa72f7a38796a54768e6ac6d1e330525f4..eefe7bbe8a7c13606ee42a61da9c12e0f8a99e2c 100644 (file)
@@ -188,28 +188,19 @@ RATEwGetRateIdx(
  * Return Value: none
  *
 -*/
-void RATEvParseMaxRate(
-     void *pDeviceHandler,
-     PWLAN_IE_SUPP_RATES pItemRates,
-     PWLAN_IE_SUPP_RATES pItemExtRates,
-     BOOL bUpdateBasicRate,
-     PWORD pwMaxBasicRate,
-     PWORD pwMaxSuppRate,
-     PWORD pwSuppRate,
-     PBYTE pbyTopCCKRate,
-     PBYTE pbyTopOFDMRate
-    )
-{
-PSDevice  pDevice = (PSDevice) pDeviceHandler;
-unsigned int  ii;
-BYTE  byHighSuppRate = 0;
-BYTE  byRate = 0;
-WORD  wOldBasicRate = pDevice->wBasicRate;
-unsigned int  uRateLen;
 
+void RATEvParseMaxRate(struct vnt_private *pDevice,
+       PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates,
+       int bUpdateBasicRate, u16 *pwMaxBasicRate, u16 *pwMaxSuppRate,
+       u16 *pwSuppRate, u8 *pbyTopCCKRate, u8 *pbyTopOFDMRate)
+{
+       int  ii;
+       u8 byHighSuppRate = 0, byRate = 0;
+       u16 wOldBasicRate = pDevice->wBasicRate;
+       u32 uRateLen;
 
-    if (pItemRates == NULL)
-        return;
+       if (pItemRates == NULL)
+               return;
 
     *pwSuppRate = 0;
     uRateLen = pItemRates->len;
@@ -301,27 +292,24 @@ unsigned int  uRateLen;
 #define AUTORATE_TXCNT_THRESHOLD        20
 #define AUTORATE_INC_THRESHOLD          30
 
-void
-RATEvTxRateFallBack(
-     void *pDeviceHandler,
-     PKnownNodeDB psNodeDBTable
-    )
+void RATEvTxRateFallBack(struct vnt_private *pDevice,
+       PKnownNodeDB psNodeDBTable)
 {
-PSDevice        pDevice = (PSDevice) pDeviceHandler;
-PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-WORD            wIdxDownRate = 0;
-unsigned int            ii;
-BOOL            bAutoRate[MAX_RATE]    = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE};
-DWORD           dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540};
-DWORD           dwThroughput = 0;
-WORD            wIdxUpRate = 0;
-DWORD           dwTxDiff = 0;
-
-    if (pMgmt->eScanState != WMAC_NO_SCANNING) {
-        // Don't do Fallback when scanning Channel
-        return;
-    }
-    psNodeDBTable->uTimeCount ++;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u16 wIdxDownRate = 0;
+       int ii;
+       int bAutoRate[MAX_RATE] = {TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE,
+                                        TRUE, TRUE, TRUE, TRUE, TRUE};
+       u32 dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180,
+               240, 360, 480, 540};
+       u32 dwThroughput = 0;
+       u16 wIdxUpRate = 0;
+       u32 dwTxDiff = 0;
+
+       if (pMgmt->eScanState != WMAC_NO_SCANNING)
+               return; /* Don't do Fallback when scanning Channel */
+
+       psNodeDBTable->uTimeCount++;
 
     if (psNodeDBTable->uTxFail[MAX_RATE] > psNodeDBTable->uTxOk[MAX_RATE])
         dwTxDiff = psNodeDBTable->uTxFail[MAX_RATE] - psNodeDBTable->uTxOk[MAX_RATE];
index c6f5163ff9b802bd970b11194b74d1916f90c20c..1320507ab01d10d1b93a5edf837642b3f290b764 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef __DATARATE_H__
 #define __DATARATE_H__
 
+
 /*---------------------  Export Definitions -------------------------*/
 
 #define FALLBACK_PKT_COLLECT_TR_H  50   // pkts
 
 
 
-void
-RATEvParseMaxRate(
-     void *pDeviceHandler,
-     PWLAN_IE_SUPP_RATES pItemRates,
-     PWLAN_IE_SUPP_RATES pItemExtRates,
-     BOOL bUpdateBasicRate,
-     PWORD pwMaxBasicRate,
-     PWORD pwMaxSuppRate,
-     PWORD pwSuppRate,
-     PBYTE pbyTopCCKRate,
-     PBYTE pbyTopOFDMRate
-    );
+void RATEvParseMaxRate(struct vnt_private *, PWLAN_IE_SUPP_RATES pItemRates,
+       PWLAN_IE_SUPP_RATES pItemExtRates, int bUpdateBasicRate,
+       u16 *pwMaxBasicRate, u16 *pwMaxSuppRate, u16 *pwSuppRate,
+       u8 *pbyTopCCKRate, u8 *pbyTopOFDMRate);
 
-void
-RATEvTxRateFallBack(
-     void *pDeviceHandler,
-     PKnownNodeDB psNodeDBTable
-    );
+void RATEvTxRateFallBack(struct vnt_private *pDevice,
+       PKnownNodeDB psNodeDBTable);
 
 BYTE
 RATEuSetIE(
index 25bf03af7733e53491caebf1e3c5d3343ea8cce1..e153bebfd18d89912807cc3ae84a50c5fea65e85 100644 (file)
@@ -174,13 +174,13 @@ typedef enum _CONTEXT_TYPE {
 // RCB (Receive Control Block)
 typedef struct _RCB
 {
-    void *Next;
-    signed long                    Ref;
-    void *pDevice;
-    struct urb              *pUrb;
-    SRxMgmtPacket           sMngPacket;
-    struct sk_buff*         skb;
-    BOOL                    bBoolInUse;
+       void *Next;
+       signed long Ref;
+       void *pDevice;
+       struct urb *pUrb;
+       struct vnt_rx_mgmt sMngPacket;
+       struct sk_buff *skb;
+       int bBoolInUse;
 
 } RCB, *PRCB;
 
@@ -392,429 +392,406 @@ typedef struct __device_opt {
 } OPTIONS, *POPTIONS;
 
 
-typedef struct __device_info {
-
-// netdev
-       struct usb_device*          usb;
-    struct net_device*          dev;
-    struct net_device_stats     stats;
+struct vnt_private {
+       /* netdev */
+       struct usb_device *usb;
+       struct net_device *dev;
+       struct net_device_stats stats;
 
+       OPTIONS sOpts;
 
-    OPTIONS                     sOpts;
+       struct tasklet_struct CmdWorkItem;
+       struct tasklet_struct EventWorkItem;
+       struct tasklet_struct ReadWorkItem;
+       struct tasklet_struct RxMngWorkItem;
 
-       struct tasklet_struct       CmdWorkItem;
-       struct tasklet_struct       EventWorkItem;
-       struct tasklet_struct       ReadWorkItem;
-       struct tasklet_struct       RxMngWorkItem;
+       u32 rx_buf_sz;
+       int multicast_limit;
+       u8 byRxMode;
 
-    u32                         rx_buf_sz;
-    int                         multicast_limit;
-    BYTE                        byRxMode;
+       spinlock_t lock;
 
-    spinlock_t                  lock;
+       u32 rx_bytes;
 
-    u32                         rx_bytes;
+       u8 byRevId;
 
-    BYTE                        byRevId;
+       u32 flags;
+       unsigned long Flags;
 
-    u32                         flags;
-    unsigned long                       Flags;
+       SCache sDupRxCache;
 
-    SCache                      sDupRxCache;
+       SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG];
+       u32 cbDFCB;
+       u32 cbFreeDFCB;
+       u32 uCurrentDFCBIdx;
 
-    SDeFragControlBlock         sRxDFCB[CB_MAX_RX_FRAG];
-    unsigned int                        cbDFCB;
-    unsigned int                        cbFreeDFCB;
-    unsigned int                        uCurrentDFCBIdx;
 
-    // +++USB
+       /* USB */
+       struct urb *pControlURB;
+       struct urb *pInterruptURB;
+       struct usb_ctrlrequest sUsbCtlRequest;
+       u32 int_interval;
 
-    struct urb                  *pControlURB;
-    struct urb                  *pInterruptURB;
-       struct usb_ctrlrequest      sUsbCtlRequest;
-
-    unsigned int                        int_interval;
-    //
-    // Variables to track resources for the BULK In Pipe
-    //
-    PRCB                        pRCBMem;
-    PRCB                        apRCB[CB_MAX_RX_DESC];
-    unsigned int                        cbRD;
-    PRCB                        FirstRecvFreeList;
-    PRCB                        LastRecvFreeList;
-    unsigned int                        NumRecvFreeList;
-    PRCB                        FirstRecvMngList;
-    PRCB                        LastRecvMngList;
-    unsigned int                        NumRecvMngList;
-    BOOL                        bIsRxWorkItemQueued;
-    BOOL                        bIsRxMngWorkItemQueued;
+       /* Variables to track resources for the BULK In Pipe */
+       PRCB pRCBMem;
+       PRCB apRCB[CB_MAX_RX_DESC];
+       u32 cbRD;
+       PRCB FirstRecvFreeList;
+       PRCB LastRecvFreeList;
+       u32 NumRecvFreeList;
+       PRCB FirstRecvMngList;
+       PRCB LastRecvMngList;
+       u32 NumRecvMngList;
+       int bIsRxWorkItemQueued;
+       int bIsRxMngWorkItemQueued;
        unsigned long ulRcvRefCount; /* packets that have not returned back */
 
-    //
-    //  Variables to track resources for the BULK Out Pipe
-    //
-
-    PUSB_SEND_CONTEXT           apTD[CB_MAX_TX_DESC];
-    unsigned int                        cbTD;
-
-    //
-    //  Variables to track resources for the Interrupt In Pipe
-    //
-    INT_BUFFER                  intBuf;
-    BOOL                        fKillEventPollingThread;
-    BOOL                        bEventAvailable;
-
-
-  //default config from file by user setting
-    DEFAULT_CONFIG    config_file;
-
-
-    //
-    // Statistic for USB
-    // protect with spinlock
-    unsigned long                       ulBulkInPosted;
-    unsigned long                       ulBulkInError;
-    unsigned long                       ulBulkInContCRCError;
-    unsigned long                       ulBulkInBytesRead;
-
-    unsigned long                       ulBulkOutPosted;
-    unsigned long                       ulBulkOutError;
-    unsigned long                       ulBulkOutContCRCError;
-    unsigned long                       ulBulkOutBytesWrite;
-
-    unsigned long                       ulIntInPosted;
-    unsigned long                       ulIntInError;
-    unsigned long                       ulIntInContCRCError;
-    unsigned long                       ulIntInBytesRead;
-
-
-    // Version control
-    WORD                        wFirmwareVersion;
-    BYTE                        byLocalID;
-    BYTE                        byRFType;
-    BYTE                        byBBRxConf;
-
-
-    BYTE                        byZoneType;
-    BOOL                        bZoneRegExist;
-
-    BYTE                        byOriginalZonetype;
-
-    BOOL                        bLinkPass;          // link status: OK or fail
-    BYTE                        abyCurrentNetAddr[ETH_ALEN];
-    BYTE                        abyPermanentNetAddr[ETH_ALEN];
-    // SW network address
-       /* u8 abySoftwareNetAddr[ETH_ALEN]; */
-    BOOL                        bExistSWNetAddr;
-
-    // Adapter statistics
-    SStatCounter                scStatistic;
-    // 802.11 counter
-    SDot11Counters              s802_11Counter;
-
-    //
-    // Maintain statistical debug info.
-    //
-    unsigned long                       packetsReceived;
-    unsigned long                       packetsReceivedDropped;
-    unsigned long                       packetsReceivedOverflow;
-    unsigned long                       packetsSent;
-    unsigned long                       packetsSentDropped;
-    unsigned long                       SendContextsInUse;
-    unsigned long                       RcvBuffersInUse;
-
-
-    // 802.11 management
-    SMgmtObject                 sMgmtObj;
-
-    QWORD                       qwCurrTSF;
-    unsigned int                        cbBulkInMax;
-    BOOL                        bPSRxBeacon;
-
-    // 802.11 MAC specific
-    unsigned int                        uCurrRSSI;
-    BYTE                        byCurrSQ;
-
-
-    //Antenna Diversity
-    BOOL                        bTxRxAntInv;
-    DWORD                       dwRxAntennaSel;
-    DWORD                       dwTxAntennaSel;
-    BYTE                        byAntennaCount;
-    BYTE                        byRxAntennaMode;
-    BYTE                        byTxAntennaMode;
-    BYTE                        byRadioCtl;
-    BYTE                        bHWRadioOff;
-
-    //SQ3 functions for antenna diversity
-    struct timer_list           TimerSQ3Tmax1;
-    struct timer_list           TimerSQ3Tmax2;
-    struct timer_list           TimerSQ3Tmax3;
-
-    BOOL                        bDiversityRegCtlON;
-    BOOL                        bDiversityEnable;
-    unsigned long                       ulDiversityNValue;
-    unsigned long                       ulDiversityMValue;
-    BYTE                        byTMax;
-    BYTE                        byTMax2;
-    BYTE                        byTMax3;
-    unsigned long                       ulSQ3TH;
-
-    unsigned long                       uDiversityCnt;
-    BYTE                        byAntennaState;
-    unsigned long                       ulRatio_State0;
-    unsigned long                       ulRatio_State1;
-    unsigned long                       ulSQ3_State0;
-    unsigned long                       ulSQ3_State1;
-
-    unsigned long                       aulSQ3Val[MAX_RATE];
-    unsigned long                       aulPktNum[MAX_RATE];
+       /* Variables to track resources for the BULK Out Pipe */
+       PUSB_SEND_CONTEXT apTD[CB_MAX_TX_DESC];
+       u32 cbTD;
+
+       /* Variables to track resources for the Interrupt In Pipe */
+       INT_BUFFER intBuf;
+       int fKillEventPollingThread;
+       int bEventAvailable;
+
+       /* default config from file by user setting */
+       DEFAULT_CONFIG config_file;
+
+
+       /* Statistic for USB */
+       unsigned long ulBulkInPosted;
+       unsigned long ulBulkInError;
+       unsigned long ulBulkInContCRCError;
+       unsigned long ulBulkInBytesRead;
+
+       unsigned long ulBulkOutPosted;
+       unsigned long ulBulkOutError;
+       unsigned long ulBulkOutContCRCError;
+       unsigned long ulBulkOutBytesWrite;
+
+       unsigned long ulIntInPosted;
+       unsigned long ulIntInError;
+       unsigned long ulIntInContCRCError;
+       unsigned long ulIntInBytesRead;
+
+
+       /* Version control */
+       u16 wFirmwareVersion;
+       u8 byLocalID;
+       u8 byRFType;
+       u8 byBBRxConf;
+
+
+       u8 byZoneType;
+       int bZoneRegExist;
+
+       u8 byOriginalZonetype;
+
+       int bLinkPass; /* link status: OK or fail */
+       u8 abyCurrentNetAddr[ETH_ALEN];
+       u8 abyPermanentNetAddr[ETH_ALEN];
+
+       int bExistSWNetAddr;
+
+       /* Adapter statistics */
+       SStatCounter scStatistic;
+       /* 802.11 counter */
+       SDot11Counters s802_11Counter;
+
+       /* Maintain statistical debug info. */
+       unsigned long packetsReceived;
+       unsigned long packetsReceivedDropped;
+       unsigned long packetsReceivedOverflow;
+       unsigned long packetsSent;
+       unsigned long packetsSentDropped;
+       unsigned long SendContextsInUse;
+       unsigned long RcvBuffersInUse;
+
+       /* 802.11 management */
+       struct vnt_manager vnt_mgmt;
+
+       u64 qwCurrTSF;
+       u32 cbBulkInMax;
+       int bPSRxBeacon;
+
+       /* 802.11 MAC specific */
+       u32 uCurrRSSI;
+       u8 byCurrSQ;
+
+       /* Antenna Diversity */
+       int bTxRxAntInv;
+       u32 dwRxAntennaSel;
+       u32 dwTxAntennaSel;
+       u8 byAntennaCount;
+       u8 byRxAntennaMode;
+       u8 byTxAntennaMode;
+       u8 byRadioCtl;
+       u8 bHWRadioOff;
+
+       /* SQ3 functions for antenna diversity */
+       struct timer_list TimerSQ3Tmax1;
+       struct timer_list TimerSQ3Tmax2;
+       struct timer_list TimerSQ3Tmax3;
+
+       int bDiversityRegCtlON;
+       int bDiversityEnable;
+       unsigned long ulDiversityNValue;
+       unsigned long ulDiversityMValue;
+       u8 byTMax;
+       u8 byTMax2;
+       u8 byTMax3;
+       unsigned long ulSQ3TH;
+
+       unsigned long uDiversityCnt;
+       u8 byAntennaState;
+       unsigned long ulRatio_State0;
+       unsigned long ulRatio_State1;
+       unsigned long ulSQ3_State0;
+       unsigned long ulSQ3_State1;
+
+       unsigned long aulSQ3Val[MAX_RATE];
+       unsigned long aulPktNum[MAX_RATE];
 
        /* IFS & Cw */
-       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
-    BYTE                        bySIFS;
-    BYTE                        byDIFS;
-    BYTE                        byEIFS;
-    BYTE                        bySlot;
-    BYTE                        byCWMaxMin;
-
-    // Rate
-    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)
-    WORD                        wBasicRate;
-    BYTE                        byACKRate;
-    BYTE                        byTopOFDMBasicRate;
-    BYTE                        byTopCCKBasicRate;
-
-
-    DWORD                       dwAotoRateTxOkCnt;
-    DWORD                       dwAotoRateTxFailCnt;
-    DWORD                       dwErrorRateThreshold[13];
-    DWORD                       dwTPTable[MAX_RATE];
-    BYTE                        abyEEPROM[EEP_MAX_CONTEXT_SIZE];  //DWORD alignment
-
-    BYTE                        byMinChannel;
-    BYTE                        byMaxChannel;
-    unsigned int                        uConnectionRate;
-
-    BYTE                        byPreambleType;
-    BYTE                        byShortPreamble;
-    // CARD_PHY_TYPE
-    BYTE                        eConfigPHYMode;
-
-    // For RF Power table
-    BYTE                        byCCKPwr;
-    BYTE                        byOFDMPwrG;
-    BYTE                        byOFDMPwrA;
-    BYTE                        byCurPwr;
-    BYTE                        abyCCKPwrTbl[14];
-    BYTE                        abyOFDMPwrTbl[14];
-    BYTE                        abyOFDMAPwrTbl[42];
-
-    WORD                        wCurrentRate;
-    WORD                        wRTSThreshold;
-    WORD                        wFragmentationThreshold;
-    BYTE                        byShortRetryLimit;
-    BYTE                        byLongRetryLimit;
-    CARD_OP_MODE                eOPMode;
-    BOOL                        bBSSIDFilter;
-    WORD                        wMaxTransmitMSDULifetime;
-    BYTE                        abyBSSID[ETH_ALEN];
-    BYTE                        abyDesireBSSID[ETH_ALEN];
-    WORD                        wCTSDuration;       // update while speed change
-    WORD                        wACKDuration;       // update while speed change
-    WORD                        wRTSTransmitLen;    // update while speed change
-    BYTE                        byRTSServiceField;  // update while speed change
-    BYTE                        byRTSSignalField;   // update while speed change
-
-    DWORD                       dwMaxReceiveLifetime;       // dot11MaxReceiveLifetime
-
-    BOOL                        bCCK;
-    BOOL                        bEncryptionEnable;
-    BOOL                        bLongHeader;
-    BOOL                        bSoftwareGenCrcErr;
-    BOOL                        bShortSlotTime;
-    BOOL                        bProtectMode;
-    BOOL                        bNonERPPresent;
-    BOOL                        bBarkerPreambleMd;
-
-    BYTE                        byERPFlag;
-    WORD                        wUseProtectCntDown;
-
-    BOOL                        bRadioControlOff;
-    BOOL                        bRadioOff;
-
-    // Power save
-    BOOL                        bEnablePSMode;
-    WORD                        wListenInterval;
-    BOOL                        bPWBitOn;
-    WMAC_POWER_MODE             ePSMode;
-    unsigned long                       ulPSModeWaitTx;
-    BOOL                        bPSModeTxBurst;
-
-    // Beacon releated
-    WORD                    wSeqCounter;
-    BOOL                    bBeaconBufReady;
-    BOOL                    bBeaconSent;
-    BOOL                    bFixRate;
-    BYTE                    byCurrentCh;
-    unsigned int                    uScanTime;
-
-    CMD_STATE               eCommandState;
-
-    CMD_CODE                eCommand;
-    BOOL                    bBeaconTx;
-    BYTE                    byScanBBType;
-
-    BOOL                    bStopBeacon;
-    BOOL                    bStopDataPkt;
-    BOOL                    bStopTx0Pkt;
-    unsigned int                    uAutoReConnectTime;
-    unsigned int                    uIsroamingTime;
-
-    // 802.11 counter
-
-    CMD_ITEM                eCmdQueue[CMD_Q_SIZE];
-    unsigned int                    uCmdDequeueIdx;
-    unsigned int                    uCmdEnqueueIdx;
-    unsigned int                    cbFreeCmdQueue;
-    BOOL                    bCmdRunning;
-    BOOL                    bCmdClear;
-    BOOL                    bNeedRadioOFF;
-
-    BOOL                    bEnableRoaming;
-    BOOL                    bIsRoaming;
-    BOOL                    bFastRoaming;
-    BYTE                    bSameBSSMaxNum;
-    BYTE                    bSameBSSCurNum;
-    BOOL                    bRoaming;
-    BOOL                    b11hEable;
-    unsigned long                   ulTxPower;
-
-    // Encryption
-    NDIS_802_11_WEP_STATUS  eEncryptionStatus;
-    BOOL                    bTransmitKey;
-
-//mike add :save old Encryption
-    NDIS_802_11_WEP_STATUS  eOldEncryptionStatus;
-
-    SKeyManagement          sKey;
-    DWORD                   dwIVCounter;
-
-
-    RC4Ext                  SBox;
-    BYTE                    abyPRNG[WLAN_WEPMAX_KEYLEN+3];
-    BYTE                    byKeyIndex;
-
-    BOOL                    bAES;
-
-    unsigned int                    uKeyLength;
-    BYTE                    abyKey[WLAN_WEP232_KEYLEN];
-
-    // for AP mode
-    unsigned int                    uAssocCount;
-    BOOL                    bMoreData;
-
-    // QoS
-    BOOL                    bGrpAckPolicy;
-
-
-    BYTE                    byAutoFBCtrl;
-
-    BOOL                    bTxMICFail;
-    BOOL                    bRxMICFail;
-
-
-    // For Update BaseBand VGA Gain Offset
-    BOOL                    bUpdateBBVGA;
-    unsigned int                    uBBVGADiffCount;
-    BYTE                    byBBVGANew;
-    BYTE                    byBBVGACurrent;
-    BYTE                    abyBBVGA[BB_VGA_LEVEL];
-    signed long                    ldBmThreshold[BB_VGA_LEVEL];
-
-    BYTE                    byBBPreEDRSSI;
-    BYTE                    byBBPreEDIndex;
-
-
-    BOOL                    bRadioCmd;
-    DWORD                   dwDiagRefCount;
+       u32 uSIFS;  /* Current SIFS */
+       u32 uDIFS;  /* Current DIFS */
+       u32 uEIFS;  /* Current EIFS */
+       u32 uSlot;  /* Current SlotTime */
+       u32 uCwMin; /* Current CwMin */
+       u32 uCwMax; /* CwMax is fixed on 1023 */
+
+       /* PHY parameter */
+       u8  bySIFS;
+       u8  byDIFS;
+       u8  byEIFS;
+       u8  bySlot;
+       u8  byCWMaxMin;
+
+       /* Rate */
+       VIA_BB_TYPE byBBType; /* 0: 11A, 1:11B, 2:11G */
+       VIA_PKT_TYPE byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */
+       u16 wBasicRate;
+       u8 byACKRate;
+       u8 byTopOFDMBasicRate;
+       u8 byTopCCKBasicRate;
+
+
+       u32 dwAotoRateTxOkCnt;
+       u32 dwAotoRateTxFailCnt;
+       u32 dwErrorRateThreshold[13];
+       u32 dwTPTable[MAX_RATE];
+       u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE];  /*u32 alignment */
+
+       u8 byMinChannel;
+       u8 byMaxChannel;
+       u32 uConnectionRate;
+
+       u8 byPreambleType;
+       u8 byShortPreamble;
+       /* CARD_PHY_TYPE */
+       u8 eConfigPHYMode;
+
+       /* For RF Power table */
+       u8 byCCKPwr;
+       u8 byOFDMPwrG;
+       u8 byOFDMPwrA;
+       u8 byCurPwr;
+       u8 abyCCKPwrTbl[14];
+       u8 abyOFDMPwrTbl[14];
+       u8 abyOFDMAPwrTbl[42];
+
+       u16 wCurrentRate;
+       u16 wRTSThreshold;
+       u16 wFragmentationThreshold;
+       u8 byShortRetryLimit;
+       u8 byLongRetryLimit;
+       CARD_OP_MODE eOPMode;
+       int bBSSIDFilter;
+       u16 wMaxTransmitMSDULifetime;
+       u8 abyBSSID[ETH_ALEN];
+       u8 abyDesireBSSID[ETH_ALEN];
+
+       u16 wCTSDuration;       /* update while speed change */
+       u16 wACKDuration;
+       u16 wRTSTransmitLen;
+       u8 byRTSServiceField;
+       u8 byRTSSignalField;
+
+       u32 dwMaxReceiveLifetime;  /* dot11MaxReceiveLifetime */
+
+       int bCCK;
+       int bEncryptionEnable;
+       int bLongHeader;
+       int bSoftwareGenCrcErr;
+       int bShortSlotTime;
+       int bProtectMode;
+       int bNonERPPresent;
+       int bBarkerPreambleMd;
+
+       u8 byERPFlag;
+       u16 wUseProtectCntDown;
+
+       int bRadioControlOff;
+       int bRadioOff;
+
+       /* Power save */
+       int bEnablePSMode;
+       u16 wListenInterval;
+       int bPWBitOn;
+       WMAC_POWER_MODE ePSMode;
+       unsigned long ulPSModeWaitTx;
+       int bPSModeTxBurst;
+
+       /* Beacon releated */
+       u16 wSeqCounter;
+       int bBeaconBufReady;
+       int bBeaconSent;
+       int bFixRate;
+       u8 byCurrentCh;
+       u32 uScanTime;
+
+       CMD_STATE eCommandState;
+
+       CMD_CODE eCommand;
+       int bBeaconTx;
+       u8 byScanBBType;
+
+       int bStopBeacon;
+       int bStopDataPkt;
+       int bStopTx0Pkt;
+       u32 uAutoReConnectTime;
+       u32 uIsroamingTime;
+
+       /* 802.11 counter */
+
+       CMD_ITEM eCmdQueue[CMD_Q_SIZE];
+       u32 uCmdDequeueIdx;
+       u32 uCmdEnqueueIdx;
+       u32 cbFreeCmdQueue;
+       int bCmdRunning;
+       int bCmdClear;
+       int bNeedRadioOFF;
+
+       int bEnableRoaming;
+       int bIsRoaming;
+       int bFastRoaming;
+       u8 bSameBSSMaxNum;
+       u8 bSameBSSCurNum;
+       int bRoaming;
+       int b11hEable;
+       unsigned long ulTxPower;
+
+       /* Encryption */
+       NDIS_802_11_WEP_STATUS eEncryptionStatus;
+       int  bTransmitKey;
+       NDIS_802_11_WEP_STATUS eOldEncryptionStatus;
+       SKeyManagement sKey;
+       u32 dwIVCounter;
+
+
+       RC4Ext SBox;
+       u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3];
+       u8 byKeyIndex;
+
+       int bAES;
+
+       u32 uKeyLength;
+       u8 abyKey[WLAN_WEP232_KEYLEN];
+
+       /* for AP mode */
+       u32 uAssocCount;
+       int bMoreData;
+
+       /* QoS */
+       int bGrpAckPolicy;
+
+
+       u8 byAutoFBCtrl;
+
+       int bTxMICFail;
+       int bRxMICFail;
+
+
+       /* For Update BaseBand VGA Gain Offset */
+       int bUpdateBBVGA;
+       u32 uBBVGADiffCount;
+       u8 byBBVGANew;
+       u8 byBBVGACurrent;
+       u8 abyBBVGA[BB_VGA_LEVEL];
+       signed long ldBmThreshold[BB_VGA_LEVEL];
+
+       u8 byBBPreEDRSSI;
+       u8 byBBPreEDIndex;
+
+
+       int bRadioCmd;
+       u32 dwDiagRefCount;
+
+       /* For FOE Tuning */
+       u8  byFOETuning;
+
+       /* For Auto Power Tunning */
+       u8  byAutoPwrTunning;
+
+       /* BaseBand Loopback Use */
+       u8 byBBCR4d;
+       u8 byBBCRc9;
+       u8 byBBCR88;
+       u8 byBBCR09;
+
+       /* command timer */
+       struct timer_list sTimerCommand;
 
-    // For FOE Tuning
-    BYTE                    byFOETuning;
+       struct timer_list sTimerTxData;
+       unsigned long nTxDataTimeCout;
+       int fTxDataInSleep;
+       int IsTxDataTrigger;
 
-    // For Auto Power Tunning
+       int fWPA_Authened; /*is WPA/WPA-PSK or WPA2/WPA2-PSK authen?? */
+       u8 byReAssocCount;
+       u8 byLinkWaitCount;
 
-    BYTE                    byAutoPwrTunning;
+       SEthernetHeader sTxEthHeader;
+       SEthernetHeader sRxEthHeader;
+       u8 abyBroadcastAddr[ETH_ALEN];
+       u8 abySNAP_RFC1042[ETH_ALEN];
+       u8 abySNAP_Bridgetunnel[ETH_ALEN];
 
-    // BaseBand Loopback Use
-    BYTE                    byBBCR4d;
-    BYTE                    byBBCRc9;
-    BYTE                    byBBCR88;
-    BYTE                    byBBCR09;
+       /* Pre-Authentication & PMK cache */
+       SPMKID gsPMKID;
+       SPMKIDCandidateEvent gsPMKIDCandidate;
 
-    // command timer
-    struct timer_list       sTimerCommand;
 
-     struct timer_list       sTimerTxData;
-     unsigned long                       nTxDataTimeCout;
-     BOOL  fTxDataInSleep;
-     BOOL  IsTxDataTrigger;
+       /* for 802.11h */
+       int b11hEnable;
 
-    BOOL  fWPA_Authened;           //is WPA/WPA-PSK or WPA2/WPA2-PSK authen??
-    BYTE            byReAssocCount;   //mike add:re-association retry times!
-    BYTE            byLinkWaitCount;
+       int bChannelSwitch;
+       u8 byNewChannel;
+       u8 byChannelSwitchCount;
 
-    SEthernetHeader         sTxEthHeader;
-    SEthernetHeader         sRxEthHeader;
-    BYTE                    abyBroadcastAddr[ETH_ALEN];
-    BYTE                    abySNAP_RFC1042[ETH_ALEN];
-    BYTE                    abySNAP_Bridgetunnel[ETH_ALEN];
+       /* WPA supplicant daemon */
+       int bWPADEVUp;
+       int bwextstep0;
+       int bwextstep1;
+       int bwextstep2;
+       int bwextstep3;
+       int bWPASuppWextEnabled;
 
-    // Pre-Authentication & PMK cache
-    SPMKID                  gsPMKID;
-    SPMKIDCandidateEvent    gsPMKIDCandidate;
-
-
-    // for 802.11h
-    BOOL                    b11hEnable;
-
-    BOOL                    bChannelSwitch;
-    BYTE                    byNewChannel;
-    BYTE                    byChannelSwitchCount;
-
-    //WPA supplicant daemon
-       struct net_device       *wpadev;
-       BOOL                    bWPADEVUp;
-    //--
+       /* user space daemon: hostapd, is used for HOSTAP */
+       int bEnableHostapd;
+       int bEnable8021x;
+       int bEnableHostWEP;
+       struct net_device *apdev;
+       int (*tx_80211)(struct sk_buff *skb, struct net_device *dev);
 
-        BOOL                 bwextstep0;
-        BOOL                 bwextstep1;
-        BOOL                 bwextstep2;
-        BOOL                 bwextstep3;
-        BOOL                 bWPASuppWextEnabled;
+       u32 uChannel;
 
-#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;
+       struct iw_statistics wstats; /* wireless stats */
 
-       struct iw_statistics    wstats;         // wireless stats
-    BOOL                    bCommit;
+       int bCommit;
 
-} DEVICE_INFO, *PSDevice;
+};
 
 
 
@@ -871,9 +848,6 @@ typedef struct __device_info {
 
 /*---------------------  Export Functions  --------------------------*/
 
-/* BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb,
- *                       unsigned int uNodeIndex);
- */
-BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF);
+int device_alloc_frag_buf(struct vnt_private *, PSDeFragControlBlock pDeF);
 
 #endif
index e94f6a1647a3b60e21f224eec8a0aa87ea976872..208be2c4abcbb126b1aa0d1f67f15db2a20c3c6f 100644 (file)
@@ -84,61 +84,23 @@ s_vGetDASA(
      PSEthernetHeader psEthHeader
     );
 
-static
-void
-s_vProcessRxMACHeader (
-      PSDevice pDevice,
-      PBYTE pbyRxBufferAddr,
-      unsigned int cbPacketSize,
-      BOOL bIsWEP,
-      BOOL bExtIV,
-     unsigned int *pcbHeadSize
-    );
-
-static BOOL s_bAPModeRxCtl(
-     PSDevice pDevice,
-     PBYTE    pbyFrame,
-     signed int      iSANodeIndex
-    );
-
-
-
-static BOOL s_bAPModeRxData (
-     PSDevice pDevice,
-     struct sk_buff *skb,
-     unsigned int     FrameSize,
-     unsigned int     cbHeaderOffset,
-     signed int      iSANodeIndex,
-     signed int      iDANodeIndex
-    );
+static void s_vProcessRxMACHeader(struct vnt_private *pDevice,
+       u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV,
+       u32 *pcbHeadSize);
 
+static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame,
+       s32 iSANodeIndex);
 
-static BOOL s_bHandleRxEncryption(
-     PSDevice     pDevice,
-     PBYTE        pbyFrame,
-     unsigned int         FrameSize,
-     PBYTE        pbyRsr,
-     PBYTE       pbyNewRsr,
-     PSKeyItem   * pKeyOut,
-    int *       pbExtIV,
-     PWORD       pwRxTSC15_0,
-     PDWORD      pdwRxTSC47_16
-    );
-
-static BOOL s_bHostWepRxEncryption(
+static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb,
+       u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex);
 
-     PSDevice     pDevice,
-     PBYTE        pbyFrame,
-     unsigned int         FrameSize,
-     PBYTE        pbyRsr,
-     BOOL         bOnFly,
-     PSKeyItem    pKey,
-     PBYTE       pbyNewRsr,
-    int *       pbExtIV,
-     PWORD       pwRxTSC15_0,
-     PDWORD      pdwRxTSC47_16
+static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame,
+       u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut,
+       s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16);
 
-    );
+static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame,
+       u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr,
+       s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16);
 
 /*---------------------  Export Variables  --------------------------*/
 
@@ -159,22 +121,16 @@ static BOOL s_bHostWepRxEncryption(
  * Return Value: None
  *
 -*/
-static
-void
-s_vProcessRxMACHeader (
-      PSDevice pDevice,
-      PBYTE pbyRxBufferAddr,
-      unsigned int cbPacketSize,
-      BOOL bIsWEP,
-      BOOL bExtIV,
-     unsigned int *pcbHeadSize
-    )
+
+static void s_vProcessRxMACHeader(struct vnt_private *pDevice,
+       u8 *pbyRxBufferAddr, u32 cbPacketSize, int bIsWEP, int bExtIV,
+       u32 *pcbHeadSize)
 {
-    PBYTE           pbyRxBuffer;
-    unsigned int            cbHeaderSize = 0;
-    PWORD           pwType;
-    PS802_11Header  pMACHeader;
-    int             ii;
+       u8 *pbyRxBuffer;
+       u32 cbHeaderSize = 0;
+       u16 *pwType;
+       PS802_11Header pMACHeader;
+       int ii;
 
 
     pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
@@ -310,56 +266,39 @@ s_vGetDASA (
 }
 
 
-
-
-BOOL
-RXbBulkInProcessData (
-     PSDevice         pDevice,
-     PRCB             pRCB,
-     unsigned long            BytesToIndicate
-    )
+int RXbBulkInProcessData(struct vnt_private *pDevice, PRCB pRCB,
+       unsigned long BytesToIndicate)
 {
-
-    struct net_device_stats* pStats=&pDevice->stats;
-    struct sk_buff* skb;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PSRxMgmtPacket  pRxPacket = &(pMgmt->sRxPacket);
-    PS802_11Header  p802_11Header;
-    PBYTE           pbyRsr;
-    PBYTE           pbyNewRsr;
-    PBYTE           pbyRSSI;
-    PQWORD          pqwTSFTime;
-    PBYTE           pbyFrame;
-    BOOL            bDeFragRx = FALSE;
-    unsigned int            cbHeaderOffset;
+       struct net_device_stats *pStats = &pDevice->stats;
+       struct sk_buff *skb;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct vnt_rx_mgmt *pRxPacket = &pMgmt->sRxPacket;
+       PS802_11Header p802_11Header;
+       u8 *pbyRsr, *pbyNewRsr, *pbyRSSI, *pbyFrame;
+       u64 *pqwTSFTime;
+       u32 bDeFragRx = FALSE;
+       u32 cbHeaderOffset, cbIVOffset;
        u32 FrameSize;
-    WORD            wEtherType = 0;
-    signed int             iSANodeIndex = -1;
-    signed int             iDANodeIndex = -1;
-    unsigned int            ii;
-    unsigned int            cbIVOffset;
-    PBYTE           pbyRxSts;
-    PBYTE           pbyRxRate;
-    PBYTE           pbySQ;
-    PBYTE           pby3SQ;
-    unsigned int            cbHeaderSize;
-    PSKeyItem       pKey = NULL;
-    WORD            wRxTSC15_0 = 0;
-    DWORD           dwRxTSC47_16 = 0;
-    SKeyItem        STempKey;
-    // 802.11h RPI
-    /* signed long ldBm = 0; */
-    BOOL            bIsWEP = FALSE;
-    BOOL            bExtIV = FALSE;
+       u16 wEtherType = 0;
+       s32 iSANodeIndex = -1, iDANodeIndex = -1;
+       int ii;
+       u8 *pbyRxSts, *pbyRxRate, *pbySQ, *pby3SQ;
+       u32 cbHeaderSize;
+       PSKeyItem pKey = NULL;
+       u16 wRxTSC15_0 = 0;
+       u32 dwRxTSC47_16 = 0;
+       SKeyItem STempKey;
+       /* signed long ldBm = 0; */
+       int bIsWEP = FALSE; int bExtIV = FALSE;
        u32 dwWbkStatus;
-    PRCB            pRCBIndicate = pRCB;
-    PBYTE           pbyDAddress;
-    PWORD           pwPLCP_Length;
-    BYTE            abyVaildRate[MAX_RATE] = {2,4,11,22,12,18,24,36,48,72,96,108};
-    WORD            wPLCPwithPadding;
-    PS802_11Header  pMACHeader;
-    BOOL            bRxeapol_key = FALSE;
-
+       PRCB pRCBIndicate = pRCB;
+       u8 *pbyDAddress;
+       u16 *pwPLCP_Length;
+       u8 abyVaildRate[MAX_RATE]
+               = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
+       u16 wPLCPwithPadding;
+       PS802_11Header pMACHeader;
+       int bRxeapol_key = FALSE;
 
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- RXbBulkInProcessData---\n");
@@ -411,7 +350,7 @@ RXbBulkInProcessData (
 
     wPLCPwithPadding = ( (*pwPLCP_Length / 4) + ( (*pwPLCP_Length % 4) ? 1:0 ) ) *4;
 
-    pqwTSFTime = (PQWORD) (pbyDAddress + 8 + wPLCPwithPadding);
+       pqwTSFTime = (u64 *)(pbyDAddress + 8 + wPLCPwithPadding);
   if(pDevice->byBBType == BB_TYPE_11G)  {
       pby3SQ = pbyDAddress + 8 + wPLCPwithPadding + 12;
       pbySQ = pby3SQ;
@@ -598,8 +537,7 @@ RXbBulkInProcessData (
             pRxPacket->cbMPDULen = FrameSize;
             pRxPacket->uRSSI = *pbyRSSI;
             pRxPacket->bySQ = *pbySQ;
-            HIDWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(HIDWORD(*pqwTSFTime));
-            LODWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(LODWORD(*pqwTSFTime));
+               pRxPacket->qwLocalTSF = cpu_to_le64(*pqwTSFTime);
             if (bIsWEP) {
                 // strip IV
                 pbyData1 = WLAN_HDR_A3_DATA_PTR(pbyFrame);
@@ -910,11 +848,11 @@ RXbBulkInProcessData (
             RSC = dwRxTSC47_16;
             RSC <<= 16;
             RSC += wRxTSC15_0;
-            memcpy(&(pKey->KeyRSC), &RSC,  sizeof(QWORD));
+               memcpy(&(pKey->KeyRSC), &RSC,  sizeof(u64));
 
-            if ( (pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) &&
-                 (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) {
-                // check RSC
+               if (pDevice->vnt_mgmt.eCurrMode == WMAC_MODE_ESS_STA &&
+                       pDevice->vnt_mgmt.eCurrState == WMAC_STATE_ASSOC) {
+                       /* check RSC */
                 if ( (wRxTSC15_0 < wLocalTSC15_0) &&
                      (dwRxTSC47_16 <= dwLocalTSC47_16) &&
                      !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) {
@@ -986,16 +924,12 @@ RXbBulkInProcessData (
     return TRUE;
 }
 
-
-static BOOL s_bAPModeRxCtl (
-     PSDevice pDevice,
-     PBYTE    pbyFrame,
-     signed int      iSANodeIndex
-    )
+static int s_bAPModeRxCtl(struct vnt_private *pDevice, u8 *pbyFrame,
+       s32 iSANodeIndex)
 {
-    PS802_11Header      p802_11Header;
-    CMD_STATUS          Status;
-    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PS802_11Header p802_11Header;
+       CMD_STATUS Status;
 
 
     if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
@@ -1097,24 +1031,16 @@ static BOOL s_bAPModeRxCtl (
 
 }
 
-static BOOL s_bHandleRxEncryption (
-     PSDevice     pDevice,
-     PBYTE        pbyFrame,
-     unsigned int         FrameSize,
-     PBYTE        pbyRsr,
-     PBYTE       pbyNewRsr,
-     PSKeyItem   * pKeyOut,
-    int *       pbExtIV,
-     PWORD       pwRxTSC15_0,
-     PDWORD      pdwRxTSC47_16
-    )
+static int s_bHandleRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame,
+       u32 FrameSize, u8 *pbyRsr, u8 *pbyNewRsr, PSKeyItem *pKeyOut,
+       s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16)
 {
-    unsigned int            PayloadLen = FrameSize;
-    PBYTE           pbyIV;
-    BYTE            byKeyIdx;
-    PSKeyItem       pKey = NULL;
-    BYTE            byDecMode = KEY_CTL_WEP;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 PayloadLen = FrameSize;
+       u8 *pbyIV;
+       u8 byKeyIdx;
+       PSKeyItem pKey = NULL;
+       u8 byDecMode = KEY_CTL_WEP;
 
 
     *pwRxTSC15_0 = 0;
@@ -1190,7 +1116,7 @@ static BOOL s_bHandleRxEncryption (
     if (byDecMode == KEY_CTL_WEP) {
         // handle WEP
         if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
-               (((PSKeyTable)(&pKey->pvKeyTable))->bSoftWEP == TRUE)) {
+               (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE)) {
             // Software WEP
             // 1. 3253A
             // 2. WEP 256
@@ -1242,31 +1168,19 @@ static BOOL s_bHandleRxEncryption (
     return TRUE;
 }
 
-
-static BOOL s_bHostWepRxEncryption (
-     PSDevice     pDevice,
-     PBYTE        pbyFrame,
-     unsigned int         FrameSize,
-     PBYTE        pbyRsr,
-     BOOL         bOnFly,
-     PSKeyItem    pKey,
-     PBYTE       pbyNewRsr,
-    int *       pbExtIV,
-     PWORD       pwRxTSC15_0,
-     PDWORD      pdwRxTSC47_16
-    )
+static int s_bHostWepRxEncryption(struct vnt_private *pDevice, u8 *pbyFrame,
+       u32 FrameSize, u8 *pbyRsr, int bOnFly, PSKeyItem pKey, u8 *pbyNewRsr,
+       s32 *pbExtIV, u16 *pwRxTSC15_0, u32 *pdwRxTSC47_16)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            PayloadLen = FrameSize;
-    PBYTE           pbyIV;
-    BYTE            byKeyIdx;
-    BYTE            byDecMode = KEY_CTL_WEP;
-    PS802_11Header  pMACHeader;
-
-
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PS802_11Header  pMACHeader;
+       u32 PayloadLen = FrameSize;
+       u8 *pbyIV;
+       u8 byKeyIdx;
+       u8 byDecMode = KEY_CTL_WEP;
 
-    *pwRxTSC15_0 = 0;
-    *pdwRxTSC47_16 = 0;
+       *pwRxTSC15_0 = 0;
+       *pdwRxTSC47_16 = 0;
 
     pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
     if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
@@ -1299,7 +1213,7 @@ static BOOL s_bHostWepRxEncryption (
         // handle WEP
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP\n");
         if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
-               (((PSKeyTable)(&pKey->pvKeyTable))->bSoftWEP == TRUE) ||
+               (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE) ||
             (bOnFly == FALSE)) {
             // Software WEP
             // 1. 3253A
@@ -1373,26 +1287,16 @@ static BOOL s_bHostWepRxEncryption (
     return TRUE;
 }
 
-
-
-static BOOL s_bAPModeRxData (
-     PSDevice pDevice,
-     struct sk_buff *skb,
-     unsigned int     FrameSize,
-     unsigned int     cbHeaderOffset,
-     signed int      iSANodeIndex,
-     signed int      iDANodeIndex
-    )
-
+static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb,
+       u32 FrameSize, u32 cbHeaderOffset, s32 iSANodeIndex, s32 iDANodeIndex)
 {
-    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-    BOOL                bRelayAndForward = FALSE;
-    BOOL                bRelayOnly = FALSE;
-    BYTE                byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-    WORD                wAID;
-
+       struct sk_buff *skbcpy;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int  bRelayAndForward = FALSE;
+       int bRelayOnly = FALSE;
+       u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+       u16 wAID;
 
-    struct sk_buff* skbcpy = NULL;
 
     if (FrameSize > CB_MAX_BUF_SIZE)
         return FALSE;
@@ -1469,11 +1373,10 @@ static BOOL s_bAPModeRxData (
 
 
 
-void RXvWorkItem(void *Context)
+void RXvWorkItem(struct vnt_private *pDevice)
 {
-    PSDevice pDevice = (PSDevice) Context;
-    int ntStatus;
-    PRCB            pRCB=NULL;
+       int ntStatus;
+       PRCB pRCB = NULL;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n");
     spin_lock_irq(&pDevice->lock);
@@ -1493,13 +1396,9 @@ void RXvWorkItem(void *Context)
 }
 
 
-void
-RXvFreeRCB(
-     PRCB pRCB,
-     BOOL bReAllocSkb
-    )
+void RXvFreeRCB(PRCB pRCB, int bReAllocSkb)
 {
-    PSDevice pDevice = (PSDevice)pRCB->pDevice;
+       struct vnt_private *pDevice = pRCB->pDevice;
 
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->RXvFreeRCB\n");
@@ -1538,12 +1437,11 @@ RXvFreeRCB(
 }
 
 
-void RXvMngWorkItem(void *Context)
+void RXvMngWorkItem(struct vnt_private *pDevice)
 {
-    PSDevice pDevice = (PSDevice) Context;
-    PRCB            pRCB=NULL;
-    PSRxMgmtPacket  pRxPacket;
-    BOOL            bReAllocSkb = FALSE;
+       PRCB pRCB = NULL;
+       struct vnt_rx_mgmt *pRxPacket;
+       int bReAllocSkb = FALSE;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Mng Thread\n");
 
@@ -1558,7 +1456,7 @@ void RXvMngWorkItem(void *Context)
         }
         ASSERT(pRCB);// cannot be NULL
         pRxPacket = &(pRCB->sMngPacket);
-       vMgrRxManagePacket((void *) pDevice, &(pDevice->sMgmtObj), pRxPacket);
+       vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket);
         pRCB->Ref--;
         if(pRCB->Ref == 0) {
             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeMng %d %d\n",pDevice->NumRecvFreeList, pDevice->NumRecvMngList);
index d4fca43af4fe5fec38bee8dee0a46052795b6e8a..786c523f547975c4da00ef788dcc0e5677ca868c 100644 (file)
@@ -45,17 +45,9 @@ void RXvWorkItem(void *Context);
 
 void RXvMngWorkItem(void *Context);
 
-void
-RXvFreeRCB(
-     PRCB pRCB,
-     BOOL bReAllocSkb
-    );
-
-BOOL
-RXbBulkInProcessData(
-     PSDevice         pDevice,
-     PRCB             pRCB,
-     unsigned long            BytesToIndicate
-    );
+void RXvFreeRCB(PRCB pRCB, int bReAllocSkb);
+
+int RXbBulkInProcessData(struct vnt_private *, PRCB pRCB,
+       unsigned long BytesToIndicate);
 
 #endif /* __RXTX_H__ */
index 8831ea03c00152864ca4336980624ac16dcef769..93d7301bc294ae4468fab0b7cc462784d92fad1d 100644 (file)
@@ -56,10 +56,7 @@ static int          msglevel                =MSG_LEVEL_INFO;
 /*---------------------  Export Functions  --------------------------*/
 
 
-BOOL
-FIRMWAREbDownload(
-     PSDevice pDevice
-    )
+int FIRMWAREbDownload(struct vnt_private *pDevice)
 {
        struct device *dev = &pDevice->usb->dev;
        const struct firmware *fw;
@@ -114,12 +111,9 @@ out:
 }
 MODULE_FIRMWARE(FIRMWARE_NAME);
 
-BOOL
-FIRMWAREbBrach2Sram(
-     PSDevice pDevice
-    )
+int FIRMWAREbBrach2Sram(struct vnt_private *pDevice)
 {
-    int NdisStatus;
+       int NdisStatus;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Branch to Sram\n");
 
@@ -139,10 +133,7 @@ FIRMWAREbBrach2Sram(
 }
 
 
-BOOL
-FIRMWAREbCheckVersion(
-     PSDevice pDevice
-    )
+int FIRMWAREbCheckVersion(struct vnt_private *pDevice)
 {
        int ntStatus;
 
index b2f5b5818a9375b159870c43c94fa125c96df446..ebab3a6351b3d2369cca25916f617f30ad8e16b6 100644 (file)
 
 /*---------------------  Export Functions  --------------------------*/
 
-BOOL
-FIRMWAREbDownload(
-     PSDevice pDevice
-    );
-
-BOOL
-FIRMWAREbBrach2Sram(
-     PSDevice pDevice
-    );
-
-BOOL
-FIRMWAREbCheckVersion(
-     PSDevice pDevice
-    );
+int FIRMWAREbDownload(struct vnt_private *);
+int FIRMWAREbBrach2Sram(struct vnt_private *);
+int FIRMWAREbCheckVersion(struct vnt_private *);
 
 #endif /* __FIRMWARE_H__ */
index 26a7d0e4b0487aa118d85e9e665238ccb6ade802..432961c1ac5370670ebe919971df02887ed71349 100644 (file)
@@ -60,13 +60,13 @@ static int          msglevel                =MSG_LEVEL_INFO;
  *
  */
 
-static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
+static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
 {
-    PSDevice apdev_priv;
+       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,
+               .ndo_start_xmit = pDevice->tx_80211,
        };
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
@@ -120,7 +120,7 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
  *
  */
 
-static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
+static int hostap_disable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
 {
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: disabling hostapd mode\n", pDevice->dev->name);
@@ -157,7 +157,8 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked)
  *
  */
 
-int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked)
+int vt6656_hostap_set_hostapd(struct vnt_private *pDevice,
+       int val, int rtnl_locked)
 {
        if (val < 0 || val > 1)
                return -EINVAL;
@@ -187,8 +188,8 @@ int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked)
  * Return Value:
  *
  */
-static int hostap_remove_sta(PSDevice pDevice,
-                                    struct viawget_hostapd_param *param)
+static int hostap_remove_sta(struct vnt_private *pDevice,
+       struct viawget_hostapd_param *param)
 {
        unsigned int uNodeIndex;
 
@@ -215,16 +216,15 @@ static int hostap_remove_sta(PSDevice pDevice,
  * Return Value:
  *
  */
-static int hostap_add_sta(PSDevice pDevice,
-                                 struct viawget_hostapd_param *param)
+static int hostap_add_sta(struct vnt_private *pDevice,
+       struct viawget_hostapd_param *param)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        unsigned int uNodeIndex;
 
+       if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex))
+               BSSvCreateOneNode(pDevice, &uNodeIndex);
 
-    if (!BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) {
-        BSSvCreateOneNode((PSDevice)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;
@@ -275,10 +275,10 @@ static int hostap_add_sta(PSDevice pDevice,
  *
  */
 
-static int hostap_get_info_sta(PSDevice pDevice,
-                                      struct viawget_hostapd_param *param)
+static int hostap_get_info_sta(struct vnt_private *pDevice,
+       struct viawget_hostapd_param *param)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        unsigned int uNodeIndex;
 
     if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) {
@@ -308,10 +308,10 @@ static int hostap_get_info_sta(PSDevice pDevice,
  * Return Value:
  *
  */
-static int hostap_set_flags_sta(PSDevice pDevice,
-                                       struct viawget_hostapd_param *param)
+static int hostap_set_flags_sta(struct vnt_private *pDevice,
+               struct viawget_hostapd_param *param)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        unsigned int uNodeIndex;
 
     if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) {
@@ -342,10 +342,10 @@ static int hostap_set_flags_sta(PSDevice pDevice,
  * Return Value:
  *
  */
-static int hostap_set_generic_element(PSDevice pDevice,
+static int hostap_set_generic_element(struct vnt_private *pDevice,
                                        struct viawget_hostapd_param *param)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
 
 
@@ -388,7 +388,7 @@ static int hostap_set_generic_element(PSDevice pDevice,
  *
  */
 
-static void hostap_flush_sta(PSDevice pDevice)
+static void hostap_flush_sta(struct vnt_private *pDevice)
 {
     // reserved node index =0 for multicast node.
     BSSvClearNodeDBTable(pDevice, 1);
@@ -410,21 +410,20 @@ static void hostap_flush_sta(PSDevice pDevice)
  * Return Value:
  *
  */
-static int hostap_set_encryption(PSDevice pDevice,
-                                      struct viawget_hostapd_param *param,
-                                      int param_len)
+static int hostap_set_encryption(struct vnt_private *pDevice,
+       struct viawget_hostapd_param *param, int param_len)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    DWORD   dwKeyIndex = 0;
-    BYTE    abyKey[MAX_KEY_LEN];
-    BYTE    abySeq[MAX_KEY_LEN];
-    NDIS_802_11_KEY_RSC   KeyRSC;
-    BYTE    byKeyDecMode = KEY_CTL_WEP;
-       int     ret = 0;
-       int     iNodeIndex = -1;
-       int     ii;
-       BOOL    bKeyTableFull = FALSE;
-       WORD    wKeyCtl = 0;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 dwKeyIndex = 0;
+       u8 abyKey[MAX_KEY_LEN];
+       u8 abySeq[MAX_KEY_LEN];
+       NDIS_802_11_KEY_RSC   KeyRSC;
+       u8 byKeyDecMode = KEY_CTL_WEP;
+       int ret = 0;
+       s32 iNodeIndex = -1;
+       int ii;
+       int bKeyTableFull = FALSE;
+       u16 wKeyCtl = 0;
 
 
        param->u.crypt.err = 0;
@@ -512,14 +511,12 @@ static int hostap_set_encryption(PSDevice pDevice,
         } else {
             // 8021x enable, individual key
             dwKeyIndex |= (1 << 30); // set pairwise key
-            if (KeybSetKey(pDevice,
-                           &(pDevice->sKey),
-                           &param->sta_addr[0],
-                           dwKeyIndex & ~(USE_KEYRSC),
-                           param->u.crypt.key_len,
-                           (PQWORD) &(KeyRSC),
-                           (PBYTE)abyKey,
-                            KEY_CTL_WEP
+               if (KeybSetKey(pDevice, &(pDevice->sKey),
+                       &param->sta_addr[0],
+                       dwKeyIndex & ~(USE_KEYRSC),
+                       param->u.crypt.key_len,
+                       &KeyRSC, (PBYTE)abyKey,
+                       KEY_CTL_WEP
                            ) == TRUE) {
 
 
@@ -574,7 +571,7 @@ static int hostap_set_encryption(PSDevice pDevice,
                            &(pDevice->sKey),
                            dwKeyIndex,
                            param->u.crypt.key_len,
-                           (PQWORD) &(KeyRSC),
+                       &KeyRSC,
                            abyKey,
                            byKeyDecMode
                           );
@@ -587,7 +584,7 @@ static int hostap_set_encryption(PSDevice pDevice,
                        &param->sta_addr[0],
                        dwKeyIndex,
                        param->u.crypt.key_len,
-                       (PQWORD) &(KeyRSC),
+                       &KeyRSC,
                        (PBYTE)abyKey,
                         byKeyDecMode
                        ) == TRUE) {
@@ -649,14 +646,14 @@ static int hostap_set_encryption(PSDevice pDevice,
  * Return Value:
  *
  */
-static int hostap_get_encryption(PSDevice pDevice,
+static int hostap_get_encryption(struct vnt_private *pDevice,
                                       struct viawget_hostapd_param *param,
                                       int param_len)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-       int     ret = 0;
-       int     ii;
-       int     iNodeIndex =0;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ret = 0;
+       int ii;
+       s32 iNodeIndex = 0;
 
 
        param->u.crypt.err = 0;
@@ -694,7 +691,7 @@ static int hostap_get_encryption(PSDevice pDevice,
  *
  */
 
-int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
+int vt6656_hostap_ioctl(struct vnt_private *pDevice, struct iw_point *p)
 {
        struct viawget_hostapd_param *param;
        int ret = 0;
index b660aee1ca0ed7d9d22cbf134f6e3cb8aa75842d..f5656cd96a8f307d8d2004058a7b280101ba6a02 100644 (file)
@@ -61,7 +61,7 @@
 #define ARPHRD_IEEE80211 801
 #endif
 
-int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked);
-int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p);
+int vt6656_hostap_set_hostapd(struct vnt_private *, int val, int rtnl_locked);
+int vt6656_hostap_ioctl(struct vnt_private *, struct iw_point *p);
 
 #endif /* __HOSTAP_H__ */
index bba31caae036e1be67c87549873574de4ac97501..97c6896bd3b239ab35a41502ab993b11891d5e1c 100644 (file)
@@ -75,9 +75,8 @@ static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
  *  if we've gotten no data
  *
 -*/
-void INTvWorkItem(void *Context)
+void INTvWorkItem(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = Context;
        int ntStatus;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
@@ -88,10 +87,10 @@ void INTvWorkItem(void *Context)
        spin_unlock_irq(&pDevice->lock);
 }
 
-void INTnsProcessData(PSDevice pDevice)
+void INTnsProcessData(struct vnt_private *pDevice)
 {
        PSINTData pINTData;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct net_device_stats *pStats = &pDevice->stats;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
@@ -179,8 +178,7 @@ void INTnsProcessData(PSDevice pDevice)
                                                        NULL);
                        }
                }
-               LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF;
-               HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF;
+               pDevice->qwCurrTSF = cpu_to_le64(pINTData->qwTSF);
                /*DBG_PRN_GRP01(("ISR0 = %02x ,
                  LoTsf =  %08x,
                  HiTsf =  %08x\n",
index e0d2b07ba608d14415f19daee1ae8d0924b6cf65..27c725f1ce1189bee0362cbde8f10d285b901abf 100644 (file)
@@ -47,8 +47,7 @@ typedef struct tagSINTData {
        BYTE byTSR3;
        BYTE byPkt3;
        WORD wTime3;
-       u32 dwLoTSF;
-       u32 dwHiTSF;
+       u64 qwTSF;
        BYTE byISR0;
        BYTE byISR1;
        BYTE byRTSSuccess;
@@ -65,7 +64,7 @@ SINTData, *PSINTData;
 
 /*---------------------  Export Functions  --------------------------*/
 
-void INTvWorkItem(void *Context);
-void INTnsProcessData(PSDevice pDevice);
+void INTvWorkItem(struct vnt_private *);
+void INTnsProcessData(struct vnt_private *);
 
 #endif /* __INT_H__ */
index 52fce690250857eacf0a8a39e667310a77d01f18..880c025496da8e86e4cba595590561b9c46e1ee2 100644 (file)
@@ -55,7 +55,7 @@ static int msglevel = MSG_LEVEL_INFO;
 
 struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        long ldBm;
 
        pDevice->wstats.status = pDevice->eOPMode;
@@ -91,9 +91,9 @@ int iwctl_giwname(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_point *wrq = &wrqu->data;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_scan_req *req = (struct iw_scan_req *)extra;
        BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
        PWLAN_IE_SSID pItemSSID = NULL;
@@ -169,8 +169,8 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
        int ii;
        int jj;
        int kk;
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        PKnownBSS pBSS;
        PWLAN_IE_SSID pItemSSID;
        PWLAN_IE_SUPP_RATES pSuppRates;
@@ -309,7 +309,7 @@ int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_freq *wrq = &wrqu->freq;
        int rc = 0;
 
@@ -348,9 +348,9 @@ int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_freq *wrq = &wrqu->freq;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ\n");
 
@@ -379,9 +379,9 @@ int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        __u32 *wmode = &wrqu->mode;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        int rc = 0;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE\n");
@@ -492,9 +492,9 @@ int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwmode(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        __u32 *wmode = &wrqu->mode;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE\n");
 
@@ -631,9 +631,9 @@ int iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct sockaddr *wrq = &wrqu->ap_addr;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        int rc = 0;
        BYTE ZeroBSSID[WLAN_BSSID_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
@@ -683,9 +683,9 @@ int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwap(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct sockaddr *wrq = &wrqu->ap_addr;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP\n");
 
@@ -713,8 +713,8 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
        struct iw_point *wrq = &wrqu->data;
        struct sockaddr *sock;
        struct iw_quality *qual;
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &pDevice->sMgmtObj;
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        PKnownBSS pBSS = &pMgmt->sBSSList[0];
        int ii;
        int jj;
@@ -771,9 +771,9 @@ int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_point *wrq = &wrqu->essid;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        PWLAN_IE_SSID pItemSSID;
 
        if (pMgmt == NULL)
@@ -878,9 +878,9 @@ int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_point *wrq = &wrqu->essid;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        PWLAN_IE_SSID pItemSSID;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID\n");
@@ -908,7 +908,7 @@ int iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->bitrate;
        int rc = 0;
        u8 brate = 0;
@@ -986,9 +986,9 @@ int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->bitrate;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE\n");
 
@@ -1037,7 +1037,7 @@ int iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->rts;
 
        if ((wrq->value < 0 || wrq->value > 2312) && !wrq->disabled)
@@ -1057,7 +1057,7 @@ int iwctl_siwrts(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->rts;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS\n");
@@ -1073,7 +1073,7 @@ int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->frag;
        int rc = 0;
        int fthr = wrq->value;
@@ -1097,7 +1097,7 @@ int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->frag;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG\n");
@@ -1113,7 +1113,7 @@ int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->retry;
        int rc = 0;
 
@@ -1146,7 +1146,7 @@ int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->retry;
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY\n");
        wrq->disabled = 0; // Can't be disabled
@@ -1173,8 +1173,8 @@ int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_point *wrq = &wrqu->encoding;
        u32 dwKeyIndex = (u32)(wrq->flags & IW_ENCODE_INDEX);
        int ii;
@@ -1271,8 +1271,8 @@ int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_point *wrq = &wrqu->encoding;
        char abyKey[WLAN_WEP232_KEYLEN];
 
@@ -1333,8 +1333,8 @@ int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_param *wrq = &wrqu->power;
        int rc = 0;
 
@@ -1385,8 +1385,8 @@ int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_param *wrq = &wrqu->power;
        int mode = pDevice->ePSMode;
 
@@ -1418,7 +1418,7 @@ int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
 int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iw_param *wrq = &wrqu->sens;
        long ldBm;
 
@@ -1437,8 +1437,8 @@ int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_param *wrq = &wrqu->param;
        int ret = 0;
        static int wpa_version = 0; // must be static to save the last value, einsn liu
@@ -1547,8 +1547,8 @@ int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_point *wrq = &wrqu->data;
        int ret = 0;
 
@@ -1582,8 +1582,8 @@ out: // not completely ...not necessary in wpa_supplicant 0.5.8
 int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_point *wrq = &wrqu->data;
        int ret = 0;
        int space = wrq->length;
@@ -1608,8 +1608,8 @@ int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_point *wrq = &wrqu->encoding;
        struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
        struct viawget_wpa_param *param=NULL;
@@ -1741,8 +1741,8 @@ int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info,
 int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
                union iwreq_data *wrqu, char *extra)
 {
-       PSDevice pDevice = netdev_priv(dev);
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        struct iw_mlme *mlme = (struct iw_mlme *)extra;
        int ret = 0;
 
index 8c78b86b5c807886cad98ae299e3ddad4b8f8fa5..87eab91293c1544ff80770671442f691ba85677b 100644 (file)
@@ -60,13 +60,12 @@ static int          msglevel                =MSG_LEVEL_INFO;
 /*---------------------  Static Variables  --------------------------*/
 
 /*---------------------  Static Functions  --------------------------*/
-static void s_vCheckKeyTableValid(void *pDeviceHandler,
-                                 PSKeyManagement pTable)
+static void s_vCheckKeyTableValid(struct vnt_private *pDevice,
+       PSKeyManagement pTable)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int         i;
-    WORD        wLength = 0;
-    BYTE        pbyData[MAX_KEY_TABLE];
+       int i;
+       u16 wLength = 0;
+       u8 pbyData[MAX_KEY_TABLE];
 
     for (i=0;i<MAX_KEY_TABLE;i++) {
         if ((pTable->KeyTable[i].bInUse == TRUE) &&
@@ -112,12 +111,10 @@ static void s_vCheckKeyTableValid(void *pDeviceHandler,
  * Return Value: none
  *
  */
-void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable)
+void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int i;
-    int jj;
-    BYTE       pbyData[MAX_KEY_TABLE+1];
+       int i, jj;
+       u8 pbyData[MAX_KEY_TABLE+1];
 
     spin_lock_irq(&pDevice->lock);
     for (i=0;i<MAX_KEY_TABLE;i++) {
@@ -164,12 +161,12 @@ void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable)
  * Return Value: TRUE if found otherwise FALSE
  *
  */
-BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex,
-               PSKeyItem *pKey)
+int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex,
+       PSKeyItem *pKey)
 {
-    int i;
+       int i;
 
-    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey() \n");
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey()\n");
 
     *pKey = NULL;
     for (i=0;i<MAX_KEY_TABLE;i++) {
@@ -218,22 +215,13 @@ BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex,
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-BOOL KeybSetKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    )
+int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u8 *pbyBSSID, u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int         i,j;
-    unsigned int        ii;
-    PSKeyItem   pKey;
-    unsigned int        uKeyIdx;
+       PSKeyItem   pKey;
+       int i, j, ii;
+       u32 uKeyIdx;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
                "Enter KeybSetKey: %X\n", dwKeyIndex);
@@ -286,13 +274,11 @@ BOOL KeybSetKey(
             }
             MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey);
 
-            if ((dwKeyIndex & USE_KEYRSC) == 0) {
-                // RSC set by NIC
-                   memset(&(pKey->KeyRSC), 0, sizeof(QWORD));
-            }
-            else {
-                memcpy(&(pKey->KeyRSC), pKeyRSC,  sizeof(QWORD));
-            }
+               if ((dwKeyIndex & USE_KEYRSC) == 0)
+                       pKey->KeyRSC = 0; /* RSC set by NIC */
+               else
+                       pKey->KeyRSC = *KeyRSC;
+
             pKey->dwTSC47_16 = 0;
             pKey->wTSC15_0 = 0;
 
@@ -356,13 +342,11 @@ BOOL KeybSetKey(
         }
         MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey);
 
-        if ((dwKeyIndex & USE_KEYRSC) == 0) {
-            // RSC set by NIC
-               memset(&(pKey->KeyRSC), 0, sizeof(QWORD));
-        }
-        else {
-            memcpy(&(pKey->KeyRSC), pKeyRSC,  sizeof(QWORD));
-        }
+               if ((dwKeyIndex & USE_KEYRSC) == 0)
+                       pKey->KeyRSC = 0; /* RSC set by NIC */
+               else
+                       pKey->KeyRSC = *KeyRSC;
+
         pKey->dwTSC47_16 = 0;
         pKey->wTSC15_0 = 0;
 
@@ -401,16 +385,12 @@ BOOL KeybSetKey(
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-BOOL KeybRemoveKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID,
-    DWORD           dwKeyIndex
-    )
+
+int KeybRemoveKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u8 *pbyBSSID, u32 dwKeyIndex)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int     i;
-    BOOL    bReturnValue = FALSE;
+       int i;
+       int bReturnValue = FALSE;
 
     if (is_broadcast_ether_addr(pbyBSSID)) {
         // delete all keys
@@ -482,14 +462,10 @@ BOOL KeybRemoveKey(
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-BOOL KeybRemoveAllKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID
-    )
+int KeybRemoveAllKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u8 *pbyBSSID)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int  i,u;
+       int i, u;
 
     for (i=0;i<MAX_KEY_TABLE;i++) {
         if ((pTable->KeyTable[i].bInUse == TRUE) &&
@@ -518,13 +494,9 @@ BOOL KeybRemoveAllKey(
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-void KeyvRemoveWEPKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex
-    )
+void KeyvRemoveWEPKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u32 dwKeyIndex)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
 
    if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
         if (pTable->KeyTable[MAX_KEY_TABLE-1].bInUse == TRUE) {
@@ -541,9 +513,8 @@ void KeyvRemoveWEPKey(
     return;
 }
 
-void KeyvRemoveAllWEPKey(void *pDeviceHandler, PSKeyManagement pTable)
+void KeyvRemoveAllWEPKey(struct vnt_private *pDevice, PSKeyManagement pTable)
 {
-       PSDevice pDevice = (PSDevice) pDeviceHandler;
        int i;
 
        for (i = 0; i < MAX_GROUP_KEY; i++)
@@ -563,12 +534,13 @@ void KeyvRemoveAllWEPKey(void *pDeviceHandler, PSKeyManagement pTable)
  * Return Value: TRUE if found otherwise FALSE
  *
  */
-BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
-                       PSKeyItem *pKey)
+int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType,
+       PSKeyItem *pKey)
 {
-    int i, ii;
+       int i, ii;
+
+       *pKey = NULL;
 
-    *pKey = NULL;
     for (i = 0; i < MAX_KEY_TABLE; i++) {
         if ((pTable->KeyTable[i].bInUse == TRUE) &&
            !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
@@ -640,11 +612,12 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
  * Return Value: TRUE if found otherwise FALSE
  *
  */
-BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey)
+int KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey)
 {
-    int i;
+       int i;
+
+       *pKey = NULL;
 
-    *pKey = NULL;
     for (i=0;i<MAX_KEY_TABLE;i++) {
         if ((pTable->KeyTable[i].bInUse == TRUE) &&
             (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE)) {
@@ -671,20 +644,14 @@ BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey)
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-BOOL KeybSetDefaultKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    )
+
+int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    unsigned int        ii;
-    PSKeyItem   pKey;
-    unsigned int        uKeyIdx;
+       int ii;
+       PSKeyItem pKey;
+       u32 uKeyIdx;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d\n",
            (int) dwKeyIndex, (int) uKeyLength);
@@ -742,12 +709,12 @@ BOOL KeybSetDefaultKey(
 
     MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD) pKey->abyKey);
 
-    if ((dwKeyIndex & USE_KEYRSC) == 0) {
-        // RSC set by NIC
-           memset(&(pKey->KeyRSC), 0, sizeof(QWORD));
-    } else {
-        memcpy(&(pKey->KeyRSC), pKeyRSC,  sizeof(QWORD));
-    }
+               if ((dwKeyIndex & USE_KEYRSC) == 0)
+                       pKey->KeyRSC = 0; /* RSC set by NIC */
+               else
+                       pKey->KeyRSC = *KeyRSC;
+
+
     pKey->dwTSC47_16 = 0;
     pKey->wTSC15_0 = 0;
 
@@ -787,21 +754,14 @@ BOOL KeybSetDefaultKey(
  * Return Value: TRUE if success otherwise FALSE
  *
  */
-BOOL KeybSetAllGroupKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    )
+
+int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable,
+       u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode)
 {
-    PSDevice    pDevice = (PSDevice) pDeviceHandler;
-    int         i;
-    unsigned int        ii;
-    PSKeyItem   pKey;
-    unsigned int        uKeyIdx;
+       int i, ii;
+       PSKeyItem pKey;
+       u32 uKeyIdx;
 
        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %X\n",
                dwKeyIndex);
@@ -847,13 +807,11 @@ BOOL KeybSetAllGroupKey(
 
             MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD) pKey->abyKey);
 
-            if ((dwKeyIndex & USE_KEYRSC) == 0) {
-                // RSC set by NIC
-                   memset(&(pKey->KeyRSC), 0, sizeof(QWORD));
-            }
-            else {
-                memcpy(&(pKey->KeyRSC), pKeyRSC,  sizeof(QWORD));
-            }
+               if ((dwKeyIndex & USE_KEYRSC) == 0)
+                       pKey->KeyRSC = 0; /* RSC set by NIC */
+               else
+                       pKey->KeyRSC = *KeyRSC;
+
             pKey->dwTSC47_16 = 0;
             pKey->wTSC15_0 = 0;
 
index bd35d39621ae11664bd48dcd200b7ea9d7e5033d..888942331ea0f862dc01becf9424ffbcbe677b69 100644 (file)
@@ -60,7 +60,7 @@ typedef struct tagSKeyItem
     BOOL        bKeyValid;
        u32 uKeyLength;
     BYTE        abyKey[MAX_KEY_LEN];
-    QWORD       KeyRSC;
+       u64 KeyRSC;
     DWORD       dwTSC47_16;
     WORD        wTSC15_0;
     BYTE        byCipherSuite;
@@ -97,69 +97,37 @@ typedef struct tagSKeyManagement
 
 /*---------------------  Export Functions  --------------------------*/
 
-void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable);
-
-BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex,
-               PSKeyItem *pKey);
-
-BOOL KeybSetKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    );
-
-BOOL KeybRemoveKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID,
-    DWORD           dwKeyIndex
-    );
-
-BOOL KeybRemoveAllKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    PBYTE           pbyBSSID
-    );
-
-void KeyvRemoveWEPKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex
-    );
-
-void KeyvRemoveAllWEPKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable
-    );
-
-BOOL KeybGetTransmitKey(PSKeyManagement pTable,        PBYTE pbyBSSID, DWORD dwKeyType,
-                       PSKeyItem *pKey);
-
-BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey);
-
-BOOL KeybSetDefaultKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    );
-
-BOOL KeybSetAllGroupKey(
-    void *pDeviceHandler,
-    PSKeyManagement pTable,
-    DWORD           dwKeyIndex,
-       u32 uKeyLength,
-    PQWORD          pKeyRSC,
-    PBYTE           pbyKey,
-    BYTE            byKeyDecMode
-    );
+void KeyvInitTable(struct vnt_private *, PSKeyManagement pTable);
+
+int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex,
+       PSKeyItem *pKey);
+
+int KeybSetKey(struct vnt_private *, PSKeyManagement pTable, u8 *pbyBSSID,
+       u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode);
+
+int KeybRemoveKey(struct vnt_private *, PSKeyManagement pTable,
+       u8 *pbyBSSID, u32 dwKeyIndex);
+
+int KeybRemoveAllKey(struct vnt_private *, PSKeyManagement pTable,
+       u8 *pbyBSSID);
+
+void KeyvRemoveWEPKey(struct vnt_private *, PSKeyManagement pTable,
+       u32 dwKeyIndex);
+
+void KeyvRemoveAllWEPKey(struct vnt_private *, PSKeyManagement pTable);
+
+int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType,
+       PSKeyItem *pKey);
+
+int KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey);
+
+int KeybSetDefaultKey(struct vnt_private *, PSKeyManagement pTable,
+       u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode);
+
+int KeybSetAllGroupKey(struct vnt_private *, PSKeyManagement pTable,
+       u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
+       u8 byKeyDecMode);
 
 #endif /* __KEY_H__ */
index 8fddc7b3930b2c26ad46d8a4521e097838b8b5ad..76d307b58d5246d5432ea77985909ff8a704d0a0 100644 (file)
@@ -68,11 +68,11 @@ static int          msglevel                =MSG_LEVEL_INFO;
  * Return Value: none
  *
  */
-void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx)
+void MACvSetMultiAddrByHash(struct vnt_private *pDevice, u8 byHashIdx)
 {
-    unsigned int            uByteIdx;
-    BYTE            byBitMask;
-    BYTE            pbyData[2];
+       u8 uByteIdx;
+       u8 byBitMask;
+       u8 pbyData[2];
 
 
     // calculate byte position
@@ -110,9 +110,9 @@ void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx)
  * Return Value: none
  *
  */
-void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData)
+void MACvWriteMultiAddr(struct vnt_private *pDevice, u32 uByteIdx, u8 byData)
 {
-    BYTE            byData1;
+       u8 byData1;
 
     byData1 = byData;
     CONTROLnsRequestOut(pDevice,
@@ -135,7 +135,7 @@ void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData)
  *
  *
  */
-void MACbShutdown(PSDevice pDevice)
+void MACbShutdown(struct vnt_private *pDevice)
 {
     CONTROLnsRequestOutAsyn(pDevice,
                         MESSAGE_TYPE_MACSHUTDOWN,
@@ -146,9 +146,9 @@ void MACbShutdown(PSDevice pDevice)
                         );
 }
 
-void MACvSetBBType(PSDevice pDevice,BYTE byType)
+void MACvSetBBType(struct vnt_private *pDevice, u8 byType)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = byType;
@@ -163,9 +163,9 @@ BYTE            pbyData[2];
                         );
 }
 
-void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData)
+void MACvSetMISCFifo(struct vnt_private *pDevice, u16 wOffset, u32 dwData)
 {
-BYTE    pbyData[4];
+       u8 pbyData[4];
 
     if (wOffset > 273)
         return;
@@ -197,10 +197,10 @@ BYTE    pbyData[4];
  * Return Value: none
  *
  */
-void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx)
+void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx)
 {
-WORD    wOffset;
-BYTE            byData;
+       u16 wOffset;
+       u8 byData;
 
 
     byData = (BYTE) uEntryIdx;
@@ -237,20 +237,18 @@ BYTE            byData;
  * Return Value: none
  *
  */
-void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl,
-                    unsigned int uEntryIdx, unsigned int uKeyIdx,
-                    PBYTE pbyAddr, PDWORD pdwKey)
+void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx,
+       u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey)
 {
-PBYTE           pbyKey;
-WORD            wOffset;
-DWORD           dwData1,dwData2;
-int             ii;
-BYTE            pbyData[24];
-
-    if ( pDevice->byLocalID <= MAC_REVISION_A1 ) {
-        if ( pDevice->sMgmtObj.byCSSPK == KEY_CTL_CCMP )
-            return;
-    }
+       u8 *pbyKey;
+       u16 wOffset;
+       u32 dwData1, dwData2;
+       int ii;
+       u8 pbyData[24];
+
+       if (pDevice->byLocalID <= MAC_REVISION_A1)
+               if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP)
+                       return;
 
     wOffset = MISCFIFO_KEYETRY0;
     wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
@@ -321,9 +319,9 @@ BYTE            pbyData[24];
 }
 
 
-void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
+void MACvRegBitsOff(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
     pbyData[0] = 0;
     pbyData[1] = byBits;
@@ -338,9 +336,9 @@ BYTE            pbyData[2];
 }
 
 
-void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
+void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = byBits;
@@ -355,9 +353,9 @@ BYTE            pbyData[2];
                         );
 }
 
-void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData)
+void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = (BYTE)(wData & 0xff);
@@ -373,9 +371,9 @@ BYTE            pbyData[2];
 
 }
 
-void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr)
+void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr)
 {
-BYTE            pbyData[6];
+       u8 pbyData[6];
 
 
     pbyData[0] = *((PBYTE)pbyEtherAddr);
@@ -394,9 +392,9 @@ BYTE            pbyData[6];
                         );
 }
 
-void MACvEnableProtectMD(PSDevice pDevice)
+void MACvEnableProtectMD(struct vnt_private *pDevice)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = EnCFG_ProtectMd;
@@ -411,9 +409,9 @@ BYTE            pbyData[2];
                         );
 }
 
-void MACvDisableProtectMD(PSDevice pDevice)
+void MACvDisableProtectMD(struct vnt_private *pDevice)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = 0;
@@ -428,9 +426,9 @@ BYTE            pbyData[2];
                         );
 }
 
-void MACvEnableBarkerPreambleMd(PSDevice pDevice)
+void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = EnCFG_BarkerPream;
@@ -445,9 +443,9 @@ BYTE            pbyData[2];
                         );
 }
 
-void MACvDisableBarkerPreambleMd(PSDevice pDevice)
+void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
 
     pbyData[0] = 0;
@@ -463,12 +461,12 @@ BYTE            pbyData[2];
 }
 
 
-void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval)
+void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval)
 {
-BYTE            pbyData[2];
+       u8 pbyData[2];
 
-    pbyData[0] = (BYTE) (wInterval & 0xff);
-    pbyData[1] = (BYTE) (wInterval >> 8);
+       pbyData[0] = (u8)(wInterval & 0xff);
+       pbyData[1] = (u8)(wInterval >> 8);
 
     CONTROLnsRequestOut(pDevice,
                        MESSAGE_TYPE_WRITE,
index 147ac50218d3a29d40d5545a16d7ed165aad7d12..6e28500ae5f824dde2f7fe8aadd795ccc3328249 100644 (file)
 
 /*---------------------  Export Functions  --------------------------*/
 
-void MACvSetMultiAddrByHash(PSDevice pDevice, BYTE byHashIdx);
-void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData);
-void MACbShutdown(PSDevice pDevice);
-void MACvSetBBType(PSDevice pDevice, BYTE byType);
-void MACvSetMISCFifo(PSDevice pDevice, WORD wOffset, DWORD dwData);
-void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx);
-void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl, unsigned int uEntryIdx,
-                    unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey);
-
-void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits);
-void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits);
-void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData);
-
-void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr);
-void MACvEnableProtectMD(PSDevice pDevice);
-void MACvDisableProtectMD(PSDevice pDevice);
-void MACvEnableBarkerPreambleMd(PSDevice pDevice);
-void MACvDisableBarkerPreambleMd(PSDevice pDevice);
-void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval);
+void MACvSetMultiAddrByHash(struct vnt_private *, u8);
+void MACvWriteMultiAddr(struct vnt_private *, u32, u8);
+void MACbShutdown(struct vnt_private *);
+void MACvSetBBType(struct vnt_private *, u8);
+void MACvSetMISCFifo(struct vnt_private *pDevice, u16, u32);
+void MACvDisableKeyEntry(struct vnt_private *, u32);
+void MACvSetKeyEntry(struct vnt_private *, u16, u32, u32, u8 *, u32 *);
+void MACvRegBitsOff(struct vnt_private *, u8, u8);
+void MACvRegBitsOn(struct vnt_private *, u8, u8);
+void MACvWriteWord(struct vnt_private *, u8, u16);
+void MACvWriteBSSIDAddress(struct vnt_private *, u8 *);
+void MACvEnableProtectMD(struct vnt_private *);
+void MACvDisableProtectMD(struct vnt_private *);
+void MACvEnableBarkerPreambleMd(struct vnt_private *);
+void MACvDisableBarkerPreambleMd(struct vnt_private *);
+void MACvWriteBeaconInterval(struct vnt_private *, u16);
 
 #endif /* __MAC_H__ */
index f33086d66496f0b178bc5fd5748fc42b89d168c3..99ac7eb6cdfe06e03c7c0b6665b3c05f900a2fa7 100644 (file)
@@ -225,26 +225,27 @@ 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);
 
-static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType);
-static BOOL device_init_defrag_cb(PSDevice pDevice);
-static void device_init_diversity_timer(PSDevice pDevice);
+static int device_init_registers(struct vnt_private *pDevice,
+       DEVICE_INIT_TYPE InitType);
+static BOOL device_init_defrag_cb(struct vnt_private *pDevice);
+static void device_init_diversity_timer(struct vnt_private *pDevice);
 static int  device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
 
 static int  ethtool_ioctl(struct net_device *dev, void *useraddr);
-static void device_free_tx_bufs(PSDevice pDevice);
-static void device_free_rx_bufs(PSDevice pDevice);
-static void device_free_int_bufs(PSDevice pDevice);
-static void device_free_frag_bufs(PSDevice pDevice);
-static BOOL device_alloc_bufs(PSDevice pDevice);
-
-static int Read_config_file(PSDevice pDevice);
-static unsigned char *Config_FileOperation(PSDevice pDevice);
+static void device_free_tx_bufs(struct vnt_private *pDevice);
+static void device_free_rx_bufs(struct vnt_private *pDevice);
+static void device_free_int_bufs(struct vnt_private *pDevice);
+static void device_free_frag_bufs(struct vnt_private *pDevice);
+static BOOL device_alloc_bufs(struct vnt_private *pDevice);
+
+static int Read_config_file(struct vnt_private *pDevice);
+static unsigned char *Config_FileOperation(struct vnt_private *pDevice);
 static int Config_FileGetParameter(unsigned char *string,
                                   unsigned char *dest,
                                   unsigned char *source);
 
 
-static void usb_device_reset(PSDevice pDevice);
+static void usb_device_reset(struct vnt_private *pDevice);
 
 
 
@@ -254,7 +255,7 @@ static void usb_device_reset(PSDevice pDevice);
 
 
 static void
-device_set_options(PSDevice pDevice) {
+device_set_options(struct vnt_private *pDevice) {
 
     BYTE    abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
     BYTE    abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
@@ -292,7 +293,7 @@ device_set_options(PSDevice pDevice) {
 }
 
 
-static void device_init_diversity_timer(PSDevice pDevice)
+static void device_init_diversity_timer(struct vnt_private *pDevice)
 {
     init_timer(&pDevice->TimerSQ3Tmax1);
     pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice;
@@ -317,21 +318,21 @@ static void device_init_diversity_timer(PSDevice pDevice)
 // Initialization of MAC & BBP registers
 //
 
-static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
+static int device_init_registers(struct vnt_private *pDevice,
+       DEVICE_INIT_TYPE InitType)
 {
-    u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-    u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-    u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
-    BYTE            byAntenna;
-    unsigned int            ii;
-    CMD_CARD_INIT   sInitCmd;
-    int ntStatus = STATUS_SUCCESS;
-    RSP_CARD_INIT   sInitRsp;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    BYTE            byTmp;
-    BYTE            byCalibTXIQ = 0;
-    BYTE            byCalibTXDC = 0;
-    BYTE            byCalibRXIQ = 0;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+       u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
+       u8 abySNAP_Bridgetunnel[ETH_ALEN]
+               = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
+       u8 byAntenna;
+       int ii;
+       CMD_CARD_INIT sInitCmd;
+       int ntStatus = STATUS_SUCCESS;
+       RSP_CARD_INIT   sInitRsp;
+       u8 byTmp;
+       u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
        spin_lock_irq(&pDevice->lock);
@@ -636,7 +637,7 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
 
 static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
 {
-       PSDevice device = usb_get_intfdata(intf);
+       struct vnt_private *device = usb_get_intfdata(intf);
 
        if (!device || !device->dev)
                return -ENODEV;
@@ -651,7 +652,7 @@ static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
 
 static int vt6656_resume(struct usb_interface *intf)
 {
-       PSDevice device = usb_get_intfdata(intf);
+       struct vnt_private *device = usb_get_intfdata(intf);
 
        if (!device || !device->dev)
                return -ENODEV;
@@ -682,13 +683,13 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
        struct usb_device *udev = interface_to_usbdev(intf);
        int rc = 0;
        struct net_device *netdev = NULL;
-       PSDevice pDevice = NULL;
+       struct vnt_private *pDevice;
 
        printk(KERN_NOTICE "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
        printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
 
        udev = usb_get_dev(udev);
-       netdev = alloc_etherdev(sizeof(DEVICE_INFO));
+       netdev = alloc_etherdev(sizeof(struct vnt_private));
        if (!netdev) {
                printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n");
                rc = -ENOMEM;
@@ -696,7 +697,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
        }
 
        pDevice = netdev_priv(netdev);
-       memset(pDevice, 0, sizeof(DEVICE_INFO));
+       memset(pDevice, 0, sizeof(struct vnt_private));
 
        pDevice->dev = netdev;
        pDevice->usb = udev;
@@ -705,7 +706,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
        spin_lock_init(&pDevice->lock);
 
        pDevice->tx_80211 = device_dma0_tx_80211;
-       pDevice->sMgmtObj.pAdapter = (void *) pDevice;
+       pDevice->vnt_mgmt.pAdapter = (void *) pDevice;
 
        netdev->netdev_ops = &device_netdev_ops;
        netdev->wireless_handlers =
@@ -732,7 +733,7 @@ err_nomem:
        return rc;
 }
 
-static void device_free_tx_bufs(PSDevice pDevice)
+static void device_free_tx_bufs(struct vnt_private *pDevice)
 {
     PUSB_SEND_CONTEXT pTxContext;
     int ii;
@@ -751,7 +752,7 @@ static void device_free_tx_bufs(PSDevice pDevice)
 }
 
 
-static void device_free_rx_bufs(PSDevice pDevice)
+static void device_free_rx_bufs(struct vnt_private *pDevice)
 {
     PRCB pRCB;
     int ii;
@@ -773,7 +774,7 @@ static void device_free_rx_bufs(PSDevice pDevice)
     return;
 }
 
-static void usb_device_reset(PSDevice pDevice)
+static void usb_device_reset(struct vnt_private *pDevice)
 {
  int status;
  status = usb_reset_device(pDevice->usb);
@@ -782,14 +783,15 @@ static void usb_device_reset(PSDevice pDevice)
        return ;
 }
 
-static void device_free_int_bufs(PSDevice pDevice)
+static void device_free_int_bufs(struct vnt_private *pDevice)
 {
     kfree(pDevice->intBuf.pDataBuf);
     return;
 }
 
 
-static BOOL device_alloc_bufs(PSDevice pDevice) {
+static BOOL device_alloc_bufs(struct vnt_private *pDevice)
+{
 
     PUSB_SEND_CONTEXT pTxContext;
     PRCB pRCB;
@@ -888,9 +890,10 @@ free_tx:
 
 
 
-static BOOL device_init_defrag_cb(PSDevice pDevice) {
-    int i;
-    PSDeFragControlBlock pDeF;
+static BOOL device_init_defrag_cb(struct vnt_private *pDevice)
+{
+       int i;
+       PSDeFragControlBlock pDeF;
 
     /* Init the fragment ctl entries */
     for (i = 0; i < CB_MAX_RX_FRAG; i++) {
@@ -912,9 +915,10 @@ free_frag:
 
 
 
-static void device_free_frag_bufs(PSDevice pDevice) {
-    PSDeFragControlBlock pDeF;
-    int i;
+static void device_free_frag_bufs(struct vnt_private *pDevice)
+{
+       PSDeFragControlBlock pDeF;
+       int i;
 
     for (i = 0; i < CB_MAX_RX_FRAG; i++) {
 
@@ -927,7 +931,9 @@ static void device_free_frag_bufs(PSDevice pDevice) {
 
 
 
-BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) {
+int device_alloc_frag_buf(struct vnt_private *pDevice,
+               PSDeFragControlBlock pDeF)
+{
 
     pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
     if (pDeF->skb == NULL)
@@ -941,8 +947,9 @@ BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) {
 
 /*-----------------------------------------------------------------*/
 
-static int  device_open(struct net_device *dev) {
-    PSDevice    pDevice=(PSDevice) netdev_priv(dev);
+static int  device_open(struct net_device *dev)
+{
+       struct vnt_private *pDevice = netdev_priv(dev);
 
      pDevice->fWPA_Authened = FALSE;
 
@@ -979,7 +986,8 @@ static int  device_open(struct net_device *dev) {
     // Init for Key Management
 
     KeyvInitTable(pDevice,&pDevice->sKey);
-    memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN);
+       memcpy(pDevice->vnt_mgmt.abyMACAddr,
+               pDevice->abyCurrentNetAddr, ETH_ALEN);
     memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
     pDevice->bStopTx0Pkt = FALSE;
     pDevice->bStopDataPkt = FALSE;
@@ -994,7 +1002,7 @@ static int  device_open(struct net_device *dev) {
     tasklet_init(&pDevice->RxMngWorkItem, (void *)RXvMngWorkItem, (unsigned long)pDevice);
     tasklet_init(&pDevice->ReadWorkItem, (void *)RXvWorkItem, (unsigned long)pDevice);
     tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice);
-    add_timer(&(pDevice->sMgmtObj.sTimerSecondCallback));
+       add_timer(&pDevice->vnt_mgmt.sTimerSecondCallback);
     pDevice->int_interval = 100;  //Max 100 microframes.
     pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
 
@@ -1028,14 +1036,10 @@ static int  device_open(struct net_device *dev) {
          pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
     }
 
-    if (pDevice->sMgmtObj.eConfigMode == WMAC_CONFIG_AP) {
+       if (pDevice->vnt_mgmt.eConfigMode == WMAC_CONFIG_AP)
                bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
-       }
-       else {
-       //mike:mark@2008-11-10
-         bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
-         /* bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL); */
-    }
+       else
+               bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
 
 
     netif_stop_queue(pDevice->dev);
@@ -1061,13 +1065,13 @@ free_rx_tx:
 
 
 
-static int  device_close(struct net_device *dev) {
-    PSDevice    pDevice=(PSDevice) netdev_priv(dev);
-    PSMgmtObject     pMgmt = &(pDevice->sMgmtObj);
-
-        int uu;
+static int device_close(struct net_device *dev)
+{
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int uu;
 
-    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1 \n");
+       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n");
     if (pDevice == NULL)
         return -ENODEV;
 
@@ -1136,7 +1140,7 @@ static int  device_close(struct net_device *dev) {
 
 static void vt6656_disconnect(struct usb_interface *intf)
 {
-       PSDevice device = usb_get_intfdata(intf);
+       struct vnt_private *device = usb_get_intfdata(intf);
 
        if (!device)
                return;
@@ -1156,7 +1160,7 @@ static void vt6656_disconnect(struct usb_interface *intf)
 
 static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
 
        spin_lock_irq(&pDevice->lock);
 
@@ -1172,7 +1176,7 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev)
 
 static int device_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-       PSDevice pDevice = netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct net_device_stats *stats = &pDevice->stats;
 
        spin_lock_irq(&pDevice->lock);
@@ -1290,7 +1294,7 @@ static int Config_FileGetParameter(unsigned char *string,
 }
 
 //if read fail,return NULL,or return data pointer;
-static unsigned char *Config_FileOperation(PSDevice pDevice)
+static unsigned char *Config_FileOperation(struct vnt_private *pDevice)
 {
     unsigned char *config_path = CONFIG_PATH;
     unsigned char *buffer = NULL;
@@ -1354,10 +1358,11 @@ if(result!=0) {
 }
 
 //return --->-1:fail;  >=0:successful
-static int Read_config_file(PSDevice pDevice) {
-  int result = 0;
-  unsigned char tmpbuffer[100];
-  unsigned char *buffer = NULL;
+static int Read_config_file(struct vnt_private *pDevice)
+{
+       int result = 0;
+       unsigned char tmpbuffer[100];
+       unsigned char *buffer = NULL;
 
   //init config setting
  pDevice->config_file.ZoneType = -1;
@@ -1406,15 +1411,16 @@ static int Read_config_file(PSDevice pDevice) {
   return result;
 }
 
-static void device_set_multi(struct net_device *dev) {
-    PSDevice         pDevice = (PSDevice) netdev_priv(dev);
-    PSMgmtObject     pMgmt = &(pDevice->sMgmtObj);
-    u32              mc_filter[2];
-    int              ii;
-    struct netdev_hw_addr *ha;
-    BYTE             pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
-    BYTE             byTmpMode = 0;
-    int              rc;
+static void device_set_multi(struct net_device *dev)
+{
+       struct vnt_private *pDevice = netdev_priv(dev);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct netdev_hw_addr *ha;
+       u32 mc_filter[2];
+       int ii;
+       u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+       u8 byTmpMode = 0;
+       int rc;
 
 
        spin_lock_irq(&pDevice->lock);
@@ -1472,14 +1478,14 @@ static void device_set_multi(struct net_device *dev) {
 
 static struct net_device_stats *device_get_stats(struct net_device *dev)
 {
-    PSDevice pDevice=(PSDevice) netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
 
-    return &pDevice->stats;
+       return &pDevice->stats;
 }
 
 static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       PSDevice pDevice = (PSDevice)netdev_priv(dev);
+       struct vnt_private *pDevice = netdev_priv(dev);
        struct iwreq *wrq = (struct iwreq *) rq;
        int rc = 0;
 
index ab3a55462056aefa317c096acc6f37d8a3e24449..43965bcc55e312e693e645003d83f1b0bd499734 100644 (file)
@@ -70,12 +70,10 @@ static int msglevel = MSG_LEVEL_INFO;
  *
  */
 
-void PSvEnablePowerSaving(void *hDeviceContext,
-                         WORD wListenInterval)
+void PSvEnablePowerSaving(struct vnt_private *pDevice, u16 wListenInterval)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-       WORD wAID = pMgmt->wCurrAID | BIT14 | BIT15;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u16 wAID = pMgmt->wCurrAID | BIT14 | BIT15;
 
        /* set period of power up before TBTT */
        MACvWriteWord(pDevice, MAC_REG_PWBT, C_PWBT);
@@ -136,10 +134,8 @@ void PSvEnablePowerSaving(void *hDeviceContext,
  *
  */
 
-void PSvDisablePowerSaving(void *hDeviceContext)
+void PSvDisablePowerSaving(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       /* PSMgmtObject pMgmt = &(pDevice->sMgmtObj); */
 
        /* disable power saving hw function */
        CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_DISABLE_PS, 0,
@@ -168,13 +164,11 @@ void PSvDisablePowerSaving(void *hDeviceContext)
  *    FALSE, if fail
  */
 
-BOOL PSbConsiderPowerDown(void *hDeviceContext,
-                         BOOL bCheckRxDMA,
-                         BOOL bCheckCountToWakeUp)
+int PSbConsiderPowerDown(struct vnt_private *pDevice, int bCheckRxDMA,
+       int bCheckCountToWakeUp)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-       BYTE byData;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 byData;
 
        /* check if already in Doze mode */
        ControlvReadByte(pDevice, MESSAGE_REQUEST_MACREG,
@@ -225,15 +219,17 @@ BOOL PSbConsiderPowerDown(void *hDeviceContext,
  *
  */
 
-void PSvSendPSPOLL(void *hDeviceContext)
+void PSvSendPSPOLL(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-       PSTxMgmtPacket pTxPacket = NULL;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+
+       memset(pMgmt->pbyPSPacketPool, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_HDR_ADDR2_LEN);
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyPSPacketPool;
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
 
-       memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN);
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
        pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16(
                (
                        WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) |
@@ -263,11 +259,10 @@ void PSvSendPSPOLL(void *hDeviceContext)
  *
  */
 
-BOOL PSbSendNullPacket(void *hDeviceContext)
+int PSbSendNullPacket(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSTxMgmtPacket pTxPacket = NULL;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        u16 flags = 0;
 
        if (pDevice->bLinkPass == FALSE)
@@ -278,9 +273,11 @@ BOOL PSbSendNullPacket(void *hDeviceContext)
                        return FALSE;
        }
 
-       memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN);
-       pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool;
-       pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       memset(pMgmt->pbyPSPacketPool, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_NULLDATA_FR_MAXLEN);
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyPSPacketPool;
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
 
        flags = WLAN_SET_FC_FTYPE(WLAN_TYPE_DATA) |
                         WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_NULL);
@@ -318,11 +315,10 @@ BOOL PSbSendNullPacket(void *hDeviceContext)
  *
  */
 
-BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext)
+int PSbIsNextTBTTWakeUp(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-       BOOL bWakeUp = FALSE;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int bWakeUp = FALSE;
 
        if (pMgmt->wListenInterval >= 2) {
                if (pMgmt->wCountToWakeUp == 0)
index 41bffe528b44c363512854306c1e79710f131ccb..879b10c0d42e6ce1e7c2f8fc2d67754f64e5baea 100644 (file)
 /*  PSDevice pDevice */
 /*  PSDevice hDeviceContext */
 
-BOOL PSbConsiderPowerDown(void *hDeviceContext,
-                         BOOL bCheckRxDMA,
-                         BOOL bCheckCountToWakeUp);
-
-void PSvDisablePowerSaving(void *hDeviceContext);
-void PSvEnablePowerSaving(void *hDeviceContext, WORD wListenInterval);
-void PSvSendPSPOLL(void *hDeviceContext);
-BOOL PSbSendNullPacket(void *hDeviceContext);
-BOOL PSbIsNextTBTTWakeUp(void *hDeviceContext);
+int PSbConsiderPowerDown(struct vnt_private *, int bCheckRxDMA,
+       int bCheckCountToWakeUp);
+void PSvDisablePowerSaving(struct vnt_private *);
+void PSvEnablePowerSaving(struct vnt_private *, u16 wListenInterval);
+void PSvSendPSPOLL(struct vnt_private *);
+int PSbSendNullPacket(struct vnt_private *);
+int PSbIsNextTBTTWakeUp(struct vnt_private *);
 
 #endif /* __POWER_H__ */
index 74c0598e37b7c4b03742b06375a56adc10f34994..5785eec7fb1257ebb33b8e2db55a8b3c4ace0191 100644 (file)
@@ -69,7 +69,7 @@ static int          msglevel                =MSG_LEVEL_INFO;
 
 
 
-BYTE abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = {
+u8 abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = {
     {0x03, 0xF7, 0x90},
     {0x03, 0x33, 0x31},
     {0x01, 0xB8, 0x02},
@@ -87,7 +87,7 @@ BYTE abyAL2230InitTable[CB_AL2230_INIT_SEQ][3] = {
     {0x00, 0x58, 0x0F}
     };
 
-BYTE abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
+u8 abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
     {0x03, 0xF7, 0x90}, // channel = 1, Tf = 2412MHz
     {0x03, 0xF7, 0x90}, // channel = 2, Tf = 2417MHz
     {0x03, 0xE7, 0x90}, // channel = 3, Tf = 2422MHz
@@ -104,7 +104,7 @@ BYTE abyAL2230ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
     {0x03, 0xE7, 0xC0}  // channel = 14, Tf = 2412M
     };
 
-BYTE abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
+u8 abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
     {0x03, 0x33, 0x31}, // channel = 1, Tf = 2412MHz
     {0x0B, 0x33, 0x31}, // channel = 2, Tf = 2417MHz
     {0x03, 0x33, 0x31}, // channel = 3, Tf = 2422MHz
@@ -123,7 +123,7 @@ BYTE abyAL2230ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
 
 // 40MHz reference frequency
 // Need to Pull PLLON(PE3) low when writing channel registers through 3-wire.
-BYTE abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = {
+u8 abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = {
     {0x20, 0x37, 0x90}, // Channel1 // Need modify for 11a
     {0x13, 0x33, 0x31}, // Channel1 // Need modify for 11a
     {0x84, 0x1F, 0xF2}, // Need modify for 11a: 451FE2
@@ -146,7 +146,7 @@ BYTE abyAL7230InitTable[CB_AL7230_INIT_SEQ][3] = {
     {0x1A, 0xBA, 0x8F} // Need modify for 11a: 12BACF
     };
 
-BYTE abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = {
+u8 abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = {
     {0x2F, 0xF5, 0x20}, // Channel184 // Need modify for 11b/g
     {0x00, 0x00, 0x01}, // Channel184 // Need modify for 11b/g
     {0x45, 0x1F, 0xE2}, // Need modify for 11b/g
@@ -165,7 +165,7 @@ BYTE abyAL7230InitTableAMode[CB_AL7230_INIT_SEQ][3] = {
     {0x12, 0xBA, 0xCF} // Need modify for 11b/g
     };
 
-BYTE abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = {
+u8 abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = {
     {0x20, 0x37, 0x90}, // channel =  1, Tf = 2412MHz
     {0x20, 0x37, 0x90}, // channel =  2, Tf = 2417MHz
     {0x20, 0x37, 0x90}, // channel =  3, Tf = 2422MHz
@@ -231,7 +231,7 @@ BYTE abyAL7230ChannelTable0[CB_MAX_CHANNEL][3] = {
     {0x2F, 0xF6, 0x10} // channel = 165, Tf = 5825MHz (56)
     };
 
-BYTE abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = {
+u8 abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = {
     {0x13, 0x33, 0x31}, // channel =  1, Tf = 2412MHz
     {0x1B, 0x33, 0x31}, // channel =  2, Tf = 2417MHz
     {0x03, 0x33, 0x31}, // channel =  3, Tf = 2422MHz
@@ -295,7 +295,7 @@ BYTE abyAL7230ChannelTable1[CB_MAX_CHANNEL][3] = {
     {0x02, 0xAA, 0xB1}  // channel = 165, Tf = 5825MHz (56)
     };
 
-BYTE abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = {
+u8 abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = {
     {0x7F, 0xD7, 0x84}, // channel =  1, Tf = 2412MHz
     {0x7F, 0xD7, 0x84}, // channel =  2, Tf = 2417MHz
     {0x7F, 0xD7, 0x84}, // channel =  3, Tf = 2422MHz
@@ -360,7 +360,7 @@ BYTE abyAL7230ChannelTable2[CB_MAX_CHANNEL][3] = {
     };
 
 ///{{RobertYu:20051111
-BYTE abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = {
+u8 abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = {
     {0x03, 0xFF, 0x80},
     {0x02, 0x82, 0xA1},
     {0x03, 0xC6, 0xA2},
@@ -374,7 +374,7 @@ BYTE abyVT3226_InitTable[CB_VT3226_INIT_SEQ][3] = {
     {0x02, 0x00, 0x2A}
     };
 
-BYTE abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = {
+u8 abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = {
     {0x03, 0xFF, 0x80},
     {0x03, 0x02, 0x21}, //RobertYu:20060327
     {0x03, 0xC6, 0xA2},
@@ -389,7 +389,7 @@ BYTE abyVT3226D0_InitTable[CB_VT3226_INIT_SEQ][3] = {
     };
 
 
-BYTE abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
+u8 abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
     {0x01, 0x97, 0x83}, // channel = 1, Tf = 2412MHz
     {0x01, 0x97, 0x83}, // channel = 2, Tf = 2417MHz
     {0x01, 0x97, 0x93}, // channel = 3, Tf = 2422MHz
@@ -406,7 +406,7 @@ BYTE abyVT3226_ChannelTable0[CB_MAX_CHANNEL_24G][3] = {
     {0x03, 0x37, 0xC3}  // channel = 14, Tf = 2484MHz
     };
 
-BYTE abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
+u8 abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
     {0x02, 0x66, 0x64}, // channel = 1, Tf = 2412MHz
     {0x03, 0x66, 0x64}, // channel = 2, Tf = 2417MHz
     {0x00, 0x66, 0x64}, // channel = 3, Tf = 2422MHz
@@ -426,7 +426,7 @@ BYTE abyVT3226_ChannelTable1[CB_MAX_CHANNEL_24G][3] = {
 
 
 //{{RobertYu:20060502, TWIF 1.14, LO Current for 11b mode
-DWORD dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = {
+u32 dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = {
     0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 1, Tf = 2412MHz
     0x0135C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 2, Tf = 2417MHz
     0x0235C600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW, // channel = 3, Tf = 2422MHz
@@ -446,7 +446,7 @@ DWORD dwVT3226D0LoCurrentTable[CB_MAX_CHANNEL_24G] = {
 
 
 //{{RobertYu:20060609
-BYTE abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { // 11b/g mode
+u8 abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { /* 11b/g mode */
     {0x03, 0xFF, 0x80}, //update for mode//
     {0x02, 0x08, 0x81},
     {0x00, 0xC6, 0x02},
@@ -469,7 +469,7 @@ BYTE abyVT3342A0_InitTable[CB_VT3342_INIT_SEQ][3] = { // 11b/g mode
  // channel56, 5280MHz  0x00C402 for disable Frac
  // other channels 0x00C602
 
-BYTE abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = {
+u8 abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = {
     {0x02, 0x05, 0x03}, // channel = 1, Tf = 2412MHz
     {0x01, 0x15, 0x03}, // channel = 2, Tf = 2417MHz
     {0x03, 0xC5, 0x03}, // channel = 3, Tf = 2422MHz
@@ -535,7 +535,7 @@ BYTE abyVT3342_ChannelTable0[CB_MAX_CHANNEL][3] = {
     {0x00, 0x06, 0x03}  // channel = 165, Tf = 5825MHz (56), TBD
     };
 
-BYTE abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = {
+u8 abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = {
     {0x01, 0x99, 0x94}, // channel = 1, Tf = 2412MHz
     {0x02, 0x44, 0x44}, // channel = 2, Tf = 2417MHz
     {0x02, 0xEE, 0xE4}, // channel = 3, Tf = 2422MHz
@@ -606,7 +606,7 @@ BYTE abyVT3342_ChannelTable1[CB_MAX_CHANNEL][3] = {
  *
 -*/
 
-const DWORD dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
+const u32 dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
     0x04040900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
     0x04041900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
     0x04042900+(BY_AL2230_REG_LEN<<3)+IFREGCTL_REGW,
@@ -682,7 +682,7 @@ const DWORD dwAL2230PowerTable[AL2230_PWR_IDX_LEN] = {
 // 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)
 
-const BYTE RFaby11aChannelIndex[200] = {
+const u8 RFaby11aChannelIndex[200] = {
   // 1   2   3   4   5   6   7   8   9  10
     00, 00, 00, 00, 00, 00, 23, 24, 25, 00,  // 10
     26, 27, 00, 00, 00, 28, 00, 00, 00, 00,  // 20
@@ -722,24 +722,20 @@ const BYTE RFaby11aChannelIndex[200] = {
  * Return Value: TRUE if succeeded; FALSE if failed.
  *
  */
-BOOL IFRFbWriteEmbedded (PSDevice pDevice, DWORD dwData)
+int IFRFbWriteEmbedded(struct vnt_private *pDevice, u32 dwData)
 {
-    BYTE        pbyData[4];
+       u8 pbyData[4];
 
-    pbyData[0] = (BYTE)dwData;
-    pbyData[1] = (BYTE)(dwData>>8);
-    pbyData[2] = (BYTE)(dwData>>16);
-    pbyData[3] = (BYTE)(dwData>>24);
-    CONTROLnsRequestOut(pDevice,
-                    MESSAGE_TYPE_WRITE_IFRF,
-                    0,
-                    0,
-                    4,
-                    pbyData
-                        );
+       pbyData[0] = (u8)dwData;
+       pbyData[1] = (u8)(dwData >> 8);
+       pbyData[2] = (u8)(dwData >> 16);
+       pbyData[3] = (u8)(dwData >> 24);
 
+       CONTROLnsRequestOut(pDevice,
+               MESSAGE_TYPE_WRITE_IFRF, 0, 0, 4, pbyData);
 
-    return TRUE;
+
+       return TRUE;
 }
 
 
@@ -756,18 +752,13 @@ BOOL IFRFbWriteEmbedded (PSDevice pDevice, DWORD dwData)
  * Return Value: TRUE if succeeded; FALSE if failed.
  *
  */
-BOOL RFbSetPower (
-      PSDevice  pDevice,
-      unsigned int      uRATE,
-      unsigned int      uCH
-    )
+int RFbSetPower(struct vnt_private *pDevice, u32 uRATE, u32 uCH)
 {
-BOOL    bResult = TRUE;
-BYTE    byPwr = pDevice->byCCKPwr;
+       int bResult = TRUE;
+       u8 byPwr = pDevice->byCCKPwr;
 
-    if (pDevice->dwDiagRefCount != 0) {
-        return TRUE;
-    }
+       if (pDevice->dwDiagRefCount)
+               return TRUE;
 
        if (uCH == 0)
                return -EINVAL;
@@ -813,13 +804,10 @@ BYTE    byPwr = pDevice->byCCKPwr;
  * Return Value: TRUE if succeeded; FALSE if failed.
  *
  */
-BOOL RFbRawSetPower (
-      PSDevice  pDevice,
-      BYTE      byPwr,
-      unsigned int      uRATE
-    )
+
+int RFbRawSetPower(struct vnt_private *pDevice, u8 byPwr, u32 uRATE)
 {
-BOOL        bResult = TRUE;
+       int bResult = TRUE;
 
     if (pDevice->byCurPwr == byPwr)
         return TRUE;
@@ -900,14 +888,22 @@ BOOL        bResult = TRUE;
                 bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226Pwr);
 
                 bResult &= IFRFbWriteEmbedded(pDevice, 0x03C6A200+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW);
-                if (pDevice->sMgmtObj.eScanState != WMAC_NO_SCANNING) {
-                    // scanning, the channel number is pDevice->uScanChannel
-                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uScanChannel);
-                    bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uScanChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate
-                } else {
-                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"@@@@ RFbRawSetPower> 11B mode uCurrChannel[%d]\n", pDevice->sMgmtObj.uCurrChannel);
-                    bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[pDevice->sMgmtObj.uCurrChannel-1]); //RobertYu:20060420, sometimes didn't change channel just set power with different rate
-                }
+               if (pDevice->vnt_mgmt.eScanState != WMAC_NO_SCANNING) {
+                       /* scanning, channel number is pDevice->uScanChannel */
+                       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+                               "RFbRawSetPower> 11B mode uCurrChannel[%d]\n",
+                               pDevice->vnt_mgmt.uScanChannel);
+                       bResult &= IFRFbWriteEmbedded(pDevice,
+                               dwVT3226D0LoCurrentTable[pDevice->
+                                       vnt_mgmt.uScanChannel - 1]);
+               } else {
+                       DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+                               "RFbRawSetPower> 11B mode uCurrChannel[%d]\n",
+                               pDevice->vnt_mgmt.uCurrChannel);
+                       bResult &= IFRFbWriteEmbedded(pDevice,
+                               dwVT3226D0LoCurrentTable[pDevice->
+                                       vnt_mgmt.uCurrChannel - 1]);
+               }
 
                 bResult &= IFRFbWriteEmbedded(pDevice, 0x015C0800+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060420, ok now, new switching power (mini-pci can have bigger power consumption)
             } else {
@@ -957,17 +953,12 @@ BOOL        bResult = TRUE;
  * Return Value: none
  *
 -*/
-void
-RFvRSSITodBm (
-      PSDevice pDevice,
-      BYTE     byCurrRSSI,
-    long *    pldBm
-    )
+void RFvRSSITodBm(struct vnt_private *pDevice, u8 byCurrRSSI, long *pldBm)
 {
-    BYTE byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03);
-    signed long b = (byCurrRSSI & 0x3F);
-    signed long a = 0;
-    BYTE abyAIROHARF[4] = {0, 18, 0, 40};
+       u8 byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03);
+       signed long b = (byCurrRSSI & 0x3F);
+       signed long a = 0;
+       u8 abyAIROHARF[4] = {0, 18, 0, 40};
 
     switch (pDevice->byRFType) {
         case RF_AL2230:
@@ -987,15 +978,12 @@ RFvRSSITodBm (
 
 
 
-void
-RFbRFTableDownload (
-      PSDevice pDevice
-    )
+void RFbRFTableDownload(struct vnt_private *pDevice)
 {
-WORD    wLength1 = 0,wLength2 = 0 ,wLength3 = 0;
-PBYTE   pbyAddr1 = NULL,pbyAddr2 = NULL,pbyAddr3 = NULL;
-WORD    wLength,wValue;
-BYTE    abyArray[256];
+       u16 wLength1 = 0, wLength2 = 0, wLength3 = 0;
+       u8 *pbyAddr1 = NULL, *pbyAddr2 = NULL, *pbyAddr3 = NULL;
+       u16 wLength, wValue;
+       u8 abyArray[256];
 
     switch ( pDevice->byRFType ) {
         case RF_AL2230:
@@ -1134,21 +1122,19 @@ BYTE    abyArray[256];
 
 }
 
-// RobertYu:20060412, TWIF1.11 adjust LO Current for 11b mode
-BOOL s_bVT3226D0_11bLoCurrentAdjust(
-      PSDevice    pDevice,
-      BYTE        byChannel,
-      BOOL        b11bMode)
+int s_bVT3226D0_11bLoCurrentAdjust(struct vnt_private *pDevice, u8 byChannel,
+       int b11bMode)
 {
-    BOOL    bResult;
+       int bResult = TRUE;
 
-    bResult = TRUE;
-    if( b11bMode )
-        bResult &= IFRFbWriteEmbedded(pDevice, dwVT3226D0LoCurrentTable[byChannel-1]);
-    else
-        bResult &= IFRFbWriteEmbedded(pDevice, 0x016BC600+(BY_VT3226_REG_LEN<<3)+IFREGCTL_REGW); //RobertYu:20060412
+       if (b11bMode)
+               bResult &= IFRFbWriteEmbedded(pDevice,
+                       dwVT3226D0LoCurrentTable[byChannel-1]);
+       else
+               bResult &= IFRFbWriteEmbedded(pDevice, 0x016bc600 +
+                       (BY_VT3226_REG_LEN << 3) + IFREGCTL_REGW);
 
-    return bResult;
+       return bResult;
 }
 
 
index 72eb27ac436b07ba2886c7d07ecfa252e6658d83..9f70cf740baefc46fbafb121f6048c20f58c3ab6 100644 (file)
 /*---------------------  Export Classes  ----------------------------*/
 
 /*---------------------  Export Variables  --------------------------*/
-extern const BYTE RFaby11aChannelIndex[200];
+extern const u8 RFaby11aChannelIndex[200];
 /*---------------------  Export Functions  --------------------------*/
 
-BOOL IFRFbWriteEmbedded(PSDevice pDevice, DWORD dwData);
-BOOL RFbSetPower(PSDevice pDevice, unsigned int uRATE, unsigned int uCH);
-
-BOOL RFbRawSetPower(
-      PSDevice  pDevice,
-      BYTE      byPwr,
-      unsigned int      uRATE
-    );
-
-void RFvRSSITodBm(PSDevice pDevice, BYTE byCurrRSSI, long *pldBm);
-void RFbRFTableDownload(PSDevice pDevice);
-
-BOOL s_bVT3226D0_11bLoCurrentAdjust(
-      PSDevice    pDevice,
-      BYTE        byChannel,
-      BOOL        b11bMode
-    );
+int IFRFbWriteEmbedded(struct vnt_private *, u32 dwData);
+int RFbSetPower(struct vnt_private *, u32 uRATE, u32 uCH);
+int RFbRawSetPower(struct vnt_private *, u8 byPwr, u32 uRATE);
+void RFvRSSITodBm(struct vnt_private *, u8 byCurrRSSI, long *pldBm);
+void RFbRFTableDownload(struct vnt_private *pDevice);
+int s_bVT3226D0_11bLoCurrentAdjust(struct vnt_private *, u8 byChannel,
+       int b11bMode);
 
 #endif /* __RF_H__ */
index 83c04e120935f5a6c6fa7488ccabc75a58417cfc..92343f2a26483463da17710bc675e71bbab9af6d 100644 (file)
@@ -106,174 +106,64 @@ const WORD wFB_Opt1[2][5] = {
 
 /*---------------------  Static Functions  --------------------------*/
 
-static
-void
-s_vSaveTxPktInfo(
-     PSDevice pDevice,
-     BYTE byPktNum,
-     PBYTE pbyDestAddr,
-     WORD wPktLength,
-     WORD wFIFOCtl
-);
-
-static
-void *
-s_vGetFreeContext(
-    PSDevice pDevice
-    );
-
-
-static
-void
-s_vGenerateTxParameter(
-     PSDevice         pDevice,
-     BYTE             byPktType,
-     WORD             wCurrentRate,
-     void *pTxBufHead,
-     void *pvRrvTime,
-     void *pvRTS,
-     void *pvCTS,
-     unsigned int             cbFrameSize,
-     BOOL             bNeedACK,
-     unsigned int             uDMAIdx,
-     PSEthernetHeader psEthHeader
-    );
-
-
-static unsigned int s_uFillDataHead(
-     PSDevice pDevice,
-     BYTE     byPktType,
-     WORD     wCurrentRate,
-     void *pTxDataHead,
-     unsigned int     cbFrameLength,
-     unsigned int     uDMAIdx,
-     BOOL     bNeedAck,
-     unsigned int     uFragIdx,
-     unsigned int     cbLastFragmentSize,
-     unsigned int     uMACfragNum,
-     BYTE     byFBOption
-    );
-
-
-
-
-static
-void
-s_vGenerateMACHeader (
-     PSDevice         pDevice,
-     PBYTE            pbyBufferAddr,
-     WORD             wDuration,
-     PSEthernetHeader psEthHeader,
-     BOOL             bNeedEncrypt,
-     WORD             wFragType,
-     unsigned int             uDMAIdx,
-     unsigned int             uFragIdx
-    );
-
-static
-void
-s_vFillTxKey(
-      PSDevice   pDevice,
-      PBYTE      pbyBuf,
-      PBYTE      pbyIVHead,
-      PSKeyItem  pTransmitKey,
-      PBYTE      pbyHdrBuf,
-      WORD       wPayloadLen,
-     PBYTE      pMICHDR
-    );
-
-static
-void
-s_vSWencryption (
-      PSDevice         pDevice,
-      PSKeyItem        pTransmitKey,
-      PBYTE            pbyPayloadHead,
-      WORD             wPayloadSize
-    );
-
-static unsigned int s_uGetTxRsvTime(
-     PSDevice pDevice,
-     BYTE     byPktType,
-     unsigned int     cbFrameLength,
-     WORD     wRate,
-     BOOL     bNeedAck
-    );
-
-
-static unsigned int s_uGetRTSCTSRsvTime(
-     PSDevice pDevice,
-     BYTE byRTSRsvType,
-     BYTE byPktType,
-     unsigned int cbFrameLength,
-     WORD wCurrentRate
-    );
-
-static
-void
-s_vFillCTSHead (
-     PSDevice pDevice,
-     unsigned int     uDMAIdx,
-     BYTE     byPktType,
-     void *pvCTS,
-     unsigned int     cbFrameLength,
-     BOOL     bNeedAck,
-     BOOL     bDisCRC,
-     WORD     wCurrentRate,
-     BYTE     byFBOption
-    );
-
-static
-void
-s_vFillRTSHead(
-     PSDevice         pDevice,
-     BYTE             byPktType,
-     void *pvRTS,
-     unsigned int             cbFrameLength,
-     BOOL             bNeedAck,
-     BOOL             bDisCRC,
-     PSEthernetHeader psEthHeader,
-     WORD             wCurrentRate,
-     BYTE             byFBOption
-    );
-
-static unsigned int s_uGetDataDuration(
-     PSDevice pDevice,
-     BYTE     byDurType,
-     unsigned int     cbFrameLength,
-     BYTE     byPktType,
-     WORD     wRate,
-     BOOL     bNeedAck,
-     unsigned int     uFragIdx,
-     unsigned int     cbLastFragmentSize,
-     unsigned int     uMACfragNum,
-     BYTE     byFBOption
-    );
-
-
-static
-unsigned int
-s_uGetRTSCTSDuration (
-     PSDevice pDevice,
-     BYTE byDurType,
-     unsigned int cbFrameLength,
-     BYTE byPktType,
-     WORD wRate,
-     BOOL bNeedAck,
-     BYTE byFBOption
-    );
+static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum,
+       u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl);
+
+static void *s_vGetFreeContext(struct vnt_private *pDevice);
+
+static void s_vGenerateTxParameter(struct vnt_private *pDevice,
+       u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime,
+       void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx,
+       PSEthernetHeader psEthHeader);
+
+static u32 s_uFillDataHead(struct vnt_private *pDevice,
+       u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength,
+       u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize,
+       u32 uMACfragNum, u8 byFBOption);
+
+
+static void s_vGenerateMACHeader(struct vnt_private *pDevice,
+       u8 *pbyBufferAddr, u16 wDuration, PSEthernetHeader psEthHeader,
+       int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx);
+
+static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf,
+       u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen,
+       u8 *pMICHDR);
+
+static void s_vSWencryption(struct vnt_private *pDevice,
+       PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize);
+
+static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType,
+       u32 cbFrameLength, u16 wRate, int bNeedAck);
+
+static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType,
+       u8 byPktType, u32 cbFrameLength, u16 wCurrentRate);
+
+static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx,
+       u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck,
+       int bDisCRC, u16 wCurrentRate, u8 byFBOption);
+
+static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
+       void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC,
+       PSEthernetHeader psEthHeader, u16 wCurrentRate, u8 byFBOption);
+
+static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType,
+       u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck,
+       u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum,
+       u8 byFBOption);
+
+static unsigned int s_uGetRTSCTSDuration(struct vnt_private *pDevice,
+       u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate,
+       int bNeedAck, u8 byFBOption);
 
 
 /*---------------------  Export Variables  --------------------------*/
 
-static
-void *
-s_vGetFreeContext(
-    PSDevice pDevice
-    )
+static void *s_vGetFreeContext(struct vnt_private *pDevice)
 {
-    PUSB_SEND_CONTEXT   pContext = NULL;
-    PUSB_SEND_CONTEXT   pReturnContext = NULL;
-    unsigned int                ii;
+       PUSB_SEND_CONTEXT pContext = NULL;
+       PUSB_SEND_CONTEXT pReturnContext = NULL;
+       int ii;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n");
 
@@ -292,11 +182,10 @@ s_vGetFreeContext(
 }
 
 
-static
-void
-s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLength, WORD wFIFOCtl)
+static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum,
+       u8 *pbyDestAddr, u16 wPktLength, u16 wFIFOCtl)
 {
-    PSStatCounter           pStatistic=&(pDevice->scStatistic);
+       PSStatCounter pStatistic = &pDevice->scStatistic;
 
     if (is_broadcast_ether_addr(pbyDestAddr))
         pStatistic->abyTxPktInfo[byPktNum].byBroadMultiUni = TX_PKT_BROAD;
@@ -312,24 +201,15 @@ s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLe
           ETH_ALEN);
 }
 
-static
-void
-s_vFillTxKey (
-      PSDevice   pDevice,
-      PBYTE      pbyBuf,
-      PBYTE      pbyIVHead,
-      PSKeyItem  pTransmitKey,
-      PBYTE      pbyHdrBuf,
-      WORD       wPayloadLen,
-     PBYTE      pMICHDR
-    )
+static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf,
+       u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf,
+       u16 wPayloadLen, u8 *pMICHDR)
 {
-    PDWORD          pdwIV = (PDWORD) pbyIVHead;
-    PDWORD          pdwExtIV = (PDWORD) ((PBYTE)pbyIVHead+4);
-    WORD            wValue;
-    PS802_11Header  pMACHeader = (PS802_11Header)pbyHdrBuf;
-    DWORD           dwRevIVCounter;
-
+       u32 *pdwIV = (u32 *)pbyIVHead;
+       u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4);
+       u16 wValue;
+       PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf;
+       u32 dwRevIVCounter;
 
 
     //Fill TXKEY
@@ -430,18 +310,12 @@ s_vFillTxKey (
 }
 
 
-static
-void
-s_vSWencryption (
-      PSDevice            pDevice,
-      PSKeyItem           pTransmitKey,
-      PBYTE               pbyPayloadHead,
-      WORD                wPayloadSize
-    )
+static void s_vSWencryption(struct vnt_private *pDevice,
+       PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize)
 {
-    unsigned int   cbICVlen = 4;
-    DWORD  dwICV = 0xFFFFFFFFL;
-    PDWORD pdwICV;
+       u32 cbICVlen = 4;
+       u32 dwICV = 0xffffffff;
+       u32 *pdwICV;
 
     if (pTransmitKey == NULL)
         return;
@@ -479,17 +353,10 @@ s_vSWencryption (
              PK_TYPE_11GB    2
              PK_TYPE_11GA    3
 */
-static
-unsigned int
-s_uGetTxRsvTime (
-     PSDevice pDevice,
-     BYTE     byPktType,
-     unsigned int     cbFrameLength,
-     WORD     wRate,
-     BOOL     bNeedAck
-    )
+static u32 s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType,
+       u32 cbFrameLength, u16 wRate, int bNeedAck)
 {
-    unsigned int uDataTime, uAckTime;
+       u32 uDataTime, uAckTime;
 
     uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate);
     if (byPktType == PK_TYPE_11B) {//llb,CCK mode
@@ -507,17 +374,10 @@ s_uGetTxRsvTime (
 }
 
 //byFreqType: 0=>5GHZ 1=>2.4GHZ
-static
-unsigned int
-s_uGetRTSCTSRsvTime (
-     PSDevice pDevice,
-     BYTE byRTSRsvType,
-     BYTE byPktType,
-     unsigned int cbFrameLength,
-     WORD wCurrentRate
-    )
+static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice,
+       u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate)
 {
-    unsigned int uRrvTime  , uRTSTime, uCTSTime, uAckTime, uDataTime;
+       u32 uRrvTime, uRTSTime, uCTSTime, uAckTime, uDataTime;
 
     uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0;
 
@@ -549,23 +409,13 @@ s_uGetRTSCTSRsvTime (
 }
 
 //byFreqType 0: 5GHz, 1:2.4Ghz
-static
-unsigned int
-s_uGetDataDuration (
-     PSDevice pDevice,
-     BYTE     byDurType,
-     unsigned int     cbFrameLength,
-     BYTE     byPktType,
-     WORD     wRate,
-     BOOL     bNeedAck,
-     unsigned int     uFragIdx,
-     unsigned int     cbLastFragmentSize,
-     unsigned int     uMACfragNum,
-     BYTE     byFBOption
-    )
+static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType,
+       u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck,
+       u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum,
+       u8 byFBOption)
 {
-    BOOL bLastFrag = 0;
-    unsigned int uAckTime = 0, uNextPktTime = 0;
+       int bLastFrag = 0;
+       u32 uAckTime = 0, uNextPktTime = 0;
 
     if (uFragIdx == (uMACfragNum-1)) {
         bLastFrag = 1;
@@ -718,19 +568,11 @@ s_uGetDataDuration (
 
 
 //byFreqType: 0=>5GHZ 1=>2.4GHZ
-static
-unsigned int
-s_uGetRTSCTSDuration (
-     PSDevice pDevice,
-     BYTE byDurType,
-     unsigned int cbFrameLength,
-     BYTE byPktType,
-     WORD wRate,
-     BOOL bNeedAck,
-     BYTE byFBOption
-    )
+static u32 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType,
+       u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck,
+       u8 byFBOption)
 {
-    unsigned int uCTSTime = 0, uDurTime = 0;
+       u32 uCTSTime = 0, uDurTime = 0;
 
 
     switch (byDurType) {
@@ -814,24 +656,10 @@ s_uGetRTSCTSDuration (
 
 }
 
-
-
-
-static
-unsigned int
-s_uFillDataHead (
-     PSDevice pDevice,
-     BYTE     byPktType,
-     WORD     wCurrentRate,
-     void *pTxDataHead,
-     unsigned int     cbFrameLength,
-     unsigned int     uDMAIdx,
-     BOOL     bNeedAck,
-     unsigned int     uFragIdx,
-     unsigned int     cbLastFragmentSize,
-     unsigned int     uMACfragNum,
-     BYTE     byFBOption
-    )
+static u32 s_uFillDataHead(struct vnt_private *pDevice,
+       u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength,
+       u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize,
+       u32 uMACfragNum, u8 byFBOption)
 {
 
     if (pTxDataHead == NULL) {
@@ -959,25 +787,12 @@ s_uFillDataHead (
     return 0;
 }
 
-
-
-
-static
-void
-s_vFillRTSHead (
-     PSDevice         pDevice,
-     BYTE             byPktType,
-     void *pvRTS,
-     unsigned int             cbFrameLength,
-     BOOL             bNeedAck,
-     BOOL             bDisCRC,
-     PSEthernetHeader psEthHeader,
-     WORD             wCurrentRate,
-     BYTE             byFBOption
-    )
+static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType,
+       void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC,
+       PSEthernetHeader psEthHeader, u16 wCurrentRate, u8 byFBOption)
 {
-    unsigned int uRTSFrameLen = 20;
-    WORD  wLen = 0x0000;
+       u32 uRTSFrameLen = 20;
+       u16 wLen = 0;
 
     if (pvRTS == NULL)
        return;
@@ -1190,22 +1005,12 @@ s_vFillRTSHead (
     }
 }
 
-static
-void
-s_vFillCTSHead (
-     PSDevice pDevice,
-     unsigned int     uDMAIdx,
-     BYTE     byPktType,
-     void *pvCTS,
-     unsigned int     cbFrameLength,
-     BOOL     bNeedAck,
-     BOOL     bDisCRC,
-     WORD     wCurrentRate,
-     BYTE     byFBOption
-    )
+static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx,
+       u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck,
+       int bDisCRC, u16 wCurrentRate, u8 byFBOption)
 {
-    unsigned int uCTSFrameLen = 14;
-    WORD  wLen = 0x0000;
+       u32 uCTSFrameLen = 14;
+       u16 wLen = 0;
 
     if (pvCTS == NULL) {
         return;
@@ -1290,27 +1095,15 @@ s_vFillCTSHead (
  *
 -*/
 
-static
-void
-s_vGenerateTxParameter (
-     PSDevice         pDevice,
-     BYTE             byPktType,
-     WORD             wCurrentRate,
-     void *pTxBufHead,
-     void *pvRrvTime,
-     void *pvRTS,
-     void *pvCTS,
-     unsigned int             cbFrameSize,
-     BOOL             bNeedACK,
-     unsigned int             uDMAIdx,
-     PSEthernetHeader psEthHeader
-    )
+static void s_vGenerateTxParameter(struct vnt_private *pDevice,
+       u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime,
+       void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx,
+       PSEthernetHeader psEthHeader)
 {
-       unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */
-    WORD wFifoCtl;
-    BOOL bDisCRC = FALSE;
-    BYTE byFBOption = AUTO_FB_NONE;
-//    WORD wCurrentRate = pDevice->wCurrentRate;
+       u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */
+       u16 wFifoCtl;
+       int bDisCRC = FALSE;
+       u8 byFBOption = AUTO_FB_NONE;
 
     //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n");
     PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead;
@@ -1407,54 +1200,39 @@ s_vGenerateTxParameter (
     unsigned int  cbFragmentSize,//Hdr+payoad+FCS
 */
 
-
-BOOL
-s_bPacketToWirelessUsb(
-      PSDevice         pDevice,
-      BYTE             byPktType,
-      PBYTE            usbPacketBuf,
-      BOOL             bNeedEncryption,
-      unsigned int             uSkbPacketLen,
-      unsigned int             uDMAIdx,
-      PSEthernetHeader psEthHeader,
-      PBYTE            pPacket,
-      PSKeyItem        pTransmitKey,
-      unsigned int             uNodeIndex,
-      WORD             wCurrentRate,
-     unsigned int             *pcbHeaderLen,
-     unsigned int             *pcbTotalLen
-    )
+static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType,
+       u8 *usbPacketBuf, int bNeedEncryption, u32 uSkbPacketLen, u32 uDMAIdx,
+       PSEthernetHeader psEthHeader, u8 *pPacket, PSKeyItem pTransmitKey,
+       u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen)
 {
-    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-    unsigned int cbFrameSize, cbFrameBodySize;
-    PTX_BUFFER          pTxBufHead;
-    unsigned int cb802_1_H_len;
-    unsigned int cbIVlen = 0, cbICVlen = 0, cbMIClen = 0,
-           cbMACHdLen = 0, cbFCSlen = 4;
-    unsigned int cbMICHDR = 0;
-    BOOL                bNeedACK,bRTS;
-    PBYTE               pbyType,pbyMacHdr,pbyIVHead,pbyPayloadHead,pbyTxBufferAddr;
-    BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
-    BYTE abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
-    unsigned int uDuration;
-    unsigned int cbHeaderLength = 0, uPadding = 0;
-    void *pvRrvTime;
-    PSMICHDRHead        pMICHDR;
-    void *pvRTS;
-    void *pvCTS;
-    void *pvTxDataHd;
-    BYTE                byFBOption = AUTO_FB_NONE,byFragType;
-    WORD                wTxBufSize;
-    DWORD               dwMICKey0,dwMICKey1,dwMIC_Priority,dwCRC;
-    PDWORD              pdwMIC_L,pdwMIC_R;
-    BOOL                bSoftWEP = FALSE;
-
-
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 cbFrameSize, cbFrameBodySize;
+       PTX_BUFFER pTxBufHead;
+       u32 cb802_1_H_len;
+       u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0;
+       u32 cbFCSlen = 4, cbMICHDR = 0;
+       int bNeedACK, bRTS;
+       u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead, *pbyTxBufferAddr;
+       u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
+       u8 abySNAP_Bridgetunnel[ETH_ALEN]
+               = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
+       u32 uDuration;
+       u32 cbHeaderLength = 0, uPadding = 0;
+       void *pvRrvTime;
+       PSMICHDRHead pMICHDR;
+       void *pvRTS;
+       void *pvCTS;
+       void *pvTxDataHd;
+       u8 byFBOption = AUTO_FB_NONE, byFragType;
+       u16 wTxBufSize;
+       u32 dwMICKey0, dwMICKey1, dwMIC_Priority, dwCRC;
+       u32 *pdwMIC_L, *pdwMIC_R;
+       int bSoftWEP = FALSE;
+
+       pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
 
-
-    pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
        if (bNeedEncryption && pTransmitKey->pvKeyTable) {
-               if (((PSKeyTable)&pTransmitKey->pvKeyTable)->bSoftWEP == TRUE)
+               if (((PSKeyTable)pTransmitKey->pvKeyTable)->bSoftWEP == TRUE)
                        bSoftWEP = TRUE; /* WEP 256 */
        }
 
@@ -1733,10 +1511,10 @@ s_bPacketToWirelessUsb(
 
         ///////////////////////////////////////////////////////////////////
 
-        if (pDevice->sMgmtObj.eAuthenMode == WMAC_AUTH_WPANONE) {
-            dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]);
-            dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]);
-        }
+       if (pDevice->vnt_mgmt.eAuthenMode == WMAC_AUTH_WPANONE) {
+               dwMICKey0 = *(u32 *)(&pTransmitKey->abyKey[16]);
+               dwMICKey1 = *(u32 *)(&pTransmitKey->abyKey[20]);
+       }
         else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) {
             dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]);
             dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]);
@@ -1839,19 +1617,11 @@ s_bPacketToWirelessUsb(
  *
 -*/
 
-void
-s_vGenerateMACHeader (
-     PSDevice         pDevice,
-     PBYTE            pbyBufferAddr,
-     WORD             wDuration,
-     PSEthernetHeader psEthHeader,
-     BOOL             bNeedEncrypt,
-     WORD             wFragType,
-     unsigned int             uDMAIdx,
-     unsigned int             uFragIdx
-    )
+static void s_vGenerateMACHeader(struct vnt_private *pDevice,
+       u8 *pbyBufferAddr, u16 wDuration, PSEthernetHeader psEthHeader,
+       int bNeedEncrypt, u16 wFragType, u32 uDMAIdx, u32 uFragIdx)
 {
-    PS802_11Header  pMACHeader = (PS802_11Header)pbyBufferAddr;
+       PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr;
 
     memset(pMACHeader, 0, (sizeof(S802_11Header)));  //- sizeof(pMACHeader->dwIV)));
 
@@ -1940,39 +1710,25 @@ s_vGenerateMACHeader (
  *
 -*/
 
-CMD_STATUS csMgmt_xmit(
-      PSDevice pDevice,
-      PSTxMgmtPacket pPacket
-    )
+CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice,
+       struct vnt_tx_mgmt *pPacket)
 {
-    BYTE            byPktType;
-    PBYTE           pbyTxBufferAddr;
-    void *pvRTS;
-    PSCTS           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;
-    WORD            wTxBufSize;
-    unsigned int            cbMacHdLen;
-    SEthernetHeader sEthHeader;
-    void *pvRrvTime;
-    void *pMICHDR;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    WORD            wCurrentRate = RATE_1M;
-    PTX_BUFFER          pTX_Buffer;
-    PUSB_SEND_CONTEXT   pContext;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PTX_BUFFER pTX_Buffer;
+       PSTxBufHead pTxBufHead;
+       PUSB_SEND_CONTEXT pContext;
+       PS802_11Header pMACHeader;
+       PSCTS pCTS;
+       SEthernetHeader sEthHeader;
+       u8 byPktType, *pbyTxBufferAddr;
+       void *pvRTS, *pvTxDataHd, *pvRrvTime, *pMICHDR;
+       u32 uDuration, cbReqCount, cbHeaderSize, cbFrameBodySize, cbFrameSize;
+       int bNeedACK, bIsPSPOLL = FALSE;
+       u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4;
+       u32 uPadding = 0;
+       u16 wTxBufSize;
+       u32 cbMacHdLen;
+       u16 wCurrentRate = RATE_1M;
 
 
 
@@ -2231,26 +1987,22 @@ CMD_STATUS csMgmt_xmit(
 }
 
 
-CMD_STATUS
-csBeacon_xmit(
-      PSDevice pDevice,
-      PSTxMgmtPacket pPacket
-    )
+CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice,
+       struct vnt_tx_mgmt *pPacket)
 {
-
-    unsigned int                cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
-    unsigned int                cbHeaderSize = 0;
-    WORD                wTxBufSize = sizeof(STxShortBufHead);
-    PSTxShortBufHead    pTxBufHead;
-    PS802_11Header      pMACHeader;
-    PSTxDataHead_ab     pTxDataHead;
-    WORD                wCurrentRate;
-    unsigned int                cbFrameBodySize;
-    unsigned int                cbReqCount;
-    PBEACON_BUFFER      pTX_Buffer;
-    PBYTE               pbyTxBufferAddr;
-    PUSB_SEND_CONTEXT   pContext;
-    CMD_STATUS          status;
+       u32 cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN;
+       u32 cbHeaderSize = 0;
+       u16 wTxBufSize = sizeof(STxShortBufHead);
+       PSTxShortBufHead pTxBufHead;
+       PS802_11Header pMACHeader;
+       PSTxDataHead_ab pTxDataHead;
+       u16 wCurrentRate;
+       u32 cbFrameBodySize;
+       u32 cbReqCount;
+       PBEACON_BUFFER pTX_Buffer;
+       u8 *pbyTxBufferAddr;
+       PUSB_SEND_CONTEXT pContext;
+       CMD_STATUS status;
 
 
     pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice);
@@ -2321,56 +2073,38 @@ csBeacon_xmit(
 }
 
 
-
-
-
-void
-vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb) {
-
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    BYTE            byPktType;
-    PBYTE           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;
-    DWORD           dwMICKey0, dwMICKey1;
-    DWORD           dwMIC_Priority;
-    PDWORD          pdwMIC_L;
-    PDWORD          pdwMIC_R;
-    WORD            wTxBufSize;
-    unsigned int            cbMacHdLen;
-    SEthernetHeader sEthHeader;
-    void *pvRrvTime;
-    void *pMICHDR;
-    WORD            wCurrentRate = RATE_1M;
-    PUWLAN_80211HDR  p80211Header;
-    unsigned int             uNodeIndex = 0;
-    BOOL            bNodeExist = FALSE;
-    SKeyItem        STempKey;
-    PSKeyItem       pTransmitKey = NULL;
-    PBYTE           pbyIVHead;
-    PBYTE           pbyPayloadHead;
-    PBYTE           pbyMacHdr;
-    unsigned int            cbExtSuppRate = 0;
-    PTX_BUFFER          pTX_Buffer;
-    PUSB_SEND_CONTEXT   pContext;
-//    PWLAN_IE        pItem;
+void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb)
+{
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 byPktType;
+       u8 *pbyTxBufferAddr;
+       void *pvRTS, *pvCTS, *pvTxDataHd;
+       u32 uDuration, cbReqCount;
+       PS802_11Header  pMACHeader;
+       u32 cbHeaderSize, cbFrameBodySize;
+       int bNeedACK, bIsPSPOLL = FALSE;
+       PSTxBufHead pTxBufHead;
+       u32 cbFrameSize;
+       u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4;
+       u32 uPadding = 0;
+       u32 cbMICHDR = 0, uLength = 0;
+       u32 dwMICKey0, dwMICKey1;
+       u32 dwMIC_Priority;
+       u32 *pdwMIC_L, *pdwMIC_R;
+       u16 wTxBufSize;
+       u32 cbMacHdLen;
+       SEthernetHeader sEthHeader;
+       void *pvRrvTime, *pMICHDR;
+       u32 wCurrentRate = RATE_1M;
+       PUWLAN_80211HDR  p80211Header;
+       u32 uNodeIndex = 0;
+       int bNodeExist = FALSE;
+       SKeyItem STempKey;
+       PSKeyItem pTransmitKey = NULL;
+       u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr;
+       u32 cbExtSuppRate = 0;
+       PTX_BUFFER pTX_Buffer;
+       PUSB_SEND_CONTEXT pContext;
 
 
     pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
@@ -2729,29 +2463,30 @@ vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb) {
  * Return Value: NULL
  */
 
-int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
+int nsDMA_tx_packet(struct vnt_private *pDevice,
+       u32 uDMAIdx, struct sk_buff *skb)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int BytesToWrite = 0, uHeaderLen = 0;
-    unsigned int            uNodeIndex = 0;
-    BYTE            byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-    WORD            wAID;
-    BYTE            byPktType;
-    BOOL            bNeedEncryption = FALSE;
-    PSKeyItem       pTransmitKey = NULL;
-    SKeyItem        STempKey;
-    unsigned int            ii;
-    BOOL            bTKIP_UseGTK = FALSE;
-    BOOL            bNeedDeAuth = FALSE;
-    PBYTE           pbyBSSID;
-    BOOL            bNodeExist = FALSE;
-    PUSB_SEND_CONTEXT pContext;
-    BOOL            fConvertedPacket;
-    PTX_BUFFER      pTX_Buffer;
-    unsigned int            status;
-    WORD            wKeepRate = pDevice->wCurrentRate;
-    struct net_device_stats* pStats = &pDevice->stats;
-     BOOL            bTxeapol_key = FALSE;
+       struct net_device_stats *pStats = &pDevice->stats;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 BytesToWrite = 0, uHeaderLen = 0;
+       u32 uNodeIndex = 0;
+       u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+       u16 wAID;
+       u8 byPktType;
+       int bNeedEncryption = FALSE;
+       PSKeyItem pTransmitKey = NULL;
+       SKeyItem STempKey;
+       int ii;
+       int bTKIP_UseGTK = FALSE;
+       int bNeedDeAuth = FALSE;
+       u8 *pbyBSSID;
+       int bNodeExist = FALSE;
+       PUSB_SEND_CONTEXT pContext;
+       BOOL fConvertedPacket;
+       PTX_BUFFER pTX_Buffer;
+       u32 status;
+       u16 wKeepRate = pDevice->wCurrentRate;
+       int bTxeapol_key = FALSE;
 
 
     if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
@@ -3125,28 +2860,22 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
  * Return Value: Return TRUE if packet is copy to dma1; otherwise FALSE
  */
 
-
-BOOL
-bRelayPacketSend (
-      PSDevice pDevice,
-      PBYTE    pbySkbData,
-      unsigned int     uDataLen,
-      unsigned int     uNodeIndex
-    )
+int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen,
+       u32 uNodeIndex)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int BytesToWrite = 0, uHeaderLen = 0;
-    BYTE            byPktType = PK_TYPE_11B;
-    BOOL            bNeedEncryption = FALSE;
-    SKeyItem        STempKey;
-    PSKeyItem       pTransmitKey = NULL;
-    PBYTE           pbyBSSID;
-    PUSB_SEND_CONTEXT   pContext;
-    BYTE            byPktTyp;
-    BOOL            fConvertedPacket;
-    PTX_BUFFER      pTX_Buffer;
-    unsigned int            status;
-    WORD            wKeepRate = pDevice->wCurrentRate;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u32 BytesToWrite = 0, uHeaderLen = 0;
+       u8 byPktType = PK_TYPE_11B;
+       int bNeedEncryption = FALSE;
+       SKeyItem STempKey;
+       PSKeyItem pTransmitKey = NULL;
+       u8 *pbyBSSID;
+       PUSB_SEND_CONTEXT pContext;
+       u8 byPktTyp;
+       int fConvertedPacket;
+       PTX_BUFFER pTX_Buffer;
+       u32 status;
+       u16 wKeepRate = pDevice->wCurrentRate;
 
 
 
index dd2198acc63679c05d2a4cd03c86c78054bc91a3..9f537022cdd1f87df34ad2c1e66f85a49836b6b8 100644 (file)
@@ -665,30 +665,11 @@ typedef struct tagSBEACON_BUFFER
 
 /*---------------------  Export Functions  --------------------------*/
 
-BOOL
-bPacketToWirelessUsb(
-      PSDevice         pDevice,
-      BYTE             byPktType,
-      PBYTE            usbPacketBuf,
-      BOOL             bNeedEncrypt,
-      unsigned int             cbPayloadSize,
-      unsigned int             uDMAIdx,
-      PSEthernetHeader psEthHeader,
-      PBYTE            pPacket,
-      PSKeyItem        pTransmitKey,
-      unsigned int             uNodeIndex,
-      WORD             wCurrentRate,
-     unsigned int             *pcbHeaderLen,
-     unsigned int             *pcbTotalLen
-    );
-
-void vDMA0_tx_80211(PSDevice  pDevice, struct sk_buff *skb);
-int nsDMA_tx_packet(PSDevice pDevice,
-                   unsigned int uDMAIdx,
-                   struct sk_buff *skb);
-CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
-CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket);
-BOOL bRelayPacketSend(PSDevice pDevice, PBYTE pbySkbData,
-                     unsigned int uDataLen, unsigned int uNodeIndex);
+void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb);
+int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb);
+CMD_STATUS csMgmt_xmit(struct vnt_private *, struct vnt_tx_mgmt *);
+CMD_STATUS csBeacon_xmit(struct vnt_private *, struct vnt_tx_mgmt *);
+int bRelayPacketSend(struct vnt_private *, u8 *pbySkbData, u32 uDataLen,
+       u32 uNodeIndex);
 
 #endif /* __RXTX_H__ */
index dfbf74713a80cd5756d3eae00ad554de01236623..89ab494922026269898606862e851059c288f5cb 100644 (file)
@@ -48,18 +48,6 @@ typedef u8 BYTE;
 typedef u16 WORD;
 typedef u32 DWORD;
 
-// QWORD is for those situation that we want
-// an 8-byte-aligned 8 byte long structure
-// which is NOT really a floating point number.
-typedef union tagUQuadWord {
-    struct {
-       u32 dwLowDword;
-       u32 dwHighDword;
-    } u;
-    double      DoNotUseThisField;
-} UQuadWord;
-typedef UQuadWord       QWORD;          // 64-bit
-
 /****** Common pointer types ***********************************************/
 
 typedef u32 ULONG_PTR;
@@ -73,6 +61,4 @@ typedef WORD *           PWORD;
 
 typedef DWORD *          PDWORD;
 
-typedef QWORD *          PQWORD;
-
 #endif /* __TTYPE_H__ */
index fc68518526e03f470782aaee81a9cc33cab2b3e4..2a020672a14b68d1522bb99366596bdd706555ee 100644 (file)
@@ -67,51 +67,18 @@ static int          msglevel                =MSG_LEVEL_INFO;
 /*---------------------  Static Variables  --------------------------*/
 
 /*---------------------  Static Functions  --------------------------*/
-static
-void
-s_nsInterruptUsbIoCompleteRead(
-     struct urb *urb
-    );
-
-
-static
-void
-s_nsBulkInUsbIoCompleteRead(
-     struct urb *urb
-    );
-
-
-static
-void
-s_nsBulkOutIoCompleteWrite(
-     struct urb *urb
-    );
-
-
-static
-void
-s_nsControlInUsbIoCompleteRead(
-     struct urb *urb
-    );
-
-static
-void
-s_nsControlInUsbIoCompleteWrite(
-     struct urb *urb
-    );
+static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
+static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
+static void s_nsBulkOutIoCompleteWrite(struct urb *urb);
+static void s_nsControlInUsbIoCompleteRead(struct urb *urb);
+static void s_nsControlInUsbIoCompleteWrite(struct urb *urb);
 
 /*---------------------  Export Variables  --------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
 
-int PIPEnsControlOutAsyn(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-     PBYTE        pbyBuffer
-    )
+int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
+       u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer)
 {
        int ntStatus;
 
@@ -147,17 +114,11 @@ int PIPEnsControlOutAsyn(
     return ntStatus;
 }
 
-int PIPEnsControlOut(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-     PBYTE        pbyBuffer
-    )
+int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
+               u16 wIndex, u16 wLength, u8 *pbyBuffer)
 {
        int ntStatus = 0;
-    int ii;
+       int ii;
 
     if (pDevice->Flags & fMP_DISCONNECTED)
         return STATUS_FAILURE;
@@ -206,17 +167,11 @@ int PIPEnsControlOut(
     return STATUS_SUCCESS;
 }
 
-int PIPEnsControlIn(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-       PBYTE   pbyBuffer
-    )
+int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
+       u16 wIndex, u16 wLength,  u8 *pbyBuffer)
 {
        int ntStatus = 0;
-    int ii;
+       int ii;
 
     if (pDevice->Flags & fMP_DISCONNECTED)
         return STATUS_FAILURE;
@@ -263,13 +218,9 @@ int PIPEnsControlIn(
     return ntStatus;
 }
 
-static
-void
-s_nsControlInUsbIoCompleteWrite(
-     struct urb *urb
-    )
+static void s_nsControlInUsbIoCompleteWrite(struct urb *urb)
 {
-    PSDevice        pDevice;
+       struct vnt_private *pDevice = (struct vnt_private *)urb->context;
 
        pDevice = urb->context;
        switch (urb->status) {
@@ -304,15 +255,11 @@ s_nsControlInUsbIoCompleteWrite(
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-static
-void
-s_nsControlInUsbIoCompleteRead(
-     struct urb *urb
-    )
+
+static void s_nsControlInUsbIoCompleteRead(struct urb *urb)
 {
-    PSDevice        pDevice;
+       struct vnt_private *pDevice = (struct vnt_private *)urb->context;
 
-       pDevice = urb->context;
        switch (urb->status) {
        case 0:
                break;
@@ -345,9 +292,10 @@ s_nsControlInUsbIoCompleteRead(
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-int PIPEnsInterruptRead(PSDevice pDevice)
+
+int PIPEnsInterruptRead(struct vnt_private *pDevice)
 {
-    int ntStatus = STATUS_FAILURE;
+       int ntStatus = STATUS_FAILURE;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartInterruptUsbRead()\n");
 
@@ -396,21 +344,16 @@ usb_fill_bulk_urb(pDevice->pInterruptURB,
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-static
-void
-s_nsInterruptUsbIoCompleteRead(
-     struct urb *urb
-    )
 
+static void s_nsInterruptUsbIoCompleteRead(struct urb *urb)
 {
-    PSDevice        pDevice;
-    int ntStatus;
+       struct vnt_private *pDevice = (struct vnt_private *)urb->context;
+       int ntStatus;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptUsbIoCompleteRead\n");
     //
     // The context given to IoSetCompletionRoutine is the receive buffer object
     //
-    pDevice = (PSDevice)urb->context;
 
     //
     // We have a number of cases:
@@ -483,10 +426,11 @@ s_nsInterruptUsbIoCompleteRead(
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB)
+
+int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, PRCB pRCB)
 {
        int ntStatus = 0;
-    struct urb          *pUrb;
+       struct urb *pUrb;
 
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
@@ -543,19 +487,15 @@ int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB)
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-static
-void
-s_nsBulkInUsbIoCompleteRead(
-     struct urb *urb
-    )
 
+static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
 {
-    PRCB    pRCB = (PRCB)urb->context;
-    PSDevice pDevice = (PSDevice)pRCB->pDevice;
-    unsigned long   bytesRead;
-    BOOL    bIndicateReceive = FALSE;
-    BOOL    bReAllocSkb = FALSE;
-    int status;
+       PRCB pRCB = (PRCB)urb->context;
+       struct vnt_private *pDevice = pRCB->pDevice;
+       unsigned long   bytesRead;
+       int bIndicateReceive = FALSE;
+       int bReAllocSkb = FALSE;
+       int status;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
     status = urb->status;
@@ -618,14 +558,11 @@ s_nsBulkInUsbIoCompleteRead(
  * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
  *
  */
-int
-PIPEnsSendBulkOut(
-      PSDevice pDevice,
-      PUSB_SEND_CONTEXT pContext
-    )
+
+int PIPEnsSendBulkOut(struct vnt_private *pDevice, PUSB_SEND_CONTEXT pContext)
 {
-    int status;
-    struct urb          *pUrb;
+       int status;
+       struct urb          *pUrb;
 
 
 
@@ -699,17 +636,14 @@ PIPEnsSendBulkOut(
  *               (IofCompleteRequest) to stop working on the irp.
  *
  */
-static
-void
-s_nsBulkOutIoCompleteWrite(
-     struct urb *urb
-    )
+
+static void s_nsBulkOutIoCompleteWrite(struct urb *urb)
 {
-    PSDevice            pDevice;
-    int status;
-    CONTEXT_TYPE        ContextType;
-    unsigned long               ulBufLen;
-    PUSB_SEND_CONTEXT   pContext;
+       struct vnt_private *pDevice;
+       int status;
+       CONTEXT_TYPE ContextType;
+       unsigned long ulBufLen;
+       PUSB_SEND_CONTEXT pContext;
 
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n");
index b3673474a9e12783d036d3c1e9b744473b33c317..b3023559c15bcfefe032ba0312d1a8a893746406 100644 (file)
 
 /*---------------------  Export Functions  --------------------------*/
 
-int PIPEnsControlOut(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-     PBYTE        pbyBuffer
-    );
-
-int PIPEnsControlOutAsyn(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-     PBYTE        pbyBuffer
-    );
-
-int PIPEnsControlIn(
-     PSDevice     pDevice,
-     BYTE         byRequest,
-     WORD         wValue,
-     WORD         wIndex,
-     WORD         wLength,
-       PBYTE   pbyBuffer
-    );
-
-int PIPEnsInterruptRead(PSDevice pDevice);
-int PIPEnsBulkInUsbRead(PSDevice pDevice, PRCB pRCB);
-int PIPEnsSendBulkOut(PSDevice pDevice, PUSB_SEND_CONTEXT pContext);
+int PIPEnsControlOut(struct vnt_private *, u8 byRequest, u16 wValue,
+               u16 wIndex, u16 wLength, u8 *pbyBuffer);
+int PIPEnsControlOutAsyn(struct vnt_private *, u8 byRequest,
+       u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer);
+int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue,
+       u16 wIndex, u16 wLength,  u8 *pbyBuffer);
+
+int PIPEnsInterruptRead(struct vnt_private *);
+int PIPEnsBulkInUsbRead(struct vnt_private *, PRCB pRCB);
+int PIPEnsSendBulkOut(struct vnt_private *, PUSB_SEND_CONTEXT pContext);
 
 #endif /* __USBPIPE_H__ */
index 22f6b41cfd196523ab19202887f2d384619fd58d..51f48c1244f6f4b3fc2b69f08438c34072a936ab 100644 (file)
@@ -68,33 +68,17 @@ static int          msglevel                =MSG_LEVEL_INFO;
 //static int          msglevel                =MSG_LEVEL_DEBUG;
 /*---------------------  Static Functions  --------------------------*/
 
-static
-void
-s_vProbeChannel(
-     PSDevice pDevice
-    );
+static void s_vProbeChannel(struct vnt_private *);
 
+static struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *,
+       struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-static
-PSTxMgmtPacket
-s_MgrMakeProbeRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pScanBSSID,
-     PWLAN_IE_SSID pSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
 
+static int s_bCommandComplete(struct vnt_private *);
 
-static
-BOOL
-s_bCommandComplete (
-    PSDevice pDevice
-    );
 
-
-static BOOL s_bClearBSSID_SCAN(void *hDeviceContext);
+static int s_bClearBSSID_SCAN(struct vnt_private *);
 
 /*---------------------  Export Variables  --------------------------*/
 
@@ -114,13 +98,10 @@ static BOOL s_bClearBSSID_SCAN(void *hDeviceContext);
  *
  */
 
-static
-void
-vAdHocBeaconStop(PSDevice  pDevice)
+static void vAdHocBeaconStop(struct vnt_private *pDevice)
 {
-
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    BOOL            bStop;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int bStop;
 
     /*
      * temporarily stop Beacon packet for AdHoc Server
@@ -171,11 +152,9 @@ vAdHocBeaconStop(PSDevice  pDevice)
  * Return Value: none
  *
  */
-static
-void
-vAdHocBeaconRestart(PSDevice pDevice)
+static void vAdHocBeaconRestart(struct vnt_private *pDevice)
 {
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
     /*
      * Restart Beacon packet for AdHoc Server
@@ -204,22 +183,22 @@ vAdHocBeaconRestart(PSDevice pDevice)
  *
 -*/
 
-static
-void
-s_vProbeChannel(
-     PSDevice pDevice
-    )
+static void s_vProbeChannel(struct vnt_private *pDevice)
 {
-                                                     //1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M
-    BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
-    BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
-                                                           //6M,   9M,   12M,  48M
-    BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-    BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
-    PBYTE           pbyRate;
-    PSTxMgmtPacket  pTxPacket;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    unsigned int            ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       struct vnt_tx_mgmt *pTxPacket;
+       u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
+                       8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
+                       /* 1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M*/
+       u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
+                       4, 0x0C, 0x12, 0x18, 0x60};
+                       /* 6M,   9M,   12M,  48M*/
+       u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
+                       8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+       u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
+                       4, 0x02, 0x04, 0x0B, 0x16};
+       u8 *pbyRate;
+       int ii;
 
 
     if (pDevice->byBBType == BB_TYPE_11A) {
@@ -268,24 +247,19 @@ s_vProbeChannel(
 -*/
 
 
-PSTxMgmtPacket
-s_MgrMakeProbeRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pScanBSSID,
-     PWLAN_IE_SSID pSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-
-    )
+struct vnt_tx_mgmt *s_MgrMakeProbeRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u8 *pScanBSSID, PWLAN_IE_SSID pSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_PROBEREQ    sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_PROBEREQ sFrame;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_PROBEREQ_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
     vMgrEncodeProbeRequest(&sFrame);
@@ -316,9 +290,8 @@ s_MgrMakeProbeRequest(
     return pTxPacket;
 }
 
-void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond)
+void vCommandTimerWait(struct vnt_private *pDevice, unsigned long MSecond)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
 
        init_timer(&pDevice->sTimerCommand);
 
@@ -331,18 +304,17 @@ void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond)
        return;
 }
 
-void vRunCommand(void *hDeviceContext)
+void vRunCommand(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    PWLAN_IE_SSID   pItemSSID;
-    PWLAN_IE_SSID   pItemSSIDCurr;
-    CMD_STATUS      Status;
-    unsigned int            ii;
-    BYTE            byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-    struct sk_buff  *skb;
-    BYTE            byData;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PWLAN_IE_SSID pItemSSID;
+       PWLAN_IE_SSID pItemSSIDCurr;
+       CMD_STATUS Status;
+       struct sk_buff  *skb;
        union iwreq_data wrqu;
+       int ii;
+       u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+       u8 byData;
 
 
     if (pDevice->dwDiagRefCount != 0)
@@ -1043,17 +1015,12 @@ void vRunCommand(void *hDeviceContext)
 }
 
 
-static
-BOOL
-s_bCommandComplete (
-    PSDevice pDevice
-    )
+static int s_bCommandComplete(struct vnt_private *pDevice)
 {
-    PWLAN_IE_SSID pSSID;
-    BOOL          bRadioCmd = FALSE;
-    //WORD          wDeAuthenReason = 0;
-    BOOL          bForceSCAN = TRUE;
-    PSMgmtObject  pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PWLAN_IE_SSID pSSID;
+       int bRadioCmd = FALSE;
+       int bForceSCAN = TRUE;
 
 
     pDevice->eCommandState = WLAN_CMD_IDLE;
@@ -1146,18 +1113,15 @@ s_bCommandComplete (
                 break;
 
         }
-       vCommandTimerWait((void *) pDevice, 0);
+       vCommandTimerWait(pDevice, 0);
     }
 
     return TRUE;
 }
 
-BOOL bScheduleCommand(void *hDeviceContext,
-                     CMD_CODE eCommand,
-                     PBYTE pbyItem0)
+int bScheduleCommand(struct vnt_private *pDevice,
+               CMD_CODE eCommand, u8 *pbyItem0)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-
 
     if (pDevice->cbFreeCmdQueue == 0) {
         return (FALSE);
@@ -1222,11 +1186,10 @@ BOOL bScheduleCommand(void *hDeviceContext,
  * Return Value: TRUE if success; otherwise FALSE
  *
  */
-static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
+static int s_bClearBSSID_SCAN(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
-    unsigned int            uCmdDequeueIdx = pDevice->uCmdDequeueIdx;
-    unsigned int            ii;
+       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 ++) {
@@ -1242,9 +1205,8 @@ static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
 
 
 //mike add:reset command timer
-void vResetCommandTimer(void *hDeviceContext)
+void vResetCommandTimer(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
 
        //delete timer
        del_timer(&pDevice->sTimerCommand);
@@ -1261,10 +1223,9 @@ void vResetCommandTimer(void *hDeviceContext)
        pDevice->bCmdClear = FALSE;
 }
 
-void BSSvSecondTxData(void *hDeviceContext)
+void BSSvSecondTxData(struct vnt_private *pDevice)
 {
-       PSDevice pDevice = (PSDevice)hDeviceContext;
-       PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
        pDevice->nTxDataTimeCout++;
 
index d24a79dce61ad1dcf5a47c80f84d7aa3f3637d31..a3d03234d0a1107c674d6c16b880e55fe509708f 100644 (file)
@@ -28,7 +28,6 @@
 
 #ifndef __WCMD_H__
 #define __WCMD_H__
-
 #include "ttype.h"
 #include "80211hdr.h"
 #include "80211mgr.h"
@@ -112,14 +111,13 @@ typedef enum tagCMD_STATE {
 /*---------------------  Export Types  ------------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
+struct vnt_private;
 
-void vResetCommandTimer(void *hDeviceContext);
+void vResetCommandTimer(struct vnt_private *);
 
-BOOL bScheduleCommand(void *hDeviceContext,
-                     CMD_CODE eCommand,
-                     PBYTE pbyItem0);
+int bScheduleCommand(struct vnt_private *, CMD_CODE eCommand, u8 *pbyItem0);
 
-void vRunCommand(void *hDeviceContext);
+void vRunCommand(struct vnt_private *);
 
 /*
 void
@@ -128,6 +126,6 @@ WCMDvCommandThread(
     );
 */
 
-void BSSvSecondTxData(void *hDeviceContext);
+void BSSvSecondTxData(struct vnt_private *);
 
 #endif /* __WCMD_H__ */
index 9249263b2da8dc3339e75870e0bd912db9d40d24..18a09a3a41308f0c3349c05c94d98696c91826b8 100644 (file)
@@ -113,7 +113,8 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader)
  *
  */
 
-unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader)
+unsigned int WCTLuSearchDFCB(struct vnt_private *pDevice,
+       PS802_11Header pMACHeader)
 {
        unsigned int ii;
 
@@ -141,7 +142,8 @@ unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader)
  * Return Value: index number in Defragment Database
  *
  */
-unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader)
+unsigned int WCTLuInsertDFCB(struct vnt_private *pDevice,
+       PS802_11Header pMACHeader)
 {
        unsigned int ii;
 
@@ -180,10 +182,10 @@ unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader)
  * Return Value: TRUE if it is valid fragment packet and we have resource to defragment; otherwise FALSE
  *
  */
-BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader,
-                        unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV)
+int WCTLbHandleFragment(struct vnt_private *pDevice, PS802_11Header pMACHeader,
+       unsigned int cbFrameLength, int bWEP, int bExtIV)
 {
-unsigned int            uHeaderSize;
+       unsigned int uHeaderSize;
 
 
     if (bWEP == TRUE) {
index 7270af68c89d42589a2907023db2bde3e39ee9d2..a509f6330801375d82f25982ed61d8fb8375eccc 100644 (file)
@@ -97,9 +97,9 @@
 /*---------------------  Export Functions  --------------------------*/
 
 BOOL WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader);
-BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader,
-                        unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV);
-unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
-unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
+int 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__ */
index 95ddc8303bb3f703189a98ecd120eb879491faa4..89491ae71b4e82d3c89d30ad10f7cb582c4d9b5d 100644 (file)
@@ -93,227 +93,98 @@ static int          msglevel                =MSG_LEVEL_INFO;
 
 /*---------------------  Static Functions  --------------------------*/
 
-static BOOL ChannelExceedZoneType(
-     PSDevice pDevice,
-     BYTE byCurrChannel
-    );
+static int ChannelExceedZoneType(struct vnt_private *, u8 byCurrChannel);
 
-// Association/diassociation functions
-static
-PSTxMgmtPacket
-s_MgrMakeAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pDAddr,
-     WORD wCurrCapInfo,
-     WORD wListenInterval,
-     PWLAN_IE_SSID pCurrSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
+/* Association/diassociation functions */
+static struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *,
+       struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
+       u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-static
-void
-s_vMgrRxAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     unsigned int  uNodeIndex
-    );
+static void s_vMgrRxAssocRequest(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       u32 uNodeIndex);
 
-static
-PSTxMgmtPacket
-s_MgrMakeReAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pDAddr,
-     WORD wCurrCapInfo,
-     WORD wListenInterval,
-     PWLAN_IE_SSID pCurrSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
+static struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *,
+       struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
+       u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-static
-void
-s_vMgrRxAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     BOOL bReAssocType
-    );
+static void s_vMgrRxAssocResponse(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       int bReAssocType);
 
-static
-void
-s_vMgrRxDisassociation(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    );
+static void s_vMgrRxDisassociation(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
 
-// Authentication/deauthen functions
-static
-void
-s_vMgrRxAuthenSequence_1(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    );
+/* Authentication/deauthen functions */
+static void s_vMgrRxAuthenSequence_1(struct vnt_private *,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
 
-static
-void
-s_vMgrRxAuthenSequence_2(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    );
+static void s_vMgrRxAuthenSequence_2(struct vnt_private *,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
 
-static
-void
-s_vMgrRxAuthenSequence_3(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    );
+static void s_vMgrRxAuthenSequence_3(struct vnt_private *,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
 
-static
-void
-s_vMgrRxAuthenSequence_4(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    );
+static void s_vMgrRxAuthenSequence_4(struct vnt_private *,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame);
 
-static
-void
-s_vMgrRxAuthentication(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    );
+static void s_vMgrRxAuthentication(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
 
-static
-void
-s_vMgrRxDeauthentication(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    );
+static void s_vMgrRxDeauthentication(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
 
-// Scan functions
-// probe request/response functions
-static
-void
-s_vMgrRxProbeRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    );
+/* Scan functions
+*  probe request/response functions */
 
-static
-void
-s_vMgrRxProbeResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    );
+static void s_vMgrRxProbeRequest(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
 
-// beacon functions
-static
-void
-s_vMgrRxBeacon(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     BOOL bInScan
-    );
+static void s_vMgrRxProbeResponse(struct vnt_private *,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket);
 
-static
-void
-s_vMgrFormatTIM(
-     PSMgmtObject pMgmt,
-     PWLAN_IE_TIM pTIM
-    );
+/* beacon functions */
+static void s_vMgrRxBeacon(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       int bInScan);
 
-static
-PSTxMgmtPacket
-s_MgrMakeBeacon(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wCurrBeaconPeriod,
-     unsigned int uCurrChannel,
-     WORD wCurrATIMWinodw,
-     PWLAN_IE_SSID pCurrSSID,
-     PBYTE pCurrBSSID,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
+static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM);
 
+static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
+       u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID,
+       u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-// Association response
-static
-PSTxMgmtPacket
-s_MgrMakeAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wAssocStatus,
-     WORD wAssocAID,
-     PBYTE pDstAddr,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
 
-// ReAssociation response
-static
-PSTxMgmtPacket
-s_MgrMakeReAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wAssocStatus,
-     WORD wAssocAID,
-     PBYTE pDstAddr,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    );
+/* Association response */
+static struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
+       u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-// Probe response
-static
-PSTxMgmtPacket
-s_MgrMakeProbeResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wCurrBeaconPeriod,
-     unsigned int uCurrChannel,
-     WORD wCurrATIMWinodw,
-     PBYTE pDstAddr,
-     PWLAN_IE_SSID pCurrSSID,
-     PBYTE pCurrBSSID,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
-     BYTE byPHYType
-    );
+/* ReAssociation response */
+static struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
+       u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates);
 
-// received status
-static
-void
-s_vMgrLogStatus(
-     PSMgmtObject pMgmt,
-     WORD wStatus
-    );
+/* Probe response */
+static struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
+       u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr,
+       PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID,
+       PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType);
 
+/* received status */
+static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus);
 
-static
-void
-s_vMgrSynchBSS (
-     PSDevice      pDevice,
-     unsigned int          uBSSMode,
-     PKnownBSS     pCurr,
-     PCMD_STATUS  pStatus
-    );
+
+static void s_vMgrSynchBSS(struct vnt_private *, u32 uBSSMode,
+       PKnownBSS pCurr, PCMD_STATUS  pStatus);
 
 
 static BOOL
@@ -324,10 +195,7 @@ s_bCipherMatch (
      PBYTE                           pbyCCSGK
     );
 
- static void  Encyption_Rebuild(
-     PSDevice pDevice,
-     PKnownBSS pCurr
- );
+static void Encyption_Rebuild(struct vnt_private *, PKnownBSS pCurr);
 
 /*---------------------  Export Variables  --------------------------*/
 
@@ -343,11 +211,10 @@ s_bCipherMatch (
  *
 -*/
 
-void vMgrObjectInit(void *hDeviceContext)
+void vMgrObjectInit(struct vnt_private *pDevice)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    int ii;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       int ii;
 
 
     pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0];
@@ -402,12 +269,10 @@ void vMgrObjectInit(void *hDeviceContext)
  *
 -*/
 
-void vMgrAssocBeginSta(void *hDeviceContext,
-                      PSMgmtObject pMgmt,
-                      PCMD_STATUS pStatus)
+void vMgrAssocBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
 {
-    PSDevice             pDevice = (PSDevice)hDeviceContext;
-    PSTxMgmtPacket          pTxPacket;
+       struct vnt_tx_mgmt *pTxPacket;
 
 
     pMgmt->wCurrCapInfo = 0;
@@ -475,14 +340,10 @@ void vMgrAssocBeginSta(void *hDeviceContext,
  *
 -*/
 
-void vMgrReAssocBeginSta(void *hDeviceContext,
-                        PSMgmtObject pMgmt,
-                        PCMD_STATUS pStatus)
+void vMgrReAssocBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
 {
-    PSDevice             pDevice = (PSDevice)hDeviceContext;
-    PSTxMgmtPacket          pTxPacket;
-
-
+       struct vnt_tx_mgmt *pTxPacket;
 
     pMgmt->wCurrCapInfo = 0;
     pMgmt->wCurrCapInfo |= WLAN_SET_CAP_INFO_ESS(1);
@@ -551,19 +412,18 @@ void vMgrReAssocBeginSta(void *hDeviceContext,
  *
 -*/
 
-void vMgrDisassocBeginSta(void *hDeviceContext,
-                         PSMgmtObject pMgmt,
-                         PBYTE  abyDestAddress,
-                         WORD    wReason,
-                         PCMD_STATUS pStatus)
+void vMgrDisassocBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason,
+       PCMD_STATUS pStatus)
 {
-    PSDevice            pDevice = (PSDevice)hDeviceContext;
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_DISASSOC    sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_DISASSOC sFrame;
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_DISASSOC_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
 
     // Setup the sFrame structure
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
@@ -610,23 +470,18 @@ void vMgrDisassocBeginSta(void *hDeviceContext,
  *
 -*/
 
-static
-void
-s_vMgrRxAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     unsigned int uNodeIndex
-    )
+static void s_vMgrRxAssocRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       u32 uNodeIndex)
 {
-    WLAN_FR_ASSOCREQ    sFrame;
-    CMD_STATUS          Status;
-    PSTxMgmtPacket      pTxPacket;
-    WORD                wAssocStatus = 0;
-    WORD                wAssocAID = 0;
-    unsigned int                uRateLen = WLAN_RATES_MAXLEN;
-    BYTE                abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-    BYTE                abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       WLAN_FR_ASSOCREQ sFrame;
+       CMD_STATUS Status;
+       struct vnt_tx_mgmt *pTxPacket;
+       u16 wAssocStatus = 0;
+       u16 wAssocAID = 0;
+       u32 uRateLen = WLAN_RATES_MAXLEN;
+       u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
 
 
     if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
@@ -766,23 +621,18 @@ s_vMgrRxAssocRequest(
  *
 -*/
 
-static
-void
-s_vMgrRxReAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     unsigned int uNodeIndex
-    )
+static void s_vMgrRxReAssocRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       u32 uNodeIndex)
 {
-    WLAN_FR_REASSOCREQ    sFrame;
-    CMD_STATUS          Status;
-    PSTxMgmtPacket      pTxPacket;
-    WORD                wAssocStatus = 0;
-    WORD                wAssocAID = 0;
-    unsigned int                uRateLen = WLAN_RATES_MAXLEN;
-    BYTE                abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-    BYTE                abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       WLAN_FR_REASSOCREQ    sFrame;
+       CMD_STATUS Status;
+       struct vnt_tx_mgmt *pTxPacket;
+       u16 wAssocStatus = 0;
+       u16 wAssocAID = 0;
+       u32 uRateLen = WLAN_RATES_MAXLEN;
+       u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
 
     if (pMgmt->eCurrMode != WMAC_MODE_ESS_AP)
         return;
@@ -913,18 +763,13 @@ s_vMgrRxReAssocRequest(
  *
 -*/
 
-static
-void
-s_vMgrRxAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     BOOL bReAssocType
-    )
+static void s_vMgrRxAssocResponse(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       int bReAssocType)
 {
-    WLAN_FR_ASSOCRESP   sFrame;
-    PWLAN_IE_SSID   pItemSSID;
-    PBYTE   pbyIEs;
+       WLAN_FR_ASSOCRESP   sFrame;
+       PWLAN_IE_SSID   pItemSSID;
+       u8 *pbyIEs;
 
 
 
@@ -1050,17 +895,17 @@ if(pMgmt->eCurrState == WMAC_STATE_ASSOC)
  *
 -*/
 
-void vMgrAuthenBeginSta(void *hDeviceContext,
-                       PSMgmtObject  pMgmt,
-                       PCMD_STATUS pStatus)
+void vMgrAuthenBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PCMD_STATUS pStatus)
 {
-    PSDevice     pDevice = (PSDevice)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)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       WLAN_FR_AUTHEN sFrame;
+       struct vnt_tx_mgmt *pTxPacket =
+               (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_AUTHEN_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
     vMgrEncodeAuthen(&sFrame);
@@ -1103,20 +948,18 @@ void vMgrAuthenBeginSta(void *hDeviceContext,
  *
 -*/
 
-void vMgrDeAuthenBeginSta(void *hDeviceContext,
-                         PSMgmtObject pMgmt,
-                         PBYTE abyDestAddress,
-                         WORD wReason,
-                         PCMD_STATUS pStatus)
+void vMgrDeAuthenBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u8 *abyDestAddress, u16 wReason,
+       PCMD_STATUS pStatus)
 {
-    PSDevice            pDevice = (PSDevice)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)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       WLAN_FR_DEAUTHEN sFrame;
+       struct vnt_tx_mgmt *pTxPacket =
+               (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_DEAUTHEN_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN;
     vMgrEncodeDeauthen(&sFrame);
@@ -1156,15 +999,10 @@ void vMgrDeAuthenBeginSta(void *hDeviceContext,
  *
 -*/
 
-static
-void
-s_vMgrRxAuthentication(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    )
+static void s_vMgrRxAuthentication(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
 {
-    WLAN_FR_AUTHEN  sFrame;
+       WLAN_FR_AUTHEN  sFrame;
 
     // we better be an AP or a STA in AUTHPENDING otherwise ignore
     if (!(pMgmt->eCurrMode == WMAC_MODE_ESS_AP ||
@@ -1214,25 +1052,21 @@ s_vMgrRxAuthentication(
 -*/
 
 
-static
-void
-s_vMgrRxAuthenSequence_1(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-     )
+static void s_vMgrRxAuthenSequence_1(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    unsigned int                uNodeIndex;
-    WLAN_FR_AUTHEN      sFrame;
-    PSKeyItem           pTransmitKey;
-
-    // Insert a Node entry
-    if (!BSSbIsSTAInNodeDB(pDevice, pFrame->pHdr->sA3.abyAddr2, &uNodeIndex)) {
-        BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
-        memcpy(pMgmt->sNodeDBTable[uNodeIndex].abyMACAddr, pFrame->pHdr->sA3.abyAddr2,
-               WLAN_ADDR_LEN);
-    }
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       u32 uNodeIndex;
+       WLAN_FR_AUTHEN sFrame;
+       PSKeyItem pTransmitKey;
+
+       /* Insert a Node entry */
+       if (!BSSbIsSTAInNodeDB(pDevice, 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;
@@ -1243,9 +1077,11 @@ s_vMgrRxAuthenSequence_1(
     }
 
     // send auth reply
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_AUTHEN_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
     // format buffer structure
@@ -1320,16 +1156,11 @@ s_vMgrRxAuthenSequence_1(
  *
 -*/
 
-static
-void
-s_vMgrRxAuthenSequence_2(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    )
+static void s_vMgrRxAuthenSequence_2(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
 {
-    WLAN_FR_AUTHEN      sFrame;
-    PSTxMgmtPacket      pTxPacket = NULL;
+       WLAN_FR_AUTHEN sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
 
 
     switch (cpu_to_le16((*(pFrame->pwAuthAlgorithm))))
@@ -1355,9 +1186,13 @@ s_vMgrRxAuthenSequence_2(
         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)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+                       pTxPacket = (struct vnt_tx_mgmt *)
+                               pMgmt->pbyMgmtPacketPool;
+                       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+                               + WLAN_AUTHEN_FR_MAXLEN);
+                       pTxPacket->p80211Header
+                               = (PUWLAN_80211HDR)((u8 *)pTxPacket
+                                       + sizeof(struct vnt_tx_mgmt));
                 sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
                 sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
                 // format buffer structure
@@ -1421,18 +1256,13 @@ s_vMgrRxAuthenSequence_2(
  *
 -*/
 
-static
-void
-s_vMgrRxAuthenSequence_3(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    )
+static void s_vMgrRxAuthenSequence_3(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    unsigned int                uStatusCode = 0 ;
-    unsigned int                uNodeIndex = 0;
-    WLAN_FR_AUTHEN      sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       u32 uStatusCode = 0 ;
+       u32 uNodeIndex = 0;
+       WLAN_FR_AUTHEN sFrame;
 
     if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) {
         uStatusCode = WLAN_MGMT_STATUS_CHALLENGE_FAIL;
@@ -1462,9 +1292,11 @@ s_vMgrRxAuthenSequence_3(
 
 reply:
     // send auth reply
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_AUTHEN_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_AUTHEN_FR_MAXLEN;
     // format buffer structure
@@ -1509,13 +1341,8 @@ reply:
  *    None.
  *
 -*/
-static
-void
-s_vMgrRxAuthenSequence_4(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PWLAN_FR_AUTHEN pFrame
-    )
+static void s_vMgrRxAuthenSequence_4(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, PWLAN_FR_AUTHEN pFrame)
 {
 
     if ( cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS ){
@@ -1547,17 +1374,12 @@ s_vMgrRxAuthenSequence_4(
  *
 -*/
 
-static
-void
-s_vMgrRxDisassociation(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    )
+static void s_vMgrRxDisassociation(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
 {
-    WLAN_FR_DISASSOC    sFrame;
-    unsigned int        uNodeIndex = 0;
-    CMD_STATUS          CmdStatus;
+       WLAN_FR_DISASSOC    sFrame;
+       u32 uNodeIndex = 0;
+       CMD_STATUS CmdStatus;
 
     if ( pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
         // if is acting an AP..
@@ -1587,7 +1409,7 @@ s_vMgrRxDisassociation(
               pDevice->byReAssocCount = 0;
                 pMgmt->eCurrState = WMAC_STATE_AUTH;  // jump back to the auth state!
                 pDevice->eCommandState = WLAN_ASSOCIATE_WAIT;
-            vMgrReAssocBeginSta((PSDevice)pDevice, pMgmt, &CmdStatus);
+               vMgrReAssocBeginSta(pDevice, pMgmt, &CmdStatus);
               if(CmdStatus == CMD_STATUS_PENDING) {
                  pDevice->byReAssocCount ++;
                  return;       //mike add: you'll retry for many times, so it cann't be regarded as disconnected!
@@ -1620,16 +1442,11 @@ s_vMgrRxDisassociation(
  *
 -*/
 
-static
-void
-s_vMgrRxDeauthentication(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    )
+static void s_vMgrRxDeauthentication(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
 {
-    WLAN_FR_DEAUTHEN    sFrame;
-    unsigned int        uNodeIndex = 0;
+       WLAN_FR_DEAUTHEN sFrame;
+       u32 uNodeIndex = 0;
 
 
     if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP ){
@@ -1692,13 +1509,9 @@ s_vMgrRxDeauthentication(
  *               True:exceed;
  *                False:normal case
 -*/
-static BOOL
-ChannelExceedZoneType(
-     PSDevice pDevice,
-     BYTE byCurrChannel
-    )
+static int ChannelExceedZoneType(struct vnt_private *pDevice, u8 byCurrChannel)
 {
-  BOOL exceed=FALSE;
+       int exceed = FALSE;
 
   switch(pDevice->byZoneType) {
        case 0x00:                  //USA:1~11
@@ -1728,39 +1541,33 @@ ChannelExceedZoneType(
  *
 -*/
 
-static
-void
-s_vMgrRxBeacon(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket,
-     BOOL bInScan
-    )
+static void s_vMgrRxBeacon(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket,
+       int bInScan)
 {
-
-    PKnownBSS           pBSSList;
-    WLAN_FR_BEACON      sFrame;
-    QWORD               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;
-    BYTE                byTIMBitOn = 0;
-    WORD                wAIDNumber = 0;
-    unsigned int                uNodeIndex;
-    QWORD               qwTimestamp, qwLocalTSF;
-    QWORD               qwCurrTSF;
-    WORD                wStartIndex = 0;
-    WORD                wAIDIndex = 0;
-    BYTE                byCurrChannel = pRxPacket->byRxChannel;
-    ERPObject           sERP;
-    unsigned int                uRateLen = WLAN_RATES_MAXLEN;
-    BOOL                bChannelHit = FALSE;
-    BYTE                byOldPreambleType;
+       PKnownBSS pBSSList;
+       WLAN_FR_BEACON sFrame;
+       u64 qwTSFOffset;
+       int bIsBSSIDEqual = FALSE;
+       int bIsSSIDEqual = FALSE;
+       int bTSFLargeDiff = FALSE;
+       int bTSFOffsetPostive = FALSE;
+       int bUpdateTSF = FALSE;
+       int bIsAPBeacon = FALSE;
+       int bIsChannelEqual = FALSE;
+       u32 uLocateByteIndex;
+       u8 byTIMBitOn = 0;
+       u16 wAIDNumber = 0;
+       u32 uNodeIndex;
+       u64 qwTimestamp, qwLocalTSF;
+       u64 qwCurrTSF;
+       u16 wStartIndex = 0;
+       u16 wAIDIndex = 0;
+       u8 byCurrChannel = pRxPacket->byRxChannel;
+       ERPObject sERP;
+       u32 uRateLen = WLAN_RATES_MAXLEN;
+       int bChannelHit = FALSE;
+       u8 byOldPreambleType;
 
 
 
@@ -2013,26 +1820,14 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
         }
     }
 
-    HIDWORD(qwTimestamp) = cpu_to_le32(HIDWORD(*sFrame.pqwTimestamp));
-    LODWORD(qwTimestamp) = cpu_to_le32(LODWORD(*sFrame.pqwTimestamp));
-    HIDWORD(qwLocalTSF) = HIDWORD(pRxPacket->qwLocalTSF);
-    LODWORD(qwLocalTSF) = LODWORD(pRxPacket->qwLocalTSF);
+       qwTimestamp = cpu_to_le64(*sFrame.pqwTimestamp);
+       qwLocalTSF = pRxPacket->qwLocalTSF;
 
     // check if beacon TSF larger or small than our local TSF
-    if (HIDWORD(qwTimestamp) == HIDWORD(qwLocalTSF)) {
-        if (LODWORD(qwTimestamp) >= LODWORD(qwLocalTSF)) {
-            bTSFOffsetPostive = TRUE;
-        }
-        else {
-            bTSFOffsetPostive = FALSE;
-        }
-    }
-    else if (HIDWORD(qwTimestamp) > HIDWORD(qwLocalTSF)) {
-        bTSFOffsetPostive = TRUE;
-    }
-    else if (HIDWORD(qwTimestamp) < HIDWORD(qwLocalTSF)) {
-        bTSFOffsetPostive = FALSE;
-    }
+       if (qwTimestamp >= qwLocalTSF)
+               bTSFOffsetPostive = TRUE;
+       else
+               bTSFOffsetPostive = FALSE;
 
     if (bTSFOffsetPostive) {
         qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwTimestamp), (qwLocalTSF));
@@ -2041,10 +1836,8 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
         qwTSFOffset = CARDqGetTSFOffset(pRxPacket->byRxRate, (qwLocalTSF), (qwTimestamp));
     }
 
-    if (HIDWORD(qwTSFOffset) != 0 ||
-        (LODWORD(qwTSFOffset) > TRIVIAL_SYNC_DIFFERENCE )) {
-         bTSFLargeDiff = TRUE;
-    }
+       if (qwTSFOffset > TRIVIAL_SYNC_DIFFERENCE)
+               bTSFLargeDiff = TRUE;
 
 
     // if infra mode
@@ -2085,12 +1878,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
             if (pMgmt->bInTIM ||
                 (pMgmt->bMulticastTIM && (pMgmt->byDTIMCount == 0))) {
                 pMgmt->bInTIMWake = TRUE;
-                // send out ps-poll packet
-//                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:In TIM\n");
-                if (pMgmt->bInTIM) {
-                    PSvSendPSPOLL((PSDevice)pDevice);
-//                    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BCN:PS-POLL sent..\n");
-                }
+               /* send out ps-poll packet */
+               if (pMgmt->bInTIM)
+                       PSvSendPSPOLL(pDevice);
 
             }
             else {
@@ -2144,8 +1934,8 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
                 pMgmt->sNodeDBTable[uNodeIndex].uInActiveCount = 0;
             }
             else {
-                // Todo, initial Node content
-                BSSvCreateOneNode((PSDevice)pDevice, &uNodeIndex);
+               /* Todo, initial Node content */
+               BSSvCreateOneNode(pDevice, &uNodeIndex);
 
                 pMgmt->abyCurrSuppRates[1] = RATEuSetIE((PWLAN_IE_SUPP_RATES)sFrame.pSuppRates,
                                                         (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates,
@@ -2256,26 +2046,22 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
  *
 -*/
 
-void vMgrCreateOwnIBSS(void *hDeviceContext,
-                      PCMD_STATUS pStatus)
+void vMgrCreateOwnIBSS(struct vnt_private *pDevice, PCMD_STATUS pStatus)
 {
-    PSDevice            pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject        pMgmt = &(pDevice->sMgmtObj);
-    WORD                wMaxBasicRate;
-    WORD                wMaxSuppRate;
-    BYTE                byTopCCKBasicRate;
-    BYTE                byTopOFDMBasicRate;
-    QWORD               qwCurrTSF;
-    unsigned int                ii;
-    BYTE    abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60};
-    BYTE    abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96};
-    BYTE    abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-    WORD                wSuppRate;
-
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u16 wMaxBasicRate;
+       u16 wMaxSuppRate;
+       u8 byTopCCKBasicRate;
+       u8 byTopOFDMBasicRate;
+       u64 qwCurrTSF = 0;
+       int ii;
+       u8 abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C,
+               0x12, 0x18, 0x60};
+       u8 abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96};
+       u8 abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+       u16 wSuppRate;
 
 
-    HIDWORD(qwCurrTSF) = 0;
-    LODWORD(qwCurrTSF) = 0;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Create Basic Service Set .......\n");
 
@@ -2420,12 +2206,12 @@ void vMgrCreateOwnIBSS(void *hDeviceContext,
     if (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) {
 
         // BSSID selected must be randomized as spec 11.1.3
-        pMgmt->abyCurrBSSID[5] = (BYTE) (LODWORD(qwCurrTSF)& 0x000000ff);
-        pMgmt->abyCurrBSSID[4] = (BYTE)((LODWORD(qwCurrTSF)& 0x0000ff00) >> 8);
-        pMgmt->abyCurrBSSID[3] = (BYTE)((LODWORD(qwCurrTSF)& 0x00ff0000) >> 16);
-        pMgmt->abyCurrBSSID[2] = (BYTE)((LODWORD(qwCurrTSF)& 0x00000ff0) >> 4);
-        pMgmt->abyCurrBSSID[1] = (BYTE)((LODWORD(qwCurrTSF)& 0x000ff000) >> 12);
-        pMgmt->abyCurrBSSID[0] = (BYTE)((LODWORD(qwCurrTSF)& 0x0ff00000) >> 20);
+       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];
@@ -2511,22 +2297,21 @@ void vMgrCreateOwnIBSS(void *hDeviceContext,
  *
 -*/
 
-void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus)
+void vMgrJoinBSSBegin(struct vnt_private *pDevice, PCMD_STATUS pStatus)
 {
-    PSDevice     pDevice = (PSDevice)hDeviceContext;
-    PSMgmtObject    pMgmt = &(pDevice->sMgmtObj);
-    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;
-    WORD            wMaxBasicRate = RATE_1M;
-    WORD            wMaxSuppRate = RATE_1M;
-    WORD            wSuppRate;
-    BYTE            byTopCCKBasicRate = RATE_1M;
-    BYTE            byTopOFDMBasicRate = RATE_1M;
-    BOOL            bShortSlotTime = FALSE;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       PKnownBSS pCurr = NULL;
+       int ii, uu;
+       PWLAN_IE_SUPP_RATES pItemRates = NULL;
+       PWLAN_IE_SUPP_RATES pItemExtRates = NULL;
+       PWLAN_IE_SSID   pItemSSID;
+       u32 uRateLen = WLAN_RATES_MAXLEN;
+       u16 wMaxBasicRate = RATE_1M;
+       u16 wMaxSuppRate = RATE_1M;
+       u16 wSuppRate;
+       u8 byTopCCKBasicRate = RATE_1M;
+       u8 byTopOFDMBasicRate = RATE_1M;
+       u8 bShortSlotTime = FALSE;
 
 
     for (ii = 0; ii < MAX_BSS_NUM; ii++) {
@@ -2836,23 +2621,20 @@ void vMgrJoinBSSBegin(void *hDeviceContext, PCMD_STATUS pStatus)
  *    PCM_STATUS
  *
 -*/
-static
-void
-s_vMgrSynchBSS (
-     PSDevice      pDevice,
-     unsigned int          uBSSMode,
-     PKnownBSS     pCurr,
-     PCMD_STATUS  pStatus
-    )
+static void s_vMgrSynchBSS(struct vnt_private *pDevice, u32 uBSSMode,
+       PKnownBSS pCurr, PCMD_STATUS pStatus)
 {
-    PSMgmtObject  pMgmt = &(pDevice->sMgmtObj);
-                                                     //1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M
-    BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
-    BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
-                                                           //6M,   9M,   12M,  48M
-    BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
-    BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
-
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
+       u8 abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES,
+                       8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
+                       /* 1M,   2M,   5M,   11M,  18M,  24M,  36M,  54M*/
+       u8 abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES,
+                       4, 0x0C, 0x12, 0x18, 0x60};
+                       /* 6M,   9M,   12M,  48M*/
+       u8 abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES,
+                       8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+       u8 abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES,
+                       4, 0x02, 0x04, 0x0B, 0x16};
 
     *pStatus = CMD_STATUS_FAILURE;
 
@@ -2991,21 +2773,13 @@ s_vMgrSynchBSS (
     return;
 };
 
-
-//mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption
-//                   ,need reset eAuthenMode and eEncryptionStatus
- static void  Encyption_Rebuild(
-     PSDevice pDevice,
-     PKnownBSS pCurr
- )
+static void Encyption_Rebuild(struct vnt_private *pDevice, PKnownBSS pCurr)
  {
-  PSMgmtObject  pMgmt = &(pDevice->sMgmtObj);
-  /* unsigned int ii, uSameBssidNum=0; */
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
 
-  //   if( uSameBssidNum>=2) {  //we only check AP in hidden sssid  mode
-        if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||           //networkmanager 0.7.0 does not give the pairwise-key selsection,
-             (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {         // so we need re-selsect it according to real pairwise-key info.
-               if(pCurr->bWPAValid == TRUE)  {   //WPA-PSK
+       if ((pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
+               (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
+               if (pCurr->bWPAValid == TRUE)  {   /*WPA-PSK */
                           pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
                    if(pCurr->abyPKType[0] == WPA_TKIP) {
                        pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;    //TKIP
@@ -3044,20 +2818,15 @@ s_vMgrSynchBSS (
  *
 -*/
 
-static
-void
-s_vMgrFormatTIM(
-     PSMgmtObject pMgmt,
-     PWLAN_IE_TIM pTIM
-    )
+static void s_vMgrFormatTIM(struct vnt_manager *pMgmt, PWLAN_IE_TIM pTIM)
 {
-    BYTE        byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-    BYTE        byMap;
-    unsigned int        ii, jj;
-    BOOL        bStartFound = FALSE;
-    BOOL        bMulticast = FALSE;
-    WORD        wStartIndex = 0;
-    WORD        wEndIndex = 0;
+       u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+       u8 byMap;
+       int ii, jj;
+       int bStartFound = FALSE;
+       int bMulticast = FALSE;
+       u16 wStartIndex = 0;
+       u16 wEndIndex = 0;
 
 
     // Find size of partial virtual bitmap
@@ -3119,30 +2888,23 @@ s_vMgrFormatTIM(
  *
 -*/
 
-static
-PSTxMgmtPacket
-s_MgrMakeBeacon(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wCurrBeaconPeriod,
-     unsigned int uCurrChannel,
-     WORD wCurrATIMWinodw,
-     PWLAN_IE_SSID pCurrSSID,
-     PBYTE pCurrBSSID,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    )
+static struct vnt_tx_mgmt *s_MgrMakeBeacon(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
+       u32 uCurrChannel, u16 wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID,
+       u8 *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_BEACON      sFrame;
-    BYTE                abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_BEACON sFrame;
+       u8 abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
 
-    // prepare beacon frame
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       /* prepare beacon frame */
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_BEACON_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     // Setup the sFrame structure.
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_BEACON_FR_MAXLEN;
@@ -3294,30 +3056,22 @@ s_MgrMakeBeacon(
 
 
 
-PSTxMgmtPacket
-s_MgrMakeProbeResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wCurrBeaconPeriod,
-     unsigned int uCurrChannel,
-     WORD wCurrATIMWinodw,
-     PBYTE pDstAddr,
-     PWLAN_IE_SSID pCurrSSID,
-     PBYTE pCurrBSSID,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates,
-     BYTE byPHYType
-    )
+struct vnt_tx_mgmt *s_MgrMakeProbeResponse(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wCurrBeaconPeriod,
+       u32 uCurrChannel, u16 wCurrATIMWinodw, u8 *pDstAddr,
+       PWLAN_IE_SSID pCurrSSID, u8 *pCurrBSSID,
+       PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates, u8 byPHYType)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_PROBERESP   sFrame;
-
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_PROBERESP sFrame;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_PROBERESP_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     // Setup the sFrame structure.
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_PROBERESP_FR_MAXLEN;
@@ -3426,27 +3180,24 @@ s_MgrMakeProbeResponse(
 -*/
 
 
-PSTxMgmtPacket
-s_MgrMakeAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pDAddr,
-     WORD wCurrCapInfo,
-     WORD wListenInterval,
-     PWLAN_IE_SSID pCurrSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    )
+struct vnt_tx_mgmt *s_MgrMakeAssocRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
+       u16 wListenInterval,
+       PWLAN_IE_SSID pCurrSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_ASSOCREQ    sFrame;
-    PBYTE               pbyIEs;
-    PBYTE               pbyRSN;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_ASSOCREQ sFrame;
+       u8 *pbyIEs;
+       u8 *pbyRSN;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_ASSOCREQ_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     // Setup the sFrame structure.
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN;
@@ -3688,27 +3439,23 @@ s_MgrMakeAssocRequest(
 -*/
 
 
-PSTxMgmtPacket
-s_MgrMakeReAssocRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PBYTE pDAddr,
-     WORD wCurrCapInfo,
-     WORD wListenInterval,
-     PWLAN_IE_SSID pCurrSSID,
-     PWLAN_IE_SUPP_RATES pCurrRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    )
+struct vnt_tx_mgmt *s_MgrMakeReAssocRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u8 *pDAddr, u16 wCurrCapInfo,
+       u16 wListenInterval, PWLAN_IE_SSID pCurrSSID,
+       PWLAN_IE_SUPP_RATES pCurrRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_REASSOCREQ  sFrame;
-    PBYTE               pbyIEs;
-    PBYTE               pbyRSN;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_REASSOCREQ  sFrame;
+       u8 *pbyIEs;
+       u8 *pbyRSN;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset( pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_REASSOCREQ_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     /* Setup the sFrame structure. */
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN;
@@ -3942,25 +3689,20 @@ s_MgrMakeReAssocRequest(
  *
 -*/
 
-PSTxMgmtPacket
-s_MgrMakeAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wAssocStatus,
-     WORD wAssocAID,
-     PBYTE pDstAddr,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    )
+struct vnt_tx_mgmt *s_MgrMakeAssocResponse(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
+       u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_ASSOCRESP   sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_ASSOCRESP   sFrame;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_ASSOCREQ_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     // Setup the sFrame structure
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
@@ -4016,25 +3758,20 @@ s_MgrMakeAssocResponse(
 -*/
 
 
-PSTxMgmtPacket
-s_MgrMakeReAssocResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     WORD wCurrCapInfo,
-     WORD wAssocStatus,
-     WORD wAssocAID,
-     PBYTE pDstAddr,
-     PWLAN_IE_SUPP_RATES pCurrSuppRates,
-     PWLAN_IE_SUPP_RATES pCurrExtSuppRates
-    )
+struct vnt_tx_mgmt *s_MgrMakeReAssocResponse(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, u16 wCurrCapInfo, u16 wAssocStatus,
+       u16 wAssocAID, u8 *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates,
+       PWLAN_IE_SUPP_RATES pCurrExtSuppRates)
 {
-    PSTxMgmtPacket      pTxPacket = NULL;
-    WLAN_FR_REASSOCRESP   sFrame;
+       struct vnt_tx_mgmt *pTxPacket = NULL;
+       WLAN_FR_REASSOCRESP sFrame;
 
 
-    pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-    memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN);
-    pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
+       pTxPacket = (struct vnt_tx_mgmt *)pMgmt->pbyMgmtPacketPool;
+       memset(pTxPacket, 0, sizeof(struct vnt_tx_mgmt)
+               + WLAN_ASSOCREQ_FR_MAXLEN);
+       pTxPacket->p80211Header = (PUWLAN_80211HDR)((u8 *)pTxPacket
+               + sizeof(struct vnt_tx_mgmt));
     // Setup the sFrame structure
     sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
     sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN;
@@ -4089,19 +3826,14 @@ s_MgrMakeReAssocResponse(
  *
 -*/
 
-static
-void
-s_vMgrRxProbeResponse(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    )
+static void s_vMgrRxProbeResponse(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
 {
-    PKnownBSS           pBSSList = NULL;
-    WLAN_FR_PROBERESP   sFrame;
-    BYTE                byCurrChannel = pRxPacket->byRxChannel;
-    ERPObject           sERP;
-    BOOL                bChannelHit = TRUE;
+       PKnownBSS pBSSList = NULL;
+       WLAN_FR_PROBERESP sFrame;
+       u8 byCurrChannel = pRxPacket->byRxChannel;
+       ERPObject sERP;
+       int bChannelHit = TRUE;
 
 
     memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP));
@@ -4221,18 +3953,13 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE)
 -*/
 
 
-static
-void
-s_vMgrRxProbeRequest(
-     PSDevice pDevice,
-     PSMgmtObject pMgmt,
-     PSRxMgmtPacket pRxPacket
-    )
+static void s_vMgrRxProbeRequest(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt, struct vnt_rx_mgmt *pRxPacket)
 {
-    WLAN_FR_PROBEREQ    sFrame;
-    CMD_STATUS          Status;
-    PSTxMgmtPacket      pTxPacket;
-    BYTE                byPHYType = BB_TYPE_11B;
+       WLAN_FR_PROBEREQ sFrame;
+       CMD_STATUS Status;
+       struct vnt_tx_mgmt *pTxPacket;
+       u8 byPHYType = BB_TYPE_11B;
 
     // STA in Ad-hoc mode: when latest TBTT beacon transmit success,
     // STA have to response this request.
@@ -4307,15 +4034,13 @@ s_vMgrRxProbeRequest(
  *
 -*/
 
-void vMgrRxManagePacket(void *hDeviceContext,
-                       PSMgmtObject pMgmt,
-                       PSRxMgmtPacket pRxPacket)
+void vMgrRxManagePacket(struct vnt_private *pDevice, struct vnt_manager *pMgmt,
+               struct vnt_rx_mgmt *pRxPacket)
 {
-    PSDevice    pDevice = (PSDevice)hDeviceContext;
-    BOOL        bInScan = FALSE;
-    unsigned int        uNodeIndex = 0;
-    NODE_STATE  eNodeState = 0;
-    CMD_STATUS  Status;
+       int bInScan = FALSE;
+       u32 uNodeIndex = 0;
+       NODE_STATE eNodeState = 0;
+       CMD_STATUS Status;
 
 
     if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
@@ -4453,10 +4178,10 @@ void vMgrRxManagePacket(void *hDeviceContext,
  *    TRUE if success; FALSE if failed.
  *
 -*/
-BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, PSMgmtObject pMgmt)
+int bMgrPrepareBeaconToSend(struct vnt_private *pDevice,
+       struct vnt_manager *pMgmt)
 {
-    PSDevice            pDevice = (PSDevice)hDeviceContext;
-    PSTxMgmtPacket      pTxPacket;
+       struct vnt_tx_mgmt *pTxPacket;
 
 //    pDevice->bBeaconBufReady = FALSE;
     if (pDevice->bEncryptionEnable || pDevice->bEnable8021x){
@@ -4504,12 +4229,7 @@ BOOL bMgrPrepareBeaconToSend(void *hDeviceContext, PSMgmtObject pMgmt)
  *    none.
  *
 -*/
-static
-void
-s_vMgrLogStatus(
-     PSMgmtObject pMgmt,
-     WORD  wStatus
-    )
+static void s_vMgrLogStatus(struct vnt_manager *pMgmt, u16 wStatus)
 {
     switch( wStatus ){
         case WLAN_MGMT_STATUS_UNSPEC_FAILURE:
@@ -4574,13 +4294,11 @@ s_vMgrLogStatus(
  *
 -*/
 
-BOOL bAdd_PMKID_Candidate(void *hDeviceContext,
-                         PBYTE pbyBSSID,
-                         PSRSNCapObject psRSNCapObj)
+int bAdd_PMKID_Candidate(struct vnt_private *pDevice, u8 *pbyBSSID,
+       PSRSNCapObject psRSNCapObj)
 {
-    PSDevice         pDevice = (PSDevice)hDeviceContext;
-    PPMKID_CANDIDATE pCandidateList;
-    unsigned int             ii = 0;
+       PPMKID_CANDIDATE pCandidateList;
+       int ii = 0;
 
     DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates);
 
@@ -4636,14 +4354,14 @@ BOOL bAdd_PMKID_Candidate(void *hDeviceContext,
  *
 -*/
 
-void vFlush_PMKID_Candidate(void *hDeviceContext)
+void vFlush_PMKID_Candidate(struct vnt_private *pDevice)
 {
-    PSDevice        pDevice = (PSDevice)hDeviceContext;
+       if (pDevice == NULL)
+               return;
 
-    if (pDevice == NULL)
-        return;
+       memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
 
-    memset(&pDevice->gsPMKIDCandidate, 0, sizeof(SPMKIDCandidateEvent));
+       return;
 }
 
 static BOOL
index 52b1b562b14144f79d7969cc17b9657d365b81fc..83aed45f68a3c3c41470eb0ad3e44a6c7753245a 100644 (file)
@@ -218,216 +218,199 @@ typedef enum tagWMAC_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;
-    QWORD               qwLocalTSF;
-    unsigned int                cbMPDULen;
-    unsigned int                cbPayloadLen;
-    unsigned int                uRSSI;
-    BYTE                bySQ;
-    BYTE                byRxRate;
-    BYTE                byRxChannel;
-
-} SRxMgmtPacket, *PSRxMgmtPacket;
-
-
-
-typedef struct tagSMgmtObject
-{
+/* Tx Management Packet descriptor */
+struct vnt_tx_mgmt {
+       PUWLAN_80211HDR p80211Header;
+       u32 cbMPDULen;
+       u32 cbPayloadLen;
+};
+
+
+/* Rx Management Packet descriptor */
+struct vnt_rx_mgmt {
+       PUWLAN_80211HDR p80211Header;
+       u64 qwLocalTSF;
+       u32 cbMPDULen;
+       u32 cbPayloadLen;
+       u32 uRSSI;
+       u8 bySQ;
+       u8 byRxRate;
+       u8 byRxChannel;
+};
+
+
+struct vnt_manager {
        void *pAdapter;
-    // MAC address
-    BYTE                    abyMACAddr[WLAN_ADDR_LEN];
-
-    // Configuration Mode
-    WMAC_CONFIG_MODE        eConfigMode; // MAC pre-configed mode
-
-    CARD_PHY_TYPE           eCurrentPHYMode;
-
-
-    // Operation state variables
-    WMAC_CURRENT_MODE       eCurrMode;   // MAC current connection mode
-    WMAC_BSS_STATE          eCurrState;  // MAC current BSS state
-    WMAC_BSS_STATE          eLastState;  // MAC last BSS state
-
-    PKnownBSS               pCurrBSS;
-    BYTE                    byCSSGK;
-    BYTE                    byCSSPK;
-
-//    BYTE                    abyNewSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
-//    BYTE                    abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN];
-    BOOL                    bCurrBSSIDFilterOn;
-
-    // Current state vars
-    unsigned int                    uCurrChannel;
-    BYTE                    abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-    BYTE                    abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-    BYTE                    abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-    BYTE                    abyCurrBSSID[WLAN_BSSID_LEN];
-    WORD                    wCurrCapInfo;
-    WORD                    wCurrAID;
-    unsigned int                    uRSSITrigger;
-    WORD                    wCurrATIMWindow;
-    WORD                    wCurrBeaconPeriod;
-    BOOL                    bIsDS;
-    BYTE                    byERPContext;
-
-    CMD_STATE               eCommandState;
-    unsigned int                    uScanChannel;
-
-    // Desire joinning BSS vars
-    BYTE                    abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-    BYTE                    abyDesireBSSID[WLAN_BSSID_LEN];
-
-//restore BSS info for Ad-Hoc mode
-     BYTE                    abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-
-    // Adhoc or AP configuration vars
-    WORD                    wIBSSBeaconPeriod;
-    WORD                    wIBSSATIMWindow;
-    unsigned int                    uIBSSChannel;
-    BYTE                    abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
-    BYTE                    byAPBBType;
-    BYTE                    abyWPAIE[MAX_WPA_IE_LEN];
-    WORD                    wWPAIELen;
-
-    unsigned int                    uAssocCount;
-    BOOL                    bMoreData;
-
-    // Scan state vars
-    WMAC_SCAN_STATE         eScanState;
-    WMAC_SCAN_TYPE          eScanType;
-    unsigned int                    uScanStartCh;
-    unsigned int                    uScanEndCh;
-    WORD                    wScanSteps;
-    unsigned int                    uScanBSSType;
-    // Desire scannig vars
-    BYTE                    abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
-    BYTE                    abyScanBSSID[WLAN_BSSID_LEN];
-
-    // Privacy
-    WMAC_AUTHENTICATION_MODE eAuthenMode;
-    BOOL                    bShareKeyAlgorithm;
-    BYTE                    abyChallenge[WLAN_CHALLENGE_LEN];
-    BOOL                    bPrivacyInvoked;
-
-    // Received beacon state vars
-    BOOL                    bInTIM;
-    BOOL                    bMulticastTIM;
-    BYTE                    byDTIMCount;
-    BYTE                    byDTIMPeriod;
-
-    // Power saving state vars
-    WMAC_POWER_MODE         ePSMode;
-    WORD                    wListenInterval;
-    WORD                    wCountToWakeUp;
-    BOOL                    bInTIMWake;
-    PBYTE                   pbyPSPacketPool;
-    BYTE                    byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN];
-    BOOL                    bRxBeaconInTBTTWake;
-    BYTE                    abyPSTxMap[MAX_NODE_NUM + 1];
-
-    // management command related
-    unsigned int                    uCmdBusy;
-    unsigned int                    uCmdHostAPBusy;
-
-    // management packet pool
-    PBYTE                   pbyMgmtPacketPool;
-    BYTE                    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];
-       /* link list of same bss's */
-    KnownBSS                           pSameBSS[6] ;
-    BOOL          Cisco_cckm ;
-    BYTE          Roam_dbm;
-
-    // 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;
-    BYTE                    byNewChannel;
-    PWLAN_IE_MEASURE_REP    pCurrMeasureEIDRep;
-    unsigned int                    uLengthOfRepEIDs;
-    BYTE                    abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
-    BYTE                    abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN];
-    BYTE                    abyIECountry[WLAN_A3FR_MAXLEN];
-    BYTE                    abyIBSSDFSOwner[6];
-    BYTE                    byIBSSDFSRecovery;
-
-    struct sk_buff  skb;
-
-} SMgmtObject, *PSMgmtObject;
+       /* MAC address */
+       u8  abyMACAddr[WLAN_ADDR_LEN];
+
+       /* Configuration Mode */
+       WMAC_CONFIG_MODE eConfigMode; /* MAC pre-configed mode */
+
+       CARD_PHY_TYPE eCurrentPHYMode;
+
+       /* Operation state variables */
+       WMAC_CURRENT_MODE eCurrMode; /* MAC current connection mode */
+       WMAC_BSS_STATE eCurrState; /* MAC current BSS state */
+       WMAC_BSS_STATE eLastState; /* MAC last BSS state */
+
+       PKnownBSS pCurrBSS;
+       u8 byCSSGK;
+       u8 byCSSPK;
+
+       int bCurrBSSIDFilterOn;
+
+       /* Current state vars */
+       u32 uCurrChannel;
+       u8 abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       u8 abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       u8 abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+       u8 abyCurrBSSID[WLAN_BSSID_LEN];
+       u16 wCurrCapInfo;
+       u16 wCurrAID;
+       u32 uRSSITrigger;
+       u16 wCurrATIMWindow;
+       u16 wCurrBeaconPeriod;
+       int bIsDS;
+       u8 byERPContext;
+
+       CMD_STATE eCommandState;
+       u32 uScanChannel;
+
+       /* Desire joinning BSS vars */
+       u8 abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+       u8 abyDesireBSSID[WLAN_BSSID_LEN];
+
+       /*restore BSS info for Ad-Hoc mode */
+       u8 abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+
+       /* Adhoc or AP configuration vars */
+       u16 wIBSSBeaconPeriod;
+       u16 wIBSSATIMWindow;
+       u32 uIBSSChannel;
+       u8 abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1];
+       u8 byAPBBType;
+       u8 abyWPAIE[MAX_WPA_IE_LEN];
+       u16 wWPAIELen;
+
+       u32 uAssocCount;
+       int bMoreData;
+
+       /* Scan state vars */
+       WMAC_SCAN_STATE eScanState;
+       WMAC_SCAN_TYPE eScanType;
+       u32 uScanStartCh;
+       u32 uScanEndCh;
+       u16 wScanSteps;
+       u32 uScanBSSType;
+       /* Desire scannig vars */
+       u8 abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+       u8 abyScanBSSID[WLAN_BSSID_LEN];
+
+       /* Privacy */
+       WMAC_AUTHENTICATION_MODE eAuthenMode;
+       int bShareKeyAlgorithm;
+       u8 abyChallenge[WLAN_CHALLENGE_LEN];
+       int bPrivacyInvoked;
+
+       /* Received beacon state vars */
+       int bInTIM;
+       int bMulticastTIM;
+       u8 byDTIMCount;
+       u8 byDTIMPeriod;
+
+       /* Power saving state vars */
+       WMAC_POWER_MODE ePSMode;
+       u16 wListenInterval;
+       u16 wCountToWakeUp;
+       int bInTIMWake;
+       u8 *pbyPSPacketPool;
+       u8 byPSPacketPool[sizeof(struct vnt_tx_mgmt)
+               + WLAN_NULLDATA_FR_MAXLEN];
+       int bRxBeaconInTBTTWake;
+       u8 abyPSTxMap[MAX_NODE_NUM + 1];
+
+       /* management command related */
+       u32 uCmdBusy;
+       u32 uCmdHostAPBusy;
+
+       /* management packet pool */
+       u8 *pbyMgmtPacketPool;
+       u8 byMgmtPacketPool[sizeof(struct vnt_tx_mgmt)
+               + WLAN_A3FR_MAXLEN];
+
+
+       /* One second callback timer */
+       struct timer_list sTimerSecondCallback;
+
+       /* Temporarily Rx Mgmt Packet Descriptor */
+       struct vnt_rx_mgmt sRxPacket;
+
+       /* link list of known bss's (scan results) */
+       KnownBSS sBSSList[MAX_BSS_NUM];
+       /* link list of same bss's */
+       KnownBSS pSameBSS[6];
+       int Cisco_cckm;
+       u8 Roam_dbm;
+
+       /* 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;
+       int bRoaming;
+
+       /* associate info */
+       SAssocInfo sAssocInfo;
+
+       /* for 802.11h */
+       int b11hEnable;
+       int bSwitchChannel;
+       u8 byNewChannel;
+       PWLAN_IE_MEASURE_REP    pCurrMeasureEIDRep;
+       u32 uLengthOfRepEIDs;
+       u8 abyCurrentMSRReq[sizeof(struct vnt_tx_mgmt)
+               + WLAN_A3FR_MAXLEN];
+       u8 abyCurrentMSRRep[sizeof(struct vnt_tx_mgmt)
+               + WLAN_A3FR_MAXLEN];
+       u8 abyIECountry[WLAN_A3FR_MAXLEN];
+       u8 abyIBSSDFSOwner[6];
+       u8 byIBSSDFSRecovery;
+
+       struct sk_buff skb;
+
+};
 
 /*---------------------  Export Macros ------------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
 
-void vMgrObjectInit(void *hDeviceContext);
+void vMgrObjectInit(struct vnt_private *pDevice);
 
-void vMgrAssocBeginSta(void *hDeviceContext,
-                      PSMgmtObject pMgmt,
-                      PCMD_STATUS pStatus);
+void vMgrAssocBeginSta(struct vnt_private *pDevice,
+               struct vnt_manager *, PCMD_STATUS pStatus);
 
-void vMgrReAssocBeginSta(void *hDeviceContext,
-                        PSMgmtObject pMgmt,
-                        PCMD_STATUS pStatus);
+void vMgrReAssocBeginSta(struct vnt_private *pDevice,
+               struct vnt_manager *, PCMD_STATUS pStatus);
 
-void vMgrDisassocBeginSta(void *hDeviceContext,
-                         PSMgmtObject pMgmt,
-                         PBYTE abyDestAddress,
-                         WORD wReason,
-                         PCMD_STATUS pStatus);
+void vMgrDisassocBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *, u8 *abyDestAddress, u16 wReason,
+       PCMD_STATUS pStatus);
 
-void vMgrAuthenBeginSta(void *hDeviceContext,
-                       PSMgmtObject pMgmt,
-                       PCMD_STATUS pStatus);
+void vMgrAuthenBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *, PCMD_STATUS pStatus);
 
-void vMgrCreateOwnIBSS(void *hDeviceContext,
-                      PCMD_STATUS pStatus);
+void vMgrCreateOwnIBSS(struct vnt_private *pDevice,
+       PCMD_STATUS pStatus);
 
-void vMgrJoinBSSBegin(void *hDeviceContext,
-                     PCMD_STATUS pStatus);
+void vMgrJoinBSSBegin(struct vnt_private *pDevice,
+       PCMD_STATUS pStatus);
 
-void vMgrRxManagePacket(void *hDeviceContext,
-                       PSMgmtObject pMgmt,
-                       PSRxMgmtPacket pRxPacket);
+void vMgrRxManagePacket(struct vnt_private *pDevice,
+       struct vnt_manager *, struct vnt_rx_mgmt *);
 
 /*
 void
@@ -437,19 +420,16 @@ vMgrScanBegin(
     );
 */
 
-void vMgrDeAuthenBeginSta(void *hDeviceContext,
-                         PSMgmtObject pMgmt,
-                         PBYTE abyDestAddress,
-                         WORD wReason,
-                         PCMD_STATUS pStatus);
+void vMgrDeAuthenBeginSta(struct vnt_private *pDevice,
+       struct vnt_manager *, u8 *abyDestAddress, u16 wReason,
+       PCMD_STATUS pStatus);
 
-BOOL bMgrPrepareBeaconToSend(void *hDeviceContext,
-                            PSMgmtObject pMgmt);
+int bMgrPrepareBeaconToSend(struct vnt_private *pDevice,
+       struct vnt_manager *);
 
-BOOL bAdd_PMKID_Candidate(void *hDeviceContext,
-                         PBYTE pbyBSSID,
-                         PSRSNCapObject psRSNCapObj);
+int bAdd_PMKID_Candidate(struct vnt_private *pDevice,
+       u8 *pbyBSSID, PSRSNCapObject psRSNCapObj);
 
-void vFlush_PMKID_Candidate(void *hDeviceContext);
+void vFlush_PMKID_Candidate(struct vnt_private *pDevice);
 
 #endif /* __WMGR_H__ */
index 616e24dcf42b9c7fce42ef7521209009ce9a7632..99b4589a631842cadf2127865a45da6ab29ef6c2 100644 (file)
@@ -260,19 +260,16 @@ WPA2vParseRSN (
  * Return Value: length of IEs.
  *
 -*/
-unsigned int
-WPA2uSetIEs(void *pMgmtHandle,
-     PWLAN_IE_RSN pRSNIEs
-    )
+unsigned int WPA2uSetIEs(void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs)
 {
-    PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtHandle;
-    PBYTE           pbyBuffer = NULL;
-    unsigned int            ii = 0;
-    PWORD           pwPMKID = NULL;
+       struct vnt_manager *pMgmt = (struct vnt_manager *)pMgmtHandle;
+       u8 *pbyBuffer = NULL;
+       int ii = 0;
+       u16 *pwPMKID = NULL;
+
+       if (pRSNIEs == NULL)
+               return 0;
 
-    if (pRSNIEs == NULL) {
-        return(0);
-    }
     if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
          (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) &&
         (pMgmt->pCurrBSS != NULL)) {
index cc1d48bced2d9ee4944009c382af8f713f97c76b..569d1a7262857454fb78f730eb0ee33f12e3d9f2 100644 (file)
@@ -67,14 +67,14 @@ static int msglevel = MSG_LEVEL_INFO;
  * Return Value:
  *
  */
-int wpa_set_keys(PSDevice pDevice, void *ctx)
+int wpa_set_keys(struct vnt_private *pDevice, void *ctx)
 {
        struct viawget_wpa_param *param = ctx;
-       PSMgmtObject pMgmt = &pDevice->sMgmtObj;
+       struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
        DWORD dwKeyIndex = 0;
        BYTE abyKey[MAX_KEY_LEN];
        BYTE abySeq[MAX_KEY_LEN];
-       QWORD KeyRSC;
+       u64 KeyRSC;
        BYTE byKeyDecMode = KEY_CTL_WEP;
        int ret = 0;
        int uu;
@@ -136,9 +136,9 @@ int wpa_set_keys(PSDevice pDevice, void *ctx)
        if (param->u.wpa_key.seq_len > 0) {
                for (ii = 0 ; ii < param->u.wpa_key.seq_len ; ii++) {
                        if (ii < 4)
-                               LODWORD(KeyRSC) |= (abySeq[ii] << (ii * 8));
+                               KeyRSC |= (abySeq[ii] << (ii * 8));
                        else
-                               HIDWORD(KeyRSC) |= (abySeq[ii] << ((ii-4) * 8));
+                               KeyRSC |= (abySeq[ii] << ((ii-4) * 8));
                }
                dwKeyIndex |= 1 << 29;
        }
@@ -203,7 +203,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx)
 
                if ((KeybSetAllGroupKey(pDevice, &(pDevice->sKey), dwKeyIndex,
                                                        param->u.wpa_key.key_len,
-                                                       (PQWORD) &(KeyRSC),
+                                                       &KeyRSC,
                                                        (PBYTE)abyKey,
                                                        byKeyDecMode
                                        ) == TRUE) &&
@@ -211,7 +211,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx)
                                        &(pDevice->sKey),
                                        dwKeyIndex,
                                        param->u.wpa_key.key_len,
-                                       (PQWORD) &(KeyRSC),
+                                       &KeyRSC,
                                        (PBYTE)abyKey,
                                        byKeyDecMode
                                ) == TRUE) ) {
@@ -234,7 +234,7 @@ int wpa_set_keys(PSDevice pDevice, void *ctx)
                }
                if (KeybSetKey(pDevice, &(pDevice->sKey), &param->addr[0],
                                dwKeyIndex, param->u.wpa_key.key_len,
-                               (PQWORD) &(KeyRSC), (PBYTE)abyKey, byKeyDecMode
+                               &KeyRSC, (PBYTE)abyKey, byKeyDecMode
                                ) == TRUE) {
                        DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Pairwise Key Set\n");
                } else {
index b4ec6b0e1c670967b2294d9b6ea328da88e370a3..2235ee97012e16a30991e9054f535f01af586e96 100644 (file)
@@ -52,6 +52,6 @@ typedef unsigned long long NDIS_802_11_KEY_RSC;
 
 /*---------------------  Export Functions  --------------------------*/
 
-int wpa_set_keys(PSDevice pDevice, void *ctx);
+int wpa_set_keys(struct vnt_private *, void *ctx);
 
 #endif /* __WPACL_H__ */
index a29f60836b774e28080aa7854fb7bad7ac1c188a..db5b053d9bc2ef0b4f0819ace88af2ab4628c693 100644 (file)
@@ -8,4 +8,4 @@ config W35UND
          Hardware is present in some Kohjinsha subnotebooks, and in some
          stand-alone USB modules. Chipset name seems to be w89c35d.
 
-         Check http://code.google.com/p/winbondport/ for new version.
+         Check <http://code.google.com/p/winbondport/> for new version.
index e524153e925dea8dfe8d0335fd79874d3098ad20..3a08d421c73561e351a6472bbdf609b1364143e7 100644 (file)
@@ -3256,7 +3256,7 @@ static const CFG_PROG_STRCT fw_image_code[] = {
                0x0146,         /* sizeof(fw_image_1_data), */
                0x00000060,                                     /* Target address in NIC Memory */
                0x0000,                                         /* CRC: yes/no  TYPE: primary/station/tertiary */
-               (hcf_8 FAR *) fw_image_1_data
+               (hcf_8 *)fw_image_1_data
        },
        {
                8,
@@ -3265,7 +3265,7 @@ static const CFG_PROG_STRCT fw_image_code[] = {
                0x1918,         /* sizeof(fw_image_2_data), */
                0x00000C16,                                     /* Target address in NIC Memory */
                0x0000,                                         /* CRC: yes/no  TYPE: primary/station/tertiary */
-               (hcf_8 FAR *) fw_image_2_data
+               (hcf_8 *)fw_image_2_data
        },
        {
                8,
@@ -3274,7 +3274,7 @@ static const CFG_PROG_STRCT fw_image_code[] = {
                0x01bc,         /* sizeof(fw_image_3_data), */
                0x001E252E,                                     /* Target address in NIC Memory */
                0x0000,                                         /* CRC: yes/no  TYPE: primary/station/tertiary */
-               (hcf_8 FAR *) fw_image_3_data
+               (hcf_8 *)fw_image_3_data
        },
        {
                8,
@@ -3283,7 +3283,7 @@ static const CFG_PROG_STRCT fw_image_code[] = {
                0xab28,         /* sizeof(fw_image_4_data), */
                0x001F4000,                                     /* Target address in NIC Memory */
                0x0000,                                         /* CRC: yes/no  TYPE: primary/station/tertiary */
-               (hcf_8 FAR *) fw_image_4_data
+               (hcf_8 *)fw_image_4_data
        },
        {
                5,
index f4491cbd08d35e615d55ac76c3c2e7f23b09ce51..d3a0faa3ab97b1dd7792917dd972a51d585b50d1 100644 (file)
  */
 
 
-#include "hcfcfg.h"                            // to get hcf_16 etc defined as well as
-                                // possible settings which inluence mdd.h or dhf.h
-#include "mdd.h"                               //to get COMP_ID_STA etc defined
-#include "dhf.h"                               //used to be "fhfmem.h", to get memblock,plugrecord,
+#include "hcfcfg.h"    /* to get hcf_16 etc defined as well as */
+                       /* possible settings which inluence mdd.h or dhf.h */
+#include "mdd.h"       /* to get COMP_ID_STA etc defined */
+#include "dhf.h"       /* used to be fhfmem.h, to get memblock,plugrecord, */
 
 static const hcf_8 fw_image_1_data[] = {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -3996,59 +3996,59 @@ static const hcf_8 fw_image_4_data[] = {
 
 static const CFG_IDENTITY_STRCT fw_image_infoidentity[] = {
        {
-               sizeof( CFG_IDENTITY_STRCT ) / sizeof(hcf_16) - 1,
+               sizeof(CFG_IDENTITY_STRCT) / sizeof(hcf_16) - 1,
                CFG_FW_IDENTITY,
                COMP_ID_FW_AP,
-               3,                                                      //Variant
-               1,                                                      //Major
-               24                                                      //Minor
+               3,      /* Variant */
+               1,      /* Major */
+               24      /* Minor */
        },
-       { 0000, 0000, 0000, 0000, 0000, 0000 }          //endsentinel
+       { 0000, 0000, 0000, 0000, 0000, 0000 }  /* endsentinel */
 };
 
 static const CFG_PROG_STRCT fw_image_code[] = {
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x0148,         // sizeof(fw_image_1_data),
-               0x00000060,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_1_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0x0148,                 /* sizeof(fw_image_1_data), */
+               0x00000060,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_1_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x2432,         // sizeof(fw_image_2_data),
-               0x00000C16,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_2_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0x2432,                 /* sizeof(fw_image_2_data), */
+               0x00000C16,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_2_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x194c,         // sizeof(fw_image_3_data),
-               0x001E3048,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_3_data
+               CFG_PROG_VOLATILE,      /*  mode */
+               0x194c,                 /*  sizeof(fw_image_3_data), */
+               0x001E3048,             /*  Target address in NIC Memory */
+               0x0000,                 /*  CRC: yes/no TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_3_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0xb7e4,         // sizeof(fw_image_4_data),
-               0x001F4000,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_4_data
+               CFG_PROG_VOLATILE,      /* mode*/
+               0xb7e4,                 /* sizeof(fw_image_4_data),*/
+               0x001F4000,             /* Target address in NIC Memory*/
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary*/
+               (hcf_8 *)fw_image_4_data
        },
        {
                5,
                CFG_PROG,
-               CFG_PROG_STOP,                          // mode
+               CFG_PROG_STOP,          /* mode*/
                0000,
-       0x000F2101,                                     // Start execution address
+               0x000F2101,             /* Start execution address*/
        },
        { 0000, 0000, 0000, 0000, 00000000, 0000, 00000000}
 };
@@ -4059,7 +4059,7 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_SUPL,
                COMP_ID_APF,
                {
-                       { 4, 1, 1 }                             //variant, bottom, top
+                       { 4, 1, 1 }     /* variant, bottom, top*/
                }
        },
        {       3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)),
@@ -4067,8 +4067,8 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_ACT,
                COMP_ID_MFI,
                {
-                       { 7, 3, 3 },                            //variant, bottom, top
-                       { 8, 1, 1 }                             //variant, bottom, top
+                       { 7, 3, 3 },    /* variant, bottom, top */
+                       { 8, 1, 1 }     /* variant, bottom, top */
                }
        },
        {       3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)),
@@ -4076,18 +4076,18 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_ACT,
                COMP_ID_CFI,
                {
-                       { 4, 1, 2 }                             //variant, bottom, top
+                       { 4, 1, 2 }     /* variant, bottom, top */
                }
        },
-       { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } }                    //endsentinel
+       { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } }    /* endsentinel */
 };
 
 memimage fw_image = {
-       "FUPU7D37dhfwci\001C",                  //signature, <format number>, C/Bin type
+       "FUPU7D37dhfwci\001C",                  /* signature, <format number>, C/Bin type */
        (CFG_PROG_STRCT *) fw_image_code,
        0x000F2101,
-       00000000,                                       //(dummy) pdaplug
-       00000000,                                       //(dummy) priplug
+       00000000,                               /* (dummy) pdaplug */
+       00000000,                               /* (dummy) priplug */
        (CFG_RANGE20_STRCT *) fw_image_infocompat,
        (CFG_IDENTITY_STRCT *) fw_image_infoidentity,
 };
index 00dffe2ed8f1b38382e5f544b8bf5de42441b838..19bed819df1e7e6f1ee4b3f68657953d4a31f870 100644 (file)
  */
 
 
-#include "hcfcfg.h"                            // to get hcf_16 etc defined as well as
-                                // possible settings which influence mdd.h or dhf.h
-#include "mdd.h"                               //to get COMP_ID_STA etc defined
-#include "dhf.h"                               //used to be "fhfmem.h", to get memblock,plugrecord,
+#include "hcfcfg.h"    /* to get hcf_16 etc defined as well as */
+                       /* possible settings which influence mdd.h or dhf.h */
+#include "mdd.h"       /* to get COMP_ID_STA etc defined */
+#include "dhf.h"       /* used to be fhfmem.h, to get memblock,plugrecord, */
 
 static const hcf_8 fw_image_1_data[] = {
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -4381,59 +4381,59 @@ static const hcf_8 fw_image_4_data[] = {
 
 static const CFG_IDENTITY_STRCT fw_image_infoidentity[] = {
        {
-               sizeof( CFG_IDENTITY_STRCT ) / sizeof(hcf_16) - 1,
+               sizeof(CFG_IDENTITY_STRCT) / sizeof(hcf_16) - 1,
                CFG_FW_IDENTITY,
                COMP_ID_FW_STA,
-               3,                                                      //Variant
-               2,                                                      //Major
-               36                                                      //Minor
+               3,                      /* Variant */
+               2,                      /* Major */
+               36                      /* Minor */
        },
-       { 0000, 0000, 0000, 0000, 0000, 0000 }          //endsentinel
+       { 0000, 0000, 0000, 0000, 0000, 0000 }  /* endsentinel */
 };
 
 static const CFG_PROG_STRCT fw_image_code[] = {
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x0186,         // sizeof(fw_image_1_data),
-               0x00000060,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_1_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0x0186,                 /* sizeof(fw_image_1_data), */
+               0x00000060,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_1_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x2518,         // sizeof(fw_image_2_data),
-               0x00000C16,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_2_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0x2518,                 /* sizeof(fw_image_2_data), */
+               0x00000C16,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_2_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0x3daa,         // sizeof(fw_image_3_data),
-               0x001E312E,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_3_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0x3daa,                 /* sizeof(fw_image_3_data), */
+               0x001E312E,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_3_data
        },
        {
                8,
                CFG_PROG,
-               CFG_PROG_VOLATILE,                      // mode
-               0xaa66,         // sizeof(fw_image_4_data),
-               0x001F4000,                                     // Target address in NIC Memory
-               0x0000,                                         // CRC: yes/no  TYPE: primary/station/tertiary
-               (hcf_8 FAR   *) fw_image_4_data
+               CFG_PROG_VOLATILE,      /* mode */
+               0xaa66,                 /* sizeof(fw_image_4_data), */
+               0x001F4000,             /* Target address in NIC Memory */
+               0x0000,                 /* CRC: yes/no  TYPE: primary/station/tertiary */
+               (hcf_8 *)fw_image_4_data
        },
        {
                5,
                CFG_PROG,
-               CFG_PROG_STOP,                          // mode
+               CFG_PROG_STOP,          /* mode */
                0000,
-       0x000F368E,                                     // Start execution address
+       0x000F368E,     /* Start execution address */
        },
        { 0000, 0000, 0000, 0000, 00000000, 0000, 00000000}
 };
@@ -4444,7 +4444,7 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_SUPL,
                COMP_ID_STA,
                {
-                       { 2, 2, 5 }                             //variant, bottom, top
+                       { 2, 2, 5 }     /* variant, bottom, top */
                }
        },
        {       3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)),
@@ -4452,9 +4452,9 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_ACT,
                COMP_ID_MFI,
                {
-                       { 4, 6, 7 },                            //variant, bottom, top
-                       { 5, 6, 7 },                            //variant, bottom, top
-                       { 6, 6, 7 }                             //variant, bottom, top
+                       { 4, 6, 7 },    /* variant, bottom, top */
+                       { 5, 6, 7 },    /* variant, bottom, top */
+                       { 6, 6, 7 }     /* variant, bottom, top */
                }
        },
        {       3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)),
@@ -4462,18 +4462,18 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = {
                COMP_ROLE_ACT,
                COMP_ID_CFI,
                {
-                       { 2, 1, 2 }                             //variant, bottom, top
+                       { 2, 1, 2 }     /* variant, bottom, top */
                }
        },
-       { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } }    //endsentinel
+       { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } }    /* endsentinel */
 };
 
 memimage fw_image = {
-       "FUPU7D37dhfwci\001C",                  //signature, <format number>, C/Bin type
+       "FUPU7D37dhfwci\001C",                  /* signature, <format number>, C/Bin type */
        (CFG_PROG_STRCT *) fw_image_code,
        0x000F368E,
-       00000000,                                       //(dummy) pdaplug
-       00000000,                                       //(dummy) priplug
+       00000000,                                       /* (dummy) pdaplug */
+       00000000,                                       /* (dummy) priplug */
        (CFG_RANGE20_STRCT *) fw_image_infocompat,
        (CFG_IDENTITY_STRCT *) fw_image_infoidentity,
 };
index 4c6f776cc4dace8dcbd8104f6667e55726a1d2da..51293d9f2be91a7b12fc4e9232e1bfaa56f3f19d 100644 (file)
@@ -105,57 +105,57 @@ extern dbg_info_t *DbgInfo;
  *      OK
  *
  ******************************************************************************/
-int wl_wep_code( char *szCrypt, char *szDest, void *Data, int nLen )
+int wl_wep_code(char *szCrypt, char *szDest, void *Data, int nLen)
 {
-    int     i;
-    int     t;
-    int     k ;
-    char    bits;
-    char    *szData = (char *) Data;
-    /*------------------------------------------------------------------------*/
+       int     i;
+       int     t;
+       int     k ;
+       char    bits;
+       char    *szData = (char *) Data;
+       /*------------------------------------------------------------------------*/
 
 
-    for( i = bits = 0 ; i < MACADDRESS_STR_LEN; i++ ) {
-           bits ^= szCrypt[i];
-           bits += szCrypt[i];
-    }
+       for (i = bits = 0; i < MACADDRESS_STR_LEN; i++) {
+               bits ^= szCrypt[i];
+               bits += szCrypt[i];
+       }
 
-    for( i = t = *szDest = 0; i < nLen; i++, t++ ) {
-           k = szData[i] ^ ( bits + i );
+       for (i = t = *szDest = 0; i < nLen; i++, t++) {
+               k = szData[i] ^ (bits + i);
 
 
-        switch( i % 3 ) {
+       switch (i % 3) {
 
-        case 0 :
+       case 0:
 
-            szDest[t]   = ((k & 0xFC) >> 2) + CH_START ;
-                       szDest[t+1] = ((k & 0x03) << 4) + CH_START ;
-               szDest[t+2] = '\0';
+               szDest[t]   = ((k & 0xFC) >> 2) + CH_START ;
+               szDest[t+1] = ((k & 0x03) << 4) + CH_START ;
+               szDest[t+2] = '\0';
 
-            break;
+               break;
 
 
-        case 1 :
+       case 1:
 
-            szDest[t]  += (( k & 0xF0 ) >> 4 );
-                       szDest[t+1] = (( k & 0x0F ) << 2 ) + CH_START ;
-               szDest[t+2] = '\0';
+               szDest[t]  += ((k & 0xF0) >> 4);
+               szDest[t+1] = ((k & 0x0F) << 2) + CH_START ;
+               szDest[t+2] = '\0';
 
-            break;
+               break;
 
 
-        case 2 :
+       case 2:
 
-            szDest[t]  += (( k & 0xC0 ) >> 6 );
-                       szDest[t+1] = ( k & 0x3F ) + CH_START ;
-               szDest[t+2] = '\0';
-               t++;
+               szDest[t]  += ((k & 0xC0) >> 6);
+               szDest[t+1] = (k & 0x3F) + CH_START ;
+               szDest[t+2] = '\0';
+               t++;
 
-            break;
-        }
-    }
+               break;
+       }
+       }
 
-    return( strlen( szDest )) ;
+       return strlen(szDest);
 
 }
 /*============================================================================*/
@@ -182,50 +182,50 @@ int wl_wep_code( char *szCrypt, char *szDest, void *Data, int nLen )
  *      OK
  *
  ******************************************************************************/
-int wl_wep_decode( char *szCrypt, void *Dest, char *szData )
+int wl_wep_decode(char *szCrypt, void *Dest, char *szData)
 {
-    int     i;
-    int     t;
-    int     nLen;
-    char    bits;
-    char    *szDest = Dest;
-  /*------------------------------------------------------------------------*/
+       int     i;
+       int     t;
+       int     nLen;
+       char    bits;
+       char    *szDest = Dest;
+       /*------------------------------------------------------------------------*/
 
 
-  for( i = bits = 0 ; i < 12; i++ ) {
-      bits ^= szCrypt[i] ;
-      bits += szCrypt[i] ;
-  }
+       for (i = bits = 0; i < 12; i++) {
+               bits ^= szCrypt[i] ;
+               bits += szCrypt[i] ;
+       }
 
-  nLen = ( strlen( szData ) * 3) / 4 ;
+       nLen = (strlen(szData) * 3) / 4 ;
 
-  for( i = t = 0; i < nLen; i++, t++ ) {
-      switch( i % 3 ) {
-      case 0 :
+       for (i = t = 0; i < nLen; i++, t++) {
+               switch (i % 3) {
+               case 0:
 
-          szDest[i] = ((( szData[t]-CH_START ) & 0x3f ) << 2 ) +
-                      ((( szData[t+1]-CH_START ) & 0x30 ) >> 4 );
-             break;
+                       szDest[i] = (((szData[t] - CH_START) & 0x3f) << 2) +
+                                   (((szData[t+1] - CH_START) & 0x30) >> 4);
+                       break;
 
 
-      case 1 :
-          szDest[i] = ((( szData[t]-CH_START ) & 0x0f ) << 4 ) +
-                      ((( szData[t+1]-CH_START ) & 0x3c ) >> 2 );
-             break;
+               case 1:
+                       szDest[i] = (((szData[t] - CH_START) & 0x0f) << 4) +
+                                   (((szData[t+1] - CH_START) & 0x3c) >> 2);
+                       break;
 
 
-      case 2 :
-          szDest[i] = ((( szData[t]-CH_START ) & 0x03 ) << 6 ) +
-                       (( szData[t+1]-CH_START ) & 0x3f );
-             t++;
-             break;
-      }
+               case 2:
+                       szDest[i] = (((szData[t] - CH_START) & 0x03) << 6) +
+                                    ((szData[t+1] - CH_START) & 0x3f);
+                       t++;
+                       break;
+               }
 
-       szDest[i] ^= ( bits + i ) ;
+               szDest[i] ^= (bits + i);
 
-  }
+       }
 
-  return( i ) ;
+       return i;
 
 }
 /*============================================================================*/
index 61f040f26d975066aad39eb3fad49c656153d82c..95bfbebf35d6e3bda8e6aff9e527a2b075ef2f40 100644 (file)
 /*******************************************************************************
  *  function prototypes
  ******************************************************************************/
-int wl_init( struct net_device *dev );
+int wl_init(struct net_device *dev);
 
-int wl_config( struct net_device *dev, struct ifmap *map );
+int wl_config(struct net_device *dev, struct ifmap *map);
 
-struct net_device *wl_device_alloc( void );
+struct net_device *wl_device_alloc(void);
 
-void wl_device_dealloc( struct net_device *dev );
+void wl_device_dealloc(struct net_device *dev);
 
-int wl_open( struct net_device *dev );
+int wl_open(struct net_device *dev);
 
-int wl_close( struct net_device *dev );
+int wl_close(struct net_device *dev);
 
-int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd );
+int wl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 
-int wl_tx( struct sk_buff *skb, struct net_device *dev, int port );
+int wl_tx(struct sk_buff *skb, struct net_device *dev, int port);
 
-int wl_send( struct wl_private *lp );
+int wl_send(struct wl_private *lp);
 
-int wl_rx( struct net_device *dev );
+int wl_rx(struct net_device *dev);
 
-void wl_tx_timeout( struct net_device *dev );
+void wl_tx_timeout(struct net_device *dev);
 
-struct net_device_stats *wl_stats( struct net_device *dev );
+struct net_device_stats *wl_stats(struct net_device *dev);
 
 
 #ifdef ENABLE_DMA
-int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port );
-int wl_rx_dma( struct net_device *dev );
+int wl_send_dma(struct wl_private *lp, struct sk_buff *skb, int port);
+int wl_rx_dma(struct net_device *dev);
 #endif
 
 #ifdef NEW_MULTICAST
-void wl_multicast( struct net_device *dev );
+void wl_multicast(struct net_device *dev);
 #else
-void wl_multicast( struct net_device *dev, int num_addrs, void *addrs );
-#endif // NEW_MULTICAST
+void wl_multicast(struct net_device *dev, int num_addrs, void *addrs);
+#endif /* NEW_MULTICAST */
 
 
-int wl_tx_port0( struct sk_buff *skb, struct net_device *dev );
+int wl_tx_port0(struct sk_buff *skb, struct net_device *dev);
 
 
 #ifdef USE_WDS
 
-int wl_tx_port1( struct sk_buff *skb, struct net_device *dev );
-int wl_tx_port2( struct sk_buff *skb, struct net_device *dev );
-int wl_tx_port3( struct sk_buff *skb, struct net_device *dev );
-int wl_tx_port4( struct sk_buff *skb, struct net_device *dev );
-int wl_tx_port5( struct sk_buff *skb, struct net_device *dev );
-int wl_tx_port6( struct sk_buff *skb, struct net_device *dev );
-
-void wl_wds_device_alloc( struct wl_private *lp );
-void wl_wds_device_dealloc( struct wl_private *lp );
-void wl_wds_netif_start_queue( struct wl_private *lp );
-void wl_wds_netif_stop_queue( struct wl_private *lp );
-void wl_wds_netif_wake_queue( struct wl_private *lp );
-void wl_wds_netif_carrier_on( struct wl_private *lp );
-void wl_wds_netif_carrier_off( struct wl_private *lp );
+int wl_tx_port1(struct sk_buff *skb, struct net_device *dev);
+int wl_tx_port2(struct sk_buff *skb, struct net_device *dev);
+int wl_tx_port3(struct sk_buff *skb, struct net_device *dev);
+int wl_tx_port4(struct sk_buff *skb, struct net_device *dev);
+int wl_tx_port5(struct sk_buff *skb, struct net_device *dev);
+int wl_tx_port6(struct sk_buff *skb, struct net_device *dev);
+
+void wl_wds_device_alloc(struct wl_private *lp);
+void wl_wds_device_dealloc(struct wl_private *lp);
+void wl_wds_netif_start_queue(struct wl_private *lp);
+void wl_wds_netif_stop_queue(struct wl_private *lp);
+void wl_wds_netif_wake_queue(struct wl_private *lp);
+void wl_wds_netif_carrier_on(struct wl_private *lp);
+void wl_wds_netif_carrier_off(struct wl_private *lp);
 
 #endif  /* USE_WDS */
 
 
 #ifdef USE_WDS
 
-#define WL_WDS_DEVICE_ALLOC( ARG )      wl_wds_device_alloc( ARG )
-#define WL_WDS_DEVICE_DEALLOC( ARG )    wl_wds_device_dealloc( ARG )
-#define WL_WDS_NETIF_START_QUEUE( ARG ) wl_wds_netif_start_queue( ARG )
-#define WL_WDS_NETIF_STOP_QUEUE( ARG )  wl_wds_netif_stop_queue( ARG )
-#define WL_WDS_NETIF_WAKE_QUEUE( ARG )  wl_wds_netif_wake_queue( ARG )
-#define WL_WDS_NETIF_CARRIER_ON( ARG )  wl_wds_netif_carrier_on( ARG )
-#define WL_WDS_NETIF_CARRIER_OFF( ARG ) wl_wds_netif_carrier_off( ARG )
+#define WL_WDS_DEVICE_ALLOC(ARG)      wl_wds_device_alloc(ARG)
+#define WL_WDS_DEVICE_DEALLOC(ARG)    wl_wds_device_dealloc(ARG)
+#define WL_WDS_NETIF_START_QUEUE(ARG) wl_wds_netif_start_queue(ARG)
+#define WL_WDS_NETIF_STOP_QUEUE(ARG)  wl_wds_netif_stop_queue(ARG)
+#define WL_WDS_NETIF_WAKE_QUEUE(ARG)  wl_wds_netif_wake_queue(ARG)
+#define WL_WDS_NETIF_CARRIER_ON(ARG)  wl_wds_netif_carrier_on(ARG)
+#define WL_WDS_NETIF_CARRIER_OFF(ARG) wl_wds_netif_carrier_off(ARG)
 
 #else
 
-#define WL_WDS_DEVICE_ALLOC( ARG )
-#define WL_WDS_DEVICE_DEALLOC( ARG )
-#define WL_WDS_NETIF_START_QUEUE( ARG )
-#define WL_WDS_NETIF_STOP_QUEUE( ARG )
-#define WL_WDS_NETIF_WAKE_QUEUE( ARG )
-#define WL_WDS_NETIF_CARRIER_ON( ARG )
-#define WL_WDS_NETIF_CARRIER_OFF( ARG )
+#define WL_WDS_DEVICE_ALLOC(ARG)
+#define WL_WDS_DEVICE_DEALLOC(ARG)
+#define WL_WDS_NETIF_START_QUEUE(ARG)
+#define WL_WDS_NETIF_STOP_QUEUE(ARG)
+#define WL_WDS_NETIF_WAKE_QUEUE(ARG)
+#define WL_WDS_NETIF_CARRIER_ON(ARG)
+#define WL_WDS_NETIF_CARRIER_OFF(ARG)
 
 #endif  /* USE_WDS */
 
 
-#endif  // __WL_NETDEV_H__
+#endif  /* __WL_NETDEV_H__ */
index 87e1e412312674567ad2a2c0e4cdfa7a46bdbb6a..c97e0e154d285d8b638dc5adb7a1bd4ac764d586 100644 (file)
@@ -67,7 +67,7 @@
 #include <linux/ioport.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include <debug.h>
 #include <hcf.h>
 #include <wl_util.h>
 #include <wl_netdev.h>
 
-int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp );
-int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp );
+int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp);
+int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp);
 
-int cfg_driver_info( struct uilreq *urq, struct wl_private *lp );
-int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp );
+int cfg_driver_info(struct uilreq *urq, struct wl_private *lp);
+int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp);
 
 
 /*******************************************************************************
@@ -99,7 +99,7 @@ int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp );
  ******************************************************************************/
 #if DBG
 extern dbg_info_t *DbgInfo;
-#endif  // DBG
+#endif  /* DBG */
 
 
 
@@ -127,47 +127,47 @@ extern dbg_info_t *DbgInfo;
  *      errno value otherwise
  *
  ******************************************************************************/
-int wvlan_uil( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil(struct uilreq *urq, struct wl_private *lp)
 {
        int ioctl_ret = 0;
        /*------------------------------------------------------------------------*/
 
-       DBG_FUNC( "wvlan_uil" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil");
+       DBG_ENTER(DbgInfo);
 
-       switch( urq->command ) {
-         case UIL_FUN_CONNECT:
+       switch (urq->command) {
+       case UIL_FUN_CONNECT:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_CONNECT\n");
-               ioctl_ret = wvlan_uil_connect( urq, lp );
+               ioctl_ret = wvlan_uil_connect(urq, lp);
                break;
-         case UIL_FUN_DISCONNECT:
+       case UIL_FUN_DISCONNECT:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_DISCONNECT\n");
-               ioctl_ret = wvlan_uil_disconnect( urq, lp );
+               ioctl_ret = wvlan_uil_disconnect(urq, lp);
                break;
-         case UIL_FUN_ACTION:
-               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_ACTION\n" );
-               ioctl_ret = wvlan_uil_action( urq, lp );
+       case UIL_FUN_ACTION:
+               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_ACTION\n");
+               ioctl_ret = wvlan_uil_action(urq, lp);
                break;
-         case UIL_FUN_SEND_DIAG_MSG:
+       case UIL_FUN_SEND_DIAG_MSG:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_SEND_DIAG_MSG\n");
-               ioctl_ret = wvlan_uil_send_diag_msg( urq, lp );
+               ioctl_ret = wvlan_uil_send_diag_msg(urq, lp);
                break;
-         case UIL_FUN_GET_INFO:
+       case UIL_FUN_GET_INFO:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_GET_INFO\n");
-               ioctl_ret = wvlan_uil_get_info( urq, lp );
+               ioctl_ret = wvlan_uil_get_info(urq, lp);
                break;
-         case UIL_FUN_PUT_INFO:
+       case UIL_FUN_PUT_INFO:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_PUT_INFO\n");
-               ioctl_ret = wvlan_uil_put_info( urq, lp );
+               ioctl_ret = wvlan_uil_put_info(urq, lp);
                break;
        default:
-               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- UNSUPPORTED UIL CODE: 0x%X", urq->command );
+               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- UNSUPPORTED UIL CODE: 0x%X", urq->command);
                ioctl_ret = -EOPNOTSUPP;
                break;
        }
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return ioctl_ret;
-} // wvlan_uil
+} /* wvlan_uil */
 /*============================================================================*/
 
 
@@ -192,28 +192,28 @@ int wvlan_uil( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_connect" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_connect");
+       DBG_ENTER(DbgInfo);
 
 
-       if( !( lp->flags & WVLAN2_UIL_CONNECTED )) {
+       if (!(lp->flags & WVLAN2_UIL_CONNECTED)) {
                lp->flags |= WVLAN2_UIL_CONNECTED;
-               urq->hcfCtx = &( lp->hcfCtx );
+               urq->hcfCtx = &(lp->hcfCtx);
                urq->result = UIL_SUCCESS;
        } else {
-               DBG_WARNING( DbgInfo, "UIL_ERR_IN_USE\n" );
+               DBG_WARNING(DbgInfo, "UIL_ERR_IN_USE\n");
                urq->result = UIL_ERR_IN_USE;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_connect
+} /* wvlan_uil_connect */
 /*============================================================================*/
 
 
@@ -238,17 +238,17 @@ int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_disconnect" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_disconnect");
+       DBG_ENTER(DbgInfo);
 
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
                if (lp->flags & WVLAN2_UIL_CONNECTED) {
                        lp->flags &= ~WVLAN2_UIL_CONNECTED;
                        /*
@@ -262,13 +262,13 @@ int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp )
                urq->hcfCtx = NULL;
                urq->result = UIL_SUCCESS;
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_disconnect
+} /* wvlan_uil_disconnect */
 /*============================================================================*/
 
 
@@ -293,60 +293,60 @@ int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp)
 {
        int     result = 0;
        ltv_t   *ltv;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_action" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_action");
+       DBG_ENTER(DbgInfo);
 
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
                /* Make sure there's an LTV in the request buffer */
                ltv = (ltv_t *)urq->data;
-               if( ltv != NULL ) {
+               if (ltv != NULL) {
                        /* Switch on the Type field of the LTV contained in the request
                           buffer */
-                       switch( ltv->typ ) {
+                       switch (ltv->typ) {
                        case UIL_ACT_BLOCK:
-                               DBG_TRACE( DbgInfo, "UIL_ACT_BLOCK\n" );
-                               result = wvlan_uil_block( urq, lp );
+                               DBG_TRACE(DbgInfo, "UIL_ACT_BLOCK\n");
+                               result = wvlan_uil_block(urq, lp);
                                break;
                        case UIL_ACT_UNBLOCK:
-                               DBG_TRACE( DbgInfo, "UIL_ACT_UNBLOCK\n" );
-                               result = wvlan_uil_unblock( urq, lp );
+                               DBG_TRACE(DbgInfo, "UIL_ACT_UNBLOCK\n");
+                               result = wvlan_uil_unblock(urq, lp);
                                break;
                        case UIL_ACT_SCAN:
-                               DBG_TRACE( DbgInfo, "UIL_ACT_SCAN\n" );
-                               urq->result = hcf_action( &( lp->hcfCtx ), MDD_ACT_SCAN );
+                               DBG_TRACE(DbgInfo, "UIL_ACT_SCAN\n");
+                               urq->result = hcf_action(&(lp->hcfCtx), MDD_ACT_SCAN);
                                break;
                        case UIL_ACT_APPLY:
-                               DBG_TRACE( DbgInfo, "UIL_ACT_APPLY\n" );
-                               urq->result = wl_apply( lp );
+                               DBG_TRACE(DbgInfo, "UIL_ACT_APPLY\n");
+                               urq->result = wl_apply(lp);
                                break;
                        case UIL_ACT_RESET:
-                               DBG_TRACE( DbgInfo, "UIL_ACT_RESET\n" );
-                               urq->result = wl_go( lp );
+                               DBG_TRACE(DbgInfo, "UIL_ACT_RESET\n");
+                               urq->result = wl_go(lp);
                                break;
                        default:
-                               DBG_WARNING( DbgInfo, "Unknown action code: 0x%x\n", ltv->typ );
+                               DBG_WARNING(DbgInfo, "Unknown action code: 0x%x\n", ltv->typ);
                                break;
                        }
                } else {
-                       DBG_ERROR( DbgInfo, "Bad LTV for this action\n" );
+                       DBG_ERROR(DbgInfo, "Bad LTV for this action\n");
                        urq->result = UIL_ERR_LEN;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_action
+} /* wvlan_uil_action */
 /*============================================================================*/
 
 
@@ -373,34 +373,34 @@ int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp )
  *
  ******************************************************************************/
 
-int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_block" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_block");
+       DBG_ENTER(DbgInfo);
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
-               if( capable( CAP_NET_ADMIN )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
+               if (capable(CAP_NET_ADMIN)) {
                        lp->flags |= WVLAN2_UIL_BUSY;
                        netif_stop_queue(lp->dev);
-                       WL_WDS_NETIF_STOP_QUEUE( lp );
+                       WL_WDS_NETIF_STOP_QUEUE(lp);
                        urq->result = UIL_SUCCESS;
                } else {
-                       DBG_ERROR( DbgInfo, "EPERM\n" );
+                       DBG_ERROR(DbgInfo, "EPERM\n");
                        urq->result = UIL_FAILURE;
                        result = -EPERM;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_block
+} /* wvlan_uil_block */
 /*============================================================================*/
 
 
@@ -425,35 +425,35 @@ int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_unblock" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_unblock");
+       DBG_ENTER(DbgInfo);
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
-               if( capable( CAP_NET_ADMIN )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
+               if (capable(CAP_NET_ADMIN)) {
                        if (lp->flags & WVLAN2_UIL_BUSY) {
                                lp->flags &= ~WVLAN2_UIL_BUSY;
                                netif_wake_queue(lp->dev);
-                               WL_WDS_NETIF_WAKE_QUEUE( lp );
+                               WL_WDS_NETIF_WAKE_QUEUE(lp);
                        }
                } else {
-                       DBG_ERROR( DbgInfo, "EPERM\n" );
+                       DBG_ERROR(DbgInfo, "EPERM\n");
                        urq->result = UIL_FAILURE;
                        result = -EPERM;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_unblock
+} /* wvlan_uil_unblock */
 /*============================================================================*/
 
 
@@ -478,47 +478,47 @@ int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp)
 {
        int         result = 0;
        DESC_STRCT  Descp[1];
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_uil_send_diag_msg" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_send_diag_msg");
+       DBG_ENTER(DbgInfo);
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
-               if( capable( CAP_NET_ADMIN )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
+               if (capable(CAP_NET_ADMIN)) {
                        if ((urq->data != NULL) && (urq->len != 0)) {
                                if (lp->hcfCtx.IFB_RscInd != 0) {
                                        u_char *data;
 
-                                       // Verify the user buffer
+                                       /* Verify the user buffer */
                                        result = verify_area(VERIFY_READ, urq->data, urq->len);
                                        if (result != 0) {
-                                               DBG_ERROR( DbgInfo, "verify_area failed, result: %d\n", result );
+                                               DBG_ERROR(DbgInfo, "verify_area failed, result: %d\n", result);
                                                urq->result = UIL_FAILURE;
-                                               DBG_LEAVE( DbgInfo );
+                                               DBG_LEAVE(DbgInfo);
                                                return result;
                                        }
 
                                        data = kmalloc(urq->len, GFP_KERNEL);
                                        if (data != NULL) {
-                                               memset( Descp, 0, sizeof( DESC_STRCT ));
-                                               memcpy( data, urq->data, urq->len );
+                                               memset(Descp, 0, sizeof(DESC_STRCT));
+                                               memcpy(data, urq->data, urq->len);
 
                                                Descp[0].buf_addr       = (wci_bufp)data;
                                                Descp[0].BUF_CNT        = urq->len;
-                                               Descp[0].next_desc_addr = 0;    // terminate list
+                                               Descp[0].next_desc_addr = 0;    /* terminate list */
 
-                                               hcf_send_msg( &(lp->hcfCtx),  &Descp[0], HCF_PORT_0 );
-                                               kfree( data );
+                                               hcf_send_msg(&(lp->hcfCtx),  &Descp[0], HCF_PORT_0);
+                                               kfree(data);
                                        } else {
-                                               DBG_ERROR( DbgInfo, "ENOMEM\n" );
+                                               DBG_ERROR(DbgInfo, "ENOMEM\n");
                                                urq->result = UIL_FAILURE;
                                                result = -ENOMEM;
-                                               DBG_LEAVE( DbgInfo );
+                                               DBG_LEAVE(DbgInfo);
                                                return result;
                                        }
 
@@ -530,18 +530,18 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp )
                                urq->result = UIL_FAILURE;
                        }
                } else {
-                       DBG_ERROR( DbgInfo, "EPERM\n" );
+                       DBG_ERROR(DbgInfo, "EPERM\n");
                        urq->result = UIL_FAILURE;
                        result = -EPERM;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_send_diag_msg
+} /* wvlan_uil_send_diag_msg */
 /*============================================================================*/
 
 
@@ -564,7 +564,7 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
 {
        int                     result = 0;
        ltv_t                   *pLtv;
@@ -575,94 +575,94 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
        hcf_16                  hcfPort  = HCF_PORT_0;
 #endif  /* USE_WDS */
        /*------------------------------------------------------------------------*/
-       DBG_FUNC( "wvlan_uil_put_info" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_put_info");
+       DBG_ENTER(DbgInfo);
 
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
-               if( capable( CAP_NET_ADMIN )) {
-                       if(( urq->data != NULL ) && ( urq->len != 0 )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
+               if (capable(CAP_NET_ADMIN)) {
+                       if ((urq->data != NULL) && (urq->len != 0)) {
                                /* Make sure that we have at least a command and length to send. */
-                               if( urq->len < ( sizeof( hcf_16 ) * 2 )) {
-                                       urq->len = sizeof( lp->ltvRecord );
+                               if (urq->len < (sizeof(hcf_16) * 2)) {
+                                       urq->len = sizeof(lp->ltvRecord);
                                        urq->result = UIL_ERR_LEN;
-                                       DBG_ERROR( DbgInfo, "No Length/Type in LTV!!!\n" );
-                                       DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" );
-                                       DBG_LEAVE( DbgInfo );
+                                       DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n");
+                                       DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
+                                       DBG_LEAVE(DbgInfo);
                                        return result;
                                }
 
                                /* Verify the user buffer */
-                               result = verify_area( VERIFY_READ, urq->data, urq->len );
-                               if( result != 0 ) {
+                               result = verify_area(VERIFY_READ, urq->data, urq->len);
+                               if (result != 0) {
                                        urq->result = UIL_FAILURE;
-                                       DBG_ERROR( DbgInfo, "verify_area(), VERIFY_READ FAILED\n" );
-                                       DBG_LEAVE( DbgInfo );
+                                       DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n");
+                                       DBG_LEAVE(DbgInfo);
                                        return result;
                                }
 
                                /* Get only the command and length information. */
-                               copy_from_user( &( lp->ltvRecord ), urq->data, sizeof( hcf_16 ) * 2 );
+                               copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2);
 
                                /* Make sure the incoming LTV record length is within the bounds of the
                                   IOCTL length */
-                               if((( lp->ltvRecord.len + 1 ) * sizeof( hcf_16 )) > urq->len ) {
-                                       urq->len = sizeof( lp->ltvRecord );
+                               if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) {
+                                       urq->len = sizeof(lp->ltvRecord);
                                        urq->result = UIL_ERR_LEN;
-                                       DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" );
-                                       DBG_LEAVE( DbgInfo );
+                                       DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
+                                       DBG_LEAVE(DbgInfo);
                                        return result;
                                }
 
                                /* If the requested length is greater than the size of our local
                                   LTV record, try to allocate it from the kernel stack.
                                   Otherwise, we just use our local LTV record. */
-                               if( urq->len > sizeof( lp->ltvRecord )) {
+                               if (urq->len > sizeof(lp->ltvRecord)) {
                                        pLtv = kmalloc(urq->len, GFP_KERNEL);
                                        if (pLtv != NULL) {
                                                ltvAllocated = TRUE;
                                        } else {
-                                               DBG_ERROR( DbgInfo, "Alloc FAILED\n" );
-                                               urq->len = sizeof( lp->ltvRecord );
+                                               DBG_ERROR(DbgInfo, "Alloc FAILED\n");
+                                               urq->len = sizeof(lp->ltvRecord);
                                                urq->result = UIL_ERR_LEN;
                                                result = -ENOMEM;
-                                               DBG_LEAVE( DbgInfo );
+                                               DBG_LEAVE(DbgInfo);
                                                return result;
                                        }
                                } else {
-                                       pLtv = &( lp->ltvRecord );
+                                       pLtv = &(lp->ltvRecord);
                                }
 
                                /* Copy the data from the user's buffer into the local LTV
                                   record data area. */
-                               copy_from_user( pLtv, urq->data, urq->len );
+                               copy_from_user(pLtv, urq->data, urq->len);
 
 
                                /* We need to snoop the commands to see if there is anything we
                                   need to store for the purposes of a reset or start/stop
                                   sequence. Perform endian translation as needed */
-                               switch( pLtv->typ ) {
+                               switch (pLtv->typ) {
                                case CFG_CNF_PORT_TYPE:
                                        lp->PortType    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_OWN_MAC_ADDR:
                                        /* TODO: determine if we are going to store anything based on this */
                                        break;
                                case CFG_CNF_OWN_CHANNEL:
                                        lp->Channel     = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                /* CFG_CNF_OWN_SSID currently same as CNF_DESIRED_SSID. Do we
                                   need separate storage for this? */
-                               //case CFG_CNF_OWN_SSID:
+                               /* case CFG_CNF_OWN_SSID: */
                                case CFG_CNF_OWN_ATIM_WINDOW:
                                        lp->atimWindow  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_SYSTEM_SCALE:
                                        lp->DistanceBetweenAPs  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
 
                                case CFG_CNF_MAX_DATA_LEN:
                                        /* TODO: determine if we are going to store anything based
@@ -670,163 +670,163 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        break;
                                case CFG_CNF_PM_ENABLED:
                                        lp->PMEnabled   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_MCAST_RX:
                                        lp->MulticastReceive    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_MAX_SLEEP_DURATION:
                                        lp->MaxSleepDuration    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_HOLDOVER_DURATION:
                                        lp->holdoverDuration    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_OWN_NAME:
-                                       memset( lp->StationName, 0, sizeof( lp->StationName ));
-                                       memcpy( (void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
-                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       memset(lp->StationName, 0, sizeof(lp->StationName));
+                                       memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
+                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_LOAD_BALANCING:
                                        lp->loadBalancing       = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_MEDIUM_DISTRIBUTION:
                                        lp->mediumDistribution  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #ifdef WARP
                                case CFG_CNF_TX_POW_LVL:
                                        lp->txPowLevel          = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
-                               //case CFG_CNF_SHORT_RETRY_LIMIT:    // Short Retry Limit
-                               //case 0xFC33:    // Long Retry Limit
-                               case CFG_SUPPORTED_RATE_SET_CNTL:        // Supported Rate Set Control
+                               /* case CFG_CNF_SHORT_RETRY_LIMIT: */ /* Short Retry Limit */
+                               /* case 0xFC33: */   /* Long Retry Limit */
+                               case CFG_SUPPORTED_RATE_SET_CNTL:        /* Supported Rate Set Control */
                                        lp->srsc[0]             = pLtv->u.u16[0];
                                        lp->srsc[1]             = pLtv->u.u16[1];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
-                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE( pLtv->u.u16[1] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
+                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
                                        break;
-                               case CFG_BASIC_RATE_SET_CNTL:        // Basic Rate Set Control
+                               case CFG_BASIC_RATE_SET_CNTL:        /* Basic Rate Set Control */
                                        lp->brsc[0]             = pLtv->u.u16[0];
                                        lp->brsc[1]             = pLtv->u.u16[1];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
-                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE( pLtv->u.u16[1] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
+                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
                                        break;
                                case CFG_CNF_CONNECTION_CNTL:
                                        lp->connectionControl   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
-                               //case CFG_PROBE_DATA_RATE:
-#endif  // HERMES25
+                               /* case CFG_PROBE_DATA_RATE: */
+#endif  /* HERMES25 */
 
-#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
-               //;?should we restore this to allow smaller memory footprint
+#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
+               /* ;?should we restore this to allow smaller memory footprint */
 
                                case CFG_CNF_OWN_DTIM_PERIOD:
                                        lp->DTIMPeriod  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #ifdef WARP
-                               case CFG_CNF_OWN_BEACON_INTERVAL:        // Own Beacon Interval
+                               case CFG_CNF_OWN_BEACON_INTERVAL:        /* Own Beacon Interval */
                                        lp->ownBeaconInterval   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
-#endif // WARP
-                               case CFG_COEXISTENSE_BEHAVIOUR:         // Coexistence behavior
+#endif /* WARP */
+                               case CFG_COEXISTENSE_BEHAVIOUR:         /* Coexistence behavior */
                                        lp->coexistence         = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #ifdef USE_WDS
                                case CFG_CNF_WDS_ADDR1:
-                                       memcpy( &lp->wds_port[0].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[0].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_1;
                                        break;
                                case CFG_CNF_WDS_ADDR2:
-                                       memcpy( &lp->wds_port[1].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[1].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_2;
                                        break;
                                case CFG_CNF_WDS_ADDR3:
-                                       memcpy( &lp->wds_port[2].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[2].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_3;
                                        break;
                                case CFG_CNF_WDS_ADDR4:
-                                       memcpy( &lp->wds_port[3].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[3].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_4;
                                        break;
                                case CFG_CNF_WDS_ADDR5:
-                                       memcpy( &lp->wds_port[4].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[4].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_5;
                                        break;
                                case CFG_CNF_WDS_ADDR6:
-                                       memcpy( &lp->wds_port[5].wdsAddress, &pLtv->u.u8[0], ETH_ALEN );
+                                       memcpy(&lp->wds_port[5].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
                                        hcfPort = HCF_PORT_6;
                                        break;
 #endif  /* USE_WDS */
 
                                case CFG_CNF_MCAST_PM_BUF:
                                        lp->multicastPMBuffering    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_REJECT_ANY:
                                        lp->RejectAny   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #endif
 
                                case CFG_CNF_ENCRYPTION:
                                        lp->EnableEncryption    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_CNF_AUTHENTICATION:
                                        lp->authentication  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
-#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
-               //;?should we restore this to allow smaller memory footprint
+#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
+               /* ;?should we restore this to allow smaller memory footprint */
 
-                               //case CFG_CNF_EXCL_UNENCRYPTED:
-                                       //lp->ExcludeUnencrypted  = pLtv->u.u16[0];
-                                       //pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
-                                       //break;
+                               /case CFG_CNF_EXCL_UNENCRYPTED:
+                                       lp->ExcludeUnencrypted  = pLtv->u.u16[0];
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
+                                       break; */
                                case CFG_CNF_MCAST_RATE:
                                        /* TODO: determine if we are going to store anything based on this */
                                        break;
                                case CFG_CNF_INTRA_BSS_RELAY:
                                        lp->intraBSSRelay   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #endif
 
                                case CFG_CNF_MICRO_WAVE:
                                        /* TODO: determine if we are going to store anything based on this */
                                        break;
-                               //case CFG_CNF_LOAD_BALANCING:
+                               /*case CFG_CNF_LOAD_BALANCING:*/
                                        /* TODO: determine if we are going to store anything based on this */
-                                       //break;
-                               //case CFG_CNF_MEDIUM_DISTRIBUTION:
+                                       /* break; */
+                               /* case CFG_CNF_MEDIUM_DISTRIBUTION: */
                                        /* TODO: determine if we are going to store anything based on this */
-                                       //break;
-                               //case CFG_CNF_RX_ALL_GROUP_ADDRESS:
-                                       // TODO: determine if we are going to store anything based on this
-                                       //break;
-                               //case CFG_CNF_COUNTRY_INFO:
+                                       /* break; */
+                               /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
+                                       /*  TODO: determine if we are going to store anything based on this */
+                                       /* break; */
+                               /* case CFG_CNF_COUNTRY_INFO: */
                                        /* TODO: determine if we are going to store anything based on this */
-                                       //break;
+                                       /* break; */
                                case CFG_CNF_OWN_SSID:
-                               //case CNF_DESIRED_SSID:
+                               /* case CNF_DESIRED_SSID: */
                                case CFG_DESIRED_SSID:
-                                       memset( lp->NetworkName, 0, sizeof( lp->NetworkName ));
-                                       memcpy( (void *)lp->NetworkName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0] );
-                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       memset(lp->NetworkName, 0, sizeof(lp->NetworkName));
+                                       memcpy((void *)lp->NetworkName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
+                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
 
                                        /* take care of the special network name "ANY" case */
-                                       if(( strlen( &pLtv->u.u8[2]        ) == 0 ) ||
-                                          ( strcmp( &pLtv->u.u8[2], "ANY" ) == 0 ) ||
-                                          ( strcmp( &pLtv->u.u8[2], "any" ) == 0 )) {
+                                       if ((strlen(&pLtv->u.u8[2]) == 0) ||
+                                          (strcmp(&pLtv->u.u8[2], "ANY") == 0) ||
+                                          (strcmp(&pLtv->u.u8[2], "any") == 0)) {
                                                /* set the SSID_STRCT llen field (u16[0]) to zero, and the
                                                effectually null the string u8[2] */
                                                pLtv->u.u16[0] = 0;
@@ -838,93 +838,93 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        break;
                                case CFG_CREATE_IBSS:
                                        lp->CreateIBSS  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_RTS_THRH:
                                        lp->RTSThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_TX_RATE_CNTL:
                                        lp->TxRateControl[0]    = pLtv->u.u16[0];
                                        lp->TxRateControl[1]    = pLtv->u.u16[1];
-                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
-                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE( pLtv->u.u16[1] );
+                                       pLtv->u.u16[0]          = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
+                                       pLtv->u.u16[1]          = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
                                        break;
                                case CFG_PROMISCUOUS_MODE:
                                        /* TODO: determine if we are going to store anything based on this */
                                        break;
-                               //case CFG_WAKE_ON_LAN:
+                               /* case CFG_WAKE_ON_LAN: */
                                        /* TODO: determine if we are going to store anything based on this */
-                                       //break;
-#if 1 //;? #if (HCF_TYPE) & HCF_TYPE_AP
-               //;?should we restore this to allow smaller memory footprint
+                                       /* break; */
+#if 1 /* ;? #if (HCF_TYPE) & HCF_TYPE_AP */
+               /* ;?should we restore this to allow smaller memory footprint */
                                case CFG_RTS_THRH0:
                                        lp->RTSThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_TX_RATE_CNTL0:
-//;?no idea what this should be, get going so comment it out                                   lp->TxRateControl   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+/*;?no idea what this should be, get going so comment it out                                   lp->TxRateControl   = pLtv->u.u16[0];*/
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
 #ifdef USE_WDS
                                case CFG_RTS_THRH1:
                                        lp->wds_port[0].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_1;
                                        break;
                                case CFG_RTS_THRH2:
                                        lp->wds_port[1].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_2;
                                        break;
                                case CFG_RTS_THRH3:
                                        lp->wds_port[2].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_3;
                                        break;
                                case CFG_RTS_THRH4:
                                        lp->wds_port[3].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_4;
                                        break;
                                case CFG_RTS_THRH5:
                                        lp->wds_port[4].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_5;
                                        break;
                                case CFG_RTS_THRH6:
                                        lp->wds_port[5].rtsThreshold    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]                  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                         = HCF_PORT_6;
                                        break;
                                case CFG_TX_RATE_CNTL1:
                                        lp->wds_port[0].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_1;
                                        break;
                                case CFG_TX_RATE_CNTL2:
                                        lp->wds_port[1].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_2;
                                        break;
                                case CFG_TX_RATE_CNTL3:
                                        lp->wds_port[2].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_3;
                                        break;
                                case CFG_TX_RATE_CNTL4:
                                        lp->wds_port[3].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_4;
                                        break;
                                case CFG_TX_RATE_CNTL5:
                                        lp->wds_port[4].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_5;
                                        break;
                                case CFG_TX_RATE_CNTL6:
                                        lp->wds_port[5].txRateCntl  = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]              = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        hcfPort                     = HCF_PORT_6;
                                        break;
 #endif  /* USE_WDS */
@@ -934,18 +934,18 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        {
                                                CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)pLtv;
 
-                                               pKeys->key[0].len = CNV_INT_TO_LITTLE( pKeys->key[0].len );
-                                               pKeys->key[1].len = CNV_INT_TO_LITTLE( pKeys->key[1].len );
-                                               pKeys->key[2].len = CNV_INT_TO_LITTLE( pKeys->key[2].len );
-                                               pKeys->key[3].len = CNV_INT_TO_LITTLE( pKeys->key[3].len );
+                                               pKeys->key[0].len = CNV_INT_TO_LITTLE(pKeys->key[0].len);
+                                               pKeys->key[1].len = CNV_INT_TO_LITTLE(pKeys->key[1].len);
+                                               pKeys->key[2].len = CNV_INT_TO_LITTLE(pKeys->key[2].len);
+                                               pKeys->key[3].len = CNV_INT_TO_LITTLE(pKeys->key[3].len);
 
-                                               memcpy( (void *)&(lp->DefaultKeys), (void *)pKeys,
-                                                               sizeof( CFG_DEFAULT_KEYS_STRCT ));
+                                               memcpy((void *)&(lp->DefaultKeys), (void *)pKeys,
+                                                               sizeof(CFG_DEFAULT_KEYS_STRCT));
                                        }
                                        break;
                                case CFG_TX_KEY_ID:
                                        lp->TransmitKeyID   = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_SCAN_SSID:
                                        /* TODO: determine if we are going to store anything based on this */
@@ -956,7 +956,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                /* these RIDS are Info RIDs, and should they be allowed for puts??? */
                                case CFG_MAX_LOAD_TIME:
                                case CFG_DL_BUF:
-                               //case CFG_HSI_SUP_RANGE:
+                               /* case CFG_HSI_SUP_RANGE: */
                                case CFG_NIC_SERIAL_NUMBER:
                                case CFG_NIC_IDENTITY:
                                case CFG_NIC_MFI_SUP_RANGE:
@@ -982,35 +982,35 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                case CFG_CF_POLLABLE:
                                case CFG_AUTHENTICATION_ALGORITHMS:
                                case CFG_PRIVACY_OPT_IMPLEMENTED:
-                               //case CFG_CURRENT_REMOTE_RATES:
-                               //case CFG_CURRENT_USED_RATES:
-                               //case CFG_CURRENT_SYSTEM_SCALE:
-                               //case CFG_CURRENT_TX_RATE1:
-                               //case CFG_CURRENT_TX_RATE2:
-                               //case CFG_CURRENT_TX_RATE3:
-                               //case CFG_CURRENT_TX_RATE4:
-                               //case CFG_CURRENT_TX_RATE5:
-                               //case CFG_CURRENT_TX_RATE6:
+                               /* case CFG_CURRENT_REMOTE_RATES: */
+                               /* case CFG_CURRENT_USED_RATES: */
+                               /* case CFG_CURRENT_SYSTEM_SCALE: */
+                               /* case CFG_CURRENT_TX_RATE1: */
+                               /* case CFG_CURRENT_TX_RATE2: */
+                               /* case CFG_CURRENT_TX_RATE3: */
+                               /* case CFG_CURRENT_TX_RATE4: */
+                               /* case CFG_CURRENT_TX_RATE5: */
+                               /* case CFG_CURRENT_TX_RATE6: */
                                case CFG_NIC_MAC_ADDR:
                                case CFG_PCF_INFO:
-                               //case CFG_CURRENT_COUNTRY_INFO:
+                               /* case CFG_CURRENT_COUNTRY_INFO: */
                                case CFG_PHY_TYPE:
                                case CFG_CUR_CHANNEL:
-                               //case CFG_CURRENT_POWER_STATE:
-                               //case CFG_CCAMODE:
+                               /* case CFG_CURRENT_POWER_STATE: */
+                               /* case CFG_CCAMODE: */
                                case CFG_SUPPORTED_DATA_RATES:
                                        break;
                                case CFG_AP_MODE:
-//;?                           lp->DownloadFirmware = ( pLtv->u.u16[0] ) + 1;
-                                       DBG_ERROR( DbgInfo, "set CFG_AP_MODE no longer supported\n" );
+/*;?                           lp->DownloadFirmware = (pLtv->u.u16[0]) + 1; */
+                                       DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported\n");
                                        break;
                                case CFG_ENCRYPT_STRING:
                                        /* TODO: ENDIAN TRANSLATION HERE??? */
-                                       memset( lp->szEncryption, 0, sizeof( lp->szEncryption ));
-                                       memcpy( (void *)lp->szEncryption,  (void *)&pLtv->u.u8[0],
-                                                       ( pLtv->len * sizeof( hcf_16 )) );
-                                       wl_wep_decode( CRYPT_CODE, &sEncryption,
-                                                                   lp->szEncryption );
+                                       memset(lp->szEncryption, 0, sizeof(lp->szEncryption));
+                                       memcpy((void *)lp->szEncryption,  (void *)&pLtv->u.u8[0],
+                                                       (pLtv->len * sizeof(hcf_16)));
+                                       wl_wep_decode(CRYPT_CODE, &sEncryption,
+                                                                   lp->szEncryption);
 
                                        /* the Linux driver likes to use 1-4 for the key IDs, and then
                                        convert to 0-3 when sending to the card.  The Windows code
@@ -1022,34 +1022,34 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                        lp->TransmitKeyID    = sEncryption.wTxKeyID + 1;
                                        lp->EnableEncryption = sEncryption.wEnabled;
 
-                                       memcpy( &lp->DefaultKeys, &sEncryption.EncStr,
-                                                       sizeof( CFG_DEFAULT_KEYS_STRCT ));
+                                       memcpy(&lp->DefaultKeys, &sEncryption.EncStr,
+                                                       sizeof(CFG_DEFAULT_KEYS_STRCT));
                                        break;
                                /*case CFG_COUNTRY_STRING:
-                                       memset( lp->countryString, 0, sizeof( lp->countryString ));
-                                       memcpy( (void *)lp->countryString, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
+                                       memset(lp->countryString, 0, sizeof(lp->countryString));
+                                       memcpy((void *)lp->countryString, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
                                        break;
                                */
 
                                case CFG_DRIVER_ENABLE:
                                        lp->driverEnable    = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]      = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_WOLAS_ENABLE:
                                        lp->wolasEnable = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_SET_WPA_AUTH_KEY_MGMT_SUITE:
                                        lp->AuthKeyMgmtSuite = pLtv->u.u16[0];
-                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0]  = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_DISASSOCIATE_ADDR:
-                                       pLtv->u.u16[ETH_ALEN / 2] = CNV_INT_TO_LITTLE( pLtv->u.u16[ETH_ALEN / 2] );
+                                       pLtv->u.u16[ETH_ALEN / 2] = CNV_INT_TO_LITTLE(pLtv->u.u16[ETH_ALEN / 2]);
                                        break;
                                case CFG_ADD_TKIP_DEFAULT_KEY:
                                case CFG_REMOVE_TKIP_DEFAULT_KEY:
                                        /* Endian convert the Tx Key Information */
-                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE( pLtv->u.u16[0] );
+                                       pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
                                        break;
                                case CFG_ADD_TKIP_MAPPED_KEY:
                                        break;
@@ -1066,7 +1066,7 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
                                   being sent to the card, as they require a call to
                                   UIL_ACT_APPLY to take effect. Dynamic Entities will be sent
                                   immediately */
-                               switch( pLtv->typ ) {
+                               switch (pLtv->typ) {
                                case CFG_CNF_PORT_TYPE:
                                case CFG_CNF_OWN_MAC_ADDR:
                                case CFG_CNF_OWN_CHANNEL:
@@ -1084,14 +1084,14 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
 #ifdef WARP
                                case CFG_CNF_TX_POW_LVL:
                                case CFG_CNF_CONNECTION_CNTL:
-                               //case CFG_PROBE_DATA_RATE:
-#endif // HERMES25
-#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
-               //;?should we restore this to allow smaller memory footprint
+                               /*case CFG_PROBE_DATA_RATE: */
+#endif /* HERMES25 */
+#if 1 /*;? (HCF_TYPE) & HCF_TYPE_AP */
+               /*;?should we restore this to allow smaller memory footprint */
                                case CFG_CNF_OWN_DTIM_PERIOD:
 #ifdef WARP
-                               case CFG_CNF_OWN_BEACON_INTERVAL:                    // Own Beacon Interval
-#endif // WARP
+                               case CFG_CNF_OWN_BEACON_INTERVAL:                    /* Own Beacon Interval */
+#endif /* WARP */
 #ifdef USE_WDS
                                case CFG_CNF_WDS_ADDR1:
                                case CFG_CNF_WDS_ADDR2:
@@ -1106,8 +1106,8 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
 
                                case CFG_CNF_ENCRYPTION:
                                case CFG_CNF_AUTHENTICATION:
-#if 1 //;? (HCF_TYPE) & HCF_TYPE_AP
-               //;?should we restore this to allow smaller memory footprint
+#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
+               /* ;?should we restore this to allow smaller memory footprint */
 
                                case CFG_CNF_EXCL_UNENCRYPTED:
                                case CFG_CNF_MCAST_RATE:
@@ -1115,68 +1115,54 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
 #endif
 
                                case CFG_CNF_MICRO_WAVE:
-                               //case CFG_CNF_LOAD_BALANCING:
-                               //case CFG_CNF_MEDIUM_DISTRIBUTION:
-                               //case CFG_CNF_RX_ALL_GROUP_ADDRESS:
-                               //case CFG_CNF_COUNTRY_INFO:
-                               //case CFG_COUNTRY_STRING:
+                               /* case CFG_CNF_LOAD_BALANCING: */
+                               /* case CFG_CNF_MEDIUM_DISTRIBUTION: */
+                               /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
+                               /* case CFG_CNF_COUNTRY_INFO: */
+                               /* case CFG_COUNTRY_STRING: */
                                case CFG_AP_MODE:
                                case CFG_ENCRYPT_STRING:
-                               //case CFG_DRIVER_ENABLE:
+                               /* case CFG_DRIVER_ENABLE: */
                                case CFG_WOLAS_ENABLE:
                                case CFG_MB_INFO:
                                case CFG_IFB:
                                        break;
                                /* Deal with this dynamic MSF RID, as it's required for WPA */
                                case CFG_DRIVER_ENABLE:
-                                       if( lp->driverEnable ) {
-                                               //hcf_cntl_port( &( lp->hcfCtx ),
-                                               //               HCF_PORT_ENABLE | HCF_PORT_0 );
-                                               // //hcf_cntl( &( lp->hcfCtx ),
-                                               // //         HCF_PORT_ENABLE | HCF_PORT_0 );
-                                               //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_ENABLE );
-                                               // //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_CONNECT );
-
-                                               hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_ENABLE | HCF_PORT_0 );
-                                               hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_CONNECT );
+                                       if (lp->driverEnable) {
+                                               hcf_cntl(&(lp->hcfCtx), HCF_CNTL_ENABLE | HCF_PORT_0);
+                                               hcf_cntl(&(lp->hcfCtx), HCF_CNTL_CONNECT);
                                        } else {
-                                               //hcf_cntl_port( &( lp->hcfCtx ),
-                                               //               HCF_PORT_DISABLE | HCF_PORT_0 );
-                                               // //hcf_cntl( &( lp->hcfCtx ),
-                                               // //         HCF_PORT_DISABLE | HCF_PORT_0 );
-                                               //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISABLE );
-                                               // //hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISCONNECT );
-
-                                               hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISABLE | HCF_PORT_0 );
-                                               hcf_cntl( &( lp->hcfCtx ), HCF_CNTL_DISCONNECT );
+                                               hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISABLE | HCF_PORT_0);
+                                               hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISCONNECT);
                                        }
                                        break;
                                default:
-                                       wl_act_int_off( lp );
+                                       wl_act_int_off(lp);
                                        urq->result = hcf_put_info(&(lp->hcfCtx), (LTVP) pLtv);
-                                       wl_act_int_on( lp );
+                                       wl_act_int_on(lp);
                                        break;
                                }
 
-                               if( ltvAllocated ) {
-                                       kfree( pLtv );
-                               }
+                               if (ltvAllocated)
+                                       kfree(pLtv);
                        } else {
                                urq->result = UIL_FAILURE;
                        }
                } else {
-                       DBG_ERROR( DbgInfo, "EPERM\n" );
+                       DBG_ERROR(DbgInfo, "EPERM\n");
                        urq->result = UIL_FAILURE;
                        result = -EPERM;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_put_info
+} /* wvlan_uil_put_info */
+
 /*============================================================================*/
 
 /*******************************************************************************
@@ -1199,97 +1185,97 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
+int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        int i;
        /*------------------------------------------------------------------------*/
 
-       DBG_FUNC( "wvlan_uil_get_info" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_uil_get_info");
+       DBG_ENTER(DbgInfo);
 
-       if( urq->hcfCtx == &( lp->hcfCtx )) {
-               if(( urq->data != NULL ) && ( urq->len != 0 )) {
+       if (urq->hcfCtx == &(lp->hcfCtx)) {
+               if ((urq->data != NULL) && (urq->len != 0)) {
                        ltv_t      *pLtv;
                        bool_t      ltvAllocated = FALSE;
 
                        /* Make sure that we have at least a command and length */
-                       if( urq->len < ( sizeof( hcf_16 ) * 2 )) {
-                               urq->len = sizeof( lp->ltvRecord );
-                               DBG_ERROR( DbgInfo, "No Length/Type in LTV!!!\n" );
-                               DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" );
+                       if (urq->len < (sizeof(hcf_16) * 2)) {
+                               urq->len = sizeof(lp->ltvRecord);
+                               DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n");
+                               DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
                                urq->result = UIL_ERR_LEN;
-                               DBG_LEAVE( DbgInfo );
+                               DBG_LEAVE(DbgInfo);
                                return result;
                        }
 
                        /* Verify the user's LTV record header. */
-                       result = verify_area( VERIFY_READ, urq->data, sizeof( hcf_16 ) * 2 );
-                       if( result != 0 ) {
-                               DBG_ERROR( DbgInfo, "verify_area(), VERIFY_READ FAILED\n" );
+                       result = verify_area(VERIFY_READ, urq->data, sizeof(hcf_16) * 2);
+                       if (result != 0) {
+                               DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n");
                                urq->result = UIL_FAILURE;
-                               DBG_LEAVE( DbgInfo );
+                               DBG_LEAVE(DbgInfo);
                                return result;
                        }
 
                        /* Get only the command and length information. */
-                       result = copy_from_user( &( lp->ltvRecord ), urq->data, sizeof( hcf_16 ) * 2 );
+                       result = copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2);
 
                        /* Make sure the incoming LTV record length is within the bounds of
                           the IOCTL length. */
-                       if((( lp->ltvRecord.len + 1 ) * sizeof( hcf_16 )) > urq->len ) {
-                               DBG_ERROR( DbgInfo, "Incoming LTV too big\n" );
-                               urq->len = sizeof( lp->ltvRecord );
+                       if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) {
+                               DBG_ERROR(DbgInfo, "Incoming LTV too big\n");
+                               urq->len = sizeof(lp->ltvRecord);
                                urq->result = UIL_ERR_LEN;
-                               DBG_LEAVE( DbgInfo );
+                               DBG_LEAVE(DbgInfo);
                                return result;
                        }
 
                        /* Determine if hcf_get_info() is needed or not */
-                       switch ( lp->ltvRecord.typ ) {
+                       switch (lp->ltvRecord.typ) {
                        case CFG_NIC_IDENTITY:
-                               memcpy( &lp->ltvRecord.u.u8[0], &lp->NICIdentity, sizeof( lp->NICIdentity ));
+                               memcpy(&lp->ltvRecord.u.u8[0], &lp->NICIdentity, sizeof(lp->NICIdentity));
                                break;
                        case CFG_PRI_IDENTITY:
-                               memcpy( &lp->ltvRecord.u.u8[0], &lp->PrimaryIdentity, sizeof( lp->PrimaryIdentity ));
+                               memcpy(&lp->ltvRecord.u.u8[0], &lp->PrimaryIdentity, sizeof(lp->PrimaryIdentity));
                                break;
                        case CFG_AP_MODE:
-                               DBG_ERROR( DbgInfo, "set CFG_AP_MODE no longer supported, so is get useful ????\n" );
+                               DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported, so is get useful ????\n");
                                lp->ltvRecord.u.u16[0] =
-                                       CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_AP;
+                                       CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_AP;
                                break;
-                       //case CFG_DRV_INFO:
+                       /* case CFG_DRV_INFO: */
                        case CFG_ENCRYPT_STRING:
                        case CFG_COUNTRY_STRING:
                        case CFG_DRIVER_ENABLE:
                        case CFG_WOLAS_ENABLE:
-                               // TODO: determine if we're going to support these
+                               /* TODO: determine if we're going to support these */
                                urq->result = UIL_FAILURE;
                                break;
                        case CFG_DRV_INFO:
-                               DBG_TRACE( DbgInfo, "Intercept CFG_DRV_INFO\n" );
-                               result = cfg_driver_info( urq, lp );
+                               DBG_TRACE(DbgInfo, "Intercept CFG_DRV_INFO\n");
+                               result = cfg_driver_info(urq, lp);
                                break;
                        case CFG_DRV_IDENTITY:
-                               DBG_TRACE( DbgInfo, "Intercept CFG_DRV_IDENTITY\n" );
-                               result = cfg_driver_identity( urq, lp );
+                               DBG_TRACE(DbgInfo, "Intercept CFG_DRV_IDENTITY\n");
+                               result = cfg_driver_identity(urq, lp);
                                break;
                        case CFG_IFB:
                                /* IFB can be a security hole */
-                               if( !capable( CAP_NET_ADMIN )) {
+                               if (!capable(CAP_NET_ADMIN)) {
                                        result = -EPERM;
                                        break;
                                }
 
                                /* Else fall through to the default */
 
-                       case CFG_FW_IDENTITY:   // For Hermes-1, this is cached
+                       case CFG_FW_IDENTITY:   /* For Hermes-1, this is cached */
                        default:
 
                                /* Verify the user buffer */
-                               result = verify_area( VERIFY_WRITE, urq->data, urq->len );
-                               if( result != 0 ) {
-                                       DBG_ERROR( DbgInfo, "verify_area(), VERIFY_WRITE FAILED\n" );
+                               result = verify_area(VERIFY_WRITE, urq->data, urq->len);
+                               if (result != 0) {
+                                       DBG_ERROR(DbgInfo, "verify_area(), VERIFY_WRITE FAILED\n");
                                        urq->result = UIL_FAILURE;
                                        break;
                                }
@@ -1297,43 +1283,43 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                                /* If the requested length is greater than the size of our local
                                   LTV record, try to allocate it from the kernel stack.
                                   Otherwise, we just use our local LTV record. */
-                               if( urq->len > sizeof( lp->ltvRecord )) {
+                               if (urq->len > sizeof(lp->ltvRecord)) {
                                        pLtv = kmalloc(urq->len, GFP_KERNEL);
                                        if (pLtv != NULL) {
                                                ltvAllocated = TRUE;
 
                                                /* Copy the command/length information into the new buffer. */
-                                               memcpy( pLtv, &( lp->ltvRecord ), sizeof( hcf_16 ) * 2 );
+                                               memcpy(pLtv, &(lp->ltvRecord), sizeof(hcf_16) * 2);
                                        } else {
-                                               urq->len = sizeof( lp->ltvRecord );
+                                               urq->len = sizeof(lp->ltvRecord);
                                                urq->result = UIL_ERR_LEN;
-                                               DBG_ERROR( DbgInfo, "kmalloc FAILED\n" );
-                                               DBG_ERROR( DbgInfo, "UIL_ERR_LEN\n" );
+                                               DBG_ERROR(DbgInfo, "kmalloc FAILED\n");
+                                               DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
                                                result = -ENOMEM;
                                                break;
                                        }
                                } else {
-                                       pLtv = &( lp->ltvRecord );
+                                       pLtv = &(lp->ltvRecord);
                                }
 
-                               wl_act_int_off( lp );
-                               urq->result = hcf_get_info( &( lp->hcfCtx ), (LTVP) pLtv );
-                               wl_act_int_on( lp );
+                               wl_act_int_off(lp);
+                               urq->result = hcf_get_info(&(lp->hcfCtx), (LTVP) pLtv);
+                               wl_act_int_on(lp);
 
-                               // Copy the LTV into the user's buffer.
-                               //copy_to_user( urq->data, pLtv, urq->len );
+                               /* Copy the LTV into the user's buffer. */
+                               /*copy_to_user(urq->data, pLtv, urq->len); */
 
-                               //if( ltvAllocated )
-                               //{
-                               //    kfree( pLtv );
-                               //}
+                               /*if(ltvAllocated)
+                               {
+                                   kfree(pLtv);
+                               }*/
 
-                               //urq->result = UIL_SUCCESS;
+                               /* urq->result = UIL_SUCCESS; */
                                break;
                        }
 
                        /* Handle endian conversion of special fields */
-                       switch( lp->ltvRecord.typ ) {
+                       switch (lp->ltvRecord.typ) {
                        /* simple int gets just need the first hcf_16 byte flipped */
                        case CFG_CNF_PORT_TYPE:
                        case CFG_CNF_OWN_CHANNEL:
@@ -1357,14 +1343,14 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
 #ifdef WARP
                        case CFG_CNF_TX_POW_LVL:
                        case CFG_CNF_CONNECTION_CNTL:
-                       case CFG_CNF_OWN_BEACON_INTERVAL:                          // Own Beacon Interval
-                       case CFG_COEXISTENSE_BEHAVIOUR:                            // Coexistence Behavior
-                       //case CFG_CNF_RX_ALL_GROUP_ADDRESS:
-#endif // HERMES25
+                       case CFG_CNF_OWN_BEACON_INTERVAL:                          /* Own Beacon Interval */
+                       case CFG_COEXISTENSE_BEHAVIOUR:                            /* Coexistence Behavior */
+                       /*case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
+#endif /* HERMES25 */
                        case CFG_CREATE_IBSS:
                        case CFG_RTS_THRH:
                        case CFG_PROMISCUOUS_MODE:
-                       //case CFG_WAKE_ON_LAN:
+                       /*case CFG_WAKE_ON_LAN: */
                        case CFG_RTS_THRH0:
                        case CFG_RTS_THRH1:
                        case CFG_RTS_THRH2:
@@ -1393,29 +1379,29 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                        case CFG_MAX_RX_LIFETIME:
                        case CFG_CF_POLLABLE:
                        case CFG_PRIVACY_OPT_IMPLEMENTED:
-                       //case CFG_CURRENT_REMOTE_RATES:
-                       //case CFG_CURRENT_USED_RATES:
-                       //case CFG_CURRENT_SYSTEM_SCALE:
-                       //case CFG_CURRENT_TX_RATE1:
-                       //case CFG_CURRENT_TX_RATE2:
-                       //case CFG_CURRENT_TX_RATE3:
-                       //case CFG_CURRENT_TX_RATE4:
-                       //case CFG_CURRENT_TX_RATE5:
-                       //case CFG_CURRENT_TX_RATE6:
+                       /* case CFG_CURRENT_REMOTE_RATES: */
+                       /* case CFG_CURRENT_USED_RATES: */
+                       /* case CFG_CURRENT_SYSTEM_SCALE: */
+                       /* case CFG_CURRENT_TX_RATE1: */
+                       /* case CFG_CURRENT_TX_RATE2: */
+                       /* case CFG_CURRENT_TX_RATE3: */
+                       /* case CFG_CURRENT_TX_RATE4: */
+                       /* case CFG_CURRENT_TX_RATE5: */
+                       /* case CFG_CURRENT_TX_RATE6: */
                        case CFG_PHY_TYPE:
                        case CFG_CUR_CHANNEL:
-                       //case CFG_CURRENT_POWER_STATE:
-                       //case CFG_CCAMODE:
-                       //    lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                       //    break;
+                       /* case CFG_CURRENT_POWER_STATE: */
+                       /* case CFG_CCAMODE: */
+                       /*     lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); */
+                       /*     break; */
                        /* name string gets just need the first hcf_16 byte flipped (length of string) */
                        case CFG_CNF_OWN_SSID:
                        case CFG_CNF_OWN_NAME:
-                       //case CNF_DESIRED_SSID:
+                       /* case CNF_DESIRED_SSID: */
                        case CFG_DESIRED_SSID:
                        case CFG_SCAN_SSID:
                        case CFG_CUR_SSID:
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
                                break;
                        /* non-length counted strings need no byte flipping */
                        case CFG_CNF_OWN_MAC_ADDR:
@@ -1432,14 +1418,14 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                        case CFG_NIC_MAC_ADDR:
                        case CFG_SUPPORTED_DATA_RATES:  /* need to ensure we can treat this as a string */
                                break;
-                       //case CFG_CNF_COUNTRY_INFO:      /* special case, see page 75  of 022486, Rev C. */
-                       //case CFG_CURRENT_COUNTRY_INFO:  /* special case, see page 101 of 022486, Rev C. */
+                       /* case CFG_CNF_COUNTRY_INFO: */     /* special case, see page 75  of 022486, Rev C. */
+                       /* case CFG_CURRENT_COUNTRY_INFO: */ /* special case, see page 101 of 022486, Rev C. */
                        /*
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] );
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
+                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
 
-                               for( i = 4; i < lp->ltvRecord.len; i++ ) {
-                                       lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[i] );
+                               for(i = 4; i < lp->ltvRecord.len; i++) {
+                                       lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]);
                                }
                                break;
                        */
@@ -1448,57 +1434,56 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                                {
                                        CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)&lp->ltvRecord.u.u8[0];
 
-                                       pKeys[0].len = CNV_INT_TO_LITTLE( pKeys[0].len );
-                                       pKeys[1].len = CNV_INT_TO_LITTLE( pKeys[1].len );
-                                       pKeys[2].len = CNV_INT_TO_LITTLE( pKeys[2].len );
-                                       pKeys[3].len = CNV_INT_TO_LITTLE( pKeys[3].len );
+                                       pKeys[0].len = CNV_INT_TO_LITTLE(pKeys[0].len);
+                                       pKeys[1].len = CNV_INT_TO_LITTLE(pKeys[1].len);
+                                       pKeys[2].len = CNV_INT_TO_LITTLE(pKeys[2].len);
+                                       pKeys[3].len = CNV_INT_TO_LITTLE(pKeys[3].len);
                                }
                                break;
                        case CFG_CNF_MCAST_RATE:
                        case CFG_TX_RATE_CNTL:
-                       case CFG_SUPPORTED_RATE_SET_CNTL:    // Supported Rate Set Control
-                       case CFG_BASIC_RATE_SET_CNTL:    // Basic Rate Set Control
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] );
+                       case CFG_SUPPORTED_RATE_SET_CNTL:    /*  Supported Rate Set Control */
+                       case CFG_BASIC_RATE_SET_CNTL:    /*  Basic Rate Set Control */
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
+                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
                                break;
                        case CFG_DL_BUF:
                        case CFG_NIC_IDENTITY:
                        case CFG_COMMS_QUALITY:
                        case CFG_PCF_INFO:
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] );
-                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] );
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
+                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
+                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
                                break;
                        case CFG_FW_IDENTITY:
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] );
-                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] );
-                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] );
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
+                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
+                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
+                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
                                break;
-                       //case CFG_HSI_SUP_RANGE:
+                       /* case CFG_HSI_SUP_RANGE: */
                        case CFG_NIC_MFI_SUP_RANGE:
                        case CFG_NIC_CFI_SUP_RANGE:
                        case CFG_NIC_PROFILE:
                        case CFG_FW_SUP_RANGE:
-                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[0] );
-                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[1] );
-                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[2] );
-                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[3] );
-                               lp->ltvRecord.u.u16[4] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[4] );
+                               lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
+                               lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
+                               lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
+                               lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
+                               lp->ltvRecord.u.u16[4] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[4]);
                                break;
                        case CFG_MFI_ACT_RANGES_STA:
                        case CFG_CFI_ACT_RANGES_STA:
                        case CFG_CUR_SCALE_THRH:
                        case CFG_AUTHENTICATION_ALGORITHMS:
-                               for( i = 0; i < ( lp->ltvRecord.len - 1 ); i++ ) {
-                                       lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE( lp->ltvRecord.u.u16[i] );
-                               }
+                               for (i = 0; i < (lp->ltvRecord.len - 1); i++)
+                                       lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]);
                                break;
                        /* done at init time, and endian handled then */
                        case CFG_PRI_IDENTITY:
                                break;
                        case CFG_MB_INFO:
-                               //wvlanEndianTranslateMailbox( pLtv );
+                               /* wvlanEndianTranslateMailbox(pLtv); */
                                break;
                        /* MSF and HCF RIDS */
                        case CFG_IFB:
@@ -1512,25 +1497,23 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
                                break;
                        }
 
-                       // Copy the LTV into the user's buffer.
-                       copy_to_user( urq->data, &( lp->ltvRecord ), urq->len );
-
-                       if( ltvAllocated ) {
-                               kfree( &( lp->ltvRecord ));
-                       }
+                       /* Copy the LTV into the user's buffer. */
+                       copy_to_user(urq->data, &(lp->ltvRecord), urq->len);
 
+                       if (ltvAllocated)
+                               kfree(&(lp->ltvRecord));
                        urq->result = UIL_SUCCESS;
                } else {
                        urq->result = UIL_FAILURE;
                }
        } else {
-               DBG_ERROR( DbgInfo, "UIL_ERR_WRONG_IFB\n" );
+               DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
                urq->result = UIL_ERR_WRONG_IFB;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // wvlan_uil_get_info
+} /* wvlan_uil_get_info */
 /*============================================================================*/
 
 
@@ -1556,41 +1539,41 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int cfg_driver_info( struct uilreq *urq, struct wl_private *lp )
+int cfg_driver_info(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "cfg_driver_info" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("cfg_driver_info");
+       DBG_ENTER(DbgInfo);
 
 
        /* Make sure that user buffer can handle the driver information buffer */
-       if( urq->len < sizeof( lp->driverInfo )) {
-               urq->len = sizeof( lp->driverInfo );
+       if (urq->len < sizeof(lp->driverInfo)) {
+               urq->len = sizeof(lp->driverInfo);
                urq->result = UIL_ERR_LEN;
-               DBG_LEAVE( DbgInfo );
+               DBG_LEAVE(DbgInfo);
                return result;
        }
 
        /* Verify the user buffer. */
-       result = verify_area( VERIFY_WRITE, urq->data, sizeof( lp->driverInfo ));
-       if( result != 0 ) {
+       result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverInfo));
+       if (result != 0) {
                urq->result = UIL_FAILURE;
-               DBG_LEAVE( DbgInfo );
+               DBG_LEAVE(DbgInfo);
                return result;
        }
 
        lp->driverInfo.card_stat = lp->hcfCtx.IFB_CardStat;
 
-       // Copy the driver information into the user's buffer.
+       /* Copy the driver information into the user's buffer. */
        urq->result = UIL_SUCCESS;
-       copy_to_user( urq->data, &( lp->driverInfo ), sizeof( lp->driverInfo ));
+       copy_to_user(urq->data, &(lp->driverInfo), sizeof(lp->driverInfo));
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // cfg_driver_info
+} /* cfg_driver_info */
 /*============================================================================*/
 
 
@@ -1615,39 +1598,39 @@ int cfg_driver_info( struct uilreq *urq, struct wl_private *lp )
  *      UIL_ERR_xxx value otherwise
  *
  ******************************************************************************/
-int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp )
+int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp)
 {
        int result = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_driver_identity" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_driver_identity");
+       DBG_ENTER(DbgInfo);
 
 
        /* Make sure that user buffer can handle the driver identity structure. */
-       if( urq->len < sizeof( lp->driverIdentity )) {
-               urq->len = sizeof( lp->driverIdentity );
+       if (urq->len < sizeof(lp->driverIdentity)) {
+               urq->len = sizeof(lp->driverIdentity);
                urq->result = UIL_ERR_LEN;
-               DBG_LEAVE( DbgInfo );
+               DBG_LEAVE(DbgInfo);
                return result;
        }
 
        /* Verify the user buffer. */
-       result = verify_area( VERIFY_WRITE, urq->data, sizeof( lp->driverIdentity ));
-       if( result != 0 ) {
+       result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverIdentity));
+       if (result != 0) {
                urq->result = UIL_FAILURE;
-               DBG_LEAVE( DbgInfo );
+               DBG_LEAVE(DbgInfo);
                return result;
        }
 
        /* Copy the driver identity into the user's buffer. */
        urq->result = UIL_SUCCESS;
-       copy_to_user( urq->data, &( lp->driverIdentity ), sizeof( lp->driverIdentity ));
+       copy_to_user(urq->data, &(lp->driverIdentity), sizeof(lp->driverIdentity));
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return result;
-} // cfg_driver_identity
+} /* cfg_driver_identity */
 /*============================================================================*/
 
 
@@ -1684,27 +1667,27 @@ int wvlan_set_netname(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
        int ret = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_set_netname" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_set_netname");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock(lp, &flags);
+       wl_lock(lp, &flags);
 
-        memset( lp->NetworkName, 0, sizeof( lp->NetworkName ));
-        memcpy( lp->NetworkName, extra, wrqu->data.length);
+       memset(lp->NetworkName, 0, sizeof(lp->NetworkName));
+       memcpy(lp->NetworkName, extra, wrqu->data.length);
 
        /* Commit the adapter parameters */
        wl_apply(lp);
-        wl_unlock(lp, &flags);
+       wl_unlock(lp, &flags);
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return ret;
-} // wvlan_set_netname
+} /* wvlan_set_netname */
 /*============================================================================*/
 
 
@@ -1734,41 +1717,41 @@ int wvlan_get_netname(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
-        int         ret = 0;
-        int         status = -1;
-        wvName_t   *pName;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
+       int         ret = 0;
+       int         status = -1;
+       wvName_t   *pName;
        /*------------------------------------------------------------------------*/
 
 
-        DBG_FUNC( "wvlan_get_netname" );
-        DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_get_netname");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock(lp, &flags);
+       wl_lock(lp, &flags);
 
-        /* Get the current network name */
-        lp->ltvRecord.len = 1 + ( sizeof( *pName ) / sizeof( hcf_16 ));
-        lp->ltvRecord.typ = CFG_CUR_SSID;
+       /* Get the current network name */
+       lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16));
+       lp->ltvRecord.typ = CFG_CUR_SSID;
 
-        status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
+       status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
 
-        if( status == HCF_SUCCESS ) {
-                pName = (wvName_t *)&( lp->ltvRecord.u.u32 );
+       if (status == HCF_SUCCESS) {
+               pName = (wvName_t *)&(lp->ltvRecord.u.u32);
 
                memset(extra, '\0', HCF_MAX_NAME_LEN);
                wrqu->data.length = pName->length;
 
-                memcpy(extra, pName->name, pName->length);
-        } else {
-                ret = -EFAULT;
+               memcpy(extra, pName->name, pName->length);
+       } else {
+               ret = -EFAULT;
        }
 
-        wl_unlock(lp, &flags);
+       wl_unlock(lp, &flags);
 
-        DBG_LEAVE( DbgInfo );
-        return ret;
-} // wvlan_get_netname
+       DBG_LEAVE(DbgInfo);
+       return ret;
+} /* wvlan_get_netname */
 /*============================================================================*/
 
 
@@ -1798,28 +1781,28 @@ int wvlan_set_station_nickname(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
-        int         ret = 0;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
+       int         ret = 0;
        /*------------------------------------------------------------------------*/
 
 
-        DBG_FUNC( "wvlan_set_station_nickname" );
-        DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_set_station_nickname");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock(lp, &flags);
+       wl_lock(lp, &flags);
 
-        memset( lp->StationName, 0, sizeof( lp->StationName ));
+       memset(lp->StationName, 0, sizeof(lp->StationName));
 
-        memcpy( lp->StationName, extra, wrqu->data.length);
+       memcpy(lp->StationName, extra, wrqu->data.length);
 
-        /* Commit the adapter parameters */
-        wl_apply( lp );
-        wl_unlock(lp, &flags);
+       /* Commit the adapter parameters */
+       wl_apply(lp);
+       wl_unlock(lp, &flags);
 
-        DBG_LEAVE( DbgInfo );
-        return ret;
-} // wvlan_set_station_nickname
+       DBG_LEAVE(DbgInfo);
+       return ret;
+} /* wvlan_set_station_nickname */
 /*============================================================================*/
 
 
@@ -1849,41 +1832,41 @@ int wvlan_get_station_nickname(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
        int         ret = 0;
        int         status = -1;
        wvName_t   *pName;
        /*------------------------------------------------------------------------*/
 
 
-        DBG_FUNC( "wvlan_get_station_nickname" );
-        DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_get_station_nickname");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock( lp, &flags );
+       wl_lock(lp, &flags);
 
-        /* Get the current station name */
-        lp->ltvRecord.len = 1 + ( sizeof( *pName ) / sizeof( hcf_16 ));
-        lp->ltvRecord.typ = CFG_CNF_OWN_NAME;
+       /* Get the current station name */
+       lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16));
+       lp->ltvRecord.typ = CFG_CNF_OWN_NAME;
 
-        status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
+       status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
 
-        if( status == HCF_SUCCESS ) {
-                pName = (wvName_t *)&( lp->ltvRecord.u.u32 );
+       if (status == HCF_SUCCESS) {
+               pName = (wvName_t *)&(lp->ltvRecord.u.u32);
 
                memset(extra, '\0', HCF_MAX_NAME_LEN);
                wrqu->data.length = pName->length;
                memcpy(extra, pName->name, pName->length);
-        } else {
-                ret = -EFAULT;
-        }
+       } else {
+               ret = -EFAULT;
+       }
 
-        wl_unlock(lp, &flags);
+       wl_unlock(lp, &flags);
 
-//out:
-        DBG_LEAVE( DbgInfo );
+/* out: */
+       DBG_LEAVE(DbgInfo);
        return ret;
-} // wvlan_get_station_nickname
+} /* wvlan_get_station_nickname */
 /*============================================================================*/
 
 
@@ -1913,37 +1896,37 @@ int wvlan_set_porttype(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
-        int     ret = 0;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
+       int     ret = 0;
        hcf_16  portType;
        /*------------------------------------------------------------------------*/
 
 
-        DBG_FUNC( "wvlan_set_porttype" );
-        DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_set_porttype");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock(lp, &flags);
+       wl_lock(lp, &flags);
 
-        /* Validate the new value */
-        portType = *((__u32 *)extra);
+       /* Validate the new value */
+       portType = *((__u32 *)extra);
 
-        if( !(( portType == 1 ) || ( portType == 3 ))) {
-                ret = -EINVAL;
+       if (!((portType == 1) || (portType == 3))) {
+               ret = -EINVAL;
                goto out_unlock;
-        }
+       }
 
-        lp->PortType = portType;
+       lp->PortType = portType;
 
-        /* Commit the adapter parameters */
-        wl_apply( lp );
+       /* Commit the adapter parameters */
+       wl_apply(lp);
 
 out_unlock:
-        wl_unlock(lp, &flags);
+       wl_unlock(lp, &flags);
 
-//out:
-        DBG_LEAVE( DbgInfo );
-        return ret;
+/* out: */
+       DBG_LEAVE(DbgInfo);
+       return ret;
 }
 
 /*============================================================================*/
@@ -1973,43 +1956,43 @@ int wvlan_get_porttype(struct net_device *dev,
                      union iwreq_data *wrqu,
                      char *extra)
 {
-        struct wl_private *lp = wl_priv(dev);
-        unsigned long flags;
-        int     ret = 0;
-        int     status = -1;
-        hcf_16  *pPortType;
-        __u32 *pData = (__u32 *)extra;
+       struct wl_private *lp = wl_priv(dev);
+       unsigned long flags;
+       int     ret = 0;
+       int     status = -1;
+       hcf_16  *pPortType;
+       __u32 *pData = (__u32 *)extra;
        /*------------------------------------------------------------------------*/
 
 
-        DBG_FUNC( "wvlan_get_porttype" );
-        DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_get_porttype");
+       DBG_ENTER(DbgInfo);
 
-        wl_lock( lp, &flags );
+       wl_lock(lp, &flags);
 
-        /* Get the current port type */
-        lp->ltvRecord.len = 1 + ( sizeof( *pPortType ) / sizeof( hcf_16 ));
-        lp->ltvRecord.typ = CFG_CNF_PORT_TYPE;
+       /* Get the current port type */
+       lp->ltvRecord.len = 1 + (sizeof(*pPortType) / sizeof(hcf_16));
+       lp->ltvRecord.typ = CFG_CNF_PORT_TYPE;
 
-        status = hcf_get_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
+       status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
 
-        if( status == HCF_SUCCESS ) {
-                pPortType = (hcf_16 *)&( lp->ltvRecord.u.u32 );
+       if (status == HCF_SUCCESS) {
+               pPortType = (hcf_16 *)&(lp->ltvRecord.u.u32);
 
-                *pData = CNV_LITTLE_TO_INT( *pPortType );
-        } else {
-            ret = -EFAULT;
+               *pData = CNV_LITTLE_TO_INT(*pPortType);
+       } else {
+           ret = -EFAULT;
        }
 
-        wl_unlock(lp, &flags);
+       wl_unlock(lp, &flags);
 
-//out:
-        DBG_LEAVE( DbgInfo );
-        return ret;
-} // wvlan_get_porttype
+/* out: */
+       DBG_LEAVE(DbgInfo);
+       return ret;
+} /* wvlan_get_porttype */
 /*============================================================================*/
 
-#endif  // WIRELESS_EXT
+#endif  /* WIRELESS_EXT */
 
 
 
@@ -2034,49 +2017,49 @@ int wvlan_get_porttype(struct net_device *dev,
  *      errno value otherwise
  *
  ******************************************************************************/
-int wvlan_rts( struct rtsreq *rrq, __u32 io_base )
+int wvlan_rts(struct rtsreq *rrq, __u32 io_base)
 {
        int ioctl_ret = 0;
        /*------------------------------------------------------------------------*/
 
 
-       DBG_FUNC( "wvlan_rts" );
-       DBG_ENTER( DbgInfo );
+       DBG_FUNC("wvlan_rts");
+       DBG_ENTER(DbgInfo);
 
 
-       DBG_PRINT( "io_base: 0x%08x\n", io_base );
+       DBG_PRINT("io_base: 0x%08x\n", io_base);
 
-       switch( rrq->typ ) {
-         case WL_IOCTL_RTS_READ:
+       switch (rrq->typ) {
+       case WL_IOCTL_RTS_READ:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_READ\n");
-               rrq->data[0] = IN_PORT_WORD( io_base + rrq->reg );
-               DBG_TRACE( DbgInfo, "  reg 0x%04x ==> 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT( rrq->data[0] ) );
+               rrq->data[0] = IN_PORT_WORD(io_base + rrq->reg);
+               DBG_TRACE(DbgInfo, "  reg 0x%04x ==> 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0]));
                break;
-         case WL_IOCTL_RTS_WRITE:
+       case WL_IOCTL_RTS_WRITE:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_WRITE\n");
-               OUT_PORT_WORD( io_base + rrq->reg, rrq->data[0] );
-               DBG_TRACE( DbgInfo, "  reg 0x%04x <== 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT( rrq->data[0] ) );
+               OUT_PORT_WORD(io_base + rrq->reg, rrq->data[0]);
+               DBG_TRACE(DbgInfo, "  reg 0x%04x <== 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0]));
                break;
-         case WL_IOCTL_RTS_BATCH_READ:
+       case WL_IOCTL_RTS_BATCH_READ:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_READ\n");
-               IN_PORT_STRING_16( io_base + rrq->reg, rrq->data, rrq->len );
-               DBG_TRACE( DbgInfo, "  reg 0x%04x ==> %d bytes\n", rrq->reg, rrq->len * sizeof (__u16 ) );
+               IN_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len);
+               DBG_TRACE(DbgInfo, "  reg 0x%04x ==> %d bytes\n", rrq->reg, rrq->len * sizeof(__u16));
                break;
-         case WL_IOCTL_RTS_BATCH_WRITE:
+       case WL_IOCTL_RTS_BATCH_WRITE:
                DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_WRITE\n");
-               OUT_PORT_STRING_16( io_base + rrq->reg, rrq->data, rrq->len );
-               DBG_TRACE( DbgInfo, "  reg 0x%04x <== %d bytes\n", rrq->reg, rrq->len * sizeof (__u16) );
+               OUT_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len);
+               DBG_TRACE(DbgInfo, "  reg 0x%04x <== %d bytes\n", rrq->reg, rrq->len * sizeof(__u16));
                break;
        default:
 
-               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- UNSUPPORTED RTS CODE: 0x%X", rrq->typ );
+               DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- UNSUPPORTED RTS CODE: 0x%X", rrq->typ);
                ioctl_ret = -EOPNOTSUPP;
                break;
        }
 
-       DBG_LEAVE( DbgInfo );
+       DBG_LEAVE(DbgInfo);
        return ioctl_ret;
-} // wvlan_rts
+} /* wvlan_rts */
 /*============================================================================*/
 
 #endif  /* USE_RTS */
index b647bfd900986304d682d3c47e76e77b65adc653..f35e79486428d366bee01cbf77782002b6b2fd5d 100644 (file)
 #ifdef WIRELESS_EXT
 
 
-int wvlan_set_netname( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_set_netname(struct net_device *, struct iw_request_info *,
+                     union iwreq_data *, char *extra);
 
-int wvlan_get_netname( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_get_netname(struct net_device *, struct iw_request_info *,
+                     union iwreq_data *, char *extra);
 
-int wvlan_set_station_nickname( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_set_station_nickname(struct net_device *, struct iw_request_info *,
+                              union iwreq_data *, char *extra);
 
-int wvlan_get_station_nickname( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_get_station_nickname(struct net_device *, struct iw_request_info *,
+                              union iwreq_data *, char *extra);
 
-int wvlan_set_porttype( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_set_porttype(struct net_device *, struct iw_request_info *,
+                      union iwreq_data *, char *extra);
 
-int wvlan_get_porttype( struct net_device *,  struct iw_request_info *, union iwreq_data *, char *extra );
+int wvlan_get_porttype(struct net_device *, struct iw_request_info *,
+                      union iwreq_data *, char *extra);
 
 
-#endif  // WIRELESS_EXT
+#endif  /* WIRELESS_EXT */
 
 
 
 
 #ifdef USE_UIL
 
-int wvlan_uil( struct uilreq *urq, struct wl_private *lp );
+int wvlan_uil(struct uilreq *urq, struct wl_private *lp);
 
-// int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp );
-// int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp );
+/* int wvlan_uil_connect( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_disconnect( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_action( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_block( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_unblock( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ); */
+/* int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ); */
 
-//int cfg_driver_info( struct uilreq *urq, struct wl_private *lp );
-//int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp );
+/* int cfg_driver_info( struct uilreq *urq, struct wl_private *lp ); */
+/* int cfg_driver_identity( struct uilreq *urq, struct wl_private *lp ); */
 
-#endif  // USE_UIL
+#endif  /* USE_UIL */
 
 
 #ifdef USE_RTS
 
-int wvlan_rts( struct rtsreq *rrq, __u32 io_base );
-int wvlan_rts_read( __u16 reg, __u16 *val, __u32 io_base );
-int wvlan_rts_write( __u16 reg, __u16 val, __u32 io_base );
-int wvlan_rts_batch_read( struct rtsreq *rrq, __u32 io_base );
-int wvlan_rts_batch_write( struct rtsreq *rrq, __u32 io_base );
+int wvlan_rts(struct rtsreq *rrq, __u32 io_base);
+int wvlan_rts_read(__u16 reg, __u16 *val, __u32 io_base);
+int wvlan_rts_write(__u16 reg, __u16 val, __u32 io_base);
+int wvlan_rts_batch_read(struct rtsreq *rrq, __u32 io_base);
+int wvlan_rts_batch_write(struct rtsreq *rrq, __u32 io_base);
 
-#endif  // USE_RTS
+#endif  /* USE_RTS */
 
 
-#endif  // __WL_PRIV_H__
+#endif  /* __WL_PRIV_H__ */
index f81df51d2216634ee7578b9b3171d65766b78aaa..d615c836f950e374f0908856a789001a55706407 100644 (file)
 /*******************************************************************************
  *  function prototypes
  ******************************************************************************/
-void parse_config( struct net_device *dev );
+void parse_config(struct net_device *dev);
 
-int readline( int filedesc, char *buffer );
+int readline(int filedesc, char *buffer);
 
-void translate_option( char *buffer, struct wl_private *lp );
+void translate_option(char *buffer, struct wl_private *lp);
 
-int parse_mac_address( char *value, u_char *byte_array );
+int parse_mac_address(char *value, u_char *byte_array);
 
-void ParseConfigLine( char *pszLine, char **ppszLVal, char **ppszRVal );
+void ParseConfigLine(char *pszLine, char **ppszLVal, char **ppszRVal);
 
 
-#endif  // __WL_PROFILE_H__
+#endif  /* __WL_PROFILE_H__ */
index 946b1b64c46fd641017b96397caf8120be00e11d..57bfd7fac6fa13326acbb191e0a0e5076c084dca 100644 (file)
 /*******************************************************************************
  *  function prototypes
  ******************************************************************************/
-int dbm( int value );
+int dbm(int value);
 
-int is_valid_key_string( char *s );
+int is_valid_key_string(char *s);
 
-void key_string2key( char *ks, KEY_STRCT *key );
+void key_string2key(char *ks, KEY_STRCT *key);
 
-void wl_hcf_error( struct net_device *dev, int hcfStatus );
+void wl_hcf_error(struct net_device *dev, int hcfStatus);
 
-void wl_endian_translate_event( ltv_t *pLtv );
+void wl_endian_translate_event(ltv_t *pLtv);
 
-int wl_has_wep( IFBP ifbp );
+int wl_has_wep(IFBP ifbp);
 
-hcf_8   wl_parse_ds_ie( PROBE_RESP *probe_rsp );
-hcf_8 * wl_parse_wpa_ie( PROBE_RESP *probe_rsp, hcf_16 *length );
-hcf_8 * wl_print_wpa_ie( hcf_8 *buffer, int length );
+hcf_8  wl_parse_ds_ie(PROBE_RESP *probe_rsp);
+hcf_8 *wl_parse_wpa_ie(PROBE_RESP *probe_rsp, hcf_16 *length);
+hcf_8 *wl_print_wpa_ie(hcf_8 *buffer, int length);
 
 int wl_get_tallies(struct wl_private *, CFG_HERMES_TALLIES_STRCT *);
-int wl_is_a_valid_chan( int channel );
-int wl_is_a_valid_freq( long frequency );
-long wl_get_freq_from_chan( int channel );
-int wl_get_chan_from_freq( long frequency );
+int wl_is_a_valid_chan(int channel);
+int wl_is_a_valid_freq(long frequency);
+long wl_get_freq_from_chan(int channel);
+int wl_get_chan_from_freq(long frequency);
 
-void wl_process_link_status( struct wl_private *lp );
-void wl_process_probe_response( struct wl_private *lp );
-void wl_process_updated_record( struct wl_private *lp );
-void wl_process_assoc_status( struct wl_private *lp );
-void wl_process_security_status( struct wl_private *lp );
+void wl_process_link_status(struct wl_private *lp);
+void wl_process_probe_response(struct wl_private *lp);
+void wl_process_updated_record(struct wl_private *lp);
+void wl_process_assoc_status(struct wl_private *lp);
+void wl_process_security_status(struct wl_private *lp);
 
-#endif  // __WL_UTIL_H__
+#endif  /* __WL_UTIL_H__ */
index f553366cccc55cea825dc2389d31f8bee7510e6c..c731ff2a6aa16301400199baed40bc3cc226a2b4 100644 (file)
@@ -796,8 +796,6 @@ static int wireless_get_bssid(struct net_device *dev, struct iw_request_info *in
 
        wl_act_int_off( lp );
 
-       memset( &ap_addr->sa_data, 0, ETH_ALEN );
-
        ap_addr->sa_family = ARPHRD_ETHER;
 
        /* Assume AP mode here, which means the BSSID is our own MAC address. In
index 89bfd858bb280949f499c463a6ec26034bddcdad..d22db43e803199f122696f7ae7ec3c16ee2d6171 100644 (file)
@@ -415,11 +415,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
                        break;
 
 #define REQBASICRATE(N) \
-       if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \
-               req->basicrate ## N .data = item->supprates[(N)-1]; \
-               req->basicrate ## N .status = \
-                       P80211ENUM_msgitem_status_data_ok; \
-       }
+       do { \
+               if ((count >= N) && DOT11_RATE5_ISBASIC_GET( \
+                       item->supprates[(N)-1])) { \
+                       req->basicrate ## N .data = item->supprates[(N)-1]; \
+                       req->basicrate ## N .status = \
+                               P80211ENUM_msgitem_status_data_ok; \
+               } \
+       } while (0)
 
        REQBASICRATE(1);
        REQBASICRATE(2);
@@ -431,11 +434,13 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
        REQBASICRATE(8);
 
 #define REQSUPPRATE(N) \
-       if (count >= N) { \
-               req->supprate ## N .data = item->supprates[(N)-1]; \
-               req->supprate ## N .status = \
-                       P80211ENUM_msgitem_status_data_ok; \
-       }
+       do { \
+               if (count >= N) { \
+                       req->supprate ## N .data = item->supprates[(N)-1]; \
+                       req->supprate ## N .status = \
+                               P80211ENUM_msgitem_status_data_ok; \
+               } \
+       } while (0)
 
        REQSUPPRATE(1);
        REQSUPPRATE(2);
@@ -1139,9 +1144,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
                        /* Enable the port */
                        result = hfa384x_drvr_enable(hw, 0);
                        if (result) {
-                               pr_debug
-                               ("failed to enable port to presniff setting, result=%d\n",
-                                    result);
+                               pr_debug("failed to enable port to presniff setting, result=%d\n",
+                                        result);
                                goto failed;
                        }
                } else {
@@ -1181,18 +1185,16 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp)
                                hfa384x_drvr_stop(hw);
                                result = hfa384x_drvr_start(hw);
                                if (result) {
-                                       pr_debug
-                                           ("failed to restart the card for sniffing, result=%d\n",
-                                            result);
+                                       pr_debug("failed to restart the card for sniffing, result=%d\n",
+                                                result);
                                        goto failed;
                                }
                        } else {
                                /* Disable the port */
                                result = hfa384x_drvr_disable(hw, 0);
                                if (result) {
-                                       pr_debug
-                                           ("failed to enable port for sniffing, result=%d\n",
-                                            result);
+                                       pr_debug("failed to enable port for sniffing, result=%d\n",
+                                                result);
                                        goto failed;
                                }
                        }
index e0f745de7e7a6f721823e9052e42287b5d76c056..68a216fcefb1099aebc8fd875b7db16246117a9f 100644 (file)
@@ -233,7 +233,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
        return 1;
 }
 
-static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
+void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
 {
        XGI_Pr->P3c4 = BaseAddr + 0x14;
        XGI_Pr->P3d4 = BaseAddr + 0x24;
index 2b791c10eb15b2dc622c27d42b5b9ad95e2bcbd2..dd34570347aa76007070fdd9396ef24a40de1eac 100644 (file)
@@ -1286,36 +1286,14 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
 
        pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
 
-       pVBInfo->BaseAddr = xgifb_info->vga_base;
-
        if (pVBInfo->FBAddr == NULL) {
                dev_dbg(&pdev->dev, "pVBInfo->FBAddr == 0\n");
                return 0;
        }
-       if (pVBInfo->BaseAddr == 0) {
-               dev_dbg(&pdev->dev, "pVBInfo->BaseAddr == 0\n");
-               return 0;
-       }
 
-       outb(0x67, (pVBInfo->BaseAddr + 0x12)); /* 3c2 <- 67 ,ynlai */
-
-       pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
-       pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
-       pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
-       pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
-       pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
-       pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
-       pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
-       pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
-       pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
-       pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
-       pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
-       pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
-       pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04;
-       pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10;
-       pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
-       pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
-       pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
+       XGIRegInit(pVBInfo, xgifb_info->vga_base);
+
+       outb(0x67, pVBInfo->P3c2);
 
        if (HwDeviceExtension->jChipType < XG20)
                /* Run XGI_GetVBType before InitTo330Pointer */
index d548983225481ad96982eeeee2f3553d60de24ef..24573026a7c07e917a396590ef28f8b0dc3d449c 100644 (file)
@@ -1,5 +1,6 @@
 #ifndef _VBINIT_
 #define _VBINIT_
 extern unsigned char XGIInitNew(struct pci_dev *pdev);
+extern void XGIRegInit(struct vb_device_info *, unsigned long);
 #endif
 
index d723a2571995102bcf3c5499af89a382c28b15e5..53b55571fec64e0fb1e3f9b52604ebb6ee1ccedf 100644 (file)
@@ -2,6 +2,7 @@
 #include "XGIfb.h"
 
 #include "vb_def.h"
+#include "vb_init.h"
 #include "vb_util.h"
 #include "vb_table.h"
 #include "vb_setmode.h"
@@ -5947,7 +5948,6 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
        unsigned short ModeIdIndex;
        struct vb_device_info VBINF;
        struct vb_device_info *pVBInfo = &VBINF;
-       pVBInfo->BaseAddr = xgifb_info->vga_base;
        pVBInfo->IF_DEF_LVDS = 0;
 
        if (HwDeviceExtension->jChipType >= XG20) {
@@ -5961,24 +5961,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
                pVBInfo->IF_DEF_CRT2Monitor = 1;
        }
 
-       pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
-       pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
-       pVBInfo->P3c0 = pVBInfo->BaseAddr + 0x10;
-       pVBInfo->P3ce = pVBInfo->BaseAddr + 0x1e;
-       pVBInfo->P3c2 = pVBInfo->BaseAddr + 0x12;
-       pVBInfo->P3cc = pVBInfo->BaseAddr + 0x1C;
-       pVBInfo->P3ca = pVBInfo->BaseAddr + 0x1a;
-       pVBInfo->P3c6 = pVBInfo->BaseAddr + 0x16;
-       pVBInfo->P3c7 = pVBInfo->BaseAddr + 0x17;
-       pVBInfo->P3c8 = pVBInfo->BaseAddr + 0x18;
-       pVBInfo->P3c9 = pVBInfo->BaseAddr + 0x19;
-       pVBInfo->P3da = pVBInfo->BaseAddr + 0x2A;
-       pVBInfo->Part0Port = pVBInfo->BaseAddr + XGI_CRT2_PORT_00;
-       pVBInfo->Part1Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_04;
-       pVBInfo->Part2Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_10;
-       pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
-       pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
-       pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
+       XGIRegInit(pVBInfo, xgifb_info->vga_base);
 
        /* for x86 Linux, XG21 LVDS */
        if (HwDeviceExtension->jChipType == XG21) {
index acf6e7fbbaed476493474b83b5ca4c4e79067953..e570baebd681c3108552a01eb7aed6b4b275627a 100644 (file)
@@ -156,7 +156,6 @@ struct vb_device_info {
        unsigned short   SelectCRT2Rate;
 
        void __iomem *FBAddr;
-       unsigned long BaseAddr;
 
        unsigned char const (*SR15)[8];
        unsigned char const (*CR40)[8];
index 4881839be6258f83743469cb2e63c2e86fd4c9e7..c1dbd0459d01d6b1c415814bbab70818ebab7506 100644 (file)
@@ -1,6 +1,6 @@
 config ZCACHE
        bool "Dynamic compression of swap pages and clean pagecache pages"
-       depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && ZSMALLOC=y
+       depends on CRYPTO=y && SWAP=y && CLEANCACHE && FRONTSWAP
        select CRYPTO_LZO
        default n
        help
@@ -9,3 +9,18 @@ config ZCACHE
          compression and an in-kernel implementation of transcendent
          memory to store clean page cache pages and swap in RAM,
          providing a noticeable reduction in disk I/O.
+
+config RAMSTER
+       bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
+       depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE=y
+       depends on NET
+       # must ensure struct page is 8-byte aligned
+       select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT
+       default n
+       help
+         RAMster allows RAM on other machines in a cluster to be utilized
+         dynamically and symmetrically instead of swapping to a local swap
+         disk, thus improving performance on memory-constrained workloads
+         while minimizing total RAM across the cluster.  RAMster, like
+         zcache2, compresses swap pages into local RAM, but then remotifies
+         the compressed pages to another node in the RAMster cluster.
index 60daa272c204b6191525d1990b4b38937400b94e..471104957dadaaa3e851359510793c6cd49407a0 100644 (file)
@@ -1,3 +1,6 @@
-zcache-y       :=      zcache-main.o tmem.o
+zcache-y       :=              zcache-main.o tmem.o zbud.o
+zcache-$(CONFIG_RAMSTER)       +=      ramster/ramster.o ramster/r2net.o
+zcache-$(CONFIG_RAMSTER)       +=      ramster/nodemanager.o ramster/tcp.o
+zcache-$(CONFIG_RAMSTER)       +=      ramster/heartbeat.o ramster/masklog.o
 
 obj-$(CONFIG_ZCACHE)   +=      zcache.o
index 56c8e606ad1c3b01d0e4c370685a47095fb37e22..a2b7e03b606279b76fc7ea5f1d39ddcafe967433 100644 (file)
@@ -1,32 +1,43 @@
 /*
  * In-kernel transcendent memory (generic implementation)
  *
- * Copyright (c) 2009-2011, Dan Magenheimer, Oracle Corp.
+ * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp.
  *
- * The primary purpose of Transcendent Memory ("tmem") is to map object-oriented
+ * The primary purpose of Transcedent Memory ("tmem") is to map object-oriented
  * "handles" (triples containing a pool id, and object id, and an index), to
  * pages in a page-accessible memory (PAM).  Tmem references the PAM pages via
  * an abstract "pampd" (PAM page-descriptor), which can be operated on by a
  * set of functions (pamops).  Each pampd contains some representation of
- * PAGE_SIZE bytes worth of data. Tmem must support potentially millions of
- * pages and must be able to insert, find, and delete these pages at a
- * potential frequency of thousands per second concurrently across many CPUs,
- * (and, if used with KVM, across many vcpus across many guests).
- * Tmem is tracked with a hierarchy of data structures, organized by
- * the elements in a handle-tuple: pool_id, object_id, and page index.
- * One or more "clients" (e.g. guests) each provide one or more tmem_pools.
- * Each pool, contains a hash table of rb_trees of tmem_objs.  Each
- * tmem_obj contains a radix-tree-like tree of pointers, with intermediate
- * nodes called tmem_objnodes.  Each leaf pointer in this tree points to
- * a pampd, which is accessible only through a small set of callbacks
- * registered by the PAM implementation (see tmem_register_pamops). Tmem
- * does all memory allocation via a set of callbacks registered by the tmem
- * host implementation (e.g. see tmem_register_hostops).
+ * PAGE_SIZE bytes worth of data. For those familiar with key-value stores,
+ * the tmem handle is a three-level hierarchical key, and the value is always
+ * reconstituted (but not necessarily stored) as PAGE_SIZE bytes and is
+ * referenced in the datastore by the pampd.  The hierarchy is required
+ * to ensure that certain invalidation functions can be performed efficiently
+ * (i.e. flush all indexes associated with this object_id, or
+ * flush all objects associated with this pool).
+ *
+ * Tmem must support potentially millions of pages and must be able to insert,
+ * find, and delete these pages at a potential frequency of thousands per
+ * second concurrently across many CPUs, (and, if used with KVM, across many
+ * vcpus across many guests).  Tmem is tracked with a hierarchy of data
+ * structures, organized by the elements in the handle-tuple: pool_id,
+ * object_id, and page index.  One or more "clients" (e.g. guests) each
+ * provide one or more tmem_pools.  Each pool, contains a hash table of
+ * rb_trees of tmem_objs.  Each tmem_obj contains a radix-tree-like tree
+ * of pointers, with intermediate nodes called tmem_objnodes.  Each leaf
+ * pointer in this tree points to a pampd, which is accessible only through
+ * a small set of callbacks registered by the PAM implementation (see
+ * tmem_register_pamops). Tmem only needs to memory allocation for objs
+ * and objnodes and this is done via a set of callbacks that must be
+ * registered by the tmem host implementation (e.g. see tmem_register_hostops).
  */
 
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/atomic.h>
+#ifdef CONFIG_RAMSTER
+#include <linux/delay.h>
+#endif
 
 #include "tmem.h"
 
@@ -51,7 +62,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
 
 /*
  * A tmem host implementation must use this function to register
- * callbacks for a page-accessible memory (PAM) implementation
+ * callbacks for a page-accessible memory (PAM) implementation.
  */
 static struct tmem_pamops tmem_pamops;
 
@@ -66,15 +77,22 @@ void tmem_register_pamops(struct tmem_pamops *m)
  * So an rb_tree is an ideal data structure to manage tmem_objs.  But because
  * of the potentially huge number of tmem_objs, each pool manages a hashtable
  * of rb_trees to reduce search, insert, delete, and rebalancing time.
- * Each hashbucket also has a lock to manage concurrent access.
+ * Each hashbucket also has a lock to manage concurrent access and no
+ * searches, inserts, or deletions can be performed unless the lock is held.
+ * As a result, care must be taken to ensure tmem routines are not called
+ * recursively; the vast majority of the time, a recursive call may work
+ * but a deadlock will occur a small fraction of the time due to the
+ * hashbucket lock.
  *
- * The following routines manage tmem_objs.  When any tmem_obj is accessed,
- * the hashbucket lock must be held.
+ * The following routines manage tmem_objs.  In all of these routines,
+ * the hashbucket lock is already held.
  */
 
-static struct tmem_obj
-*__tmem_obj_find(struct tmem_hashbucket*hb, struct tmem_oid *oidp,
-                struct rb_node **parent, struct rb_node ***link)
+/* Search for object==oid in pool, returns object if found. */
+static struct tmem_obj *__tmem_obj_find(struct tmem_hashbucket *hb,
+                                       struct tmem_oid *oidp,
+                                       struct rb_node **parent,
+                                       struct rb_node ***link)
 {
        struct rb_node *_parent = NULL, **rbnode;
        struct tmem_obj *obj = NULL;
@@ -101,23 +119,20 @@ static struct tmem_obj
                *parent = _parent;
        if (link)
                *link = rbnode;
-
        obj = NULL;
 out:
        return obj;
 }
 
-
-/* searches for object==oid in pool, returns locked object if found */
 static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb,
                                        struct tmem_oid *oidp)
 {
        return __tmem_obj_find(hb, oidp, NULL, NULL);
 }
 
-static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *);
+static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *, bool);
 
-/* free an object that has no more pampds in it */
+/* Free an object that has no more pampds in it. */
 static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb)
 {
        struct tmem_pool *pool;
@@ -128,7 +143,7 @@ static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb)
        pool = obj->pool;
        BUG_ON(pool == NULL);
        if (obj->objnode_tree_root != NULL) /* may be "stump" with no leaves */
-               tmem_pampd_destroy_all_in_obj(obj);
+               tmem_pampd_destroy_all_in_obj(obj, false);
        BUG_ON(obj->objnode_tree_root != NULL);
        BUG_ON((long)obj->objnode_count != 0);
        atomic_dec(&pool->obj_count);
@@ -140,7 +155,7 @@ static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb)
 }
 
 /*
- * initialize, and insert an tmem_object_root (called only if find failed)
+ * Initialize, and insert an tmem_object_root (called only if find failed).
  */
 static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
                                        struct tmem_pool *pool,
@@ -157,7 +172,10 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
        obj->oid = *oidp;
        obj->objnode_count = 0;
        obj->pampd_count = 0;
-       (*tmem_pamops.new_obj)(obj);
+#ifdef CONFIG_RAMSTER
+       if (tmem_pamops.new_obj != NULL)
+               (*tmem_pamops.new_obj)(obj);
+#endif
        SET_SENTINEL(obj, OBJ);
 
        if (__tmem_obj_find(hb, oidp, &parent, &new))
@@ -172,7 +190,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
  * "ephemeral" vs "persistent".  These attributes apply to all tmem_objs
  * and all pampds that belong to a tmem_pool.  A tmem_pool is created
  * or deleted relatively rarely (for example, when a filesystem is
- * mounted or unmounted.
+ * mounted or unmounted).
  */
 
 /* flush all data from a pool and, optionally, free it */
@@ -190,7 +208,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
                while (rbnode != NULL) {
                        obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node);
                        rbnode = rb_next(rbnode);
-                       tmem_pampd_destroy_all_in_obj(obj);
+                       tmem_pampd_destroy_all_in_obj(obj, true);
                        tmem_obj_free(obj, hb);
                        (*tmem_hostops.obj_free)(obj, pool);
                }
@@ -276,7 +294,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
 }
 
 /*
- * lookup index in object and return associated pampd (or NULL if not found)
+ * Lookup index in object and return associated pampd (or NULL if not found).
  */
 static void **__tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index)
 {
@@ -318,8 +336,9 @@ static void *tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index)
        return slot != NULL ? *slot : NULL;
 }
 
+#ifdef CONFIG_RAMSTER
 static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
-                                       void *new_pampd)
+                                       void *new_pampd, bool no_free)
 {
        struct tmem_objnode **slot;
        void *ret = NULL;
@@ -328,11 +347,14 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
        if ((slot != NULL) && (*slot != NULL)) {
                void *old_pampd = *(void **)slot;
                *(void **)slot = new_pampd;
-               (*tmem_pamops.free)(old_pampd, obj->pool, NULL, 0);
+               if (!no_free)
+                       (*tmem_pamops.free)(old_pampd, obj->pool,
+                                               NULL, 0, false);
                ret = new_pampd;
        }
        return ret;
 }
+#endif
 
 static int tmem_pampd_add_to_obj(struct tmem_obj *obj, uint32_t index,
                                        void *pampd)
@@ -470,7 +492,7 @@ out:
        return slot;
 }
 
-/* recursively walk the objnode_tree destroying pampds and objnodes */
+/* Recursively walk the objnode_tree destroying pampds and objnodes. */
 static void tmem_objnode_node_destroy(struct tmem_obj *obj,
                                        struct tmem_objnode *objnode,
                                        unsigned int ht)
@@ -484,7 +506,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
                        if (ht == 1) {
                                obj->pampd_count--;
                                (*tmem_pamops.free)(objnode->slots[i],
-                                               obj->pool, NULL, 0);
+                                               obj->pool, NULL, 0, true);
                                objnode->slots[i] = NULL;
                                continue;
                        }
@@ -495,13 +517,15 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
        }
 }
 
-static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj)
+static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
+                                               bool pool_destroy)
 {
        if (obj->objnode_tree_root == NULL)
                return;
        if (obj->objnode_tree_height == 0) {
                obj->pampd_count--;
-               (*tmem_pamops.free)(obj->objnode_tree_root, obj->pool, NULL, 0);
+               (*tmem_pamops.free)(obj->objnode_tree_root,
+                                       obj->pool, NULL, 0, true);
        } else {
                tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
                                        obj->objnode_tree_height);
@@ -509,7 +533,10 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj)
                obj->objnode_tree_height = 0;
        }
        obj->objnode_tree_root = NULL;
-       (*tmem_pamops.free_obj)(obj->pool, obj);
+#ifdef CONFIG_RAMSTER
+       if (tmem_pamops.free_obj != NULL)
+               (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
+#endif
 }
 
 /*
@@ -522,17 +549,16 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj)
  */
 
 /*
- * "Put" a page, e.g. copy a page from the kernel into newly allocated
- * PAM space (if such space is available).  Tmem_put is complicated by
- * a corner case: What if a page with matching handle already exists in
- * tmem?  To guarantee coherency, one of two actions is necessary: Either
- * the data for the page must be overwritten, or the page must be
- * "flushed" so that the data is not accessible to a subsequent "get".
- * Since these "duplicate puts" are relatively rare, this implementation
- * always flushes for simplicity.
+ * "Put" a page, e.g. associate the passed pampd with the passed handle.
+ * Tmem_put is complicated by a corner case: What if a page with matching
+ * handle already exists in tmem?  To guarantee coherency, one of two
+ * actions is necessary: Either the data for the page must be overwritten,
+ * or the page must be "flushed" so that the data is not accessible to a
+ * subsequent "get".  Since these "duplicate puts" are relatively rare,
+ * this implementation always flushes for simplicity.
  */
 int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
-               char *data, size_t size, bool raw, bool ephemeral)
+               bool raw, void *pampd_to_use)
 {
        struct tmem_obj *obj = NULL, *objfound = NULL, *objnew = NULL;
        void *pampd = NULL, *pampd_del = NULL;
@@ -548,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
                        /* if found, is a dup put, flush the old one */
                        pampd_del = tmem_pampd_delete_from_obj(obj, index);
                        BUG_ON(pampd_del != pampd);
-                       (*tmem_pamops.free)(pampd, pool, oidp, index);
+                       (*tmem_pamops.free)(pampd, pool, oidp, index, true);
                        if (obj->pampd_count == 0) {
                                objnew = obj;
                                objfound = NULL;
@@ -565,21 +591,19 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
        }
        BUG_ON(obj == NULL);
        BUG_ON(((objnew != obj) && (objfound != obj)) || (objnew == objfound));
-       pampd = (*tmem_pamops.create)(data, size, raw, ephemeral,
-                                       obj->pool, &obj->oid, index);
-       if (unlikely(pampd == NULL))
-               goto free;
+       pampd = pampd_to_use;
+       BUG_ON(pampd_to_use == NULL);
        ret = tmem_pampd_add_to_obj(obj, index, pampd);
        if (unlikely(ret == -ENOMEM))
                /* may have partially built objnode tree ("stump") */
                goto delete_and_free;
+       (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
        goto out;
 
 delete_and_free:
        (void)tmem_pampd_delete_from_obj(obj, index);
-free:
        if (pampd)
-               (*tmem_pamops.free)(pampd, pool, NULL, 0);
+               (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
        if (objnew) {
                tmem_obj_free(objnew, hb);
                (*tmem_hostops.obj_free)(objnew, pool);
@@ -589,35 +613,160 @@ out:
        return ret;
 }
 
+#ifdef CONFIG_RAMSTER
+/*
+ * For ramster only:  The following routines provide a two-step sequence
+ * to allow the caller to replace a pampd in the tmem data structures with
+ * another pampd. Here, we lookup the passed handle and, if found, return the
+ * associated pampd and object, leaving the hashbucket locked and returning
+ * a reference to it.  The caller is expected to immediately call the
+ * matching tmem_localify_finish routine which will handles the replacement
+ * and unlocks the hashbucket.
+ */
+void *tmem_localify_get_pampd(struct tmem_pool *pool, struct tmem_oid *oidp,
+                               uint32_t index, struct tmem_obj **ret_obj,
+                               void **saved_hb)
+{
+       struct tmem_hashbucket *hb;
+       struct tmem_obj *obj = NULL;
+       void *pampd = NULL;
+
+       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
+       spin_lock(&hb->lock);
+       obj = tmem_obj_find(hb, oidp);
+       if (likely(obj != NULL))
+               pampd = tmem_pampd_lookup_in_obj(obj, index);
+       *ret_obj = obj;
+       *saved_hb = (void *)hb;
+       /* note, hashbucket remains locked */
+       return pampd;
+}
+
+void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
+                         void *pampd, void *saved_hb, bool delete)
+{
+       struct tmem_hashbucket *hb = (struct tmem_hashbucket *)saved_hb;
+
+       BUG_ON(!spin_is_locked(&hb->lock));
+       if (pampd != NULL) {
+               BUG_ON(obj == NULL);
+               (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
+               (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
+       } else if (delete) {
+               BUG_ON(obj == NULL);
+               (void)tmem_pampd_delete_from_obj(obj, index);
+       }
+       spin_unlock(&hb->lock);
+}
+
+/*
+ * For ramster only.  Helper function to support asynchronous tmem_get.
+ */
+static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
+                               struct tmem_pool *pool, struct tmem_oid *oidp,
+                               uint32_t index, bool free, char *data)
+{
+       void *old_pampd = *ppampd, *new_pampd = NULL;
+       bool intransit = false;
+       int ret = 0;
+
+       if (!is_ephemeral(pool))
+               new_pampd = (*tmem_pamops.repatriate_preload)(
+                               old_pampd, pool, oidp, index, &intransit);
+       if (intransit)
+               ret = -EAGAIN;
+       else if (new_pampd != NULL)
+               *ppampd = new_pampd;
+       /* must release the hb->lock else repatriate can't sleep */
+       spin_unlock(&hb->lock);
+       if (!intransit)
+               ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
+                                               oidp, index, free, data);
+       if (ret == -EAGAIN) {
+               /* rare I think, but should cond_resched()??? */
+               usleep_range(10, 1000);
+       } else if (ret == -ENOTCONN || ret == -EHOSTDOWN) {
+               ret = -1;
+       } else if (ret != 0 && ret != -ENOENT) {
+               ret = -1;
+       }
+       /* note hb->lock has now been unlocked */
+       return ret;
+}
+
 /*
- * "Get" a page, e.g. if one can be found, copy the tmem page with the
- * matching handle from PAM space to the kernel.  By tmem definition,
- * when a "get" is successful on an ephemeral page, the page is "flushed",
- * and when a "get" is successful on a persistent page, the page is retained
- * in tmem.  Note that to preserve
+ * For ramster only.  If a page in tmem matches the handle, replace the
+ * page so that any subsequent "get" gets the new page.  Returns 0 if
+ * there was a page to replace, else returns -1.
+ */
+int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
+                       uint32_t index, void *new_pampd)
+{
+       struct tmem_obj *obj;
+       int ret = -1;
+       struct tmem_hashbucket *hb;
+
+       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
+       spin_lock(&hb->lock);
+       obj = tmem_obj_find(hb, oidp);
+       if (obj == NULL)
+               goto out;
+       new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
+       /* if we bug here, pamops wasn't properly set up for ramster */
+       BUG_ON(tmem_pamops.replace_in_obj == NULL);
+       ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
+out:
+       spin_unlock(&hb->lock);
+       return ret;
+}
+#endif
+
+/*
+ * "Get" a page, e.g. if a pampd can be found matching the passed handle,
+ * use a pamops callback to recreated the page from the pampd with the
+ * matching handle.  By tmem definition, when a "get" is successful on
+ * an ephemeral page, the page is "flushed", and when a "get" is successful
+ * on a persistent page, the page is retained in tmem.  Note that to preserve
  * coherency, "get" can never be skipped if tmem contains the data.
  * That is, if a get is done with a certain handle and fails, any
  * subsequent "get" must also fail (unless of course there is a
  * "put" done with the same handle).
-
  */
 int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
-               char *data, size_t *size, bool raw, int get_and_free)
+               char *data, size_t *sizep, bool raw, int get_and_free)
 {
        struct tmem_obj *obj;
-       void *pampd;
+       void *pampd = NULL;
        bool ephemeral = is_ephemeral(pool);
        int ret = -1;
        struct tmem_hashbucket *hb;
        bool free = (get_and_free == 1) || ((get_and_free == 0) && ephemeral);
        bool lock_held = false;
+       void **ppampd;
 
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       lock_held = true;
-       obj = tmem_obj_find(hb, oidp);
-       if (obj == NULL)
-               goto out;
+       do {
+               hb = &pool->hashbucket[tmem_oid_hash(oidp)];
+               spin_lock(&hb->lock);
+               lock_held = true;
+               obj = tmem_obj_find(hb, oidp);
+               if (obj == NULL)
+                       goto out;
+               ppampd = __tmem_pampd_lookup_in_obj(obj, index);
+               if (ppampd == NULL)
+                       goto out;
+#ifdef CONFIG_RAMSTER
+               if ((tmem_pamops.is_remote != NULL) &&
+                    tmem_pamops.is_remote(*ppampd)) {
+                       ret = tmem_repatriate(ppampd, hb, pool, oidp,
+                                               index, free, data);
+                       /* tmem_repatriate releases hb->lock */
+                       lock_held = false;
+                       *sizep = PAGE_SIZE;
+                       if (ret != -EAGAIN)
+                               goto out;
+               }
+#endif
+       } while (ret == -EAGAIN);
        if (free)
                pampd = tmem_pampd_delete_from_obj(obj, index);
        else
@@ -631,16 +780,12 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
                        obj = NULL;
                }
        }
-       if (tmem_pamops.is_remote(pampd)) {
-               lock_held = false;
-               spin_unlock(&hb->lock);
-       }
        if (free)
                ret = (*tmem_pamops.get_data_and_free)(
-                               data, size, raw, pampd, pool, oidp, index);
+                               data, sizep, raw, pampd, pool, oidp, index);
        else
                ret = (*tmem_pamops.get_data)(
-                               data, size, raw, pampd, pool, oidp, index);
+                               data, sizep, raw, pampd, pool, oidp, index);
        if (ret < 0)
                goto out;
        ret = 0;
@@ -671,7 +816,7 @@ int tmem_flush_page(struct tmem_pool *pool,
        pampd = tmem_pampd_delete_from_obj(obj, index);
        if (pampd == NULL)
                goto out;
-       (*tmem_pamops.free)(pampd, pool, oidp, index);
+       (*tmem_pamops.free)(pampd, pool, oidp, index, true);
        if (obj->pampd_count == 0) {
                tmem_obj_free(obj, hb);
                (*tmem_hostops.obj_free)(obj, pool);
@@ -683,30 +828,6 @@ out:
        return ret;
 }
 
-/*
- * If a page in tmem matches the handle, replace the page so that any
- * subsequent "get" gets the new page.  Returns 0 if
- * there was a page to replace, else returns -1.
- */
-int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
-                       uint32_t index, void *new_pampd)
-{
-       struct tmem_obj *obj;
-       int ret = -1;
-       struct tmem_hashbucket *hb;
-
-       hb = &pool->hashbucket[tmem_oid_hash(oidp)];
-       spin_lock(&hb->lock);
-       obj = tmem_obj_find(hb, oidp);
-       if (obj == NULL)
-               goto out;
-       new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd);
-       ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
-out:
-       spin_unlock(&hb->lock);
-       return ret;
-}
-
 /*
  * "Flush" all pages in tmem matching this oid.
  */
@@ -721,7 +842,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
        obj = tmem_obj_find(hb, oidp);
        if (obj == NULL)
                goto out;
-       tmem_pampd_destroy_all_in_obj(obj);
+       tmem_pampd_destroy_all_in_obj(obj, false);
        tmem_obj_free(obj, hb);
        (*tmem_hostops.obj_free)(obj, pool);
        ret = 0;
index 0d4aa82706b336e2857d018071929a53c68efc3c..adbe5a8f28aa3caa1440cbe0c274c3c3bc73783d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Transcendent memory
  *
- * Copyright (c) 2009-2011, Dan Magenheimer, Oracle Corp.
+ * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp.
  */
 
 #ifndef _TMEM_H_
 #include <linux/atomic.h>
 
 /*
- * These are pre-defined by the Xen<->Linux ABI
+ * These are defined by the Xen<->Linux ABI so should remain consistent
  */
-#define TMEM_PUT_PAGE                  4
-#define TMEM_GET_PAGE                  5
-#define TMEM_FLUSH_PAGE                        6
-#define TMEM_FLUSH_OBJECT              7
 #define TMEM_POOL_PERSIST              1
 #define TMEM_POOL_SHARED               2
 #define TMEM_POOL_PRECOMPRESSED                4
@@ -32,7 +28,7 @@
  * sentinels have proven very useful for debugging but can be removed
  * or disabled before final merge.
  */
-#define SENTINELS
+#undef SENTINELS
 #ifdef SENTINELS
 #define DECL_SENTINEL uint32_t sentinel;
 #define SET_SENTINEL(_x, _y) (_x->sentinel = _y##_SENTINEL)
@@ -130,6 +126,34 @@ static inline unsigned tmem_oid_hash(struct tmem_oid *oidp)
                                TMEM_HASH_BUCKET_BITS);
 }
 
+#ifdef CONFIG_RAMSTER
+struct tmem_xhandle {
+       uint8_t client_id;
+       uint8_t xh_data_cksum;
+       uint16_t xh_data_size;
+       uint16_t pool_id;
+       struct tmem_oid oid;
+       uint32_t index;
+       void *extra;
+};
+
+static inline struct tmem_xhandle tmem_xhandle_fill(uint16_t client_id,
+                                       struct tmem_pool *pool,
+                                       struct tmem_oid *oidp,
+                                       uint32_t index)
+{
+       struct tmem_xhandle xh;
+       xh.client_id = client_id;
+       xh.xh_data_cksum = (uint8_t)-1;
+       xh.xh_data_size = (uint16_t)-1;
+       xh.pool_id = pool->pool_id;
+       xh.oid = *oidp;
+       xh.index = index;
+       return xh;
+}
+#endif
+
+
 /*
  * A tmem_obj contains an identifier (oid), pointers to the parent
  * pool and the rb_tree to which it belongs, counters, and an ordered
@@ -147,7 +171,15 @@ struct tmem_obj {
        unsigned int objnode_tree_height;
        unsigned long objnode_count;
        long pampd_count;
+#ifdef CONFIG_RAMSTER
+       /*
+        * for current design of ramster, all pages belonging to
+        * an object reside on the same remotenode and extra is
+        * used to record the number of the remotenode so a
+        * flush-object operation can specify it
+        */
        void *extra; /* for private use by pampd implementation */
+#endif
        DECL_SENTINEL
 };
 
@@ -165,20 +197,34 @@ struct tmem_objnode {
        unsigned int slots_in_use;
 };
 
+struct tmem_handle {
+       struct tmem_oid oid; /* 24 bytes */
+       uint32_t index;
+       uint16_t pool_id;
+       uint16_t client_id;
+};
+
+
 /* pampd abstract datatype methods provided by the PAM implementation */
 struct tmem_pamops {
-       void *(*create)(char *, size_t, bool, int,
-                       struct tmem_pool *, struct tmem_oid *, uint32_t);
+       void (*create_finish)(void *, bool);
        int (*get_data)(char *, size_t *, bool, void *, struct tmem_pool *,
                                struct tmem_oid *, uint32_t);
        int (*get_data_and_free)(char *, size_t *, bool, void *,
                                struct tmem_pool *, struct tmem_oid *,
                                uint32_t);
-       void (*free)(void *, struct tmem_pool *, struct tmem_oid *, uint32_t);
-       void (*free_obj)(struct tmem_pool *, struct tmem_obj *);
-       bool (*is_remote)(void *);
+       void (*free)(void *, struct tmem_pool *,
+                               struct tmem_oid *, uint32_t, bool);
+#ifdef CONFIG_RAMSTER
        void (*new_obj)(struct tmem_obj *);
+       void (*free_obj)(struct tmem_pool *, struct tmem_obj *, bool);
+       void *(*repatriate_preload)(void *, struct tmem_pool *,
+                                       struct tmem_oid *, uint32_t, bool *);
+       int (*repatriate)(void *, void *, struct tmem_pool *,
+                               struct tmem_oid *, uint32_t, bool, void *);
+       bool (*is_remote)(void *);
        int (*replace_in_obj)(void *, struct tmem_obj *);
+#endif
 };
 extern void tmem_register_pamops(struct tmem_pamops *m);
 
@@ -193,14 +239,21 @@ extern void tmem_register_hostops(struct tmem_hostops *m);
 
 /* core tmem accessor functions */
 extern int tmem_put(struct tmem_pool *, struct tmem_oid *, uint32_t index,
-                       char *, size_t, bool, bool);
+                       bool, void *);
 extern int tmem_get(struct tmem_pool *, struct tmem_oid *, uint32_t index,
                        char *, size_t *, bool, int);
-extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index,
-                       void *);
 extern int tmem_flush_page(struct tmem_pool *, struct tmem_oid *,
                        uint32_t index);
 extern int tmem_flush_object(struct tmem_pool *, struct tmem_oid *);
 extern int tmem_destroy_pool(struct tmem_pool *);
 extern void tmem_new_pool(struct tmem_pool *, uint32_t);
+#ifdef CONFIG_RAMSTER
+extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index,
+                       void *);
+extern void *tmem_localify_get_pampd(struct tmem_pool *, struct tmem_oid *,
+                                  uint32_t index, struct tmem_obj **,
+                                  void **);
+extern void tmem_localify_finish(struct tmem_obj *, uint32_t index,
+                                void *, void *, bool);
+#endif
 #endif /* _TMEM_H */
similarity index 99%
rename from drivers/staging/ramster/zbud.c
rename to drivers/staging/zcache/zbud.c
index a7c436127aa121064a195936979ca01eada57733..6835fab5d116527ec2d92812c1b768a4db5200a7 100644 (file)
@@ -103,8 +103,8 @@ struct zbudpage {
                struct {
                        unsigned long space_for_flags;
                        struct {
-                               unsigned zbud0_size:12;
-                               unsigned zbud1_size:12;
+                               unsigned zbud0_size: PAGE_SHIFT;
+                               unsigned zbud1_size: PAGE_SHIFT;
                                unsigned unevictable:2;
                        };
                        struct list_head budlist;
@@ -112,6 +112,9 @@ struct zbudpage {
                };
        };
 };
+#if (PAGE_SHIFT * 2) + 2 > BITS_PER_LONG
+#error "zbud won't work for this arch, PAGE_SIZE is too large"
+#endif
 
 struct zbudref {
        union {
index 52b43b7b83d7b3c9d7e3acfc853912afc64c2b61..6ab13e123e7b411f4ca906d1143445441638f184 100644 (file)
@@ -1,23 +1,15 @@
 /*
  * zcache.c
  *
- * Copyright (c) 2010,2011, Dan Magenheimer, Oracle Corp.
+ * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp.
  * Copyright (c) 2010,2011, Nitin Gupta
  *
  * Zcache provides an in-kernel "host implementation" for transcendent memory
- * and, thus indirectly, for cleancache and frontswap.  Zcache includes two
- * page-accessible memory [1] interfaces, both utilizing the crypto compression
- * API:
- * 1) "compression buddies" ("zbud") is used for ephemeral pages
- * 2) zsmalloc is used for persistent pages.
- * Xvmalloc (based on the TLSF allocator) has very low fragmentation
- * so maximizes space efficiency, while zbud allows pairs (and potentially,
- * in the future, more than a pair of) compressed pages to be closely linked
- * so that reclaiming can be done via the kernel's physical-page-oriented
- * "shrinker" interface.
- *
- * [1] For a definition of page-accessible memory (aka PAM), see:
- *   http://marc.info/?l=linux-mm&m=127811271605009
+ * ("tmem") and, thus indirectly, for cleancache and frontswap.  Zcache uses
+ * lzo1x compression to improve density and an embedded allocator called
+ * "zbud" which "buddies" two compressed pages semi-optimally in each physical
+ * pageframe.  Zbud is integrally tied into tmem to allow pageframes to
+ * be "reclaimed" efficiently.
  */
 
 #include <linux/module.h>
 #include <linux/atomic.h>
 #include <linux/math64.h>
 #include <linux/crypto.h>
-#include <linux/string.h>
-#include <linux/idr.h>
-#include "tmem.h"
-
-#include "../zsmalloc/zsmalloc.h"
 
-#ifdef CONFIG_CLEANCACHE
 #include <linux/cleancache.h>
-#endif
-#ifdef CONFIG_FRONTSWAP
 #include <linux/frontswap.h>
-#endif
-
-#if 0
-/* this is more aggressive but may cause other problems? */
-#define ZCACHE_GFP_MASK        (GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN)
+#include "tmem.h"
+#include "zcache.h"
+#include "zbud.h"
+#include "ramster.h"
+#ifdef CONFIG_RAMSTER
+static int ramster_enabled;
 #else
-#define ZCACHE_GFP_MASK \
-       (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC)
+#define ramster_enabled 0
 #endif
 
-#define MAX_CLIENTS 16
-#define LOCAL_CLIENT ((uint16_t)-1)
-
-MODULE_LICENSE("GPL");
-
-struct zcache_client {
-       struct idr tmem_pools;
-       struct zs_pool *zspool;
-       bool allocated;
-       atomic_t refcount;
-};
-
-static struct zcache_client zcache_host;
-static struct zcache_client zcache_clients[MAX_CLIENTS];
-
-static inline uint16_t get_client_id_from_client(struct zcache_client *cli)
+#ifndef __PG_WAS_ACTIVE
+static inline bool PageWasActive(struct page *page)
 {
-       BUG_ON(cli == NULL);
-       if (cli == &zcache_host)
-               return LOCAL_CLIENT;
-       return cli - &zcache_clients[0];
+       return true;
 }
 
-static struct zcache_client *get_zcache_client(uint16_t cli_id)
+static inline void SetPageWasActive(struct page *page)
 {
-       if (cli_id == LOCAL_CLIENT)
-               return &zcache_host;
-
-       if ((unsigned int)cli_id < MAX_CLIENTS)
-               return &zcache_clients[cli_id];
-
-       return NULL;
 }
+#endif
 
-static inline bool is_local_client(struct zcache_client *cli)
+#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS
+static bool frontswap_has_exclusive_gets __read_mostly = true;
+#else
+static bool frontswap_has_exclusive_gets __read_mostly;
+static inline void frontswap_tmem_exclusive_gets(bool b)
 {
-       return cli == &zcache_host;
 }
+#endif
+
+static int zcache_enabled __read_mostly;
+static int disable_cleancache __read_mostly;
+static int disable_frontswap __read_mostly;
+static int disable_frontswap_ignore_nonactive __read_mostly;
+static int disable_cleancache_ignore_nonactive __read_mostly;
+static char *namestr __read_mostly = "zcache";
+
+#define ZCACHE_GFP_MASK \
+       (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC)
+
+MODULE_LICENSE("GPL");
 
 /* crypto API for zcache  */
 #define ZCACHE_COMP_NAME_SZ CRYPTO_MAX_ALG_NAME
-static char zcache_comp_name[ZCACHE_COMP_NAME_SZ];
-static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms;
+static char zcache_comp_name[ZCACHE_COMP_NAME_SZ] __read_mostly;
+static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms __read_mostly;
 
 enum comp_op {
        ZCACHE_COMPOP_COMPRESS,
@@ -105,7 +82,7 @@ static inline int zcache_comp_op(enum comp_op op,
                                u8 *dst, unsigned int *dlen)
 {
        struct crypto_comp *tfm;
-       int ret;
+       int ret = -1;
 
        BUG_ON(!zcache_comp_pcpu_tfms);
        tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu());
@@ -124,816 +101,226 @@ static inline int zcache_comp_op(enum comp_op op,
        return ret;
 }
 
-/**********
- * Compression buddies ("zbud") provides for packing two (or, possibly
- * in the future, more) compressed ephemeral pages into a single "raw"
- * (physical) page and tracking them with data structures so that
- * the raw pages can be easily reclaimed.
- *
- * A zbud page ("zbpg") is an aligned page containing a list_head,
- * a lock, and two "zbud headers".  The remainder of the physical
- * page is divided up into aligned 64-byte "chunks" which contain
- * the compressed data for zero, one, or two zbuds.  Each zbpg
- * resides on: (1) an "unused list" if it has no zbuds; (2) a
- * "buddied" list if it is fully populated  with two zbuds; or
- * (3) one of PAGE_SIZE/64 "unbuddied" lists indexed by how many chunks
- * the one unbuddied zbud uses.  The data inside a zbpg cannot be
- * read or written unless the zbpg's lock is held.
- */
-
-#define ZBH_SENTINEL  0x43214321
-#define ZBPG_SENTINEL  0xdeadbeef
-
-#define ZBUD_MAX_BUDS 2
-
-struct zbud_hdr {
-       uint16_t client_id;
-       uint16_t pool_id;
-       struct tmem_oid oid;
-       uint32_t index;
-       uint16_t size; /* compressed size in bytes, zero means unused */
-       DECL_SENTINEL
-};
-
-struct zbud_page {
-       struct list_head bud_list;
-       spinlock_t lock;
-       struct zbud_hdr buddy[ZBUD_MAX_BUDS];
-       DECL_SENTINEL
-       /* followed by NUM_CHUNK aligned CHUNK_SIZE-byte chunks */
-};
-
-#define CHUNK_SHIFT    6
-#define CHUNK_SIZE     (1 << CHUNK_SHIFT)
-#define CHUNK_MASK     (~(CHUNK_SIZE-1))
-#define NCHUNKS                (((PAGE_SIZE - sizeof(struct zbud_page)) & \
-                               CHUNK_MASK) >> CHUNK_SHIFT)
-#define MAX_CHUNK      (NCHUNKS-1)
-
-static struct {
-       struct list_head list;
-       unsigned count;
-} zbud_unbuddied[NCHUNKS];
-/* list N contains pages with N chunks USED and NCHUNKS-N unused */
-/* element 0 is never used but optimizing that isn't worth it */
-static unsigned long zbud_cumul_chunk_counts[NCHUNKS];
-
-struct list_head zbud_buddied_list;
-static unsigned long zcache_zbud_buddied_count;
-
-/* protects the buddied list and all unbuddied lists */
-static DEFINE_SPINLOCK(zbud_budlists_spinlock);
-
-static LIST_HEAD(zbpg_unused_list);
-static unsigned long zcache_zbpg_unused_list_count;
-
-/* protects the unused page list */
-static DEFINE_SPINLOCK(zbpg_unused_list_spinlock);
-
-static atomic_t zcache_zbud_curr_raw_pages;
-static atomic_t zcache_zbud_curr_zpages;
-static unsigned long zcache_zbud_curr_zbytes;
-static unsigned long zcache_zbud_cumul_zpages;
-static unsigned long zcache_zbud_cumul_zbytes;
-static unsigned long zcache_compress_poor;
-static unsigned long zcache_mean_compress_poor;
-
-/* forward references */
-static void *zcache_get_free_page(void);
-static void zcache_free_page(void *p);
-
-/*
- * zbud helper functions
- */
-
-static inline unsigned zbud_max_buddy_size(void)
-{
-       return MAX_CHUNK << CHUNK_SHIFT;
-}
-
-static inline unsigned zbud_size_to_chunks(unsigned size)
-{
-       BUG_ON(size == 0 || size > zbud_max_buddy_size());
-       return (size + CHUNK_SIZE - 1) >> CHUNK_SHIFT;
-}
-
-static inline int zbud_budnum(struct zbud_hdr *zh)
-{
-       unsigned offset = (unsigned long)zh & (PAGE_SIZE - 1);
-       struct zbud_page *zbpg = NULL;
-       unsigned budnum = -1U;
-       int i;
-
-       for (i = 0; i < ZBUD_MAX_BUDS; i++)
-               if (offset == offsetof(typeof(*zbpg), buddy[i])) {
-                       budnum = i;
-                       break;
-               }
-       BUG_ON(budnum == -1U);
-       return budnum;
-}
-
-static char *zbud_data(struct zbud_hdr *zh, unsigned size)
-{
-       struct zbud_page *zbpg;
-       char *p;
-       unsigned budnum;
-
-       ASSERT_SENTINEL(zh, ZBH);
-       budnum = zbud_budnum(zh);
-       BUG_ON(size == 0 || size > zbud_max_buddy_size());
-       zbpg = container_of(zh, struct zbud_page, buddy[budnum]);
-       ASSERT_SPINLOCK(&zbpg->lock);
-       p = (char *)zbpg;
-       if (budnum == 0)
-               p += ((sizeof(struct zbud_page) + CHUNK_SIZE - 1) &
-                                                       CHUNK_MASK);
-       else if (budnum == 1)
-               p += PAGE_SIZE - ((size + CHUNK_SIZE - 1) & CHUNK_MASK);
-       return p;
-}
-
-/*
- * zbud raw page management
- */
-
-static struct zbud_page *zbud_alloc_raw_page(void)
-{
-       struct zbud_page *zbpg = NULL;
-       struct zbud_hdr *zh0, *zh1;
-       bool recycled = 0;
-
-       /* if any pages on the zbpg list, use one */
-       spin_lock(&zbpg_unused_list_spinlock);
-       if (!list_empty(&zbpg_unused_list)) {
-               zbpg = list_first_entry(&zbpg_unused_list,
-                               struct zbud_page, bud_list);
-               list_del_init(&zbpg->bud_list);
-               zcache_zbpg_unused_list_count--;
-               recycled = 1;
-       }
-       spin_unlock(&zbpg_unused_list_spinlock);
-       if (zbpg == NULL)
-               /* none on zbpg list, try to get a kernel page */
-               zbpg = zcache_get_free_page();
-       if (likely(zbpg != NULL)) {
-               INIT_LIST_HEAD(&zbpg->bud_list);
-               zh0 = &zbpg->buddy[0]; zh1 = &zbpg->buddy[1];
-               spin_lock_init(&zbpg->lock);
-               if (recycled) {
-                       ASSERT_INVERTED_SENTINEL(zbpg, ZBPG);
-                       SET_SENTINEL(zbpg, ZBPG);
-                       BUG_ON(zh0->size != 0 || tmem_oid_valid(&zh0->oid));
-                       BUG_ON(zh1->size != 0 || tmem_oid_valid(&zh1->oid));
-               } else {
-                       atomic_inc(&zcache_zbud_curr_raw_pages);
-                       INIT_LIST_HEAD(&zbpg->bud_list);
-                       SET_SENTINEL(zbpg, ZBPG);
-                       zh0->size = 0; zh1->size = 0;
-                       tmem_oid_set_invalid(&zh0->oid);
-                       tmem_oid_set_invalid(&zh1->oid);
-               }
-       }
-       return zbpg;
-}
-
-static void zbud_free_raw_page(struct zbud_page *zbpg)
-{
-       struct zbud_hdr *zh0 = &zbpg->buddy[0], *zh1 = &zbpg->buddy[1];
-
-       ASSERT_SENTINEL(zbpg, ZBPG);
-       BUG_ON(!list_empty(&zbpg->bud_list));
-       ASSERT_SPINLOCK(&zbpg->lock);
-       BUG_ON(zh0->size != 0 || tmem_oid_valid(&zh0->oid));
-       BUG_ON(zh1->size != 0 || tmem_oid_valid(&zh1->oid));
-       INVERT_SENTINEL(zbpg, ZBPG);
-       spin_unlock(&zbpg->lock);
-       spin_lock(&zbpg_unused_list_spinlock);
-       list_add(&zbpg->bud_list, &zbpg_unused_list);
-       zcache_zbpg_unused_list_count++;
-       spin_unlock(&zbpg_unused_list_spinlock);
-}
-
-/*
- * core zbud handling routines
- */
-
-static unsigned zbud_free(struct zbud_hdr *zh)
-{
-       unsigned size;
-
-       ASSERT_SENTINEL(zh, ZBH);
-       BUG_ON(!tmem_oid_valid(&zh->oid));
-       size = zh->size;
-       BUG_ON(zh->size == 0 || zh->size > zbud_max_buddy_size());
-       zh->size = 0;
-       tmem_oid_set_invalid(&zh->oid);
-       INVERT_SENTINEL(zh, ZBH);
-       zcache_zbud_curr_zbytes -= size;
-       atomic_dec(&zcache_zbud_curr_zpages);
-       return size;
-}
-
-static void zbud_free_and_delist(struct zbud_hdr *zh)
-{
-       unsigned chunks;
-       struct zbud_hdr *zh_other;
-       unsigned budnum = zbud_budnum(zh), size;
-       struct zbud_page *zbpg =
-               container_of(zh, struct zbud_page, buddy[budnum]);
-
-       spin_lock(&zbud_budlists_spinlock);
-       spin_lock(&zbpg->lock);
-       if (list_empty(&zbpg->bud_list)) {
-               /* ignore zombie page... see zbud_evict_pages() */
-               spin_unlock(&zbpg->lock);
-               spin_unlock(&zbud_budlists_spinlock);
-               return;
-       }
-       size = zbud_free(zh);
-       ASSERT_SPINLOCK(&zbpg->lock);
-       zh_other = &zbpg->buddy[(budnum == 0) ? 1 : 0];
-       if (zh_other->size == 0) { /* was unbuddied: unlist and free */
-               chunks = zbud_size_to_chunks(size) ;
-               BUG_ON(list_empty(&zbud_unbuddied[chunks].list));
-               list_del_init(&zbpg->bud_list);
-               zbud_unbuddied[chunks].count--;
-               spin_unlock(&zbud_budlists_spinlock);
-               zbud_free_raw_page(zbpg);
-       } else { /* was buddied: move remaining buddy to unbuddied list */
-               chunks = zbud_size_to_chunks(zh_other->size) ;
-               list_del_init(&zbpg->bud_list);
-               zcache_zbud_buddied_count--;
-               list_add_tail(&zbpg->bud_list, &zbud_unbuddied[chunks].list);
-               zbud_unbuddied[chunks].count++;
-               spin_unlock(&zbud_budlists_spinlock);
-               spin_unlock(&zbpg->lock);
-       }
-}
-
-static struct zbud_hdr *zbud_create(uint16_t client_id, uint16_t pool_id,
-                                       struct tmem_oid *oid,
-                                       uint32_t index, struct page *page,
-                                       void *cdata, unsigned size)
-{
-       struct zbud_hdr *zh0, *zh1, *zh = NULL;
-       struct zbud_page *zbpg = NULL, *ztmp;
-       unsigned nchunks;
-       char *to;
-       int i, found_good_buddy = 0;
-
-       nchunks = zbud_size_to_chunks(size) ;
-       for (i = MAX_CHUNK - nchunks + 1; i > 0; i--) {
-               spin_lock(&zbud_budlists_spinlock);
-               if (!list_empty(&zbud_unbuddied[i].list)) {
-                       list_for_each_entry_safe(zbpg, ztmp,
-                                   &zbud_unbuddied[i].list, bud_list) {
-                               if (spin_trylock(&zbpg->lock)) {
-                                       found_good_buddy = i;
-                                       goto found_unbuddied;
-                               }
-                       }
-               }
-               spin_unlock(&zbud_budlists_spinlock);
-       }
-       /* didn't find a good buddy, try allocating a new page */
-       zbpg = zbud_alloc_raw_page();
-       if (unlikely(zbpg == NULL))
-               goto out;
-       /* ok, have a page, now compress the data before taking locks */
-       spin_lock(&zbud_budlists_spinlock);
-       spin_lock(&zbpg->lock);
-       list_add_tail(&zbpg->bud_list, &zbud_unbuddied[nchunks].list);
-       zbud_unbuddied[nchunks].count++;
-       zh = &zbpg->buddy[0];
-       goto init_zh;
-
-found_unbuddied:
-       ASSERT_SPINLOCK(&zbpg->lock);
-       zh0 = &zbpg->buddy[0]; zh1 = &zbpg->buddy[1];
-       BUG_ON(!((zh0->size == 0) ^ (zh1->size == 0)));
-       if (zh0->size != 0) { /* buddy0 in use, buddy1 is vacant */
-               ASSERT_SENTINEL(zh0, ZBH);
-               zh = zh1;
-       } else if (zh1->size != 0) { /* buddy1 in use, buddy0 is vacant */
-               ASSERT_SENTINEL(zh1, ZBH);
-               zh = zh0;
-       } else
-               BUG();
-       list_del_init(&zbpg->bud_list);
-       zbud_unbuddied[found_good_buddy].count--;
-       list_add_tail(&zbpg->bud_list, &zbud_buddied_list);
-       zcache_zbud_buddied_count++;
-
-init_zh:
-       SET_SENTINEL(zh, ZBH);
-       zh->size = size;
-       zh->index = index;
-       zh->oid = *oid;
-       zh->pool_id = pool_id;
-       zh->client_id = client_id;
-       to = zbud_data(zh, size);
-       memcpy(to, cdata, size);
-       spin_unlock(&zbpg->lock);
-       spin_unlock(&zbud_budlists_spinlock);
-
-       zbud_cumul_chunk_counts[nchunks]++;
-       atomic_inc(&zcache_zbud_curr_zpages);
-       zcache_zbud_cumul_zpages++;
-       zcache_zbud_curr_zbytes += size;
-       zcache_zbud_cumul_zbytes += size;
-out:
-       return zh;
-}
-
-static int zbud_decompress(struct page *page, struct zbud_hdr *zh)
-{
-       struct zbud_page *zbpg;
-       unsigned budnum = zbud_budnum(zh);
-       unsigned int out_len = PAGE_SIZE;
-       char *to_va, *from_va;
-       unsigned size;
-       int ret = 0;
-
-       zbpg = container_of(zh, struct zbud_page, buddy[budnum]);
-       spin_lock(&zbpg->lock);
-       if (list_empty(&zbpg->bud_list)) {
-               /* ignore zombie page... see zbud_evict_pages() */
-               ret = -EINVAL;
-               goto out;
-       }
-       ASSERT_SENTINEL(zh, ZBH);
-       BUG_ON(zh->size == 0 || zh->size > zbud_max_buddy_size());
-       to_va = kmap_atomic(page);
-       size = zh->size;
-       from_va = zbud_data(zh, size);
-       ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size,
-                               to_va, &out_len);
-       BUG_ON(ret);
-       BUG_ON(out_len != PAGE_SIZE);
-       kunmap_atomic(to_va);
-out:
-       spin_unlock(&zbpg->lock);
-       return ret;
-}
-
-/*
- * The following routines handle shrinking of ephemeral pages by evicting
- * pages "least valuable" first.
- */
-
-static unsigned long zcache_evicted_raw_pages;
-static unsigned long zcache_evicted_buddied_pages;
-static unsigned long zcache_evicted_unbuddied_pages;
-
-static struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id,
-                                               uint16_t poolid);
-static void zcache_put_pool(struct tmem_pool *pool);
-
-/*
- * Flush and free all zbuds in a zbpg, then free the pageframe
- */
-static void zbud_evict_zbpg(struct zbud_page *zbpg)
-{
-       struct zbud_hdr *zh;
-       int i, j;
-       uint32_t pool_id[ZBUD_MAX_BUDS], client_id[ZBUD_MAX_BUDS];
-       uint32_t index[ZBUD_MAX_BUDS];
-       struct tmem_oid oid[ZBUD_MAX_BUDS];
-       struct tmem_pool *pool;
-
-       ASSERT_SPINLOCK(&zbpg->lock);
-       BUG_ON(!list_empty(&zbpg->bud_list));
-       for (i = 0, j = 0; i < ZBUD_MAX_BUDS; i++) {
-               zh = &zbpg->buddy[i];
-               if (zh->size) {
-                       client_id[j] = zh->client_id;
-                       pool_id[j] = zh->pool_id;
-                       oid[j] = zh->oid;
-                       index[j] = zh->index;
-                       j++;
-                       zbud_free(zh);
-               }
-       }
-       spin_unlock(&zbpg->lock);
-       for (i = 0; i < j; i++) {
-               pool = zcache_get_pool_by_id(client_id[i], pool_id[i]);
-               if (pool != NULL) {
-                       tmem_flush_page(pool, &oid[i], index[i]);
-                       zcache_put_pool(pool);
-               }
-       }
-       ASSERT_SENTINEL(zbpg, ZBPG);
-       spin_lock(&zbpg->lock);
-       zbud_free_raw_page(zbpg);
-}
-
-/*
- * Free nr pages.  This code is funky because we want to hold the locks
- * protecting various lists for as short a time as possible, and in some
- * circumstances the list may change asynchronously when the list lock is
- * not held.  In some cases we also trylock not only to avoid waiting on a
- * page in use by another cpu, but also to avoid potential deadlock due to
- * lock inversion.
- */
-static void zbud_evict_pages(int nr)
-{
-       struct zbud_page *zbpg;
-       int i;
-
-       /* first try freeing any pages on unused list */
-retry_unused_list:
-       spin_lock_bh(&zbpg_unused_list_spinlock);
-       if (!list_empty(&zbpg_unused_list)) {
-               /* can't walk list here, since it may change when unlocked */
-               zbpg = list_first_entry(&zbpg_unused_list,
-                               struct zbud_page, bud_list);
-               list_del_init(&zbpg->bud_list);
-               zcache_zbpg_unused_list_count--;
-               atomic_dec(&zcache_zbud_curr_raw_pages);
-               spin_unlock_bh(&zbpg_unused_list_spinlock);
-               zcache_free_page(zbpg);
-               zcache_evicted_raw_pages++;
-               if (--nr <= 0)
-                       goto out;
-               goto retry_unused_list;
-       }
-       spin_unlock_bh(&zbpg_unused_list_spinlock);
-
-       /* now try freeing unbuddied pages, starting with least space avail */
-       for (i = 0; i < MAX_CHUNK; i++) {
-retry_unbud_list_i:
-               spin_lock_bh(&zbud_budlists_spinlock);
-               if (list_empty(&zbud_unbuddied[i].list)) {
-                       spin_unlock_bh(&zbud_budlists_spinlock);
-                       continue;
-               }
-               list_for_each_entry(zbpg, &zbud_unbuddied[i].list, bud_list) {
-                       if (unlikely(!spin_trylock(&zbpg->lock)))
-                               continue;
-                       list_del_init(&zbpg->bud_list);
-                       zbud_unbuddied[i].count--;
-                       spin_unlock(&zbud_budlists_spinlock);
-                       zcache_evicted_unbuddied_pages++;
-                       /* want budlists unlocked when doing zbpg eviction */
-                       zbud_evict_zbpg(zbpg);
-                       local_bh_enable();
-                       if (--nr <= 0)
-                               goto out;
-                       goto retry_unbud_list_i;
-               }
-               spin_unlock_bh(&zbud_budlists_spinlock);
-       }
-
-       /* as a last resort, free buddied pages */
-retry_bud_list:
-       spin_lock_bh(&zbud_budlists_spinlock);
-       if (list_empty(&zbud_buddied_list)) {
-               spin_unlock_bh(&zbud_budlists_spinlock);
-               goto out;
-       }
-       list_for_each_entry(zbpg, &zbud_buddied_list, bud_list) {
-               if (unlikely(!spin_trylock(&zbpg->lock)))
-                       continue;
-               list_del_init(&zbpg->bud_list);
-               zcache_zbud_buddied_count--;
-               spin_unlock(&zbud_budlists_spinlock);
-               zcache_evicted_buddied_pages++;
-               /* want budlists unlocked when doing zbpg eviction */
-               zbud_evict_zbpg(zbpg);
-               local_bh_enable();
-               if (--nr <= 0)
-                       goto out;
-               goto retry_bud_list;
-       }
-       spin_unlock_bh(&zbud_budlists_spinlock);
-out:
-       return;
-}
-
-static void __init zbud_init(void)
-{
-       int i;
-
-       INIT_LIST_HEAD(&zbud_buddied_list);
-
-       for (i = 0; i < NCHUNKS; i++)
-               INIT_LIST_HEAD(&zbud_unbuddied[i].list);
-}
-
-#ifdef CONFIG_SYSFS
 /*
- * These sysfs routines show a nice distribution of how many zbpg's are
- * currently (and have ever been placed) in each unbuddied list.  It's fun
- * to watch but can probably go away before final merge.
+ * policy parameters
  */
-static int zbud_show_unbuddied_list_counts(char *buf)
-{
-       int i;
-       char *p = buf;
-
-       for (i = 0; i < NCHUNKS; i++)
-               p += sprintf(p, "%u ", zbud_unbuddied[i].count);
-       return p - buf;
-}
-
-static int zbud_show_cumul_chunk_counts(char *buf)
-{
-       unsigned long i, chunks = 0, total_chunks = 0, sum_total_chunks = 0;
-       unsigned long total_chunks_lte_21 = 0, total_chunks_lte_32 = 0;
-       unsigned long total_chunks_lte_42 = 0;
-       char *p = buf;
-
-       for (i = 0; i < NCHUNKS; i++) {
-               p += sprintf(p, "%lu ", zbud_cumul_chunk_counts[i]);
-               chunks += zbud_cumul_chunk_counts[i];
-               total_chunks += zbud_cumul_chunk_counts[i];
-               sum_total_chunks += i * zbud_cumul_chunk_counts[i];
-               if (i == 21)
-                       total_chunks_lte_21 = total_chunks;
-               if (i == 32)
-                       total_chunks_lte_32 = total_chunks;
-               if (i == 42)
-                       total_chunks_lte_42 = total_chunks;
-       }
-       p += sprintf(p, "<=21:%lu <=32:%lu <=42:%lu, mean:%lu\n",
-               total_chunks_lte_21, total_chunks_lte_32, total_chunks_lte_42,
-               chunks == 0 ? 0 : sum_total_chunks / chunks);
-       return p - buf;
-}
-#endif
-
-/**********
- * This "zv" PAM implementation combines the slab-based zsmalloc
- * with the crypto compression API to maximize the amount of data that can
- * be packed into a physical page.
- *
- * Zv represents a PAM page with the index and object (plus a "size" value
- * necessary for decompression) immediately preceding the compressed data.
- */
-
-#define ZVH_SENTINEL  0x43214321
 
-struct zv_hdr {
-       uint32_t pool_id;
-       struct tmem_oid oid;
-       uint32_t index;
-       size_t size;
-       DECL_SENTINEL
-};
-
-/* rudimentary policy limits */
-/* total number of persistent pages may not exceed this percentage */
-static unsigned int zv_page_count_policy_percent = 75;
 /*
  * byte count defining poor compression; pages with greater zsize will be
  * rejected
  */
-static unsigned int zv_max_zsize = (PAGE_SIZE / 8) * 7;
+static unsigned int zbud_max_zsize __read_mostly = (PAGE_SIZE / 8) * 7;
 /*
  * byte count defining poor *mean* compression; pages with greater zsize
  * will be rejected until sufficient better-compressed pages are accepted
  * driving the mean below this threshold
  */
-static unsigned int zv_max_mean_zsize = (PAGE_SIZE / 8) * 5;
-
-static atomic_t zv_curr_dist_counts[NCHUNKS];
-static atomic_t zv_cumul_dist_counts[NCHUNKS];
+static unsigned int zbud_max_mean_zsize __read_mostly = (PAGE_SIZE / 8) * 5;
 
-static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id,
-                               struct tmem_oid *oid, uint32_t index,
-                               void *cdata, unsigned clen)
-{
-       struct zv_hdr *zv;
-       u32 size = clen + sizeof(struct zv_hdr);
-       int chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT;
-       unsigned long handle = 0;
-
-       BUG_ON(!irqs_disabled());
-       BUG_ON(chunks >= NCHUNKS);
-       handle = zs_malloc(pool, size);
-       if (!handle)
-               goto out;
-       atomic_inc(&zv_curr_dist_counts[chunks]);
-       atomic_inc(&zv_cumul_dist_counts[chunks]);
-       zv = zs_map_object(pool, handle, ZS_MM_WO);
-       zv->index = index;
-       zv->oid = *oid;
-       zv->pool_id = pool_id;
-       zv->size = clen;
-       SET_SENTINEL(zv, ZVH);
-       memcpy((char *)zv + sizeof(struct zv_hdr), cdata, clen);
-       zs_unmap_object(pool, handle);
-out:
-       return handle;
-}
-
-static void zv_free(struct zs_pool *pool, unsigned long handle)
-{
-       unsigned long flags;
-       struct zv_hdr *zv;
-       uint16_t size;
-       int chunks;
-
-       zv = zs_map_object(pool, handle, ZS_MM_RW);
-       ASSERT_SENTINEL(zv, ZVH);
-       size = zv->size + sizeof(struct zv_hdr);
-       INVERT_SENTINEL(zv, ZVH);
-       zs_unmap_object(pool, handle);
-
-       chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT;
-       BUG_ON(chunks >= NCHUNKS);
-       atomic_dec(&zv_curr_dist_counts[chunks]);
-
-       local_irq_save(flags);
-       zs_free(pool, handle);
-       local_irq_restore(flags);
-}
-
-static void zv_decompress(struct page *page, unsigned long handle)
-{
-       unsigned int clen = PAGE_SIZE;
-       char *to_va;
-       int ret;
-       struct zv_hdr *zv;
-
-       zv = zs_map_object(zcache_host.zspool, handle, ZS_MM_RO);
-       BUG_ON(zv->size == 0);
-       ASSERT_SENTINEL(zv, ZVH);
-       to_va = kmap_atomic(page);
-       ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, (char *)zv + sizeof(*zv),
-                               zv->size, to_va, &clen);
-       kunmap_atomic(to_va);
-       zs_unmap_object(zcache_host.zspool, handle);
-       BUG_ON(ret);
-       BUG_ON(clen != PAGE_SIZE);
-}
-
-#ifdef CONFIG_SYSFS
 /*
- * show a distribution of compression stats for zv pages.
+ * for now, used named slabs so can easily track usage; later can
+ * either just use kmalloc, or perhaps add a slab-like allocator
+ * to more carefully manage total memory utilization
  */
+static struct kmem_cache *zcache_objnode_cache;
+static struct kmem_cache *zcache_obj_cache;
 
-static int zv_curr_dist_counts_show(char *buf)
-{
-       unsigned long i, n, chunks = 0, sum_total_chunks = 0;
-       char *p = buf;
-
-       for (i = 0; i < NCHUNKS; i++) {
-               n = atomic_read(&zv_curr_dist_counts[i]);
-               p += sprintf(p, "%lu ", n);
-               chunks += n;
-               sum_total_chunks += i * n;
-       }
-       p += sprintf(p, "mean:%lu\n",
-               chunks == 0 ? 0 : sum_total_chunks / chunks);
-       return p - buf;
-}
-
-static int zv_cumul_dist_counts_show(char *buf)
-{
-       unsigned long i, n, chunks = 0, sum_total_chunks = 0;
-       char *p = buf;
-
-       for (i = 0; i < NCHUNKS; i++) {
-               n = atomic_read(&zv_cumul_dist_counts[i]);
-               p += sprintf(p, "%lu ", n);
-               chunks += n;
-               sum_total_chunks += i * n;
-       }
-       p += sprintf(p, "mean:%lu\n",
-               chunks == 0 ? 0 : sum_total_chunks / chunks);
-       return p - buf;
-}
+static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
 
-/*
- * setting zv_max_zsize via sysfs causes all persistent (e.g. swap)
- * pages that don't compress to less than this value (including metadata
- * overhead) to be rejected.  We don't allow the value to get too close
- * to PAGE_SIZE.
- */
-static ssize_t zv_max_zsize_show(struct kobject *kobj,
-                                   struct kobj_attribute *attr,
-                                   char *buf)
-{
-       return sprintf(buf, "%u\n", zv_max_zsize);
+/* we try to keep these statistics SMP-consistent */
+static long zcache_obj_count;
+static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
+static long zcache_obj_count_max;
+static long zcache_objnode_count;
+static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
+static long zcache_objnode_count_max;
+static u64 zcache_eph_zbytes;
+static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
+static u64 zcache_eph_zbytes_max;
+static u64 zcache_pers_zbytes;
+static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
+static u64 zcache_pers_zbytes_max;
+static long zcache_eph_pageframes;
+static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
+static long zcache_eph_pageframes_max;
+static long zcache_pers_pageframes;
+static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
+static long zcache_pers_pageframes_max;
+static long zcache_pageframes_alloced;
+static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
+static long zcache_pageframes_freed;
+static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
+static long zcache_eph_zpages;
+static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
+static long zcache_eph_zpages_max;
+static long zcache_pers_zpages;
+static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
+static long zcache_pers_zpages_max;
+
+/* but for the rest of these, counting races are ok */
+static unsigned long zcache_flush_total;
+static unsigned long zcache_flush_found;
+static unsigned long zcache_flobj_total;
+static unsigned long zcache_flobj_found;
+static unsigned long zcache_failed_eph_puts;
+static unsigned long zcache_failed_pers_puts;
+static unsigned long zcache_failed_getfreepages;
+static unsigned long zcache_failed_alloc;
+static unsigned long zcache_put_to_flush;
+static unsigned long zcache_compress_poor;
+static unsigned long zcache_mean_compress_poor;
+static unsigned long zcache_eph_ate_tail;
+static unsigned long zcache_eph_ate_tail_failed;
+static unsigned long zcache_pers_ate_eph;
+static unsigned long zcache_pers_ate_eph_failed;
+static unsigned long zcache_evicted_eph_zpages;
+static unsigned long zcache_evicted_eph_pageframes;
+static unsigned long zcache_last_active_file_pageframes;
+static unsigned long zcache_last_inactive_file_pageframes;
+static unsigned long zcache_last_active_anon_pageframes;
+static unsigned long zcache_last_inactive_anon_pageframes;
+static unsigned long zcache_eph_nonactive_puts_ignored;
+static unsigned long zcache_pers_nonactive_puts_ignored;
+
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#define        zdfs    debugfs_create_size_t
+#define        zdfs64  debugfs_create_u64
+static int zcache_debugfs_init(void)
+{
+       struct dentry *root = debugfs_create_dir("zcache", NULL);
+       if (root == NULL)
+               return -ENXIO;
+
+       zdfs("obj_count", S_IRUGO, root, &zcache_obj_count);
+       zdfs("obj_count_max", S_IRUGO, root, &zcache_obj_count_max);
+       zdfs("objnode_count", S_IRUGO, root, &zcache_objnode_count);
+       zdfs("objnode_count_max", S_IRUGO, root, &zcache_objnode_count_max);
+       zdfs("flush_total", S_IRUGO, root, &zcache_flush_total);
+       zdfs("flush_found", S_IRUGO, root, &zcache_flush_found);
+       zdfs("flobj_total", S_IRUGO, root, &zcache_flobj_total);
+       zdfs("flobj_found", S_IRUGO, root, &zcache_flobj_found);
+       zdfs("failed_eph_puts", S_IRUGO, root, &zcache_failed_eph_puts);
+       zdfs("failed_pers_puts", S_IRUGO, root, &zcache_failed_pers_puts);
+       zdfs("failed_get_free_pages", S_IRUGO, root,
+                               &zcache_failed_getfreepages);
+       zdfs("failed_alloc", S_IRUGO, root, &zcache_failed_alloc);
+       zdfs("put_to_flush", S_IRUGO, root, &zcache_put_to_flush);
+       zdfs("compress_poor", S_IRUGO, root, &zcache_compress_poor);
+       zdfs("mean_compress_poor", S_IRUGO, root, &zcache_mean_compress_poor);
+       zdfs("eph_ate_tail", S_IRUGO, root, &zcache_eph_ate_tail);
+       zdfs("eph_ate_tail_failed", S_IRUGO, root, &zcache_eph_ate_tail_failed);
+       zdfs("pers_ate_eph", S_IRUGO, root, &zcache_pers_ate_eph);
+       zdfs("pers_ate_eph_failed", S_IRUGO, root, &zcache_pers_ate_eph_failed);
+       zdfs("evicted_eph_zpages", S_IRUGO, root, &zcache_evicted_eph_zpages);
+       zdfs("evicted_eph_pageframes", S_IRUGO, root,
+                               &zcache_evicted_eph_pageframes);
+       zdfs("eph_pageframes", S_IRUGO, root, &zcache_eph_pageframes);
+       zdfs("eph_pageframes_max", S_IRUGO, root, &zcache_eph_pageframes_max);
+       zdfs("pers_pageframes", S_IRUGO, root, &zcache_pers_pageframes);
+       zdfs("pers_pageframes_max", S_IRUGO, root, &zcache_pers_pageframes_max);
+       zdfs("eph_zpages", S_IRUGO, root, &zcache_eph_zpages);
+       zdfs("eph_zpages_max", S_IRUGO, root, &zcache_eph_zpages_max);
+       zdfs("pers_zpages", S_IRUGO, root, &zcache_pers_zpages);
+       zdfs("pers_zpages_max", S_IRUGO, root, &zcache_pers_zpages_max);
+       zdfs("last_active_file_pageframes", S_IRUGO, root,
+                               &zcache_last_active_file_pageframes);
+       zdfs("last_inactive_file_pageframes", S_IRUGO, root,
+                               &zcache_last_inactive_file_pageframes);
+       zdfs("last_active_anon_pageframes", S_IRUGO, root,
+                               &zcache_last_active_anon_pageframes);
+       zdfs("last_inactive_anon_pageframes", S_IRUGO, root,
+                               &zcache_last_inactive_anon_pageframes);
+       zdfs("eph_nonactive_puts_ignored", S_IRUGO, root,
+                               &zcache_eph_nonactive_puts_ignored);
+       zdfs("pers_nonactive_puts_ignored", S_IRUGO, root,
+                               &zcache_pers_nonactive_puts_ignored);
+       zdfs64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
+       zdfs64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
+       zdfs64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
+       zdfs64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
+       return 0;
 }
+#undef zdebugfs
+#undef zdfs64
+#endif
 
-static ssize_t zv_max_zsize_store(struct kobject *kobj,
-                                   struct kobj_attribute *attr,
-                                   const char *buf, size_t count)
-{
-       unsigned long val;
-       int err;
-
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-
-       err = kstrtoul(buf, 10, &val);
-       if (err || (val == 0) || (val > (PAGE_SIZE / 8) * 7))
-               return -EINVAL;
-       zv_max_zsize = val;
-       return count;
+#define ZCACHE_DEBUG
+#ifdef ZCACHE_DEBUG
+/* developers can call this in case of ooms, e.g. to find memory leaks */
+void zcache_dump(void)
+{
+       pr_info("zcache: obj_count=%lu\n", zcache_obj_count);
+       pr_info("zcache: obj_count_max=%lu\n", zcache_obj_count_max);
+       pr_info("zcache: objnode_count=%lu\n", zcache_objnode_count);
+       pr_info("zcache: objnode_count_max=%lu\n", zcache_objnode_count_max);
+       pr_info("zcache: flush_total=%lu\n", zcache_flush_total);
+       pr_info("zcache: flush_found=%lu\n", zcache_flush_found);
+       pr_info("zcache: flobj_total=%lu\n", zcache_flobj_total);
+       pr_info("zcache: flobj_found=%lu\n", zcache_flobj_found);
+       pr_info("zcache: failed_eph_puts=%lu\n", zcache_failed_eph_puts);
+       pr_info("zcache: failed_pers_puts=%lu\n", zcache_failed_pers_puts);
+       pr_info("zcache: failed_get_free_pages=%lu\n",
+                               zcache_failed_getfreepages);
+       pr_info("zcache: failed_alloc=%lu\n", zcache_failed_alloc);
+       pr_info("zcache: put_to_flush=%lu\n", zcache_put_to_flush);
+       pr_info("zcache: compress_poor=%lu\n", zcache_compress_poor);
+       pr_info("zcache: mean_compress_poor=%lu\n",
+                               zcache_mean_compress_poor);
+       pr_info("zcache: eph_ate_tail=%lu\n", zcache_eph_ate_tail);
+       pr_info("zcache: eph_ate_tail_failed=%lu\n",
+                               zcache_eph_ate_tail_failed);
+       pr_info("zcache: pers_ate_eph=%lu\n", zcache_pers_ate_eph);
+       pr_info("zcache: pers_ate_eph_failed=%lu\n",
+                               zcache_pers_ate_eph_failed);
+       pr_info("zcache: evicted_eph_zpages=%lu\n", zcache_evicted_eph_zpages);
+       pr_info("zcache: evicted_eph_pageframes=%lu\n",
+                               zcache_evicted_eph_pageframes);
+       pr_info("zcache: eph_pageframes=%lu\n", zcache_eph_pageframes);
+       pr_info("zcache: eph_pageframes_max=%lu\n", zcache_eph_pageframes_max);
+       pr_info("zcache: pers_pageframes=%lu\n", zcache_pers_pageframes);
+       pr_info("zcache: pers_pageframes_max=%lu\n",
+                               zcache_pers_pageframes_max);
+       pr_info("zcache: eph_zpages=%lu\n", zcache_eph_zpages);
+       pr_info("zcache: eph_zpages_max=%lu\n", zcache_eph_zpages_max);
+       pr_info("zcache: pers_zpages=%lu\n", zcache_pers_zpages);
+       pr_info("zcache: pers_zpages_max=%lu\n", zcache_pers_zpages_max);
+       pr_info("zcache: eph_zbytes=%llu\n",
+                               (unsigned long long)zcache_eph_zbytes);
+       pr_info("zcache: eph_zbytes_max=%llu\n",
+                               (unsigned long long)zcache_eph_zbytes_max);
+       pr_info("zcache: pers_zbytes=%llu\n",
+                               (unsigned long long)zcache_pers_zbytes);
+       pr_info("zcache: pers_zbytes_max=%llu\n",
+                       (unsigned long long)zcache_pers_zbytes_max);
 }
+#endif
 
 /*
- * setting zv_max_mean_zsize via sysfs causes all persistent (e.g. swap)
- * pages that don't compress to less than this value (including metadata
- * overhead) to be rejected UNLESS the mean compression is also smaller
- * than this value.  In other words, we are load-balancing-by-zsize the
- * accepted pages.  Again, we don't allow the value to get too close
- * to PAGE_SIZE.
+ * zcache core code starts here
  */
-static ssize_t zv_max_mean_zsize_show(struct kobject *kobj,
-                                   struct kobj_attribute *attr,
-                                   char *buf)
-{
-       return sprintf(buf, "%u\n", zv_max_mean_zsize);
-}
-
-static ssize_t zv_max_mean_zsize_store(struct kobject *kobj,
-                                   struct kobj_attribute *attr,
-                                   const char *buf, size_t count)
-{
-       unsigned long val;
-       int err;
-
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
 
-       err = kstrtoul(buf, 10, &val);
-       if (err || (val == 0) || (val > (PAGE_SIZE / 8) * 7))
-               return -EINVAL;
-       zv_max_mean_zsize = val;
-       return count;
-}
+static struct zcache_client zcache_host;
+static struct zcache_client zcache_clients[MAX_CLIENTS];
 
-/*
- * setting zv_page_count_policy_percent via sysfs sets an upper bound of
- * persistent (e.g. swap) pages that will be retained according to:
- *     (zv_page_count_policy_percent * totalram_pages) / 100)
- * when that limit is reached, further puts will be rejected (until
- * some pages have been flushed).  Note that, due to compression,
- * this number may exceed 100; it defaults to 75 and we set an
- * arbitary limit of 150.  A poor choice will almost certainly result
- * in OOM's, so this value should only be changed prudently.
- */
-static ssize_t zv_page_count_policy_percent_show(struct kobject *kobj,
-                                                struct kobj_attribute *attr,
-                                                char *buf)
+static inline bool is_local_client(struct zcache_client *cli)
 {
-       return sprintf(buf, "%u\n", zv_page_count_policy_percent);
+       return cli == &zcache_host;
 }
 
-static ssize_t zv_page_count_policy_percent_store(struct kobject *kobj,
-                                                 struct kobj_attribute *attr,
-                                                 const char *buf, size_t count)
+static struct zcache_client *zcache_get_client_by_id(uint16_t cli_id)
 {
-       unsigned long val;
-       int err;
+       struct zcache_client *cli = &zcache_host;
 
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-
-       err = kstrtoul(buf, 10, &val);
-       if (err || (val == 0) || (val > 150))
-               return -EINVAL;
-       zv_page_count_policy_percent = val;
-       return count;
+       if (cli_id != LOCAL_CLIENT) {
+               if (cli_id >= MAX_CLIENTS)
+                       goto out;
+               cli = &zcache_clients[cli_id];
+       }
+out:
+       return cli;
 }
 
-static struct kobj_attribute zcache_zv_max_zsize_attr = {
-               .attr = { .name = "zv_max_zsize", .mode = 0644 },
-               .show = zv_max_zsize_show,
-               .store = zv_max_zsize_store,
-};
-
-static struct kobj_attribute zcache_zv_max_mean_zsize_attr = {
-               .attr = { .name = "zv_max_mean_zsize", .mode = 0644 },
-               .show = zv_max_mean_zsize_show,
-               .store = zv_max_mean_zsize_store,
-};
-
-static struct kobj_attribute zcache_zv_page_count_policy_percent_attr = {
-               .attr = { .name = "zv_page_count_policy_percent",
-                         .mode = 0644 },
-               .show = zv_page_count_policy_percent_show,
-               .store = zv_page_count_policy_percent_store,
-};
-#endif
-
-/*
- * zcache core code starts here
- */
-
-/* useful stats not collected by cleancache or frontswap */
-static unsigned long zcache_flush_total;
-static unsigned long zcache_flush_found;
-static unsigned long zcache_flobj_total;
-static unsigned long zcache_flobj_found;
-static unsigned long zcache_failed_eph_puts;
-static unsigned long zcache_failed_pers_puts;
-
 /*
  * Tmem operations assume the poolid implies the invoking client.
  * Zcache only has one client (the kernel itself): LOCAL_CLIENT.
@@ -941,24 +328,26 @@ static unsigned long zcache_failed_pers_puts;
  * of zcache would have one client per guest and each client might
  * have a poolid==N.
  */
-static struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid)
+struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid)
 {
        struct tmem_pool *pool = NULL;
        struct zcache_client *cli = NULL;
 
-       cli = get_zcache_client(cli_id);
-       if (!cli)
+       cli = zcache_get_client_by_id(cli_id);
+       if (cli == NULL)
                goto out;
-
-       atomic_inc(&cli->refcount);
-       pool = idr_find(&cli->tmem_pools, poolid);
-       if (pool != NULL)
-               atomic_inc(&pool->refcount);
+       if (!is_local_client(cli))
+               atomic_inc(&cli->refcount);
+       if (poolid < MAX_POOLS_PER_CLIENT) {
+               pool = cli->tmem_pools[poolid];
+               if (pool != NULL)
+                       atomic_inc(&pool->refcount);
+       }
 out:
        return pool;
 }
 
-static void zcache_put_pool(struct tmem_pool *pool)
+void zcache_put_pool(struct tmem_pool *pool)
 {
        struct zcache_client *cli = NULL;
 
@@ -966,7 +355,8 @@ static void zcache_put_pool(struct tmem_pool *pool)
                BUG();
        cli = pool->client;
        atomic_dec(&pool->refcount);
-       atomic_dec(&cli->refcount);
+       if (!is_local_client(cli))
+               atomic_dec(&cli->refcount);
 }
 
 int zcache_new_client(uint16_t cli_id)
@@ -974,120 +364,17 @@ int zcache_new_client(uint16_t cli_id)
        struct zcache_client *cli;
        int ret = -1;
 
-       cli = get_zcache_client(cli_id);
-
+       cli = zcache_get_client_by_id(cli_id);
        if (cli == NULL)
                goto out;
        if (cli->allocated)
                goto out;
        cli->allocated = 1;
-#ifdef CONFIG_FRONTSWAP
-       cli->zspool = zs_create_pool("zcache", ZCACHE_GFP_MASK);
-       if (cli->zspool == NULL)
-               goto out;
-       idr_init(&cli->tmem_pools);
-#endif
        ret = 0;
 out:
        return ret;
 }
 
-/* counters for debugging */
-static unsigned long zcache_failed_get_free_pages;
-static unsigned long zcache_failed_alloc;
-static unsigned long zcache_put_to_flush;
-
-/*
- * for now, used named slabs so can easily track usage; later can
- * either just use kmalloc, or perhaps add a slab-like allocator
- * to more carefully manage total memory utilization
- */
-static struct kmem_cache *zcache_objnode_cache;
-static struct kmem_cache *zcache_obj_cache;
-static atomic_t zcache_curr_obj_count = ATOMIC_INIT(0);
-static unsigned long zcache_curr_obj_count_max;
-static atomic_t zcache_curr_objnode_count = ATOMIC_INIT(0);
-static unsigned long zcache_curr_objnode_count_max;
-
-/*
- * to avoid memory allocation recursion (e.g. due to direct reclaim), we
- * preload all necessary data structures so the hostops callbacks never
- * actually do a malloc
- */
-struct zcache_preload {
-       void *page;
-       struct tmem_obj *obj;
-       int nr;
-       struct tmem_objnode *objnodes[OBJNODE_TREE_MAX_PATH];
-};
-static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, };
-
-static int zcache_do_preload(struct tmem_pool *pool)
-{
-       struct zcache_preload *kp;
-       struct tmem_objnode *objnode;
-       struct tmem_obj *obj;
-       void *page;
-       int ret = -ENOMEM;
-
-       if (unlikely(zcache_objnode_cache == NULL))
-               goto out;
-       if (unlikely(zcache_obj_cache == NULL))
-               goto out;
-
-       /* IRQ has already been disabled. */
-       kp = &__get_cpu_var(zcache_preloads);
-       while (kp->nr < ARRAY_SIZE(kp->objnodes)) {
-               objnode = kmem_cache_alloc(zcache_objnode_cache,
-                               ZCACHE_GFP_MASK);
-               if (unlikely(objnode == NULL)) {
-                       zcache_failed_alloc++;
-                       goto out;
-               }
-
-               kp->objnodes[kp->nr++] = objnode;
-       }
-
-       if (!kp->obj) {
-               obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
-               if (unlikely(obj == NULL)) {
-                       zcache_failed_alloc++;
-                       goto out;
-               }
-               kp->obj = obj;
-       }
-
-       if (!kp->page) {
-               page = (void *)__get_free_page(ZCACHE_GFP_MASK);
-               if (unlikely(page == NULL)) {
-                       zcache_failed_get_free_pages++;
-                       goto out;
-               }
-               kp->page =  page;
-       }
-
-       ret = 0;
-out:
-       return ret;
-}
-
-static void *zcache_get_free_page(void)
-{
-       struct zcache_preload *kp;
-       void *page;
-
-       kp = &__get_cpu_var(zcache_preloads);
-       page = kp->page;
-       BUG_ON(page == NULL);
-       kp->page = NULL;
-       return page;
-}
-
-static void zcache_free_page(void *p)
-{
-       free_page((unsigned long)p);
-}
-
 /*
  * zcache implementation for tmem host ops
  */
@@ -1095,151 +382,367 @@ static void zcache_free_page(void *p)
 static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool)
 {
        struct tmem_objnode *objnode = NULL;
-       unsigned long count;
        struct zcache_preload *kp;
+       int i;
 
        kp = &__get_cpu_var(zcache_preloads);
-       if (kp->nr <= 0)
-               goto out;
-       objnode = kp->objnodes[kp->nr - 1];
+       for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
+               objnode = kp->objnodes[i];
+               if (objnode != NULL) {
+                       kp->objnodes[i] = NULL;
+                       break;
+               }
+       }
        BUG_ON(objnode == NULL);
-       kp->objnodes[kp->nr - 1] = NULL;
-       kp->nr--;
-       count = atomic_inc_return(&zcache_curr_objnode_count);
-       if (count > zcache_curr_objnode_count_max)
-               zcache_curr_objnode_count_max = count;
-out:
+       zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
+       if (zcache_objnode_count > zcache_objnode_count_max)
+               zcache_objnode_count_max = zcache_objnode_count;
        return objnode;
 }
 
 static void zcache_objnode_free(struct tmem_objnode *objnode,
                                        struct tmem_pool *pool)
 {
-       atomic_dec(&zcache_curr_objnode_count);
-       BUG_ON(atomic_read(&zcache_curr_objnode_count) < 0);
+       zcache_objnode_count =
+               atomic_dec_return(&zcache_objnode_atomic);
+       BUG_ON(zcache_objnode_count < 0);
        kmem_cache_free(zcache_objnode_cache, objnode);
 }
 
 static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool)
 {
        struct tmem_obj *obj = NULL;
-       unsigned long count;
        struct zcache_preload *kp;
 
        kp = &__get_cpu_var(zcache_preloads);
        obj = kp->obj;
        BUG_ON(obj == NULL);
        kp->obj = NULL;
-       count = atomic_inc_return(&zcache_curr_obj_count);
-       if (count > zcache_curr_obj_count_max)
-               zcache_curr_obj_count_max = count;
+       zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
+       if (zcache_obj_count > zcache_obj_count_max)
+               zcache_obj_count_max = zcache_obj_count;
        return obj;
 }
 
 static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool)
 {
-       atomic_dec(&zcache_curr_obj_count);
-       BUG_ON(atomic_read(&zcache_curr_obj_count) < 0);
+       zcache_obj_count =
+               atomic_dec_return(&zcache_obj_atomic);
+       BUG_ON(zcache_obj_count < 0);
        kmem_cache_free(zcache_obj_cache, obj);
 }
 
-static struct tmem_hostops zcache_hostops = {
-       .obj_alloc = zcache_obj_alloc,
-       .obj_free = zcache_obj_free,
-       .objnode_alloc = zcache_objnode_alloc,
-       .objnode_free = zcache_objnode_free,
-};
-
+static struct tmem_hostops zcache_hostops = {
+       .obj_alloc = zcache_obj_alloc,
+       .obj_free = zcache_obj_free,
+       .objnode_alloc = zcache_objnode_alloc,
+       .objnode_free = zcache_objnode_free,
+};
+
+static struct page *zcache_alloc_page(void)
+{
+       struct page *page = alloc_page(ZCACHE_GFP_MASK);
+
+       if (page != NULL)
+               zcache_pageframes_alloced =
+                       atomic_inc_return(&zcache_pageframes_alloced_atomic);
+       return page;
+}
+
+#ifdef FRONTSWAP_HAS_UNUSE
+static void zcache_unacct_page(void)
+{
+       zcache_pageframes_freed =
+               atomic_inc_return(&zcache_pageframes_freed_atomic);
+}
+#endif
+
+static void zcache_free_page(struct page *page)
+{
+       long curr_pageframes;
+       static long max_pageframes, min_pageframes;
+
+       if (page == NULL)
+               BUG();
+       __free_page(page);
+       zcache_pageframes_freed =
+               atomic_inc_return(&zcache_pageframes_freed_atomic);
+       curr_pageframes = zcache_pageframes_alloced -
+                       atomic_read(&zcache_pageframes_freed_atomic) -
+                       atomic_read(&zcache_eph_pageframes_atomic) -
+                       atomic_read(&zcache_pers_pageframes_atomic);
+       if (curr_pageframes > max_pageframes)
+               max_pageframes = curr_pageframes;
+       if (curr_pageframes < min_pageframes)
+               min_pageframes = curr_pageframes;
+#ifdef ZCACHE_DEBUG
+       if (curr_pageframes > 2L || curr_pageframes < -2L) {
+               /* pr_info here */
+       }
+#endif
+}
+
 /*
  * zcache implementations for PAM page descriptor ops
  */
 
-static atomic_t zcache_curr_eph_pampd_count = ATOMIC_INIT(0);
-static unsigned long zcache_curr_eph_pampd_count_max;
-static atomic_t zcache_curr_pers_pampd_count = ATOMIC_INIT(0);
-static unsigned long zcache_curr_pers_pampd_count_max;
-
 /* forward reference */
-static int zcache_compress(struct page *from, void **out_va, unsigned *out_len);
+static void zcache_compress(struct page *from,
+                               void **out_va, unsigned *out_len);
 
-static void *zcache_pampd_create(char *data, size_t size, bool raw, int eph,
-                               struct tmem_pool *pool, struct tmem_oid *oid,
-                                uint32_t index)
+static struct page *zcache_evict_eph_pageframe(void);
+
+static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
+                                       struct tmem_handle *th)
 {
-       void *pampd = NULL, *cdata;
-       unsigned clen;
-       int ret;
-       unsigned long count;
-       struct page *page = (struct page *)(data);
-       struct zcache_client *cli = pool->client;
-       uint16_t client_id = get_client_id_from_client(cli);
-       unsigned long zv_mean_zsize;
-       unsigned long curr_pers_pampd_count;
-       u64 total_zsize;
+       void *pampd = NULL, *cdata = data;
+       unsigned clen = size;
+       struct page *page = (struct page *)(data), *newpage;
 
-       if (eph) {
-               ret = zcache_compress(page, &cdata, &clen);
-               if (ret == 0)
-                       goto out;
-               if (clen == 0 || clen > zbud_max_buddy_size()) {
+       if (!raw) {
+               zcache_compress(page, &cdata, &clen);
+               if (clen > zbud_max_buddy_size()) {
                        zcache_compress_poor++;
                        goto out;
                }
-               pampd = (void *)zbud_create(client_id, pool->pool_id, oid,
-                                               index, page, cdata, clen);
-               if (pampd != NULL) {
-                       count = atomic_inc_return(&zcache_curr_eph_pampd_count);
-                       if (count > zcache_curr_eph_pampd_count_max)
-                               zcache_curr_eph_pampd_count_max = count;
-               }
        } else {
-               curr_pers_pampd_count =
-                       atomic_read(&zcache_curr_pers_pampd_count);
-               if (curr_pers_pampd_count >
-                   (zv_page_count_policy_percent * totalram_pages) / 100)
-                       goto out;
-               ret = zcache_compress(page, &cdata, &clen);
-               if (ret == 0)
-                       goto out;
-               /* reject if compression is too poor */
-               if (clen > zv_max_zsize) {
-                       zcache_compress_poor++;
+               BUG_ON(clen > zbud_max_buddy_size());
+       }
+
+       /* look for space via an existing match first */
+       pampd = (void *)zbud_match_prep(th, true, cdata, clen);
+       if (pampd != NULL)
+               goto got_pampd;
+
+       /* no match, now we need to find (or free up) a full page */
+       newpage = zcache_alloc_page();
+       if (newpage != NULL)
+               goto create_in_new_page;
+
+       zcache_failed_getfreepages++;
+       /* can't allocate a page, evict an ephemeral page via LRU */
+       newpage = zcache_evict_eph_pageframe();
+       if (newpage == NULL) {
+               zcache_eph_ate_tail_failed++;
+               goto out;
+       }
+       zcache_eph_ate_tail++;
+
+create_in_new_page:
+       pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage);
+       BUG_ON(pampd == NULL);
+       zcache_eph_pageframes =
+               atomic_inc_return(&zcache_eph_pageframes_atomic);
+       if (zcache_eph_pageframes > zcache_eph_pageframes_max)
+               zcache_eph_pageframes_max = zcache_eph_pageframes;
+
+got_pampd:
+       zcache_eph_zbytes =
+               atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
+       if (zcache_eph_zbytes > zcache_eph_zbytes_max)
+               zcache_eph_zbytes_max = zcache_eph_zbytes;
+       zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
+       if (zcache_eph_zpages > zcache_eph_zpages_max)
+               zcache_eph_zpages_max = zcache_eph_zpages;
+       if (ramster_enabled && raw)
+               ramster_count_foreign_pages(true, 1);
+out:
+       return pampd;
+}
+
+static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
+                                       struct tmem_handle *th)
+{
+       void *pampd = NULL, *cdata = data;
+       unsigned clen = size;
+       struct page *page = (struct page *)(data), *newpage;
+       unsigned long zbud_mean_zsize;
+       unsigned long curr_pers_zpages, total_zsize;
+
+       if (data == NULL) {
+               BUG_ON(!ramster_enabled);
+               goto create_pampd;
+       }
+       curr_pers_zpages = zcache_pers_zpages;
+/* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */
+       if (!raw)
+               zcache_compress(page, &cdata, &clen);
+       /* reject if compression is too poor */
+       if (clen > zbud_max_zsize) {
+               zcache_compress_poor++;
+               goto out;
+       }
+       /* reject if mean compression is too poor */
+       if ((clen > zbud_max_mean_zsize) && (curr_pers_zpages > 0)) {
+               total_zsize = zcache_pers_zbytes;
+               if ((long)total_zsize < 0)
+                       total_zsize = 0;
+               zbud_mean_zsize = div_u64(total_zsize,
+                                       curr_pers_zpages);
+               if (zbud_mean_zsize > zbud_max_mean_zsize) {
+                       zcache_mean_compress_poor++;
                        goto out;
                }
-               /* reject if mean compression is too poor */
-               if ((clen > zv_max_mean_zsize) && (curr_pers_pampd_count > 0)) {
-                       total_zsize = zs_get_total_size_bytes(cli->zspool);
-                       zv_mean_zsize = div_u64(total_zsize,
-                                               curr_pers_pampd_count);
-                       if (zv_mean_zsize > zv_max_mean_zsize) {
-                               zcache_mean_compress_poor++;
+       }
+
+create_pampd:
+       /* look for space via an existing match first */
+       pampd = (void *)zbud_match_prep(th, false, cdata, clen);
+       if (pampd != NULL)
+               goto got_pampd;
+
+       /* no match, now we need to find (or free up) a full page */
+       newpage = zcache_alloc_page();
+       if (newpage != NULL)
+               goto create_in_new_page;
+       /*
+        * FIXME do the following only if eph is oversized?
+        * if (zcache_eph_pageframes >
+        * (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) +
+        * global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE)))
+        */
+       zcache_failed_getfreepages++;
+       /* can't allocate a page, evict an ephemeral page via LRU */
+       newpage = zcache_evict_eph_pageframe();
+       if (newpage == NULL) {
+               zcache_pers_ate_eph_failed++;
+               goto out;
+       }
+       zcache_pers_ate_eph++;
+
+create_in_new_page:
+       pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage);
+       BUG_ON(pampd == NULL);
+       zcache_pers_pageframes =
+               atomic_inc_return(&zcache_pers_pageframes_atomic);
+       if (zcache_pers_pageframes > zcache_pers_pageframes_max)
+               zcache_pers_pageframes_max = zcache_pers_pageframes;
+
+got_pampd:
+       zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
+       if (zcache_pers_zpages > zcache_pers_zpages_max)
+               zcache_pers_zpages_max = zcache_pers_zpages;
+       zcache_pers_zbytes =
+               atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
+       if (zcache_pers_zbytes > zcache_pers_zbytes_max)
+               zcache_pers_zbytes_max = zcache_pers_zbytes;
+       if (ramster_enabled && raw)
+               ramster_count_foreign_pages(false, 1);
+out:
+       return pampd;
+}
+
+/*
+ * This is called directly from zcache_put_page to pre-allocate space
+ * to store a zpage.
+ */
+void *zcache_pampd_create(char *data, unsigned int size, bool raw,
+                                       int eph, struct tmem_handle *th)
+{
+       void *pampd = NULL;
+       struct zcache_preload *kp;
+       struct tmem_objnode *objnode;
+       struct tmem_obj *obj;
+       int i;
+
+       BUG_ON(!irqs_disabled());
+       /* pre-allocate per-cpu metadata */
+       BUG_ON(zcache_objnode_cache == NULL);
+       BUG_ON(zcache_obj_cache == NULL);
+       kp = &__get_cpu_var(zcache_preloads);
+       for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
+               objnode = kp->objnodes[i];
+               if (objnode == NULL) {
+                       objnode = kmem_cache_alloc(zcache_objnode_cache,
+                                                       ZCACHE_GFP_MASK);
+                       if (unlikely(objnode == NULL)) {
+                               zcache_failed_alloc++;
                                goto out;
                        }
+                       kp->objnodes[i] = objnode;
                }
-               pampd = (void *)zv_create(cli->zspool, pool->pool_id,
-                                               oid, index, cdata, clen);
-               if (pampd == NULL)
-                       goto out;
-               count = atomic_inc_return(&zcache_curr_pers_pampd_count);
-               if (count > zcache_curr_pers_pampd_count_max)
-                       zcache_curr_pers_pampd_count_max = count;
        }
+       if (kp->obj == NULL) {
+               obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
+               kp->obj = obj;
+       }
+       if (unlikely(kp->obj == NULL)) {
+               zcache_failed_alloc++;
+               goto out;
+       }
+       /*
+        * ok, have all the metadata pre-allocated, now do the data
+        * but since how we allocate the data is dependent on ephemeral
+        * or persistent, we split the call here to different sub-functions
+        */
+       if (eph)
+               pampd = zcache_pampd_eph_create(data, size, raw, th);
+       else
+               pampd = zcache_pampd_pers_create(data, size, raw, th);
 out:
        return pampd;
 }
 
+/*
+ * This is a pamops called via tmem_put and is necessary to "finish"
+ * a pampd creation.
+ */
+void zcache_pampd_create_finish(void *pampd, bool eph)
+{
+       zbud_create_finish((struct zbudref *)pampd, eph);
+}
+
+/*
+ * This is passed as a function parameter to zbud_decompress so that
+ * zbud need not be familiar with the details of crypto. It assumes that
+ * the bytes from_va and to_va through from_va+size-1 and to_va+size-1 are
+ * kmapped.  It must be successful, else there is a logic bug somewhere.
+ */
+static void zcache_decompress(char *from_va, unsigned int size, char *to_va)
+{
+       int ret;
+       unsigned int outlen = PAGE_SIZE;
+
+       ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size,
+                               to_va, &outlen);
+       BUG_ON(ret);
+       BUG_ON(outlen != PAGE_SIZE);
+}
+
+/*
+ * Decompress from the kernel va to a pageframe
+ */
+void zcache_decompress_to_page(char *from_va, unsigned int size,
+                                       struct page *to_page)
+{
+       char *to_va = kmap_atomic(to_page);
+       zcache_decompress(from_va, size, to_va);
+       kunmap_atomic(to_va);
+}
+
 /*
  * fill the pageframe corresponding to the struct page with the data
  * from the passed pampd
  */
-static int zcache_pampd_get_data(char *data, size_t *bufsize, bool raw,
+static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw,
                                        void *pampd, struct tmem_pool *pool,
                                        struct tmem_oid *oid, uint32_t index)
 {
-       int ret = 0;
-
-       BUG_ON(is_ephemeral(pool));
-       zv_decompress((struct page *)(data), (unsigned long)pampd);
+       int ret;
+       bool eph = !is_persistent(pool);
+
+       BUG_ON(preemptible());
+       BUG_ON(eph);    /* fix later if shared pools get implemented */
+       BUG_ON(pampd_is_remote(pampd));
+       if (raw)
+               ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd,
+                                               sizep, eph);
+       else {
+               ret = zbud_decompress((struct page *)(data),
+                                       (struct zbudref *)pampd, false,
+                                       zcache_decompress);
+               *sizep = PAGE_SIZE;
+       }
        return ret;
 }
 
@@ -1247,16 +750,50 @@ static int zcache_pampd_get_data(char *data, size_t *bufsize, bool raw,
  * fill the pageframe corresponding to the struct page with the data
  * from the passed pampd
  */
-static int zcache_pampd_get_data_and_free(char *data, size_t *bufsize, bool raw,
+static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
                                        void *pampd, struct tmem_pool *pool,
                                        struct tmem_oid *oid, uint32_t index)
 {
-       BUG_ON(!is_ephemeral(pool));
-       if (zbud_decompress((struct page *)(data), pampd) < 0)
-               return -EINVAL;
-       zbud_free_and_delist((struct zbud_hdr *)pampd);
-       atomic_dec(&zcache_curr_eph_pampd_count);
-       return 0;
+       int ret;
+       bool eph = !is_persistent(pool);
+       struct page *page = NULL;
+       unsigned int zsize, zpages;
+
+       BUG_ON(preemptible());
+       BUG_ON(pampd_is_remote(pampd));
+       if (raw)
+               ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd,
+                                               sizep, eph);
+       else {
+               ret = zbud_decompress((struct page *)(data),
+                                       (struct zbudref *)pampd, eph,
+                                       zcache_decompress);
+               *sizep = PAGE_SIZE;
+       }
+       page = zbud_free_and_delist((struct zbudref *)pampd, eph,
+                                       &zsize, &zpages);
+       if (eph) {
+               if (page)
+                       zcache_eph_pageframes =
+                           atomic_dec_return(&zcache_eph_pageframes_atomic);
+               zcache_eph_zpages =
+                   atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
+               zcache_eph_zbytes =
+                   atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+       } else {
+               if (page)
+                       zcache_pers_pageframes =
+                           atomic_dec_return(&zcache_pers_pageframes_atomic);
+               zcache_pers_zpages =
+                   atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
+               zcache_pers_zbytes =
+                   atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
+       }
+       if (!is_local_client(pool->client))
+               ramster_count_foreign_pages(eph, -1);
+       if (page)
+               zcache_free_page(page);
+       return ret;
 }
 
 /*
@@ -1264,48 +801,51 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *bufsize, bool raw,
  * pampd must no longer be pointed to from any tmem data structures!
  */
 static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
-                               struct tmem_oid *oid, uint32_t index)
+                             struct tmem_oid *oid, uint32_t index, bool acct)
 {
-       struct zcache_client *cli = pool->client;
+       struct page *page = NULL;
+       unsigned int zsize, zpages;
 
+       BUG_ON(preemptible());
+       if (pampd_is_remote(pampd)) {
+               BUG_ON(!ramster_enabled);
+               pampd = ramster_pampd_free(pampd, pool, oid, index, acct);
+               if (pampd == NULL)
+                       return;
+       }
        if (is_ephemeral(pool)) {
-               zbud_free_and_delist((struct zbud_hdr *)pampd);
-               atomic_dec(&zcache_curr_eph_pampd_count);
-               BUG_ON(atomic_read(&zcache_curr_eph_pampd_count) < 0);
+               page = zbud_free_and_delist((struct zbudref *)pampd,
+                                               true, &zsize, &zpages);
+               if (page)
+                       zcache_eph_pageframes =
+                           atomic_dec_return(&zcache_eph_pageframes_atomic);
+               zcache_eph_zpages =
+                   atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
+               zcache_eph_zbytes =
+                   atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
+               /* FIXME CONFIG_RAMSTER... check acct parameter? */
        } else {
-               zv_free(cli->zspool, (unsigned long)pampd);
-               atomic_dec(&zcache_curr_pers_pampd_count);
-               BUG_ON(atomic_read(&zcache_curr_pers_pampd_count) < 0);
+               page = zbud_free_and_delist((struct zbudref *)pampd,
+                                               false, &zsize, &zpages);
+               if (page)
+                       zcache_pers_pageframes =
+                           atomic_dec_return(&zcache_pers_pageframes_atomic);
+               zcache_pers_zpages =
+                    atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
+               zcache_pers_zbytes =
+                   atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
        }
-}
-
-static void zcache_pampd_free_obj(struct tmem_pool *pool, struct tmem_obj *obj)
-{
-}
-
-static void zcache_pampd_new_obj(struct tmem_obj *obj)
-{
-}
-
-static int zcache_pampd_replace_in_obj(void *pampd, struct tmem_obj *obj)
-{
-       return -1;
-}
-
-static bool zcache_pampd_is_remote(void *pampd)
-{
-       return 0;
+       if (!is_local_client(pool->client))
+               ramster_count_foreign_pages(is_ephemeral(pool), -1);
+       if (page)
+               zcache_free_page(page);
 }
 
 static struct tmem_pamops zcache_pamops = {
-       .create = zcache_pampd_create,
+       .create_finish = zcache_pampd_create_finish,
        .get_data = zcache_pampd_get_data,
        .get_data_and_free = zcache_pampd_get_data_and_free,
        .free = zcache_pampd_free,
-       .free_obj = zcache_pampd_free_obj,
-       .new_obj = zcache_pampd_new_obj,
-       .replace_in_obj = zcache_pampd_replace_in_obj,
-       .is_remote = zcache_pampd_is_remote,
 };
 
 /*
@@ -1315,15 +855,15 @@ static struct tmem_pamops zcache_pamops = {
 static DEFINE_PER_CPU(unsigned char *, zcache_dstmem);
 #define ZCACHE_DSTMEM_ORDER 1
 
-static int zcache_compress(struct page *from, void **out_va, unsigned *out_len)
+static void zcache_compress(struct page *from, void **out_va, unsigned *out_len)
 {
-       int ret = 0;
+       int ret;
        unsigned char *dmem = __get_cpu_var(zcache_dstmem);
        char *from_va;
 
        BUG_ON(!irqs_disabled());
-       if (unlikely(dmem == NULL))
-               goto out;  /* no buffer or no compressor so can't compress */
+       /* no buffer or no compressor so can't compress */
+       BUG_ON(dmem == NULL);
        *out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER;
        from_va = kmap_atomic(from);
        mb();
@@ -1332,9 +872,6 @@ static int zcache_compress(struct page *from, void **out_va, unsigned *out_len)
        BUG_ON(ret);
        *out_va = dmem;
        kunmap_atomic(from_va);
-       ret = 1;
-out:
-       return ret;
 }
 
 static int zcache_comp_cpu_up(int cpu)
@@ -1360,18 +897,21 @@ static void zcache_comp_cpu_down(int cpu)
 static int zcache_cpu_notifier(struct notifier_block *nb,
                                unsigned long action, void *pcpu)
 {
-       int ret, cpu = (long)pcpu;
+       int ret, i, cpu = (long)pcpu;
        struct zcache_preload *kp;
 
        switch (action) {
        case CPU_UP_PREPARE:
                ret = zcache_comp_cpu_up(cpu);
                if (ret != NOTIFY_OK) {
-                       pr_err("zcache: can't allocate compressor transform\n");
+                       pr_err("%s: can't allocate compressor xform\n",
+                               namestr);
                        return ret;
                }
                per_cpu(zcache_dstmem, cpu) = (void *)__get_free_pages(
                        GFP_KERNEL | __GFP_REPEAT, ZCACHE_DSTMEM_ORDER);
+               if (ramster_enabled)
+                       ramster_cpu_up(cpu);
                break;
        case CPU_DEAD:
        case CPU_UP_CANCELED:
@@ -1380,20 +920,17 @@ static int zcache_cpu_notifier(struct notifier_block *nb,
                        ZCACHE_DSTMEM_ORDER);
                per_cpu(zcache_dstmem, cpu) = NULL;
                kp = &per_cpu(zcache_preloads, cpu);
-               while (kp->nr) {
-                       kmem_cache_free(zcache_objnode_cache,
-                                       kp->objnodes[kp->nr - 1]);
-                       kp->objnodes[kp->nr - 1] = NULL;
-                       kp->nr--;
+               for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) {
+                       if (kp->objnodes[i])
+                               kmem_cache_free(zcache_objnode_cache,
+                                               kp->objnodes[i]);
                }
                if (kp->obj) {
                        kmem_cache_free(zcache_obj_cache, kp->obj);
                        kp->obj = NULL;
                }
-               if (kp->page) {
-                       free_page((unsigned long)kp->page);
-                       kp->page = NULL;
-               }
+               if (ramster_enabled)
+                       ramster_cpu_down(cpu);
                break;
        default:
                break;
@@ -1405,116 +942,104 @@ static struct notifier_block zcache_cpu_notifier_block = {
        .notifier_call = zcache_cpu_notifier
 };
 
-#ifdef CONFIG_SYSFS
-#define ZCACHE_SYSFS_RO(_name) \
-       static ssize_t zcache_##_name##_show(struct kobject *kobj, \
-                               struct kobj_attribute *attr, char *buf) \
-       { \
-               return sprintf(buf, "%lu\n", zcache_##_name); \
-       } \
-       static struct kobj_attribute zcache_##_name##_attr = { \
-               .attr = { .name = __stringify(_name), .mode = 0444 }, \
-               .show = zcache_##_name##_show, \
-       }
+/*
+ * The following code interacts with the zbud eviction and zbud
+ * zombify code to access LRU pages
+ */
 
-#define ZCACHE_SYSFS_RO_ATOMIC(_name) \
-       static ssize_t zcache_##_name##_show(struct kobject *kobj, \
-                               struct kobj_attribute *attr, char *buf) \
-       { \
-           return sprintf(buf, "%d\n", atomic_read(&zcache_##_name)); \
-       } \
-       static struct kobj_attribute zcache_##_name##_attr = { \
-               .attr = { .name = __stringify(_name), .mode = 0444 }, \
-               .show = zcache_##_name##_show, \
-       }
+static struct page *zcache_evict_eph_pageframe(void)
+{
+       struct page *page;
+       unsigned int zsize = 0, zpages = 0;
 
-#define ZCACHE_SYSFS_RO_CUSTOM(_name, _func) \
-       static ssize_t zcache_##_name##_show(struct kobject *kobj, \
-                               struct kobj_attribute *attr, char *buf) \
-       { \
-           return _func(buf); \
-       } \
-       static struct kobj_attribute zcache_##_name##_attr = { \
-               .attr = { .name = __stringify(_name), .mode = 0444 }, \
-               .show = zcache_##_name##_show, \
-       }
+       page = zbud_evict_pageframe_lru(&zsize, &zpages);
+       if (page == NULL)
+               goto out;
+       zcache_eph_zbytes = atomic_long_sub_return(zsize,
+                                       &zcache_eph_zbytes_atomic);
+       zcache_eph_zpages = atomic_sub_return(zpages,
+                                       &zcache_eph_zpages_atomic);
+       zcache_evicted_eph_zpages++;
+       zcache_eph_pageframes =
+               atomic_dec_return(&zcache_eph_pageframes_atomic);
+       zcache_evicted_eph_pageframes++;
+out:
+       return page;
+}
 
-ZCACHE_SYSFS_RO(curr_obj_count_max);
-ZCACHE_SYSFS_RO(curr_objnode_count_max);
-ZCACHE_SYSFS_RO(flush_total);
-ZCACHE_SYSFS_RO(flush_found);
-ZCACHE_SYSFS_RO(flobj_total);
-ZCACHE_SYSFS_RO(flobj_found);
-ZCACHE_SYSFS_RO(failed_eph_puts);
-ZCACHE_SYSFS_RO(failed_pers_puts);
-ZCACHE_SYSFS_RO(zbud_curr_zbytes);
-ZCACHE_SYSFS_RO(zbud_cumul_zpages);
-ZCACHE_SYSFS_RO(zbud_cumul_zbytes);
-ZCACHE_SYSFS_RO(zbud_buddied_count);
-ZCACHE_SYSFS_RO(zbpg_unused_list_count);
-ZCACHE_SYSFS_RO(evicted_raw_pages);
-ZCACHE_SYSFS_RO(evicted_unbuddied_pages);
-ZCACHE_SYSFS_RO(evicted_buddied_pages);
-ZCACHE_SYSFS_RO(failed_get_free_pages);
-ZCACHE_SYSFS_RO(failed_alloc);
-ZCACHE_SYSFS_RO(put_to_flush);
-ZCACHE_SYSFS_RO(compress_poor);
-ZCACHE_SYSFS_RO(mean_compress_poor);
-ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_raw_pages);
-ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_zpages);
-ZCACHE_SYSFS_RO_ATOMIC(curr_obj_count);
-ZCACHE_SYSFS_RO_ATOMIC(curr_objnode_count);
-ZCACHE_SYSFS_RO_CUSTOM(zbud_unbuddied_list_counts,
-                       zbud_show_unbuddied_list_counts);
-ZCACHE_SYSFS_RO_CUSTOM(zbud_cumul_chunk_counts,
-                       zbud_show_cumul_chunk_counts);
-ZCACHE_SYSFS_RO_CUSTOM(zv_curr_dist_counts,
-                       zv_curr_dist_counts_show);
-ZCACHE_SYSFS_RO_CUSTOM(zv_cumul_dist_counts,
-                       zv_cumul_dist_counts_show);
-
-static struct attribute *zcache_attrs[] = {
-       &zcache_curr_obj_count_attr.attr,
-       &zcache_curr_obj_count_max_attr.attr,
-       &zcache_curr_objnode_count_attr.attr,
-       &zcache_curr_objnode_count_max_attr.attr,
-       &zcache_flush_total_attr.attr,
-       &zcache_flobj_total_attr.attr,
-       &zcache_flush_found_attr.attr,
-       &zcache_flobj_found_attr.attr,
-       &zcache_failed_eph_puts_attr.attr,
-       &zcache_failed_pers_puts_attr.attr,
-       &zcache_compress_poor_attr.attr,
-       &zcache_mean_compress_poor_attr.attr,
-       &zcache_zbud_curr_raw_pages_attr.attr,
-       &zcache_zbud_curr_zpages_attr.attr,
-       &zcache_zbud_curr_zbytes_attr.attr,
-       &zcache_zbud_cumul_zpages_attr.attr,
-       &zcache_zbud_cumul_zbytes_attr.attr,
-       &zcache_zbud_buddied_count_attr.attr,
-       &zcache_zbpg_unused_list_count_attr.attr,
-       &zcache_evicted_raw_pages_attr.attr,
-       &zcache_evicted_unbuddied_pages_attr.attr,
-       &zcache_evicted_buddied_pages_attr.attr,
-       &zcache_failed_get_free_pages_attr.attr,
-       &zcache_failed_alloc_attr.attr,
-       &zcache_put_to_flush_attr.attr,
-       &zcache_zbud_unbuddied_list_counts_attr.attr,
-       &zcache_zbud_cumul_chunk_counts_attr.attr,
-       &zcache_zv_curr_dist_counts_attr.attr,
-       &zcache_zv_cumul_dist_counts_attr.attr,
-       &zcache_zv_max_zsize_attr.attr,
-       &zcache_zv_max_mean_zsize_attr.attr,
-       &zcache_zv_page_count_policy_percent_attr.attr,
-       NULL,
-};
+#ifdef FRONTSWAP_HAS_UNUSE
+static void unswiz(struct tmem_oid oid, u32 index,
+                               unsigned *type, pgoff_t *offset);
 
-static struct attribute_group zcache_attr_group = {
-       .attrs = zcache_attrs,
-       .name = "zcache",
-};
+/*
+ *  Choose an LRU persistent pageframe and attempt to "unuse" it by
+ *  calling frontswap_unuse on both zpages.
+ *
+ *  This is work-in-progress.
+ */
+
+static int zcache_frontswap_unuse(void)
+{
+       struct tmem_handle th[2];
+       int ret = -ENOMEM;
+       int nzbuds, unuse_ret;
+       unsigned type;
+       struct page *newpage1 = NULL, *newpage2 = NULL;
+       struct page *evictpage1 = NULL, *evictpage2 = NULL;
+       pgoff_t offset;
+
+       newpage1 = alloc_page(ZCACHE_GFP_MASK);
+       newpage2 = alloc_page(ZCACHE_GFP_MASK);
+       if (newpage1 == NULL)
+               evictpage1 = zcache_evict_eph_pageframe();
+       if (newpage2 == NULL)
+               evictpage2 = zcache_evict_eph_pageframe();
+       if (evictpage1 == NULL || evictpage2 == NULL)
+               goto free_and_out;
+       /* ok, we have two pages pre-allocated */
+       nzbuds = zbud_make_zombie_lru(&th[0], NULL, NULL, false);
+       if (nzbuds == 0) {
+               ret = -ENOENT;
+               goto free_and_out;
+       }
+       unswiz(th[0].oid, th[0].index, &type, &offset);
+       unuse_ret = frontswap_unuse(type, offset,
+                               newpage1 != NULL ? newpage1 : evictpage1,
+                               ZCACHE_GFP_MASK);
+       if (unuse_ret != 0)
+               goto free_and_out;
+       else if (evictpage1 != NULL)
+               zcache_unacct_page();
+       newpage1 = NULL;
+       evictpage1 = NULL;
+       if (nzbuds == 2) {
+               unswiz(th[1].oid, th[1].index, &type, &offset);
+               unuse_ret = frontswap_unuse(type, offset,
+                               newpage2 != NULL ? newpage2 : evictpage2,
+                               ZCACHE_GFP_MASK);
+               if (unuse_ret != 0) {
+                       goto free_and_out;
+               } else if (evictpage2 != NULL) {
+                       zcache_unacct_page();
+               }
+       }
+       ret = 0;
+       goto out;
+
+free_and_out:
+       if (newpage1 != NULL)
+               __free_page(newpage1);
+       if (newpage2 != NULL)
+               __free_page(newpage2);
+       if (evictpage1 != NULL)
+               zcache_free_page(evictpage1);
+       if (evictpage2 != NULL)
+               zcache_free_page(evictpage2);
+out:
+       return ret;
+}
+#endif
 
-#endif /* CONFIG_SYSFS */
 /*
  * When zcache is disabled ("frozen"), pools can be created and destroyed,
  * but all puts (and thus all other operations that require memory allocation)
@@ -1525,23 +1050,74 @@ static struct attribute_group zcache_attr_group = {
 static bool zcache_freeze;
 
 /*
- * zcache shrinker interface (only useful for ephemeral pages, so zbud only)
+ * This zcache shrinker interface reduces the number of ephemeral pageframes
+ * used by zcache to approximately the same as the total number of LRU_FILE
+ * pageframes in use.
  */
 static int shrink_zcache_memory(struct shrinker *shrink,
                                struct shrink_control *sc)
 {
+       static bool in_progress;
        int ret = -1;
        int nr = sc->nr_to_scan;
-       gfp_t gfp_mask = sc->gfp_mask;
+       int nr_evict = 0;
+       int nr_unuse = 0;
+       struct page *page;
+#ifdef FRONTSWAP_HAS_UNUSE
+       int unuse_ret;
+#endif
 
-       if (nr >= 0) {
-               if (!(gfp_mask & __GFP_FS))
-                       /* does this case really need to be skipped? */
-                       goto out;
-               zbud_evict_pages(nr);
+       if (nr <= 0)
+               goto skip_evict;
+
+       /* don't allow more than one eviction thread at a time */
+       if (in_progress)
+               goto skip_evict;
+
+       in_progress = true;
+
+       /* we are going to ignore nr, and target a different value */
+       zcache_last_active_file_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE);
+       zcache_last_inactive_file_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE);
+       nr_evict = zcache_eph_pageframes - zcache_last_active_file_pageframes +
+               zcache_last_inactive_file_pageframes;
+       while (nr_evict-- > 0) {
+               page = zcache_evict_eph_pageframe();
+               if (page == NULL)
+                       break;
+               zcache_free_page(page);
        }
-       ret = (int)atomic_read(&zcache_zbud_curr_raw_pages);
-out:
+
+       zcache_last_active_anon_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON);
+       zcache_last_inactive_anon_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON);
+       nr_unuse = zcache_pers_pageframes - zcache_last_active_anon_pageframes +
+               zcache_last_inactive_anon_pageframes;
+#ifdef FRONTSWAP_HAS_UNUSE
+       /* rate limit for testing */
+       if (nr_unuse > 32)
+               nr_unuse = 32;
+       while (nr_unuse-- > 0) {
+               unuse_ret = zcache_frontswap_unuse();
+               if (unuse_ret == -ENOMEM)
+                       break;
+       }
+#endif
+       in_progress = false;
+
+skip_evict:
+       /* resample: has changed, but maybe not all the way yet */
+       zcache_last_active_file_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE);
+       zcache_last_inactive_file_pageframes =
+               global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE);
+       ret = zcache_eph_pageframes - zcache_last_active_file_pageframes +
+               zcache_last_inactive_file_pageframes;
+       if (ret < 0)
+               ret = 0;
        return ret;
 }
 
@@ -1554,59 +1130,86 @@ static struct shrinker zcache_shrinker = {
  * zcache shims between cleancache/frontswap ops and tmem
  */
 
-static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
-                               uint32_t index, struct page *page)
+/* FIXME rename these core routines to zcache_tmemput etc? */
+int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
+                               uint32_t index, void *page,
+                               unsigned int size, bool raw, int ephemeral)
 {
        struct tmem_pool *pool;
+       struct tmem_handle th;
        int ret = -1;
+       void *pampd = NULL;
 
        BUG_ON(!irqs_disabled());
        pool = zcache_get_pool_by_id(cli_id, pool_id);
        if (unlikely(pool == NULL))
                goto out;
-       if (!zcache_freeze && zcache_do_preload(pool) == 0) {
-               /* preload does preempt_disable on success */
-               ret = tmem_put(pool, oidp, index, (char *)(page),
-                               PAGE_SIZE, 0, is_ephemeral(pool));
-               if (ret < 0) {
-                       if (is_ephemeral(pool))
+       if (!zcache_freeze) {
+               ret = 0;
+               th.client_id = cli_id;
+               th.pool_id = pool_id;
+               th.oid = *oidp;
+               th.index = index;
+               pampd = zcache_pampd_create((char *)page, size, raw,
+                               ephemeral, &th);
+               if (pampd == NULL) {
+                       ret = -ENOMEM;
+                       if (ephemeral)
                                zcache_failed_eph_puts++;
                        else
                                zcache_failed_pers_puts++;
+               } else {
+                       if (ramster_enabled)
+                               ramster_do_preload_flnode(pool);
+                       ret = tmem_put(pool, oidp, index, 0, pampd);
+                       if (ret < 0)
+                               BUG();
                }
+               zcache_put_pool(pool);
        } else {
                zcache_put_to_flush++;
+               if (ramster_enabled)
+                       ramster_do_preload_flnode(pool);
                if (atomic_read(&pool->obj_count) > 0)
                        /* the put fails whether the flush succeeds or not */
                        (void)tmem_flush_page(pool, oidp, index);
+               zcache_put_pool(pool);
        }
-
-       zcache_put_pool(pool);
 out:
        return ret;
 }
 
-static int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp,
-                               uint32_t index, struct page *page)
+int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp,
+                               uint32_t index, void *page,
+                               size_t *sizep, bool raw, int get_and_free)
 {
        struct tmem_pool *pool;
        int ret = -1;
-       unsigned long flags;
-       size_t size = PAGE_SIZE;
+       bool eph;
 
-       local_irq_save(flags);
+       if (!raw) {
+               BUG_ON(irqs_disabled());
+               BUG_ON(in_softirq());
+       }
        pool = zcache_get_pool_by_id(cli_id, pool_id);
+       eph = is_ephemeral(pool);
        if (likely(pool != NULL)) {
                if (atomic_read(&pool->obj_count) > 0)
                        ret = tmem_get(pool, oidp, index, (char *)(page),
-                                       &size, 0, is_ephemeral(pool));
+                                       sizep, raw, get_and_free);
                zcache_put_pool(pool);
        }
-       local_irq_restore(flags);
+       WARN_ONCE((!is_ephemeral(pool) && (ret != 0)),
+                       "zcache_get fails on persistent pool, "
+                       "bad things are very likely to happen soon\n");
+#ifdef RAMSTER_TESTING
+       if (ret != 0 && ret != -1 && !(ret == -EINVAL && is_ephemeral(pool)))
+               pr_err("TESTING zcache_get tmem_get returns ret=%d\n", ret);
+#endif
        return ret;
 }
 
-static int zcache_flush_page(int cli_id, int pool_id,
+int zcache_flush_page(int cli_id, int pool_id,
                                struct tmem_oid *oidp, uint32_t index)
 {
        struct tmem_pool *pool;
@@ -1616,6 +1219,8 @@ static int zcache_flush_page(int cli_id, int pool_id,
        local_irq_save(flags);
        zcache_flush_total++;
        pool = zcache_get_pool_by_id(cli_id, pool_id);
+       if (ramster_enabled)
+               ramster_do_preload_flnode(pool);
        if (likely(pool != NULL)) {
                if (atomic_read(&pool->obj_count) > 0)
                        ret = tmem_flush_page(pool, oidp, index);
@@ -1627,7 +1232,7 @@ static int zcache_flush_page(int cli_id, int pool_id,
        return ret;
 }
 
-static int zcache_flush_object(int cli_id, int pool_id,
+int zcache_flush_object(int cli_id, int pool_id,
                                struct tmem_oid *oidp)
 {
        struct tmem_pool *pool;
@@ -1637,6 +1242,8 @@ static int zcache_flush_object(int cli_id, int pool_id,
        local_irq_save(flags);
        zcache_flobj_total++;
        pool = zcache_get_pool_by_id(cli_id, pool_id);
+       if (ramster_enabled)
+               ramster_do_preload_flnode(pool);
        if (likely(pool != NULL)) {
                if (atomic_read(&pool->obj_count) > 0)
                        ret = tmem_flush_object(pool, oidp);
@@ -1648,24 +1255,25 @@ static int zcache_flush_object(int cli_id, int pool_id,
        return ret;
 }
 
-static int zcache_destroy_pool(int cli_id, int pool_id)
+static int zcache_client_destroy_pool(int cli_id, int pool_id)
 {
        struct tmem_pool *pool = NULL;
-       struct zcache_client *cli;
+       struct zcache_client *cli = NULL;
        int ret = -1;
 
        if (pool_id < 0)
                goto out;
-
-       cli = get_zcache_client(cli_id);
+       if (cli_id == LOCAL_CLIENT)
+               cli = &zcache_host;
+       else if ((unsigned int)cli_id < MAX_CLIENTS)
+               cli = &zcache_clients[cli_id];
        if (cli == NULL)
                goto out;
-
        atomic_inc(&cli->refcount);
-       pool = idr_find(&cli->tmem_pools, pool_id);
+       pool = cli->tmem_pools[pool_id];
        if (pool == NULL)
                goto out;
-       idr_remove(&cli->tmem_pools, pool_id);
+       cli->tmem_pools[pool_id] = NULL;
        /* wait for pool activity on other cpus to quiesce */
        while (atomic_read(&pool->refcount) != 0)
                ;
@@ -1674,58 +1282,124 @@ static int zcache_destroy_pool(int cli_id, int pool_id)
        ret = tmem_destroy_pool(pool);
        local_bh_enable();
        kfree(pool);
-       pr_info("zcache: destroyed pool id=%d, cli_id=%d\n",
-                       pool_id, cli_id);
+       if (cli_id == LOCAL_CLIENT)
+               pr_info("%s: destroyed local pool id=%d\n", namestr, pool_id);
+       else
+               pr_info("%s: destroyed pool id=%d, client=%d\n",
+                               namestr, pool_id, cli_id);
 out:
        return ret;
 }
 
-static int zcache_new_pool(uint16_t cli_id, uint32_t flags)
+int zcache_new_pool(uint16_t cli_id, uint32_t flags)
 {
        int poolid = -1;
        struct tmem_pool *pool;
        struct zcache_client *cli = NULL;
-       int r;
 
-       cli = get_zcache_client(cli_id);
+       if (cli_id == LOCAL_CLIENT)
+               cli = &zcache_host;
+       else if ((unsigned int)cli_id < MAX_CLIENTS)
+               cli = &zcache_clients[cli_id];
        if (cli == NULL)
                goto out;
-
        atomic_inc(&cli->refcount);
        pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC);
        if (pool == NULL) {
-               pr_info("zcache: pool creation failed: out of memory\n");
+               pr_info("%s: pool creation failed: out of memory\n", namestr);
                goto out;
        }
 
-       do {
-               r = idr_pre_get(&cli->tmem_pools, GFP_ATOMIC);
-               if (r != 1) {
-                       kfree(pool);
-                       pr_info("zcache: pool creation failed: out of memory\n");
-                       goto out;
-               }
-               r = idr_get_new(&cli->tmem_pools, pool, &poolid);
-       } while (r == -EAGAIN);
-       if (r) {
-               pr_info("zcache: pool creation failed: error %d\n", r);
+       for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++)
+               if (cli->tmem_pools[poolid] == NULL)
+                       break;
+       if (poolid >= MAX_POOLS_PER_CLIENT) {
+               pr_info("%s: pool creation failed: max exceeded\n", namestr);
                kfree(pool);
+               poolid = -1;
                goto out;
        }
-
        atomic_set(&pool->refcount, 0);
        pool->client = cli;
        pool->pool_id = poolid;
        tmem_new_pool(pool, flags);
-       pr_info("zcache: created %s tmem pool, id=%d, client=%d\n",
-               flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
-               poolid, cli_id);
+       cli->tmem_pools[poolid] = pool;
+       if (cli_id == LOCAL_CLIENT)
+               pr_info("%s: created %s local tmem pool, id=%d\n", namestr,
+                       flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
+                       poolid);
+       else
+               pr_info("%s: created %s tmem pool, id=%d, client=%d\n", namestr,
+                       flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
+                       poolid, cli_id);
 out:
        if (cli != NULL)
                atomic_dec(&cli->refcount);
        return poolid;
 }
 
+static int zcache_local_new_pool(uint32_t flags)
+{
+       return zcache_new_pool(LOCAL_CLIENT, flags);
+}
+
+int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph)
+{
+       struct tmem_pool *pool;
+       struct zcache_client *cli = NULL;
+       uint32_t flags = eph ? 0 : TMEM_POOL_PERSIST;
+       int ret = -1;
+
+       BUG_ON(!ramster_enabled);
+       if (cli_id == LOCAL_CLIENT)
+               goto out;
+       if (pool_id >= MAX_POOLS_PER_CLIENT)
+               goto out;
+       if (cli_id >= MAX_CLIENTS)
+               goto out;
+
+       cli = &zcache_clients[cli_id];
+       if ((eph && disable_cleancache) || (!eph && disable_frontswap)) {
+               pr_err("zcache_autocreate_pool: pool type disabled\n");
+               goto out;
+       }
+       if (!cli->allocated) {
+               if (zcache_new_client(cli_id)) {
+                       pr_err("zcache_autocreate_pool: can't create client\n");
+                       goto out;
+               }
+               cli = &zcache_clients[cli_id];
+       }
+       atomic_inc(&cli->refcount);
+       pool = cli->tmem_pools[pool_id];
+       if (pool != NULL) {
+               if (pool->persistent && eph) {
+                       pr_err("zcache_autocreate_pool: type mismatch\n");
+                       goto out;
+               }
+               ret = 0;
+               goto out;
+       }
+       pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL);
+       if (pool == NULL) {
+               pr_info("%s: pool creation failed: out of memory\n", namestr);
+               goto out;
+       }
+       atomic_set(&pool->refcount, 0);
+       pool->client = cli;
+       pool->pool_id = pool_id;
+       tmem_new_pool(pool, flags);
+       cli->tmem_pools[pool_id] = pool;
+       pr_info("%s: AUTOcreated %s tmem poolid=%d, for remote client=%d\n",
+               namestr, flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
+               pool_id, cli_id);
+       ret = 0;
+out:
+       if (cli != NULL)
+               atomic_dec(&cli->refcount);
+       return ret;
+}
+
 /**********
  * Two kernel functionalities currently can be layered on top of tmem.
  * These are "cleancache" which is used as a second-chance cache for clean
@@ -1734,7 +1408,6 @@ out:
  * to translate in-kernel semantics to zcache semantics.
  */
 
-#ifdef CONFIG_CLEANCACHE
 static void zcache_cleancache_put_page(int pool_id,
                                        struct cleancache_filekey key,
                                        pgoff_t index, struct page *page)
@@ -1742,8 +1415,13 @@ static void zcache_cleancache_put_page(int pool_id,
        u32 ind = (u32) index;
        struct tmem_oid oid = *(struct tmem_oid *)&key;
 
+       if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) {
+               zcache_eph_nonactive_puts_ignored++;
+               return;
+       }
        if (likely(ind == index))
-               (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index, page);
+               (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index,
+                                       page, PAGE_SIZE, false, 1);
 }
 
 static int zcache_cleancache_get_page(int pool_id,
@@ -1752,10 +1430,16 @@ static int zcache_cleancache_get_page(int pool_id,
 {
        u32 ind = (u32) index;
        struct tmem_oid oid = *(struct tmem_oid *)&key;
+       size_t size;
        int ret = -1;
 
-       if (likely(ind == index))
-               ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index, page);
+       if (likely(ind == index)) {
+               ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index,
+                                       page, &size, false, 0);
+               BUG_ON(ret >= 0 && size != PAGE_SIZE);
+               if (ret == 0)
+                       SetPageWasActive(page);
+       }
        return ret;
 }
 
@@ -1781,7 +1465,7 @@ static void zcache_cleancache_flush_inode(int pool_id,
 static void zcache_cleancache_flush_fs(int pool_id)
 {
        if (pool_id >= 0)
-               (void)zcache_destroy_pool(LOCAL_CLIENT, pool_id);
+               (void)zcache_client_destroy_pool(LOCAL_CLIENT, pool_id);
 }
 
 static int zcache_cleancache_init_fs(size_t pagesize)
@@ -1789,7 +1473,7 @@ static int zcache_cleancache_init_fs(size_t pagesize)
        BUG_ON(sizeof(struct cleancache_filekey) !=
                                sizeof(struct tmem_oid));
        BUG_ON(pagesize != PAGE_SIZE);
-       return zcache_new_pool(LOCAL_CLIENT, 0);
+       return zcache_local_new_pool(0);
 }
 
 static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize)
@@ -1798,7 +1482,7 @@ static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize)
        BUG_ON(sizeof(struct cleancache_filekey) !=
                                sizeof(struct tmem_oid));
        BUG_ON(pagesize != PAGE_SIZE);
-       return zcache_new_pool(LOCAL_CLIENT, 0);
+       return zcache_local_new_pool(0);
 }
 
 static struct cleancache_ops zcache_cleancache_ops = {
@@ -1818,17 +1502,15 @@ struct cleancache_ops zcache_cleancache_register_ops(void)
 
        return old_ops;
 }
-#endif
 
-#ifdef CONFIG_FRONTSWAP
 /* a single tmem poolid is used for all frontswap "types" (swapfiles) */
-static int zcache_frontswap_poolid = -1;
+static int zcache_frontswap_poolid __read_mostly = -1;
 
 /*
  * Swizzling increases objects per swaptype, increasing tmem concurrency
  * for heavy swaploads.  Later, larger nr_cpus -> larger SWIZ_BITS
  * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from
- * frontswap_load(), but has side-effects. Hence using 8.
+ * frontswap_get_page(), but has side-effects. Hence using 8.
  */
 #define SWIZ_BITS              8
 #define SWIZ_MASK              ((1 << SWIZ_BITS) - 1)
@@ -1842,8 +1524,18 @@ static inline struct tmem_oid oswiz(unsigned type, u32 ind)
        return oid;
 }
 
-static int zcache_frontswap_store(unsigned type, pgoff_t offset,
-                                  struct page *page)
+#ifdef FRONTSWAP_HAS_UNUSE
+static void unswiz(struct tmem_oid oid, u32 index,
+                               unsigned *type, pgoff_t *offset)
+{
+       *type = (unsigned)(oid.oid[0] >> SWIZ_BITS);
+       *offset = (pgoff_t)((index << SWIZ_BITS) |
+                       (oid.oid[0] & SWIZ_MASK));
+}
+#endif
+
+static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
+                                       struct page *page)
 {
        u64 ind64 = (u64)offset;
        u32 ind = (u32)offset;
@@ -1852,29 +1544,44 @@ static int zcache_frontswap_store(unsigned type, pgoff_t offset,
        unsigned long flags;
 
        BUG_ON(!PageLocked(page));
+       if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) {
+               zcache_pers_nonactive_puts_ignored++;
+               ret = -ERANGE;
+               goto out;
+       }
        if (likely(ind64 == ind)) {
                local_irq_save(flags);
                ret = zcache_put_page(LOCAL_CLIENT, zcache_frontswap_poolid,
-                                       &oid, iswiz(ind), page);
+                                       &oid, iswiz(ind),
+                                       page, PAGE_SIZE, false, 0);
                local_irq_restore(flags);
        }
+out:
        return ret;
 }
 
 /* returns 0 if the page was successfully gotten from frontswap, -1 if
  * was not present (should never happen!) */
-static int zcache_frontswap_load(unsigned type, pgoff_t offset,
-                                  struct page *page)
+static int zcache_frontswap_get_page(unsigned type, pgoff_t offset,
+                                       struct page *page)
 {
        u64 ind64 = (u64)offset;
        u32 ind = (u32)offset;
        struct tmem_oid oid = oswiz(type, ind);
-       int ret = -1;
+       size_t size;
+       int ret = -1, get_and_free;
 
+       if (frontswap_has_exclusive_gets)
+               get_and_free = 1;
+       else
+               get_and_free = -1;
        BUG_ON(!PageLocked(page));
-       if (likely(ind64 == ind))
+       if (likely(ind64 == ind)) {
                ret = zcache_get_page(LOCAL_CLIENT, zcache_frontswap_poolid,
-                                       &oid, iswiz(ind), page);
+                                       &oid, iswiz(ind),
+                                       page, &size, false, get_and_free);
+               BUG_ON(ret >= 0 && size != PAGE_SIZE);
+       }
        return ret;
 }
 
@@ -1908,12 +1615,12 @@ static void zcache_frontswap_init(unsigned ignored)
        /* a single tmem poolid is used for all frontswap "types" (swapfiles) */
        if (zcache_frontswap_poolid < 0)
                zcache_frontswap_poolid =
-                       zcache_new_pool(LOCAL_CLIENT, TMEM_POOL_PERSIST);
+                       zcache_local_new_pool(TMEM_POOL_PERSIST);
 }
 
 static struct frontswap_ops zcache_frontswap_ops = {
-       .store = zcache_frontswap_store,
-       .load = zcache_frontswap_load,
+       .store = zcache_frontswap_put_page,
+       .load = zcache_frontswap_get_page,
        .invalidate_page = zcache_frontswap_flush_page,
        .invalidate_area = zcache_frontswap_flush_area,
        .init = zcache_frontswap_init
@@ -1926,16 +1633,13 @@ struct frontswap_ops zcache_frontswap_register_ops(void)
 
        return old_ops;
 }
-#endif
 
 /*
  * zcache initialization
- * NOTE FOR NOW zcache MUST BE PROVIDED AS A KERNEL BOOT PARAMETER OR
- * NOTHING HAPPENS!
+ * NOTE FOR NOW zcache or ramster MUST BE PROVIDED AS A KERNEL BOOT PARAMETER
+ * OR NOTHING HAPPENS!
  */
 
-static int zcache_enabled;
-
 static int __init enable_zcache(char *s)
 {
        zcache_enabled = 1;
@@ -1943,28 +1647,58 @@ static int __init enable_zcache(char *s)
 }
 __setup("zcache", enable_zcache);
 
-/* allow independent dynamic disabling of cleancache and frontswap */
+static int __init enable_ramster(char *s)
+{
+       zcache_enabled = 1;
+#ifdef CONFIG_RAMSTER
+       ramster_enabled = 1;
+#endif
+       return 1;
+}
+__setup("ramster", enable_ramster);
 
-static int use_cleancache = 1;
+/* allow independent dynamic disabling of cleancache and frontswap */
 
 static int __init no_cleancache(char *s)
 {
-       use_cleancache = 0;
+       disable_cleancache = 1;
        return 1;
 }
 
 __setup("nocleancache", no_cleancache);
 
-static int use_frontswap = 1;
-
 static int __init no_frontswap(char *s)
 {
-       use_frontswap = 0;
+       disable_frontswap = 1;
        return 1;
 }
 
 __setup("nofrontswap", no_frontswap);
 
+static int __init no_frontswap_exclusive_gets(char *s)
+{
+       frontswap_has_exclusive_gets = false;
+       return 1;
+}
+
+__setup("nofrontswapexclusivegets", no_frontswap_exclusive_gets);
+
+static int __init no_frontswap_ignore_nonactive(char *s)
+{
+       disable_frontswap_ignore_nonactive = 1;
+       return 1;
+}
+
+__setup("nofrontswapignorenonactive", no_frontswap_ignore_nonactive);
+
+static int __init no_cleancache_ignore_nonactive(char *s)
+{
+       disable_cleancache_ignore_nonactive = 1;
+       return 1;
+}
+
+__setup("nocleancacheignorenonactive", no_cleancache_ignore_nonactive);
+
 static int __init enable_zcache_compressor(char *s)
 {
        strncpy(zcache_comp_name, s, ZCACHE_COMP_NAME_SZ);
@@ -2007,14 +1741,13 @@ static int __init zcache_init(void)
 {
        int ret = 0;
 
-#ifdef CONFIG_SYSFS
-       ret = sysfs_create_group(mm_kobj, &zcache_attr_group);
-       if (ret) {
-               pr_err("zcache: can't create sysfs\n");
-               goto out;
+       if (ramster_enabled) {
+               namestr = "ramster";
+               ramster_register_pamops(&zcache_pamops);
        }
-#endif /* CONFIG_SYSFS */
-
+#ifdef CONFIG_DEBUG_FS
+       zcache_debugfs_init();
+#endif
        if (zcache_enabled) {
                unsigned int cpu;
 
@@ -2022,12 +1755,13 @@ static int __init zcache_init(void)
                tmem_register_pamops(&zcache_pamops);
                ret = register_cpu_notifier(&zcache_cpu_notifier_block);
                if (ret) {
-                       pr_err("zcache: can't register cpu notifier\n");
+                       pr_err("%s: can't register cpu notifier\n", namestr);
                        goto out;
                }
                ret = zcache_comp_init();
                if (ret) {
-                       pr_err("zcache: compressor initialization failed\n");
+                       pr_err("%s: compressor initialization failed\n",
+                               namestr);
                        goto out;
                }
                for_each_online_cpu(cpu) {
@@ -2042,36 +1776,45 @@ static int __init zcache_init(void)
                                sizeof(struct tmem_obj), 0, 0, NULL);
        ret = zcache_new_client(LOCAL_CLIENT);
        if (ret) {
-               pr_err("zcache: can't create client\n");
+               pr_err("%s: can't create client\n", namestr);
                goto out;
        }
-
-#ifdef CONFIG_CLEANCACHE
-       if (zcache_enabled && use_cleancache) {
+       zbud_init();
+       if (zcache_enabled && !disable_cleancache) {
                struct cleancache_ops old_ops;
 
-               zbud_init();
                register_shrinker(&zcache_shrinker);
                old_ops = zcache_cleancache_register_ops();
-               pr_info("zcache: cleancache enabled using kernel "
-                       "transcendent memory and compression buddies\n");
+               pr_info("%s: cleancache enabled using kernel transcendent "
+                       "memory and compression buddies\n", namestr);
+#ifdef ZCACHE_DEBUG
+               pr_info("%s: cleancache: ignorenonactive = %d\n",
+                       namestr, !disable_cleancache_ignore_nonactive);
+#endif
                if (old_ops.init_fs != NULL)
-                       pr_warning("zcache: cleancache_ops overridden");
+                       pr_warn("%s: cleancache_ops overridden\n", namestr);
        }
-#endif
-#ifdef CONFIG_FRONTSWAP
-       if (zcache_enabled && use_frontswap) {
+       if (zcache_enabled && !disable_frontswap) {
                struct frontswap_ops old_ops;
 
                old_ops = zcache_frontswap_register_ops();
-               pr_info("zcache: frontswap enabled using kernel "
-                       "transcendent memory and zsmalloc\n");
+               if (frontswap_has_exclusive_gets)
+                       frontswap_tmem_exclusive_gets(true);
+               pr_info("%s: frontswap enabled using kernel transcendent "
+                       "memory and compression buddies\n", namestr);
+#ifdef ZCACHE_DEBUG
+               pr_info("%s: frontswap: excl gets = %d active only = %d\n",
+                       namestr, frontswap_has_exclusive_gets,
+                       !disable_frontswap_ignore_nonactive);
+#endif
                if (old_ops.init != NULL)
-                       pr_warning("zcache: frontswap_ops overridden");
+                       pr_warn("%s: frontswap_ops overridden\n", namestr);
        }
-#endif
+       if (ramster_enabled)
+               ramster_init(!disable_cleancache, !disable_frontswap,
+                               frontswap_has_exclusive_gets);
 out:
        return ret;
 }
 
-module_init(zcache_init)
+late_initcall(zcache_init);
index be5abe8e7943af5a6238ef868218906557e15807..983314c41349666c08213fe6f0dbd0e1509d4d9e 100644 (file)
@@ -14,7 +14,7 @@ config ZRAM
          disks and maybe many more.
 
          See zram.txt for more information.
-         Project home: http://compcache.googlecode.com/
+         Project home: <https://compcache.googlecode.com/>
 
 config ZRAM_DEBUG
        bool "Compressed RAM block device debug support"
index f2a73bd739fb94b750e66e1ee2c931e3c971a52a..77a3f0dfba770821ebe8aef3ce3229bfa1163078 100644 (file)
@@ -40,17 +40,7 @@ static int zram_major;
 struct zram *zram_devices;
 
 /* Module params (documentation at end) */
-static unsigned int num_devices;
-
-static void zram_stat_inc(u32 *v)
-{
-       *v = *v + 1;
-}
-
-static void zram_stat_dec(u32 *v)
-{
-       *v = *v - 1;
-}
+static unsigned int num_devices = 1;
 
 static void zram_stat64_add(struct zram *zram, u64 *v, u64 inc)
 {
@@ -126,8 +116,7 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
                "\tMemory Size: %zu kB\n"
                "\tSize you selected: %llu kB\n"
                "Continuing anyway ...\n",
-               totalram_bytes >> 10, zram->disksize
-               );
+               totalram_bytes >> 10, zram->disksize >> 10);
        }
 
        zram->disksize &= PAGE_MASK;
@@ -145,22 +134,22 @@ static void zram_free_page(struct zram *zram, size_t index)
                 */
                if (zram_test_flag(zram, index, ZRAM_ZERO)) {
                        zram_clear_flag(zram, index, ZRAM_ZERO);
-                       zram_stat_dec(&zram->stats.pages_zero);
+                       zram->stats.pages_zero--;
                }
                return;
        }
 
        if (unlikely(size > max_zpage_size))
-               zram_stat_dec(&zram->stats.bad_compress);
+               zram->stats.bad_compress--;
 
        zs_free(zram->mem_pool, handle);
 
        if (size <= PAGE_SIZE / 2)
-               zram_stat_dec(&zram->stats.good_compress);
+               zram->stats.good_compress--;
 
        zram_stat64_sub(zram, &zram->stats.compr_size,
                        zram->table[index].size);
-       zram_stat_dec(&zram->stats.pages_stored);
+       zram->stats.pages_stored--;
 
        zram->table[index].handle = 0;
        zram->table[index].size = 0;
@@ -310,9 +299,10 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        }
 
        if (page_zero_filled(uncmem)) {
-               if (!is_partial_io(bvec))
-                       kunmap_atomic(user_mem);
-               zram_stat_inc(&zram->stats.pages_zero);
+               kunmap_atomic(user_mem);
+               if (is_partial_io(bvec))
+                       kfree(uncmem);
+               zram->stats.pages_zero++;
                zram_set_flag(zram, index, ZRAM_ZERO);
                ret = 0;
                goto out;
@@ -333,7 +323,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
        }
 
        if (unlikely(clen > max_zpage_size)) {
-               zram_stat_inc(&zram->stats.bad_compress);
+               zram->stats.bad_compress++;
                clen = PAGE_SIZE;
                src = NULL;
                if (is_partial_io(bvec))
@@ -362,9 +352,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 
        /* Update stats */
        zram_stat64_add(zram, &zram->stats.compr_size, clen);
-       zram_stat_inc(&zram->stats.pages_stored);
+       zram->stats.pages_stored++;
        if (clen <= PAGE_SIZE / 2)
-               zram_stat_inc(&zram->stats.good_compress);
+               zram->stats.good_compress++;
 
 out:
        if (is_partial_io(bvec))
@@ -724,13 +714,7 @@ static int __init zram_init(void)
                goto out;
        }
 
-       if (!num_devices) {
-               pr_info("num_devices not specified. Using default: 1\n");
-               num_devices = 1;
-       }
-
        /* Allocate the device array and initialize each one */
-       pr_info("Creating %u devices ...\n", num_devices);
        zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
        if (!zram_devices) {
                ret = -ENOMEM;
@@ -743,6 +727,8 @@ static int __init zram_init(void)
                        goto free_devices;
        }
 
+       pr_info("Created %u device(s) ...\n", num_devices);
+
        return 0;
 
 free_devices:
index 09a9d35d436ff6075f256ec02f9e029e9e26a455..eb0077261ac617276c3447939ce58ed6792df414 100644 (file)
@@ -798,6 +798,17 @@ fail:
        return notifier_to_errno(ret);
 }
 
+/**
+ * zs_create_pool - Creates an allocation pool to work from.
+ * @name: name of the pool to be created
+ * @flags: allocation flags used when growing pool
+ *
+ * This function must be called before anything when using
+ * the zsmalloc allocator.
+ *
+ * On success, a pointer to the newly created pool is returned,
+ * otherwise NULL.
+ */
 struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
 {
        int i, ovhd_size;
index 0aa5f4c42ae6af5c7b26b7fc4f8f6cee9af72c63..ecefb7311dd61c2310114c71a0e2f54608ce3597 100644 (file)
@@ -157,4 +157,42 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 */
 int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
                        u32 field_index, s32 *value);
+
+/* hid-sensor-attributes */
+
+/* Common hid sensor iio structure */
+struct hid_sensor_common {
+       struct hid_sensor_hub_device *hsdev;
+       struct platform_device *pdev;
+       unsigned usage_id;
+       bool data_ready;
+       struct hid_sensor_hub_attribute_info poll;
+       struct hid_sensor_hub_attribute_info report_state;
+       struct hid_sensor_hub_attribute_info power_state;
+       struct hid_sensor_hub_attribute_info sensitivity;
+};
+
+/*Convert from hid unit expo to regular exponent*/
+static inline int hid_sensor_convert_exponent(int unit_expo)
+{
+       if (unit_expo < 0x08)
+               return unit_expo;
+       else if (unit_expo <= 0x0f)
+               return -(0x0f-unit_expo+1);
+       else
+               return 0;
+}
+
+int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
+                                       u32 usage_id,
+                                       struct hid_sensor_common *st);
+int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
+                                       int val1, int val2);
+int hid_sensor_read_raw_hyst_value(struct hid_sensor_common *st,
+                                       int *val1, int *val2);
+int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
+                                       int val1, int val2);
+int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
+                                       int *val1, int *val2);
+
 #endif
index 55f277372fed00e6b454d9fd7249bd531ccbbb8d..6f24446e76699b295eef42e6e8946388766a121e 100644 (file)
 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Y_AXIS               0x200486
 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX_Z_AXIS               0x200487
 
+/* Time (2000a0) */
+#define HID_USAGE_SENSOR_TIME                                  0x2000a0
+#define HID_USAGE_SENSOR_TIME_YEAR                             0x200521
+#define HID_USAGE_SENSOR_TIME_MONTH                            0x200522
+#define HID_USAGE_SENSOR_TIME_DAY                              0x200523
+#define HID_USAGE_SENSOR_TIME_HOUR                             0x200525
+#define HID_USAGE_SENSOR_TIME_MINUTE                           0x200526
+#define HID_USAGE_SENSOR_TIME_SECOND                           0x200527
+
 /* Units */
 #define HID_USAGE_SENSOR_UNITS_NOT_SPECIFIED                   0x00
 #define HID_USAGE_SENSOR_UNITS_LUX                             0x01