Merge 4.0-rc5 into staging-testing
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Mar 2015 20:36:48 +0000 (21:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Mar 2015 20:36:48 +0000 (21:36 +0100)
We want the staging tree fixes that are upstream here as well to prevent
merge conflicts from people trying to clean up code.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
660 files changed:
MAINTAINERS
drivers/dma/ste_dma40.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/ion/ion.c
drivers/staging/comedi/Kconfig
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedi_pci.c
drivers/staging/comedi/comedi_pci.h [new file with mode: 0644]
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/8253.h [deleted file]
drivers/staging/comedi/drivers/8255_pci.c
drivers/staging/comedi/drivers/Makefile
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_2032.c
drivers/staging/comedi/drivers/addi_apci_2200.c
drivers/staging/comedi/drivers/addi_apci_3120.c
drivers/staging/comedi/drivers/addi_apci_3501.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c
drivers/staging/comedi/drivers/addi_watchdog.c
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/adq12b.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/adv_pci1723.c
drivers/staging/comedi/drivers/adv_pci1724.c
drivers/staging/comedi/drivers/adv_pci_dio.c
drivers/staging/comedi/drivers/amplc_dio200_common.c
drivers/staging/comedi/drivers/amplc_dio200_pci.c
drivers/staging/comedi/drivers/amplc_pc236_common.c
drivers/staging/comedi/drivers/amplc_pci224.c
drivers/staging/comedi/drivers/amplc_pci230.c
drivers/staging/comedi/drivers/amplc_pci236.c
drivers/staging/comedi/drivers/amplc_pci263.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_8254.c [new file with mode: 0644]
drivers/staging/comedi/drivers/comedi_8254.h [new file with mode: 0644]
drivers/staging/comedi/drivers/comedi_bond.c
drivers/staging/comedi/drivers/comedi_isadma.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_pci.c
drivers/staging/comedi/drivers/das16.c
drivers/staging/comedi/drivers/das16m1.c
drivers/staging/comedi/drivers/das1800.c
drivers/staging/comedi/drivers/das6402.c
drivers/staging/comedi/drivers/das800.c
drivers/staging/comedi/drivers/dmm32at.c
drivers/staging/comedi/drivers/dt2801.c
drivers/staging/comedi/drivers/dt2811.c
drivers/staging/comedi/drivers/dt2814.c
drivers/staging/comedi/drivers/dt2815.c
drivers/staging/comedi/drivers/dt282x.c
drivers/staging/comedi/drivers/dt3000.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/mf6x4.c
drivers/staging/comedi/drivers/mite.c
drivers/staging/comedi/drivers/mite.h
drivers/staging/comedi/drivers/mpc624.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_at_a2150.c
drivers/staging/comedi/drivers/ni_at_ao.c
drivers/staging/comedi/drivers/ni_atmio.c
drivers/staging/comedi/drivers/ni_atmio16d.c
drivers/staging/comedi/drivers/ni_labpc.c
drivers/staging/comedi/drivers/ni_labpc.h
drivers/staging/comedi/drivers/ni_labpc_common.c
drivers/staging/comedi/drivers/ni_labpc_cs.c
drivers/staging/comedi/drivers/ni_labpc_pci.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_pcidio.c
drivers/staging/comedi/drivers/ni_pcimio.c
drivers/staging/comedi/drivers/ni_tiocmd.c
drivers/staging/comedi/drivers/pcl711.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.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/serial2002.c
drivers/staging/comedi/drivers/ssv_dnp.c
drivers/staging/comedi/drivers/unioxx5.c
drivers/staging/comedi/drivers/usbdux.c
drivers/staging/comedi/drivers/usbduxfast.c
drivers/staging/comedi/drivers/usbduxsigma.c
drivers/staging/comedi/kcomedilib/kcomedilib_main.c
drivers/staging/dgap/dgap.c
drivers/staging/dgap/dgap.h
drivers/staging/dgnc/Makefile
drivers/staging/dgnc/TODO
drivers/staging/dgnc/dgnc_cls.c
drivers/staging/dgnc/dgnc_cls.h
drivers/staging/dgnc/dgnc_driver.c
drivers/staging/dgnc/dgnc_driver.h
drivers/staging/dgnc/dgnc_kcompat.h
drivers/staging/dgnc/dgnc_mgmt.c
drivers/staging/dgnc/dgnc_mgmt.h
drivers/staging/dgnc/dgnc_neo.c
drivers/staging/dgnc/dgnc_neo.h
drivers/staging/dgnc/dgnc_pci.h
drivers/staging/dgnc/dgnc_sysfs.c
drivers/staging/dgnc/dgnc_sysfs.h
drivers/staging/dgnc/dgnc_tty.c
drivers/staging/dgnc/dgnc_tty.h
drivers/staging/dgnc/dgnc_types.h
drivers/staging/dgnc/digi.h
drivers/staging/dgnc/dpacompat.h
drivers/staging/emxx_udc/emxx_udc.c
drivers/staging/emxx_udc/emxx_udc.h
drivers/staging/fbtft/README
drivers/staging/fbtft/fb_agm1264k-fl.c
drivers/staging/fbtft/fb_bd663474.c
drivers/staging/fbtft/fb_hx8340bn.c
drivers/staging/fbtft/fb_hx8353d.c
drivers/staging/fbtft/fb_ili9320.c
drivers/staging/fbtft/fb_ili9340.c
drivers/staging/fbtft/fb_ili9486.c
drivers/staging/fbtft/fb_pcd8544.c
drivers/staging/fbtft/fb_ra8875.c
drivers/staging/fbtft/fb_s6d02a1.c
drivers/staging/fbtft/fb_s6d1121.c
drivers/staging/fbtft/fb_ssd1306.c
drivers/staging/fbtft/fb_ssd1331.c
drivers/staging/fbtft/fb_ssd1351.c
drivers/staging/fbtft/fb_st7735r.c
drivers/staging/fbtft/fb_tls8204.c
drivers/staging/fbtft/fb_uc1701.c
drivers/staging/fbtft/fb_upd161704.c
drivers/staging/fbtft/fb_watterott.c
drivers/staging/fbtft/fbtft-bus.c
drivers/staging/fbtft/fbtft-core.c
drivers/staging/fbtft/fbtft-io.c
drivers/staging/fbtft/fbtft-sysfs.c
drivers/staging/fbtft/fbtft_device.c
drivers/staging/fbtft/internal.h [new file with mode: 0644]
drivers/staging/fsl-mc/Kconfig [new file with mode: 0644]
drivers/staging/fsl-mc/Makefile [new file with mode: 0644]
drivers/staging/fsl-mc/TODO [new file with mode: 0644]
drivers/staging/fsl-mc/bus/Kconfig [new file with mode: 0644]
drivers/staging/fsl-mc/bus/Makefile [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpbp.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpmcp-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpmcp.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpmcp.h [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpmng-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dpmng.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dprc-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dprc-driver.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/dprc.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/mc-allocator.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/mc-bus.c [new file with mode: 0644]
drivers/staging/fsl-mc/bus/mc-sys.c [new file with mode: 0644]
drivers/staging/fsl-mc/include/dpbp-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/dpbp.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/dpcon-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/dpmng.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/dprc.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/mc-cmd.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/mc-private.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/mc-sys.h [new file with mode: 0644]
drivers/staging/fsl-mc/include/mc.h [new file with mode: 0644]
drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c
drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
drivers/staging/ft1000/ft1000-usb/ft1000_download.c
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
drivers/staging/fwserial/fwserial.c
drivers/staging/gdm724x/gdm_lte.c
drivers/staging/gdm724x/gdm_mux.c
drivers/staging/gdm724x/gdm_usb.c
drivers/staging/gdm72xx/gdm_qos.c
drivers/staging/gdm72xx/gdm_sdio.c
drivers/staging/gdm72xx/gdm_wimax.c
drivers/staging/goldfish/goldfish_audio.c
drivers/staging/goldfish/goldfish_nand.c
drivers/staging/gs_fpgaboot/gs_fpgaboot.c
drivers/staging/i2o/bus-osm.c
drivers/staging/i2o/config-osm.c
drivers/staging/i2o/debug.c
drivers/staging/i2o/device.c
drivers/staging/i2o/driver.c
drivers/staging/i2o/exec-osm.c
drivers/staging/i2o/i2o_block.c
drivers/staging/i2o/i2o_config.c
drivers/staging/i2o/i2o_proc.c
drivers/staging/i2o/iop.c
drivers/staging/i2o/memory.c
drivers/staging/i2o/pci.c
drivers/staging/iio/Documentation/generic_buffer.c
drivers/staging/iio/Documentation/iio_utils.h
drivers/staging/iio/accel/adis16220_core.c
drivers/staging/iio/accel/adis16240_core.c
drivers/staging/iio/accel/lis3l02dq_ring.c
drivers/staging/iio/accel/sca3000.h
drivers/staging/iio/accel/sca3000_core.c
drivers/staging/iio/adc/ad7280a.c
drivers/staging/iio/frequency/ad9832.c
drivers/staging/iio/frequency/ad9832.h
drivers/staging/iio/frequency/ad9834.c
drivers/staging/iio/frequency/ad9834.h
drivers/staging/iio/frequency/dds.h
drivers/staging/iio/iio_simple_dummy.c
drivers/staging/iio/light/isl29028.c
drivers/staging/iio/light/tsl2583.c
drivers/staging/iio/light/tsl2x7x_core.c
drivers/staging/iio/magnetometer/hmc5843.h
drivers/staging/iio/magnetometer/hmc5843_core.c
drivers/staging/iio/magnetometer/hmc5843_i2c.c
drivers/staging/iio/meter/ade7753.c
drivers/staging/iio/meter/ade7754.c
drivers/staging/iio/meter/ade7758_core.c
drivers/staging/iio/meter/ade7758_ring.c
drivers/staging/iio/meter/ade7759.c
drivers/staging/iio/meter/ade7854-i2c.c
drivers/staging/iio/meter/ade7854-spi.c
drivers/staging/iio/meter/meter.h
drivers/staging/iio/resolver/ad2s1210.c
drivers/staging/iio/resolver/ad2s1210.h
drivers/staging/iio/trigger/iio-trig-bfin-timer.c
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h
drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h
drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
drivers/staging/lustre/lnet/lnet/lib-eq.c
drivers/staging/lustre/lnet/lnet/router.c
drivers/staging/lustre/lnet/selftest/conctl.c
drivers/staging/lustre/lnet/selftest/console.c
drivers/staging/lustre/lnet/selftest/framework.c
drivers/staging/lustre/lnet/selftest/rpc.c
drivers/staging/lustre/lustre/fid/lproc_fid.c
drivers/staging/lustre/lustre/fld/fld_internal.h
drivers/staging/lustre/lustre/fld/fld_request.c
drivers/staging/lustre/lustre/fld/lproc_fld.c
drivers/staging/lustre/lustre/include/lprocfs_status.h
drivers/staging/lustre/lustre/include/lu_object.h
drivers/staging/lustre/lustre/include/lustre_dlm.h
drivers/staging/lustre/lustre/include/lustre_net.h
drivers/staging/lustre/lustre/lclient/lcommon_cl.c
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
drivers/staging/lustre/lustre/ldlm/ldlm_request.c
drivers/staging/lustre/lustre/libcfs/Makefile
drivers/staging/lustre/lustre/libcfs/debug.c
drivers/staging/lustre/lustre/libcfs/hash.c
drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c
drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c
drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c
drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c [deleted file]
drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c
drivers/staging/lustre/lustre/libcfs/module.c
drivers/staging/lustre/lustre/libcfs/tracefile.c
drivers/staging/lustre/lustre/libcfs/workitem.c
drivers/staging/lustre/lustre/llite/dcache.c
drivers/staging/lustre/lustre/llite/dir.c
drivers/staging/lustre/lustre/llite/file.c
drivers/staging/lustre/lustre/llite/llite_close.c
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/llite/llite_mmap.c
drivers/staging/lustre/lustre/llite/lloop.c
drivers/staging/lustre/lustre/llite/lproc_llite.c
drivers/staging/lustre/lustre/llite/namei.c
drivers/staging/lustre/lustre/llite/rw.c
drivers/staging/lustre/lustre/llite/rw26.c
drivers/staging/lustre/lustre/llite/statahead.c
drivers/staging/lustre/lustre/llite/super25.c
drivers/staging/lustre/lustre/llite/vvp_dev.c
drivers/staging/lustre/lustre/llite/xattr_cache.c
drivers/staging/lustre/lustre/lmv/lmv_obd.c
drivers/staging/lustre/lustre/lmv/lproc_lmv.c
drivers/staging/lustre/lustre/lov/lov_dev.c
drivers/staging/lustre/lustre/lov/lov_ea.c
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_object.c
drivers/staging/lustre/lustre/lov/lov_pool.c
drivers/staging/lustre/lustre/lov/lproc_lov.c
drivers/staging/lustre/lustre/mdc/lproc_mdc.c
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/obdclass/dt_object.c
drivers/staging/lustre/lustre/obdclass/genops.c
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
drivers/staging/lustre/lustre/obdclass/llog_cat.c
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
drivers/staging/lustre/lustre/obdclass/lu_object.c
drivers/staging/lustre/lustre/obdclass/obd_mount.c
drivers/staging/lustre/lustre/obdecho/echo_client.c
drivers/staging/lustre/lustre/obdecho/lproc_echo.c
drivers/staging/lustre/lustre/osc/lproc_osc.c
drivers/staging/lustre/lustre/osc/osc_io.c
drivers/staging/lustre/lustre/osc/osc_lock.c
drivers/staging/lustre/lustre/osc/osc_request.c
drivers/staging/lustre/lustre/ptlrpc/client.c
drivers/staging/lustre/lustre/ptlrpc/connection.c
drivers/staging/lustre/lustre/ptlrpc/layout.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/niobuf.c
drivers/staging/lustre/lustre/ptlrpc/nrs.c
drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
drivers/staging/lustre/lustre/ptlrpc/pinger.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
drivers/staging/lustre/lustre/ptlrpc/service.c
drivers/staging/media/bcm2048/radio-bcm2048.c
drivers/staging/media/cxd2099/cxd2099.c
drivers/staging/media/davinci_vpfe/dm365_ipipeif.c
drivers/staging/media/davinci_vpfe/dm365_resizer.c
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
drivers/staging/media/lirc/lirc_imon.c
drivers/staging/media/lirc/lirc_parallel.c
drivers/staging/media/lirc/lirc_sasem.c
drivers/staging/media/lirc/lirc_serial.c
drivers/staging/media/lirc/lirc_sir.c
drivers/staging/media/lirc/lirc_zilog.c
drivers/staging/media/mn88472/mn88472.c
drivers/staging/media/mn88473/mn88473.c
drivers/staging/media/omap4iss/iss.c
drivers/staging/media/omap4iss/iss_video.c
drivers/staging/mt29f_spinand/mt29f_spinand.c
drivers/staging/netlogic/xlr_net.c
drivers/staging/nvec/Kconfig
drivers/staging/nvec/nvec.c
drivers/staging/nvec/nvec_paz00.c
drivers/staging/nvec/nvec_power.c
drivers/staging/nvec/nvec_ps2.c
drivers/staging/octeon-usb/octeon-hcd.c
drivers/staging/octeon/ethernet.c
drivers/staging/ozwpan/ozhcd.c
drivers/staging/ozwpan/ozpd.c
drivers/staging/ozwpan/ozproto.c
drivers/staging/panel/panel.c
drivers/staging/rtl8188eu/core/rtw_ap.c
drivers/staging/rtl8188eu/core/rtw_cmd.c
drivers/staging/rtl8188eu/core/rtw_efuse.c
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/core/rtw_ioctl_set.c
drivers/staging/rtl8188eu/core/rtw_led.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/core/rtw_security.c
drivers/staging/rtl8188eu/core/rtw_sreset.c
drivers/staging/rtl8188eu/core/rtw_wlan_util.c
drivers/staging/rtl8188eu/core/rtw_xmit.c
drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c
drivers/staging/rtl8188eu/hal/bb_cfg.c
drivers/staging/rtl8188eu/hal/fw.c
drivers/staging/rtl8188eu/hal/odm.c
drivers/staging/rtl8188eu/hal/odm_HWConfig.c
drivers/staging/rtl8188eu/hal/phy.c
drivers/staging/rtl8188eu/hal/pwrseqcmd.c
drivers/staging/rtl8188eu/hal/rf.c
drivers/staging/rtl8188eu/hal/rf_cfg.c
drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c
drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c
drivers/staging/rtl8188eu/hal/usb_halinit.c
drivers/staging/rtl8188eu/include/ieee80211.h
drivers/staging/rtl8188eu/include/osdep_service.h
drivers/staging/rtl8188eu/include/rtw_led.h
drivers/staging/rtl8188eu/include/rtw_mlme.h
drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
drivers/staging/rtl8188eu/include/rtw_pwrctrl.h
drivers/staging/rtl8188eu/include/rtw_recv.h
drivers/staging/rtl8188eu/include/rtw_security.h
drivers/staging/rtl8188eu/include/wifi.h
drivers/staging/rtl8188eu/include/wlan_bssdef.h
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
drivers/staging/rtl8188eu/os_dep/mlme_linux.c
drivers/staging/rtl8188eu/os_dep/os_intfs.c
drivers/staging/rtl8188eu/os_dep/recv_linux.c
drivers/staging/rtl8188eu/os_dep/usb_intf.c
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
drivers/staging/rtl8192e/dot11d.h
drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
drivers/staging/rtl8192e/rtl8192e/rtl_core.c
drivers/staging/rtl8192e/rtl8192e/rtl_core.h
drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
drivers/staging/rtl8192e/rtl8192e/rtl_dm.h
drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
drivers/staging/rtl8192e/rtl819x_BAProc.c
drivers/staging/rtl8192e/rtl819x_HT.h
drivers/staging/rtl8192e/rtl819x_HTProc.c
drivers/staging/rtl8192e/rtl819x_Qos.h
drivers/staging/rtl8192e/rtl819x_TSProc.c
drivers/staging/rtl8192e/rtllib.h
drivers/staging/rtl8192e/rtllib_crypt.c
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
drivers/staging/rtl8192e/rtllib_crypt_tkip.c
drivers/staging/rtl8192e/rtllib_crypt_wep.c
drivers/staging/rtl8192e/rtllib_debug.h
drivers/staging/rtl8192e/rtllib_endianfree.h [deleted file]
drivers/staging/rtl8192e/rtllib_module.c
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192e/rtllib_softmac.c
drivers/staging/rtl8192e/rtllib_softmac_wx.c
drivers/staging/rtl8192e/rtllib_tx.c
drivers/staging/rtl8192e/rtllib_wx.c
drivers/staging/rtl8192u/ieee80211/dot11d.c
drivers/staging/rtl8192u/ieee80211/dot11d.h
drivers/staging/rtl8192u/ieee80211/ieee80211.h
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt.c
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
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/rtl819x_HTProc.c
drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
drivers/staging/rtl8192u/r8190_rtl8256.c
drivers/staging/rtl8192u/r8190_rtl8256.h
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_wx.c
drivers/staging/rtl8192u/r8192U_wx.h
drivers/staging/rtl8192u/r819xU_firmware.c
drivers/staging/rtl8192u/r819xU_phy.c
drivers/staging/rtl8712/hal_init.c
drivers/staging/rtl8712/mlme_linux.c
drivers/staging/rtl8712/os_intfs.c
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/recv_linux.c
drivers/staging/rtl8712/rtl8712_cmd.c
drivers/staging/rtl8712/rtl8712_led.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl871x_cmd.c
drivers/staging/rtl8712/rtl871x_eeprom.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_ioctl_set.c
drivers/staging/rtl8712/rtl871x_mlme.c
drivers/staging/rtl8712/rtl871x_mp.c
drivers/staging/rtl8712/rtl871x_pwrctrl.c
drivers/staging/rtl8712/rtl871x_recv.c
drivers/staging/rtl8712/rtl871x_security.c
drivers/staging/rtl8712/rtl871x_security.h
drivers/staging/rtl8712/rtl871x_sta_mgt.c
drivers/staging/rtl8712/rtl871x_xmit.c
drivers/staging/rtl8712/wifi.h
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_efuse.c
drivers/staging/rtl8723au/core/rtw_mlme_ext.c
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/core/rtw_security.c
drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c
drivers/staging/rtl8723au/hal/HalHWImg8723A_BB.c
drivers/staging/rtl8723au/hal/HalHWImg8723A_MAC.c
drivers/staging/rtl8723au/hal/HalHWImg8723A_RF.c
drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c
drivers/staging/rtl8723au/hal/hal_com.c
drivers/staging/rtl8723au/hal/odm.c
drivers/staging/rtl8723au/hal/odm_HWConfig.c
drivers/staging/rtl8723au/hal/odm_RegConfig8723A.c
drivers/staging/rtl8723au/hal/odm_interface.c
drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c
drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
drivers/staging/rtl8723au/hal/rtl8723a_dm.c
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
drivers/staging/rtl8723au/hal/rtl8723au_recv.c
drivers/staging/rtl8723au/hal/usb_halinit.c
drivers/staging/rtl8723au/include/Hal8723APhyCfg.h
drivers/staging/rtl8723au/include/HalVerDef.h
drivers/staging/rtl8723au/include/hal_com.h
drivers/staging/rtl8723au/include/hal_intf.h
drivers/staging/rtl8723au/include/ieee80211.h
drivers/staging/rtl8723au/include/odm.h
drivers/staging/rtl8723au/include/odm_RegConfig8723A.h
drivers/staging/rtl8723au/include/odm_interface.h
drivers/staging/rtl8723au/include/rtl8723a_hal.h
drivers/staging/rtl8723au/os_dep/os_intfs.c
drivers/staging/rtl8723au/os_dep/usb_intf.c
drivers/staging/rts5208/ms.c
drivers/staging/rts5208/ms.h
drivers/staging/rts5208/rtsx.c
drivers/staging/rts5208/rtsx_chip.c
drivers/staging/rts5208/rtsx_scsi.c
drivers/staging/rts5208/rtsx_transport.c
drivers/staging/rts5208/sd.c
drivers/staging/rts5208/sd.h
drivers/staging/skein/skein_block.c
drivers/staging/slicoss/slicoss.c
drivers/staging/sm750fb/Kconfig [new file with mode: 0644]
drivers/staging/sm750fb/Makefile [new file with mode: 0644]
drivers/staging/sm750fb/TODO [new file with mode: 0644]
drivers/staging/sm750fb/ddk750.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_chip.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_chip.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_display.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_display.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_dvi.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_dvi.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_help.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_help.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_hwi2c.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_hwi2c.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_mode.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_mode.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_power.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_power.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_reg.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_sii164.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_sii164.h [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_swi2c.c [new file with mode: 0644]
drivers/staging/sm750fb/ddk750_swi2c.h [new file with mode: 0644]
drivers/staging/sm750fb/modedb.h [new file with mode: 0644]
drivers/staging/sm750fb/readme [new file with mode: 0644]
drivers/staging/sm750fb/sm750.c [new file with mode: 0644]
drivers/staging/sm750fb/sm750.h [new file with mode: 0644]
drivers/staging/sm750fb/sm750_accel.c [new file with mode: 0644]
drivers/staging/sm750fb/sm750_accel.h [new file with mode: 0644]
drivers/staging/sm750fb/sm750_cursor.c [new file with mode: 0644]
drivers/staging/sm750fb/sm750_cursor.h [new file with mode: 0644]
drivers/staging/sm750fb/sm750_help.h [new file with mode: 0644]
drivers/staging/sm750fb/sm750_hw.c [new file with mode: 0644]
drivers/staging/sm750fb/sm750_hw.h [new file with mode: 0644]
drivers/staging/sm7xxfb/sm7xx.h
drivers/staging/sm7xxfb/sm7xxfb.c
drivers/staging/speakup/kobjects.c
drivers/staging/speakup/main.c
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_soft.c
drivers/staging/speakup/speakup_spkout.c
drivers/staging/speakup/speakup_txprt.c
drivers/staging/speakup/spk_priv.h
drivers/staging/speakup/spk_types.h
drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
drivers/staging/unisys/common-spar/include/channels/iochannel.h
drivers/staging/unisys/common-spar/include/vmcallinterface.h
drivers/staging/unisys/include/procobjecttree.h
drivers/staging/unisys/include/timskmod.h
drivers/staging/unisys/include/uisqueue.h
drivers/staging/unisys/include/uisthread.h
drivers/staging/unisys/include/uisutils.h
drivers/staging/unisys/include/uniklog.h [deleted file]
drivers/staging/unisys/uislib/Kconfig
drivers/staging/unisys/uislib/Makefile
drivers/staging/unisys/uislib/uislib.c
drivers/staging/unisys/uislib/uisqueue.c
drivers/staging/unisys/uislib/uisthread.c
drivers/staging/unisys/uislib/uisutils.c
drivers/staging/unisys/virthba/Kconfig
drivers/staging/unisys/virthba/Makefile
drivers/staging/unisys/virthba/virthba.c
drivers/staging/unisys/virtpci/Kconfig
drivers/staging/unisys/virtpci/virtpci.c
drivers/staging/unisys/visorchannel/Kconfig
drivers/staging/unisys/visorchannel/globals.h
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
drivers/staging/unisys/visorchannel/visorchannel_main.c
drivers/staging/unisys/visorchipset/Kconfig
drivers/staging/unisys/visorchipset/file.c
drivers/staging/unisys/visorchipset/globals.h
drivers/staging/unisys/visorchipset/parser.c
drivers/staging/unisys/visorchipset/parser.h
drivers/staging/unisys/visorchipset/visorchipset_main.c
drivers/staging/unisys/visorutil/Kconfig
drivers/staging/unisys/visorutil/charqueue.c
drivers/staging/unisys/visorutil/charqueue.h
drivers/staging/unisys/visorutil/easyproc.c
drivers/staging/unisys/visorutil/memregion_direct.c
drivers/staging/unisys/visorutil/periodic_work.c
drivers/staging/unisys/visorutil/procobjecttree.c
drivers/staging/unisys/visorutil/visorkmodutils.c
drivers/staging/vme/devices/vme_pio2_core.c
drivers/staging/vme/devices/vme_pio2_gpio.c
drivers/staging/vme/devices/vme_user.c
drivers/staging/vt6655/baseband.c
drivers/staging/vt6655/channel.c
drivers/staging/vt6655/device_main.c
drivers/staging/vt6655/dpc.c
drivers/staging/vt6655/key.h
drivers/staging/vt6655/mac.c
drivers/staging/vt6655/mib.c
drivers/staging/vt6655/rxtx.c
drivers/staging/vt6655/srom.h
drivers/staging/vt6655/tmacro.h
drivers/staging/vt6656/firmware.c
drivers/staging/vt6656/mac.c
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/rxtx.c
drivers/staging/wlan-ng/hfa384x.h
drivers/staging/wlan-ng/hfa384x_usb.c
drivers/staging/wlan-ng/prism2mib.c
drivers/staging/wlan-ng/prism2sta.c
drivers/staging/xgifb/XGI_main_26.c
drivers/staging/xgifb/vb_setmode.c
drivers/vme/bridges/vme_tsi148.c
drivers/vme/vme.c
include/linux/vme.h

index 358eb0105e008d4b89b0f485141f8b676884fdb3..ccf1c898afb1f0bddf05e82de42b0d0fbc93f8f0 100644 (file)
@@ -725,7 +725,7 @@ F:  staging/iio/trigger/iio-trig-bfin-timer.c
 
 ANDROID DRIVERS
 M:     Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-M:     Arve HjønnevÃ¥g <arve@android.com>
+M:     Arve HjønnevÃ¥g <arve@android.com>
 M:     Riley Andrews <riandrews@android.com>
 T:     git git://git.kernel.org/pub/scm/linux/kernel/gregkh/staging.git
 L:     devel@driverdev.osuosl.org
@@ -4156,6 +4156,12 @@ F:       sound/soc/fsl/fsl*
 F:     sound/soc/fsl/imx*
 F:     sound/soc/fsl/mpc8610_hpcd.c
 
+FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER
+M:     J. German Rivera <German.Rivera@freescale.com>
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+F:     drivers/staging/fsl-mc/
+
 FREEVXFS FILESYSTEM
 M:     Christoph Hellwig <hch@infradead.org>
 W:     ftp://ftp.openlinux.org/pub/people/hch/vxfs
@@ -9358,6 +9364,14 @@ L:       linux-fbdev@vger.kernel.org
 S:     Maintained
 F:     drivers/staging/sm7xxfb/
 
+STAGING - SILICON MOTION SM750 FRAME BUFFER DRIVER
+M:     Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+M:     Teddy Wang <teddy.wang@siliconmotion.com>
+M:     Sudip Mukherjee <sudip@vectorindia.org>
+L:     linux-fbdev@vger.kernel.org
+S:     Maintained
+F:     drivers/staging/sm750fb/
+
 STAGING - SLICOSS
 M:     Lior Dotan <liodot@gmail.com>
 M:     Christopher Harrer <charrer@alacritech.com>
index 68aca3334a17e4fcc9fba62af4e89f082d5c681f..1332b1d4d541cb37c99f4a4ada988f3cbaee0f7f 100644 (file)
@@ -3548,7 +3548,7 @@ static int __init d40_probe(struct platform_device *pdev)
 
        if (!plat_data) {
                if (np) {
-                       if(d40_of_probe(pdev, np)) {
+                       if (d40_of_probe(pdev, np)) {
                                ret = -ENOMEM;
                                goto failure;
                        }
index 45baa83be7cefa74e9ba2d6814cc6bc62d9e073c..bfacf69f68f4c5044f723f6d48b16015ed2b0b5c 100644 (file)
@@ -58,6 +58,8 @@ source "drivers/staging/iio/Kconfig"
 
 source "drivers/staging/sm7xxfb/Kconfig"
 
+source "drivers/staging/sm750fb/Kconfig"
+
 source "drivers/staging/xgifb/Kconfig"
 
 source "drivers/staging/emxx_udc/Kconfig"
@@ -108,4 +110,6 @@ source "drivers/staging/fbtft/Kconfig"
 
 source "drivers/staging/i2o/Kconfig"
 
+source "drivers/staging/fsl-mc/Kconfig"
+
 endif # STAGING
index 29160790841f76ee909c325cd336b937f47faf4e..2bbd1bf04c55d5b5050ef6dca63d246db461b286 100644 (file)
@@ -23,6 +23,7 @@ obj-$(CONFIG_VT6656)          += vt6656/
 obj-$(CONFIG_VME_BUS)          += vme/
 obj-$(CONFIG_IIO)              += iio/
 obj-$(CONFIG_FB_SM7XX)         += sm7xxfb/
+obj-$(CONFIG_FB_SM7XX)         += sm750fb/
 obj-$(CONFIG_FB_XGI)           += xgifb/
 obj-$(CONFIG_USB_EMXX)         += emxx_udc/
 obj-$(CONFIG_FT1000)           += ft1000/
@@ -46,3 +47,4 @@ obj-$(CONFIG_UNISYSSPAR)      += unisys/
 obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD)  += clocking-wizard/
 obj-$(CONFIG_FB_TFT)           += fbtft/
 obj-$(CONFIG_I2O)              += i2o/
+obj-$(CONFIG_FSL_MC_BUS)       += fsl-mc/
index b8f1c491553e2619bfbbbbb9ff52318e2f8017cc..0e3d8c7add24e1955e2bd480075df0caf09b1a94 100644 (file)
@@ -566,8 +566,8 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle,
        buffer = handle->buffer;
 
        if (!buffer->heap->ops->phys) {
-               pr_err("%s: ion_phys is not implemented by this heap.\n",
-                      __func__);
+               pr_err("%s: ion_phys is not implemented by this heap (name=%s, type=%d).\n",
+                       __func__, buffer->heap->name, buffer->heap->type);
                mutex_unlock(&client->lock);
                return -ENODEV;
        }
@@ -1395,7 +1395,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
        size_t total_size = 0;
        size_t total_orphaned_size = 0;
 
-       seq_printf(s, "%16.s %16.s %16.s\n", "client", "pid", "size");
+       seq_printf(s, "%16s %16s %16s\n", "client", "pid", "size");
        seq_puts(s, "----------------------------------------------------\n");
 
        for (n = rb_first(&dev->clients); n; n = rb_next(n)) {
@@ -1409,10 +1409,10 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
                        char task_comm[TASK_COMM_LEN];
 
                        get_task_comm(task_comm, client->task);
-                       seq_printf(s, "%16.s %16u %16zu\n", task_comm,
+                       seq_printf(s, "%16s %16u %16zu\n", task_comm,
                                   client->pid, size);
                } else {
-                       seq_printf(s, "%16.s %16u %16zu\n", client->name,
+                       seq_printf(s, "%16s %16u %16zu\n", client->name,
                                   client->pid, size);
                }
        }
@@ -1426,7 +1426,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
                        continue;
                total_size += buffer->size;
                if (!buffer->handle_count) {
-                       seq_printf(s, "%16.s %16u %16zu %d %d\n",
+                       seq_printf(s, "%16s %16u %16zu %d %d\n",
                                   buffer->task_comm, buffer->pid,
                                   buffer->size, buffer->kmap_cnt,
                                   atomic_read(&buffer->ref.refcount));
@@ -1435,11 +1435,11 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused)
        }
        mutex_unlock(&dev->buffer_lock);
        seq_puts(s, "----------------------------------------------------\n");
-       seq_printf(s, "%16.s %16zu\n", "total orphaned",
+       seq_printf(s, "%16s %16zu\n", "total orphaned",
                   total_orphaned_size);
-       seq_printf(s, "%16.s %16zu\n", "total ", total_size);
+       seq_printf(s, "%16s %16zu\n", "total ", total_size);
        if (heap->flags & ION_HEAP_FLAG_DEFER_FREE)
-               seq_printf(s, "%16.s %16zu\n", "deferred free",
+               seq_printf(s, "%16s %16zu\n", "deferred free",
                                heap->free_list_size);
        seq_puts(s, "----------------------------------------------------\n");
 
index 593fcb1783b463ebe08f0cfcc55c15bb17771c74..61c6351f55ac4c2a4886645fb276ef54d74eee9f 100644 (file)
@@ -108,6 +108,7 @@ if COMEDI_ISA_DRIVERS
 
 config COMEDI_PCL711
        tristate "Advantech PCL-711/711b and ADlink ACL-8112 ISA card support"
+       select COMEDI_8254
        ---help---
          Enable support for Advantech PCL-711 and 711b, ADlink ACL-8112
 
@@ -169,6 +170,7 @@ config COMEDI_PCL730
 config COMEDI_PCL812
        tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        ---help---
          Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink
          ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA,
@@ -180,6 +182,7 @@ config COMEDI_PCL812
 config COMEDI_PCL816
        tristate "Advantech PCL-814 and PCL-816 ISA card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        ---help---
          Enable support for Advantech PCL-814 and PCL-816 ISA cards
 
@@ -189,6 +192,7 @@ config COMEDI_PCL816
 config COMEDI_PCL818
        tristate "Advantech PCL-718 and PCL-818 ISA card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        ---help---
          Enable support for Advantech PCL-818 ISA cards
          PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718
@@ -259,6 +263,7 @@ config COMEDI_DAC02
 
 config COMEDI_DAS16M1
        tristate "MeasurementComputing CIO-DAS16/M1DAS-16 ISA card support"
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for Measurement Computing CIO-DAS16/M1 ISA cards.
@@ -282,6 +287,7 @@ config COMEDI_DAS08_ISA
 config COMEDI_DAS16
        tristate "DAS-16 compatible ISA and PC/104 card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for Keithley Metrabyte/ComputerBoards DAS16
@@ -298,6 +304,7 @@ config COMEDI_DAS16
 
 config COMEDI_DAS800
        tristate "DAS800 and compatible ISA card support"
+       select COMEDI_8254
        ---help---
          Enable support for Keithley Metrabyte DAS800 and compatible ISA cards
          Keithley Metrabyte DAS-800, DAS-801, DAS-802
@@ -310,6 +317,7 @@ config COMEDI_DAS800
 config COMEDI_DAS1800
        tristate "DAS1800 and compatible ISA card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        ---help---
          Enable support for DAS1800 and compatible ISA cards
          Keithley Metrabyte DAS-1701ST, DAS-1701ST-DA, DAS-1701/AO,
@@ -323,6 +331,7 @@ config COMEDI_DAS1800
 
 config COMEDI_DAS6402
        tristate "DAS6402 and compatible ISA card support"
+       select COMEDI_8254
        ---help---
          Enable support for DAS6402 and compatible ISA cards
          Computerboards, Keithley Metrabyte DAS6402 and compatibles
@@ -463,6 +472,7 @@ config COMEDI_ADQ12B
 config COMEDI_NI_AT_A2150
        tristate "NI AT-A2150 ISA card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        ---help---
          Enable support for National Instruments AT-A2150 cards
 
@@ -471,6 +481,7 @@ config COMEDI_NI_AT_A2150
 
 config COMEDI_NI_AT_AO
        tristate "NI AT-AO-6/10 EISA card support"
+       select COMEDI_8254
        ---help---
          Enable support for National Instruments AT-AO-6/10 cards
 
@@ -715,6 +726,7 @@ config COMEDI_ADL_PCI8164
 
 config COMEDI_ADL_PCI9111
        tristate "ADLink PCI-9111HR support"
+       select COMEDI_8254
        ---help---
          Enable support for ADlink PCI9111 cards
 
@@ -724,6 +736,7 @@ config COMEDI_ADL_PCI9111
 config COMEDI_ADL_PCI9118
        tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support"
        depends on HAS_DMA
+       select COMEDI_8254
        ---help---
          Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards
 
@@ -732,6 +745,7 @@ config COMEDI_ADL_PCI9118
 
 config COMEDI_ADV_PCI1710
        tristate "Advantech PCI-171x, PCI-1720 and PCI-1731 support"
+       select COMEDI_8254
        ---help---
          Enable support for Advantech PCI-1710, PCI-1710HG, PCI-1711,
          PCI-1713, PCI-1720 and PCI-1731
@@ -759,6 +773,7 @@ config COMEDI_ADV_PCI1724
 
 config COMEDI_ADV_PCI_DIO
        tristate "Advantech PCI DIO card support"
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for Advantech PCI DIO cards
@@ -799,6 +814,7 @@ config COMEDI_AMPLC_PC263_PCI
 
 config COMEDI_AMPLC_PCI224
        tristate "Amplicon PCI224 and PCI234 support"
+       select COMEDI_8254
        ---help---
          Enable support for Amplicon PCI224 and PCI234 AO boards
 
@@ -807,6 +823,7 @@ config COMEDI_AMPLC_PCI224
 
 config COMEDI_AMPLC_PCI230
        tristate "Amplicon PCI230 and PCI260 support"
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for Amplicon PCI230 and PCI260 Multifunction I/O
@@ -912,6 +929,7 @@ config COMEDI_CB_PCIDAS64
 
 config COMEDI_CB_PCIDAS
        tristate "MeasurementComputing PCI-DAS support"
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for ComputerBoards/MeasurementComputing PCI-DAS with
@@ -935,6 +953,7 @@ config COMEDI_CB_PCIDDA
 
 config COMEDI_CB_PCIMDAS
        tristate "MeasurementComputing PCIM-DAS1602/16, PCIe-DAS1602/16 support"
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for ComputerBoards/MeasurementComputing PCI Migration
@@ -954,6 +973,7 @@ config COMEDI_CB_PCIMDDA
 
 config COMEDI_ME4000
        tristate "Meilhaus ME-4000 support"
+       select COMEDI_8254
        ---help---
          Enable support for Meilhaus PCI data acquisition cards
          ME-4650, ME-4670i, ME-4680, ME-4680i and ME-4680is
@@ -1091,6 +1111,7 @@ if COMEDI_PCMCIA_DRIVERS
 
 config COMEDI_CB_DAS16_CS
        tristate "CB DAS16 series PCMCIA support"
+       select COMEDI_8254
        ---help---
          Enable support for the ComputerBoards/MeasurementComputing PCMCIA
          cards DAS16/16, PCM-DAS16D/12 and PCM-DAS16s/16
@@ -1222,6 +1243,9 @@ config COMEDI_VMK80XX
 
 endif # COMEDI_USB_DRIVERS
 
+config COMEDI_8254
+       tristate
+
 config COMEDI_8255
        tristate "Generic 8255 support"
        ---help---
@@ -1252,6 +1276,7 @@ config COMEDI_KCOMEDILIB
          called kcomedilib.
 
 config COMEDI_AMPLC_DIO200
+       select COMEDI_8254
        tristate
 
 config COMEDI_AMPLC_PC236
@@ -1260,6 +1285,7 @@ config COMEDI_AMPLC_PC236
 
 config COMEDI_DAS08
        tristate
+       select COMEDI_8254
        select COMEDI_8255
 
 config COMEDI_ISADMA
@@ -1267,6 +1293,7 @@ config COMEDI_ISADMA
 
 config COMEDI_NI_LABPC
        tristate
+       select COMEDI_8254
        select COMEDI_8255
 
 config COMEDI_NI_LABPC_ISADMA
index 727640e89c73ad53e39fcf1f720ae6e92fb3b0f0..8bf57b736659520c3ad35408a514a5be05537f26 100644 (file)
@@ -144,7 +144,7 @@ static void comedi_device_cleanup(struct comedi_device *dev)
 {
        struct module *driver_module = NULL;
 
-       if (dev == NULL)
+       if (!dev)
                return;
        mutex_lock(&dev->mutex);
        if (dev->attached)
@@ -260,7 +260,7 @@ comedi_read_subdevice(const struct comedi_device *dev, unsigned int minor)
 
        if (minor >= COMEDI_NUM_BOARD_MINORS) {
                s = comedi_subdevice_from_minor(dev, minor);
-               if (s == NULL || (s->subdev_flags & SDF_CMD_READ))
+               if (!s || (s->subdev_flags & SDF_CMD_READ))
                        return s;
        }
        return dev->read_subdev;
@@ -273,7 +273,7 @@ comedi_write_subdevice(const struct comedi_device *dev, unsigned int minor)
 
        if (minor >= COMEDI_NUM_BOARD_MINORS) {
                s = comedi_subdevice_from_minor(dev, minor);
-               if (s == NULL || (s->subdev_flags & SDF_CMD_WRITE))
+               if (!s || (s->subdev_flags & SDF_CMD_WRITE))
                        return s;
        }
        return dev->write_subdev;
@@ -290,9 +290,9 @@ static void comedi_file_reset(struct file *file)
        write_s = dev->write_subdev;
        if (minor >= COMEDI_NUM_BOARD_MINORS) {
                s = comedi_subdevice_from_minor(dev, minor);
-               if (s == NULL || s->subdev_flags & SDF_CMD_READ)
+               if (!s || s->subdev_flags & SDF_CMD_READ)
                        read_s = s;
-               if (s == NULL || s->subdev_flags & SDF_CMD_WRITE)
+               if (!s || s->subdev_flags & SDF_CMD_WRITE)
                        write_s = s;
        }
        cfp->last_attached = dev->attached;
@@ -759,7 +759,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
-       if (arg == NULL) {
+       if (!arg) {
                if (is_device_busy(dev))
                        return -EBUSY;
                if (dev->attached) {
@@ -1840,7 +1840,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
        if (arg >= dev->n_subdevices)
                return -EINVAL;
        s = &dev->subdevices[arg];
-       if (s->async == NULL)
+       if (!s->async)
                return -EINVAL;
 
        if (!s->busy)
@@ -2682,7 +2682,7 @@ struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
        unsigned i;
 
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (dev == NULL)
+       if (!dev)
                return ERR_PTR(-ENOMEM);
        comedi_device_init(dev);
        comedi_set_hw_dev(dev, hardware_device);
@@ -2690,7 +2690,7 @@ struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
        mutex_lock(&comedi_board_minor_table_lock);
        for (i = hardware_device ? comedi_num_legacy_minors : 0;
             i < COMEDI_NUM_BOARD_MINORS; ++i) {
-               if (comedi_board_minor_table[i] == NULL) {
+               if (!comedi_board_minor_table[i]) {
                        comedi_board_minor_table[i] = dev;
                        break;
                }
@@ -2700,7 +2700,8 @@ struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
                mutex_unlock(&dev->mutex);
                comedi_device_cleanup(dev);
                comedi_dev_put(dev);
-               pr_err("ran out of minor numbers for board device files\n");
+               dev_err(hardware_device,
+                       "ran out of minor numbers for board device files\n");
                return ERR_PTR(-EBUSY);
        }
        dev->minor = i;
@@ -2746,14 +2747,15 @@ int comedi_alloc_subdevice_minor(struct comedi_subdevice *s)
 
        mutex_lock(&comedi_subdevice_minor_table_lock);
        for (i = 0; i < COMEDI_NUM_SUBDEVICE_MINORS; ++i) {
-               if (comedi_subdevice_minor_table[i] == NULL) {
+               if (!comedi_subdevice_minor_table[i]) {
                        comedi_subdevice_minor_table[i] = s;
                        break;
                }
        }
        mutex_unlock(&comedi_subdevice_minor_table_lock);
        if (i == COMEDI_NUM_SUBDEVICE_MINORS) {
-               pr_err("ran out of minor numbers for subdevice files\n");
+               dev_err(dev->class_dev,
+                       "ran out of minor numbers for subdevice files\n");
                return -EBUSY;
        }
        i += COMEDI_NUM_BOARD_MINORS;
@@ -2771,7 +2773,7 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
 {
        unsigned int i;
 
-       if (s == NULL)
+       if (!s)
                return;
        if (s->minor < 0)
                return;
index 6ba59c9770067d4976c6f9590be96ec734752322..027f0f4e59c15a35d3190df836b01969666739d1 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "comedidev.h"
+#include "comedi_pci.h"
 
 /**
  * comedi_to_pci_dev() - comedi_device pointer to pci_dev pointer.
diff --git a/drivers/staging/comedi/comedi_pci.h b/drivers/staging/comedi/comedi_pci.h
new file mode 100644 (file)
index 0000000..4005cc9
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * comedi_pci.h
+ * header file for Comedi PCI drivers
+ *
+ * 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.
+ */
+
+#ifndef _COMEDI_PCI_H
+#define _COMEDI_PCI_H
+
+#include <linux/pci.h>
+
+#include "comedidev.h"
+
+/*
+ * PCI Vendor IDs not in <linux/pci_ids.h>
+ */
+#define PCI_VENDOR_ID_KOLTER           0x1001
+#define PCI_VENDOR_ID_ICP              0x104c
+#define PCI_VENDOR_ID_DT               0x1116
+#define PCI_VENDOR_ID_IOTECH           0x1616
+#define PCI_VENDOR_ID_CONTEC           0x1221
+#define PCI_VENDOR_ID_RTD              0x1435
+#define PCI_VENDOR_ID_HUMUSOFT         0x186c
+
+struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
+
+int comedi_pci_enable(struct comedi_device *);
+void comedi_pci_disable(struct comedi_device *);
+void comedi_pci_detach(struct comedi_device *);
+
+int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
+                          unsigned long context);
+void comedi_pci_auto_unconfig(struct pci_dev *);
+
+int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
+void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
+
+/**
+ * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
+ * @__comedi_driver: comedi_driver struct
+ * @__pci_driver: pci_driver struct
+ *
+ * Helper macro for comedi PCI 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_pci_driver(__comedi_driver, __pci_driver) \
+       module_driver(__comedi_driver, comedi_pci_driver_register, \
+                       comedi_pci_driver_unregister, &(__pci_driver))
+
+#endif /* _COMEDI_PCI_H */
index e138eb0dc374c24b6cf360eddeda716fa7cf476d..4720dbcd0b382ea2f765abe4ef85655897dd2164 100644 (file)
@@ -256,6 +256,7 @@ struct comedi_driver {
 struct comedi_device {
        int use_count;
        struct comedi_driver *driver;
+       struct comedi_8254 *pacer;
        void *private;
 
        struct device *class_dev;
@@ -553,47 +554,4 @@ void comedi_driver_unregister(struct comedi_driver *);
        module_driver(__comedi_driver, comedi_driver_register, \
                        comedi_driver_unregister)
 
-/* comedi_pci.c - comedi PCI driver specific functions */
-
-/*
- * PCI Vendor IDs not in <linux/pci_ids.h>
- */
-#define PCI_VENDOR_ID_KOLTER           0x1001
-#define PCI_VENDOR_ID_ICP              0x104c
-#define PCI_VENDOR_ID_DT               0x1116
-#define PCI_VENDOR_ID_IOTECH           0x1616
-#define PCI_VENDOR_ID_CONTEC           0x1221
-#define PCI_VENDOR_ID_RTD              0x1435
-#define PCI_VENDOR_ID_HUMUSOFT         0x186c
-
-struct pci_dev;
-struct pci_driver;
-
-struct pci_dev *comedi_to_pci_dev(struct comedi_device *);
-
-int comedi_pci_enable(struct comedi_device *);
-void comedi_pci_disable(struct comedi_device *);
-void comedi_pci_detach(struct comedi_device *);
-
-int comedi_pci_auto_config(struct pci_dev *, struct comedi_driver *,
-                          unsigned long context);
-void comedi_pci_auto_unconfig(struct pci_dev *);
-
-int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
-void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
-
-/**
- * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
- * @__comedi_driver: comedi_driver struct
- * @__pci_driver: pci_driver struct
- *
- * Helper macro for comedi PCI 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_pci_driver(__comedi_driver, __pci_driver) \
-       module_driver(__comedi_driver, comedi_pci_driver_register, \
-                       comedi_pci_driver_unregister, &(__pci_driver))
-
 #endif /* _COMEDIDEV_H */
index f32e71438948a999bfa661f8cfad23dbf969a089..57dcffe00204580129478a202527b56362078726 100644 (file)
@@ -46,7 +46,7 @@ int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev)
 {
        if (hw_dev == dev->hw_dev)
                return 0;
-       if (dev->hw_dev != NULL)
+       if (dev->hw_dev)
                return -EEXIST;
        dev->hw_dev = get_device(hw_dev);
        return 0;
@@ -139,7 +139,9 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev)
                dev->n_subdevices = 0;
        }
        kfree(dev->private);
+       kfree(dev->pacer);
        dev->private = NULL;
+       dev->pacer = NULL;
        dev->driver = NULL;
        dev->board_name = NULL;
        dev->board_ptr = NULL;
@@ -800,7 +802,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                }
                module_put(driv->module);
        }
-       if (driv == NULL) {
+       if (!driv) {
                /*  recognize has failed if we get here */
                /*  report valid board names before returning error */
                for (driv = comedi_drivers; driv; driv = driv->next) {
@@ -812,7 +814,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                ret = -EIO;
                goto out;
        }
-       if (driv->attach == NULL) {
+       if (!driv->attach) {
                /* driver does not support manual configuration */
                dev_warn(dev->class_dev,
                         "driver '%s' does not support attach using comedi_config\n",
@@ -896,7 +898,7 @@ EXPORT_SYMBOL_GPL(comedi_auto_config);
 
 void comedi_auto_unconfig(struct device *hardware_device)
 {
-       if (hardware_device == NULL)
+       if (!hardware_device)
                return;
        comedi_release_hardware_device(hardware_device);
 }
diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h
deleted file mode 100644 (file)
index 51b9c8d..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * comedi/drivers/8253.h
- * Header file for 8253
- *
- * COMEDI - Linux Control and Measurement Device Interface
- * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#ifndef _8253_H
-#define _8253_H
-
-#include "../comedi.h"
-
-/*
- * Common oscillator base values in nanoseconds
- */
-#define I8254_OSC_BASE_10MHZ           100
-#define I8254_OSC_BASE_5MHZ            200
-#define I8254_OSC_BASE_4MHZ            250
-#define I8254_OSC_BASE_2MHZ            500
-#define I8254_OSC_BASE_1MHZ            1000
-
-static inline void i8253_cascade_ns_to_timer(int i8253_osc_base,
-                                            unsigned int *d1,
-                                            unsigned int *d2,
-                                            unsigned int *nanosec,
-                                            unsigned int flags)
-{
-       unsigned int divider;
-       unsigned int div1, div2;
-       unsigned int div1_glb, div2_glb, ns_glb;
-       unsigned int div1_lub, div2_lub, ns_lub;
-       unsigned int ns;
-       unsigned int start;
-       unsigned int ns_low, ns_high;
-       static const unsigned int max_count = 0x10000;
-       /*
-        * exit early if everything is already correct (this can save time
-        * since this function may be called repeatedly during command tests
-        * and execution)
-        */
-       div1 = *d1 ? *d1 : max_count;
-       div2 = *d2 ? *d2 : max_count;
-       divider = div1 * div2;
-       if (div1 * div2 * i8253_osc_base == *nanosec &&
-           div1 > 1 && div1 <= max_count && div2 > 1 && div2 <= max_count &&
-           /* check for overflow */
-           divider > div1 && divider > div2 &&
-           divider * i8253_osc_base > divider &&
-           divider * i8253_osc_base > i8253_osc_base) {
-               return;
-       }
-
-       divider = *nanosec / i8253_osc_base;
-
-       div1_lub = div2_lub = 0;
-       div1_glb = div2_glb = 0;
-
-       ns_glb = 0;
-       ns_lub = 0xffffffff;
-
-       div2 = max_count;
-       start = divider / div2;
-       if (start < 2)
-               start = 2;
-       for (div1 = start; div1 <= divider / div1 + 1 && div1 <= max_count;
-            div1++) {
-               for (div2 = divider / div1;
-                    div1 * div2 <= divider + div1 + 1 && div2 <= max_count;
-                    div2++) {
-                       ns = i8253_osc_base * div1 * div2;
-                       if (ns <= *nanosec && ns > ns_glb) {
-                               ns_glb = ns;
-                               div1_glb = div1;
-                               div2_glb = div2;
-                       }
-                       if (ns >= *nanosec && ns < ns_lub) {
-                               ns_lub = ns;
-                               div1_lub = div1;
-                               div2_lub = div2;
-                       }
-               }
-       }
-
-       switch (flags & CMDF_ROUND_MASK) {
-       case CMDF_ROUND_NEAREST:
-       default:
-               ns_high = div1_lub * div2_lub * i8253_osc_base;
-               ns_low = div1_glb * div2_glb * i8253_osc_base;
-               if (ns_high - *nanosec < *nanosec - ns_low) {
-                       div1 = div1_lub;
-                       div2 = div2_lub;
-               } else {
-                       div1 = div1_glb;
-                       div2 = div2_glb;
-               }
-               break;
-       case CMDF_ROUND_UP:
-               div1 = div1_lub;
-               div2 = div2_lub;
-               break;
-       case CMDF_ROUND_DOWN:
-               div1 = div1_glb;
-               div2 = div2_glb;
-               break;
-       }
-
-       *nanosec = div1 * div2 * i8253_osc_base;
-       /* masking is done since counter maps zero to 0x10000 */
-       *d1 = div1 & 0xffff;
-       *d2 = div2 & 0xffff;
-}
-
-#ifndef CMDTEST
-/*
- * i8254_load programs 8254 counter chip.  It should also work for the 8253.
- * base_address is the lowest io address
- * for the chip (the address of counter 0).
- * counter_number is the counter you want to load (0,1 or 2)
- * count is the number to load into the counter.
- *
- * You probably want to use mode 2.
- *
- * Use i8254_mm_load() if you board uses memory-mapped io, it is
- * the same as i8254_load() except it uses writeb() instead of outb().
- *
- * Neither i8254_load() or i8254_read() do their loading/reading
- * atomically.  The 16 bit read/writes are performed with two successive
- * 8 bit read/writes.  So if two parts of your driver do a load/read on
- * the same counter, it may be necessary to protect these functions
- * with a spinlock.
- *
- * FMH
- */
-
-#define i8254_control_reg      3
-
-static inline int i8254_load(unsigned long base_address, unsigned int regshift,
-                            unsigned int counter_number, unsigned int count,
-                            unsigned int mode)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return -1;
-       if (count > 0xffff)
-               return -1;
-       if (mode > 5)
-               return -1;
-       if ((mode == 2 || mode == 3) && count == 1)
-               return -1;
-
-       byte = counter_number << 6;
-       byte |= 0x30;           /* load low then high byte */
-       byte |= (mode << 1);    /* set counter mode */
-       outb(byte, base_address + (i8254_control_reg << regshift));
-       byte = count & 0xff;    /* lsb of counter value */
-       outb(byte, base_address + (counter_number << regshift));
-       byte = (count >> 8) & 0xff;     /* msb of counter value */
-       outb(byte, base_address + (counter_number << regshift));
-
-       return 0;
-}
-
-static inline int i8254_mm_load(void __iomem *base_address,
-                               unsigned int regshift,
-                               unsigned int counter_number,
-                               unsigned int count,
-                               unsigned int mode)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return -1;
-       if (count > 0xffff)
-               return -1;
-       if (mode > 5)
-               return -1;
-       if ((mode == 2 || mode == 3) && count == 1)
-               return -1;
-
-       byte = counter_number << 6;
-       byte |= 0x30;           /* load low then high byte */
-       byte |= (mode << 1);    /* set counter mode */
-       writeb(byte, base_address + (i8254_control_reg << regshift));
-       byte = count & 0xff;    /* lsb of counter value */
-       writeb(byte, base_address + (counter_number << regshift));
-       byte = (count >> 8) & 0xff;     /* msb of counter value */
-       writeb(byte, base_address + (counter_number << regshift));
-
-       return 0;
-}
-
-/* Returns 16 bit counter value, should work for 8253 also. */
-static inline int i8254_read(unsigned long base_address, unsigned int regshift,
-                            unsigned int counter_number)
-{
-       unsigned int byte;
-       int ret;
-
-       if (counter_number > 2)
-               return -1;
-
-       /* latch counter */
-       byte = counter_number << 6;
-       outb(byte, base_address + (i8254_control_reg << regshift));
-
-       /* read lsb */
-       ret = inb(base_address + (counter_number << regshift));
-       /* read msb */
-       ret += inb(base_address + (counter_number << regshift)) << 8;
-
-       return ret;
-}
-
-static inline int i8254_mm_read(void __iomem *base_address,
-                               unsigned int regshift,
-                               unsigned int counter_number)
-{
-       unsigned int byte;
-       int ret;
-
-       if (counter_number > 2)
-               return -1;
-
-       /* latch counter */
-       byte = counter_number << 6;
-       writeb(byte, base_address + (i8254_control_reg << regshift));
-
-       /* read lsb */
-       ret = readb(base_address + (counter_number << regshift));
-       /* read msb */
-       ret += readb(base_address + (counter_number << regshift)) << 8;
-
-       return ret;
-}
-
-/* Loads 16 bit initial counter value, should work for 8253 also. */
-static inline void i8254_write(unsigned long base_address,
-                              unsigned int regshift,
-                              unsigned int counter_number, unsigned int count)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return;
-
-       byte = count & 0xff;    /* lsb of counter value */
-       outb(byte, base_address + (counter_number << regshift));
-       byte = (count >> 8) & 0xff;     /* msb of counter value */
-       outb(byte, base_address + (counter_number << regshift));
-}
-
-static inline void i8254_mm_write(void __iomem *base_address,
-                                 unsigned int regshift,
-                                 unsigned int counter_number,
-                                 unsigned int count)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return;
-
-       byte = count & 0xff;    /* lsb of counter value */
-       writeb(byte, base_address + (counter_number << regshift));
-       byte = (count >> 8) & 0xff;     /* msb of counter value */
-       writeb(byte, base_address + (counter_number << regshift));
-}
-
-/*
- * Set counter mode, should work for 8253 also.
- * Note: the 'mode' value is different to that for i8254_load() and comes
- * from the INSN_CONFIG_8254_SET_MODE command:
- *   I8254_MODE0, I8254_MODE1, ..., I8254_MODE5
- * OR'ed with:
- *   I8254_BCD, I8254_BINARY
- */
-static inline int i8254_set_mode(unsigned long base_address,
-                                unsigned int regshift,
-                                unsigned int counter_number, unsigned int mode)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return -1;
-       if (mode > (I8254_MODE5 | I8254_BCD))
-               return -1;
-
-       byte = counter_number << 6;
-       byte |= 0x30;           /* load low then high byte */
-       byte |= mode;           /* set counter mode and BCD|binary */
-       outb(byte, base_address + (i8254_control_reg << regshift));
-
-       return 0;
-}
-
-static inline int i8254_mm_set_mode(void __iomem *base_address,
-                                   unsigned int regshift,
-                                   unsigned int counter_number,
-                                   unsigned int mode)
-{
-       unsigned int byte;
-
-       if (counter_number > 2)
-               return -1;
-       if (mode > (I8254_MODE5 | I8254_BCD))
-               return -1;
-
-       byte = counter_number << 6;
-       byte |= 0x30;           /* load low then high byte */
-       byte |= mode;           /* set counter mode and BCD|binary */
-       writeb(byte, base_address + (i8254_control_reg << regshift));
-
-       return 0;
-}
-
-static inline int i8254_status(unsigned long base_address,
-                              unsigned int regshift,
-                              unsigned int counter_number)
-{
-       outb(0xE0 | (2 << counter_number),
-            base_address + (i8254_control_reg << regshift));
-       return inb(base_address + (counter_number << regshift));
-}
-
-static inline int i8254_mm_status(void __iomem *base_address,
-                                 unsigned int regshift,
-                                 unsigned int counter_number)
-{
-       writeb(0xE0 | (2 << counter_number),
-              base_address + (i8254_control_reg << regshift));
-       return readb(base_address + (counter_number << regshift));
-}
-
-#endif
-
-#endif
index 984764211a2df11533fecf54e6ebf2f47ab8b594..bb9854b568077b80f5203c3861e70ab6c1eb71b9 100644 (file)
@@ -62,9 +62,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "8255.h"
 
@@ -178,7 +177,7 @@ static const struct pci_8255_boardinfo pci_8255_boards[] = {
        },
 };
 
-/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+/* ripped from mite.h and mite_setup2() to avoid mite dependency */
 #define MITE_IODWBSR   0xc0     /* IO Device Window Base Size Register */
 #define WENAB          (1 << 7) /* window enable */
 
index 7d1fbd53a8abdbfd8a80340a0308cbd6fe448bd5..d6d834006015836996ed752c186edf502cdbc38d 100644 (file)
@@ -3,6 +3,7 @@
 ccflags-$(CONFIG_COMEDI_DEBUG)         := -DDEBUG
 
 # Comedi "helper" modules
+obj-$(CONFIG_COMEDI_8254)              += comedi_8254.o
 obj-$(CONFIG_COMEDI_ISADMA)            += comedi_isadma.o
 
 # Comedi misc drivers
index 4911b627203bf83f79472fcdfc3b38f3963f7c84..f82cee40c8e60da980d6b58d5394c28ce7cb16bf 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
@@ -238,7 +237,7 @@ static int apci1032_cos_cmd(struct comedi_device *dev,
 
        if (!devpriv->ctrl) {
                dev_warn(dev->class_dev,
-                       "Interrupts disabled due to mode configuration!\n");
+                        "Interrupts disabled due to mode configuration!\n");
                return -EINVAL;
        }
 
@@ -296,7 +295,7 @@ static int apci1032_di_insn_bits(struct comedi_device *dev,
 }
 
 static int apci1032_auto_attach(struct comedi_device *dev,
-                                         unsigned long context_unused)
+                               unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct apci1032_private *devpriv;
index f15aa1f6b4762eb2bbb1921c388e8ff735415f9a..c71847eb749bd4536818f1822a88c2fc59c527bd 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 #include "z8536.h"
@@ -249,8 +248,8 @@ static irqreturn_t apci1500_interrupt(int irq, void *d)
         *
         *    Mask     Meaning
         * ----------  ------------------------------------------
-        * 0x00000001  Event 1 has occured
-        * 0x00000010  Event 2 has occured
+        * 0x00000001  Event 1 has occurred
+        * 0x00000010  Event 2 has occurred
         * 0x00000100  Counter/timer 1 has run down (not implemented)
         * 0x00001000  Counter/timer 2 has run down (not implemented)
         * 0x00010000  Counter 3 has run down (not implemented)
index d8410415cc90e5901771090df02f0dfddefb2881..c3505a52cdc257ba7dbfea6be40578d037f12b5e 100644 (file)
@@ -23,9 +23,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "addi_watchdog.h"
 #include "comedi_fc.h"
 
index 6872b69da5dbf730b981b2cbb8fce95636be50f3..c481c48cdbde9f4063d425d61d77a2e8e150afe6 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "comedi_fc.h"
 #include "addi_tcw.h"
 #include "addi_watchdog.h"
@@ -407,7 +406,7 @@ static int apci1564_cos_cmd(struct comedi_device *dev,
 
        if (!devpriv->ctrl) {
                dev_warn(dev->class_dev,
-                       "Interrupts disabled due to mode configuration!\n");
+                        "Interrupts disabled due to mode configuration!\n");
                return -EINVAL;
        }
 
@@ -430,7 +429,7 @@ static int apci1564_cos_cancel(struct comedi_device *dev,
 }
 
 static int apci1564_auto_attach(struct comedi_device *dev,
-                                     unsigned long context_unused)
+                               unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct apci1564_private *devpriv;
index a1248dab369f30f3e8ca63c6049fd0d9277c391c..c63133a12a4e12aa3a63c57cc42e307bd9ac614a 100644 (file)
@@ -23,9 +23,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * Register I/O map
index eebf4f151b39ce7d6a3a47126c733b113101c72b..86abb720169877875a8ecfcb45ac16fefca683e3 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "addi_watchdog.h"
 #include "comedi_fc.h"
 
index 1f9d13661ac902ca8c5435084c478a934f97b4d5..2b382a52d80d41c0679857eef6fb03e3df12e986 100644 (file)
@@ -23,9 +23,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "addi_watchdog.h"
 
 /*
index c65f9407fd068c872944b0d3ac27249d76558e6a..5822f1fe359a17f85012c9260d8b05d0ce460688 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
index 5961f195ba0bfaacc811109eba14b3da98100f0e..0869f7f66842df9e4969e2c80b3fc11520ddae10 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 
@@ -203,7 +202,7 @@ static unsigned short apci3501_eeprom_readw(unsigned long iobase,
                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);
+                    iobase + AMCC_OP_REG_MCSR_NVDATA);
                apci3501_eeprom_wait(iobase);
 
                /* Read the eeprom data byte */
@@ -270,7 +269,7 @@ static irqreturn_t apci3501_interrupt(int irq, void *d)
 
        /*  Disable Interrupt */
        ul_Command1 = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
-       ul_Command1 = (ul_Command1 & 0xFFFFF9FDul);
+       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;
@@ -282,7 +281,7 @@ static irqreturn_t apci3501_interrupt(int irq, void *d)
        /* 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);
+       ul_Command1 = (ul_Command1 & 0xFFFFF9FDul) | 1 << 1;
        outl(ul_Command1, dev->iobase + APCI3501_TIMER_CTRL_REG);
        inl(dev->iobase + APCI3501_TIMER_STATUS_REG);
 
index c173810a3b5b5d044907fd8536d9a50dd1f06474..8dadab8b3e09a45ae80aceb63b29df01966ade5c 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 
index c5b082d4e51e3ccce736af728d8a5e17d6dfb5f0..9d9853fe54a006cd8316ea20e4fb6cbfae090c33 100644 (file)
@@ -54,7 +54,7 @@ static int addi_watchdog_insn_config(struct comedi_device *dev,
 
                /* Time base is 20ms, let the user know the timeout */
                dev_info(dev->class_dev, "watchdog enabled, timeout:%dms\n",
-                       20 * reload + 20);
+                        20 * reload + 20);
                break;
        case INSN_CONFIG_DISARM:
                spriv->wdog_ctrl = 0;
index a3ea4b7c18dda50975d0d51dd7c908eb5eda9dc9..7ed3fd6fbd3ec24ceb1f321c13b23aaebf8071de 100644 (file)
 /*
  * Driver: adl_pci6208
  * Description: ADLink PCI-6208/6216 Series Multi-channel Analog Output Cards
- * Devices: [ADLink] PCI-6208 (adl_pci6208), PCI-6216 (adl_pci6216)
+ * Devices: [ADLink] PCI-6208 (adl_pci6208), PCI-6216
  * Author: nsyeow <nsyeow@pd.jaring.my>
- * Updated: Fri, 30 Jan 2004 14:44:27 +0800
+ * Updated: Wed, 11 Feb 2015 11:37:18 +0000
  * Status: untested
  *
  * Configuration Options: not applicable, uses PCI auto config
+ *
+ * All supported devices share the same PCI device ID and are treated as a
+ * PCI-6216 with 16 analog output channels.  On a PCI-6208, the upper 8
+ * channels exist in registers, but don't go to DAC chips.
  */
 
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI-6208/6216-GL register map
 #define PCI6208_DIO_DI_MASK            (0xf0)
 #define PCI6208_DIO_DI_SHIFT           (4)
 
-enum pci6208_boardid {
-       BOARD_PCI6208,
-       BOARD_PCI6216,
-};
-
-struct pci6208_board {
-       const char *name;
-       int ao_chans;
-};
-
-static const struct pci6208_board pci6208_boards[] = {
-       [BOARD_PCI6208] = {
-               .name           = "adl_pci6208",
-               .ao_chans       = 8,
-       },
-       [BOARD_PCI6216] = {
-               .name           = "adl_pci6216",
-               .ao_chans       = 16,
-       },
-};
-
 static int pci6208_ao_eoc(struct comedi_device *dev,
                          struct comedi_subdevice *s,
                          struct comedi_insn *insn,
@@ -136,21 +118,13 @@ static int pci6208_do_insn_bits(struct comedi_device *dev,
 }
 
 static int pci6208_auto_attach(struct comedi_device *dev,
-                              unsigned long context)
+                              unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-       const struct pci6208_board *boardinfo = NULL;
        struct comedi_subdevice *s;
        unsigned int val;
        int ret;
 
-       if (context < ARRAY_SIZE(pci6208_boards))
-               boardinfo = &pci6208_boards[context];
-       if (!boardinfo)
-               return -ENODEV;
-       dev->board_ptr = boardinfo;
-       dev->board_name = boardinfo->name;
-
        ret = comedi_pci_enable(dev);
        if (ret)
                return ret;
@@ -164,7 +138,7 @@ static int pci6208_auto_attach(struct comedi_device *dev,
        /* analog output subdevice */
        s->type         = COMEDI_SUBD_AO;
        s->subdev_flags = SDF_WRITABLE;
-       s->n_chan       = boardinfo->ao_chans;
+       s->n_chan       = 16;   /* Only 8 usable on PCI-6208 */
        s->maxdata      = 0xffff;
        s->range_table  = &range_bipolar10;
        s->insn_write   = pci6208_ao_insn_write;
@@ -217,8 +191,9 @@ static int adl_pci6208_pci_probe(struct pci_dev *dev,
 }
 
 static const struct pci_device_id adl_pci6208_pci_table[] = {
-       { PCI_VDEVICE(ADLINK, 0x6208), BOARD_PCI6208 },
-       { PCI_VDEVICE(ADLINK, 0x6216), BOARD_PCI6216 },
+       { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
+       { PCI_DEVICE_SUB(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+                        0x9999, 0x6208) },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, adl_pci6208_pci_table);
index 618e641ffaac6a7f6673ee088d8f45a9da92b812..934af3ff789732f4aeb4928997e72318ad609f7b 100644 (file)
@@ -53,9 +53,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * Register I/O map (32-bit access only)
index cc6c53b800a7dfbe289a68cdc388c33919972d27..da901c8dec0e2ade20d736136a30d48f8821822b 100644 (file)
@@ -28,9 +28,8 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #define PCI8164_AXIS(x)                ((x) * 0x08)
 #define PCI8164_CMD_MSTS_REG   0x00
@@ -69,7 +68,7 @@ static int adl_pci8164_insn_write(struct comedi_device *dev,
 }
 
 static int adl_pci8164_auto_attach(struct comedi_device *dev,
-                                            unsigned long context_unused)
+                                  unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct comedi_subdevice *s;
index f68dc99f8e277a2031f12dff57090b2f1a76c6e0..5ca7c6e45d933d8e0d6944c727c83d72914be44c 100644 (file)
@@ -65,15 +65,14 @@ TODO:
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
-#include "8253.h"
 #include "plx9052.h"
 #include "comedi_fc.h"
+#include "comedi_8254.h"
 
 #define PCI9111_FIFO_HALF_SIZE 512
 
@@ -137,9 +136,6 @@ struct pci9111_private_data {
        unsigned int chunk_counter;
        unsigned int chunk_num_samples;
 
-       unsigned int div1;
-       unsigned int div2;
-
        unsigned short ai_bounce_buffer[2 * PCI9111_FIFO_HALF_SIZE];
 };
 
@@ -167,21 +163,6 @@ static void plx9050_interrupt_control(unsigned long io_base,
        outb(flags, io_base + PLX9052_INTCSR);
 }
 
-static void pci9111_timer_set(struct comedi_device *dev)
-{
-       struct pci9111_private_data *dev_private = dev->private;
-       unsigned long timer_base = dev->iobase + PCI9111_8254_BASE_REG;
-
-       i8254_set_mode(timer_base, 1, 0, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY);
-
-       udelay(1);
-
-       i8254_write(timer_base, 1, 2, dev_private->div2);
-       i8254_write(timer_base, 1, 1, dev_private->div1);
-}
-
 enum pci9111_ISC0_sources {
        irq_on_eoc,
        irq_on_fifo_half_full
@@ -281,7 +262,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
                                  struct comedi_cmd *cmd)
 {
-       struct pci9111_private_data *dev_private = dev->private;
        int err = 0;
        unsigned int arg;
 
@@ -345,10 +325,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
 
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
-                                         &dev_private->div1,
-                                         &dev_private->div2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -376,7 +353,6 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                return 5;
 
        return 0;
-
 }
 
 static int pci9111_ai_do_cmd(struct comedi_device *dev,
@@ -400,13 +376,14 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev,
        /*  This is the same gain on every channel */
 
        outb(CR_RANGE(cmd->chanlist[0]) & PCI9111_AI_RANGE_MASK,
-               dev->iobase + PCI9111_AI_RANGE_STAT_REG);
+            dev->iobase + PCI9111_AI_RANGE_STAT_REG);
 
        /*  Set timer pacer */
        dev_private->scan_delay = 0;
        if (cmd->convert_src == TRIG_TIMER) {
                trig |= PCI9111_AI_TRIG_CTRL_TPST;
-               pci9111_timer_set(dev);
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
                pci9111_fifo_reset(dev);
                pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
                                             irq_on_timer_tick);
@@ -593,7 +570,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
        status = inb(dev->iobase + PCI9111_AI_RANGE_STAT_REG);
        if ((status & PCI9111_AI_RANGE_MASK) != range) {
                outb(range & PCI9111_AI_RANGE_MASK,
-                       dev->iobase + PCI9111_AI_RANGE_STAT_REG);
+                    dev->iobase + PCI9111_AI_RANGE_STAT_REG);
        }
 
        pci9111_fifo_reset(dev);
@@ -667,16 +644,11 @@ static int pci9111_reset(struct comedi_device *dev)
        /* disable A/D triggers (software trigger mode) and auto scan off */
        outb(0, dev->iobase + PCI9111_AI_TRIG_CTRL_REG);
 
-       /* Reset 8254 chip */
-       dev_private->div1 = 0;
-       dev_private->div2 = 0;
-       pci9111_timer_set(dev);
-
        return 0;
 }
 
 static int pci9111_auto_attach(struct comedi_device *dev,
-                                        unsigned long context_unused)
+                              unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct pci9111_private_data *dev_private;
@@ -702,6 +674,11 @@ static int pci9111_auto_attach(struct comedi_device *dev,
                        dev->irq = pcidev->irq;
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCI9111_8254_BASE_REG,
+                                     I8254_OSC_BASE_2MHZ, I8254_IO16, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index f61e392c2d3ef4ba93be7708d48ac17ab1343bb5..eb4a528b643195ba7411969f69d7cd458794a4f8 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/gfp.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "amcc_s5933.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "comedi_fc.h"
 
 #define IORANGE_9118   64      /* I hope */
@@ -94,8 +93,7 @@
 /*
  * PCI BAR2 Register map (dev->iobase)
  */
-#define PCI9118_TIMER_REG(x)           (0x00 + ((x) * 4))
-#define PCI9118_TIMER_CTRL_REG         0x0c
+#define PCI9118_TIMER_BASE             0x00
 #define PCI9118_AI_FIFO_REG            0x10
 #define PCI9118_AO_REG(x)              (0x10 + ((x) * 4))
 #define PCI9118_AI_STATUS_REG          0x18
@@ -239,10 +237,6 @@ struct pci9118_private {
                                         * measure can start/stop
                                         * on external trigger
                                         */
-       unsigned int ai_divisor1, ai_divisor2;  /*
-                                                * divisors for start of measure
-                                                * on external start
-                                                */
        unsigned int dma_actbuf;                /* which buffer is used now */
        struct pci9118_dmabuf dmabuf[2];
        int softsshdelay;               /*
@@ -297,24 +291,6 @@ static void pci9118_amcc_int_ena(struct comedi_device *dev, bool enable)
        outl(intcsr, devpriv->iobase_a + AMCC_OP_REG_INTCSR);
 }
 
-static void pci9118_timer_write(struct comedi_device *dev,
-                               unsigned int timer, unsigned int val)
-{
-       outl(val & 0xff, dev->iobase + PCI9118_TIMER_REG(timer));
-       outl((val >> 8) & 0xff, dev->iobase + PCI9118_TIMER_REG(timer));
-}
-
-static void pci9118_timer_set_mode(struct comedi_device *dev,
-                                  unsigned int timer, unsigned int mode)
-{
-       unsigned int val;
-
-       val = timer << 6;       /* select timer */
-       val |= 0x30;            /* load low then high byte */
-       val |= mode;            /* set timer mode and BCD|binary */
-       outl(val, dev->iobase + PCI9118_TIMER_CTRL_REG);
-}
-
 static void pci9118_ai_reset_fifo(struct comedi_device *dev)
 {
        /* writing any value resets the A/D FIFO */
@@ -440,8 +416,8 @@ static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev,
        devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG |
                          PCI9118_AI_CFG_AM;
        outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
-       pci9118_timer_set_mode(dev, 0, I8254_MODE0);
-       pci9118_timer_write(dev, 0, dmabuf->hw >> 1);
+       comedi_8254_load(dev->pacer, 0, dmabuf->hw >> 1,
+                        I8254_MODE0 | I8254_BINARY);
        devpriv->ai_cfg |= PCI9118_AI_CFG_START;
        outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
 }
@@ -577,15 +553,16 @@ static void pci9118_calc_divisors(struct comedi_device *dev,
                                  unsigned int *div1, unsigned int *div2,
                                  unsigned int chnsshfront)
 {
+       struct comedi_8254 *pacer = dev->pacer;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       *div1 = *tim2 / I8254_OSC_BASE_4MHZ;    /* convert timer (burst) */
-       *div2 = *tim1 / I8254_OSC_BASE_4MHZ;    /* scan timer */
+       *div1 = *tim2 / pacer->osc_base;        /* convert timer (burst) */
+       *div2 = *tim1 / pacer->osc_base;        /* scan timer */
        *div2 = *div2 / *div1;                  /* major timer is c1*c2 */
        if (*div2 < chans)
                *div2 = chans;
 
-       *tim2 = *div1 * I8254_OSC_BASE_4MHZ;    /* real convert timer */
+       *tim2 = *div1 * pacer->osc_base;        /* real convert timer */
 
        if (cmd->convert_src == TRIG_NOW && !chnsshfront) {
                /* use BSSH signal */
@@ -593,21 +570,13 @@ static void pci9118_calc_divisors(struct comedi_device *dev,
                        *div2 = chans + 2;
        }
 
-       *tim1 = *div1 * *div2 * I8254_OSC_BASE_4MHZ;
+       *tim1 = *div1 * *div2 * pacer->osc_base;
 }
 
 static void pci9118_start_pacer(struct comedi_device *dev, int mode)
 {
-       struct pci9118_private *devpriv = dev->private;
-
-       pci9118_timer_set_mode(dev, 1, I8254_MODE2);
-       pci9118_timer_set_mode(dev, 2, I8254_MODE2);
-       udelay(1);
-
-       if ((mode == 1) || (mode == 2) || (mode == 4)) {
-               pci9118_timer_write(dev, 2, devpriv->ai_divisor2);
-               pci9118_timer_write(dev, 1, devpriv->ai_divisor1);
-       }
+       if (mode == 1 || mode == 2 || mode == 4)
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 }
 
 static int pci9118_ai_cancel(struct comedi_device *dev,
@@ -618,7 +587,7 @@ static int pci9118_ai_cancel(struct comedi_device *dev,
        if (devpriv->usedma)
                pci9118_amcc_dma_ena(dev, false);
        pci9118_exttrg_enable(dev, false);
-       pci9118_start_pacer(dev, 0);    /* stop 8254 counters */
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
        /* set default config (disable burst and triggers) */
        devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG;
        outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
@@ -663,7 +632,6 @@ static void pci9118_ai_munge(struct comedi_device *dev,
                        array[i] ^= 0x8000;
                else
                        array[i] = (array[i] >> 4) & 0x0fff;
-
        }
 }
 
@@ -966,7 +934,7 @@ static int Compute_and_setup_dma(struct comedi_device *dev,
 /* outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); */
        pci9118_amcc_dma_ena(dev, true);
        outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS,
-                       devpriv->iobase_a + AMCC_OP_REG_INTCSR);
+            devpriv->iobase_a + AMCC_OP_REG_INTCSR);
                                                /* allow bus mastering */
 
        return 0;
@@ -975,6 +943,7 @@ static int Compute_and_setup_dma(struct comedi_device *dev,
 static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct pci9118_private *devpriv = dev->private;
+       struct comedi_8254 *pacer = dev->pacer;
        struct comedi_cmd *cmd = &s->async->cmd;
        unsigned int addchans = 0;
 
@@ -1093,12 +1062,10 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                else
                        devpriv->ai_do = 1;
 
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ,
-                                         &devpriv->ai_divisor1,
-                                         &devpriv->ai_divisor2,
-                                         &cmd->convert_arg,
-                                         devpriv->ai_flags &
-                                         CMDF_ROUND_NEAREST);
+               comedi_8254_cascade_ns_to_timer(pacer, &cmd->convert_arg,
+                                               devpriv->ai_flags &
+                                               CMDF_ROUND_NEAREST);
+               comedi_8254_update_divisors(pacer);
 
                devpriv->ai_ctrl |= PCI9118_AI_CTRL_TMRTR;
 
@@ -1112,8 +1079,8 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
                        devpriv->ai_cfg |= PCI9118_AI_CFG_AM;
                        outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
-                       pci9118_timer_set_mode(dev, 0, I8254_MODE0);
-                       pci9118_timer_write(dev, 0, dmabuf->hw >> 1);
+                       comedi_8254_load(pacer, 0, dmabuf->hw >> 1,
+                                        I8254_MODE0 | I8254_BINARY);
                        devpriv->ai_cfg |= PCI9118_AI_CFG_START;
                }
        }
@@ -1133,8 +1100,8 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                                      &cmd->scan_begin_arg, &cmd->convert_arg,
                                      devpriv->ai_flags,
                                      devpriv->ai_n_realscanlen,
-                                     &devpriv->ai_divisor1,
-                                     &devpriv->ai_divisor2,
+                                     &pacer->divisor1,
+                                     &pacer->divisor2,
                                      devpriv->ai_add_front);
 
                devpriv->ai_ctrl |= PCI9118_AI_CTRL_TMRTR;
@@ -1162,8 +1129,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        if (devpriv->usedma)
                devpriv->ai_ctrl |= PCI9118_AI_CTRL_DMA;
 
-       pci9118_start_pacer(dev, -1);   /* stop pacer */
-
        /* set default config (disable burst and triggers) */
        devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG;
        outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
@@ -1206,7 +1171,6 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
        int err = 0;
        unsigned int flags;
        unsigned int arg;
-       unsigned int divisor1 = 0, divisor2 = 0;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -1323,17 +1287,13 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ,
-                                         &divisor1, &divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) {
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_4MHZ,
-                                         &divisor1, &divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER &&
@@ -1482,10 +1442,6 @@ static void pci9118_reset(struct comedi_device *dev)
        inl(dev->iobase + PCI9118_INT_CTRL_REG);
        inl(dev->iobase + PCI9118_AI_STATUS_REG);
 
-       /* reset and stop counters */
-       pci9118_timer_set_mode(dev, 0, I8254_MODE0);
-       pci9118_start_pacer(dev, 0);
-
        /* reset DMA and scan queue */
        outl(0, dev->iobase + PCI9118_AI_BURST_NUM_REG);
        outl(1, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
@@ -1590,6 +1546,11 @@ static int pci9118_common_attach(struct comedi_device *dev,
        devpriv->iobase_a = pci_resource_start(pcidev, 0);
        dev->iobase = pci_resource_start(pcidev, 2);
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCI9118_TIMER_BASE,
+                                     I8254_OSC_BASE_4MHZ, I8254_IO32, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        pci9118_reset(dev);
 
        if (pcidev->irq) {
index 8b15cbec9891996dedf11502d74c43ed9486c696..bc5f97f50f9a478b6af4aed56137c64252b310a3 100644 (file)
@@ -69,8 +69,6 @@ If you do not specify any options, they will default to
 
    13-oct-2007
      + first try
-
-
 */
 
 #include <linux/module.h>
@@ -170,7 +168,6 @@ static int adq12b_di_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
                               struct comedi_insn *insn, unsigned int *data)
 {
-
        /* only bits 0-4 have information about digital inputs */
        data[1] = (inb(dev->iobase + ADQ12B_STINR) & ADQ12B_STINR_IN_MASK);
 
index 3f72451d2de01aa44d1b16f633ddd8999894db25..f71750bb430455185cb41c9554e270f5e2abd1e0 100644 (file)
@@ -4,7 +4,7 @@
  * Author: Michal Dobes <dobes@tesnet.cz>
  *
  * Thanks to ZhenGang Shang <ZhenGang.Shang@Advantech.com.cn>
- * for testing and informations.
+ * for testing and information.
  *
  *  hardware driver for Advantech cards:
  *   card:   PCI-1710, PCI-1710HG, PCI-1711, PCI-1713, PCI-1720, PCI-1731
@@ -42,13 +42,12 @@ Configuration options:
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "amcc_s5933.h"
 
 #define PCI171x_AD_DATA         0      /* R:   A/D data */
@@ -67,11 +66,6 @@ Configuration options:
 
 #define PCI171X_TIMER_BASE     0x18
 
-#define PCI171x_CNT0   24      /* R/W: 8254 counter 0 */
-#define PCI171x_CNT1   26      /* R/W: 8254 counter 1 */
-#define PCI171x_CNT2   28      /* R/W: 8254 counter 2 */
-#define PCI171x_CNTCTRL        30      /* W:   8254 counter control */
-
 /* upper bits from status register (PCI171x_STATUS) (lower is same with control
  * reg) */
 #define        Status_FE       0x0100  /* 1=FIFO is empty */
@@ -87,16 +81,6 @@ Configuration options:
 #define Control_EXT    0x0004  /* 1=external trigger source */
 #define Control_PACER  0x0002  /* 1=enable internal 8254 trigger source */
 #define Control_SW     0x0001  /* 1=enable software trigger source */
-/* bits from counter control register (PCI171x_CNTCTRL) */
-#define Counter_BCD     0x0001 /* 0 = binary counter, 1 = BCD counter */
-#define Counter_M0      0x0002 /* M0-M2 select modes 0-5 */
-#define Counter_M1      0x0004 /* 000 = mode 0, 010 = mode 2 ... */
-#define Counter_M2      0x0008
-#define Counter_RW0     0x0010 /* RW0/RW1 select read/write mode */
-#define Counter_RW1     0x0020
-#define Counter_SC0     0x0040 /* Select Counter. Only 00 or 11 may */
-#define Counter_SC1     0x0080 /* be used, 00 for CNT0,
-                                * 11 for read-back command */
 
 #define PCI1720_DA0     0      /* W:   D/A register 0 */
 #define PCI1720_DA1     2      /* W:   D/A register 1 */
@@ -265,15 +249,9 @@ struct pci1710_private {
        unsigned char ai_et;
        unsigned int ai_et_CntrlReg;
        unsigned int ai_et_MuxVal;
-       unsigned int next_divisor1;
-       unsigned int next_divisor2;
-       unsigned int divisor1;
-       unsigned int divisor2;
        unsigned int act_chanlist[32];  /*  list of scanned channel */
        unsigned char saved_seglen;     /* len of the non-repeating chanlist */
        unsigned char da_ranges;        /*  copy of D/A outpit range register */
-       unsigned int cnt0_write_wait;   /* after a write, wait for update of the
-                                        * internal state */
 };
 
 static int pci171x_ai_check_chanlist(struct comedi_device *dev,
@@ -508,105 +486,6 @@ static int pci171x_do_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
-static void pci171x_start_pacer(struct comedi_device *dev,
-                               bool load_counters)
-{
-       struct pci1710_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + PCI171X_TIMER_BASE;
-
-       i8254_set_mode(timer_base, 1, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 1, 1, I8254_MODE2 | I8254_BINARY);
-
-       if (load_counters) {
-               i8254_write(timer_base, 1, 2, devpriv->divisor2);
-               i8254_write(timer_base, 1, 1, devpriv->divisor1);
-       }
-}
-
-static int pci171x_counter_insn_read(struct comedi_device *dev,
-                                    struct comedi_subdevice *s,
-                                    struct comedi_insn *insn,
-                                    unsigned int *data)
-{
-       unsigned int msb, lsb, ccntrl;
-       int i;
-
-       ccntrl = 0xD2;          /* count only */
-       for (i = 0; i < insn->n; i++) {
-               outw(ccntrl, dev->iobase + PCI171x_CNTCTRL);
-
-               lsb = inw(dev->iobase + PCI171x_CNT0) & 0xFF;
-               msb = inw(dev->iobase + PCI171x_CNT0) & 0xFF;
-
-               data[0] = lsb | (msb << 8);
-       }
-
-       return insn->n;
-}
-
-static int pci171x_counter_insn_write(struct comedi_device *dev,
-                                     struct comedi_subdevice *s,
-                                     struct comedi_insn *insn,
-                                     unsigned int *data)
-{
-       struct pci1710_private *devpriv = dev->private;
-       uint msb, lsb, ccntrl, status;
-
-       lsb = data[0] & 0x00FF;
-       msb = (data[0] & 0xFF00) >> 8;
-
-       /* write lsb, then msb */
-       outw(lsb, dev->iobase + PCI171x_CNT0);
-       outw(msb, dev->iobase + PCI171x_CNT0);
-
-       if (devpriv->cnt0_write_wait) {
-               /* wait for the new count to be loaded */
-               ccntrl = 0xE2;
-               do {
-                       outw(ccntrl, dev->iobase + PCI171x_CNTCTRL);
-                       status = inw(dev->iobase + PCI171x_CNT0) & 0xFF;
-               } while (status & 0x40);
-       }
-
-       return insn->n;
-}
-
-static int pci171x_counter_insn_config(struct comedi_device *dev,
-                                      struct comedi_subdevice *s,
-                                      struct comedi_insn *insn,
-                                      unsigned int *data)
-{
-#ifdef unused
-       /* This doesn't work like a normal Comedi counter config */
-       struct pci1710_private *devpriv = dev->private;
-       uint ccntrl = 0;
-
-       devpriv->cnt0_write_wait = data[0] & 0x20;
-
-       /* internal or external clock? */
-       if (!(data[0] & 0x10)) {        /* internal */
-               devpriv->CntrlReg &= ~Control_CNT0;
-       } else {
-               devpriv->CntrlReg |= Control_CNT0;
-       }
-       outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
-
-       if (data[0] & 0x01)
-               ccntrl |= Counter_M0;
-       if (data[0] & 0x02)
-               ccntrl |= Counter_M1;
-       if (data[0] & 0x04)
-               ccntrl |= Counter_M2;
-       if (data[0] & 0x08)
-               ccntrl |= Counter_BCD;
-       ccntrl |= Counter_RW0;  /* set read/write mode */
-       ccntrl |= Counter_RW1;
-       outw(ccntrl, dev->iobase + PCI171x_CNTCTRL);
-#endif
-
-       return 1;
-}
-
 static int pci1720_ao_insn_write(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
                                 struct comedi_insn *insn,
@@ -646,7 +525,7 @@ static int pci171x_ai_cancel(struct comedi_device *dev,
        devpriv->CntrlReg |= Control_SW;
        /* reset any operations */
        outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
-       pci171x_start_pacer(dev, false);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
        outb(0, dev->iobase + PCI171x_CLRFIFO);
        outb(0, dev->iobase + PCI171x_CLRINT);
 
@@ -767,7 +646,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
                outb(0, dev->iobase + PCI171x_CLRINT);
                outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX);
                outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
-               pci171x_start_pacer(dev, true);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
                return IRQ_HANDLED;
        }
 
@@ -786,8 +665,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        struct pci1710_private *devpriv = dev->private;
        struct comedi_cmd *cmd = &s->async->cmd;
 
-       pci171x_start_pacer(dev, false);
-
        pci171x_ai_setup_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len,
                                  devpriv->saved_seglen);
 
@@ -798,10 +675,9 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        if ((cmd->flags & CMDF_WAKE_EOS) == 0)
                devpriv->CntrlReg |= Control_ONEFH;
 
-       devpriv->divisor1 = devpriv->next_divisor1;
-       devpriv->divisor2 = devpriv->next_divisor2;
-
        if (cmd->convert_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(dev->pacer);
+
                devpriv->CntrlReg |= Control_PACER | Control_IRQEN;
                if (cmd->start_src == TRIG_EXT) {
                        devpriv->ai_et_CntrlReg = devpriv->CntrlReg;
@@ -815,7 +691,7 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
 
                if (cmd->start_src == TRIG_NOW)
-                       pci171x_start_pacer(dev, true);
+                       comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
        } else {        /* TRIG_EXT */
                devpriv->CntrlReg |= Control_EXT | Control_IRQEN;
                outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
@@ -828,9 +704,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
                              struct comedi_subdevice *s,
                              struct comedi_cmd *cmd)
 {
-       struct pci1710_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -877,11 +751,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
        /* step 4: fix up any arguments */
 
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->next_divisor1,
-                                         &devpriv->next_divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -898,19 +770,54 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
        return 0;
 }
 
+static int pci171x_insn_counter_config(struct comedi_device *dev,
+                                      struct comedi_subdevice *s,
+                                      struct comedi_insn *insn,
+                                      unsigned int *data)
+{
+       struct pci1710_private *devpriv = dev->private;
+
+       switch (data[0]) {
+       case INSN_CONFIG_SET_CLOCK_SRC:
+               switch (data[1]) {
+               case 0: /* internal */
+                       devpriv->ai_et_CntrlReg &= ~Control_CNT0;
+                       break;
+               case 1: /* external */
+                       devpriv->ai_et_CntrlReg |= Control_CNT0;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               outw(devpriv->ai_et_CntrlReg, dev->iobase + PCI171x_CONTROL);
+               break;
+       case INSN_CONFIG_GET_CLOCK_SRC:
+               if (devpriv->ai_et_CntrlReg & Control_CNT0) {
+                       data[1] = 1;
+                       data[2] = 0;
+               } else {
+                       data[1] = 0;
+                       data[2] = I8254_OSC_BASE_10MHZ;
+               }
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return insn->n;
+}
+
 static int pci171x_reset(struct comedi_device *dev)
 {
        const struct boardtype *board = dev->board_ptr;
        struct pci1710_private *devpriv = dev->private;
 
-       outw(0x30, dev->iobase + PCI171x_CNTCTRL);
        /* Software trigger, CNT0=external */
        devpriv->CntrlReg = Control_SW | Control_CNT0;
        /* reset any operations */
        outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
        outb(0, dev->iobase + PCI171x_CLRFIFO); /*  clear FIFO */
        outb(0, dev->iobase + PCI171x_CLRINT);  /*  clear INT request */
-       pci171x_start_pacer(dev, false);
        devpriv->da_ranges = 0;
        if (board->has_ao) {
                /* set DACs to 0..5V */
@@ -977,6 +884,11 @@ static int pci1710_auto_attach(struct comedi_device *dev,
                return ret;
        dev->iobase = pci_resource_start(pcidev, 2);
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCI171X_TIMER_BASE,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        n_subdevices = 0;
        if (board->n_aichan)
                n_subdevices++;
@@ -1073,16 +985,17 @@ static int pci1710_auto_attach(struct comedi_device *dev,
                subdev++;
        }
 
+       /* Counter subdevice (8254) */
        if (board->has_counter) {
                s = &dev->subdevices[subdev];
-               s->type         = COMEDI_SUBD_COUNTER;
-               s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-               s->n_chan       = 1;
-               s->maxdata      = 0xffff;
-               s->range_table  = &range_unknown;
-               s->insn_read    = pci171x_counter_insn_read;
-               s->insn_write   = pci171x_counter_insn_write;
-               s->insn_config  = pci171x_counter_insn_config;
+               comedi_8254_subdevice_init(s, dev->pacer);
+
+               dev->pacer->insn_config = pci171x_insn_counter_config;
+
+               /* counters 1 and 2 are used internally for the pacer */
+               comedi_8254_set_busy(dev->pacer, 1, true);
+               comedi_8254_set_busy(dev->pacer, 2, true);
+
                subdev++;
        }
 
index f1945be89eff1468425b981550d185338b1a6ff8..1921a97cc5ca3b7d18c26dd1bbe8bd717cf189b2 100644 (file)
@@ -41,9 +41,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI Bar 2 I/O Register map (dev->iobase)
index a3573ea6f9c0f77b00447bf8b3ebd81f048b377e..f7a7dab013db152bb7bfca43177eb350bb67ae46 100644 (file)
@@ -47,9 +47,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI bar 2 Register I/O map (dev->iobase)
index 09609d6d02da283210493b9c25ed981ccd693e88..456e87013063e73eaf35724f2310d76ea6cdf50f 100644 (file)
@@ -30,13 +30,12 @@ Configuration options:
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "8255.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /* hardware types of the cards */
 enum hw_cards_id {
@@ -60,12 +59,6 @@ enum hw_io_access {
 #define MAX_DO_SUBDEVS 2       /* max number of DO subdevices per card */
 #define MAX_DIO_SUBDEVG        2       /* max number of DIO subdevices group per
                                 * card */
-#define MAX_8254_SUBDEVS   1   /* max number of 8254 counter subdevs per
-                                * card */
-                               /* (could be more than one 8254 per
-                                * subdevice) */
-
-#define SIZE_8254         4    /* 8254 IO space length */
 
 #define PCIDIO_MAINREG    2    /* main I/O region for all Advantech cards? */
 
@@ -230,7 +223,7 @@ struct diosubd_data {
        int chans;              /*  num of chans */
        int addr;               /*  PCI address ofset */
        int regs;               /*  number of registers to read or 8255
-                                   subdevices or 8254 chips */
+                                   subdevices */
        unsigned int specflags; /*  addon subdevice flags */
 };
 
@@ -243,7 +236,7 @@ struct dio_boardtype {
        struct diosubd_data sdo[MAX_DO_SUBDEVS];        /*  DO chans */
        struct diosubd_data sdio[MAX_DIO_SUBDEVG];      /*  DIO 8255 chans */
        struct diosubd_data boardid;    /*  card supports board ID switch */
-       struct diosubd_data s8254[MAX_8254_SUBDEVS];    /* 8254 subdevices */
+       unsigned long timer_regbase;
        enum hw_io_access io_access;
 };
 
@@ -286,7 +279,7 @@ static const struct dio_boardtype boardtypes[] = {
                .sdi[0]         = { 32, PCI1735_DI, 4, 0, },
                .sdo[0]         = { 32, PCI1735_DO, 4, 0, },
                .boardid        = { 4, PCI1735_BOARDID, 1, SDF_INTERNAL, },
-               .s8254[0]       = { 3, PCI1735_C8254, 1, 0, },
+               .timer_regbase  = PCI1735_C8254,
                .io_access      = IO_8b,
        },
        [TYPE_PCI1736] = {
@@ -322,7 +315,7 @@ static const struct dio_boardtype boardtypes[] = {
                .cardtype       = TYPE_PCI1751,
                .nsubdevs       = 3,
                .sdio[0]        = { 48, PCI1751_DIO, 2, 0, },
-               .s8254[0]       = { 3, PCI1751_CNT, 1, 0, },
+               .timer_regbase  = PCI1751_CNT,
                .io_access      = IO_8b,
        },
        [TYPE_PCI1752] = {
@@ -425,7 +418,6 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev,
        for (i = 0; i < d->regs; i++)
                data[1] |= inb(dev->iobase + d->addr + i) << (8 * i);
 
-
        return insn->n;
 }
 
@@ -484,83 +476,6 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
-==============================================================================
-*/
-static int pci_8254_insn_read(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data)
-{
-       const struct diosubd_data *d = (const struct diosubd_data *)s->private;
-       unsigned int chan, chip, chipchan;
-       unsigned long flags;
-
-       chan = CR_CHAN(insn->chanspec); /* channel on subdevice */
-       chip = chan / 3;                /* chip on subdevice */
-       chipchan = chan - (3 * chip);   /* channel on chip on subdevice */
-       spin_lock_irqsave(&s->spin_lock, flags);
-       data[0] = i8254_read(dev->iobase + d->addr + (SIZE_8254 * chip),
-                       0, chipchan);
-       spin_unlock_irqrestore(&s->spin_lock, flags);
-       return 1;
-}
-
-/*
-==============================================================================
-*/
-static int pci_8254_insn_write(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       const struct diosubd_data *d = (const struct diosubd_data *)s->private;
-       unsigned int chan, chip, chipchan;
-       unsigned long flags;
-
-       chan = CR_CHAN(insn->chanspec); /* channel on subdevice */
-       chip = chan / 3;                /* chip on subdevice */
-       chipchan = chan - (3 * chip);   /* channel on chip on subdevice */
-       spin_lock_irqsave(&s->spin_lock, flags);
-       i8254_write(dev->iobase + d->addr + (SIZE_8254 * chip),
-                       0, chipchan, data[0]);
-       spin_unlock_irqrestore(&s->spin_lock, flags);
-       return 1;
-}
-
-/*
-==============================================================================
-*/
-static int pci_8254_insn_config(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
-{
-       const struct diosubd_data *d = (const struct diosubd_data *)s->private;
-       unsigned int chan, chip, chipchan;
-       unsigned long iobase;
-       int ret = 0;
-       unsigned long flags;
-
-       chan = CR_CHAN(insn->chanspec); /* channel on subdevice */
-       chip = chan / 3;                /* chip on subdevice */
-       chipchan = chan - (3 * chip);   /* channel on chip on subdevice */
-       iobase = dev->iobase + d->addr + (SIZE_8254 * chip);
-       spin_lock_irqsave(&s->spin_lock, flags);
-       switch (data[0]) {
-       case INSN_CONFIG_SET_COUNTER_MODE:
-               ret = i8254_set_mode(iobase, 0, chipchan, data[1]);
-               if (ret < 0)
-                       ret = -EINVAL;
-               break;
-       case INSN_CONFIG_8254_READ_STATUS:
-               data[1] = i8254_status(iobase, 0, chipchan);
-               break;
-       default:
-               ret = -EINVAL;
-               break;
-       }
-       spin_unlock_irqrestore(&s->spin_lock, flags);
-       return ret < 0 ? ret : insn->n;
-}
-
 /*
 ==============================================================================
 */
@@ -845,9 +760,6 @@ static int pci_dio_reset(struct comedi_device *dev)
                outb(0, dev->iobase + PCI1735_DO + 1);
                outb(0, dev->iobase + PCI1735_DO + 2);
                outb(0, dev->iobase + PCI1735_DO + 3);
-               i8254_set_mode(dev->iobase + PCI1735_C8254, 0, 0, I8254_MODE0);
-               i8254_set_mode(dev->iobase + PCI1735_C8254, 0, 1, I8254_MODE0);
-               i8254_set_mode(dev->iobase + PCI1735_C8254, 0, 2, I8254_MODE0);
                break;
 
        case TYPE_PCI1736:
@@ -1029,26 +941,6 @@ static int pci_dio_add_do(struct comedi_device *dev,
        return 0;
 }
 
-/*
-==============================================================================
-*/
-static int pci_dio_add_8254(struct comedi_device *dev,
-                           struct comedi_subdevice *s,
-                           const struct diosubd_data *d)
-{
-       s->type = COMEDI_SUBD_COUNTER;
-       s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-       s->n_chan = d->chans;
-       s->maxdata = 65535;
-       s->len_chanlist = d->chans;
-       s->insn_read = pci_8254_insn_read;
-       s->insn_write = pci_8254_insn_write;
-       s->insn_config = pci_8254_insn_config;
-       s->private = (void *)d;
-
-       return 0;
-}
-
 static unsigned long pci_dio_override_cardtype(struct pci_dev *pcidev,
                                               unsigned long cardtype)
 {
@@ -1144,12 +1036,19 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
                subdev++;
        }
 
-       for (i = 0; i < MAX_8254_SUBDEVS; i++)
-               if (this_board->s8254[i].chans) {
-                       s = &dev->subdevices[subdev];
-                       pci_dio_add_8254(dev, s, &this_board->s8254[i]);
-                       subdev++;
-               }
+       if (this_board->timer_regbase) {
+               s = &dev->subdevices[subdev];
+
+               dev->pacer = comedi_8254_init(dev->iobase +
+                                             this_board->timer_regbase,
+                                             0, I8254_IO8, 0);
+               if (!dev->pacer)
+                       return -ENOMEM;
+
+               comedi_8254_subdevice_init(s, dev->pacer);
+
+               subdev++;
+       }
 
        if (this_board->cardtype == TYPE_PCI1760)
                pci1760_attach(dev);
index 26aad705aad30d83539dc704d9deacff8ee78b68..0101e92667a16cfdbda2f23b7d724f7fc5d5999b 100644 (file)
 
 #include "amplc_dio200.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"              /* only for register defines */
 
 /* 200 series registers */
 #define DIO200_IO_SIZE         0x20
 #define DIO200_PCIE_IO_SIZE    0x4000
-#define DIO200_XCLK_SCE                0x18    /* Group X clock selection register */
-#define DIO200_YCLK_SCE                0x19    /* Group Y clock selection register */
-#define DIO200_ZCLK_SCE                0x1a    /* Group Z clock selection register */
-#define DIO200_XGAT_SCE                0x1b    /* Group X gate selection register */
-#define DIO200_YGAT_SCE                0x1c    /* Group Y gate selection register */
-#define DIO200_ZGAT_SCE                0x1d    /* Group Z gate selection register */
+#define DIO200_CLK_SCE(x)      (0x18 + (x))    /* Group X/Y/Z clock sel reg */
+#define DIO200_GAT_SCE(x)      (0x1b + (x))    /* Group X/Y/Z gate sel reg */
 #define DIO200_INT_SCE         0x1e    /* Interrupt enable/status register */
 /* Extra registers for new PCIe boards */
 #define DIO200_ENHANCE         0x20    /* 1 to enable enhanced features */
@@ -101,16 +97,6 @@ static const unsigned int ts_clock_period[TS_CONFIG_MAX_CLK_SRC + 1] = {
        1000000,                /* 1 millisecond. */
 };
 
-struct dio200_subdev_8254 {
-       unsigned int ofs;               /* Counter base offset */
-       unsigned int clk_sce_ofs;       /* CLK_SCE base address */
-       unsigned int gat_sce_ofs;       /* GAT_SCE base address */
-       int which;                      /* Bit 5 of CLK_SCE or GAT_SCE */
-       unsigned int clock_src[3];      /* Current clock sources */
-       unsigned int gate_src[3];       /* Current gate sources */
-       spinlock_t spinlock;
-};
-
 struct dio200_subdev_8255 {
        unsigned int ofs;               /* DIO base offset */
 };
@@ -177,6 +163,27 @@ static void dio200_write32(struct comedi_device *dev,
                outl(val, dev->iobase + offset);
 }
 
+static unsigned int dio200_subdev_8254_offset(struct comedi_device *dev,
+                                             struct comedi_subdevice *s)
+{
+       const struct dio200_board *board = dev->board_ptr;
+       struct comedi_8254 *i8254 = s->private;
+       unsigned int offset;
+
+       /* get the offset that was passed to comedi_8254_*_init() */
+       if (dev->mmio)
+               offset = i8254->mmio - dev->mmio;
+       else
+               offset = i8254->iobase - dev->iobase;
+
+       /* remove the shift that was added for PCIe boards */
+       if (board->is_pcie)
+               offset >>= 3;
+
+       /* this offset now works for the dio200_{read,write} helpers */
+       return offset;
+}
+
 static int dio200_subdev_intr_insn_bits(struct comedi_device *dev,
                                        struct comedi_subdevice *s,
                                        struct comedi_insn *insn,
@@ -482,175 +489,26 @@ static irqreturn_t dio200_interrupt(int irq, void *d)
        return IRQ_RETVAL(handled);
 }
 
-static unsigned int dio200_subdev_8254_read_chan(struct comedi_device *dev,
-                                                struct comedi_subdevice *s,
-                                                unsigned int chan)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-       unsigned int val;
-
-       /* latch counter */
-       val = chan << 6;
-       dio200_write8(dev, subpriv->ofs + i8254_control_reg, val);
-       /* read lsb, msb */
-       val = dio200_read8(dev, subpriv->ofs + chan);
-       val += dio200_read8(dev, subpriv->ofs + chan) << 8;
-       return val;
-}
-
-static void dio200_subdev_8254_write_chan(struct comedi_device *dev,
-                                         struct comedi_subdevice *s,
-                                         unsigned int chan,
-                                         unsigned int count)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-
-       /* write lsb, msb */
-       dio200_write8(dev, subpriv->ofs + chan, count & 0xff);
-       dio200_write8(dev, subpriv->ofs + chan, (count >> 8) & 0xff);
-}
-
-static void dio200_subdev_8254_set_mode(struct comedi_device *dev,
-                                       struct comedi_subdevice *s,
-                                       unsigned int chan,
-                                       unsigned int mode)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-       unsigned int byte;
-
-       byte = chan << 6;
-       byte |= 0x30;           /* access order: lsb, msb */
-       byte |= (mode & 0xf);   /* counter mode and BCD|binary */
-       dio200_write8(dev, subpriv->ofs + i8254_control_reg, byte);
-}
-
-static unsigned int dio200_subdev_8254_status(struct comedi_device *dev,
-                                             struct comedi_subdevice *s,
-                                             unsigned int chan)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-
-       /* latch status */
-       dio200_write8(dev, subpriv->ofs + i8254_control_reg,
-                     0xe0 | (2 << chan));
-       /* read status */
-       return dio200_read8(dev, subpriv->ofs + chan);
-}
-
-static int dio200_subdev_8254_read(struct comedi_device *dev,
-                                  struct comedi_subdevice *s,
-                                  struct comedi_insn *insn,
-                                  unsigned int *data)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-       int chan = CR_CHAN(insn->chanspec);
-       unsigned int n;
-       unsigned long flags;
-
-       for (n = 0; n < insn->n; n++) {
-               spin_lock_irqsave(&subpriv->spinlock, flags);
-               data[n] = dio200_subdev_8254_read_chan(dev, s, chan);
-               spin_unlock_irqrestore(&subpriv->spinlock, flags);
-       }
-       return insn->n;
-}
-
-static int dio200_subdev_8254_write(struct comedi_device *dev,
-                                   struct comedi_subdevice *s,
-                                   struct comedi_insn *insn,
-                                   unsigned int *data)
-{
-       struct dio200_subdev_8254 *subpriv = s->private;
-       int chan = CR_CHAN(insn->chanspec);
-       unsigned int n;
-       unsigned long flags;
-
-       for (n = 0; n < insn->n; n++) {
-               spin_lock_irqsave(&subpriv->spinlock, flags);
-               dio200_subdev_8254_write_chan(dev, s, chan, data[n]);
-               spin_unlock_irqrestore(&subpriv->spinlock, flags);
-       }
-       return insn->n;
-}
-
-static int dio200_subdev_8254_set_gate_src(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          unsigned int counter_number,
-                                          unsigned int gate_src)
-{
-       const struct dio200_board *board = dev->board_ptr;
-       struct dio200_subdev_8254 *subpriv = s->private;
-       unsigned char byte;
-
-       if (!board->has_clk_gat_sce)
-               return -1;
-       if (counter_number > 2)
-               return -1;
-       if (gate_src > (board->is_pcie ? 31 : 7))
-               return -1;
-
-       subpriv->gate_src[counter_number] = gate_src;
-       byte = gat_sce(subpriv->which, counter_number, gate_src);
-       dio200_write8(dev, subpriv->gat_sce_ofs, byte);
-
-       return 0;
-}
-
-static int dio200_subdev_8254_get_gate_src(struct comedi_device *dev,
-                                          struct comedi_subdevice *s,
-                                          unsigned int counter_number)
-{
-       const struct dio200_board *board = dev->board_ptr;
-       struct dio200_subdev_8254 *subpriv = s->private;
-
-       if (!board->has_clk_gat_sce)
-               return -1;
-       if (counter_number > 2)
-               return -1;
-
-       return subpriv->gate_src[counter_number];
-}
-
-static int dio200_subdev_8254_set_clock_src(struct comedi_device *dev,
+static void dio200_subdev_8254_set_gate_src(struct comedi_device *dev,
                                            struct comedi_subdevice *s,
-                                           unsigned int counter_number,
-                                           unsigned int clock_src)
+                                           unsigned int chan,
+                                           unsigned int src)
 {
-       const struct dio200_board *board = dev->board_ptr;
-       struct dio200_subdev_8254 *subpriv = s->private;
-       unsigned char byte;
-
-       if (!board->has_clk_gat_sce)
-               return -1;
-       if (counter_number > 2)
-               return -1;
-       if (clock_src > (board->is_pcie ? 31 : 7))
-               return -1;
-
-       subpriv->clock_src[counter_number] = clock_src;
-       byte = clk_sce(subpriv->which, counter_number, clock_src);
-       dio200_write8(dev, subpriv->clk_sce_ofs, byte);
+       unsigned int offset = dio200_subdev_8254_offset(dev, s);
 
-       return 0;
+       dio200_write8(dev, DIO200_GAT_SCE(offset >> 3),
+                     gat_sce((offset >> 2) & 1, chan, src));
 }
 
-static int dio200_subdev_8254_get_clock_src(struct comedi_device *dev,
-                                           struct comedi_subdevice *s,
-                                           unsigned int counter_number,
-                                           unsigned int *period_ns)
+static void dio200_subdev_8254_set_clock_src(struct comedi_device *dev,
+                                            struct comedi_subdevice *s,
+                                            unsigned int chan,
+                                            unsigned int src)
 {
-       const struct dio200_board *board = dev->board_ptr;
-       struct dio200_subdev_8254 *subpriv = s->private;
-       unsigned clock_src;
-
-       if (!board->has_clk_gat_sce)
-               return -1;
-       if (counter_number > 2)
-               return -1;
+       unsigned int offset = dio200_subdev_8254_offset(dev, s);
 
-       clock_src = subpriv->clock_src[counter_number];
-       *period_ns = clock_period[clock_src];
-       return clock_src;
+       dio200_write8(dev, DIO200_CLK_SCE(offset >> 3),
+                     clk_sce((offset >> 2) & 1, chan, src));
 }
 
 static int dio200_subdev_8254_config(struct comedi_device *dev,
@@ -658,54 +516,44 @@ static int dio200_subdev_8254_config(struct comedi_device *dev,
                                     struct comedi_insn *insn,
                                     unsigned int *data)
 {
-       struct dio200_subdev_8254 *subpriv = s->private;
-       int ret = 0;
-       int chan = CR_CHAN(insn->chanspec);
-       unsigned long flags;
+       const struct dio200_board *board = dev->board_ptr;
+       struct comedi_8254 *i8254 = s->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int max_src = board->is_pcie ? 31 : 7;
+       unsigned int src;
+
+       if (!board->has_clk_gat_sce)
+               return -EINVAL;
 
-       spin_lock_irqsave(&subpriv->spinlock, flags);
        switch (data[0]) {
-       case INSN_CONFIG_SET_COUNTER_MODE:
-               if (data[1] > (I8254_MODE5 | I8254_BCD))
-                       ret = -EINVAL;
-               else
-                       dio200_subdev_8254_set_mode(dev, s, chan, data[1]);
-               break;
-       case INSN_CONFIG_8254_READ_STATUS:
-               data[1] = dio200_subdev_8254_status(dev, s, chan);
-               break;
        case INSN_CONFIG_SET_GATE_SRC:
-               ret = dio200_subdev_8254_set_gate_src(dev, s, chan, data[2]);
-               if (ret < 0)
-                       ret = -EINVAL;
+               src = data[2];
+               if (src > max_src)
+                       return -EINVAL;
+
+               dio200_subdev_8254_set_gate_src(dev, s, chan, src);
+               i8254->gate_src[chan] = src;
                break;
        case INSN_CONFIG_GET_GATE_SRC:
-               ret = dio200_subdev_8254_get_gate_src(dev, s, chan);
-               if (ret < 0) {
-                       ret = -EINVAL;
-                       break;
-               }
-               data[2] = ret;
+               data[2] = i8254->gate_src[chan];
                break;
        case INSN_CONFIG_SET_CLOCK_SRC:
-               ret = dio200_subdev_8254_set_clock_src(dev, s, chan, data[1]);
-               if (ret < 0)
-                       ret = -EINVAL;
+               src = data[1];
+               if (src > max_src)
+                       return -EINVAL;
+
+               dio200_subdev_8254_set_clock_src(dev, s, chan, src);
+               i8254->clock_src[chan] = src;
                break;
        case INSN_CONFIG_GET_CLOCK_SRC:
-               ret = dio200_subdev_8254_get_clock_src(dev, s, chan, &data[2]);
-               if (ret < 0) {
-                       ret = -EINVAL;
-                       break;
-               }
-               data[1] = ret;
+               data[1] = i8254->clock_src[chan];
+               data[2] = clock_period[i8254->clock_src[chan]];
                break;
        default:
-               ret = -EINVAL;
-               break;
+               return -EINVAL;
        }
-       spin_unlock_irqrestore(&subpriv->spinlock, flags);
-       return ret < 0 ? ret : insn->n;
+
+       return insn->n;
 }
 
 static int dio200_subdev_8254_init(struct comedi_device *dev,
@@ -713,36 +561,46 @@ static int dio200_subdev_8254_init(struct comedi_device *dev,
                                   unsigned int offset)
 {
        const struct dio200_board *board = dev->board_ptr;
-       struct dio200_subdev_8254 *subpriv;
-       unsigned int chan;
+       struct comedi_8254 *i8254;
+       unsigned int regshift;
+       int chan;
+
+       /*
+        * PCIe boards need the offset shifted in order to get the
+        * correct base address of the timer.
+        */
+       if (board->is_pcie) {
+               offset <<= 3;
+               regshift = 3;
+       } else {
+               regshift = 0;
+       }
 
-       subpriv = comedi_alloc_spriv(s, sizeof(*subpriv));
-       if (!subpriv)
+       if (dev->mmio)
+               i8254 = comedi_8254_mm_init(dev->mmio + offset,
+                                           0, I8254_IO8, regshift);
+       else
+               i8254 = comedi_8254_init(dev->iobase + offset,
+                                        0, I8254_IO8, regshift);
+       if (!i8254)
                return -ENOMEM;
 
-       s->type = COMEDI_SUBD_COUNTER;
-       s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-       s->n_chan = 3;
-       s->maxdata = 0xFFFF;
-       s->insn_read = dio200_subdev_8254_read;
-       s->insn_write = dio200_subdev_8254_write;
-       s->insn_config = dio200_subdev_8254_config;
+       comedi_8254_subdevice_init(s, i8254);
 
-       spin_lock_init(&subpriv->spinlock);
-       subpriv->ofs = offset;
-       if (board->has_clk_gat_sce) {
-               /* Derive CLK_SCE and GAT_SCE register offsets from
-                * 8254 offset. */
-               subpriv->clk_sce_ofs = DIO200_XCLK_SCE + (offset >> 3);
-               subpriv->gat_sce_ofs = DIO200_XGAT_SCE + (offset >> 3);
-               subpriv->which = (offset >> 2) & 1;
-       }
+       i8254->insn_config = dio200_subdev_8254_config;
+
+       /*
+        * There could be multiple timers so this driver does not
+        * use dev->pacer to save the i8254 pointer. Instead,
+        * comedi_8254_subdevice_init() saved the i8254 pointer in
+        * s->private. Set the runflag bit so that the core will
+        * automatically free it when the driver is detached.
+        */
+       s->runflags |= COMEDI_SRF_FREE_SPRIV;
 
        /* Initialize channels. */
-       for (chan = 0; chan < 3; chan++) {
-               dio200_subdev_8254_set_mode(dev, s, chan,
-                                           I8254_MODE0 | I8254_BINARY);
-               if (board->has_clk_gat_sce) {
+       if (board->has_clk_gat_sce) {
+               for (chan = 0; chan < 3; chan++) {
                        /* Gate source 0 is VCC (logic 1). */
                        dio200_subdev_8254_set_gate_src(dev, s, chan, 0);
                        /* Clock source 0 is the dedicated clock input. */
index b83d1f5a8fb999395dbaa34789e3daeeddfe4079..d9850c917163ae426385a3bed28dac254fbdcb27 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "amplc_dio200.h"
 
index be87172d1f3f22de766dfb4de9785e2f147bd291..cc26b9d04d66071daa1bcb23c0ed9043ced3ed84 100644 (file)
@@ -195,7 +195,6 @@ static void __exit amplc_pc236_common_exit(void)
 }
 module_exit(amplc_pc236_common_exit);
 
-
 MODULE_AUTHOR("Comedi http://www.comedi.org");
 MODULE_DESCRIPTION("Comedi helper for amplc_pc236 and amplc_pci236");
 MODULE_LICENSE("GPL");
index 924c8298c7a04b4ad3fdb7868bae1a0f49e19e23..6c9fa4ab4fcd11ff7324bddd52e61d1328a324d5 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * PCI224/234 i/o space 1 (PCIBAR2) registers.
  */
-#define PCI224_Z2_CT0  0x14    /* 82C54 counter/timer 0 */
-#define PCI224_Z2_CT1  0x15    /* 82C54 counter/timer 1 */
-#define PCI224_Z2_CT2  0x16    /* 82C54 counter/timer 2 */
-#define PCI224_Z2_CTC  0x17    /* 82C54 counter/timer control word */
+#define PCI224_Z2_BASE 0x14    /* 82C54 counter/timer */
 #define PCI224_ZCLK_SCE        0x1A    /* Group Z Clock Configuration Register */
 #define PCI224_ZGAT_SCE        0x1D    /* Group Z Gate Configuration Register */
 #define PCI224_INT_SCE 0x1E    /* ISR Interrupt source mask register */
@@ -379,8 +375,6 @@ struct pci224_private {
        int intr_cpuid;
        short intr_running;
        unsigned short daccon;
-       unsigned int cached_div1;
-       unsigned int cached_div2;
        unsigned short ao_enab; /* max 16 channels so 'short' will do */
        unsigned char intsce;
 };
@@ -451,7 +445,6 @@ static void pci224_ao_stop(struct comedi_device *dev,
        if (!test_and_clear_bit(AO_CMD_STARTED, &devpriv->state))
                return;
 
-
        spin_lock_irqsave(&devpriv->ao_spinlock, flags);
        /* Kill the interrupts. */
        devpriv->intsce = 0;
@@ -668,7 +661,6 @@ static int
 pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                  struct comedi_cmd *cmd)
 {
-       struct pci224_private *devpriv = dev->private;
        int err = 0;
        unsigned int arg;
 
@@ -793,10 +785,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                /* Use two timers. */
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->cached_div1,
-                                         &devpriv->cached_div2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
@@ -817,7 +806,6 @@ static void pci224_ao_start_pacer(struct comedi_device *dev,
                                  struct comedi_subdevice *s)
 {
        struct pci224_private *devpriv = dev->private;
-       unsigned long timer_base = devpriv->iobase1 + PCI224_Z2_CT0;
 
        /*
         * The output of timer Z2-0 will be used as the scan trigger
@@ -830,14 +818,10 @@ static void pci224_ao_start_pacer(struct comedi_device *dev,
        outb(GAT_CONFIG(2, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE);
        /* Z2-2 needs 10 MHz clock. */
        outb(CLK_CONFIG(2, CLK_10MHZ), devpriv->iobase1 + PCI224_ZCLK_SCE);
-       /* Load Z2-2 mode (2) and counter (div1). */
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_write(timer_base, 0, 2, devpriv->cached_div1);
        /* Z2-0 is clocked from Z2-2's output. */
        outb(CLK_CONFIG(0, CLK_OUTNM1), devpriv->iobase1 + PCI224_ZCLK_SCE);
-       /* Load Z2-0 mode (2) and counter (div2). */
-       i8254_set_mode(timer_base, 0, 0, I8254_MODE2 | I8254_BINARY);
-       i8254_write(timer_base, 0, 0, devpriv->cached_div2);
+
+       comedi_8254_pacer_enable(dev->pacer, 2, 0, false);
 }
 
 static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -852,10 +836,9 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        unsigned long flags;
 
        /* Cannot handle null/empty chanlist. */
-       if (cmd->chanlist == NULL || cmd->chanlist_len == 0)
+       if (!cmd->chanlist || cmd->chanlist_len == 0)
                return -EINVAL;
 
-
        /* Determine which channels are enabled and their load order.  */
        devpriv->ao_enab = 0;
 
@@ -893,8 +876,10 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
             dev->iobase + PCI224_DACCON);
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(dev->pacer);
                pci224_ao_start_pacer(dev, s);
+       }
 
        spin_lock_irqsave(&devpriv->ao_spinlock, flags);
        if (cmd->start_src == TRIG_INT) {
@@ -1042,14 +1027,12 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
        if (!devpriv->ao_scan_vals)
                return -ENOMEM;
 
-
        /* Allocate buffer to hold AO channel scan order. */
        devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
                                         thisboard->ao_chans, GFP_KERNEL);
        if (!devpriv->ao_scan_order)
                return -ENOMEM;
 
-
        /* Disable interrupt sources. */
        devpriv->intsce = 0;
        outb(0, devpriv->iobase1 + PCI224_INT_SCE);
@@ -1063,6 +1046,11 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
        outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
             dev->iobase + PCI224_DACCON);
 
+       dev->pacer = comedi_8254_init(devpriv->iobase1 + PCI224_Z2_BASE,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 1);
        if (ret)
                return ret;
index 49806a5e514c71faa0a8be2d569186b432c89445..a145f39682f49bec31117e2d1bc410bb349d2373 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"
 
 /*
 #define PCI230_PPI_X_C         0x02    /* User PPI (82C55) port C */
 #define PCI230_PPI_X_CMD       0x03    /* User PPI (82C55) control word */
 #define PCI230_Z2_CT_BASE      0x14    /* 82C54 counter/timer base */
-#define PCI230_Z2_CT0          0x14    /* 82C54 counter/timer 0 */
-#define PCI230_Z2_CT1          0x15    /* 82C54 counter/timer 1 */
-#define PCI230_Z2_CT2          0x16    /* 82C54 counter/timer 2 */
-#define PCI230_Z2_CTC          0x17    /* 82C54 counter/timer control word */
 #define PCI230_ZCLK_SCE                0x1A    /* Group Z Clock Configuration */
 #define PCI230_ZGAT_SCE                0x1D    /* Group Z Gate Configuration */
 #define PCI230_INT_SCE         0x1E    /* Interrupt source mask (w) */
 #define CLK_EXT                7       /* external clock */
 /* Macro to construct clock input configuration register value. */
 #define CLK_CONFIG(chan, src)  ((((chan) & 3) << 3) | ((src) & 7))
-/* Timebases in ns. */
-#define TIMEBASE_10MHZ         100
-#define TIMEBASE_1MHZ          1000
-#define TIMEBASE_100KHZ                10000
-#define TIMEBASE_10KHZ         100000
-#define TIMEBASE_1KHZ          1000000
 
 /*
  * Counter/timer gate input configuration sources.
@@ -507,11 +496,11 @@ struct pci230_private {
 
 /* PCI230 clock source periods in ns */
 static const unsigned int pci230_timebase[8] = {
-       [CLK_10MHZ] = TIMEBASE_10MHZ,
-       [CLK_1MHZ] = TIMEBASE_1MHZ,
-       [CLK_100KHZ] = TIMEBASE_100KHZ,
-       [CLK_10KHZ] = TIMEBASE_10KHZ,
-       [CLK_1KHZ] = TIMEBASE_1KHZ,
+       [CLK_10MHZ]     = I8254_OSC_BASE_10MHZ,
+       [CLK_1MHZ]      = I8254_OSC_BASE_1MHZ,
+       [CLK_100KHZ]    = I8254_OSC_BASE_100KHZ,
+       [CLK_10KHZ]     = I8254_OSC_BASE_10KHZ,
+       [CLK_1KHZ]      = I8254_OSC_BASE_1KHZ,
 };
 
 /* PCI230 analogue input range table */
@@ -695,7 +684,7 @@ static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
        unsigned int count;
 
        /* Set mode. */
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, ct, mode);
+       comedi_8254_set_mode(dev->pacer, ct, mode);
        /* Determine clock source and count. */
        clk_src = pci230_choose_clk_count(ns, &count, flags);
        /* Program clock source. */
@@ -704,13 +693,13 @@ static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
        if (count >= 65536)
                count = 0;
 
-       i8254_write(dev->iobase + PCI230_Z2_CT_BASE, 0, ct, count);
+       comedi_8254_write(dev->pacer, ct, count);
 }
 
 static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
 {
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, ct, I8254_MODE1);
        /* Counter ct, 8254 mode 1, initial count not written. */
+       comedi_8254_set_mode(dev->pacer, ct, I8254_MODE1);
 }
 
 static int pci230_ai_eoc(struct comedi_device *dev,
@@ -760,7 +749,7 @@ static int pci230_ai_insn_read(struct comedi_device *dev,
         */
        adccon = PCI230_ADC_TRIG_Z2CT2 | PCI230_ADC_FIFO_EN;
        /* Set Z2-CT2 output low to avoid any false triggers. */
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE0);
+       comedi_8254_set_mode(dev->pacer, 2, I8254_MODE0);
        devpriv->ai_bipolar = comedi_range_is_bipolar(s, range);
        if (aref == AREF_DIFF) {
                /* Differential. */
@@ -811,10 +800,8 @@ static int pci230_ai_insn_read(struct comedi_device *dev,
                 * Trigger conversion by toggling Z2-CT2 output
                 * (finish with output high).
                 */
-               i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0,
-                              2, I8254_MODE0);
-               i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0,
-                              2, I8254_MODE1);
+               comedi_8254_set_mode(dev->pacer, 2, I8254_MODE0);
+               comedi_8254_set_mode(dev->pacer, 2, I8254_MODE1);
 
                /* wait for conversion to end */
                ret = comedi_timeout(dev, s, insn, pci230_ai_eoc, 0);
@@ -1767,8 +1754,8 @@ static int pci230_ai_inttrig_convert(struct comedi_device *dev,
         * Trigger conversion by toggling Z2-CT2 output.
         * Finish with output high.
         */
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE0);
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE1);
+       comedi_8254_set_mode(dev->pacer, 2, I8254_MODE0);
+       comedi_8254_set_mode(dev->pacer, 2, I8254_MODE1);
        /*
         * Delay.  Should driver be responsible for this?  An
         * alternative would be to wait until conversion is complete,
@@ -2189,7 +2176,7 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
         * Set counter/timer 2 output high for use as the initial start
         * conversion source.
         */
-       i8254_set_mode(dev->iobase + PCI230_Z2_CT_BASE, 0, 2, I8254_MODE1);
+       comedi_8254_set_mode(dev->pacer, 2, I8254_MODE1);
 
        /*
         * Temporarily use CT2 output as conversion trigger source and
@@ -2393,7 +2380,7 @@ static int pci230_auto_attach(struct comedi_device *dev,
        spin_lock_init(&devpriv->ao_stop_spinlock);
 
        dev->board_ptr = pci230_find_pci_board(pci_dev);
-       if (dev->board_ptr == NULL) {
+       if (!dev->board_ptr) {
                dev_err(dev->class_dev,
                        "amplc_pci230: BUG! cannot determine board type!\n");
                return -EINVAL;
@@ -2481,6 +2468,11 @@ static int pci230_auto_attach(struct comedi_device *dev,
                        dev->irq = pci_dev->irq;
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCI230_Z2_CT_BASE,
+                                     0, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        rc = comedi_alloc_subdevices(dev, 3);
        if (rc)
                return rc;
index ad1e93dd13a0132b88c2cf0be405236139d5e4f7..31cc38b4bcadf6154445e4a951074f05123991db 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "amplc_pc236.h"
 #include "plx9052.h"
index 0d2224b832ac6665256bb8ef799d81511109f46c..b6768aa905473e32cbd559d896f5b024f31782d9 100644 (file)
@@ -33,9 +33,8 @@ The state of the outputs can be read.
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 static int pci263_do_insn_bits(struct comedi_device *dev,
                               struct comedi_subdevice *s,
index 1079b6c72b15d8c7034d88cc46bdc333ff8c433c..9abc2c7954798df7755f78c65bdcd8f092f4f4f8 100644 (file)
@@ -30,8 +30,6 @@ Devices: [ComputerBoards] PC-CARD DAS16/16 (cb_das16_cs), PC-CARD DAS16/16-AO
 Author: ds
 Updated: Mon, 04 Nov 2002 20:04:21 -0800
 Status: experimental
-
-
 */
 
 #include <linux/module.h>
@@ -41,16 +39,13 @@ Status: experimental
 #include "../comedi_pcmcia.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 #define DAS16CS_ADC_DATA               0
 #define DAS16CS_DIO_MUX                        2
 #define DAS16CS_MISC1                  4
 #define DAS16CS_MISC2                  6
-#define DAS16CS_CTR0                   8
-#define DAS16CS_CTR1                   10
-#define DAS16CS_CTR2                   12
-#define DAS16CS_CTR_CONTROL            14
+#define DAS16CS_TIMER_BASE             8
 #define DAS16CS_DIO                    16
 
 struct das16cs_board {
@@ -279,6 +274,11 @@ static int das16cs_auto_attach(struct comedi_device *dev,
        if (!devpriv)
                return -ENOMEM;
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS16CS_TIMER_BASE,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 3);
        if (ret)
                return ret;
index dd0c65a5b5a0a22e29098a877b0776c21f814b86..bad04d99190bb9d0cc03d2e32257813d1a7b4271 100644 (file)
@@ -62,13 +62,12 @@ analog triggering on 1602 series
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"
 #include "amcc_s5933.h"
 #include "comedi_fc.h"
@@ -338,14 +337,12 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
 };
 
 struct cb_pcidas_private {
+       struct comedi_8254 *ao_pacer;
        /* base addresses */
        unsigned long s5933_config;
        unsigned long control_status;
        unsigned long adc_fifo;
        unsigned long ao_registers;
-       /* divisors of master clock for analog input pacing */
-       unsigned int divisor1;
-       unsigned int divisor2;
        /* bits to write to registers */
        unsigned int adc_fifo_bits;
        unsigned int s5933_intcsr_bits;
@@ -353,9 +350,6 @@ struct cb_pcidas_private {
        /* fifo buffers */
        unsigned short ai_buffer[AI_BUFFER_SIZE];
        unsigned short ao_buffer[AO_BUFFER_SIZE];
-       /* divisors of master clock for analog output pacing */
-       unsigned int ao_divisor1;
-       unsigned int ao_divisor2;
        unsigned int calibration_source;
 };
 
@@ -530,7 +524,7 @@ static int wait_for_nvram_ready(unsigned long s5933_base_addr)
 }
 
 static int nvram_read(struct comedi_device *dev, unsigned int address,
-                       uint8_t *data)
+                     uint8_t *data)
 {
        struct cb_pcidas_private *devpriv = dev->private;
        unsigned long iobase = devpriv->s5933_config;
@@ -778,7 +772,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
                                struct comedi_cmd *cmd)
 {
        const struct cb_pcidas_board *thisboard = dev->board_ptr;
-       struct cb_pcidas_private *devpriv = dev->private;
        int err = 0;
        unsigned int arg;
 
@@ -858,18 +851,12 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -886,18 +873,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
        return 0;
 }
 
-static void cb_pcidas_ai_load_counters(struct comedi_device *dev)
-{
-       struct cb_pcidas_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + ADC8254;
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-       i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->divisor2);
-}
-
 static int cb_pcidas_ai_cmd(struct comedi_device *dev,
                            struct comedi_subdevice *s)
 {
@@ -933,8 +908,11 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
        outw(bits, devpriv->control_status + ADCMUX_CONT);
 
        /*  load counters */
-       if (cmd->scan_begin_src == TRIG_TIMER || cmd->convert_src == TRIG_TIMER)
-               cb_pcidas_ai_load_counters(dev);
+       if (cmd->scan_begin_src == TRIG_TIMER ||
+           cmd->convert_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
+       }
 
        /*  enable interrupts */
        spin_lock_irqsave(&dev->spinlock, flags);
@@ -1004,7 +982,6 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
        const struct cb_pcidas_board *thisboard = dev->board_ptr;
        struct cb_pcidas_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -1049,11 +1026,10 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
        /* step 4: fix up any arguments */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->ao_divisor1,
-                                         &devpriv->ao_divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->scan_begin_arg;
+
+               comedi_8254_cascade_ns_to_timer(devpriv->ao_pacer,
+                                               &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
@@ -1139,18 +1115,6 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
        return 0;
 }
 
-static void cb_pcidas_ao_load_counters(struct comedi_device *dev)
-{
-       struct cb_pcidas_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAC8254;
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-       i8254_write(timer_base, 0, 1, devpriv->ao_divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->ao_divisor2);
-}
-
 static int cb_pcidas_ao_cmd(struct comedi_device *dev,
                            struct comedi_subdevice *s)
 {
@@ -1180,8 +1144,10 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
        outw(0, devpriv->ao_registers + DACFIFOCLR);
 
        /*  load counters */
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               cb_pcidas_ao_load_counters(dev);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(devpriv->ao_pacer);
+               comedi_8254_pacer_enable(devpriv->ao_pacer, 1, 2, true);
+       }
 
        /*  set pacer source */
        spin_lock_irqsave(&dev->spinlock, flags);
@@ -1408,6 +1374,17 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
        }
        dev->irq = pcidev->irq;
 
+       dev->pacer = comedi_8254_init(dev->iobase + ADC8254,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
+       devpriv->ao_pacer = comedi_8254_init(dev->iobase + DAC8254,
+                                            I8254_OSC_BASE_10MHZ,
+                                            I8254_IO8, 0);
+       if (!devpriv->ao_pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 7);
        if (ret)
                return ret;
@@ -1530,8 +1507,9 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
                        dac08_write(dev, s->maxdata / 2);
                        s->readback[i] = s->maxdata / 2;
                }
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /*  make sure mailbox 4 is empty */
        inl(devpriv->s5933_config + AMCC_OP_REG_IMB4);
@@ -1550,9 +1528,11 @@ static void cb_pcidas_detach(struct comedi_device *dev)
 {
        struct cb_pcidas_private *devpriv = dev->private;
 
-       if (devpriv && devpriv->s5933_config) {
-               outl(INTCSR_INBOX_INTR_STATUS,
-                    devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+       if (devpriv) {
+               if (devpriv->s5933_config)
+                       outl(INTCSR_INBOX_INTR_STATUS,
+                            devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+               kfree(devpriv->ao_pacer);
        }
        comedi_pci_detach(dev);
 }
index 5b43e4e6d037793ca295d05c2420e8bf3c64857b..15106d0a38b270496cedf9361b64da0005c3c031 100644 (file)
@@ -81,13 +81,11 @@ TODO:
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
-#include "8253.h"
 #include "8255.h"
 #include "plx9080.h"
 #include "comedi_fc.h"
@@ -1474,9 +1472,8 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
                devpriv->ai_buffer[i] =
                        pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
                                             &devpriv->ai_buffer_bus_addr[i]);
-               if (devpriv->ai_buffer[i] == NULL)
+               if (!devpriv->ai_buffer[i])
                        return -ENOMEM;
-
        }
        for (i = 0; i < AO_DMA_RING_COUNT; i++) {
                if (ao_cmd_is_supported(thisboard)) {
@@ -1484,9 +1481,8 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
                                pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
                                                     &devpriv->
                                                      ao_buffer_bus_addr[i]);
-                       if (devpriv->ao_buffer[i] == NULL)
+                       if (!devpriv->ao_buffer[i])
                                return -ENOMEM;
-
                }
        }
        /*  allocate dma descriptors */
@@ -1494,7 +1490,7 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
                pci_alloc_consistent(pcidev, sizeof(struct plx_dma_desc) *
                                     ai_dma_ring_count(thisboard),
                                     &devpriv->ai_dma_desc_bus_addr);
-       if (devpriv->ai_dma_desc == NULL)
+       if (!devpriv->ai_dma_desc)
                return -ENOMEM;
 
        if (ao_cmd_is_supported(thisboard)) {
@@ -1503,7 +1499,7 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
                                             sizeof(struct plx_dma_desc) *
                                             AO_DMA_RING_COUNT,
                                             &devpriv->ao_dma_desc_bus_addr);
-               if (devpriv->ao_dma_desc == NULL)
+               if (!devpriv->ao_dma_desc)
                        return -ENOMEM;
        }
        /*  initialize dma descriptors */
@@ -1704,8 +1700,7 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
 
        /*  get acknowledge */
        if (i2c_read_ack(dev) != 0) {
-               dev_err(dev->class_dev, "%s failed: no acknowledge\n",
-                       __func__);
+               dev_err(dev->class_dev, "failed: no acknowledge\n");
                i2c_stop(dev);
                return;
        }
@@ -1713,8 +1708,7 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
        for (i = 0; i < length; i++) {
                i2c_write_byte(dev, data[i]);
                if (i2c_read_ack(dev) != 0) {
-                       dev_err(dev->class_dev, "%s failed: no acknowledge\n",
-                               __func__);
+                       dev_err(dev->class_dev, "failed: no acknowledge\n");
                        i2c_stop(dev);
                        return;
                }
@@ -1841,7 +1835,6 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
        }
 
        for (n = 0; n < insn->n; n++) {
-
                /*  clear adc buffer (inside loop for 4020 sake) */
                writew(0, devpriv->main_iobase + ADC_BUFFER_CLEAR_REG);
 
@@ -1903,7 +1896,6 @@ static int ai_config_block_size(struct comedi_device *dev, unsigned int *data)
                retval = set_ai_fifo_size(dev, fifo_size);
                if (retval < 0)
                        return retval;
-
        }
 
        block_size = ai_fifo_size(dev) / fifo->num_segments * bytes_in_sample;
@@ -2001,7 +1993,8 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags)
 static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
 {
        const struct pcidas64_board *thisboard = dev->board_ptr;
-       unsigned int convert_divisor = 0, scan_divisor;
+       unsigned long long convert_divisor = 0;
+       unsigned int scan_divisor;
        static const int min_convert_divisor = 3;
        static const int max_convert_divisor =
                max_counter_value + min_convert_divisor;
@@ -2027,7 +2020,6 @@ static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
        if (cmd->scan_begin_src == TRIG_TIMER) {
                scan_divisor = get_divisor(cmd->scan_begin_arg, cmd->flags);
                if (cmd->convert_src == TRIG_TIMER) {
-                       /*  XXX check for integer overflows */
                        min_scan_divisor = convert_divisor * cmd->chanlist_len;
                        max_scan_divisor =
                                (convert_divisor * cmd->chanlist_len - 1) +
@@ -2637,8 +2629,9 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                bits |= ADC_START_TRIG_EXT_BITS;
                if (cmd->start_arg & CR_INVERT)
                        bits |= ADC_START_TRIG_FALLING_BIT;
-       } else if (cmd->start_src == TRIG_NOW)
+       } else if (cmd->start_src == TRIG_NOW) {
                bits |= ADC_START_TRIG_SOFT_BITS;
+       }
        if (use_hw_sample_counter(cmd))
                bits |= ADC_SAMPLE_COUNTER_EN_BIT;
        writew(bits, devpriv->main_iobase + ADC_CONTROL0_REG);
@@ -2827,8 +2820,9 @@ static void handle_ai_interrupt(struct comedi_device *dev,
                if (devpriv->ai_cmd_running) {
                        spin_unlock_irqrestore(&dev->spinlock, flags);
                        pio_drain_ai_fifo(dev);
-               } else
+               } else {
                        spin_unlock_irqrestore(&dev->spinlock, flags);
+               }
        }
        /*  if we are have all the data, then quit */
        if ((cmd->stop_src == TRIG_COUNT &&
@@ -2978,7 +2972,7 @@ static void handle_ao_interrupt(struct comedi_device *dev,
        unsigned long flags;
 
        /* board might not support ao, in which case write_subdev is NULL */
-       if (s == NULL)
+       if (!s)
                return;
        async = s->async;
        cmd = &async->cmd;
@@ -3817,8 +3811,9 @@ static int setup_subdevices(struct comedi_device *dev)
                s->maxdata = 1;
                s->range_table = &range_digital;
                s->insn_bits = di_rbits;
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /*  digital output */
        if (thisboard->layout == LAYOUT_64XX) {
@@ -3829,8 +3824,9 @@ static int setup_subdevices(struct comedi_device *dev)
                s->maxdata = 1;
                s->range_table = &range_digital;
                s->insn_bits = do_wbits;
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /* 8255 */
        s = &dev->subdevices[4];
@@ -3858,8 +3854,9 @@ static int setup_subdevices(struct comedi_device *dev)
                s->range_table = &range_digital;
                s->insn_config = dio_60xx_config_insn;
                s->insn_bits = dio_60xx_wbits;
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /*  caldac */
        s = &dev->subdevices[6];
@@ -3898,8 +3895,9 @@ static int setup_subdevices(struct comedi_device *dev)
                        ad8402_write(dev, i, s->maxdata / 2);
                        s->readback[i] = s->maxdata / 2;
                }
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /* serial EEPROM, if present */
        s = &dev->subdevices[8];
@@ -3909,8 +3907,9 @@ static int setup_subdevices(struct comedi_device *dev)
                s->n_chan = 128;
                s->maxdata = 0xffff;
                s->insn_read = eeprom_read_insn;
-       } else
+       } else {
                s->type = COMEDI_SUBD_UNUSED;
+       }
 
        /*  user counter subd XXX */
        s = &dev->subdevices[9];
index 2b2cfcdda5bdd938035c35ff362f41812e7cc474..1e232b1e3194cb9ea02a5bd122498eb522e6039a 100644 (file)
@@ -36,9 +36,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "8255.h"
index 70dd2c9eecdba21174c2d9bc7595f2eb609a3654..c458e5010a745cb631013374e3c2f0b881ea07d3 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
+#include "comedi_8254.h"
 #include "plx9052.h"
 #include "8255.h"
 
-/* Registers for the PCIM-DAS1602/16 and PCIe-DAS1602/16 */
-
-/* DAC Offsets */
-#define ADC_TRIG 0
-#define DAC0_OFFSET 2
-#define DAC1_OFFSET 4
-
-/* AI and Counter Constants */
-#define MUX_LIMITS 0
-#define MAIN_CONN_DIO 1
-#define ADC_STAT 2
-#define ADC_CONV_STAT 3
-#define ADC_INT 4
-#define ADC_PACER 5
-#define BURST_MODE 6
-#define PROG_GAIN 7
-#define CLK8254_1_DATA 8
-#define CLK8254_2_DATA 9
-#define CLK8254_3_DATA 10
-#define CLK8254_CONTROL 11
-#define USER_COUNTER 12
-#define RESID_COUNT_H 13
-#define RESID_COUNT_L 14
+/*
+ * PCI Bar 1 Register map
+ * see plx9052.h for register and bit defines
+ */
+
+/*
+ * PCI Bar 2 Register map (devpriv->daqio)
+ */
+#define PCIMDAS_AI_REG                 0x00
+#define PCIMDAS_AI_SOFTTRIG_REG                0x00
+#define PCIMDAS_AO_REG(x)              (0x02 + ((x) * 2))
+
+/*
+ * PCI Bar 3 Register map (devpriv->BADR3)
+ */
+#define PCIMDAS_MUX_REG                        0x00
+#define PCIMDAS_MUX(_lo, _hi)          ((_lo) | ((_hi) << 4))
+#define PCIMDAS_DI_DO_REG              0x01
+#define PCIMDAS_STATUS_REG             0x02
+#define PCIMDAS_STATUS_EOC             BIT(7)
+#define PCIMDAS_STATUS_UB              BIT(6)
+#define PCIMDAS_STATUS_MUX             BIT(5)
+#define PCIMDAS_STATUS_CLK             BIT(4)
+#define PCIMDAS_STATUS_TO_CURR_MUX(x)  ((x) & 0xf)
+#define PCIMDAS_CONV_STATUS_REG                0x03
+#define PCIMDAS_CONV_STATUS_EOC                BIT(7)
+#define PCIMDAS_CONV_STATUS_EOB                BIT(6)
+#define PCIMDAS_CONV_STATUS_EOA                BIT(5)
+#define PCIMDAS_CONV_STATUS_FNE                BIT(4)
+#define PCIMDAS_CONV_STATUS_FHF                BIT(3)
+#define PCIMDAS_CONV_STATUS_OVERRUN    BIT(2)
+#define PCIMDAS_IRQ_REG                        0x04
+#define PCIMDAS_IRQ_INTE               BIT(7)
+#define PCIMDAS_IRQ_INT                        BIT(6)
+#define PCIMDAS_IRQ_OVERRUN            BIT(4)
+#define PCIMDAS_IRQ_EOA                        BIT(3)
+#define PCIMDAS_IRQ_EOA_INT_SEL                BIT(2)
+#define PCIMDAS_IRQ_INTSEL(x)          ((x) << 0)
+#define PCIMDAS_IRQ_INTSEL_EOC         PCIMDAS_IRQ_INTSEL(0)
+#define PCIMDAS_IRQ_INTSEL_FNE         PCIMDAS_IRQ_INTSEL(1)
+#define PCIMDAS_IRQ_INTSEL_EOB         PCIMDAS_IRQ_INTSEL(2)
+#define PCIMDAS_IRQ_INTSEL_FHF_EOA     PCIMDAS_IRQ_INTSEL(3)
+#define PCIMDAS_PACER_REG              0x05
+#define PCIMDAS_PACER_GATE_STATUS      BIT(6)
+#define PCIMDAS_PACER_GATE_POL         BIT(5)
+#define PCIMDAS_PACER_GATE_LATCH       BIT(4)
+#define PCIMDAS_PACER_GATE_EN          BIT(3)
+#define PCIMDAS_PACER_EXT_PACER_POL    BIT(2)
+#define PCIMDAS_PACER_SRC(x)           ((x) << 0)
+#define PCIMDAS_PACER_SRC_POLLED       PCIMDAS_PACER_SRC(0)
+#define PCIMDAS_PACER_SRC_EXT          PCIMDAS_PACER_SRC(2)
+#define PCIMDAS_PACER_SRC_INT          PCIMDAS_PACER_SRC(3)
+#define PCIMDAS_PACER_SRC_MASK         (3 << 0)
+#define PCIMDAS_BURST_REG              0x06
+#define PCIMDAS_BURST_BME              BIT(1)
+#define PCIMDAS_BURST_CONV_EN          BIT(0)
+#define PCIMDAS_GAIN_REG               0x07
+#define PCIMDAS_8254_BASE              0x08
+#define PCIMDAS_USER_CNTR_REG          0x0c
+#define PCIMDAS_USER_CNTR_CTR1_CLK_SEL BIT(0)
+#define PCIMDAS_RESIDUE_MSB_REG                0x0d
+#define PCIMDAS_RESIDUE_LSB_REG                0x0e
+
+/*
+ * PCI Bar 4 Register map (dev->iobase)
+ */
+#define PCIMDAS_8255_BASE              0x00
+
+static const struct comedi_lrange cb_pcimdas_ai_bip_range = {
+       4, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               BIP_RANGE(2.5),
+               BIP_RANGE(1.25)
+       }
+};
+
+static const struct comedi_lrange cb_pcimdas_ai_uni_range = {
+       4, {
+               UNI_RANGE(10),
+               UNI_RANGE(5),
+               UNI_RANGE(2.5),
+               UNI_RANGE(1.25)
+       }
+};
+
+/*
+ * The Analog Output range is not programmable. The DAC ranges are
+ * jumper-settable on the board. The settings are not software-readable.
+ */
+static const struct comedi_lrange cb_pcimdas_ao_range = {
+       4, {
+               BIP_RANGE(10),
+               BIP_RANGE(5),
+               UNI_RANGE(10),
+               UNI_RANGE(5)
+       }
+};
 
 /*
  * this structure is for data unique to this hardware driver.  If
@@ -94,59 +169,47 @@ static int cb_pcimdas_ai_eoc(struct comedi_device *dev,
        struct cb_pcimdas_private *devpriv = dev->private;
        unsigned int status;
 
-       status = inb(devpriv->BADR3 + 2);
-       if ((status & 0x80) == 0)
+       status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+       if ((status & PCIMDAS_STATUS_EOC) == 0)
                return 0;
        return -EBUSY;
 }
 
-static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
+static int cb_pcimdas_ai_insn_read(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
 {
        struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int range = CR_RANGE(insn->chanspec);
        int n;
        unsigned int d;
-       int chan = CR_CHAN(insn->chanspec);
-       unsigned short chanlims;
-       int maxchans;
        int ret;
 
        /*  only support sw initiated reads from a single channel */
 
-       /* check channel number */
-       if ((inb(devpriv->BADR3 + 2) & 0x20) == 0)      /* differential mode */
-               maxchans = s->n_chan / 2;
-       else
-               maxchans = s->n_chan;
-
-       if (chan > (maxchans - 1))
-               return -ETIMEDOUT;      /* *** Wrong error code. Fixme. */
-
        /* configure for sw initiated read */
-       d = inb(devpriv->BADR3 + 5);
-       if ((d & 0x03) > 0) {   /* only reset if needed. */
-               d = d & 0xfd;
-               outb(d, devpriv->BADR3 + 5);
+       d = inb(devpriv->BADR3 + PCIMDAS_PACER_REG);
+       if ((d & PCIMDAS_PACER_SRC_MASK) != PCIMDAS_PACER_SRC_POLLED) {
+               d &= ~PCIMDAS_PACER_SRC_MASK;
+               d |= PCIMDAS_PACER_SRC_POLLED;
+               outb(d, devpriv->BADR3 + PCIMDAS_PACER_REG);
        }
 
        /* set bursting off, conversions on */
-       outb(0x01, devpriv->BADR3 + 6);
+       outb(PCIMDAS_BURST_CONV_EN, devpriv->BADR3 + PCIMDAS_BURST_REG);
 
-       /* set range to 10V. UP/BP is controlled by a switch on the board */
-       outb(0x00, devpriv->BADR3 + 7);
+       /* set range */
+       outb(range, devpriv->BADR3 + PCIMDAS_GAIN_REG);
 
-       /*
-        * write channel limits to multiplexer, set Low (bits 0-3) and
-        * High (bits 4-7) channels to chan.
-        */
-       chanlims = chan | (chan << 4);
-       outb(chanlims, devpriv->BADR3 + 0);
+       /* set mux for single channel scan */
+       outb(PCIMDAS_MUX(chan, chan), devpriv->BADR3 + PCIMDAS_MUX_REG);
 
        /* convert n samples */
        for (n = 0; n < insn->n; n++) {
                /* trigger conversion */
-               outw(0, devpriv->daqio + 0);
+               outw(0, devpriv->daqio + PCIMDAS_AI_SOFTTRIG_REG);
 
                /* wait for conversion to end */
                ret = comedi_timeout(dev, s, insn, cb_pcimdas_ai_eoc, 0);
@@ -154,7 +217,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
                        return ret;
 
                /* read data */
-               data[n] = inw(devpriv->daqio + 0);
+               data[n] = inw(devpriv->daqio + PCIMDAS_AI_REG);
        }
 
        /* return the number of samples read/written */
@@ -169,20 +232,128 @@ static int cb_pcimdas_ao_insn_write(struct comedi_device *dev,
        struct cb_pcimdas_private *devpriv = dev->private;
        unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int val = s->readback[chan];
-       unsigned int reg = (chan) ? DAC1_OFFSET : DAC0_OFFSET;
        int i;
 
        for (i = 0; i < insn->n; i++) {
                val = data[i];
-               outw(val, devpriv->daqio + reg);
+               outw(val, devpriv->daqio + PCIMDAS_AO_REG(chan));
        }
        s->readback[chan] = val;
 
        return insn->n;
 }
 
+static int cb_pcimdas_di_insn_read(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int val;
+
+       val = inb(devpriv->BADR3 + PCIMDAS_DI_DO_REG);
+
+       data[1] = val & 0x0f;
+
+       return insn->n;
+}
+
+static int cb_pcimdas_do_insn_write(struct comedi_device *dev,
+                                   struct comedi_subdevice *s,
+                                   struct comedi_insn *insn,
+                                   unsigned int *data)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+
+       if (comedi_dio_update_state(s, data))
+               outb(s->state, devpriv->BADR3 + PCIMDAS_DI_DO_REG);
+
+       data[1] = s->state;
+
+       return insn->n;
+}
+
+static int cb_pcimdas_counter_insn_config(struct comedi_device *dev,
+                                         struct comedi_subdevice *s,
+                                         struct comedi_insn *insn,
+                                         unsigned int *data)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int ctrl;
+
+       switch (data[0]) {
+       case INSN_CONFIG_SET_CLOCK_SRC:
+               switch (data[1]) {
+               case 0: /* internal 100 kHz clock */
+                       ctrl = PCIMDAS_USER_CNTR_CTR1_CLK_SEL;
+                       break;
+               case 1: /* external clk on pin 21 */
+                       ctrl = 0;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+               outb(ctrl, devpriv->BADR3 + PCIMDAS_USER_CNTR_REG);
+               break;
+       case INSN_CONFIG_GET_CLOCK_SRC:
+               ctrl = inb(devpriv->BADR3 + PCIMDAS_USER_CNTR_REG);
+               if (ctrl & PCIMDAS_USER_CNTR_CTR1_CLK_SEL) {
+                       data[1] = 0;
+                       data[2] = I8254_OSC_BASE_100KHZ;
+               } else {
+                       data[1] = 1;
+                       data[2] = 0;
+               }
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return insn->n;
+}
+
+static unsigned int cb_pcimdas_pacer_clk(struct comedi_device *dev)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int status;
+
+       /* The Pacer Clock jumper selects a 10 MHz or 1 MHz clock */
+       status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+       if (status & PCIMDAS_STATUS_CLK)
+               return I8254_OSC_BASE_10MHZ;
+       return I8254_OSC_BASE_1MHZ;
+}
+
+static bool cb_pcimdas_is_ai_se(struct comedi_device *dev)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int status;
+
+       /*
+        * The number of Analog Input channels is set with the
+        * Analog Input Mode Switch on the board. The board can
+        * have 16 single-ended or 8 differential channels.
+        */
+       status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+       return status & PCIMDAS_STATUS_MUX;
+}
+
+static bool cb_pcimdas_is_ai_uni(struct comedi_device *dev)
+{
+       struct cb_pcimdas_private *devpriv = dev->private;
+       unsigned int status;
+
+       /*
+        * The Analog Input range polarity is set with the
+        * Analog Input Polarity Switch on the board. The
+        * inputs can be set to Unipolar or Bipolar ranges.
+        */
+       status = inb(devpriv->BADR3 + PCIMDAS_STATUS_REG);
+       return status & PCIMDAS_STATUS_UB;
+}
+
 static int cb_pcimdas_auto_attach(struct comedi_device *dev,
-                                           unsigned long context_unused)
+                                 unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct cb_pcimdas_private *devpriv;
@@ -201,42 +372,79 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
        devpriv->BADR3 = pci_resource_start(pcidev, 3);
        dev->iobase = pci_resource_start(pcidev, 4);
 
-       ret = comedi_alloc_subdevices(dev, 3);
+       dev->pacer = comedi_8254_init(devpriv->BADR3 + PCIMDAS_8254_BASE,
+                                     cb_pcimdas_pacer_clk(dev),
+                                     I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
+       ret = comedi_alloc_subdevices(dev, 6);
        if (ret)
                return ret;
 
+       /* Analog Input subdevice */
        s = &dev->subdevices[0];
-       /* dev->read_subdev=s; */
-       /*  analog input subdevice */
-       s->type = COMEDI_SUBD_AI;
-       s->subdev_flags = SDF_READABLE | SDF_GROUND;
-       s->n_chan = 16;
-       s->maxdata = 0xffff;
-       s->range_table = &range_unknown;
-       s->len_chanlist = 1;    /*  This is the maximum chanlist length that */
-       /*  the board can handle */
-       s->insn_read = cb_pcimdas_ai_rinsn;
+       s->type         = COMEDI_SUBD_AI;
+       s->subdev_flags = SDF_READABLE;
+       if (cb_pcimdas_is_ai_se(dev)) {
+               s->subdev_flags |= SDF_GROUND;
+               s->n_chan       = 16;
+       } else {
+               s->subdev_flags |= SDF_DIFF;
+               s->n_chan       = 8;
+       }
+       s->maxdata      = 0xffff;
+       s->range_table  = cb_pcimdas_is_ai_uni(dev) ? &cb_pcimdas_ai_uni_range
+                                                   : &cb_pcimdas_ai_bip_range;
+       s->insn_read    = cb_pcimdas_ai_insn_read;
 
+       /* Analog Output subdevice */
        s = &dev->subdevices[1];
-       /*  analog output subdevice */
-       s->type = COMEDI_SUBD_AO;
-       s->subdev_flags = SDF_WRITABLE;
-       s->n_chan = 2;
-       s->maxdata = 0xfff;
-       /* ranges are hardware settable, but not software readable. */
-       s->range_table = &range_unknown;
-       s->insn_write = cb_pcimdas_ao_insn_write;
+       s->type         = COMEDI_SUBD_AO;
+       s->subdev_flags = SDF_WRITABLE;
+       s->n_chan       = 2;
+       s->maxdata      = 0xfff;
+       s->range_table  = &cb_pcimdas_ao_range;
+       s->insn_write   = cb_pcimdas_ao_insn_write;
 
        ret = comedi_alloc_subdev_readback(s);
        if (ret)
                return ret;
 
+       /* Digital I/O subdevice */
        s = &dev->subdevices[2];
-       /* digital i/o subdevice */
-       ret = subdev_8255_init(dev, s, NULL, 0x00);
+       ret = subdev_8255_init(dev, s, NULL, PCIMDAS_8255_BASE);
        if (ret)
                return ret;
 
+       /* Digital Input subdevice (main connector) */
+       s = &dev->subdevices[3];
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 4;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_read    = cb_pcimdas_di_insn_read;
+
+       /* Digital Output subdevice (main connector) */
+       s = &dev->subdevices[4];
+       s->type         = COMEDI_SUBD_DO;
+       s->subdev_flags = SDF_WRITABLE;
+       s->n_chan       = 4;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_write   = cb_pcimdas_do_insn_write;
+
+       /* Counter subdevice (8254) */
+       s = &dev->subdevices[5];
+       comedi_8254_subdevice_init(s, dev->pacer);
+
+       dev->pacer->insn_config = cb_pcimdas_counter_insn_config;
+
+       /* counters 1 and 2 are used internally for the pacer */
+       comedi_8254_set_busy(dev->pacer, 1, true);
+       comedi_8254_set_busy(dev->pacer, 2, true);
+
        return 0;
 }
 
index 03043e7b9b589109fd256674fa056f6f8e018c7a..a4781dbbdd82e6469f6e5a1060ff0a2375b89bbf 100644 (file)
@@ -75,9 +75,8 @@ Configuration Options: not applicable, uses PCI auto config
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "8255.h"
 
@@ -134,7 +133,7 @@ static int cb_pcimdda_ao_insn_read(struct comedi_device *dev,
 }
 
 static int cb_pcimdda_auto_attach(struct comedi_device *dev,
-                                           unsigned long context_unused)
+                                 unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct comedi_subdevice *s;
diff --git a/drivers/staging/comedi/drivers/comedi_8254.c b/drivers/staging/comedi/drivers/comedi_8254.c
new file mode 100644 (file)
index 0000000..0d5d56b
--- /dev/null
@@ -0,0 +1,664 @@
+/*
+ * comedi_8254.c
+ * Generic 8254 timer/counter support
+ * Copyright (C) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
+ *
+ * Based on 8253.h and various subdevice implementations in comedi drivers.
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * Module: comedi_8254
+ * Description: Generic 8254 timer/counter support
+ * Author: H Hartley Sweeten <hsweeten@visionengravers.com>
+ * Updated: Thu Jan 8 16:45:45 MST 2015
+ * Status: works
+ *
+ * This module is not used directly by end-users. Rather, it is used by other
+ * drivers to provide support for an 8254 Programmable Interval Timer. These
+ * counters are typically used to generate the pacer clock used for data
+ * acquisition. Some drivers also expose the counters for general purpose use.
+ *
+ * This module provides the following basic functions:
+ *
+ * comedi_8254_init() / comedi_8254_mm_init()
+ *     Initializes this module to access the 8254 registers. The _mm version
+ *     sets up the module for MMIO register access the other for PIO access.
+ *     The pointer returned from these functions is normally stored in the
+ *     comedi_device dev->pacer and will be freed by the comedi core during
+ *     the driver (*detach). If a driver has multiple 8254 devices, they need
+ *     to be stored in the drivers private data and freed when the driver is
+ *     detached.
+ *
+ *     NOTE: The counters are reset by setting them to I8254_MODE0 as part of
+ *     this initialization.
+ *
+ * comedi_8254_set_mode()
+ *     Sets a counters operation mode:
+ *             I8254_MODE0     Interrupt on terminal count
+ *             I8254_MODE1     Hardware retriggerable one-shot
+ *             I8254_MODE2     Rate generator
+ *             I8254_MODE3     Square wave mode
+ *             I8254_MODE4     Software triggered strobe
+ *             I8254_MODE5     Hardware triggered strobe (retriggerable)
+ *
+ *     In addition I8254_BCD and I8254_BINARY specify the counting mode:
+ *             I8254_BCD       BCD counting
+ *             I8254_BINARY    Binary counting
+ *
+ * comedi_8254_write()
+ *     Writes an initial value to a counter.
+ *
+ *     The largest possible initial count is 0; this is equivalent to 2^16
+ *     for binary counting and 10^4 for BCD counting.
+ *
+ *     NOTE: The counter does not stop when it reaches zero. In Mode 0, 1, 4,
+ *     and 5 the counter "wraps around" to the highest count, either 0xffff
+ *     for binary counting or 9999 for BCD counting, and continues counting.
+ *     Modes 2 and 3 are periodic; the counter reloads itself with the initial
+ *     count and continues counting from there.
+ *
+ * comedi_8254_read()
+ *     Reads the current value from a counter.
+ *
+ * comedi_8254_status()
+ *     Reads the status of a counter.
+ *
+ * comedi_8254_load()
+ *     Sets a counters operation mode and writes the initial value.
+ *
+ * Typically the pacer clock is created by cascading two of the 16-bit counters
+ * to create a 32-bit rate generator (I8254_MODE2). These functions are
+ * provided to handle the cascaded counters:
+ *
+ * comedi_8254_ns_to_timer()
+ *     Calculates the divisor value needed for a single counter to generate
+ *     ns timing.
+ *
+ * comedi_8254_cascade_ns_to_timer()
+ *     Calculates the two divisor values needed to the generate the pacer
+ *     clock (in ns).
+ *
+ * comedi_8254_update_divisors()
+ *     Transfers the intermediate divisor values to the current divisors.
+ *
+ * comedi_8254_pacer_enable()
+ *     Programs the mode of the cascaded counters and writes the current
+ *     divisor values.
+ *
+ * To expose the counters as a subdevice for general purpose use the following
+ * functions a provided:
+ *
+ * comedi_8254_subdevice_init()
+ *     Initializes a comedi_subdevice to use the 8254 timer.
+ *
+ * comedi_8254_set_busy()
+ *     Internally flags a counter as "busy". This is done to protect the
+ *     counters that are used for the cascaded 32-bit pacer.
+ *
+ * The subdevice provides (*insn_read) and (*insn_write) operations to read
+ * the current value and write an initial value to a counter. A (*insn_config)
+ * operation is also provided to handle the following comedi instructions:
+ *
+ *     INSN_CONFIG_SET_COUNTER_MODE    calls comedi_8254_set_mode()
+ *     INSN_CONFIG_8254_READ_STATUS    calls comedi_8254_status()
+ *
+ * The (*insn_config) member of comedi_8254 can be initialized by the external
+ * driver to handle any additional instructions.
+ *
+ * NOTE: Gate control, clock routing, and any interrupt handling for the
+ * counters is not handled by this module. These features are driver dependent.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+
+#include "../comedidev.h"
+
+#include "comedi_8254.h"
+
+static unsigned int __i8254_read(struct comedi_8254 *i8254, unsigned int reg)
+{
+       unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift;
+       unsigned int val;
+
+       switch (i8254->iosize) {
+       default:
+       case I8254_IO8:
+               if (i8254->mmio)
+                       val = readb(i8254->mmio + reg_offset);
+               else
+                       val = inb(i8254->iobase + reg_offset);
+               break;
+       case I8254_IO16:
+               if (i8254->mmio)
+                       val = readw(i8254->mmio + reg_offset);
+               else
+                       val = inw(i8254->iobase + reg_offset);
+               break;
+       case I8254_IO32:
+               if (i8254->mmio)
+                       val = readl(i8254->mmio + reg_offset);
+               else
+                       val = inl(i8254->iobase + reg_offset);
+               break;
+       }
+       return val & 0xff;
+}
+
+static void __i8254_write(struct comedi_8254 *i8254,
+                         unsigned int val, unsigned int reg)
+{
+       unsigned int reg_offset = (reg * i8254->iosize) << i8254->regshift;
+
+       switch (i8254->iosize) {
+       default:
+       case I8254_IO8:
+               if (i8254->mmio)
+                       writeb(val, i8254->mmio + reg_offset);
+               else
+                       outb(val, i8254->iobase + reg_offset);
+               break;
+       case I8254_IO16:
+               if (i8254->mmio)
+                       writew(val, i8254->mmio + reg_offset);
+               else
+                       outw(val, i8254->iobase + reg_offset);
+               break;
+       case I8254_IO32:
+               if (i8254->mmio)
+                       writel(val, i8254->mmio + reg_offset);
+               else
+                       outl(val, i8254->iobase + reg_offset);
+               break;
+       }
+}
+
+/**
+ * comedi_8254_status - return the status of a counter
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ */
+unsigned int comedi_8254_status(struct comedi_8254 *i8254, unsigned int counter)
+{
+       unsigned int cmd;
+
+       if (counter > 2)
+               return 0;
+
+       cmd = I8254_CTRL_READBACK_STATUS | I8254_CTRL_READBACK_SEL_CTR(counter);
+       __i8254_write(i8254, cmd, I8254_CTRL_REG);
+
+       return __i8254_read(i8254, counter);
+}
+EXPORT_SYMBOL_GPL(comedi_8254_status);
+
+/**
+ * comedi_8254_read - read the current counter value
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ */
+unsigned int comedi_8254_read(struct comedi_8254 *i8254, unsigned int counter)
+{
+       unsigned int val;
+
+       if (counter > 2)
+               return 0;
+
+       /* latch counter */
+       __i8254_write(i8254, I8254_CTRL_SEL_CTR(counter) | I8254_CTRL_LATCH,
+                     I8254_CTRL_REG);
+
+       /* read LSB then MSB */
+       val = __i8254_read(i8254, counter);
+       val |= (__i8254_read(i8254, counter) << 8);
+
+       return val;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_read);
+
+/**
+ * comedi_8254_write - load a 16-bit initial counter value
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ * @val:       the initial value
+ */
+void comedi_8254_write(struct comedi_8254 *i8254,
+                      unsigned int counter, unsigned int val)
+{
+       unsigned int byte;
+
+       if (counter > 2)
+               return;
+       if (val > 0xffff)
+               return;
+
+       /* load LSB then MSB */
+       byte = val & 0xff;
+       __i8254_write(i8254, byte, counter);
+       byte = (val >> 8) & 0xff;
+       __i8254_write(i8254, byte, counter);
+}
+EXPORT_SYMBOL_GPL(comedi_8254_write);
+
+/**
+ * comedi_8254_set_mode - set the mode of a counter
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ * @mode:      the I8254_MODEx and I8254_BCD|I8254_BINARY
+ */
+int comedi_8254_set_mode(struct comedi_8254 *i8254, unsigned int counter,
+                        unsigned int mode)
+{
+       unsigned int byte;
+
+       if (counter > 2)
+               return -EINVAL;
+       if (mode > (I8254_MODE5 | I8254_BCD))
+               return -EINVAL;
+
+       byte = I8254_CTRL_SEL_CTR(counter) |    /* select counter */
+              I8254_CTRL_LSB_MSB |             /* load LSB then MSB */
+              mode;                            /* mode and BCD|binary */
+       __i8254_write(i8254, byte, I8254_CTRL_REG);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_set_mode);
+
+/**
+ * comedi_8254_load - program the mode and initial count of a counter
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ * @mode:      the I8254_MODEx and I8254_BCD|I8254_BINARY
+ * @val:       the initial value
+ */
+int comedi_8254_load(struct comedi_8254 *i8254, unsigned int counter,
+                    unsigned int val, unsigned int mode)
+{
+       if (counter > 2)
+               return -EINVAL;
+       if (val > 0xffff)
+               return -EINVAL;
+       if (mode > (I8254_MODE5 | I8254_BCD))
+               return -EINVAL;
+
+       comedi_8254_set_mode(i8254, counter, mode);
+       comedi_8254_write(i8254, counter, val);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_load);
+
+/**
+ * comedi_8254_pacer_enable - set the mode and load the cascaded counters
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter1:  the counter number for the first divisor
+ * @counter2:  the counter number for the second divisor
+ * @enable:    flag to enable (load) the counters
+ */
+void comedi_8254_pacer_enable(struct comedi_8254 *i8254,
+                             unsigned int counter1,
+                             unsigned int counter2,
+                             bool enable)
+{
+       unsigned int mode;
+
+       if (counter1 > 2 || counter2 > 2 || counter1 == counter2)
+               return;
+
+       if (enable)
+               mode = I8254_MODE2 | I8254_BINARY;
+       else
+               mode = I8254_MODE0 | I8254_BINARY;
+
+       comedi_8254_set_mode(i8254, counter1, mode);
+       comedi_8254_set_mode(i8254, counter2, mode);
+
+       if (enable) {
+               /*
+                * Divisors are loaded second counter then first counter to
+                * avoid possible issues with the first counter expiring
+                * before the second counter is loaded.
+                */
+               comedi_8254_write(i8254, counter2, i8254->divisor2);
+               comedi_8254_write(i8254, counter1, i8254->divisor1);
+       }
+}
+EXPORT_SYMBOL_GPL(comedi_8254_pacer_enable);
+
+/**
+ * comedi_8254_update_divisors - update the divisors for the cascaded counters
+ * @i8254:     comedi_8254 struct for the timer
+ */
+void comedi_8254_update_divisors(struct comedi_8254 *i8254)
+{
+       /* masking is done since counter maps zero to 0x10000 */
+       i8254->divisor = i8254->next_div & 0xffff;
+       i8254->divisor1 = i8254->next_div1 & 0xffff;
+       i8254->divisor2 = i8254->next_div2 & 0xffff;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_update_divisors);
+
+/**
+ * comedi_8254_cascade_ns_to_timer - calculate the cascaded divisor values
+ * @i8254:     comedi_8254 struct for the timer
+ * @nanosec:   the desired ns time
+ * @flags:     comedi_cmd flags
+ */
+void comedi_8254_cascade_ns_to_timer(struct comedi_8254 *i8254,
+                                    unsigned int *nanosec,
+                                    unsigned int flags)
+{
+       unsigned int d1 = i8254->next_div1 ? i8254->next_div1 : I8254_MAX_COUNT;
+       unsigned int d2 = i8254->next_div2 ? i8254->next_div2 : I8254_MAX_COUNT;
+       unsigned int div = d1 * d2;
+       unsigned int ns_lub = 0xffffffff;
+       unsigned int ns_glb = 0;
+       unsigned int d1_lub = 0;
+       unsigned int d1_glb = 0;
+       unsigned int d2_lub = 0;
+       unsigned int d2_glb = 0;
+       unsigned int start;
+       unsigned int ns;
+       unsigned int ns_low;
+       unsigned int ns_high;
+
+       /* exit early if everything is already correct */
+       if (div * i8254->osc_base == *nanosec &&
+           d1 > 1 && d1 <= I8254_MAX_COUNT &&
+           d2 > 1 && d2 <= I8254_MAX_COUNT &&
+           /* check for overflow */
+           div > d1 && div > d2 &&
+           div * i8254->osc_base > div &&
+           div * i8254->osc_base > i8254->osc_base)
+               return;
+
+       div = *nanosec / i8254->osc_base;
+       d2 = I8254_MAX_COUNT;
+       start = div / d2;
+       if (start < 2)
+               start = 2;
+       for (d1 = start; d1 <= div / d1 + 1 && d1 <= I8254_MAX_COUNT; d1++) {
+               for (d2 = div / d1;
+                    d1 * d2 <= div + d1 + 1 && d2 <= I8254_MAX_COUNT; d2++) {
+                       ns = i8254->osc_base * d1 * d2;
+                       if (ns <= *nanosec && ns > ns_glb) {
+                               ns_glb = ns;
+                               d1_glb = d1;
+                               d2_glb = d2;
+                       }
+                       if (ns >= *nanosec && ns < ns_lub) {
+                               ns_lub = ns;
+                               d1_lub = d1;
+                               d2_lub = d2;
+                       }
+               }
+       }
+
+       switch (flags & CMDF_ROUND_MASK) {
+       case CMDF_ROUND_NEAREST:
+       default:
+               ns_high = d1_lub * d2_lub * i8254->osc_base;
+               ns_low = d1_glb * d2_glb * i8254->osc_base;
+               if (ns_high - *nanosec < *nanosec - ns_low) {
+                       d1 = d1_lub;
+                       d2 = d2_lub;
+               } else {
+                       d1 = d1_glb;
+                       d2 = d2_glb;
+               }
+               break;
+       case CMDF_ROUND_UP:
+               d1 = d1_lub;
+               d2 = d2_lub;
+               break;
+       case CMDF_ROUND_DOWN:
+               d1 = d1_glb;
+               d2 = d2_glb;
+               break;
+       }
+
+       *nanosec = d1 * d2 * i8254->osc_base;
+       i8254->next_div1 = d1;
+       i8254->next_div2 = d2;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_cascade_ns_to_timer);
+
+/**
+ * comedi_8254_ns_to_timer - calculate the divisor value for nanosec timing
+ * @i8254:     comedi_8254 struct for the timer
+ * @nanosec:   the desired ns time
+ * @flags:     comedi_cmd flags
+ */
+void comedi_8254_ns_to_timer(struct comedi_8254 *i8254,
+                            unsigned int *nanosec, unsigned int flags)
+{
+       unsigned int divisor;
+
+       switch (flags & CMDF_ROUND_MASK) {
+       default:
+       case CMDF_ROUND_NEAREST:
+               divisor = DIV_ROUND_CLOSEST(*nanosec, i8254->osc_base);
+               break;
+       case CMDF_ROUND_UP:
+               divisor = DIV_ROUND_UP(*nanosec, i8254->osc_base);
+               break;
+       case CMDF_ROUND_DOWN:
+               divisor = *nanosec / i8254->osc_base;
+               break;
+       }
+       if (divisor < 2)
+               divisor = 2;
+       if (divisor > I8254_MAX_COUNT)
+               divisor = I8254_MAX_COUNT;
+
+       *nanosec = divisor * i8254->osc_base;
+       i8254->next_div = divisor;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_ns_to_timer);
+
+/**
+ * comedi_8254_set_busy - set/clear the "busy" flag for a given counter
+ * @i8254:     comedi_8254 struct for the timer
+ * @counter:   the counter number
+ * @busy:      set/clear flag
+ */
+void comedi_8254_set_busy(struct comedi_8254 *i8254,
+                         unsigned int counter, bool busy)
+{
+       if (counter < 3)
+               i8254->busy[counter] = busy;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_set_busy);
+
+static int comedi_8254_insn_read(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       struct comedi_8254 *i8254 = s->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       int i;
+
+       if (i8254->busy[chan])
+               return -EBUSY;
+
+       for (i = 0; i < insn->n; i++)
+               data[i] = comedi_8254_read(i8254, chan);
+
+       return insn->n;
+}
+
+static int comedi_8254_insn_write(struct comedi_device *dev,
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
+{
+       struct comedi_8254 *i8254 = s->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+
+       if (i8254->busy[chan])
+               return -EBUSY;
+
+       if (insn->n)
+               comedi_8254_write(i8254, chan, data[insn->n - 1]);
+
+       return insn->n;
+}
+
+static int comedi_8254_insn_config(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
+{
+       struct comedi_8254 *i8254 = s->private;
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       int ret;
+
+       if (i8254->busy[chan])
+               return -EBUSY;
+
+       switch (data[0]) {
+       case INSN_CONFIG_RESET:
+               ret = comedi_8254_set_mode(i8254, chan,
+                                          I8254_MODE0 | I8254_BINARY);
+               if (ret)
+                       return ret;
+               break;
+       case INSN_CONFIG_SET_COUNTER_MODE:
+               ret = comedi_8254_set_mode(i8254, chan, data[1]);
+               if (ret)
+                       return ret;
+               break;
+       case INSN_CONFIG_8254_READ_STATUS:
+               data[1] = comedi_8254_status(i8254, chan);
+               break;
+       default:
+               /*
+                * If available, call the driver provided (*insn_config)
+                * to handle any driver implemented instructions.
+                */
+               if (i8254->insn_config)
+                       return i8254->insn_config(dev, s, insn, data);
+
+               return -EINVAL;
+       }
+
+       return insn->n;
+}
+
+/**
+ * comedi_8254_subdevice_init - initialize a comedi_subdevice for the 8254 timer
+ * @s:         comedi_subdevice struct
+ */
+void comedi_8254_subdevice_init(struct comedi_subdevice *s,
+                               struct comedi_8254 *i8254)
+{
+       s->type         = COMEDI_SUBD_COUNTER;
+       s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+       s->n_chan       = 3;
+       s->maxdata      = 0xffff;
+       s->range_table  = &range_unknown;
+       s->insn_read    = comedi_8254_insn_read;
+       s->insn_write   = comedi_8254_insn_write;
+       s->insn_config  = comedi_8254_insn_config;
+
+       s->private      = i8254;
+}
+EXPORT_SYMBOL_GPL(comedi_8254_subdevice_init);
+
+static struct comedi_8254 *__i8254_init(unsigned long iobase,
+                                       void __iomem *mmio,
+                                       unsigned int osc_base,
+                                       unsigned int iosize,
+                                       unsigned int regshift)
+{
+       struct comedi_8254 *i8254;
+       int i;
+
+       /* sanity check that the iosize is valid */
+       if (!(iosize == I8254_IO8 || iosize == I8254_IO16 ||
+             iosize == I8254_IO32))
+               return NULL;
+
+       i8254 = kzalloc(sizeof(*i8254), GFP_KERNEL);
+       if (!i8254)
+               return NULL;
+
+       i8254->iobase   = iobase;
+       i8254->mmio     = mmio;
+       i8254->iosize   = iosize;
+       i8254->regshift = regshift;
+
+       /* default osc_base to the max speed of a generic 8254 timer */
+       i8254->osc_base = osc_base ? osc_base : I8254_OSC_BASE_10MHZ;
+
+       /* reset all the counters by setting them to I8254_MODE0 */
+       for (i = 0; i < 3; i++)
+               comedi_8254_set_mode(i8254, i, I8254_MODE0 | I8254_BINARY);
+
+       return i8254;
+}
+
+/**
+ * comedi_8254_init - allocate and initialize the 8254 device for pio access
+ * @mmio:      port I/O base address
+ * @osc_base:  base time of the counter in ns
+ *             OPTIONAL - only used by comedi_8254_cascade_ns_to_timer()
+ * @iosize:    I/O register size
+ * @regshift:  register gap shift
+ */
+struct comedi_8254 *comedi_8254_init(unsigned long iobase,
+                                    unsigned int osc_base,
+                                    unsigned int iosize,
+                                    unsigned int regshift)
+{
+       return __i8254_init(iobase, NULL, osc_base, iosize, regshift);
+}
+EXPORT_SYMBOL_GPL(comedi_8254_init);
+
+/**
+ * comedi_8254_mm_init - allocate and initialize the 8254 device for mmio access
+ * @mmio:      memory mapped I/O base address
+ * @osc_base:  base time of the counter in ns
+ *             OPTIONAL - only used by comedi_8254_cascade_ns_to_timer()
+ * @iosize:    I/O register size
+ * @regshift:  register gap shift
+ */
+struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio,
+                                       unsigned int osc_base,
+                                       unsigned int iosize,
+                                       unsigned int regshift)
+{
+       return __i8254_init(0, mmio, osc_base, iosize, regshift);
+}
+EXPORT_SYMBOL_GPL(comedi_8254_mm_init);
+
+static int __init comedi_8254_module_init(void)
+{
+       return 0;
+}
+module_init(comedi_8254_module_init);
+
+static void __exit comedi_8254_module_exit(void)
+{
+}
+module_exit(comedi_8254_module_exit);
+
+MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
+MODULE_DESCRIPTION("Comedi: Generic 8254 timer/counter support");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/comedi_8254.h b/drivers/staging/comedi/drivers/comedi_8254.h
new file mode 100644 (file)
index 0000000..d89f6d9
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * comedi_8254.h
+ * Generic 8254 timer/counter support
+ * Copyright (C) 2014 H Hartley Sweeten <hsweeten@visionengravers.com>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _COMEDI_8254_H
+#define _COMEDI_8254_H
+
+/*
+ * Common oscillator base values in nanoseconds
+ */
+#define I8254_OSC_BASE_10MHZ   100
+#define I8254_OSC_BASE_5MHZ    200
+#define I8254_OSC_BASE_4MHZ    250
+#define I8254_OSC_BASE_2MHZ    500
+#define I8254_OSC_BASE_1MHZ    1000
+#define I8254_OSC_BASE_100KHZ  10000
+#define I8254_OSC_BASE_10KHZ   100000
+#define I8254_OSC_BASE_1KHZ    1000000
+
+/*
+ * I/O access size used to read/write registers
+ */
+#define I8254_IO8              1
+#define I8254_IO16             2
+#define I8254_IO32             4
+
+/*
+ * Register map for generic 8254 timer (I8254_IO8 with 0 regshift)
+ */
+#define I8254_COUNTER0_REG             0x00
+#define I8254_COUNTER1_REG             0x01
+#define I8254_COUNTER2_REG             0x02
+#define I8254_CTRL_REG                 0x03
+#define I8254_CTRL_SEL_CTR(x)          ((x) << 6)
+#define I8254_CTRL_READBACK_COUNT      ((3 << 6) | (1 << 4))
+#define I8254_CTRL_READBACK_STATUS     ((3 << 6) | (1 << 5))
+#define I8254_CTRL_READBACK_SEL_CTR(x) (2 << (x))
+#define I8254_CTRL_LATCH               (0 << 4)
+#define I8254_CTRL_LSB_ONLY            (1 << 4)
+#define I8254_CTRL_MSB_ONLY            (2 << 4)
+#define I8254_CTRL_LSB_MSB             (3 << 4)
+
+/* counter maps zero to 0x10000 */
+#define I8254_MAX_COUNT                        0x10000
+
+/**
+ * struct comedi_8254 - private data used by this module
+ * @iobase:            PIO base address of the registers (in/out)
+ * @mmio:              MMIO base address of the registers (read/write)
+ * @iosize:            I/O size used to access the registers (b/w/l)
+ * @regshift:          register gap shift
+ * @osc_base:          cascaded oscillator speed in ns
+ * @divisor:           divisor for single counter
+ * @divisor1:          divisor loaded into first cascaded counter
+ * @divisor2:          divisor loaded into second cascaded counter
+ * #next_div:          next divisor for single counter
+ * @next_div1:         next divisor to use for first cascaded counter
+ * @next_div2:         next divisor to use for second cascaded counter
+ * @clock_src;         current clock source for each counter (driver specific)
+ * @gate_src;          current gate source  for each counter (driver specific)
+ * @busy:              flags used to indicate that a counter is "busy"
+ * @insn_config:       driver specific (*insn_config) callback
+ */
+struct comedi_8254 {
+       unsigned long iobase;
+       void __iomem *mmio;
+       unsigned int iosize;
+       unsigned int regshift;
+       unsigned int osc_base;
+       unsigned int divisor;
+       unsigned int divisor1;
+       unsigned int divisor2;
+       unsigned int next_div;
+       unsigned int next_div1;
+       unsigned int next_div2;
+       unsigned int clock_src[3];
+       unsigned int gate_src[3];
+       bool busy[3];
+
+       int (*insn_config)(struct comedi_device *, struct comedi_subdevice *s,
+                          struct comedi_insn *, unsigned int *data);
+};
+
+unsigned int comedi_8254_status(struct comedi_8254 *, unsigned int counter);
+unsigned int comedi_8254_read(struct comedi_8254 *, unsigned int counter);
+void comedi_8254_write(struct comedi_8254 *,
+                      unsigned int counter, unsigned int val);
+
+int comedi_8254_set_mode(struct comedi_8254 *,
+                        unsigned int counter, unsigned int mode);
+int comedi_8254_load(struct comedi_8254 *,
+                    unsigned int counter, unsigned int val, unsigned int mode);
+
+void comedi_8254_pacer_enable(struct comedi_8254 *,
+                             unsigned int counter1, unsigned int counter2,
+                             bool enable);
+void comedi_8254_update_divisors(struct comedi_8254 *);
+void comedi_8254_cascade_ns_to_timer(struct comedi_8254 *,
+                                    unsigned int *nanosec, unsigned int flags);
+void comedi_8254_ns_to_timer(struct comedi_8254 *,
+                            unsigned int *nanosec, unsigned int flags);
+
+void comedi_8254_set_busy(struct comedi_8254 *,
+                         unsigned int counter, bool busy);
+
+void comedi_8254_subdevice_init(struct comedi_subdevice *,
+                               struct comedi_8254 *);
+
+struct comedi_8254 *comedi_8254_init(unsigned long iobase,
+                                    unsigned int osc_base,
+                                    unsigned int iosize,
+                                    unsigned int regshift);
+struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio,
+                                       unsigned int osc_base,
+                                       unsigned int iosize,
+                                       unsigned int regshift);
+
+#endif /* _COMEDI_8254_H */
index 221d3819c96744711fd2fe2c018317dd4691d389..96db0c2686a1e6971478ee74c23412049fb654cf 100644 (file)
@@ -267,7 +267,6 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
                                strlcat(devpriv->name, buf,
                                        sizeof(devpriv->name));
                        }
-
                }
        }
 
@@ -313,9 +312,9 @@ static int bonding_attach(struct comedi_device *dev,
        s->insn_config = bonding_dio_insn_config;
 
        dev_info(dev->class_dev,
-               "%s: %s attached, %u channels from %u devices\n",
-               dev->driver->driver_name, dev->board_name,
-               devpriv->nchans, devpriv->ndevs);
+                "%s: %s attached, %u channels from %u devices\n",
+                dev->driver->driver_name, dev->board_name,
+                devpriv->nchans, devpriv->ndevs);
 
        return 0;
 }
index e856f01ca07716c8acb3881bbe8e4373a64beab5..6ba71d114a95c180f95eebb6d1af93707cd50818 100644 (file)
@@ -235,7 +235,8 @@ void comedi_isadma_free(struct comedi_isadma *dma)
                        desc = &dma->desc[i];
                        if (desc->virt_addr)
                                dma_free_coherent(NULL, desc->maxsize,
-                                               desc->virt_addr, desc->hw_addr);
+                                                 desc->virt_addr,
+                                                 desc->hw_addr);
                }
                kfree(dma->desc);
        }
index e56525a1c8f3bf55571e04ed4caae6ce011f9c5b..fbc43420f698d6ebb3b15e57a35580d10e7d6dd4 100644 (file)
@@ -420,9 +420,8 @@ static int waveform_attach(struct comedi_device *dev,
        for (i = 0; i < s->n_chan; i++)
                devpriv->ao_loopbacks[i] = s->maxdata / 2;
 
-       init_timer(&devpriv->timer);
-       devpriv->timer.function = waveform_ai_interrupt;
-       devpriv->timer.data = (unsigned long)dev;
+       setup_timer(&devpriv->timer, waveform_ai_interrupt,
+                   (unsigned long)dev);
 
        dev_info(dev->class_dev,
                 "%s: %i microvolt, %li microsecond waveform attached\n",
index 205f9df345a212d9beafde891ce2c125617b863c..4956a49a61400aab2dd228a6fe282f381cb20aa3 100644 (file)
@@ -26,9 +26,8 @@ Configuration Options: not applicable, uses comedi PCI auto config
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * Register map
@@ -59,7 +58,7 @@ static int contec_di_insn_bits(struct comedi_device *dev,
 }
 
 static int contec_auto_attach(struct comedi_device *dev,
-                                       unsigned long context_unused)
+                             unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct comedi_subdevice *s;
index 96697fbb5239af57df6dc6ba93da02cd0d7b0a52..f97d18d92255bf6b6047d29610975a3a22aff4ae 100644 (file)
@@ -103,11 +103,10 @@ Configuration options: not applicable, uses PCI auto config
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "8255.h"
 
@@ -649,7 +648,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev,
 }
 
 static int daqboard2000_auto_attach(struct comedi_device *dev,
-                                             unsigned long context_unused)
+                                   unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        const struct daq200_boardtype *board;
index c78c0df9bbe30e731403db335be53262862b8ff5..73f4c8dbbde3ff926eba8e3280d7dc72a985aaa1 100644 (file)
@@ -23,7 +23,7 @@
 #include "../comedidev.h"
 
 #include "8255.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "das08.h"
 
 /*
@@ -359,62 +359,6 @@ static int das08_ao_insn_write(struct comedi_device *dev,
        return insn->n;
 }
 
-static void i8254_initialize(struct comedi_device *dev)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       unsigned int mode = I8254_MODE0 | I8254_BINARY;
-       int i;
-
-       for (i = 0; i < 3; ++i)
-               i8254_set_mode(i8254_iobase, 0, i, mode);
-}
-
-static int das08_counter_read(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       data[0] = i8254_read(i8254_iobase, 0, chan);
-       return 1;
-}
-
-static int das08_counter_write(struct comedi_device *dev,
-                              struct comedi_subdevice *s,
-                              struct comedi_insn *insn, unsigned int *data)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       i8254_write(i8254_iobase, 0, chan, data[0]);
-       return 1;
-}
-
-static int das08_counter_config(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
-{
-       const struct das08_board_struct *thisboard = dev->board_ptr;
-       unsigned long i8254_iobase = dev->iobase + thisboard->i8254_offset;
-       int chan = insn->chanspec;
-
-       switch (data[0]) {
-       case INSN_CONFIG_SET_COUNTER_MODE:
-               i8254_set_mode(i8254_iobase, 0, chan, data[1]);
-               break;
-       case INSN_CONFIG_8254_READ_STATUS:
-               data[1] = i8254_status(i8254_iobase, 0, chan);
-               break;
-       default:
-               return -EINVAL;
-       }
-       return 2;
-}
-
 int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 {
        const struct das08_board_struct *thisboard = dev->board_ptr;
@@ -464,7 +408,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                if (ret)
                        return ret;
 
-               /* intialize all channels to 0V */
+               /* initialize all channels to 0V */
                for (i = 0; i < s->n_chan; i++) {
                        s->readback[i] = s->maxdata / 2;
                        das08_ao_set_data(dev, i, s->readback[i]);
@@ -511,17 +455,16 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                s->type = COMEDI_SUBD_UNUSED;
        }
 
+       /* Counter subdevice (8254) */
        s = &dev->subdevices[5];
-       /* 8254 */
-       if (thisboard->i8254_offset != 0) {
-               s->type = COMEDI_SUBD_COUNTER;
-               s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-               s->n_chan = 3;
-               s->maxdata = 0xFFFF;
-               s->insn_read = das08_counter_read;
-               s->insn_write = das08_counter_write;
-               s->insn_config = das08_counter_config;
-               i8254_initialize(dev);
+       if (thisboard->i8254_offset) {
+               dev->pacer = comedi_8254_init(dev->iobase +
+                                             thisboard->i8254_offset,
+                                             0, I8254_IO8, 0);
+               if (!dev->pacer)
+                       return -ENOMEM;
+
+               comedi_8254_subdevice_init(s, dev->pacer);
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }
index b2ea10b848c354a3c3dff92697003a372f2f6f28..d8d27fa4449133720189cf1e681877d571f9b968 100644 (file)
@@ -32,9 +32,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "das08.h"
 
index 2c20311120f18638d251225a79bf88f36d69a11a..f66db97b9d4fc97ae0e21eb62d06c9a41f93adda 100644 (file)
@@ -77,7 +77,7 @@
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"
 
 #define DAS16_DMA_SIZE 0xff00  /*  size in bytes of allocated dma buffer */
@@ -663,18 +663,12 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
        /*  step 4: fix up arguments */
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
        if (err)
@@ -693,17 +687,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
                                    unsigned int flags)
 {
-       struct das16_private_struct *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
-
-       i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                 &devpriv->divisor1, &devpriv->divisor2,
-                                 &ns, flags);
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->divisor2);
+       comedi_8254_cascade_ns_to_timer(dev->pacer, &ns, flags);
+       comedi_8254_update_divisors(dev->pacer);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 
        return ns;
 }
@@ -722,7 +708,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (cmd->flags & CMDF_PRIORITY) {
                dev_err(dev->class_dev,
-                        "isa dma transfers cannot be performed with CMDF_PRIORITY, aborting\n");
+                       "isa dma transfers cannot be performed with CMDF_PRIORITY, aborting\n");
                return -1;
        }
 
@@ -935,7 +921,6 @@ static void das16_reset(struct comedi_device *dev)
        outb(0, dev->iobase + DAS16_STATUS_REG);
        outb(0, dev->iobase + DAS16_CTRL_REG);
        outb(0, dev->iobase + DAS16_PACER_REG);
-       outb(0, dev->iobase + DAS16_TIMER_BASE_REG + i8254_control_reg);
 }
 
 static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
@@ -950,9 +935,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
        devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
                                           DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
        if (devpriv->dma) {
-               init_timer(&devpriv->timer);
-               devpriv->timer.function = das16_timer_interrupt;
-               devpriv->timer.data = (unsigned long)dev;
+               setup_timer(&devpriv->timer, das16_timer_interrupt,
+                           (unsigned long)dev);
        }
 }
 
@@ -1039,6 +1023,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        const struct das16_board *board = dev->board_ptr;
        struct das16_private_struct *devpriv;
        struct comedi_subdevice *s;
+       unsigned int osc_base;
        unsigned int status;
        int ret;
 
@@ -1078,21 +1063,21 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return -EINVAL;
 
        /*  get master clock speed */
+       osc_base = I8254_OSC_BASE_1MHZ;
        if (devpriv->can_burst) {
                status = inb(dev->iobase + DAS1600_STATUS_REG);
-
                if (status & DAS1600_STATUS_CLK_10MHZ)
-                       devpriv->clockbase = I8254_OSC_BASE_10MHZ;
-               else
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+                       osc_base = I8254_OSC_BASE_10MHZ;
        } else {
                if (it->options[3])
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ /
-                                            it->options[3];
-               else
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+                       osc_base = I8254_OSC_BASE_1MHZ / it->options[3];
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS16_TIMER_BASE_REG,
+                                     osc_base, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        das16_alloc_dma(dev, it->options[2]);
 
        ret = comedi_alloc_subdevices(dev, 4 + board->has_8255);
index 3666a68979fb65379b894b89a5d834141c77e9d0..cdef03d09738bb9bec32232dad2f7ce6dda162bc 100644 (file)
@@ -53,11 +53,12 @@ irq can be omitted, although the cmd interface will not work without it.
 */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include "../comedidev.h"
 
 #include "8255.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "comedi_fc.h"
 
 #define DAS16M1_SIZE2 8
@@ -103,8 +104,6 @@ irq can be omitted, although the cmd interface will not work without it.
 #define   Q_RANGE(x)             (((x) & 0xf) << 4)
 #define   UNIPOLAR               0x40
 #define DAS16M1_8254_FIRST             0x8
-#define DAS16M1_8254_FIRST_CNTRL       0xb
-#define   TOTAL_CLEAR                    0x30
 #define DAS16M1_8254_SECOND            0xc
 #define DAS16M1_82C55                  0x400
 #define DAS16M1_8254_THIRD             0x404
@@ -124,6 +123,7 @@ static const struct comedi_lrange range_das16m1 = {
 };
 
 struct das16m1_private_struct {
+       struct comedi_8254 *counter;
        unsigned int control_state;
        unsigned int adc_count; /*  number of samples completed */
        /* initial value in lower half of hardware conversion counter,
@@ -131,8 +131,6 @@ struct das16m1_private_struct {
         * counter yet (loaded by first sample conversion) */
        u16 initial_hw_count;
        unsigned short ai_buffer[FIFO_SIZE];
-       unsigned int divisor1;  /*  divides master clock to obtain conversion speed */
-       unsigned int divisor2;  /*  divides master clock to obtain conversion speed */
        unsigned long extra_iobase;
 };
 
@@ -169,7 +167,7 @@ static int das16m1_ai_check_chanlist(struct comedi_device *dev,
 
                if ((i % 2) != (chan % 2)) {
                        dev_dbg(dev->class_dev,
-                                "even/odd channels must go have even/odd chanlist indices\n");
+                               "even/odd channels must go have even/odd chanlist indices\n");
                        return -EINVAL;
                }
        }
@@ -180,9 +178,7 @@ static int das16m1_ai_check_chanlist(struct comedi_device *dev,
 static int das16m1_cmd_test(struct comedi_device *dev,
                            struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
-       struct das16m1_private_struct *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -229,11 +225,9 @@ static int das16m1_cmd_test(struct comedi_device *dev,
        /* step 4: fix up arguments */
 
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -250,25 +244,12 @@ static int das16m1_cmd_test(struct comedi_device *dev,
        return 0;
 }
 
-static void das16m1_set_pacer(struct comedi_device *dev)
-{
-       struct das16m1_private_struct *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAS16M1_8254_SECOND;
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-       i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->divisor2);
-}
-
 static int das16m1_cmd_exec(struct comedi_device *dev,
                            struct comedi_subdevice *s)
 {
        struct das16m1_private_struct *devpriv = dev->private;
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
-       unsigned long timer_base = dev->iobase + DAS16M1_8254_FIRST;
        unsigned int byte, i;
 
        /* disable interrupts and internal pacer */
@@ -277,14 +258,21 @@ static int das16m1_cmd_exec(struct comedi_device *dev,
 
        /*  set software count */
        devpriv->adc_count = 0;
-       /* Initialize lower half of hardware counter, used to determine how
+
+       /*
+        * Initialize lower half of hardware counter, used to determine how
         * many samples are in fifo.  Value doesn't actually load into counter
-        * until counter's next clock (the next a/d conversion) */
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_write(timer_base, 0, 1, 0);
-       /* remember current reading of counter so we know when counter has
-        * actually been loaded */
-       devpriv->initial_hw_count = i8254_read(timer_base, 0, 1);
+        * until counter's next clock (the next a/d conversion).
+        */
+       comedi_8254_set_mode(devpriv->counter, 1, I8254_MODE2 | I8254_BINARY);
+       comedi_8254_write(devpriv->counter, 1, 0);
+
+       /*
+        * Remember current reading of counter so we know when counter has
+        * actually been loaded.
+        */
+       devpriv->initial_hw_count = comedi_8254_read(devpriv->counter, 1);
+
        /* setup channel/gain queue */
        for (i = 0; i < cmd->chanlist_len; i++) {
                outb(i, dev->iobase + DAS16M1_QUEUE_ADDR);
@@ -297,7 +285,8 @@ static int das16m1_cmd_exec(struct comedi_device *dev,
        /* enable interrupts and set internal pacer counter mode and counts */
        devpriv->control_state &= ~PACER_MASK;
        if (cmd->convert_src == TRIG_TIMER) {
-               das16m1_set_pacer(dev);
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
                devpriv->control_state |= INT_PACER;
        } else {        /* TRIG_EXT */
                devpriv->control_state |= EXT_PACER;
@@ -417,8 +406,8 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
        async = s->async;
        cmd = &async->cmd;
 
-       /*  figure out how many samples are in fifo */
-       hw_counter = i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
+       /* figure out how many samples are in fifo */
+       hw_counter = comedi_8254_read(devpriv->counter, 1);
        /* make sure hardware counter reading is not bogus due to initial value
         * not having been loaded yet */
        if (devpriv->adc_count == 0 && hw_counter == devpriv->initial_hw_count) {
@@ -563,6 +552,16 @@ static int das16m1_attach(struct comedi_device *dev,
                        dev->irq = it->options[1];
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS16M1_8254_SECOND,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
+       devpriv->counter = comedi_8254_init(dev->iobase + DAS16M1_8254_FIRST,
+                                           0, I8254_IO8, 0);
+       if (!devpriv->counter)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
@@ -609,9 +608,6 @@ static int das16m1_attach(struct comedi_device *dev,
        if (ret)
                return ret;
 
-       /*  disable upper half of hardware conversion counter so it doesn't mess with us */
-       outb(TOTAL_CLEAR, dev->iobase + DAS16M1_8254_FIRST_CNTRL);
-
        /*  initialize digital output lines */
        outb(0, dev->iobase + DAS16M1_DIO);
 
@@ -626,8 +622,11 @@ static void das16m1_detach(struct comedi_device *dev)
 {
        struct das16m1_private_struct *devpriv = dev->private;
 
-       if (devpriv && devpriv->extra_iobase)
-               release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
+       if (devpriv) {
+               if (devpriv->extra_iobase)
+                       release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
+               kfree(devpriv->counter);
+       }
        comedi_legacy_detach(dev);
 }
 
index 0790a28828de79f3c5625d3739ff2972f669cca1..0a93ae93da9306627f48d6b95881aa4ad9828d2c 100644 (file)
@@ -103,7 +103,7 @@ TODO:
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /* misc. defines */
 #define DAS1800_SIZE           16      /* uses 16 io addresses */
@@ -422,8 +422,6 @@ static const struct das1800_board das1800_boards[] = {
 
 struct das1800_private {
        struct comedi_isadma *dma;
-       unsigned int divisor1;  /* value to load into board's counter 1 for timed conversions */
-       unsigned int divisor2;  /* value to load into board's counter 2 for timed conversions */
        int irq_dma_bits;       /* bits for control register b */
        /* dma bits for control register b, stored so that dma can be
         * turned on and off */
@@ -491,9 +489,7 @@ static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
 
        while (inb(dev->iobase + DAS1800_STATUS) & FNE) {
                dpnt = inw(dev->iobase + DAS1800_FIFO);
-               /* convert to unsigned type if we are in a bipolar mode */
-               if (!unipolar)
-                       ;
+               /* convert to unsigned type */
                dpnt = munge_bipolar_sample(dev, dpnt);
                comedi_buf_write_samples(s, &dpnt, 1);
 
@@ -731,7 +727,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
                                 struct comedi_cmd *cmd)
 {
        const struct das1800_board *thisboard = dev->board_ptr;
-       struct das1800_private *devpriv = dev->private;
        int err = 0;
        unsigned int arg;
 
@@ -795,35 +790,23 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
            cmd->convert_src == TRIG_TIMER) {
                /* we are not in burst mode */
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &cmd->convert_arg, cmd->flags);
-               if (arg != cmd->convert_arg)
-                       err++;
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        } else if (cmd->convert_src == TRIG_TIMER) {
                /* we are in burst mode */
-               arg = cmd->convert_arg;
-               cmd->convert_arg = burst_convert_arg(cmd->convert_arg,
-                                                    cmd->flags);
-               if (arg != cmd->convert_arg)
-                       err++;
+               arg = burst_convert_arg(cmd->convert_arg, cmd->flags);
+               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        arg = cmd->convert_arg * cmd->chanlist_len;
-                       if (arg > cmd->scan_begin_arg) {
-                               cmd->scan_begin_arg = arg;
-                               err++;
-                       }
+                       err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                        arg);
 
                        arg = cmd->scan_begin_arg;
-                       i8253_cascade_ns_to_timer(I8254_OSC_BASE_5MHZ,
-                                                 &devpriv->divisor1,
-                                                 &devpriv->divisor2,
-                                                 &cmd->scan_begin_arg,
-                                                 cmd->flags);
-                       if (arg != cmd->scan_begin_arg)
-                               err++;
+                       comedi_8254_cascade_ns_to_timer(dev->pacer, &arg,
+                                                       cmd->flags);
+                       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg,
+                                                       arg);
                }
        }
 
@@ -910,31 +893,6 @@ static int control_c_bits(const struct comedi_cmd *cmd)
        return control_c;
 }
 
-static void das1800_setup_counters(struct comedi_device *dev,
-                                  const struct comedi_cmd *cmd)
-{
-       struct das1800_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAS1800_COUNTER;
-
-       /* setup cascaded counters for conversion/scan frequency */
-       if ((cmd->scan_begin_src == TRIG_FOLLOW ||
-            cmd->scan_begin_src == TRIG_TIMER) &&
-           cmd->convert_src == TRIG_TIMER) {
-               i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-               i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-               i8254_write(timer_base, 0, 1, devpriv->divisor1);
-               i8254_write(timer_base, 0, 2, devpriv->divisor2);
-       }
-
-       /* setup counter 0 for 'about triggering' */
-       if (cmd->stop_src == TRIG_EXT) {
-               i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY);
-
-               i8254_write(timer_base, 0, 0, 1);
-       }
-}
-
 static unsigned int das1800_ai_transfer_size(struct comedi_device *dev,
                                             struct comedi_subdevice *s,
                                             unsigned int maxbytes,
@@ -1053,7 +1011,19 @@ static int das1800_ai_do_cmd(struct comedi_device *dev,
 
        /* setup card and start */
        program_chanlist(dev, cmd);
-       das1800_setup_counters(dev, cmd);
+
+       /* setup cascaded counters for conversion/scan frequency */
+       if ((cmd->scan_begin_src == TRIG_FOLLOW ||
+            cmd->scan_begin_src == TRIG_TIMER) &&
+           cmd->convert_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
+       }
+
+       /* setup counter 0 for 'about triggering' */
+       if (cmd->stop_src == TRIG_EXT)
+               comedi_8254_load(dev->pacer, 0, 1, I8254_MODE0 | I8254_BINARY);
+
        das1800_ai_setup_dma(dev, s);
        outb(control_c, dev->iobase + DAS1800_CONTROL_C);
        /*  set conversion rate and length for burst mode */
@@ -1171,7 +1141,6 @@ static int das1800_di_rbits(struct comedi_device *dev,
                            struct comedi_subdevice *s,
                            struct comedi_insn *insn, unsigned int *data)
 {
-
        data[1] = inb(dev->iobase + DAS1800_DIGITAL) & 0xf;
        data[0] = 0;
 
@@ -1378,6 +1347,11 @@ static int das1800_attach(struct comedi_device *dev,
        if (!devpriv->fifo_buf)
                return -ENOMEM;
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS1800_COUNTER,
+                                     I8254_OSC_BASE_5MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index b8755b50a11e42d64bb103aa3ea27d0c0e2af79f..3aa6b13894bf3ce89bd6d26d908d869f8a121efa 100644 (file)
@@ -35,8 +35,9 @@
 #include <linux/interrupt.h>
 
 #include "../comedidev.h"
+
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * Register I/O map
@@ -138,11 +139,6 @@ static struct das6402_boardinfo das6402_boards[] = {
 
 struct das6402_private {
        unsigned int irq;
-
-       unsigned int count;
-       unsigned int divider1;
-       unsigned int divider2;
-
        unsigned int ao_range;
 };
 
@@ -172,27 +168,6 @@ static void das6402_ai_clear_eoc(struct comedi_device *dev)
        outb(DAS6402_STATUS_W_CLRINT, dev->iobase + DAS6402_STATUS_REG);
 }
 
-static void das6402_enable_counter(struct comedi_device *dev, bool load)
-{
-       struct das6402_private *devpriv = dev->private;
-       unsigned long timer_iobase = dev->iobase + DAS6402_TIMER_BASE;
-
-       if (load) {
-               i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY);
-               i8254_set_mode(timer_iobase, 0, 1, I8254_MODE2 | I8254_BINARY);
-               i8254_set_mode(timer_iobase, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-               i8254_write(timer_iobase, 0, 0, devpriv->count);
-               i8254_write(timer_iobase, 0, 1, devpriv->divider1);
-               i8254_write(timer_iobase, 0, 2, devpriv->divider2);
-
-       } else {
-               i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY);
-               i8254_set_mode(timer_iobase, 0, 1, I8254_MODE0 | I8254_BINARY);
-               i8254_set_mode(timer_iobase, 0, 2, I8254_MODE0 | I8254_BINARY);
-       }
-}
-
 static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
                                           struct comedi_subdevice *s)
 {
@@ -267,7 +242,8 @@ static int das6402_ai_cmd(struct comedi_device *dev,
        outw(DAS6402_AI_MUX_HI(chan_hi) | DAS6402_AI_MUX_LO(chan_lo),
             dev->iobase + DAS6402_AI_MUX_REG);
 
-       das6402_enable_counter(dev, true);
+       comedi_8254_update_divisors(dev->pacer);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 
        /* enable interrupt and pacer trigger */
        outb(DAS6402_CTRL_INTE |
@@ -322,7 +298,6 @@ static int das6402_ai_cmdtest(struct comedi_device *dev,
                              struct comedi_subdevice *s,
                              struct comedi_cmd *cmd)
 {
-       struct das6402_private *devpriv = dev->private;
        int err = 0;
        unsigned int arg;
 
@@ -364,14 +339,9 @@ static int das6402_ai_cmdtest(struct comedi_device *dev,
 
        /* step 4: fix up any arguments */
 
-       if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->divider1,
-                                         &devpriv->divider2,
-                                         &arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
-       }
+       arg = cmd->convert_arg;
+       comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
        if (err)
                return 4;
@@ -581,8 +551,6 @@ static void das6402_reset(struct comedi_device *dev)
        outw(0, dev->iobase + DAS6402_AO_DATA_REG(0));
        inw(dev->iobase + DAS6402_AO_LSB_REG(0));
 
-       das6402_enable_counter(dev, false);
-
        /* set all digital outputs low */
        outb(0, dev->iobase + DAS6402_DI_DO_REG);
 
@@ -631,6 +599,11 @@ static int das6402_attach(struct comedi_device *dev,
                }
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS6402_TIMER_BASE,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index ff7f4be3f31432c67a50510b883df360b2d06510..ece3e56a72bb605407bc180dd2d7229eb8169c9c 100644 (file)
@@ -43,8 +43,6 @@ Notes:
 
        The cio-das802/16 does not have a fifo-empty status bit!  Therefore
        only fifo-half-full transfers are possible with this card.
-*/
-/*
 
 cmd triggers supported:
        start_src:      TRIG_NOW | TRIG_EXT
@@ -52,18 +50,16 @@ cmd triggers supported:
        scan_end_src:   TRIG_COUNT
        convert_src:    TRIG_TIMER | TRIG_EXT
        stop_src:       TRIG_NONE | TRIG_COUNT
-
-
 */
 
 #include <linux/module.h>
 #include <linux/interrupt.h>
-#include "../comedidev.h"
-
 #include <linux/delay.h>
 
-#include "8253.h"
+#include "../comedidev.h"
+
 #include "comedi_fc.h"
+#include "comedi_8254.h"
 
 #define N_CHAN_AI             8        /*  number of analog input channels */
 
@@ -219,8 +215,6 @@ static const struct das800_board das800_boards[] = {
 };
 
 struct das800_private {
-       unsigned int divisor1;  /* counter 1 value for timed conversions */
-       unsigned int divisor2;  /* counter 2 value for timed conversions */
        unsigned int do_bits;   /* digital output bits */
 };
 
@@ -272,17 +266,6 @@ static void das800_disable(struct comedi_device *dev)
        spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 }
 
-static void das800_set_frequency(struct comedi_device *dev)
-{
-       struct das800_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAS800_8254;
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->divisor2);
-}
-
 static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        das800_disable(dev);
@@ -322,9 +305,7 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev,
                                struct comedi_cmd *cmd)
 {
        const struct das800_board *thisboard = dev->board_ptr;
-       struct das800_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -370,11 +351,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev,
        /* step 4: fix up any arguments */
 
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_1MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -426,8 +405,8 @@ static int das800_ai_do_cmd(struct comedi_device *dev,
                conv_bits |= DTEN;
        if (cmd->convert_src == TRIG_TIMER) {
                conv_bits |= CASC | ITE;
-               /* set conversion frequency */
-               das800_set_frequency(dev);
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
        }
 
        spin_lock_irqsave(&dev->spinlock, irq_flags);
@@ -697,6 +676,11 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                        dev->irq = irq;
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS800_8254,
+                                     I8254_OSC_BASE_1MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 3);
        if (ret)
                return ret;
index 1af006609fc1b70d700eaa18e47e4cb5a428eafc..094422f81d4c9b848350db458b67cc1b8bc55791 100644 (file)
@@ -30,7 +30,7 @@
  * This driver is for the Diamond Systems MM-32-AT board
  *     http://www.diamondsystems.com/products/diamondmm32at
  *
- * It is being used on serveral projects inside NASA, without
+ * It is being used on several projects inside NASA, without
  * problems so far. For analog input commands, TRIG_EXT is not
  * yet supported.
  */
@@ -391,13 +391,12 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                /* start the clock and enable the interrupts */
                dmm32at_setaitimer(dev, cmd->scan_begin_arg);
        } else {
-               /* start the interrups and initiate a single scan */
+               /* start the interrupts and initiate a single scan */
                outb(DMM32AT_INTCLK_ADINT, dev->iobase + DMM32AT_INTCLK_REG);
                outb(0xff, dev->iobase + DMM32AT_AI_START_CONV_REG);
        }
 
        return 0;
-
 }
 
 static int dmm32at_ai_cancel(struct comedi_device *dev,
index b96e60ffad73bcd58d9e3d1bec19d461a160199e..80e38dedd359ec3ac86a768ac402d4aa11d1d639 100644 (file)
@@ -126,7 +126,6 @@ static const struct comedi_lrange range_dt2801_ai_pgl_unipolar = {
 };
 
 struct dt2801_board {
-
        const char *name;
        int boardcode;
        int ad_diff;
@@ -280,7 +279,7 @@ static int dt2801_writedata2(struct comedi_device *dev, unsigned int data)
        ret = dt2801_writedata(dev, data & 0xff);
        if (ret < 0)
                return ret;
-       ret = dt2801_writedata(dev, (data >> 8));
+       ret = dt2801_writedata(dev, data >> 8);
        if (ret < 0)
                return ret;
 
index d660f277487eb94545b51eb64089ecc4d6664ffd..a80773291fdc8bc0e865f42b43ebcc4dfe273aa3 100644 (file)
@@ -194,7 +194,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = {
 #define DT2811_ADMODE   0x03
 
 struct dt2811_board {
-
        const char *name;
        const struct comedi_lrange *bip_5;
        const struct comedi_lrange *bip_2_5;
index 9805be13005a89a1b4d32a9c98f19568a708c521..5a20be569011acbd993a9795f3a9c76c6b498113 100644 (file)
@@ -56,7 +56,6 @@ addition, the clock does not seem to be very accurate.
 #define DT2814_CHANMASK 0x0f
 
 struct dt2814_private {
-
        int ntrig;
        int curadchan;
 };
@@ -193,7 +192,6 @@ static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        outb(chan | DT2814_ENB | (trigvar << 5), dev->iobase + DT2814_CSR);
 
        return 0;
-
 }
 
 static irqreturn_t dt2814_interrupt(int irq, void *d)
index a98fb66fdd53f3b093b3710a9e1eaa9f09185bb8..fb08569c1ac1fd4b582f7b46d7599f8010c95e30 100644 (file)
@@ -60,7 +60,6 @@ Configuration options:
 #define DT2815_STATUS 1
 
 struct dt2815_private {
-
        const struct comedi_lrange *range_type_list[8];
        unsigned int ao_readback[8];
 };
index db21d213585607f50a5acf7a5f7875f078459ec8..52a50bc3343a1255937d2291a380a9111a57c122 100644 (file)
@@ -764,7 +764,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) {
                outw(devpriv->supcsr | DT2821_SUPCSR_STRIG,
-                       dev->iobase + DT2821_SUPCSR_REG);
+                    dev->iobase + DT2821_SUPCSR_REG);
        } else {
                devpriv->supcsr |= DT2821_SUPCSR_XTRIG;
                outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR_REG);
@@ -874,7 +874,6 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
                return 4;
 
        return 0;
-
 }
 
 static int dt282x_ao_inttrig(struct comedi_device *dev,
index 0aa51980e32778e267eaf2d2c440c55465ac91f8..1b8ac9999477aeaa14ed4be0fcdee8010687ce4f 100644 (file)
@@ -49,11 +49,10 @@ AO commands are not supported.
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 
index 6c1e442f6c81c71ec6a4885ed0fc34c0d1d9bf2e..c9eb26fab44e7d02951287d9d48f3d3f74e0f5d5 100644 (file)
 
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/pci.h>
 #include <linux/mutex.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #define READ_TIMEOUT 50
 
@@ -70,8 +69,9 @@ static int dyna_pci10xx_ai_eoc(struct comedi_device *dev,
 }
 
 static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
-                       struct comedi_subdevice *s,
-                       struct comedi_insn *insn, unsigned int *data)
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
 {
        struct dyna_pci10xx_private *devpriv = dev->private;
        int n;
@@ -109,8 +109,9 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
 
 /* analog output callback */
 static int dyna_pci10xx_insn_write_ao(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn, unsigned int *data)
+                                     struct comedi_subdevice *s,
+                                     struct comedi_insn *insn,
+                                     unsigned int *data)
 {
        struct dyna_pci10xx_private *devpriv = dev->private;
        int n;
@@ -132,8 +133,9 @@ static int dyna_pci10xx_insn_write_ao(struct comedi_device *dev,
 
 /* digital input bit interface */
 static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
-                             struct comedi_subdevice *s,
-                             struct comedi_insn *insn, unsigned int *data)
+                                    struct comedi_subdevice *s,
+                                    struct comedi_insn *insn,
+                                    unsigned int *data)
 {
        struct dyna_pci10xx_private *devpriv = dev->private;
        u16 d = 0;
@@ -171,7 +173,7 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
 }
 
 static int dyna_pci10xx_auto_attach(struct comedi_device *dev,
-                                             unsigned long context_unused)
+                                   unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct dyna_pci10xx_private *devpriv;
index deada9784b693bdef49dc36a631470c8172c34e3..8b7c475903ecee2c5bb1f1f5907be8869dc6ba88 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "plx9080.h"
 #include "comedi_fc.h"
@@ -433,7 +432,6 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
                return 5;
 
        return 0;
-
 }
 
 /* setup dma descriptors so a link completes every 'len' bytes */
index 1ea1686201031eace09cf9c395ee05071d99d44c..1e104ebf80576e472f3792666c8756a54fa1e32c 100644 (file)
@@ -43,11 +43,10 @@ Configuration options: not applicable, uses PCI auto config
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #define ICP_MULTI_ADC_CSR      0       /* R/W: ADC command/status register */
 #define ICP_MULTI_AI           2       /* R:   Analogue input data */
@@ -370,7 +369,6 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
                break;
        default:
                break;
-
        }
 
        return IRQ_HANDLED;
@@ -445,7 +443,7 @@ static int icp_multi_reset(struct comedi_device *dev)
 }
 
 static int icp_multi_auto_attach(struct comedi_device *dev,
-                                          unsigned long context_unused)
+                                unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct icp_multi_private *devpriv;
index 81fab2dfafa43b3b277ff22945d7623115d92fb4..b87192e0f9aa8ba93217aef26fb16b031cc1e469 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/ctype.h>
 #include <linux/jiffies.h>
 #include <linux/slab.h>
 #include <linux/timer.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "jr3_pci.h"
 
@@ -706,8 +705,6 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
        if (!devpriv)
                return -ENOMEM;
 
-       init_timer(&devpriv->timer);
-
        ret = comedi_pci_enable(dev);
        if (ret)
                return ret;
@@ -775,8 +772,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
                spriv->next_time_max = jiffies + msecs_to_jiffies(2000);
        }
 
-       devpriv->timer.data = (unsigned long)dev;
-       devpriv->timer.function = jr3_pci_poll_dev;
+       setup_timer(&devpriv->timer, jr3_pci_poll_dev, (unsigned long)dev);
        devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
        add_timer(&devpriv->timer);
 
index 3c19e0f178ca28a207897706f19b5f7e92d844db..dc642edf4f655c7ae7eeee6473c937445dcda901 100644 (file)
@@ -28,9 +28,8 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI BAR 0 Register I/O map
index d120aa244cf9a303f8804015d481a8eaeff97de1..2502ac67bd4e9d070d2c486ff615e8c792db017f 100644 (file)
@@ -41,14 +41,13 @@ broken.
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "plx9052.h"
 
 #define ME4000_FIRMWARE                "me4000_firmware.bin"
@@ -170,7 +169,6 @@ broken.
 
 struct me4000_info {
        unsigned long plx_regbase;
-       unsigned long timer_regbase;
 };
 
 enum me4000_boardid {
@@ -424,7 +422,7 @@ static void me4000_reset(struct comedi_device *dev)
 
        /* Set both stop bits in the analog input control register */
        outl(ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
-               dev->iobase + ME4000_AI_CTRL_REG);
+            dev->iobase + ME4000_AI_CTRL_REG);
 
        /* Set both stop bits in the analog output control register */
        val = ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP;
@@ -438,7 +436,7 @@ static void me4000_reset(struct comedi_device *dev)
 
        /* Set the adustment register for AO demux */
        outl(ME4000_AO_DEMUX_ADJUST_VALUE,
-                   dev->iobase + ME4000_AO_DEMUX_ADJUST_REG);
+            dev->iobase + ME4000_AO_DEMUX_ADJUST_REG);
 
        /*
         * Set digital I/O direction for port 0
@@ -609,7 +607,7 @@ static int me4000_ai_check_chanlist(struct comedi_device *dev,
 
                        if (!comedi_range_is_bipolar(s, range)) {
                                dev_dbg(dev->class_dev,
-                                      "Bipolar is not selected in differential mode\n");
+                                       "Bipolar is not selected in differential mode\n");
                                return -EINVAL;
                        }
                }
@@ -624,7 +622,6 @@ static int ai_round_cmd_args(struct comedi_device *dev,
                             unsigned int *init_ticks,
                             unsigned int *scan_ticks, unsigned int *chan_ticks)
 {
-
        int rest;
 
        *init_ticks = 0;
@@ -731,7 +728,6 @@ static int ai_prepare(struct comedi_device *dev,
                      unsigned int init_ticks,
                      unsigned int scan_ticks, unsigned int chan_ticks)
 {
-
        unsigned int tmp = 0;
 
        /* Write timer arguments */
@@ -772,12 +768,12 @@ static int ai_prepare(struct comedi_device *dev,
        /* Stop triggers */
        if (cmd->stop_src == TRIG_COUNT) {
                outl(cmd->chanlist_len * cmd->stop_arg,
-                           dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
+                    dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
                tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
        } else if (cmd->stop_src == TRIG_NONE &&
                   cmd->scan_end_src == TRIG_COUNT) {
                outl(cmd->scan_end_arg,
-                           dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
+                    dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
                tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
        } else {
                tmp |= ME4000_AI_CTRL_BIT_HF_IRQ;
@@ -827,7 +823,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
                                 struct comedi_cmd *cmd)
 {
-
        unsigned int init_ticks;
        unsigned int chan_ticks;
        unsigned int scan_ticks;
@@ -919,7 +914,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        if (cmd->start_src == TRIG_NOW &&
            cmd->scan_begin_src == TRIG_TIMER &&
            cmd->convert_src == TRIG_TIMER) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -941,7 +935,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        } else if (cmd->start_src == TRIG_NOW &&
                   cmd->scan_begin_src == TRIG_FOLLOW &&
                   cmd->convert_src == TRIG_TIMER) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -956,7 +949,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        } else if (cmd->start_src == TRIG_EXT &&
                   cmd->scan_begin_src == TRIG_TIMER &&
                   cmd->convert_src == TRIG_TIMER) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -978,7 +970,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        } else if (cmd->start_src == TRIG_EXT &&
                   cmd->scan_begin_src == TRIG_FOLLOW &&
                   cmd->convert_src == TRIG_TIMER) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -993,7 +984,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        } else if (cmd->start_src == TRIG_EXT &&
                   cmd->scan_begin_src == TRIG_EXT &&
                   cmd->convert_src == TRIG_TIMER) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -1008,7 +998,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        } else if (cmd->start_src == TRIG_EXT &&
                   cmd->scan_begin_src == TRIG_EXT &&
                   cmd->convert_src == TRIG_EXT) {
-
                /* Check timer arguments */
                if (init_ticks < ME4000_AI_MIN_TICKS) {
                        dev_err(dev->class_dev, "Invalid start arg\n");
@@ -1187,13 +1176,13 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
 {
        if (comedi_dio_update_state(s, data)) {
                outl((s->state >> 0) & 0xFF,
-                           dev->iobase + ME4000_DIO_PORT_0_REG);
+                    dev->iobase + ME4000_DIO_PORT_0_REG);
                outl((s->state >> 8) & 0xFF,
-                           dev->iobase + ME4000_DIO_PORT_1_REG);
+                    dev->iobase + ME4000_DIO_PORT_1_REG);
                outl((s->state >> 16) & 0xFF,
-                           dev->iobase + ME4000_DIO_PORT_2_REG);
+                    dev->iobase + ME4000_DIO_PORT_2_REG);
                outl((s->state >> 24) & 0xFF,
-                           dev->iobase + ME4000_DIO_PORT_3_REG);
+                    dev->iobase + ME4000_DIO_PORT_3_REG);
        }
 
        data[1] = ((inl(dev->iobase + ME4000_DIO_PORT_0_REG) & 0xFF) << 0) |
@@ -1259,85 +1248,6 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-/*=============================================================================
-  Counter section
-  ===========================================================================*/
-
-static int me4000_cnt_insn_config(struct comedi_device *dev,
-                                 struct comedi_subdevice *s,
-                                 struct comedi_insn *insn,
-                                 unsigned int *data)
-{
-       struct me4000_info *info = dev->private;
-       unsigned int chan = CR_CHAN(insn->chanspec);
-       int err;
-
-       switch (data[0]) {
-       case GPCT_RESET:
-               if (insn->n != 1)
-                       return -EINVAL;
-
-               err = i8254_set_mode(info->timer_regbase, 0, chan,
-                                    I8254_MODE0 | I8254_BINARY);
-               if (err)
-                       return err;
-               i8254_write(info->timer_regbase, 0, chan, 0);
-               break;
-       case GPCT_SET_OPERATION:
-               if (insn->n != 2)
-                       return -EINVAL;
-
-               err = i8254_set_mode(info->timer_regbase, 0, chan,
-                               (data[1] << 1) | I8254_BINARY);
-               if (err)
-                       return err;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return insn->n;
-}
-
-static int me4000_cnt_insn_read(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
-{
-       struct me4000_info *info = dev->private;
-
-       if (insn->n == 0)
-               return 0;
-
-       if (insn->n > 1) {
-               dev_err(dev->class_dev, "Invalid instruction length %d\n",
-                       insn->n);
-               return -EINVAL;
-       }
-
-       data[0] = i8254_read(info->timer_regbase, 0, insn->chanspec);
-
-       return 1;
-}
-
-static int me4000_cnt_insn_write(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn, unsigned int *data)
-{
-       struct me4000_info *info = dev->private;
-
-       if (insn->n == 0) {
-               return 0;
-       } else if (insn->n > 1) {
-               dev_err(dev->class_dev, "Invalid instruction length %d\n",
-                       insn->n);
-               return -EINVAL;
-       }
-
-       i8254_write(info->timer_regbase, 0, insn->chanspec, data[0]);
-
-       return 1;
-}
-
 static int me4000_auto_attach(struct comedi_device *dev,
                              unsigned long context)
 {
@@ -1364,8 +1274,7 @@ static int me4000_auto_attach(struct comedi_device *dev,
 
        info->plx_regbase = pci_resource_start(pcidev, 1);
        dev->iobase = pci_resource_start(pcidev, 2);
-       info->timer_regbase = pci_resource_start(pcidev, 3);
-       if (!info->plx_regbase || !dev->iobase || !info->timer_regbase)
+       if (!info->plx_regbase || !dev->iobase)
                return -ENODEV;
 
        result = comedi_load_firmware(dev, &pcidev->dev, ME4000_FIRMWARE,
@@ -1377,7 +1286,7 @@ static int me4000_auto_attach(struct comedi_device *dev,
 
        if (pcidev->irq > 0) {
                result = request_irq(pcidev->irq, me4000_ai_isr, IRQF_SHARED,
-                                 dev->board_name, dev);
+                                    dev->board_name, dev);
                if (result == 0)
                        dev->irq = pcidev->irq;
        }
@@ -1459,23 +1368,22 @@ static int me4000_auto_attach(struct comedi_device *dev,
        if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) {
                s->io_bits |= 0xFF;
                outl(ME4000_DIO_CTRL_BIT_MODE_0,
-                       dev->iobase + ME4000_DIO_DIR_REG);
+                    dev->iobase + ME4000_DIO_DIR_REG);
        }
 
-    /*=========================================================================
-      Counter subdevice
-      ========================================================================*/
-
+       /* Counter subdevice (8254) */
        s = &dev->subdevices[3];
-
        if (thisboard->has_counter) {
-               s->type = COMEDI_SUBD_COUNTER;
-               s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-               s->n_chan = 3;
-               s->maxdata = 0xFFFF;    /*  16 bit counters */
-               s->insn_read = me4000_cnt_insn_read;
-               s->insn_write = me4000_cnt_insn_write;
-               s->insn_config = me4000_cnt_insn_config;
+               unsigned long timer_base = pci_resource_start(pcidev, 3);
+
+               if (!timer_base)
+                       return -ENODEV;
+
+               dev->pacer = comedi_8254_init(timer_base, 0, I8254_IO8, 0);
+               if (!dev->pacer)
+                       return -ENOMEM;
+
+               comedi_8254_subdevice_init(s, dev->pacer);
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }
index 92e23527f2cb3c09703197450a2a399f6eff867e..d78e9195fbce305bbd272240371edec79edf4cd3 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "plx9052.h"
 
index db972bce2b5b1f6724022741d4a3b6bd7f526228..a675e2ef9b4553e4ba950a06d22f0d61040002a6 100644 (file)
@@ -26,9 +26,9 @@
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
-#include "../comedidev.h"
+
+#include "../comedi_pci.h"
 
 /* Registers present in BAR0 memory region */
 #define MF624_GPIOC_R                                  0x54
@@ -237,7 +237,6 @@ static int mf6x4_auto_attach(struct comedi_device *dev, unsigned long context)
        else
                devpriv->gpioc_R = devpriv->bar0_mem + MF624_GPIOC_R;
 
-
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index 1e537a5cf86286eeb646836f471968caaa2213fb..4cfe949e4dc58ed431a703eb1432a6704c931298 100644 (file)
@@ -47,9 +47,8 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "mite.h"
@@ -186,10 +185,10 @@ struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite)
        struct mite_dma_descriptor_ring *ring =
            kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
 
-       if (ring == NULL)
-               return ring;
+       if (!ring)
+               return NULL;
        ring->hw_dev = get_device(&mite->pcidev->dev);
-       if (ring->hw_dev == NULL) {
+       if (!ring->hw_dev) {
                kfree(ring);
                return NULL;
        }
index b2b12045b3a5f0054efcd1850db6f16f1d90c01a..b3ca7fc3a31e7de83a261c189093711531b99575 100644 (file)
 #ifndef _MITE_H_
 #define _MITE_H_
 
-#include <linux/pci.h>
 #include <linux/log2.h>
 #include <linux/slab.h>
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #define PCIMIO_COMPAT
 
index 1241f9987cab2c01715da3b1d1297648dc8860f7..0207b8edfcb4534f8742ba840de1bd196c950c30 100644 (file)
@@ -115,7 +115,6 @@ Configuration Options:
        (MPC624_OSR4 | MPC624_OSR3 | MPC624_OSR2 | MPC624_OSR1 | MPC624_OSR0)
 /* -------------------------------------------------------------------------- */
 struct mpc624_private {
-
        /*  set by mpc624_attach() from driver's parameters */
        unsigned long int ulConvertionRate;
 };
index 530f716f65863a962a6c284bd6e095aa35dcf3a9..dc87114727a2ca91dde53cb070cb4a497ba2ab6b 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 
index 67cb758eb0cd9293e41abbcd7d91e50daafa0b75..b158bfb292bfc004238ad4ab8cf9f5390b1c41ec 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 
@@ -613,7 +612,7 @@ static int ni_65xx_intr_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+/* ripped from mite.h and mite_setup2() to avoid mite dependency */
 #define MITE_IODWBSR   0xc0     /* IO Device Window Base Size Register */
 #define WENAB          (1 << 7) /* window enable */
 
@@ -676,7 +675,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev,
        }
 
        dev_info(dev->class_dev, "board: %s, ID=0x%02x", dev->board_name,
-              readb(dev->mmio + NI_65XX_ID_REG));
+                readb(dev->mmio + NI_65XX_ID_REG));
 
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
index 1e4dd82b12ea7d082d1d595d71ac6e96347443ec..b913158e5706b29e356f9344221458c41702d3a9 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "mite.h"
@@ -195,7 +194,6 @@ static inline unsigned NI_660X_GPCT_SUBDEV(unsigned index)
 }
 
 struct NI_660xRegisterData {
-
        const char *name;       /*  Register Name */
        int offset;             /*  Offset from base address from GPCT chip */
        enum ni_660x_register_direction direction;
@@ -702,7 +700,7 @@ static int ni_660x_request_mite_channel(struct comedi_device *dev,
        BUG_ON(counter->mite_chan);
        mite_chan = mite_request_channel(devpriv->mite,
                                         mite_ring(devpriv, counter));
-       if (mite_chan == NULL) {
+       if (!mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev,
                        "failed to reserve mite dma channel for counter\n");
@@ -861,7 +859,7 @@ static int ni_660x_alloc_mite_rings(struct comedi_device *dev)
                for (j = 0; j < counters_per_chip; ++j) {
                        devpriv->mite_rings[i][j] =
                            mite_alloc_ring(devpriv->mite);
-                       if (devpriv->mite_rings[i][j] == NULL)
+                       if (!devpriv->mite_rings[i][j])
                                return -ENOMEM;
                }
        }
@@ -1107,7 +1105,7 @@ static int ni_660x_auto_attach(struct comedi_device *dev,
                                                     ni_gpct_variant_660x,
                                                     ni_660x_num_counters
                                                     (dev));
-       if (devpriv->counter_dev == NULL)
+       if (!devpriv->counter_dev)
                return -ENOMEM;
        for (i = 0; i < NI_660X_MAX_NUM_COUNTERS; ++i) {
                s = &dev->subdevices[NI_660X_GPCT_SUBDEV(i)];
index c42a81c0bfa1cd3fd9f444ac7b405cc5869213c3..13c6ccb1fdea4abcc4f4c6c05005b784edf31734 100644 (file)
@@ -37,11 +37,10 @@ Commands are not supported.
 */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #define AO_VALUE_OFFSET                        0x00
 #define        AO_CHAN_OFFSET                  0x0c
@@ -146,7 +145,7 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev,
        return insn->n;
 }
 
-/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+/* ripped from mite.h and mite_setup2() to avoid mite dependency */
 #define MITE_IODWBSR   0xc0     /* IO Device Window Base Size Register */
 #define WENAB          (1 << 7) /* window enable */
 
index a1ce0b0b8c41c340180990ca022b2442e3b07144..66c0e65a953a98e183bf998c6a9fab0523a22af4 100644 (file)
@@ -68,7 +68,7 @@ TRIG_WAKE_EOS
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 #define A2150_DMA_BUFFER_SIZE  0xff00  /*  size in bytes of dma buffer */
 
@@ -110,8 +110,6 @@ TRIG_WAKE_EOS
 #define   DMA_INTR_EN_BIT              0x800   /*  enable interrupt on dma terminal count */
 #define   DMA_DEM_EN_BIT       0x1000  /*  enables demand mode dma */
 #define I8253_BASE_REG         0x14
-#define I8253_MODE_REG         0x17
-#define   HW_COUNT_DISABLE             0x30    /*  disable hardware counting of conversions */
 
 struct a2150_board {
        const char *name;
@@ -488,7 +486,6 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        struct comedi_isadma_desc *desc = &dma->desc[0];
        struct comedi_async *async = s->async;
        struct comedi_cmd *cmd = &async->cmd;
-       unsigned long timer_base = dev->iobase + I8253_BASE_REG;
        unsigned int old_config_bits = devpriv->config_bits;
        unsigned int trigger_bits;
 
@@ -547,8 +544,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
 
        /*  may need to wait 72 sampling periods if timing was changed */
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);
-       i8254_write(timer_base, 0, 2, 72);
+       comedi_8254_load(dev->pacer, 2, 72, I8254_MODE0 | I8254_BINARY);
 
        /*  setup start triggering */
        trigger_bits = 0;
@@ -726,6 +722,11 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        /* an IRQ and DMA are required to support async commands */
        a2150_alloc_irq_and_dma(dev, it);
 
+       dev->pacer = comedi_8254_init(dev->iobase + I8253_BASE_REG,
+                                     0, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 1);
        if (ret)
                return ret;
@@ -747,10 +748,6 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                s->cancel = a2150_cancel;
        }
 
-       /* need to do this for software counting of completed conversions, to
-        * prevent hardware count from stopping acquisition */
-       outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG);
-
        /*  set card's irq and dma levels */
        outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
 
index 9eeaf3c5a85828b34195488087d98a868b4b8d7f..f27aa0e822346e2e486cdac34905540a1fedb0af 100644 (file)
@@ -37,7 +37,7 @@
 
 #include "../comedidev.h"
 
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * Register map
@@ -274,7 +274,6 @@ static int atao_calib_insn_write(struct comedi_device *dev,
 static void atao_reset(struct comedi_device *dev)
 {
        struct atao_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + ATAO_82C53_BASE;
 
        /* This is the reset sequence described in the manual */
 
@@ -282,9 +281,9 @@ static void atao_reset(struct comedi_device *dev)
        outw(devpriv->cfg1, dev->iobase + ATAO_CFG1_REG);
 
        /* Put outputs of counter 1 and counter 2 in a high state */
-       i8254_set_mode(timer_base, 0, 0, I8254_MODE4 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE4 | I8254_BINARY);
-       i8254_write(timer_base, 0, 0, 0x0003);
+       comedi_8254_set_mode(dev->pacer, 0, I8254_MODE4 | I8254_BINARY);
+       comedi_8254_set_mode(dev->pacer, 1, I8254_MODE4 | I8254_BINARY);
+       comedi_8254_write(dev->pacer, 0, 0x0003);
 
        outw(ATAO_CFG2_CALLD_NOP, dev->iobase + ATAO_CFG2_REG);
 
@@ -315,6 +314,11 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (!devpriv)
                return -ENOMEM;
 
+       dev->pacer = comedi_8254_init(dev->iobase + ATAO_82C53_BASE,
+                                     0, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index 301f154be8138a9cf6c23a8c182c3ed791922e0b..1304b06980a6ad55c626a32cbe8d02869ab88a99 100644 (file)
@@ -250,7 +250,7 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
                                          ISAPNP_FUNCTION(ni_boards[i].
                                                          isapnp_id), NULL);
 
-               if (isapnp_dev == NULL || isapnp_dev->card == NULL)
+               if (!isapnp_dev || !isapnp_dev->card)
                        continue;
 
                if (pnp_device_attach(isapnp_dev) < 0)
@@ -282,7 +282,6 @@ static int ni_getboardtype(struct comedi_device *dev)
        for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
                if (ni_boards[i].device_id == device_id)
                        return i;
-
        }
        if (device_id == 255)
                dev_err(dev->class_dev, "can't find board\n");
@@ -355,7 +354,6 @@ static int ni_atmio_attach(struct comedi_device *dev,
        if (ret < 0)
                return ret;
 
-
        return 0;
 }
 
index c484c89c94b53631252bc7c0d28fdce2986c3892..73e58024379572d2522da4be418dbf4576230f4c 100644 (file)
@@ -96,7 +96,6 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d)
 #define CLOCK_100_HZ   0x8F25
 
 struct atmio16_board_t {
-
        const char *name;
        int has_8255;
 };
index a916047791b86bc733d4b1d275476c52220e918a..51e5e942b442975daf4abcb33956289672207a47 100644 (file)
@@ -105,6 +105,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static void labpc_detach(struct comedi_device *dev)
 {
        labpc_free_dma_chan(dev);
+       labpc_common_detach(dev);
        comedi_legacy_detach(dev);
 }
 
index be89ae479afcd265ec7b4990a1b8312448320343..83f878adbd5365e17dad60f686a3bfed7b13e596 100644 (file)
@@ -36,6 +36,7 @@ struct labpc_boardinfo {
 
 struct labpc_private {
        struct comedi_isadma *dma;
+       struct comedi_8254 *counter;
 
        /*  number of data points left to be taken */
        unsigned long long count;
@@ -49,20 +50,6 @@ struct labpc_private {
        /*  store last read of board status registers */
        unsigned int stat1;
        unsigned int stat2;
-       /*
-        * value to load into board's counter a0 (conversion pacing) for timed
-        * conversions
-        */
-       unsigned int divisor_a0;
-       /*
-        * value to load into board's counter b0 (master) for timed conversions
-        */
-       unsigned int divisor_b0;
-       /*
-        * value to load into board's counter b1 (scan pacing) for timed
-        * conversions
-        */
-       unsigned int divisor_b1;
 
        /* we are using dma/fifo-half-full/etc. */
        enum transfer_type current_transfer;
@@ -77,5 +64,6 @@ struct labpc_private {
 
 int labpc_common_attach(struct comedi_device *dev,
                        unsigned int irq, unsigned long isr_flags);
+void labpc_common_detach(struct comedi_device *dev);
 
 #endif /* _NI_LABPC_H */
index b88ee2614bfe5df7f7e5fff2a1cd3a5fea364a63..0dac8cf312b239052ae76096fa2923d004199fb4 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include "../comedidev.h"
 
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"
 #include "comedi_fc.h"
 #include "ni_labpc.h"
@@ -108,32 +109,6 @@ static void labpc_writeb(struct comedi_device *dev,
        writeb(byte, dev->mmio + reg);
 }
 
-static void labpc_counter_load(struct comedi_device *dev,
-                              unsigned long reg,
-                              unsigned int counter_number,
-                              unsigned int count,
-                              unsigned int mode)
-{
-       if (dev->mmio) {
-               i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
-               i8254_mm_write(dev->mmio + reg, 0, counter_number, count);
-       } else {
-               i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
-               i8254_write(dev->iobase + reg, 0, counter_number, count);
-       }
-}
-
-static void labpc_counter_set_mode(struct comedi_device *dev,
-                                  unsigned long reg,
-                                  unsigned int counter_number,
-                                  unsigned int mode)
-{
-       if (dev->mmio)
-               i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
-       else
-               i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
-}
-
 static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct labpc_private *devpriv = dev->private;
@@ -284,7 +259,7 @@ static int labpc_ai_insn_read(struct comedi_device *dev,
        devpriv->write_byte(dev, devpriv->cmd4, CMD4_REG);
 
        /* initialize pacer counter to prevent any problems */
-       labpc_counter_set_mode(dev, COUNTER_A_BASE_REG, 0, I8254_MODE2);
+       comedi_8254_set_mode(devpriv->counter, 0, I8254_MODE2 | I8254_BINARY);
 
        labpc_clear_adc_fifo(dev);
 
@@ -367,83 +342,79 @@ static void labpc_set_ai_scan_period(struct comedi_cmd *cmd,
 static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd,
                             enum scan_mode mode)
 {
-       struct labpc_private *devpriv = dev->private;
+       struct comedi_8254 *pacer = dev->pacer;
+       unsigned int convert_period = labpc_ai_convert_period(cmd, mode);
+       unsigned int scan_period = labpc_ai_scan_period(cmd, mode);
        unsigned int base_period;
-       unsigned int scan_period;
-       unsigned int convert_period;
 
        /*
-        * if both convert and scan triggers are TRIG_TIMER, then they
-        * both rely on counter b0
+        * If both convert and scan triggers are TRIG_TIMER, then they
+        * both rely on counter b0. If only one TRIG_TIMER is used, we
+        * can use the generic cascaded timing functions.
         */
-       convert_period = labpc_ai_convert_period(cmd, mode);
-       scan_period = labpc_ai_scan_period(cmd, mode);
        if (convert_period && scan_period) {
                /*
-                * pick the lowest b0 divisor value we can (for maximum input
+                * pick the lowest divisor value we can (for maximum input
                 * clock speed on convert and scan counters)
                 */
-               devpriv->divisor_b0 = (scan_period - 1) /
-                   (I8254_OSC_BASE_2MHZ * 0x10000) + 1;
+               pacer->next_div1 = (scan_period - 1) /
+                                  (pacer->osc_base * I8254_MAX_COUNT) + 1;
 
-               cfc_check_trigger_arg_min(&devpriv->divisor_b0, 2);
-               cfc_check_trigger_arg_max(&devpriv->divisor_b0, 0x10000);
+               cfc_check_trigger_arg_min(&pacer->next_div1, 2);
+               cfc_check_trigger_arg_max(&pacer->next_div1, I8254_MAX_COUNT);
 
-               base_period = I8254_OSC_BASE_2MHZ * devpriv->divisor_b0;
+               base_period = pacer->osc_base * pacer->next_div1;
 
                /*  set a0 for conversion frequency and b1 for scan frequency */
                switch (cmd->flags & CMDF_ROUND_MASK) {
                default:
                case CMDF_ROUND_NEAREST:
-                       devpriv->divisor_a0 = DIV_ROUND_CLOSEST(convert_period,
-                                                               base_period);
-                       devpriv->divisor_b1 = DIV_ROUND_CLOSEST(scan_period,
-                                                               base_period);
+                       pacer->next_div = DIV_ROUND_CLOSEST(convert_period,
+                                                           base_period);
+                       pacer->next_div2 = DIV_ROUND_CLOSEST(scan_period,
+                                                            base_period);
                        break;
                case CMDF_ROUND_UP:
-                       devpriv->divisor_a0 = DIV_ROUND_UP(convert_period,
-                                                          base_period);
-                       devpriv->divisor_b1 = DIV_ROUND_UP(scan_period,
-                                                          base_period);
+                       pacer->next_div = DIV_ROUND_UP(convert_period,
+                                                      base_period);
+                       pacer->next_div2 = DIV_ROUND_UP(scan_period,
+                                                       base_period);
                        break;
                case CMDF_ROUND_DOWN:
-                       devpriv->divisor_a0 = convert_period / base_period;
-                       devpriv->divisor_b1 = scan_period / base_period;
+                       pacer->next_div = convert_period / base_period;
+                       pacer->next_div2 = scan_period / base_period;
                        break;
                }
                /*  make sure a0 and b1 values are acceptable */
-               cfc_check_trigger_arg_min(&devpriv->divisor_a0, 2);
-               cfc_check_trigger_arg_max(&devpriv->divisor_a0, 0x10000);
-               cfc_check_trigger_arg_min(&devpriv->divisor_b1, 2);
-               cfc_check_trigger_arg_max(&devpriv->divisor_b1, 0x10000);
+               cfc_check_trigger_arg_min(&pacer->next_div, 2);
+               cfc_check_trigger_arg_max(&pacer->next_div, I8254_MAX_COUNT);
+               cfc_check_trigger_arg_min(&pacer->next_div2, 2);
+               cfc_check_trigger_arg_max(&pacer->next_div2, I8254_MAX_COUNT);
+
                /*  write corrected timings to command */
                labpc_set_ai_convert_period(cmd, mode,
-                                           base_period * devpriv->divisor_a0);
+                                           base_period * pacer->next_div);
                labpc_set_ai_scan_period(cmd, mode,
-                                        base_period * devpriv->divisor_b1);
-               /*
-                * if only one TRIG_TIMER is used, we can employ the generic
-                * cascaded timing functions
-                */
+                                        base_period * pacer->next_div2);
        } else if (scan_period) {
                /*
                 * calculate cascaded counter values
                 * that give desired scan timing
+                * (pacer->next_div2 / pacer->next_div1)
                 */
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
-                                         &devpriv->divisor_b1,
-                                         &devpriv->divisor_b0,
-                                         &scan_period, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(pacer, &scan_period,
+                                               cmd->flags);
                labpc_set_ai_scan_period(cmd, mode, scan_period);
        } else if (convert_period) {
                /*
                 * calculate cascaded counter values
                 * that give desired conversion timing
+                * (pacer->next_div / pacer->next_div1)
                 */
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
-                                         &devpriv->divisor_a0,
-                                         &devpriv->divisor_b0,
-                                         &convert_period, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(pacer, &convert_period,
+                                               cmd->flags);
+               /* transfer div2 value so correct timer gets updated */
+               pacer->next_div = pacer->next_div2;
                labpc_set_ai_convert_period(cmd, mode, convert_period);
        }
 }
@@ -457,7 +428,7 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
                return MODE_SINGLE_CHAN;
 
        /* chanlist may be NULL during cmdtest */
-       if (cmd->chanlist == NULL)
+       if (!cmd->chanlist)
                return MODE_MULT_CHAN_UP;
 
        chan0 = CR_CHAN(cmd->chanlist[0]);
@@ -482,9 +453,6 @@ static int labpc_ai_check_chanlist(struct comedi_device *dev,
        unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
        int i;
 
-       if (mode == MODE_SINGLE_CHAN)
-               return 0;
-
        for (i = 0; i < cmd->chanlist_len; i++) {
                unsigned int chan = CR_CHAN(cmd->chanlist[i]);
                unsigned int range = CR_RANGE(cmd->chanlist[i]);
@@ -670,11 +638,12 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                 * load counter a1 with count of 3
                 * (pc+ manual says this is minimum allowed) using mode 0
                 */
-               labpc_counter_load(dev, COUNTER_A_BASE_REG,
-                                  1, 3, I8254_MODE0);
+               comedi_8254_load(devpriv->counter, 1,
+                                3, I8254_MODE0 | I8254_BINARY);
        } else  {
                /* just put counter a1 in mode 0 to set its output low */
-               labpc_counter_set_mode(dev, COUNTER_A_BASE_REG, 1, I8254_MODE0);
+               comedi_8254_set_mode(devpriv->counter, 1,
+                                    I8254_MODE0 | I8254_BINARY);
        }
 
        /* figure out what method we will use to transfer data */
@@ -715,27 +684,24 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
        if (cmd->convert_src == TRIG_TIMER ||
            cmd->scan_begin_src == TRIG_TIMER) {
-               /*  set up pacing */
-               labpc_adc_timing(dev, cmd, mode);
-               /*  load counter b0 in mode 3 */
-               labpc_counter_load(dev, COUNTER_B_BASE_REG,
-                                  0, devpriv->divisor_b0, I8254_MODE3);
-       }
-       /*  set up conversion pacing */
-       if (labpc_ai_convert_period(cmd, mode)) {
-               /*  load counter a0 in mode 2 */
-               labpc_counter_load(dev, COUNTER_A_BASE_REG,
-                                  0, devpriv->divisor_a0, I8254_MODE2);
-       } else {
-               /* initialize pacer counter to prevent any problems */
-               labpc_counter_set_mode(dev, COUNTER_A_BASE_REG, 0, I8254_MODE2);
-       }
+               struct comedi_8254 *pacer = dev->pacer;
+               struct comedi_8254 *counter = devpriv->counter;
+
+               comedi_8254_update_divisors(pacer);
 
-       /*  set up scan pacing */
-       if (labpc_ai_scan_period(cmd, mode)) {
-               /*  load counter b1 in mode 2 */
-               labpc_counter_load(dev, COUNTER_B_BASE_REG,
-                                  1, devpriv->divisor_b1, I8254_MODE2);
+               /* set up pacing */
+               comedi_8254_load(pacer, 0, pacer->divisor1,
+                                I8254_MODE3 | I8254_BINARY);
+
+               /* set up conversion pacing */
+               comedi_8254_set_mode(counter, 0, I8254_MODE2 | I8254_BINARY);
+               if (labpc_ai_convert_period(cmd, mode))
+                       comedi_8254_write(counter, 0, pacer->divisor);
+
+               /* set up scan pacing */
+               if (labpc_ai_scan_period(cmd, mode))
+                       comedi_8254_load(pacer, 1, pacer->divisor2,
+                                        I8254_MODE2 | I8254_BINARY);
        }
 
        labpc_clear_adc_fifo(dev);
@@ -1240,6 +1206,26 @@ int labpc_common_attach(struct comedi_device *dev,
                        dev->irq = irq;
        }
 
+       if (dev->mmio) {
+               dev->pacer = comedi_8254_mm_init(dev->mmio + COUNTER_B_BASE_REG,
+                                                I8254_OSC_BASE_2MHZ,
+                                                I8254_IO8, 0);
+               devpriv->counter = comedi_8254_mm_init(dev->mmio +
+                                                      COUNTER_A_BASE_REG,
+                                                      I8254_OSC_BASE_2MHZ,
+                                                      I8254_IO8, 0);
+       } else {
+               dev->pacer = comedi_8254_init(dev->iobase + COUNTER_B_BASE_REG,
+                                             I8254_OSC_BASE_2MHZ,
+                                             I8254_IO8, 0);
+               devpriv->counter = comedi_8254_init(dev->iobase +
+                                                   COUNTER_A_BASE_REG,
+                                                   I8254_OSC_BASE_2MHZ,
+                                                   I8254_IO8, 0);
+       }
+       if (!dev->pacer || !devpriv->counter)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 5);
        if (ret)
                return ret;
@@ -1336,6 +1322,15 @@ int labpc_common_attach(struct comedi_device *dev,
 }
 EXPORT_SYMBOL_GPL(labpc_common_attach);
 
+void labpc_common_detach(struct comedi_device *dev)
+{
+       struct labpc_private *devpriv = dev->private;
+
+       if (devpriv)
+               kfree(devpriv->counter);
+}
+EXPORT_SYMBOL_GPL(labpc_common_detach);
+
 static int __init labpc_common_init(void)
 {
        return 0;
index 746c4cd9978dead43d9b0252793de9f08a28522d..a1c69ac075d517ffa3035d5748ecd514082d1290 100644 (file)
@@ -68,8 +68,8 @@ static const struct labpc_boardinfo labpc_cs_boards[] = {
        },
 };
 
-static int labpc_auto_attach(struct comedi_device *dev,
-                            unsigned long context)
+static int labpc_cs_auto_attach(struct comedi_device *dev,
+                               unsigned long context)
 {
        struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
        int ret;
@@ -90,11 +90,17 @@ static int labpc_auto_attach(struct comedi_device *dev,
        return labpc_common_attach(dev, link->irq, IRQF_SHARED);
 }
 
+static void labpc_cs_detach(struct comedi_device *dev)
+{
+       labpc_common_detach(dev);
+       comedi_pcmcia_disable(dev);
+}
+
 static struct comedi_driver driver_labpc_cs = {
        .driver_name    = "ni_labpc_cs",
        .module         = THIS_MODULE,
-       .auto_attach    = labpc_auto_attach,
-       .detach         = comedi_pcmcia_disable,
+       .auto_attach    = labpc_cs_auto_attach,
+       .detach         = labpc_cs_detach,
 };
 
 static int labpc_cs_attach(struct pcmcia_device *link)
index 0407ff681dfd507cf731053a9d2f415cf09b9500..77d403801db505fae0390e9d58920118e29ed1db 100644 (file)
@@ -31,9 +31,8 @@
 
 #include <linux/module.h>
 #include <linux/interrupt.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "ni_labpc.h"
 
@@ -51,7 +50,7 @@ static const struct labpc_boardinfo labpc_pci_boards[] = {
        },
 };
 
-/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+/* ripped from mite.h and mite_setup2() to avoid mite dependency */
 #define MITE_IODWBSR   0xc0     /* IO Device Window Base Size Register */
 #define WENAB          (1 << 7) /* window enable */
 
@@ -103,11 +102,17 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
        return labpc_common_attach(dev, pcidev->irq, IRQF_SHARED);
 }
 
+static void labpc_pci_detach(struct comedi_device *dev)
+{
+       labpc_common_detach(dev);
+       comedi_pci_detach(dev);
+}
+
 static struct comedi_driver labpc_pci_comedi_driver = {
        .driver_name    = "labpc_pci",
        .module         = THIS_MODULE,
        .auto_attach    = labpc_pci_auto_attach,
-       .detach         = comedi_pci_detach,
+       .detach         = labpc_pci_detach,
 };
 
 static const struct pci_device_id labpc_pci_table[] = {
index b6ddc015dedf733e2903d5f4f59b0cd970e61d50..ada050eb359cfddf7e821033ff5f0ba97eedc7aa 100644 (file)
@@ -670,8 +670,8 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
                ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
                break;
        default:
-               dev_err(dev->class_dev,
-                       "%s called with invalid register %d\n", __func__, reg);
+               dev_err(dev->class_dev, "called with invalid register %d\n",
+                       reg);
                break;
        }
        mmiowb();
@@ -755,7 +755,7 @@ static int ni_request_ai_mite_channel(struct comedi_device *dev)
        BUG_ON(devpriv->ai_mite_chan);
        devpriv->ai_mite_chan =
            mite_request_channel(devpriv->mite, devpriv->ai_mite_ring);
-       if (devpriv->ai_mite_chan == NULL) {
+       if (!devpriv->ai_mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev,
                        "failed to reserve mite dma channel for analog input\n");
@@ -776,7 +776,7 @@ static int ni_request_ao_mite_channel(struct comedi_device *dev)
        BUG_ON(devpriv->ao_mite_chan);
        devpriv->ao_mite_chan =
            mite_request_channel(devpriv->mite, devpriv->ao_mite_ring);
-       if (devpriv->ao_mite_chan == NULL) {
+       if (!devpriv->ao_mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev,
                        "failed to reserve mite dma channel for analog outut\n");
@@ -802,7 +802,7 @@ static int ni_request_gpct_mite_channel(struct comedi_device *dev,
        mite_chan =
            mite_request_channel(devpriv->mite,
                                 devpriv->gpct_mite_ring[gpct_index]);
-       if (mite_chan == NULL) {
+       if (!mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev,
                        "failed to reserve mite dma channel for counter\n");
@@ -828,7 +828,7 @@ static int ni_request_cdo_mite_channel(struct comedi_device *dev)
        BUG_ON(devpriv->cdo_mite_chan);
        devpriv->cdo_mite_chan =
            mite_request_channel(devpriv->mite, devpriv->cdo_mite_ring);
-       if (devpriv->cdo_mite_chan == NULL) {
+       if (!devpriv->cdo_mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev,
                        "failed to reserve mite dma channel for correlated digital output\n");
@@ -1068,7 +1068,7 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
                        udelay(5);
                }
                if (i == timeout) {
-                       dev_err(dev->class_dev, "%s timed out\n", __func__);
+                       dev_err(dev->class_dev, "timed out\n");
                        dev_err(dev->class_dev,
                                "mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
                                mite_bytes_in_transit(devpriv->ai_mite_chan),
@@ -1360,7 +1360,7 @@ static void get_last_sample_611x(struct comedi_device *dev)
        /* Check if there's a single sample stuck in the FIFO */
        if (ni_readb(dev, XXX_Status) & 0x80) {
                dl = ni_readl(dev, ADC_FIFO_Data_611x);
-               data = (dl & 0xffff);
+               data = dl & 0xffff;
                comedi_buf_write_samples(s, &data, 1);
        }
 }
@@ -1657,7 +1657,7 @@ static int ni_ai_setup_MITE_dma(struct comedi_device *dev)
        comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
 
        spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
-       if (devpriv->ai_mite_chan == NULL) {
+       if (!devpriv->ai_mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                return -EIO;
        }
@@ -1700,8 +1700,9 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
                        mite_prep_dma(devpriv->ao_mite_chan, 16, 32);
                }
                mite_dma_arm(devpriv->ao_mite_chan);
-       } else
+       } else {
                retval = -EIO;
+       }
        spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
 
        return retval;
@@ -1870,7 +1871,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
                chan = CR_CHAN(list[0]);
                range = CR_RANGE(list[0]);
                range_code = ni_gainlkup[board->gainlkup][range];
-               dither = ((list[0] & CR_ALT_FILTER) != 0);
+               dither = (list[0] & CR_ALT_FILTER) != 0;
                bypass_bits = MSeries_AI_Bypass_Config_FIFO_Bit;
                bypass_bits |= chan;
                bypass_bits |=
@@ -1894,7 +1895,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
                chan = CR_CHAN(list[i]);
                aref = CR_AREF(list[i]);
                range = CR_RANGE(list[i]);
-               dither = ((list[i] & CR_ALT_FILTER) != 0);
+               dither = (list[i] & CR_ALT_FILTER) != 0;
 
                range_code = ni_gainlkup[board->gainlkup][range];
                devpriv->ai_offset[i] = 0;
@@ -2020,7 +2021,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
                        chan = CR_CHAN(list[i]);
                aref = CR_AREF(list[i]);
                range = CR_RANGE(list[i]);
-               dither = ((list[i] & CR_ALT_FILTER) != 0);
+               dither = (list[i] & CR_ALT_FILTER) != 0;
 
                /* fix the external/internal range differences */
                range = ni_gainlkup[board->gainlkup][range];
@@ -2116,8 +2117,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                                }
                        }
                        if (i == NI_TIMEOUT) {
-                               dev_err(dev->class_dev, "%s timeout\n",
-                                       __func__);
+                               dev_err(dev->class_dev, "timeout\n");
                                return -ETIME;
                        }
                        d += signbits;
@@ -2140,8 +2140,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                                }
                        }
                        if (i == NI_TIMEOUT) {
-                               dev_err(dev->class_dev, "%s timeout\n",
-                                       __func__);
+                               dev_err(dev->class_dev, "timeout\n");
                                return -ETIME;
                        }
                        data[n] = (((dl >> 16) & 0xFFFF) + signbits) & 0xFFFF;
@@ -2156,8 +2155,7 @@ static int ni_ai_insn_read(struct comedi_device *dev,
                                        break;
                        }
                        if (i == NI_TIMEOUT) {
-                               dev_err(dev->class_dev, "%s timeout\n",
-                                       __func__);
+                               dev_err(dev->class_dev, "timeout\n");
                                return -ETIME;
                        }
                        if (devpriv->is_m_series) {
@@ -2529,7 +2527,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
                start_stop_select |=
                    AI_START_Select(1 + CR_CHAN(cmd->scan_begin_arg));
                ni_stc_writew(dev, start_stop_select,
-                                   AI_START_STOP_Select_Register);
+                             AI_START_STOP_Select_Register);
                break;
        }
 
@@ -2572,7 +2570,6 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        }
 
        if (dev->irq) {
-
                /* interrupt on FIFO, errors, SC_TC */
                interrupt_a_enable |= AI_Error_Interrupt_Enable |
                    AI_SC_TC_Interrupt_Enable;
@@ -2808,8 +2805,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
                        break;
                default:
                        dev_err(dev->class_dev,
-                               "%s: bug! unhandled ao reference voltage\n",
-                               __func__);
+                               "bug! unhandled ao reference voltage\n");
                        break;
                }
                switch (krange->max + krange->min) {
@@ -2821,8 +2817,7 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
                        break;
                default:
                        dev_err(dev->class_dev,
-                               "%s: bug! unhandled ao offset voltage\n",
-                               __func__);
+                               "bug! unhandled ao offset voltage\n");
                        break;
                }
                if (timed)
@@ -3694,8 +3689,7 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
                udelay((devpriv->serial_interval_ns + 999) / 1000);
                if (--count < 0) {
                        dev_err(dev->class_dev,
-                               "%s: SPI serial I/O didn't finish in time!\n",
-                               __func__);
+                               "SPI serial I/O didn't finish in time!\n");
                        err = -ETIME;
                        goto Error;
                }
@@ -3705,7 +3699,7 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
           DIO_Serial_IO_In_Progress_St goes high one bit too early. */
        udelay((devpriv->serial_interval_ns + 999) / 1000);
 
-       if (data_in != NULL)
+       if (data_in)
                *data_in = ni_stc_readw(dev, DIO_Serial_Input_Register);
 
 Error:
@@ -3817,8 +3811,6 @@ static int ni_serial_insn_config(struct comedi_device *dev,
                              Clock_and_FOUT_Register);
                return 1;
 
-               break;
-
        case INSN_CONFIG_BIDIRECTIONAL_DATA:
 
                if (devpriv->serial_interval_ns == 0)
@@ -3833,8 +3825,7 @@ static int ni_serial_insn_config(struct comedi_device *dev,
                        err = ni_serial_sw_readwrite8(dev, s, byte_out,
                                                      &byte_in);
                } else {
-                       dev_err(dev->class_dev, "%s: serial disabled!\n",
-                               __func__);
+                       dev_err(dev->class_dev, "serial disabled!\n");
                        return -EINVAL;
                }
                if (err < 0)
@@ -3846,7 +3837,6 @@ static int ni_serial_insn_config(struct comedi_device *dev,
        default:
                return -EINVAL;
        }
-
 }
 
 static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -4520,8 +4510,7 @@ static unsigned ni_old_get_pfi_routing(struct comedi_device *dev,
        case 9:
                return NI_PFI_OUTPUT_G_GATE0;
        default:
-               dev_err(dev->class_dev,
-                       "%s: bug, unhandled case in switch.\n", __func__);
+               dev_err(dev->class_dev, "bug, unhandled case in switch.\n");
                break;
        }
        return 0;
@@ -4673,7 +4662,7 @@ static int cs5529_wait_for_idle(struct comedi_device *dev)
                        return -EIO;
        }
        if (i == timeout) {
-               dev_err(dev->class_dev, "%s timeout\n", __func__);
+               dev_err(dev->class_dev, "timeout\n");
                return -ETIME;
        }
        return 0;
@@ -4908,7 +4897,7 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
                                               &devpriv->clock_ns);
        if (retval < 0) {
                dev_err(dev->class_dev,
-                       "%s: bug, failed to find pll parameters\n", __func__);
+                       "bug, failed to find pll parameters\n");
                return retval;
        }
 
@@ -4966,14 +4955,14 @@ static int ni_set_master_clock(struct comedi_device *dev,
                                              RTSI_Trig_Direction_Register);
                                if (period_ns == 0) {
                                        dev_err(dev->class_dev,
-                                               "%s: we don't handle an unspecified clock period correctly yet, returning error\n",
-                                               __func__);
+                                               "we don't handle an unspecified clock period correctly yet, returning error\n");
                                        return -EINVAL;
                                }
                                devpriv->clock_ns = period_ns;
                                devpriv->clock_source = source;
-                       } else
+                       } else {
                                return -EINVAL;
+                       }
                }
        }
        return 3;
@@ -5057,8 +5046,7 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
        } else {
                if (chan == old_RTSI_clock_channel)
                        return NI_RTSI_OUTPUT_RTSI_OSC;
-               dev_err(dev->class_dev, "%s: bug! should never get here?\n",
-                       __func__);
+               dev_err(dev->class_dev, "bug! should never get here?\n");
                return 0;
        }
 }
index db399fe8c301049143009a602401e9a9f01916a7..9e01f8d859948835393db09c702e50cbbb9cbba1 100644 (file)
@@ -53,7 +53,7 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "mite.h"
@@ -304,7 +304,7 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
        devpriv->di_mite_chan =
            mite_request_channel_in_range(devpriv->mite,
                                          devpriv->di_mite_ring, 1, 2);
-       if (devpriv->di_mite_chan == NULL) {
+       if (!devpriv->di_mite_chan) {
                spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
                dev_err(dev->class_dev, "failed to reserve mite dma channel\n");
                return -EBUSY;
@@ -354,8 +354,9 @@ static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
        if (devpriv->di_mite_chan) {
                mite_prep_dma(devpriv->di_mite_chan, 32, 32);
                mite_dma_arm(devpriv->di_mite_chan);
-       } else
+       } else {
                retval = -EIO;
+       }
        spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
 
        return retval;
@@ -924,7 +925,7 @@ static int nidio_auto_attach(struct comedi_device *dev,
                return ret;
 
        devpriv->di_mite_ring = mite_alloc_ring(devpriv->mite);
-       if (devpriv->di_mite_ring == NULL)
+       if (!devpriv->di_mite_ring)
                return -ENOMEM;
 
        if (board->uses_firmware) {
index 3b2bdebbca5983ae2cc87f552301101ae930f32a..1481f71a31b1b3e8fd36914e4edcea405650952b 100644 (file)
@@ -109,7 +109,7 @@ Bugs:
 #include <linux/module.h>
 #include <linux/delay.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include <asm/byteorder.h>
 
@@ -1041,7 +1041,6 @@ static int pcimio_dio_change(struct comedi_device *dev,
        return 0;
 }
 
-
 static void m_series_init_eeprom_buffer(struct comedi_device *dev)
 {
        struct ni_private *devpriv = dev->private;
@@ -1183,19 +1182,19 @@ static int pcimio_auto_attach(struct comedi_device *dev,
                return ret;
 
        devpriv->ai_mite_ring = mite_alloc_ring(devpriv->mite);
-       if (devpriv->ai_mite_ring == NULL)
+       if (!devpriv->ai_mite_ring)
                return -ENOMEM;
        devpriv->ao_mite_ring = mite_alloc_ring(devpriv->mite);
-       if (devpriv->ao_mite_ring == NULL)
+       if (!devpriv->ao_mite_ring)
                return -ENOMEM;
        devpriv->cdo_mite_ring = mite_alloc_ring(devpriv->mite);
-       if (devpriv->cdo_mite_ring == NULL)
+       if (!devpriv->cdo_mite_ring)
                return -ENOMEM;
        devpriv->gpct_mite_ring[0] = mite_alloc_ring(devpriv->mite);
-       if (devpriv->gpct_mite_ring[0] == NULL)
+       if (!devpriv->gpct_mite_ring[0])
                return -ENOMEM;
        devpriv->gpct_mite_ring[1] = mite_alloc_ring(devpriv->mite);
-       if (devpriv->gpct_mite_ring[1] == NULL)
+       if (!devpriv->gpct_mite_ring[1])
                return -ENOMEM;
 
        if (devpriv->is_m_series)
index d36c3abd31209dd42e6651183ecf5f3a64bddb8a..2a1f8b26c407b3fcb93ed6132684c922f2a353da 100644 (file)
@@ -201,7 +201,7 @@ int ni_tio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        unsigned long flags;
 
        spin_lock_irqsave(&counter->lock, flags);
-       if (counter->mite_chan == NULL) {
+       if (!counter->mite_chan) {
                dev_err(counter->counter_dev->dev->class_dev,
                        "commands only supported with DMA.  ");
                dev_err(counter->counter_dev->dev->class_dev,
@@ -329,7 +329,7 @@ static int should_ack_gate(struct ni_gpct *counter)
        case ni_gpct_variant_e_series:
                spin_lock_irqsave(&counter->lock, flags);
                {
-                       if (counter->mite_chan == NULL ||
+                       if (!counter->mite_chan ||
                            counter->mite_chan->dir != COMEDI_INPUT ||
                            (mite_done(counter->mite_chan))) {
                                retval = 1;
@@ -366,7 +366,7 @@ static void ni_tio_acknowledge_and_confirm(struct ni_gpct *counter,
        if (gxx_status & GI_GATE_ERROR(cidx)) {
                ack |= GI_GATE_ERROR_CONFIRM(cidx);
                if (gate_error) {
-                       /*660x don't support automatic acknowledgement
+                       /*660x don't support automatic acknowledgment
                          of gate interrupt via dma read/write
                           and report bogus gate errors */
                        if (counter->counter_dev->variant !=
@@ -443,7 +443,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter,
                break;
        }
        spin_lock_irqsave(&counter->lock, flags);
-       if (counter->mite_chan == NULL) {
+       if (!counter->mite_chan) {
                spin_unlock_irqrestore(&counter->lock, flags);
                return;
        }
index cb7e4c37b8b9957923f1ed414585eada582afd19..ef7db12617391ee85b923e2551626f0faced551c 100644 (file)
@@ -42,7 +42,7 @@
 #include "../comedidev.h"
 
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * I/O port register map
@@ -153,11 +153,6 @@ static const struct pcl711_board boardtypes[] = {
        },
 };
 
-struct pcl711_private {
-       unsigned int divisor1;
-       unsigned int divisor2;
-};
-
 static void pcl711_ai_set_mode(struct comedi_device *dev, unsigned int mode)
 {
        /*
@@ -287,9 +282,7 @@ static int pcl711_ai_insn_read(struct comedi_device *dev,
 static int pcl711_ai_cmdtest(struct comedi_device *dev,
                             struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
-       struct pcl711_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -339,11 +332,9 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
        /* step 4 */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->scan_begin_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
@@ -353,18 +344,6 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
        return 0;
 }
 
-static void pcl711_ai_load_counters(struct comedi_device *dev)
-{
-       struct pcl711_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + PCL711_TIMER_BASE;
-
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-
-       i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       i8254_write(timer_base, 0, 2, devpriv->divisor2);
-}
-
 static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct comedi_cmd *cmd = &s->async->cmd;
@@ -372,7 +351,8 @@ static int pcl711_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        pcl711_set_changain(dev, s, cmd->chanlist[0]);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               pcl711_ai_load_counters(dev);
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
                outb(PCL711_INT_STAT_CLR, dev->iobase + PCL711_INT_STAT_REG);
                pcl711_ai_set_mode(dev, PCL711_MODE_PACER_IRQ);
        } else {
@@ -445,14 +425,9 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,
 static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
        const struct pcl711_board *board = dev->board_ptr;
-       struct pcl711_private *devpriv;
        struct comedi_subdevice *s;
        int ret;
 
-       devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
-       if (!devpriv)
-               return -ENOMEM;
-
        ret = comedi_request_region(dev, it->options[0], 0x10);
        if (ret)
                return ret;
@@ -464,6 +439,11 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                        dev->irq = it->options[1];
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCL711_TIMER_BASE,
+                                     I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index 3ffb1ea2ecc87ba462d4a472c3bde08ed95d442f..1bb67aadff5904f1f1b95257cd8ce0c21f8fe970 100644 (file)
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /* hardware types of the cards */
 #define boardPCL812PG        0 /* and ACL-8112PG */
@@ -513,8 +513,6 @@ struct pcl812_private {
        unsigned char mode_reg_int;     /*  there is stored INT number for some card */
        unsigned int ai_poll_ptr;       /*  how many sampes transfer poll */
        unsigned int max_812_ai_mode0_rangewait;        /*  setling time for gain */
-       unsigned int divisor1;
-       unsigned int divisor2;
        unsigned int use_diff:1;
        unsigned int use_mpc508:1;
        unsigned int use_ext_trg:1;
@@ -522,21 +520,6 @@ struct pcl812_private {
        unsigned int ai_eos:1;
 };
 
-static void pcl812_start_pacer(struct comedi_device *dev, bool load_timers)
-{
-       struct pcl812_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + PCL812_TIMER_BASE;
-
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       udelay(1);
-
-       if (load_timers) {
-               i8254_write(timer_base, 0, 2, devpriv->divisor2);
-               i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       }
-}
-
 static void pcl812_ai_setup_dma(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                unsigned int unread_samples)
@@ -650,7 +633,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
        struct pcl812_private *devpriv = dev->private;
        int err = 0;
        unsigned int flags;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -703,11 +685,9 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
        /* step 4: fix up any arguments */
 
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_2MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -725,8 +705,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        unsigned int ctrl = 0;
        unsigned int i;
 
-       pcl812_start_pacer(dev, false);
-
        pcl812_ai_set_chan_range(dev, cmd->chanlist[0], 1);
 
        if (dma) {      /*  check if we can use DMA transfer */
@@ -760,7 +738,8 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
        switch (cmd->convert_src) {
        case TRIG_TIMER:
-               pcl812_start_pacer(dev, true);
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
                break;
        }
 
@@ -918,7 +897,7 @@ static int pcl812_ai_cancel(struct comedi_device *dev,
 
        outb(devpriv->mode_reg_int | PCL812_CTRL_DISABLE_TRIG,
             dev->iobase + PCL812_CTRL_REG);
-       pcl812_start_pacer(dev, false);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
        pcl812_ai_clear_eoc(dev);
        return 0;
 }
@@ -1010,10 +989,6 @@ static void pcl812_reset(struct comedi_device *dev)
             dev->iobase + PCL812_CTRL_REG);
        pcl812_ai_clear_eoc(dev);
 
-       /* stop pacer */
-       if (board->IRQbits)
-               pcl812_start_pacer(dev, false);
-
        /*
         * Invalidate last_ai_chanspec then set analog input to
         * known channel/range.
@@ -1162,11 +1137,19 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (ret)
                return ret;
 
-       if ((1 << it->options[1]) & board->IRQbits) {
-               ret = request_irq(it->options[1], pcl812_interrupt, 0,
-                                 dev->board_name, dev);
-               if (ret == 0)
-                       dev->irq = it->options[1];
+       if (board->IRQbits) {
+               dev->pacer = comedi_8254_init(dev->iobase + PCL812_TIMER_BASE,
+                                             I8254_OSC_BASE_2MHZ,
+                                             I8254_IO8, 0);
+               if (!dev->pacer)
+                       return -ENOMEM;
+
+               if ((1 << it->options[1]) & board->IRQbits) {
+                       ret = request_irq(it->options[1], pcl812_interrupt, 0,
+                                         dev->board_name, dev);
+                       if (ret == 0)
+                               dev->irq = it->options[1];
+               }
        }
 
        /* we need an IRQ to do DMA on channel 3 or 1 */
index da35edfccbc3bb5fb570ea0c606da236eb559e8f..992a38c81d0f3b962165935bdccf1aad7dd1a1e2 100644 (file)
@@ -42,7 +42,7 @@ Configuration Options:
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * Register I/O map
@@ -116,31 +116,10 @@ static const struct pcl816_board boardtypes[] = {
 struct pcl816_private {
        struct comedi_isadma *dma;
        unsigned int ai_poll_ptr;       /*  how many sampes transfer poll */
-       unsigned int divisor1;
-       unsigned int divisor2;
        unsigned int ai_cmd_running:1;
        unsigned int ai_cmd_canceled:1;
 };
 
-static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters)
-{
-       struct pcl816_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE;
-
-       i8254_set_mode(timer_base, 0, 0, I8254_MODE1 | I8254_BINARY);
-       i8254_write(timer_base, 0, 0, 0x00ff);
-       udelay(1);
-
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       udelay(1);
-
-       if (load_counters) {
-               i8254_write(timer_base, 0, 2, devpriv->divisor2);
-               i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       }
-}
-
 static void pcl816_ai_setup_dma(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                unsigned int unread_samples)
@@ -367,9 +346,7 @@ static int check_channel_list(struct comedi_device *dev,
 static int pcl816_ai_cmdtest(struct comedi_device *dev,
                             struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
-       struct pcl816_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -392,7 +369,6 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 2;
 
-
        /* Step 3: check if arguments are trivially valid */
 
        err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
@@ -413,21 +389,17 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 3;
 
-
        /* step 4: fix up any arguments */
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
                return 4;
 
-
        /* step 5: complain about special chanlist considerations */
 
        if (cmd->chanlist) {
@@ -450,8 +422,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        if (devpriv->ai_cmd_running)
                return -EBUSY;
 
-       pcl816_start_pacer(dev, false);
-
        seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len);
        if (seglen < 1)
                return -EINVAL;
@@ -466,7 +436,11 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        dma->cur_dma = 0;
        pcl816_ai_setup_dma(dev, s, 0);
 
-       pcl816_start_pacer(dev, true);
+       comedi_8254_set_mode(dev->pacer, 0, I8254_MODE1 | I8254_BINARY);
+       comedi_8254_write(dev->pacer, 0, 0x0ff);
+       udelay(1);
+       comedi_8254_update_divisors(dev->pacer);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 
        ctrl = PCL816_CTRL_INTEN | PCL816_CTRL_DMAEN | PCL816_CTRL_DMASRC_SLOT0;
        if (cmd->convert_src == TRIG_TIMER)
@@ -525,11 +499,7 @@ static int pcl816_ai_cancel(struct comedi_device *dev,
        outb(PCL816_CTRL_DISABLE_TRIG, dev->iobase + PCL816_CTRL_REG);
        pcl816_ai_clear_eoc(dev);
 
-       /* Stop pacer */
-       i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
-                       2, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(dev->iobase + PCL816_TIMER_BASE, 0,
-                       1, I8254_MODE0 | I8254_BINARY);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
 
        devpriv->ai_cmd_running = 0;
        devpriv->ai_cmd_canceled = 1;
@@ -596,17 +566,10 @@ static int pcl816_do_insn_bits(struct comedi_device *dev,
 
 static void pcl816_reset(struct comedi_device *dev)
 {
-       unsigned long timer_base = dev->iobase + PCL816_TIMER_BASE;
-
        outb(PCL816_CTRL_DISABLE_TRIG, dev->iobase + PCL816_CTRL_REG);
        pcl816_ai_set_chan_range(dev, 0, 0);
        pcl816_ai_clear_eoc(dev);
 
-       /* Stop pacer */
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY);
-
        /* set all digital outputs low */
        outb(0, dev->iobase + PCL816_DO_DI_LSB_REG);
        outb(0, dev->iobase + PCL816_DO_DI_MSB_REG);
@@ -662,6 +625,11 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        /* an IRQ and DMA are required to support async commands */
        pcl816_alloc_irq_and_dma(dev, it);
 
+       dev->pacer = comedi_8254_init(dev->iobase + PCL816_TIMER_BASE,
+                                     I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
index 7e4cdea5fe59f95f4f5285512a739b821421130d..8d933dcad533e369691168d7a5253d4d7c34e9c3 100644 (file)
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /* boards constants */
 
@@ -299,33 +299,15 @@ struct pcl818_private {
        struct comedi_isadma *dma;
        /*  manimal allowed delay between samples (in us) for actual card */
        unsigned int ns_min;
-       int i8253_osc_base;     /*  1/frequency of on board oscilator in ns */
        /*  MUX setting for actual AI operations */
        unsigned int act_chanlist[16];
        unsigned int act_chanlist_len;  /*  how long is actual MUX list */
        unsigned int act_chanlist_pos;  /*  actual position in MUX list */
-       unsigned int divisor1;
-       unsigned int divisor2;
        unsigned int usefifo:1;
        unsigned int ai_cmd_running:1;
        unsigned int ai_cmd_canceled:1;
 };
 
-static void pcl818_start_pacer(struct comedi_device *dev, bool load_counters)
-{
-       struct pcl818_private *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE;
-
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
-       udelay(1);
-
-       if (load_counters) {
-               i8254_write(timer_base, 0, 2, devpriv->divisor2);
-               i8254_write(timer_base, 0, 1, devpriv->divisor1);
-       }
-}
-
 static void pcl818_ai_setup_dma(struct comedi_device *dev,
                                struct comedi_subdevice *s,
                                unsigned int unread_samples)
@@ -663,9 +645,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                      struct comedi_cmd *cmd)
 {
        const struct pcl818_board *board = dev->board_ptr;
-       struct pcl818_private *devpriv = dev->private;
        int err = 0;
-       unsigned int arg;
 
        /* Step 1 : check if triggers are trivially valid */
 
@@ -712,11 +692,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        /* step 4: fix up any arguments */
 
        if (cmd->convert_src == TRIG_TIMER) {
-               arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(devpriv->i8253_osc_base,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
@@ -746,8 +724,6 @@ static int pcl818_ai_cmd(struct comedi_device *dev,
        if (devpriv->ai_cmd_running)
                return -EBUSY;
 
-       pcl818_start_pacer(dev, false);
-
        seglen = check_channel_list(dev, s, cmd->chanlist, cmd->chanlist_len);
        if (seglen < 1)
                return -EINVAL;
@@ -779,8 +755,10 @@ static int pcl818_ai_cmd(struct comedi_device *dev,
        }
        outb(ctrl, dev->iobase + PCL818_CTRL_REG);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               pcl818_start_pacer(dev, true);
+       if (cmd->convert_src == TRIG_TIMER) {
+               comedi_8254_update_divisors(dev->pacer);
+               comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
+       }
 
        return 0;
 }
@@ -812,7 +790,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
        }
 
        outb(PCL818_CTRL_DISABLE_TRIG, dev->iobase + PCL818_CTRL_REG);
-       pcl818_start_pacer(dev, false);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, false);
        pcl818_ai_clear_eoc(dev);
 
        if (devpriv->usefifo) { /*  FIFO shutdown */
@@ -906,7 +884,6 @@ static int pcl818_do_insn_bits(struct comedi_device *dev,
 static void pcl818_reset(struct comedi_device *dev)
 {
        const struct pcl818_board *board = dev->board_ptr;
-       unsigned long timer_base = dev->iobase + PCL818_TIMER_BASE;
        unsigned int chan;
 
        /* flush and disable the FIFO */
@@ -924,9 +901,6 @@ static void pcl818_reset(struct comedi_device *dev)
 
        /* stop pacer */
        outb(PCL818_CNTENABLE_PACER_ENA, dev->iobase + PCL818_CNTENABLE_REG);
-       i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 1, I8254_MODE0 | I8254_BINARY);
-       i8254_set_mode(timer_base, 0, 0, I8254_MODE0 | I8254_BINARY);
 
        /* set analog output channels to 0V */
        for (chan = 0; chan < board->n_aochan; chan++) {
@@ -1016,6 +990,7 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        const struct pcl818_board *board = dev->board_ptr;
        struct pcl818_private *devpriv;
        struct comedi_subdevice *s;
+       unsigned int osc_base;
        int ret;
 
        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
@@ -1043,6 +1018,25 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (dev->irq && board->has_dma)
                pcl818_alloc_dma(dev, it->options[2]);
 
+       /* use 1MHz or 10MHz oscilator */
+       if ((it->options[3] == 0) || (it->options[3] == 10))
+               osc_base = I8254_OSC_BASE_10MHZ;
+       else
+               osc_base = I8254_OSC_BASE_1MHZ;
+
+       dev->pacer = comedi_8254_init(dev->iobase + PCL818_TIMER_BASE,
+                                     osc_base, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
+       /* max sampling speed */
+       devpriv->ns_min = board->ns_min;
+       if (!board->is_818) {
+               /* extended PCL718 to 100kHz DAC */
+               if ((it->options[6] == 1) || (it->options[6] == 100))
+                       devpriv->ns_min = 10000;
+       }
+
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
@@ -1117,22 +1111,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        s->range_table  = &range_digital;
        s->insn_bits    = pcl818_do_insn_bits;
 
-       /* select 1/10MHz oscilator */
-       if ((it->options[3] == 0) || (it->options[3] == 10))
-               devpriv->i8253_osc_base = I8254_OSC_BASE_10MHZ;
-       else
-               devpriv->i8253_osc_base = I8254_OSC_BASE_1MHZ;
-
-       /* max sampling speed */
-       devpriv->ns_min = board->ns_min;
-
-       if (!board->is_818) {
-               if ((it->options[6] == 1) || (it->options[6] == 100)) {
-                       /* extended PCL718 to 100kHz DAC */
-                       devpriv->ns_min = 10000;
-               }
-       }
-
        pcl818_reset(dev);
 
        return 0;
index a1641d98181245eee97662f7f20d1054ac3df567..213457286031264f6316d2b5bd847d2c0dce9990 100644 (file)
@@ -568,7 +568,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                } else if (it->options[2]) {
                        /* request the irq for the 2nd asic */
                        ret = request_irq(it->options[2], pcmuio_interrupt, 0,
-                                       dev->board_name, dev);
+                                         dev->board_name, dev);
                        if (ret == 0)
                                devpriv->irq2 = it->options[2];
                }
@@ -588,7 +588,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                s->insn_bits    = pcmuio_dio_insn_bits;
                s->insn_config  = pcmuio_dio_insn_config;
 
-               /* subdevices 0 and 2 can suppport interrupts */
+               /* subdevices 0 and 2 can support interrupts */
                if ((i == 0 && dev->irq) || (i == 2 && devpriv->irq2)) {
                        /* setup the interrupt subdevice */
                        dev->read_subdev = s;
index 8387fd0e4b7e12f09b553a3b16c7b219bd02fd76..aa865346577120bded6cdb534d70a9f8907f6aba 100644 (file)
@@ -315,7 +315,6 @@ static int daqp_ai_insn_read(struct comedi_device *dev,
        devpriv->interrupt_mode = semaphore;
 
        for (i = 0; i < insn->n; i++) {
-
                /* Start conversion */
                outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
                     dev->iobase + DAQP_COMMAND);
index c94ad12ed446bea7250ccb4c0772076681406f4a..d1ecb518b97c00021bdb99982726a39f3343d03a 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "plx9080.h"
@@ -579,7 +578,7 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
 
                /* read data */
                d = readw(devpriv->las1 + LAS1_ADC_FIFO);
-               d = d >> 3;     /* low 3 bits are marker lines */
+               d >>= 3;        /* low 3 bits are marker lines */
 
                /* convert bipolar data to comedi unsigned data */
                if (comedi_range_is_bipolar(s, range))
@@ -616,7 +615,7 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
                }
 
                d = readw(devpriv->las1 + LAS1_ADC_FIFO);
-               d = d >> 3;     /* low 3 bits are marker lines */
+               d >>= 3;        /* low 3 bits are marker lines */
 
                /* convert bipolar data to comedi unsigned data */
                if (comedi_range_is_bipolar(s, range))
@@ -839,7 +838,6 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
        if (err)
                return 3;
 
-
        /* step 4: fix up any arguments */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -1181,8 +1179,8 @@ static void rtd_pci_latency_quirk(struct comedi_device *dev,
        pci_read_config_byte(pcidev, PCI_LATENCY_TIMER, &pci_latency);
        if (pci_latency < 32) {
                dev_info(dev->class_dev,
-                       "PCI latency changed from %d to %d\n",
-                       pci_latency, 32);
+                        "PCI latency changed from %d to %d\n",
+                        pci_latency, 32);
                pci_write_config_byte(pcidev, PCI_LATENCY_TIMER, 32);
        }
 }
@@ -1299,12 +1297,8 @@ static void rtd_detach(struct comedi_device *dev)
                /* Shut down any board ops by resetting it */
                if (dev->mmio && devpriv->lcfg)
                        rtd_reset(dev);
-               if (dev->irq) {
-                       writel(readl(devpriv->lcfg + PLX_INTRCS_REG) &
-                               ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E),
-                               devpriv->lcfg + PLX_INTRCS_REG);
+               if (dev->irq)
                        free_irq(dev->irq, dev);
-               }
                if (dev->mmio)
                        iounmap(dev->mmio);
                if (devpriv->las1)
index fc497dd920219553458c300f1624e7a07edc4379..53a248bc9d8052ab55692163158a7260901b8b42 100644 (file)
 
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
 #include "comedi_fc.h"
 #include "s626.h"
@@ -231,9 +230,9 @@ static void s626_debi_replace(struct comedi_device *dev, unsigned int addr,
 /* **************  EEPROM ACCESS FUNCTIONS  ************** */
 
 static int s626_i2c_handshake_eoc(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned long context)
+                                 struct comedi_subdevice *s,
+                                 struct comedi_insn *insn,
+                                 unsigned long context)
 {
        bool status;
 
@@ -294,7 +293,7 @@ static uint8_t s626_i2c_read(struct comedi_device *dev, uint8_t addr)
         *  Byte0 = Not sent.
         */
        if (s626_i2c_handshake(dev, S626_I2C_B2(S626_I2C_ATTRSTART,
-                                          (devpriv->i2c_adrs | 1)) |
+                                               (devpriv->i2c_adrs | 1)) |
                                    S626_I2C_B1(S626_I2C_ATTRSTOP, 0) |
                                    S626_I2C_B0(S626_I2C_ATTRNOP, 0)))
                /* Abort function and declare error if handshake failed. */
@@ -517,8 +516,8 @@ static int s626_send_dac(struct comedi_device *dev, uint32_t val)
 /*
  * Private helper function: Write setpoint to an application DAC channel.
  */
-static int s626_set_dac(struct comedi_device *dev, uint16_t chan,
-                        int16_t dacdata)
+static int s626_set_dac(struct comedi_device *dev,
+                       uint16_t chan, int16_t dacdata)
 {
        struct s626_private *devpriv = dev->private;
        uint16_t signmask;
@@ -583,8 +582,8 @@ static int s626_set_dac(struct comedi_device *dev, uint16_t chan,
        return s626_send_dac(dev, val);
 }
 
-static int s626_write_trim_dac(struct comedi_device *dev, uint8_t logical_chan,
-                               uint8_t dac_data)
+static int s626_write_trim_dac(struct comedi_device *dev,
+                              uint8_t logical_chan, uint8_t dac_data)
 {
        struct s626_private *devpriv = dev->private;
        uint32_t chan;
@@ -641,7 +640,7 @@ static int s626_load_trim_dacs(struct comedi_device *dev)
        /* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
        for (i = 0; i < ARRAY_SIZE(s626_trimchan); i++) {
                ret = s626_write_trim_dac(dev, i,
-                                   s626_i2c_read(dev, s626_trimadrs[i]));
+                                         s626_i2c_read(dev, s626_trimadrs[i]));
                if (ret)
                        return ret;
        }
@@ -1576,7 +1575,7 @@ static void s626_reset_adc(struct comedi_device *dev, uint8_t *ppl)
               dev->mmio + S626_P_RPSADDR1);
 
        /* Construct RPS program in rps_buf DMA buffer */
-       if (cmd != NULL && cmd->scan_begin_src != TRIG_FOLLOW) {
+       if (cmd->scan_begin_src != TRIG_FOLLOW) {
                /* Wait for Start trigger. */
                *rps++ = S626_RPS_PAUSE | S626_RPS_SIGADC;
                *rps++ = S626_RPS_CLRSIGNAL | S626_RPS_SIGADC;
@@ -1665,7 +1664,7 @@ static void s626_reset_adc(struct comedi_device *dev, uint8_t *ppl)
                        *rps++ = jmp_adrs;
                }
 
-               if (cmd != NULL && cmd->convert_src != TRIG_NOW) {
+               if (cmd->convert_src != TRIG_NOW) {
                        /* Wait for Start trigger. */
                        *rps++ = S626_RPS_PAUSE | S626_RPS_SIGADC;
                        *rps++ = S626_RPS_CLRSIGNAL | S626_RPS_SIGADC;
@@ -2034,10 +2033,6 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        /* reset ai_cmd_running flag */
        devpriv->ai_cmd_running = 0;
 
-       /* test if cmd is valid */
-       if (cmd == NULL)
-               return -EINVAL;
-
        s626_ai_load_polllist(ppl, cmd);
        devpriv->ai_cmd_running = 1;
        devpriv->ai_convert_count = 0;
@@ -2733,7 +2728,7 @@ static int s626_initialize(struct comedi_device *dev)
 }
 
 static int s626_auto_attach(struct comedi_device *dev,
-                                     unsigned long context_unused)
+                           unsigned long context_unused)
 {
        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
        struct s626_private *devpriv;
index 71226ee9064efc4c829a6b8804ac620df61551ac..ad35ed6e93f0a26554348922ee02f04e758f6f04 100644 (file)
@@ -39,14 +39,12 @@ Status: in development
 #include <linux/poll.h>
 
 struct serial2002_range_table_t {
-
        /*  HACK... */
        int length;
        struct comedi_krange range;
 };
 
 struct serial2002_private {
-
        int port;               /*  /dev/ttyS<port> */
        int speed;              /*  baudrate */
        struct file *tty;
@@ -145,8 +143,8 @@ static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
                        break;
                }
                do_gettimeofday(&now);
-               elapsed = (1000000 * (now.tv_sec - start.tv_sec) +
-                         now.tv_usec - start.tv_usec);
+               elapsed = 1000000 * (now.tv_sec - start.tv_sec) +
+                         now.tv_usec - start.tv_usec;
                if (elapsed > timeout)
                        break;
                set_current_state(TASK_INTERRUPTIBLE);
@@ -300,7 +298,6 @@ static struct serial_data serial2002_read(struct file *f, int timeout)
                }
        }
        return result;
-
 }
 
 static void serial2002_write(struct file *f, struct serial_data data)
index 848c3080158073a2ff1a263f5747f45f0b9bc4f2..acc7f3445c583e426253138f7fba68e36e9c7b98 100644 (file)
@@ -127,7 +127,6 @@ static int dnp_dio_insn_config(struct comedi_device *dev,
        outb(val, CSCDR);
 
        return insn->n;
-
 }
 
 static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
index 7c2276a086ac8c3e2d8a2fa4caa0f92142226453..51498b889c6c178fc7e5f63e46952abe7d770445 100644 (file)
@@ -38,7 +38,6 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5),
 
 */
 
-
 #include <linux/module.h>
 #include <linux/delay.h>
 #include "../comedidev.h"
@@ -81,7 +80,6 @@ struct unioxx5_subd_priv {
 
 static int __unioxx5_define_chan_offset(int chan_num)
 {
-
        if (chan_num < 0 || chan_num > 23)
                return -1;
 
@@ -266,7 +264,7 @@ static int __unioxx5_analog_write(struct comedi_subdevice *s,
        /* sending for bytes to module(one byte per cycle iteration) */
        for (i = 0; i < 4; i++) {
                while (!((inb(usp->usp_iobase + 0)) & TxBE))
-                       ;       /* waits while writting will be allowed */
+                       ;       /* waits while writing will be allowed */
                outb(usp->usp_extra_data[module][i], usp->usp_iobase + 6);
        }
 
@@ -399,7 +397,7 @@ static int __unioxx5_subdev_init(struct comedi_device *dev,
                outb(i + 1, iobase + 5);
                outb('H', iobase + 6);  /* requests EEPROM world */
                while (!(inb(iobase + 0) & TxBE))
-                       ;       /* waits while writting will be allowed */
+                       ;       /* waits while writing will be allowed */
                outb(0, iobase + 6);
 
                /* waits while reading of two bytes will be allowed */
@@ -413,8 +411,9 @@ static int __unioxx5_subdev_init(struct comedi_device *dev,
                if (ndef_flag) {
                        usp->usp_module_type[i] = 0;
                        ndef_flag = 0;
-               } else
+               } else {
                        usp->usp_module_type[i] = inb(iobase + 6);
+               }
 
                udelay(1);
        }
index 1cd7403a4e9c741a0cb7137cdec134579924c343..a6403d2d2c083cb65d071b205a37ad1d16df141e 100644 (file)
@@ -633,8 +633,8 @@ static int receive_dux_commands(struct comedi_device *dev, unsigned int command)
 
        for (i = 0; i < RETRIES; i++) {
                ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, 8),
-                                     devpriv->insn_buf, SIZEINSNBUF,
-                                     &nrec, BULK_TIMEOUT);
+                                  devpriv->insn_buf, SIZEINSNBUF,
+                                  &nrec, BULK_TIMEOUT);
                if (ret < 0)
                        return ret;
                if (le16_to_cpu(devpriv->insn_buf[0]) == command)
@@ -1041,7 +1041,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
                                struct comedi_insn *insn,
                                unsigned int *data)
 {
-
        struct usbdux_private *devpriv = dev->private;
        int ret;
 
index 7ce27c16c2f99e107265dee703d027e0ba11e9bc..50c47af5f0ac6c585e5957d61d7f38afed23f454 100644 (file)
@@ -419,7 +419,6 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
        /* step 4: fix up any arguments */
 
        return 0;
-
 }
 
 static int usbduxfast_ai_inttrig(struct comedi_device *dev,
index 394969b7458c19df240d52cb1ad83bd2b61e1c7b..f50cf8a8dada58d5715e827e0aa6a3f678881ebd 100644 (file)
@@ -243,9 +243,8 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device *dev,
                urb->dev = comedi_to_usb_dev(dev);
                ret = usb_submit_urb(urb, GFP_ATOMIC);
                if (ret < 0) {
-                       dev_err(dev->class_dev,
-                               "%s: urb resubmit failed (%d)\n",
-                               __func__, ret);
+                       dev_err(dev->class_dev, "urb resubmit failed (%d)\n",
+                               ret);
                        if (ret == -EL2NSYNC)
                                dev_err(dev->class_dev,
                                        "buggy USB host controller or bug in IRQ handler\n");
@@ -292,8 +291,8 @@ static void usbduxsigma_ai_urb_complete(struct urb *urb)
 
        default:
                /* a real error */
-               dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n",
-                       __func__, urb->status);
+               dev_err(dev->class_dev, "non-zero urb status (%d)\n",
+                       urb->status);
                async->events |= COMEDI_CB_ERROR;
                break;
        }
@@ -386,9 +385,8 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device *dev,
                urb->iso_frame_desc[0].status = 0;
                ret = usb_submit_urb(urb, GFP_ATOMIC);
                if (ret < 0) {
-                       dev_err(dev->class_dev,
-                               "%s: urb resubmit failed (%d)\n",
-                               __func__, ret);
+                       dev_err(dev->class_dev, "urb resubmit failed (%d)\n",
+                               ret);
                        if (ret == -EL2NSYNC)
                                dev_err(dev->class_dev,
                                        "buggy USB host controller or bug in IRQ handler\n");
@@ -423,8 +421,8 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb)
 
        default:
                /* a real error */
-               dev_err(dev->class_dev, "%s: non-zero urb status (%d)\n",
-                       __func__, urb->status);
+               dev_err(dev->class_dev, "non-zero urb status (%d)\n",
+                       urb->status);
                async->events |= COMEDI_CB_ERROR;
                break;
        }
@@ -1071,9 +1069,8 @@ static void usbduxsigma_pwm_urb_complete(struct urb *urb)
        default:
                /* a real error */
                if (devpriv->pwm_cmd_running) {
-                       dev_err(dev->class_dev,
-                               "%s: non-zero urb status (%d)\n",
-                               __func__, urb->status);
+                       dev_err(dev->class_dev, "non-zero urb status (%d)\n",
+                               urb->status);
                        usbduxsigma_pwm_stop(dev, 0);   /* w/o unlink */
                }
                return;
@@ -1087,8 +1084,7 @@ static void usbduxsigma_pwm_urb_complete(struct urb *urb)
        urb->status = 0;
        ret = usb_submit_urb(urb, GFP_ATOMIC);
        if (ret < 0) {
-               dev_err(dev->class_dev, "%s: urb resubmit failed (%d)\n",
-                       __func__, ret);
+               dev_err(dev->class_dev, "urb resubmit failed (%d)\n", ret);
                if (ret == -EL2NSYNC)
                        dev_err(dev->class_dev,
                                "buggy USB host controller or bug in IRQ handler\n");
index 973f544e85e1aaa5f457c7fe79735d2feae50189..76bf5619fdd522f121793b994331236268298c0b 100644 (file)
@@ -58,7 +58,7 @@ struct comedi_device *comedi_open(const char *filename)
                retval = NULL;
        up_read(&dev->attach_lock);
 
-       if (retval == NULL)
+       if (!retval)
                comedi_dev_put(dev);
 
        return retval;
index 7184747e0652ca39799a1b104888a4205297db38..6766d5a91a90805329b60efed81ccc0e64e5af02 100644 (file)
@@ -1361,7 +1361,6 @@ static uint dgap_get_custom_baud(struct channel_t *ch)
 {
        u8 __iomem *vaddr;
        ulong offset;
-       uint value;
 
        if (!ch || ch->magic != DGAP_CHANNEL_MAGIC)
                return 0;
@@ -1384,8 +1383,7 @@ static uint dgap_get_custom_baud(struct channel_t *ch)
        offset = (ioread16(vaddr + ECS_SEG) << 4) + (ch->ch_portnum * 0x28)
               + LINE_SPEED;
 
-       value = readw(vaddr + offset);
-       return value;
+       return readw(vaddr + offset);
 }
 
 /*
@@ -2196,7 +2194,7 @@ static struct board_t *dgap_found_board(struct pci_dev *pdev, int id,
         * will be mapped into the low 2MB of the 4MB memory space
         */
        brd->port = brd->membase + PCI_IO_OFFSET;
-       brd->port_end = brd->port + PCI_IO_SIZE;
+       brd->port_end = brd->port + PCI_IO_SIZE_DGAP;
 
        /*
         * Special initialization for non-PLX boards
@@ -3979,7 +3977,6 @@ static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value)
        int result;
        u8 mstat;
        ulong lock_flags;
-       int rc;
 
        spin_lock_irqsave(&ch->ch_lock, lock_flags);
 
@@ -4004,9 +4001,7 @@ static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value)
        if (mstat & D_CD(ch))
                result |= TIOCM_CD;
 
-       rc = put_user(result, value);
-
-       return rc;
+       return put_user(result, value);
 }
 
 /*
@@ -7044,8 +7039,7 @@ static int dgap_start(void)
 
        /* Start the poller */
        spin_lock_irqsave(&dgap_poll_lock, flags);
-       init_timer(&dgap_poll_timer);
-       dgap_poll_timer.function = dgap_poll_handler;
+       setup_timer(&dgap_poll_timer, dgap_poll_handler, 0);
        dgap_poll_timer.data = 0;
        dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick);
        dgap_poll_timer.expires = dgap_poll_time;
index 684033156e8c3f9a9db6c0563bcddbf6e7d08d0a..a2e5b26c673ad151361a8f8820f66022d577cdf4 100644 (file)
 #define PCI_IO_OFFSET          0x00200000
 
 /* Size of IO (2MB) */
-#define PCI_IO_SIZE            0x00200000
+#define PCI_IO_SIZE_DGAP       0x00200000
 
 /* Number of boards we support at once. */
 #define        MAXBOARDS       32
index b69f7b6b11430d74716327ac80506bac2c967623..995c874f40eb138ce0af15eb6c97acd2e5730707 100644 (file)
@@ -1,5 +1,3 @@
-EXTRA_CFLAGS += -DDG_NAME=\"dgnc-1.3-16\" -DDG_PART=\"40002369_F\"
-
 obj-$(CONFIG_DGNC) += dgnc.o
 
 dgnc-objs :=   dgnc_cls.o dgnc_driver.o\
index 22adff1078f39acaeee86157e702970bed67190e..2b2c6ea03c615e19bb04b7128cfbae6a715c496f 100644 (file)
@@ -1,10 +1,10 @@
 * checkpatch fixes
 * remove unecessary comments
-* remove unecessary error messages. Example kzalloc() has its 
+* remove unecessary error messages. Example kzalloc() has its
   own error message. Adding an extra one is useless.
 * use goto statements for error handling when appropriate
-* there is a lot of unecessary code in the driver. It was 
+* there is a lot of unecessary code in the driver. It was
   originally a standalone driver. Remove uneeded code.
 
-Please send patches to Greg Kroah-Hartman <greg@kroah.com> and 
+Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
 Cc: Lidza Louina <lidza.louina@gmail.com>
index bedc5221b6fc6e73279f15171dec8d63de53bbf4..66397d66ee0e77f793f097e900d9d5cdfb038733 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
- *
  */
 
 #include <linux/kernel.h>
@@ -92,14 +76,12 @@ struct board_ops dgnc_cls_ops = {
        .send_immediate_char =          cls_send_immediate_char
 };
 
-
 static inline void cls_set_cts_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -136,14 +118,12 @@ static inline void cls_set_cts_flow_control(struct channel_t *ch)
 
 }
 
-
 static inline void cls_set_ixon_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -184,14 +164,12 @@ static inline void cls_set_ixon_flow_control(struct channel_t *ch)
 
 }
 
-
 static inline void cls_set_no_output_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -230,14 +208,12 @@ static inline void cls_set_no_output_flow_control(struct channel_t *ch)
 
 }
 
-
 static inline void cls_set_rts_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -266,20 +242,17 @@ static inline void cls_set_rts_flow_control(struct channel_t *ch)
                UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR),
                &ch->ch_cls_uart->isr_fcr);
 
-
        ch->ch_r_watermark = 4;
        ch->ch_r_tlevel = 8;
 
 }
 
-
 static inline void cls_set_ixoff_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -316,14 +289,12 @@ static inline void cls_set_ixoff_flow_control(struct channel_t *ch)
 
 }
 
-
 static inline void cls_set_no_input_flow_control(struct channel_t *ch)
 {
        unsigned char lcrb = readb(&ch->ch_cls_uart->lcr);
        unsigned char ier = readb(&ch->ch_cls_uart->ier);
        unsigned char isr_fcr = 0;
 
-
        /*
         * The Enhanced Register Set may only be accessed when
         * the Line Control Register is set to 0xBFh.
@@ -357,7 +328,6 @@ static inline void cls_set_no_input_flow_control(struct channel_t *ch)
 
 }
 
-
 /*
  * cls_clear_break.
  * Determines whether its time to shut off break condition.
@@ -393,7 +363,6 @@ static inline void cls_clear_break(struct channel_t *ch, int force)
        spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
-
 /* Parse the ISR register for the specific port */
 static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
 {
@@ -457,7 +426,6 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
        }
 }
 
-
 /*
  * cls_param()
  * Send any/all changes to the line to the UART.
@@ -711,7 +679,6 @@ static void cls_param(struct tty_struct *tty)
        cls_parse_modem(ch, readb(&ch->ch_cls_uart->msr));
 }
 
-
 /*
  * Our board poller function.
  */
@@ -784,7 +751,6 @@ static void cls_tasklet(unsigned long data)
 
 }
 
-
 /*
  * cls_intr()
  *
@@ -834,7 +800,6 @@ static irqreturn_t cls_intr(int irq, void *voidbrd)
        return IRQ_HANDLED;
 }
 
-
 static void cls_disable_receiver(struct channel_t *ch)
 {
        unsigned char tmp = readb(&ch->ch_cls_uart->ier);
@@ -843,7 +808,6 @@ static void cls_disable_receiver(struct channel_t *ch)
        writeb(tmp, &ch->ch_cls_uart->ier);
 }
 
-
 static void cls_enable_receiver(struct channel_t *ch)
 {
        unsigned char tmp = readb(&ch->ch_cls_uart->ier);
@@ -852,7 +816,6 @@ static void cls_enable_receiver(struct channel_t *ch)
        writeb(tmp, &ch->ch_cls_uart->ier);
 }
 
-
 static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
 {
        int qleft = 0;
@@ -942,7 +905,6 @@ static void cls_copy_data_from_uart_to_queue(struct channel_t *ch)
        spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
-
 /*
  * This function basically goes to sleep for secs, or until
  * it gets signalled that the port has fully drained.
@@ -978,7 +940,6 @@ static int cls_drain(struct tty_struct *tty, uint seconds)
                                         ((un->un_flags & UN_EMPTY) == 0));
 }
 
-
 /* Channel lock MUST be held before calling this function! */
 static void cls_flush_uart_write(struct channel_t *ch)
 {
@@ -992,7 +953,6 @@ static void cls_flush_uart_write(struct channel_t *ch)
        ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
 }
 
-
 /* Channel lock MUST be held before calling this function! */
 static void cls_flush_uart_read(struct channel_t *ch)
 {
@@ -1013,7 +973,6 @@ static void cls_flush_uart_read(struct channel_t *ch)
        udelay(10);
 }
 
-
 static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
 {
        ushort head;
@@ -1029,22 +988,16 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
        spin_lock_irqsave(&ch->ch_lock, flags);
 
        /* No data to write to the UART */
-       if (ch->ch_w_tail == ch->ch_w_head) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if (ch->ch_w_tail == ch->ch_w_head)
+               goto exit_unlock;
 
        /* If port is "stopped", don't send any data to the UART */
        if ((ch->ch_flags & CH_FORCED_STOP) ||
-                                (ch->ch_flags & CH_BREAK_SENDING)) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+                                (ch->ch_flags & CH_BREAK_SENDING))
+               goto exit_unlock;
 
-       if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM)))
+               goto exit_unlock;
 
        n = 32;
 
@@ -1094,10 +1047,10 @@ static void cls_copy_data_from_queue_to_uart(struct channel_t *ch)
        if (len_written > 0)
                ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
 
+exit_unlock:
        spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
-
 static void cls_parse_modem(struct channel_t *ch, unsigned char signals)
 {
        unsigned char msignals = signals;
@@ -1162,7 +1115,6 @@ static void cls_parse_modem(struct channel_t *ch, unsigned char signals)
        spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
-
 /* Make the UART raise any of the output signals we want up */
 static void cls_assert_modem_signals(struct channel_t *ch)
 {
@@ -1182,7 +1134,6 @@ static void cls_assert_modem_signals(struct channel_t *ch)
        udelay(10);
 }
 
-
 static void cls_send_start_character(struct channel_t *ch)
 {
        if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
@@ -1194,7 +1145,6 @@ static void cls_send_start_character(struct channel_t *ch)
        }
 }
 
-
 static void cls_send_stop_character(struct channel_t *ch)
 {
        if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
@@ -1206,7 +1156,6 @@ static void cls_send_stop_character(struct channel_t *ch)
        }
 }
 
-
 /* Inits UART */
 static void cls_uart_init(struct channel_t *ch)
 {
@@ -1244,7 +1193,6 @@ static void cls_uart_init(struct channel_t *ch)
        readb(&ch->ch_cls_uart->msr);
 }
 
-
 /*
  * Turns off UART.
  */
@@ -1253,7 +1201,6 @@ static void cls_uart_off(struct channel_t *ch)
        writeb(0, &ch->ch_cls_uart->ier);
 }
 
-
 /*
  * cls_get_uarts_bytes_left.
  * Returns 0 is nothing left in the FIFO, returns 1 otherwise.
@@ -1283,7 +1230,6 @@ static uint cls_get_uart_bytes_left(struct channel_t *ch)
        return left;
 }
 
-
 /*
  * cls_send_break.
  * Starts sending a break thru the UART.
@@ -1326,7 +1272,6 @@ static void cls_send_break(struct channel_t *ch, int msecs)
        }
 }
 
-
 /*
  * cls_send_immediate_char.
  * Sends a specific character as soon as possible to the UART,
@@ -1348,7 +1293,6 @@ static void cls_vpd(struct dgnc_board *brd)
        u8 __iomem           *re_map_vpdbase;/* Remapped memory of the card */
        int i = 0;
 
-
        vpdbase = pci_resource_start(brd->pdev, 3);
 
        /* No VPD */
@@ -1370,4 +1314,3 @@ static void cls_vpd(struct dgnc_board *brd)
        if (re_map_vpdbase)
                iounmap(re_map_vpdbase);
 }
-
index 465d79a6f75f6c138f6b5d12909f8962b01226c1..2398514e10ec580150bd70bd298e392033ea829e 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- *
  */
 
 #ifndef __DGNC_CLS_H
  *                     U = Unused.                                     *
  ************************************************************************/
 
+/*
+ * txrx    : WR RHR/THR - Holding reg
+ * ier     : WR IER - Interrupt Enable Reg
+ * isr_fcr : WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg
+ * lcr     : WR LCR - Line Control Reg
+ * mcr     : WR MCR - Modem Control Reg
+ * lsr     : WR LSR - Line Status Reg
+ * msr     : WR MSG - Modem Status Reg
+ * spr     : WR SPR - Scratch pad Reg
+ */
 struct cls_uart_struct {
-       u8 txrx;                /* WR  RHR/THR - Holding Reg */
-       u8 ier;         /* WR  IER - Interrupt Enable Reg */
-       u8 isr_fcr;             /* WR  ISR/FCR - Interrupt Status Reg/Fifo Control Reg */
-       u8 lcr;         /* WR  LCR - Line Control Reg */
-       u8 mcr;         /* WR  MCR - Modem Control Reg */
-       u8 lsr;         /* WR  LSR - Line Status Reg */
-       u8 msr;         /* WR  MSR - Modem Status Reg */
-       u8 spr;         /* WR  SPR - Scratch Pad Reg */
+       u8 txrx;
+       u8 ier;
+       u8 isr_fcr;
+       u8 lcr;
+       u8 mcr;
+       u8 lsr;
+       u8 msr;
+       u8 spr;
 };
 
 /* Where to read the interrupt register (8bits) */
@@ -61,8 +64,11 @@ struct cls_uart_struct {
 #define UART_16654_FCR_RXTRIGGER_56    0x80
 #define UART_16654_FCR_RXTRIGGER_60     0xC0
 
-#define UART_IIR_CTSRTS                        0x20    /* Received CTS/RTS change of state */
-#define UART_IIR_RDI_TIMEOUT           0x0C    /* Receiver data TIMEOUT */
+/* Received CTS/RTS change of state */
+#define UART_IIR_CTSRTS                        0x20
+
+/* Receiver data TIMEOUT */
+#define UART_IIR_RDI_TIMEOUT           0x0C
 
 /*
  * These are the EXTENDED definitions for the Exar 654's Interrupt
@@ -74,8 +80,11 @@ struct cls_uart_struct {
 #define UART_EXAR654_EFR_RTSDTR   0x40    /* Auto RTS/DTR Flow Control Enable */
 #define UART_EXAR654_EFR_CTSDSR   0x80    /* Auto CTS/DSR Flow COntrol Enable */
 
-#define UART_EXAR654_XOFF_DETECT  0x1     /* Indicates whether chip saw an incoming XOFF char  */
-#define UART_EXAR654_XON_DETECT   0x2     /* Indicates whether chip saw an incoming XON char */
+/* Indicates whether chip saw an incoming XOFF char  */
+#define UART_EXAR654_XOFF_DETECT  0x1
+
+/* Indicates whether chip saw an incoming XON char */
+#define UART_EXAR654_XON_DETECT   0x2
 
 #define UART_EXAR654_IER_XOFF     0x20    /* Xoff Interrupt Enable */
 #define UART_EXAR654_IER_RTSDTR   0x40    /* Output Interrupt Enable */
index f177d3a258c2cf8bce2c2f18182b19167e6155f7..9ae9014dd1449c64fad943da23d86e9ddea19157 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
- *
  */
 
 
@@ -60,7 +44,8 @@ static void           dgnc_init_globals(void);
 static int             dgnc_found_board(struct pci_dev *pdev, int id);
 static void            dgnc_cleanup_board(struct dgnc_board *brd);
 static void            dgnc_poll_handler(ulong dummy);
-static int             dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
+static int             dgnc_init_one(struct pci_dev *pdev,
+                                     const struct pci_device_id *ent);
 static void            dgnc_do_remap(struct dgnc_board *brd);
 
 /*
@@ -92,8 +77,8 @@ static struct class *dgnc_class;
  * Poller stuff
  */
 static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
-static ulong           dgnc_poll_time;                         /* Time of next poll */
-static uint            dgnc_poll_stop;                         /* Used to tell poller to stop */
+static ulong           dgnc_poll_time; /* Time of next poll */
+static uint            dgnc_poll_stop; /* Used to tell poller to stop */
 static struct timer_list dgnc_poll_timer;
 
 
@@ -139,14 +124,6 @@ static struct pci_driver dgnc_driver = {
        .id_table       = dgnc_pci_tbl,
 };
 
-
-char *dgnc_state_text[] = {
-       "Board Failed",
-       "Board Found",
-       "Board READY",
-};
-
-
 /************************************************************************
  *
  * Driver load/unload functions
@@ -214,7 +191,7 @@ static int __init dgnc_init_module(void)
         * If something went wrong in the scan, bail out of driver.
         */
        if (rc < 0) {
-               /* Only unregister the pci driver if it was actually registered. */
+               /* Only unregister if it was actually registered. */
                if (dgnc_NumBoards)
                        pci_unregister_driver(&dgnc_driver);
                else
@@ -251,9 +228,9 @@ static int dgnc_start(void)
         * Register management/dpa devices
         */
        rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
-       if (rc <= 0) {
+       if (rc < 0) {
                pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
-               return -ENXIO;
+               return rc;
        }
        dgnc_Major = rc;
 
@@ -285,9 +262,7 @@ static int dgnc_start(void)
 
        /* Start the poller */
        spin_lock_irqsave(&dgnc_poll_lock, flags);
-       init_timer(&dgnc_poll_timer);
-       dgnc_poll_timer.function = dgnc_poll_handler;
-       dgnc_poll_timer.data = 0;
+       setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
        dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
        dgnc_poll_timer.expires = dgnc_poll_time;
        spin_unlock_irqrestore(&dgnc_poll_lock, flags);
@@ -364,7 +339,7 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
 
                spin_lock_irqsave(&dgnc_global_lock, flags);
                brd->msgbuf = NULL;
-               printk("%s", brd->msgbuf_head);
+               dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
                kfree(brd->msgbuf_head);
                brd->msgbuf_head = NULL;
                spin_unlock_irqrestore(&dgnc_global_lock, flags);
@@ -410,7 +385,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
                return -ENOMEM;
 
        /* make a temporary message buffer for the boot messages */
-       brd->msgbuf_head = kzalloc(sizeof(u8) * 8192, GFP_KERNEL);
+       brd->msgbuf_head = kcalloc(8192, sizeof(u8), GFP_KERNEL);
        brd->msgbuf = brd->msgbuf_head;
 
        if (!brd->msgbuf) {
@@ -553,7 +528,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
                if (brd->re_map_membase) {
 
-                       /* After remap is complete, we need to read and store the dvid */
+                       /* Read and store the dvid after remapping */
                        brd->dvid = readb(brd->re_map_membase + 0x8D);
 
                        /* Get and store the board VPD, if it exists */
@@ -574,29 +549,19 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
        rc = dgnc_tty_register(brd);
        if (rc < 0) {
-               dgnc_tty_uninit(brd);
                pr_err(DRVSTR ": Can't register tty devices (%d)\n", rc);
-               brd->state = BOARD_FAILED;
-               brd->dpastatus = BD_NOFEP;
                goto failed;
        }
 
        rc = dgnc_finalize_board_init(brd);
        if (rc < 0) {
                pr_err(DRVSTR ": Can't finalize board init (%d)\n", rc);
-               brd->state = BOARD_FAILED;
-               brd->dpastatus = BD_NOFEP;
-
                goto failed;
        }
 
        rc = dgnc_tty_init(brd);
        if (rc < 0) {
-               dgnc_tty_uninit(brd);
                pr_err(DRVSTR ": Can't init tty devices (%d)\n", rc);
-               brd->state = BOARD_FAILED;
-               brd->dpastatus = BD_NOFEP;
-
                goto failed;
        }
 
@@ -606,11 +571,13 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        dgnc_create_ports_sysfiles(brd);
 
        /* init our poll helper tasklet */
-       tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd);
+       tasklet_init(&brd->helper_tasklet,
+                    brd->bd_ops->tasklet,
+                    (unsigned long) brd);
 
        spin_lock_irqsave(&dgnc_global_lock, flags);
        brd->msgbuf = NULL;
-       printk("%s", brd->msgbuf_head);
+       dev_dbg(&brd->pdev->dev, "%s\n", brd->msgbuf_head);
        kfree(brd->msgbuf_head);
        brd->msgbuf_head = NULL;
        spin_unlock_irqrestore(&dgnc_global_lock, flags);
@@ -628,6 +595,9 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
        return 0;
 
 failed:
+       dgnc_tty_uninit(brd);
+       brd->state = BOARD_FAILED;
+       brd->dpastatus = BD_NOFEP;
 
        return -ENXIO;
 
@@ -708,7 +678,7 @@ static void dgnc_poll_handler(ulong dummy)
 
                spin_lock_irqsave(&brd->bd_lock, flags);
 
-               /* If board is in a failed state, don't bother scheduling a tasklet */
+               /* If board is in a failed state don't schedule a tasklet */
                if (brd->state == BOARD_FAILED) {
                        spin_unlock_irqrestore(&brd->bd_lock, flags);
                        continue;
@@ -729,11 +699,9 @@ static void dgnc_poll_handler(ulong dummy)
        new_time = dgnc_poll_time - jiffies;
 
        if ((ulong) new_time >= 2 * dgnc_poll_tick)
-               dgnc_poll_time = jiffies +  dgnc_jiffies_from_ms(dgnc_poll_tick);
+               dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
 
-       init_timer(&dgnc_poll_timer);
-       dgnc_poll_timer.function = dgnc_poll_handler;
-       dgnc_poll_timer.data = 0;
+       setup_timer(&dgnc_poll_timer, dgnc_poll_handler, 0);
        dgnc_poll_timer.expires = dgnc_poll_time;
        spin_unlock_irqrestore(&dgnc_poll_lock, flags);
 
index a8157eba28dac470ac5ae5c5d92c9843bd7f096b..15c4d95cfe07f6e316dd06c48fbadd1add3a5adf 100644 (file)
  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- *
  *************************************************************************
  *
  * Driver includes
@@ -46,6 +40,7 @@
 #define        PROCSTR         "dgnc"                  /* /proc entries         */
 #define        DEVSTR          "/dev/dg/dgnc"          /* /dev entries          */
 #define        DRVSTR          "dgnc"                  /* Driver name string    */
+#define        DG_PART         "40002369_F"            /* RPM part number       */
 
 #define TRC_TO_CONSOLE 1
 
@@ -398,11 +393,10 @@ struct channel_t {
 /*
  * Our Global Variables.
  */
-extern uint            dgnc_Major;             /* Our driver/mgmt major        */
-extern int             dgnc_poll_tick;         /* Poll interval - 20 ms        */
-extern spinlock_t      dgnc_global_lock;       /* Driver global spinlock       */
-extern uint            dgnc_NumBoards;         /* Total number of boards       */
-extern struct dgnc_board       *dgnc_Board[MAXBOARDS]; /* Array of board structs       */
-extern char            *dgnc_state_text[];     /* Array of state text          */
+extern uint            dgnc_Major;             /* Our driver/mgmt major */
+extern int             dgnc_poll_tick;         /* Poll interval - 20 ms */
+extern spinlock_t      dgnc_global_lock;       /* Driver global spinlock */
+extern uint            dgnc_NumBoards;         /* Total number of boards */
+extern struct dgnc_board       *dgnc_Board[MAXBOARDS]; /* Array of board structs */
 
 #endif
index 566cad0d33e7fc01e81e6c4d3d14f03ebf853d84..22060385321a262939d2fabb2b43744355618d1f 100644 (file)
  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * PURPOSE.  See the GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- *
  *************************************************************************
  *
  * This file is intended to contain all the kernel "differences" between the
index 5544a8e7f4bc405195130417f31927f72cf42a59..57814061f6db401114cb12ca1888ad2844329f93 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
- *
  */
 
 /************************************************************************
@@ -153,8 +137,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                if (copy_from_user(&brd, uarg, sizeof(int)))
                        return -EFAULT;
 
-               if ((brd < 0) || (brd > dgnc_NumBoards) ||
-                   (dgnc_NumBoards == 0))
+               if (brd < 0 || brd >= dgnc_NumBoards)
                        return -ENODEV;
 
                memset(&di, 0, sizeof(di));
index 567f687b18ddb79bc0dae4124be9f6f1ede2f46f..708abe9594d41a2c91bfe3e6de77117c113a46be 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DGNC_MGMT_H
index c9a8a9825cfb25fa4d3392e7c23eea8bfecbf7c6..41105be24229e1b3c547d4f56ea46efdc569b4fc 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
- *
  */
 
 
@@ -119,7 +103,7 @@ static inline void neo_set_cts_flow_control(struct channel_t *ch)
 
        /* Turn on auto CTS flow control */
 #if 1
-       ier |= (UART_17158_IER_CTSDSR);
+       ier |= UART_17158_IER_CTSDSR;
 #else
        ier &= ~(UART_17158_IER_CTSDSR);
 #endif
@@ -127,7 +111,7 @@ static inline void neo_set_cts_flow_control(struct channel_t *ch)
        efr |= (UART_17158_EFR_ECB | UART_17158_EFR_CTSDSR);
 
        /* Turn off auto Xon flow control */
-       efr &= ~(UART_17158_EFR_IXON);
+       efr &= ~UART_17158_EFR_IXON;
 
        /* Why? Becuz Exar's spec says we have to zero it out before setting it */
        writeb(0, &ch->ch_neo_uart->efr);
@@ -155,15 +139,15 @@ static inline void neo_set_rts_flow_control(struct channel_t *ch)
 
        /* Turn on auto RTS flow control */
 #if 1
-       ier |= (UART_17158_IER_RTSDTR);
+       ier |= UART_17158_IER_RTSDTR;
 #else
        ier &= ~(UART_17158_IER_RTSDTR);
 #endif
        efr |= (UART_17158_EFR_ECB | UART_17158_EFR_RTSDTR);
 
        /* Turn off auto Xoff flow control */
-       ier &= ~(UART_17158_IER_XOFF);
-       efr &= ~(UART_17158_EFR_IXOFF);
+       ier &= ~UART_17158_IER_XOFF;
+       efr &= ~UART_17158_EFR_IXOFF;
 
        /* Why? Becuz Exar's spec says we have to zero it out before setting it */
        writeb(0, &ch->ch_neo_uart->efr);
@@ -185,7 +169,7 @@ static inline void neo_set_rts_flow_control(struct channel_t *ch)
         * RTS/DTR# output pin (MCR bit-0 or 1 to logic 1 after
         * it is enabled.
         */
-       ch->ch_mostat |= (UART_MCR_RTS);
+       ch->ch_mostat |= UART_MCR_RTS;
 
        neo_pci_posting_flush(ch->ch_bd);
 }
@@ -197,8 +181,8 @@ static inline void neo_set_ixon_flow_control(struct channel_t *ch)
        unsigned char efr = readb(&ch->ch_neo_uart->efr);
 
        /* Turn off auto CTS flow control */
-       ier &= ~(UART_17158_IER_CTSDSR);
-       efr &= ~(UART_17158_EFR_CTSDSR);
+       ier &= ~UART_17158_IER_CTSDSR;
+       efr &= ~UART_17158_EFR_CTSDSR;
 
        /* Turn on auto Xon flow control */
        efr |= (UART_17158_EFR_ECB | UART_17158_EFR_IXON);
@@ -234,11 +218,11 @@ static inline void neo_set_ixoff_flow_control(struct channel_t *ch)
        unsigned char efr = readb(&ch->ch_neo_uart->efr);
 
        /* Turn off auto RTS flow control */
-       ier &= ~(UART_17158_IER_RTSDTR);
-       efr &= ~(UART_17158_EFR_RTSDTR);
+       ier &= ~UART_17158_IER_RTSDTR;
+       efr &= ~UART_17158_EFR_RTSDTR;
 
        /* Turn on auto Xoff flow control */
-       ier |= (UART_17158_IER_XOFF);
+       ier |= UART_17158_IER_XOFF;
        efr |= (UART_17158_EFR_ECB | UART_17158_EFR_IXOFF);
 
        /* Why? Becuz Exar's spec says we have to zero it out before setting it */
@@ -272,11 +256,11 @@ static inline void neo_set_no_input_flow_control(struct channel_t *ch)
        unsigned char efr = readb(&ch->ch_neo_uart->efr);
 
        /* Turn off auto RTS flow control */
-       ier &= ~(UART_17158_IER_RTSDTR);
-       efr &= ~(UART_17158_EFR_RTSDTR);
+       ier &= ~UART_17158_IER_RTSDTR;
+       efr &= ~UART_17158_EFR_RTSDTR;
 
        /* Turn off auto Xoff flow control */
-       ier &= ~(UART_17158_IER_XOFF);
+       ier &= ~UART_17158_IER_XOFF;
        if (ch->ch_c_iflag & IXON)
                efr &= ~(UART_17158_EFR_IXOFF);
        else
@@ -312,12 +296,12 @@ static inline void neo_set_no_output_flow_control(struct channel_t *ch)
        unsigned char efr = readb(&ch->ch_neo_uart->efr);
 
        /* Turn off auto CTS flow control */
-       ier &= ~(UART_17158_IER_CTSDSR);
-       efr &= ~(UART_17158_EFR_CTSDSR);
+       ier &= ~UART_17158_IER_CTSDSR;
+       efr &= ~UART_17158_EFR_CTSDSR;
 
        /* Turn off auto Xon flow control */
        if (ch->ch_c_iflag & IXOFF)
-               efr &= ~(UART_17158_EFR_IXON);
+               efr &= ~UART_17158_EFR_IXON;
        else
                efr &= ~(UART_17158_EFR_ECB | UART_17158_EFR_IXON);
 
@@ -1203,7 +1187,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
                 * IBM pSeries platform.
                 * 15 bytes max appears to be the magic number.
                 */
-               n = min((uint) n, (uint) 12);
+               n = min_t(uint, n, 12);
 
                /*
                 * Since we are grabbing the linestatus register, which
@@ -1436,16 +1420,13 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
        spin_lock_irqsave(&ch->ch_lock, flags);
 
        /* No data to write to the UART */
-       if (ch->ch_w_tail == ch->ch_w_head) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if (ch->ch_w_tail == ch->ch_w_head)
+               goto exit_unlock;
 
        /* If port is "stopped", don't send any data to the UART */
-       if ((ch->ch_flags & CH_FORCED_STOP) || (ch->ch_flags & CH_BREAK_SENDING)) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if ((ch->ch_flags & CH_FORCED_STOP) ||
+                (ch->ch_flags & CH_BREAK_SENDING))
+               goto exit_unlock;
 
        /*
         * If FIFOs are disabled. Send data directly to txrx register
@@ -1486,27 +1467,23 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
                        ch->ch_w_tail &= WQUEUEMASK;
                        ch->ch_txcount++;
                }
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
+
+               goto exit_unlock;
        }
 
        /*
         * We have to do it this way, because of the EXAR TXFIFO count bug.
         */
        if ((ch->ch_bd->dvid & 0xf0) < UART_XR17E158_DVID) {
-               if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) {
-                       spin_unlock_irqrestore(&ch->ch_lock, flags);
-                       return;
-               }
+               if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM)))
+                       goto exit_unlock;
 
                len_written = 0;
 
                n = readb(&ch->ch_neo_uart->tfifo);
 
-               if ((unsigned int) n > ch->ch_t_tlevel) {
-                       spin_unlock_irqrestore(&ch->ch_lock, flags);
-                       return;
-               }
+               if ((unsigned int) n > ch->ch_t_tlevel)
+                       goto exit_unlock;
 
                n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel;
        } else {
@@ -1570,6 +1547,7 @@ static void neo_copy_data_from_queue_to_uart(struct channel_t *ch)
                ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM);
        }
 
+exit_unlock:
        spin_unlock_irqrestore(&ch->ch_lock, flags);
 }
 
index 1a4abb128693657bfc1fcfc7520f313fe18317b6..d7e764a307b97500559ced23ac5d5916e47c39be 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
- *
  */
 
 #ifndef __DGNC_NEO_H
index 5b6f76d98aa72a8ea5b826ce1ffe98037ad6be60..617d40d1ec190cda7163b7e47634b9e665cc7ccd 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DGNC_PCI_H
index 2fd34ca70c599a260c0a9bacdea3923a86c9a032..2df889e29e53b50598877d81f5de43e9fd45735e 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *      NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *      This is shared code between Digi's CVS archive and the
- *      Linux Kernel sources.
- *      Changing the source just for reformatting needlessly breaks
- *      our CVS diff history.
- *
- *      Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *      Thank you.
- *
  */
 
 
@@ -360,7 +344,7 @@ void dgnc_create_ports_sysfiles(struct dgnc_board *bd)
        rc |= device_create_file(&(bd->pdev->dev), &dev_attr_vpd);
        rc |= device_create_file(&(bd->pdev->dev), &dev_attr_serial_number);
        if (rc)
-               printk(KERN_ERR "DGNC: sysfs device_create_file failed!\n");
+               dev_err(&bd->pdev->dev, "dgnc: sysfs device_create_file failed!\n");
 }
 
 
index 68c0de5898a483c6c918c7cd10d69932e56f7129..2758914f69d248eb919d36cffe506d390dd713f0 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DGNC_SYSFS_H
index f81a375f8bc17e87cf23d6ffe793bb782edb019c..f1c4d07a0aaa578bbd1ca900c0b9316045900b27 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *
- *     NOTE TO LINUX KERNEL HACKERS:  DO NOT REFORMAT THIS CODE!
- *
- *     This is shared code between Digi's CVS archive and the
- *     Linux Kernel sources.
- *     Changing the source just for reformatting needlessly breaks
- *     our CVS diff history.
- *
- *     Send any bug fixes/changes to:  Eng.Linux at digi dot com.
- *     Thank you.
  */
 
 /************************************************************************
@@ -507,7 +492,7 @@ void dgnc_input(struct channel_t *ch)
 {
        struct dgnc_board *bd;
        struct tty_struct *tp;
-       struct tty_ldisc *ld;
+       struct tty_ldisc *ld = NULL;
        uint    rmask;
        ushort  head;
        ushort  tail;
@@ -539,10 +524,8 @@ void dgnc_input(struct channel_t *ch)
        tail = ch->ch_r_tail & rmask;
        data_len = (head - tail) & rmask;
 
-       if (data_len == 0) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if (data_len == 0)
+               goto exit_unlock;
 
        /*
         * If the device is not open, or CREAD is off,
@@ -556,17 +539,14 @@ void dgnc_input(struct channel_t *ch)
                /* Force queue flow control to be released, if needed */
                dgnc_check_queue_flow_control(ch);
 
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
+               goto exit_unlock;
        }
 
        /*
         * If we are throttled, simply don't read any data.
         */
-       if (ch->ch_flags & CH_FORCED_STOPI) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return;
-       }
+       if (ch->ch_flags & CH_FORCED_STOPI)
+               goto exit_unlock;
 
        flip_len = TTY_FLIPBUF_SIZE;
 
@@ -604,12 +584,8 @@ void dgnc_input(struct channel_t *ch)
                }
        }
 
-       if (len <= 0) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               if (ld)
-                       tty_ldisc_deref(ld);
-               return;
-       }
+       if (len <= 0)
+               goto exit_unlock;
 
        /*
         * The tty layer in the kernel has changed in 2.6.16+.
@@ -675,6 +651,12 @@ void dgnc_input(struct channel_t *ch)
        /* Tell the tty layer its okay to "eat" the data now */
        tty_flip_buffer_push(tp->port);
 
+       if (ld)
+               tty_ldisc_deref(ld);
+       return;
+
+exit_unlock:
+       spin_unlock_irqrestore(&ch->ch_lock, flags);
        if (ld)
                tty_ldisc_deref(ld);
 }
@@ -886,10 +868,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
                                ch->ch_stops_sent++;
                        }
                }
-               /* No FLOW */
-               else {
-                       /* Empty... Can't do anything about the impending overflow... */
-               }
        }
 
        /*
@@ -1777,10 +1755,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
        /*
         * Bail if no space left.
         */
-       if (count <= 0) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return 0;
-       }
+       if (count <= 0)
+               goto exit_retry;
 
        /*
         * Output the printer ON string, if we are in terminal mode, but
@@ -1807,10 +1783,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
        /*
         * If there is nothing left to copy, or I can't handle any more data, leave.
         */
-       if (count <= 0) {
-               spin_unlock_irqrestore(&ch->ch_lock, flags);
-               return 0;
-       }
+       if (count <= 0)
+               goto exit_retry;
 
        if (from_user) {
 
@@ -1896,6 +1870,11 @@ static int dgnc_tty_write(struct tty_struct *tty,
        }
 
        return count;
+
+exit_retry:
+
+       spin_unlock_irqrestore(&ch->ch_lock, flags);
+       return 0;
 }
 
 
index 3975f040714334fb6296b4a38a8342fc83a17073..21d3369b875ce147fcf6285ecd996e970b3958c1 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DGNC_TTY_H
index 3aafcedbb0d9dc82a0749bc1d828f03ab9b91242..2853d164e51e0de4d78e1283776bcc043b7519c0 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DGNC_TYPES_H
index d6e0b9f6b24a3896811556d91f110f011654c8a5..554fbeb2add3335b373c938535692ccd727f969d 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *     NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 #ifndef __DIGI_H
index 33cb394524b8d371edb155b2d084441dbf0361fc..f41a0e164d2f0b956cfabbf0c619c9d8920e1be0 100644 (file)
  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
- *
- *      NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
  */
 
 
index 4be646ce8a12215aac76d6326e2832ee34d26f0f..fbf82bc735cff6c6249ddae0c923b29e640699f8 100644 (file)
@@ -115,7 +115,7 @@ static void _nbu2ss_dump_register(struct nbu2ss_udc *udc)
        pr_info("=== %s()\n", __func__);
 
        if (udc == NULL) {
-               ERR("%s udc == NULL\n", __func__);
+               pr_err("%s udc == NULL\n", __func__);
                return;
        }
 
@@ -201,7 +201,7 @@ static u32 _nbu2ss_get_begin_ram_address(struct nbu2ss_udc *udc)
        u32             num, buf_type;
        u32             data, last_ram_adr, use_ram_size;
 
-       PT_EP_REGS      p_ep_regs;
+       struct ep_regs *p_ep_regs;
 
        last_ram_adr = (D_RAM_SIZE_CTRL / sizeof(u32)) * 2;
        use_ram_size = 0;
@@ -394,7 +394,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep)
 {
        u32             num;
        u32             data;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (udc->vbus_active == 0)
                return;         /* VBUS OFF */
@@ -425,7 +425,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep)
 /* Abort DMA */
 static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep)
 {
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        _nbu2ss_bitclr(&preg->EP_DCR[ep->epnum-1].EP_DCR1, DCR1_EPn_REQEN);
        mdelay(DMA_DISABLE_TIME);       /* DCR1_EPn_REQEN Clear */
@@ -443,7 +443,7 @@ static void _nbu2ss_ep_in_end(
 {
        u32             data;
        u32             num;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (length >= sizeof(u32))
                return;
@@ -567,7 +567,7 @@ static int EP0_out_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
        u32             i;
        int             nret   = 0;
        u32             iWordLength = 0;
-       USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
+       union usb_reg_access *pBuf32 = (union usb_reg_access *)pBuf;
 
        /*------------------------------------------------------------*/
        /* Read Length */
@@ -592,8 +592,8 @@ static int EP0_out_OverBytes(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 {
        u32             i;
        u32             iReadSize = 0;
-       USB_REG_ACCESS  Temp32;
-       USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
+       union usb_reg_access  Temp32;
+       union usb_reg_access  *pBuf32 = (union usb_reg_access *)pBuf;
 
        if ((0 < length) && (length < sizeof(u32))) {
                Temp32.dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
@@ -613,7 +613,7 @@ static int EP0_in_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
        u32             iMaxLength   = EP0_PACKETSIZE;
        u32             iWordLength  = 0;
        u32             iWriteLength = 0;
-       USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
+       union usb_reg_access  *pBuf32 = (union usb_reg_access *)pBuf;
 
        /*------------------------------------------------------------*/
        /* Transfer Length */
@@ -638,8 +638,8 @@ static int EP0_in_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 static int EP0_in_OverBytes(struct nbu2ss_udc *udc, u8 *pBuf, u32 iRemainSize)
 {
        u32             i;
-       USB_REG_ACCESS Temp32;
-       USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
+       union usb_reg_access  Temp32;
+       union usb_reg_access  *pBuf32 = (union usb_reg_access *)pBuf;
 
        if ((0 < iRemainSize) && (iRemainSize < sizeof(u32))) {
                for (i = 0 ; i < iRemainSize ; i++)
@@ -808,7 +808,7 @@ static int _nbu2ss_ep0_out_transfer(
                return 0;               /* Short Packet Transfer End */
 
        if (req->req.actual > req->req.length) {
-               ERR(" *** Overrun Error\n");
+               dev_err(udc->dev, " *** Overrun Error\n");
                return -EOVERFLOW;
        }
 
@@ -840,7 +840,7 @@ static int _nbu2ss_out_dma(
        u32             burst = 1;
        u32             data;
        int             result = -EINVAL;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (req->dma_flag)
                return 1;               /* DMA is forwarded */
@@ -900,10 +900,10 @@ static int _nbu2ss_epn_out_pio(
        u32             i;
        u32             data;
        u32             iWordLength;
-       USB_REG_ACCESS  Temp32;
-       USB_REG_ACCESS  *pBuf32;
+       union usb_reg_access    Temp32;
+       union usb_reg_access    *pBuf32;
        int             result = 0;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (req->dma_flag)
                return 1;               /* DMA is forwarded */
@@ -912,7 +912,7 @@ static int _nbu2ss_epn_out_pio(
                return 0;
 
        pBuffer = (u8 *)req->req.buf;
-       pBuf32 = (USB_REG_ACCESS *)(pBuffer + req->req.actual);
+       pBuf32 = (union usb_reg_access *)(pBuffer + req->req.actual);
 
        iWordLength = length / sizeof(u32);
        if (iWordLength > 0) {
@@ -988,7 +988,7 @@ static int _nbu2ss_epn_out_transfer(
        u32             num;
        u32             iRecvLength;
        int             result = 1;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (ep->epnum == 0)
                return -EINVAL;
@@ -1026,8 +1026,8 @@ static int _nbu2ss_epn_out_transfer(
        }
 
        if (req->req.actual > req->req.length) {
-               ERR(" *** Overrun Error\n");
-               ERR(" *** actual = %d, length = %d\n",
+               dev_err(udc->dev, " Overrun Error\n");
+               dev_err(udc->dev, " actual = %d, length = %d\n",
                        req->req.actual, req->req.length);
                result = -EOVERFLOW;
        }
@@ -1051,7 +1051,7 @@ static int _nbu2ss_in_dma(
        u32             iWriteLength;
        u32             data;
        int             result = -EINVAL;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (req->dma_flag)
                return 1;               /* DMA is forwarded */
@@ -1123,17 +1123,17 @@ static int _nbu2ss_epn_in_pio(
        u32             i;
        u32             data;
        u32             iWordLength;
-       USB_REG_ACCESS  Temp32;
-       USB_REG_ACCESS  *pBuf32 = NULL;
+       union usb_reg_access    Temp32;
+       union usb_reg_access    *pBuf32 = NULL;
        int             result = 0;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (req->dma_flag)
                return 1;               /* DMA is forwarded */
 
        if (length > 0) {
                pBuffer = (u8 *)req->req.buf;
-               pBuf32 = (USB_REG_ACCESS *)(pBuffer + req->req.actual);
+               pBuf32 = (union usb_reg_access *)(pBuffer + req->req.actual);
 
                iWordLength = length / sizeof(u32);
                if (iWordLength > 0) {
@@ -1347,7 +1347,7 @@ static void _nbu2ss_set_endpoint_stall(
        u8              num, epnum;
        u32             data;
        struct nbu2ss_ep *ep;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if ((ep_adrs == 0) || (ep_adrs == 0x80)) {
                if (bstall) {
@@ -1426,7 +1426,7 @@ static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode)
        if (mode > MAX_TEST_MODE_NUM)
                return;
 
-       pr_info("SET FEATURE : test mode = %d\n", mode);
+       dev_info(udc->dev, "SET FEATURE : test mode = %d\n", mode);
 
        data = _nbu2ss_readl(&udc->p_regs->USB_CONTROL);
        data &= ~TEST_FORCE_ENABLE;
@@ -1454,7 +1454,7 @@ static int _nbu2ss_set_feature_device(
                break;
 
        case USB_DEVICE_TEST_MODE:
-               wIndex = wIndex >> 8;
+               wIndex >>= 8;
                if (wIndex <= MAX_TEST_MODE_NUM)
                        result = 0;
                break;
@@ -1471,7 +1471,7 @@ static int _nbu2ss_get_ep_stall(struct nbu2ss_udc *udc, u8 ep_adrs)
 {
        u8              epnum;
        u32             data = 0, bit_data;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        epnum = ep_adrs & ~USB_ENDPOINT_DIR_MASK;
        if (epnum == 0) {
@@ -1566,7 +1566,7 @@ static void _nbu2ss_epn_set_stall(
        u32     regdata;
        int     limit_cnt = 0;
 
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (ep->direct == USB_DIR_IN) {
                for (limit_cnt = 0
@@ -1638,7 +1638,7 @@ static int std_req_get_status(struct nbu2ss_udc *udc)
                _nbu2ss_ep0_in_transfer(udc, &udc->ep[0], &udc->ep0_req);
 
        } else {
-               ERR("*** Error GET_STATUS\n");
+               dev_err(udc->dev, " Error GET_STATUS\n");
        }
 
        return result;
@@ -1671,7 +1671,7 @@ static int std_req_set_address(struct nbu2ss_udc *udc)
        if (wValue != (wValue & 0x007F))
                return -EINVAL;
 
-       wValue = wValue << USB_ADRS_SHIFT;
+       wValue <<= USB_ADRS_SHIFT;
 
        _nbu2ss_writel(&udc->p_regs->USB_ADDRESS, wValue);
        _nbu2ss_create_ep0_packet(udc, udc->ep0_buf, 0);
@@ -1885,8 +1885,8 @@ static inline void _nbu2ss_ep0_int(struct nbu2ss_udc *udc)
                        | STG_END_INT | EP0_OUT_NULL_INT);
 
        if (status == 0) {
-               pr_info("--- %s Not Decode Interrupt\n", __func__);
-               pr_info("--- EP0_STATUS = 0x%08x\n", intr);
+               dev_info(udc->dev, "%s Not Decode Interrupt\n", __func__);
+               dev_info(udc->dev, "EP0_STATUS = 0x%08x\n", intr);
                return;
        }
 
@@ -1994,7 +1994,7 @@ static inline void _nbu2ss_epn_in_int(
        int     result = 0;
        u32     status;
 
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (req->dma_flag)
                return;         /* DMA is forwarded */
@@ -2090,7 +2090,7 @@ static inline void _nbu2ss_epn_out_dma_int(
        u32             num;
        u32             dmacnt, ep_dmacnt;
        u32             mpkt;
-       PT_FC_REGS      preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        num = ep->epnum - 1;
 
@@ -2229,8 +2229,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
                return 0;
 
        /* called with irqs blocked */
-       while (!list_empty(&ep->queue)) {
-               req = list_entry(ep->queue.next, struct nbu2ss_req, queue);
+       list_for_each_entry(req, &ep->queue, queue) {
                _nbu2ss_ep_done(ep, req, status);
        }
 
@@ -2257,11 +2256,6 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on)
 {
        u32     reg_dt;
 
-       if (!udc) {
-               ERR("%s, bad param\n", __func__);
-               return -EINVAL;
-       }
-
        if (udc->vbus_active == 0)
                return -ESHUTDOWN;
 
@@ -2293,7 +2287,7 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on)
 /*-------------------------------------------------------------------------*/
 static void _nbu2ss_fifo_flush(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep)
 {
-       PT_FC_REGS      p = udc->p_regs;
+       struct fc_regs  *p = udc->p_regs;
 
        if (udc->vbus_active == 0)
                return;
@@ -2350,7 +2344,7 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc)
                waitcnt++;
                udelay(1);      /* 1us wait */
                if (waitcnt == EPC_PLL_LOCK_COUNT) {
-                       ERR("*** Reset Cancel failed\n");
+                       dev_err(udc->dev, "*** Reset Cancel failed\n");
                        return -EINVAL;
                }
        };
@@ -2412,7 +2406,7 @@ static inline void _nbu2ss_check_vbus(struct nbu2ss_udc *udc)
                udc->linux_suspended = 0;
 
                _nbu2ss_reset_controller(udc);
-               pr_info(" ----- VBUS OFF\n");
+               dev_info(udc->dev, " ----- VBUS OFF\n");
 
                if (udc->vbus_active == 1) {
                        /* VBUS OFF */
@@ -2438,7 +2432,7 @@ static inline void _nbu2ss_check_vbus(struct nbu2ss_udc *udc)
                if (reg_dt == 0)
                        return;
 
-               pr_info(" ----- VBUS ON\n");
+               dev_info(udc->dev, " ----- VBUS ON\n");
 
                if (udc->linux_suspended)
                        return;
@@ -2536,7 +2530,7 @@ static irqreturn_t _nbu2ss_udc_irq(int irq, void *_udc)
        u32     epnum, int_bit;
 
        struct nbu2ss_udc       *udc = (struct nbu2ss_udc *)_udc;
-       PT_FC_REGS              preg = udc->p_regs;
+       struct fc_regs  *preg = udc->p_regs;
 
        if (gpio_get_value(VBUS_VALUE) == 0) {
                _nbu2ss_writel(&preg->USB_INT_STA, ~USB_INT_STA_RW);
@@ -2612,13 +2606,13 @@ static int nbu2ss_ep_enable(
        struct nbu2ss_udc       *udc;
 
        if ((_ep == NULL) || (desc == NULL)) {
-               ERR(" *** %s, bad param\n", __func__);
+               pr_err(" *** %s, bad param\n", __func__);
                return -EINVAL;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if ((ep == NULL) || (ep->udc == NULL)) {
-               ERR(" *** %s, ep == NULL !!\n", __func__);
+               pr_err(" *** %s, ep == NULL !!\n", __func__);
                return -EINVAL;
        }
 
@@ -2626,7 +2620,7 @@ static int nbu2ss_ep_enable(
        if ((ep_type == USB_ENDPOINT_XFER_CONTROL)
                || (ep_type == USB_ENDPOINT_XFER_ISOC)) {
 
-               ERR(" *** %s, bat bmAttributes\n", __func__);
+               pr_err(" *** %s, bat bmAttributes\n", __func__);
                return -EINVAL;
        }
 
@@ -2637,7 +2631,7 @@ static int nbu2ss_ep_enable(
        if ((udc->driver == NULL)
                || (udc->gadget.speed == USB_SPEED_UNKNOWN)) {
 
-               ERR(" *** %s, udc !!\n", __func__);
+               dev_err(ep->udc->dev, " *** %s, udc !!\n", __func__);
                return -ESHUTDOWN;
        }
 
@@ -2672,13 +2666,13 @@ static int nbu2ss_ep_disable(struct usb_ep *_ep)
        unsigned long           flags;
 
        if (_ep == NULL) {
-               ERR(" *** %s, bad param\n", __func__);
+               pr_err(" *** %s, bad param\n", __func__);
                return -EINVAL;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if ((ep == NULL) || (ep->udc == NULL)) {
-               ERR(" *** %s, ep == NULL !!\n", __func__);
+               pr_err("udc: *** %s, ep == NULL !!\n", __func__);
                return -EINVAL;
        }
 
@@ -2742,10 +2736,10 @@ static int nbu2ss_ep_queue(
        /* catch various bogus parameters */
        if ((_ep == NULL) || (_req == NULL)) {
                if (_ep == NULL)
-                       ERR("*** %s --- _ep == NULL\n", __func__);
+                       pr_err("udc: %s --- _ep == NULL\n", __func__);
 
                if (_req == NULL)
-                       ERR("*** %s --- _req == NULL\n", __func__);
+                       pr_err("udc: %s --- _req == NULL\n", __func__);
 
                return -EINVAL;
        }
@@ -2756,13 +2750,13 @@ static int nbu2ss_ep_queue(
             || !list_empty(&req->queue))) {
 
                if (!_req->complete)
-                       ERR("*** %s --- !_req->complete\n", __func__);
+                       pr_err("udc: %s --- !_req->complete\n", __func__);
 
                if (!_req->buf)
-                       ERR("*** %s --- !_req->buf\n", __func__);
+                       pr_err("udc:%s --- !_req->buf\n", __func__);
 
                if (!list_empty(&req->queue))
-                       ERR("*** %s --- !list_empty(&req->queue)\n", __func__);
+                       pr_err("%s --- !list_empty(&req->queue)\n", __func__);
 
                return -EINVAL;
        }
@@ -2773,12 +2767,13 @@ static int nbu2ss_ep_queue(
 /*     INFO("=== %s(ep%d), zero=%d\n", __func__, ep->epnum, _req->zero); */
 
        if (udc->vbus_active == 0) {
-               pr_info("Can't ep_queue (VBUS OFF)\n");
+               dev_info(udc->dev, "Can't ep_queue (VBUS OFF)\n");
                return -ESHUTDOWN;
        }
 
        if (unlikely(!udc->driver)) {
-               ERR("%s, bogus device state %p\n", __func__, udc->driver);
+               dev_err(udc->dev, "%s, bogus device state %p\n", __func__,
+                               udc->driver);
                return -ESHUTDOWN;
        }
 
@@ -2794,7 +2789,7 @@ static int nbu2ss_ep_queue(
                if (ep->virt_buf == NULL)
                        ep->virt_buf = (u8 *)dma_alloc_coherent(
                                NULL, PAGE_SIZE,
-                               &ep->phys_buf, GFP_KERNEL | GFP_DMA);
+                               &ep->phys_buf, GFP_ATOMIC | GFP_DMA);
                if (ep->epnum > 0)  {
                        if (ep->direct == USB_DIR_IN)
                                memcpy(ep->virt_buf, req->req.buf,
@@ -2817,7 +2812,8 @@ static int nbu2ss_ep_queue(
 
                result = _nbu2ss_start_transfer(udc, ep, req, FALSE);
                if (result < 0) {
-                       ERR(" *** %s, result = %d\n", __func__, result);
+                       dev_err(udc->dev, " *** %s, result = %d\n", __func__,
+                                       result);
                        list_del(&req->queue);
                } else if ((ep->epnum > 0) && (ep->direct == USB_DIR_OUT)) {
 #ifdef USE_DMA
@@ -2849,13 +2845,13 @@ static int nbu2ss_ep_dequeue(
 
        /* catch various bogus parameters */
        if ((_ep == NULL) || (_req == NULL)) {
-               /* ERR("%s, bad param(1)\n", __func__); */
+               /* pr_err("%s, bad param(1)\n", __func__); */
                return -EINVAL;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if (!ep) {
-               ERR("%s, ep == NULL !!\n", __func__);
+               pr_err("%s, ep == NULL !!\n", __func__);
                return -EINVAL;
        }
 
@@ -2895,19 +2891,19 @@ static int nbu2ss_ep_set_halt(struct usb_ep *_ep, int value)
 /*     INFO("=== %s()\n", __func__); */
 
        if (!_ep) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if (!ep) {
-               ERR("%s, bad ep\n", __func__);
+               pr_err("%s, bad ep\n", __func__);
                return -EINVAL;
        }
 
        udc = ep->udc;
        if (!udc) {
-               ERR(" *** %s, bad udc\n", __func__);
+               dev_err(ep->udc->dev, " *** %s, bad udc\n", __func__);
                return -EINVAL;
        }
 
@@ -2944,24 +2940,24 @@ static int nbu2ss_ep_fifo_status(struct usb_ep *_ep)
        struct nbu2ss_ep        *ep;
        struct nbu2ss_udc       *udc;
        unsigned long           flags;
-       PT_FC_REGS              preg;
+       struct fc_regs          *preg;
 
 /*     INFO("=== %s()\n", __func__); */
 
        if (!_ep) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if (!ep) {
-               ERR("%s, bad ep\n", __func__);
+               pr_err("%s, bad ep\n", __func__);
                return -EINVAL;
        }
 
        udc = ep->udc;
        if (!udc) {
-               ERR("%s, bad udc\n", __func__);
+               dev_err(ep->udc->dev, "%s, bad udc\n", __func__);
                return -EINVAL;
        }
 
@@ -2997,19 +2993,19 @@ static void  nbu2ss_ep_fifo_flush(struct usb_ep *_ep)
 /*     INFO("=== %s()\n", __func__); */
 
        if (!_ep) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("udc: %s, bad param\n", __func__);
                return;
        }
 
        ep = container_of(_ep, struct nbu2ss_ep, ep);
        if (!_ep) {
-               ERR("%s, bad ep\n", __func__);
+               pr_err("udc: %s, bad ep\n", __func__);
                return;
        }
 
        udc = ep->udc;
        if (!udc) {
-               ERR("%s, bad udc\n", __func__);
+               dev_err(ep->udc->dev, "%s, bad udc\n", __func__);
                return;
        }
 
@@ -3053,13 +3049,13 @@ static int nbu2ss_gad_get_frame(struct usb_gadget *pgadget)
 /*     INFO("=== %s()\n", __func__); */
 
        if (pgadget == NULL) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("udc: %s, bad param\n", __func__);
                return -EINVAL;
        }
 
        udc = container_of(pgadget, struct nbu2ss_udc, gadget);
        if (udc == NULL) {
-               ERR("%s, udc == NULL\n", __func__);
+               dev_err(&pgadget->dev, "%s, udc == NULL\n", __func__);
                return -EINVAL;
        }
 
@@ -3083,19 +3079,19 @@ static int nbu2ss_gad_wakeup(struct usb_gadget *pgadget)
 /*     INFO("=== %s()\n", __func__); */
 
        if (pgadget == NULL) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
        udc = container_of(pgadget, struct nbu2ss_udc, gadget);
        if (udc == NULL) {
-               ERR("%s, udc == NULL\n", __func__);
+               dev_err(&pgadget->dev, "%s, udc == NULL\n", __func__);
                return -EINVAL;
        }
 
        data = gpio_get_value(VBUS_VALUE);
        if (data == 0) {
-               pr_warn("VBUS LEVEL = %d\n", data);
+               dev_warn(&pgadget->dev, "VBUS LEVEL = %d\n", data);
                return -EINVAL;
        }
 
@@ -3123,7 +3119,7 @@ static int nbu2ss_gad_set_selfpowered(struct usb_gadget *pgadget,
 /*     INFO("=== %s()\n", __func__); */
 
        if (pgadget == NULL) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
@@ -3152,7 +3148,7 @@ static int nbu2ss_gad_vbus_draw(struct usb_gadget *pgadget, unsigned mA)
 /*     INFO("=== %s()\n", __func__); */
 
        if (pgadget == NULL) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
@@ -3174,7 +3170,7 @@ static int nbu2ss_gad_pullup(struct usb_gadget *pgadget, int is_on)
 /*     INFO("=== %s()\n", __func__); */
 
        if (pgadget == NULL) {
-               ERR("%s, bad param\n", __func__);
+               pr_err("%s, bad param\n", __func__);
                return -EINVAL;
        }
 
@@ -3341,11 +3337,11 @@ static int nbu2ss_drv_probe(struct platform_device *pdev)
                                  0, driver_name, udc);
 
        /* IO Memory */
-       udc->p_regs = (PT_FC_REGS)mmio_base;
+       udc->p_regs = (struct fc_regs *)mmio_base;
 
        /* USB Function Controller Interrupt */
        if (status != 0) {
-               ERR("request_irq(USB_UDC_IRQ_1) failed\n");
+               dev_err(udc->dev, "request_irq(USB_UDC_IRQ_1) failed\n");
                goto cleanup1;
        }
 
@@ -3365,7 +3361,7 @@ static int nbu2ss_drv_probe(struct platform_device *pdev)
                                udc);
 
        if (status != 0) {
-               ERR("request_irq(INT_VBUS) failed\n");
+               dev_err(udc->dev, "request_irq(INT_VBUS) failed\n");
                goto cleanup1;
        }
 
index 202e2dc72bba4d6605eddafbf1e343f3a6bb47fc..c19168f7835461c8bf08902965c4f6119924489f 100644 (file)
 
 /*===========================================================================*/
 /* Struct */
-/*------- T_EP_REGS */
-typedef struct _T_EP_REGS {
+/*------- ep_regs */
+struct ep_regs {
        u32 EP_CONTROL;                 /* EP Control */
        u32 EP_STATUS;                  /* EP Status */
        u32 EP_INT_ENA;                 /* EP Interrupt Enable */
@@ -484,18 +484,18 @@ typedef struct _T_EP_REGS {
        u32 EP_LEN_DCNT;                /* EP Length & DMA count */
        u32 EP_READ;                    /* EP Read */
        u32 EP_WRITE;                   /* EP Write */
-} T_EP_REGS, *PT_EP_REGS;
+};
 
-/*------- T_EP_DCR */
-typedef struct _T_EP_DCR {
+/*------- ep_dcr */
+struct ep_dcr {
        u32 EP_DCR1;                    /* EP_DCR1 */
        u32 EP_DCR2;                    /* EP_DCR2 */
        u32 EP_TADR;                    /* EP_TADR */
        u32 Reserved;                   /* Reserved */
-} T_EP_DCR, *PT_EP_DCR;
+};
 
 /*------- Function Registers */
-typedef struct _T_FC_REGS {
+struct fc_regs {
        u32 USB_CONTROL;                /* (0x0000) USB Control */
        u32 USB_STATUS;                 /* (0x0004) USB Status */
        u32 USB_ADDRESS;                /* (0x0008) USB Address */
@@ -513,7 +513,7 @@ typedef struct _T_FC_REGS {
        u32 EP0_READ;                   /* (0x0038) EP0 Read */
        u32 EP0_WRITE;                  /* (0x003C) EP0 Write */
 
-       T_EP_REGS EP_REGS[REG_EP_NUM];  /* Endpoint Register */
+       struct ep_regs EP_REGS[REG_EP_NUM];     /* Endpoint Register */
 
        u8 Reserved220[0x1000-0x220];   /* (0x0220:0x0FFF) Reserved */
 
@@ -531,11 +531,10 @@ typedef struct _T_FC_REGS {
 
        u8 Reserved1028[0x110-0x28];    /* (0x1028:0x110F) Reserved */
 
-       T_EP_DCR EP_DCR[REG_EP_NUM];    /* */
+       struct ep_dcr EP_DCR[REG_EP_NUM];       /* */
 
        u8 Reserved1200[0x1000-0x200];  /* Reserved */
-
-} __attribute__ ((aligned(32))) T_FC_REGS, *PT_FC_REGS;
+} __aligned(32);
 
 
 
@@ -631,18 +630,17 @@ struct nbu2ss_udc {
 
        u32             curr_config;    /* Current Configuration Number */
 
-       PT_FC_REGS              p_regs;
+       struct fc_regs          *p_regs;
 };
 
 /* USB register access structure */
-typedef volatile union {
+union usb_reg_access {
        struct {
                unsigned char   DATA[4];
        } byte;
        unsigned int            dw;
-} USB_REG_ACCESS;
+};
 
 /*-------------------------------------------------------------------------*/
-#define ERR(stuff...)          printk(KERN_ERR "udc: " stuff)
 
 #endif  /* _LINUX_EMXX_H */
index bc89b5805f7bcf15beefc08656e3dcd608af4a39..ba4c74c92e4c3eff8c9b9b9f3c776703ba443d50 100644 (file)
@@ -9,20 +9,20 @@ Development is done on a Raspberry Pi running the Raspbian "wheezy" distribution
 INSTALLATION
   Download kernel sources
 
-  From Linux 3.15  
+  From Linux 3.15
     cd drivers/video/fbdev/fbtft
     git clone https://github.com/notro/fbtft.git
-    
+
     Add to drivers/video/fbdev/Kconfig:   source "drivers/video/fbdev/fbtft/Kconfig"
     Add to drivers/video/fbdev/Makefile:  obj-y += fbtft/
-  
-  Before Linux 3.15  
+
+  Before Linux 3.15
     cd drivers/video
     git clone https://github.com/notro/fbtft.git
-    
+
     Add to drivers/video/Kconfig:   source "drivers/video/fbtft/Kconfig"
     Add to drivers/video/Makefile:  obj-y += fbtft/
-  
+
   Enable driver(s) in menuconfig and build the kernel
 
 
index 9cc7d25cf0e5cbfd3e188c62e92d9893b2f79980..939b7b963043d4d0a1558a896dcb6738d71b39e6 100644 (file)
@@ -198,8 +198,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 
        if (*buf > 1) {
                va_end(args);
-               dev_err(par->info->device, "%s: Incorrect chip sellect request (%d)\n",
-                       __func__, *buf);
+               dev_err(par->info->device,
+                       "Incorrect chip sellect request (%d)\n", *buf);
                return;
        }
 
@@ -224,8 +224,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
                ret = par->fbtftops.write(par, par->buf, len * (sizeof(u8)));
                if (ret < 0) {
                        va_end(args);
-                       dev_err(par->info->device, "%s: write() failed and returned %d\n",
-                               __func__, ret);
+                       dev_err(par->info->device,
+                               "write() failed and returned %d\n", ret);
                        return;
                }
        }
@@ -282,6 +282,9 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        signed short *convert_buf = kmalloc(par->info->var.xres *
                par->info->var.yres * sizeof(signed short), GFP_NOIO);
 
+       if (!convert_buf)
+               return -ENOMEM;
+
        fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s()\n", __func__);
 
        /* converting to grayscale16 */
@@ -376,8 +379,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
                        ret = par->fbtftops.write(par, buf, len);
                        if (ret < 0)
                                dev_err(par->info->device,
-                                       "%s: write failed and returned: %d\n",
-                                       __func__, ret);
+                                       "write failed and returned: %d\n",
+                                       ret);
                }
                /* right half of display */
                if (addr_win.xe >= par->info->var.xres / 2) {
@@ -390,7 +393,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
                        /* select right side (sc1)
                         * set addr
                         */
-                       write_reg(par, 0x01, (1 << 6));
+                       write_reg(par, 0x01, 1 << 6);
                        write_reg(par, 0x01, (0x17 << 3) | (u8)y);
 
                        /* write bitmap */
@@ -398,8 +401,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
                        par->fbtftops.write(par, buf, len);
                        if (ret < 0)
                                dev_err(par->info->device,
-                                       "%s: write failed and returned: %d\n",
-                                       __func__, ret);
+                                       "write failed and returned: %d\n",
+                                       ret);
                }
        }
        kfree(convert_buf);
index 7e00c609c7fe22f8611a320fe7c313b30ed804e9..17a2162a7e5b10f08ab0d29d88fc7f7f23d5a904 100644 (file)
@@ -47,49 +47,49 @@ static int init_display(struct fbtft_par *par)
        /* Initialization sequence from Lib_UTFT */
 
        /* oscillator start */
-       write_reg(par, 0x000,0x0001);   /*oscillator 0: stop, 1: operation */
+       write_reg(par, 0x000, 0x0001);  /*oscillator 0: stop, 1: operation */
        mdelay(10);
 
        /* Power settings */
-       write_reg(par, 0x100, 0x0000 ); /* power supply setup */
-       write_reg(par, 0x101, 0x0000 );
-       write_reg(par, 0x102, 0x3110 );
-       write_reg(par, 0x103, 0xe200 );
-       write_reg(par, 0x110, 0x009d );
-       write_reg(par, 0x111, 0x0022 );
-       write_reg(par, 0x100, 0x0120 );
-       mdelay( 20 );
-
-       write_reg(par, 0x100, 0x3120 );
-       mdelay( 80 );
+       write_reg(par, 0x100, 0x0000); /* power supply setup */
+       write_reg(par, 0x101, 0x0000);
+       write_reg(par, 0x102, 0x3110);
+       write_reg(par, 0x103, 0xe200);
+       write_reg(par, 0x110, 0x009d);
+       write_reg(par, 0x111, 0x0022);
+       write_reg(par, 0x100, 0x0120);
+       mdelay(20);
+
+       write_reg(par, 0x100, 0x3120);
+       mdelay(80);
        /* Display control */
-       write_reg(par, 0x001, 0x0100 );
-       write_reg(par, 0x002, 0x0000 );
-       write_reg(par, 0x003, 0x1230 );
-       write_reg(par, 0x006, 0x0000 );
-       write_reg(par, 0x007, 0x0101 );
-       write_reg(par, 0x008, 0x0808 );
-       write_reg(par, 0x009, 0x0000 );
-       write_reg(par, 0x00b, 0x0000 );
-       write_reg(par, 0x00c, 0x0000 );
-       write_reg(par, 0x00d, 0x0018 );
+       write_reg(par, 0x001, 0x0100);
+       write_reg(par, 0x002, 0x0000);
+       write_reg(par, 0x003, 0x1230);
+       write_reg(par, 0x006, 0x0000);
+       write_reg(par, 0x007, 0x0101);
+       write_reg(par, 0x008, 0x0808);
+       write_reg(par, 0x009, 0x0000);
+       write_reg(par, 0x00b, 0x0000);
+       write_reg(par, 0x00c, 0x0000);
+       write_reg(par, 0x00d, 0x0018);
        /* LTPS control settings */
-       write_reg(par, 0x012, 0x0000 );
-       write_reg(par, 0x013, 0x0000 );
-       write_reg(par, 0x018, 0x0000 );
-       write_reg(par, 0x019, 0x0000 );
-
-       write_reg(par, 0x203, 0x0000 );
-       write_reg(par, 0x204, 0x0000 );
-
-       write_reg(par, 0x210, 0x0000 );
-       write_reg(par, 0x211, 0x00ef );
-       write_reg(par, 0x212, 0x0000 );
-       write_reg(par, 0x213, 0x013f );
-       write_reg(par, 0x214, 0x0000 );
-       write_reg(par, 0x215, 0x0000 );
-       write_reg(par, 0x216, 0x0000 );
-       write_reg(par, 0x217, 0x0000 );
+       write_reg(par, 0x012, 0x0000);
+       write_reg(par, 0x013, 0x0000);
+       write_reg(par, 0x018, 0x0000);
+       write_reg(par, 0x019, 0x0000);
+
+       write_reg(par, 0x203, 0x0000);
+       write_reg(par, 0x204, 0x0000);
+
+       write_reg(par, 0x210, 0x0000);
+       write_reg(par, 0x211, 0x00ef);
+       write_reg(par, 0x212, 0x0000);
+       write_reg(par, 0x213, 0x013f);
+       write_reg(par, 0x214, 0x0000);
+       write_reg(par, 0x215, 0x0000);
+       write_reg(par, 0x216, 0x0000);
+       write_reg(par, 0x217, 0x0000);
 
        /* Gray scale settings */
        write_reg(par, 0x300, 0x5343);
@@ -104,18 +104,18 @@ static int init_display(struct fbtft_par *par)
        write_reg(par, 0x309, 0x050a);
 
        /* RAM access settings */
-       write_reg(par, 0x400, 0x4027 );
-       write_reg(par, 0x401, 0x0000 );
-       write_reg(par, 0x402, 0x0000 );  /* First screen drive position (1) */
-       write_reg(par, 0x403, 0x013f );  /* First screen drive position (2) */
-       write_reg(par, 0x404, 0x0000 );
-
-       write_reg(par, 0x200, 0x0000 );
-       write_reg(par, 0x201, 0x0000 );
-       write_reg(par, 0x100, 0x7120 );
-       write_reg(par, 0x007, 0x0103 );
-       mdelay( 10 );
-       write_reg(par, 0x007, 0x0113 );
+       write_reg(par, 0x400, 0x4027);
+       write_reg(par, 0x401, 0x0000);
+       write_reg(par, 0x402, 0x0000);  /* First screen drive position (1) */
+       write_reg(par, 0x403, 0x013f);  /* First screen drive position (2) */
+       write_reg(par, 0x404, 0x0000);
+
+       write_reg(par, 0x200, 0x0000);
+       write_reg(par, 0x201, 0x0000);
+       write_reg(par, 0x100, 0x7120);
+       write_reg(par, 0x007, 0x0103);
+       mdelay(10);
+       write_reg(par, 0x007, 0x0113);
 
        return 0;
 }
index 3939502f2c81c3d4afe2077819f0bba1326c43df..53edf253ed63a7619a3f2d1a159832401b3552a1 100644 (file)
@@ -47,8 +47,6 @@ MODULE_PARM_DESC(emulate, "Force emulation in 9-bit mode");
 
 static int init_display(struct fbtft_par *par)
 {
-       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
-
        par->fbtftops.reset(par);
 
        /* BTL221722-276L startup sequence, from datasheet */
@@ -108,11 +106,8 @@ static int init_display(struct fbtft_par *par)
        return 0;
 }
 
-void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
+static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
 {
-       fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par,
-               "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye);
-
        write_reg(par, FBTFT_CASET, 0x00, xs, 0x00, xe);
        write_reg(par, FBTFT_RASET, 0x00, ys, 0x00, ye);
        write_reg(par, FBTFT_RAMWR);
@@ -120,8 +115,6 @@ void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
 
 static int set_var(struct fbtft_par *par)
 {
-       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
-
        /* MADCTL - Memory data access control */
        /* RGB/BGR can be set with H/W pin SRGB and MADCTL BGR bit */
 #define MY (1 << 7)
@@ -129,7 +122,7 @@ static int set_var(struct fbtft_par *par)
 #define MV (1 << 5)
        switch (par->info->var.rotate) {
        case 0:
-               write_reg(par, 0x36, (par->bgr << 3));
+               write_reg(par, 0x36, par->bgr << 3);
                break;
        case 270:
                write_reg(par, 0x36, MX | MV | (par->bgr << 3));
@@ -162,8 +155,6 @@ static int set_gamma(struct fbtft_par *par, unsigned long *curves)
                0b111, 0b111, 0b111, 0b111, 0b111, 0b111, 0b0, 0b0 };
        int i, j;
 
-       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
-
        /* apply mask */
        for (i = 0; i < par->gamma.num_curves; i++)
                for (j = 0; j < par->gamma.num_values; j++)
index c9512dc5f4d349478cac23ead77286a9351904b9..ca52465715d2fe62bc5ce0807453566cb12f44ee 100644 (file)
@@ -112,7 +112,7 @@ static int set_var(struct fbtft_par *par)
                write_reg(par, 0x36, my | mv | (par->bgr << 3));
                break;
        case 180:
-               write_reg(par, 0x36, (par->bgr << 3));
+               write_reg(par, 0x36, par->bgr << 3);
                break;
        case 90:
                write_reg(par, 0x36, mx | mv | (par->bgr << 3));
index b26d89368da7ca831192e7c322d5de8cc8424e4c..880f548158e68be8bd4999372958af1eeb1e1801 100644 (file)
@@ -47,6 +47,7 @@ static unsigned read_devicecode(struct fbtft_par *par)
 static int init_display(struct fbtft_par *par)
 {
        unsigned devcode;
+
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
 
        par->fbtftops.reset(par);
index 985687d94ec238622a29ce78d41051550a4e53b6..c8698710e10826c96c5f1dc6fa4067ffe0411d71 100644 (file)
@@ -39,12 +39,12 @@ static int init_display(struct fbtft_par *par)
        par->fbtftops.reset(par);
 
        write_reg(par, 0xEF, 0x03, 0x80, 0x02);
-       write_reg(par, 0xCF, 0x00 , 0XC1 , 0X30);
-       write_reg(par, 0xED, 0x64 , 0x03 , 0X12 , 0X81);
-       write_reg(par, 0xE8, 0x85 , 0x00 , 0x78);
-       write_reg(par, 0xCB, 0x39 , 0x2C , 0x00 , 0x34 , 0x02);
+       write_reg(par, 0xCF, 0x00, 0XC1, 0X30);
+       write_reg(par, 0xED, 0x64, 0x03, 0X12, 0X81);
+       write_reg(par, 0xE8, 0x85, 0x00, 0x78);
+       write_reg(par, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02);
        write_reg(par, 0xF7, 0x20);
-       write_reg(par, 0xEA, 0x00 , 0x00);
+       write_reg(par, 0xEA, 0x00, 0x00);
 
        /* Power Control 1 */
        write_reg(par, 0xC0, 0x23);
index 95b89999d32a840b3a4235dfc2427926975c0167..5ce3e201aac0afcd884697de62e57558a889bbb3 100644 (file)
@@ -44,13 +44,13 @@ static int default_init_sequence[] = {
        -1, 0xC5, 0x00, 0x00, 0x00, 0x00,
        /* PGAMCTRL(Positive Gamma Control) */
        -1, 0xE0, 0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98,
-                 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00,
+                 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00,
        /* NGAMCTRL(Negative Gamma Control) */
        -1, 0xE1, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75,
-                 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
+                 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
        /* Digital Gamma Control 1 */
        -1, 0xE2, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75,
-                 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
+                 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
        /* Sleep OUT */
        -1, 0x11,
        /* Display ON */
index 8b9ebfb49ef8e733c5d1030e9db54f314a68c6b0..b13162c3550819c98726b4a748663ab5f03eca23 100644 (file)
@@ -120,9 +120,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        for (x = 0; x < 84; x++) {
                for (y = 0; y < 6; y++) {
                        *buf = 0x00;
-                       for (i = 0; i < 8; i++) {
+                       for (i = 0; i < 8; i++)
                                *buf |= (vmem16[(y*8+i)*84+x] ? 1 : 0) << i;
-                       }
                        buf++;
                }
        }
@@ -131,7 +130,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        gpio_set_value(par->gpio.dc, 1);
        ret = par->fbtftops.write(par, par->txbuf.buf, 6*84);
        if (ret < 0)
-               dev_err(par->info->device, "%s: write failed and returned: %d\n", __func__, ret);
+               dev_err(par->info->device, "write failed and returned: %d\n",
+                       ret);
 
        return ret;
 }
index c323c06344fdeff47f73374e27769b7588959e41..e21af6c5a95fa3760dace0c7c74a98d307fb0ab4 100644 (file)
@@ -79,112 +79,112 @@ static int init_display(struct fbtft_par *par)
 
        if ((par->info->var.xres == 320) && (par->info->var.yres == 240)) {
                /* PLL clock frequency */
-               write_reg(par, 0x88 , 0x0A);
-               write_reg(par, 0x89 , 0x02);
+               write_reg(par, 0x88, 0x0A);
+               write_reg(par, 0x89, 0x02);
                mdelay(10);
                /* color deep / MCU Interface */
-               write_reg(par, 0x10 , 0x0C);
+               write_reg(par, 0x10, 0x0C);
                /* pixel clock period  */
-               write_reg(par, 0x04 , 0x03);
+               write_reg(par, 0x04, 0x03);
                mdelay(1);
                /* horizontal settings */
-               write_reg(par, 0x14 , 0x27);
-               write_reg(par, 0x15 , 0x00);
-               write_reg(par, 0x16 , 0x05);
-               write_reg(par, 0x17 , 0x04);
-               write_reg(par, 0x18 , 0x03);
+               write_reg(par, 0x14, 0x27);
+               write_reg(par, 0x15, 0x00);
+               write_reg(par, 0x16, 0x05);
+               write_reg(par, 0x17, 0x04);
+               write_reg(par, 0x18, 0x03);
                /* vertical settings */
-               write_reg(par, 0x19 , 0xEF);
-               write_reg(par, 0x1A , 0x00);
-               write_reg(par, 0x1B , 0x05);
-               write_reg(par, 0x1C , 0x00);
-               write_reg(par, 0x1D , 0x0E);
-               write_reg(par, 0x1E , 0x00);
-               write_reg(par, 0x1F , 0x02);
+               write_reg(par, 0x19, 0xEF);
+               write_reg(par, 0x1A, 0x00);
+               write_reg(par, 0x1B, 0x05);
+               write_reg(par, 0x1C, 0x00);
+               write_reg(par, 0x1D, 0x0E);
+               write_reg(par, 0x1E, 0x00);
+               write_reg(par, 0x1F, 0x02);
        } else if ((par->info->var.xres == 480) && (par->info->var.yres == 272)) {
                /* PLL clock frequency  */
-               write_reg(par, 0x88 , 0x0A);
-               write_reg(par, 0x89 , 0x02);
+               write_reg(par, 0x88, 0x0A);
+               write_reg(par, 0x89, 0x02);
                mdelay(10);
                /* color deep / MCU Interface */
-               write_reg(par, 0x10 , 0x0C);
+               write_reg(par, 0x10, 0x0C);
                /* pixel clock period  */
-               write_reg(par, 0x04 , 0x82);
+               write_reg(par, 0x04, 0x82);
                mdelay(1);
                /* horizontal settings */
-               write_reg(par, 0x14 , 0x3B);
-               write_reg(par, 0x15 , 0x00);
-               write_reg(par, 0x16 , 0x01);
-               write_reg(par, 0x17 , 0x00);
-               write_reg(par, 0x18 , 0x05);
+               write_reg(par, 0x14, 0x3B);
+               write_reg(par, 0x15, 0x00);
+               write_reg(par, 0x16, 0x01);
+               write_reg(par, 0x17, 0x00);
+               write_reg(par, 0x18, 0x05);
                /* vertical settings */
-               write_reg(par, 0x19 , 0x0F);
-               write_reg(par, 0x1A , 0x01);
-               write_reg(par, 0x1B , 0x02);
-               write_reg(par, 0x1C , 0x00);
-               write_reg(par, 0x1D , 0x07);
-               write_reg(par, 0x1E , 0x00);
-               write_reg(par, 0x1F , 0x09);
+               write_reg(par, 0x19, 0x0F);
+               write_reg(par, 0x1A, 0x01);
+               write_reg(par, 0x1B, 0x02);
+               write_reg(par, 0x1C, 0x00);
+               write_reg(par, 0x1D, 0x07);
+               write_reg(par, 0x1E, 0x00);
+               write_reg(par, 0x1F, 0x09);
        } else if ((par->info->var.xres == 640) && (par->info->var.yres == 480)) {
                /* PLL clock frequency */
-               write_reg(par, 0x88 , 0x0B);
-               write_reg(par, 0x89 , 0x02);
+               write_reg(par, 0x88, 0x0B);
+               write_reg(par, 0x89, 0x02);
                mdelay(10);
                /* color deep / MCU Interface */
-               write_reg(par, 0x10 , 0x0C);
+               write_reg(par, 0x10, 0x0C);
                /* pixel clock period */
-               write_reg(par, 0x04 , 0x01);
+               write_reg(par, 0x04, 0x01);
                mdelay(1);
                /* horizontal settings */
-               write_reg(par, 0x14 , 0x4F);
-               write_reg(par, 0x15 , 0x05);
-               write_reg(par, 0x16 , 0x0F);
-               write_reg(par, 0x17 , 0x01);
-               write_reg(par, 0x18 , 0x00);
+               write_reg(par, 0x14, 0x4F);
+               write_reg(par, 0x15, 0x05);
+               write_reg(par, 0x16, 0x0F);
+               write_reg(par, 0x17, 0x01);
+               write_reg(par, 0x18, 0x00);
                /* vertical settings */
-               write_reg(par, 0x19 , 0xDF);
-               write_reg(par, 0x1A , 0x01);
-               write_reg(par, 0x1B , 0x0A);
-               write_reg(par, 0x1C , 0x00);
-               write_reg(par, 0x1D , 0x0E);
-               write_reg(par, 0x1E , 0x00);
-               write_reg(par, 0x1F , 0x01);
+               write_reg(par, 0x19, 0xDF);
+               write_reg(par, 0x1A, 0x01);
+               write_reg(par, 0x1B, 0x0A);
+               write_reg(par, 0x1C, 0x00);
+               write_reg(par, 0x1D, 0x0E);
+               write_reg(par, 0x1E, 0x00);
+               write_reg(par, 0x1F, 0x01);
        } else if ((par->info->var.xres == 800) && (par->info->var.yres == 480)) {
                /* PLL clock frequency */
-               write_reg(par, 0x88 , 0x0B);
-               write_reg(par, 0x89 , 0x02);
+               write_reg(par, 0x88, 0x0B);
+               write_reg(par, 0x89, 0x02);
                mdelay(10);
                /* color deep / MCU Interface */
-               write_reg(par, 0x10 , 0x0C);
+               write_reg(par, 0x10, 0x0C);
                /* pixel clock period */
-               write_reg(par, 0x04 , 0x81);
+               write_reg(par, 0x04, 0x81);
                mdelay(1);
                /* horizontal settings */
-               write_reg(par, 0x14 , 0x63);
-               write_reg(par, 0x15 , 0x03);
-               write_reg(par, 0x16 , 0x03);
-               write_reg(par, 0x17 , 0x02);
-               write_reg(par, 0x18 , 0x00);
+               write_reg(par, 0x14, 0x63);
+               write_reg(par, 0x15, 0x03);
+               write_reg(par, 0x16, 0x03);
+               write_reg(par, 0x17, 0x02);
+               write_reg(par, 0x18, 0x00);
                /* vertical settings */
-               write_reg(par, 0x19 , 0xDF);
-               write_reg(par, 0x1A , 0x01);
-               write_reg(par, 0x1B , 0x14);
-               write_reg(par, 0x1C , 0x00);
-               write_reg(par, 0x1D , 0x06);
-               write_reg(par, 0x1E , 0x00);
-               write_reg(par, 0x1F , 0x01);
+               write_reg(par, 0x19, 0xDF);
+               write_reg(par, 0x1A, 0x01);
+               write_reg(par, 0x1B, 0x14);
+               write_reg(par, 0x1C, 0x00);
+               write_reg(par, 0x1D, 0x06);
+               write_reg(par, 0x1E, 0x00);
+               write_reg(par, 0x1F, 0x01);
        } else {
                dev_err(par->info->device, "display size is not supported!!");
                return -1;
        }
 
        /* PWM clock */
-       write_reg(par, 0x8a , 0x81);
-       write_reg(par, 0x8b , 0xFF);
+       write_reg(par, 0x8a, 0x81);
+       write_reg(par, 0x8b, 0xFF);
        mdelay(10);
 
        /* Display ON */
-       write_reg(par, 0x01 , 0x80);
+       write_reg(par, 0x01, 0x80);
        mdelay(10);
 
        return 0;
@@ -196,14 +196,14 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
                "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye);
 
        /* Set_Active_Window */
-       write_reg(par, 0x30 , xs & 0x00FF);
-       write_reg(par, 0x31 , (xs & 0xFF00) >> 8);
-       write_reg(par, 0x32 , ys & 0x00FF);
-       write_reg(par, 0x33 , (ys & 0xFF00) >> 8);
-       write_reg(par, 0x34 , (xs+xe) & 0x00FF);
-       write_reg(par, 0x35 , ((xs+xe) & 0xFF00) >> 8);
-       write_reg(par, 0x36 , (ys+ye) & 0x00FF);
-       write_reg(par, 0x37 , ((ys+ye) & 0xFF00) >> 8);
+       write_reg(par, 0x30, xs & 0x00FF);
+       write_reg(par, 0x31, (xs & 0xFF00) >> 8);
+       write_reg(par, 0x32, ys & 0x00FF);
+       write_reg(par, 0x33, (ys & 0xFF00) >> 8);
+       write_reg(par, 0x34, (xs+xe) & 0x00FF);
+       write_reg(par, 0x35, ((xs+xe) & 0xFF00) >> 8);
+       write_reg(par, 0x36, (ys+ye) & 0x00FF);
+       write_reg(par, 0x37, ((ys+ye) & 0xFF00) >> 8);
 
        /* Set_Memory_Write_Cursor */
        write_reg(par, 0x46,  xs & 0xff);
@@ -238,8 +238,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
        ret = par->fbtftops.write(par, par->buf, 2);
        if (ret < 0) {
                va_end(args);
-               dev_err(par->info->device, "%s: write() failed and returned %dn",
-                       __func__, ret);
+               dev_err(par->info->device, "write() failed and returned %dn",
+                       ret);
                return;
        }
        len--;
@@ -256,8 +256,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
                ret = par->fbtftops.write(par, par->buf, len + 1);
                if (ret < 0) {
                        va_end(args);
-                       dev_err(par->info->device, "%s: write() failed and returned %dn",
-                               __func__, ret);
+                       dev_err(par->info->device,
+                               "write() failed and returned %dn", ret);
                        return;
                }
        }
index e412a42443e5d2436e7bc9ecad190907fbcddbdb..c87aa253064d55f8962e57cbdae9c88ca6c07fd2 100644 (file)
@@ -136,7 +136,7 @@ static int set_var(struct fbtft_par *par)
                write_reg(par, 0x36, MY | MV | (par->bgr << 3));
                break;
        case 180:
-               write_reg(par, 0x36, (par->bgr << 3));
+               write_reg(par, 0x36, par->bgr << 3);
                break;
        case 90:
                write_reg(par, 0x36, MX | MV | (par->bgr << 3));
index 1ef8c1ad827e249260a99a841129dd381666fffa..7bbb21b28effafab928e689874fb4986d3574ff9 100644 (file)
@@ -143,7 +143,7 @@ static int set_var(struct fbtft_par *par)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 
+               0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
                0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
                0b11111, 0b11111,
                0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
index 5ea195b0de1b3de8ec39e0ef71ad73d92b6ca7ca..15ee44dd130bddfd282849631964b2cf23ea2d3c 100644 (file)
@@ -193,8 +193,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        ret = par->fbtftops.write(par, par->txbuf.buf,
                                par->info->var.xres*par->info->var.yres/8);
        if (ret < 0)
-               dev_err(par->info->device,
-                       "%s: write failed and returned: %d\n", __func__, ret);
+               dev_err(par->info->device, "write failed and returned: %d\n",
+                       ret);
 
        return ret;
 }
index da7464f90e37c93849b05224daeb494c61cb846b..5bb741046c85264104c4160f17d2b2be3d3d31e5 100644 (file)
@@ -29,24 +29,24 @@ static int init_display(struct fbtft_par *par)
 
        write_reg(par, 0xae); /* Display Off */
        write_reg(par, 0xa0, 0x70 | (par->bgr << 2)); /* Set Colour Depth */
-       write_reg(par, 0x72); // RGB colour
+       write_reg(par, 0x72); /* RGB colour */
        write_reg(par, 0xa1, 0x00); /* Set Display Start Line */
        write_reg(par, 0xa2, 0x00); /* Set Display Offset */
        write_reg(par, 0xa4); /* NORMALDISPLAY */
-       write_reg(par, 0xa8, 0x3f); // Set multiplex
-       write_reg(par, 0xad, 0x8e); // Set master
-       // write_reg(par, 0xb0, 0x0b); // Set power mode
-       write_reg(par, 0xb1, 0x31); // Precharge
-       write_reg(par, 0xb3, 0xf0); // Clock div
-       write_reg(par, 0x8a, 0x64); // Precharge A
-       write_reg(par, 0x8b, 0x78); // Precharge B
-       write_reg(par, 0x8c, 0x64); // Precharge C
-       write_reg(par, 0xbb, 0x3a); // Precharge level
-       write_reg(par, 0xbe, 0x3e); // vcomh
-       write_reg(par, 0x87, 0x06); // Master current
-       write_reg(par, 0x81, 0x91); // Contrast A
-       write_reg(par, 0x82, 0x50); // Contrast B
-       write_reg(par, 0x83, 0x7d); // Contrast C
+       write_reg(par, 0xa8, 0x3f); /* Set multiplex */
+       write_reg(par, 0xad, 0x8e); /* Set master */
+       /* write_reg(par, 0xb0, 0x0b);  Set power mode */
+       write_reg(par, 0xb1, 0x31); /* Precharge */
+       write_reg(par, 0xb3, 0xf0); /* Clock div */
+       write_reg(par, 0x8a, 0x64); /* Precharge A */
+       write_reg(par, 0x8b, 0x78); /* Precharge B */
+       write_reg(par, 0x8c, 0x64); /* Precharge C */
+       write_reg(par, 0xbb, 0x3a); /* Precharge level */
+       write_reg(par, 0xbe, 0x3e); /* vcomh */
+       write_reg(par, 0x87, 0x06); /* Master current */
+       write_reg(par, 0x81, 0x91); /* Contrast A */
+       write_reg(par, 0x82, 0x50); /* Contrast B */
+       write_reg(par, 0x83, 0x7d); /* Contrast C */
        write_reg(par, 0xaf); /* Set Sleep Mode Display On */
 
        return 0;
@@ -69,9 +69,8 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 
        if (unlikely(par->debug & DEBUG_WRITE_REGISTER)) {
                va_start(args, len);
-               for (i = 0; i < len; i++) {
+               for (i = 0; i < len; i++)
                        buf[i] = (u8)va_arg(args, unsigned int);
-               }
                va_end(args);
                fbtft_par_dbg_hex(DEBUG_WRITE_REGISTER, par, par->info->device, u8, buf, len, "%s: ", __func__);
        }
@@ -84,20 +83,21 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
        ret = par->fbtftops.write(par, par->buf, sizeof(u8));
        if (ret < 0) {
                va_end(args);
-               dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret);
+               dev_err(par->info->device,
+                       "write() failed and returned %d\n", ret);
                return;
        }
        len--;
 
        if (len) {
                i = len;
-               while (i--) {
+               while (i--)
                        *buf++ = (u8)va_arg(args, unsigned int);
-               }
                ret = par->fbtftops.write(par, par->buf, len * (sizeof(u8)));
                if (ret < 0) {
                        va_end(args);
-                       dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret);
+                       dev_err(par->info->device,
+                               "write() failed and returned %d\n", ret);
                        return;
                }
        }
index 062d98660f6378eafde788880b547424093037ec..fd492b4eaad6fef2810d3259b4c469502a8738c9 100644 (file)
@@ -72,6 +72,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
 static int set_var(struct fbtft_par *par)
 {
        unsigned remap;
+
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
 
        if (par->fbtftops.init_display != init_display) {
@@ -217,12 +218,8 @@ static void register_onboard_backlight(struct fbtft_par *par)
 
        bl_ops = devm_kzalloc(par->info->device, sizeof(struct backlight_ops),
                                GFP_KERNEL);
-       if (!bl_ops) {
-               dev_err(par->info->device,
-                       "%s: could not allocate memory for backlight operations.\n",
-                       __func__);
+       if (!bl_ops)
                return;
-       }
 
        bl_ops->update_status = update_onboard_backlight;
        bl_props.type = BACKLIGHT_RAW;
index b63aa38e51cf3629ca50d26e1b87c237ff2697bd..eb3af1d712d01627256f6a192c9de1ed470744a2 100644 (file)
@@ -68,7 +68,7 @@ static int default_init_sequence[] = {
 
        /* PWCTR4 - Power Control
             BCLK/2, Opamp current small & Medium low */
-       -1, 0xC3,0x8A,0x2A,
+       -1, 0xC3, 0x8A, 0x2A,
 
        /* PWCTR5 - Power Control */
        -1, 0xC4, 0x8A, 0xEE,
@@ -130,7 +130,7 @@ static int set_var(struct fbtft_par *par)
                write_reg(par, 0x36, MY | MV | (par->bgr << 3));
                break;
        case 180:
-               write_reg(par, 0x36, (par->bgr << 3));
+               write_reg(par, 0x36, par->bgr << 3);
                break;
        case 90:
                write_reg(par, 0x36, MX | MV | (par->bgr << 3));
@@ -148,21 +148,21 @@ static int set_var(struct fbtft_par *par)
 #define CURVE(num, idx)  curves[num*par->gamma.num_values + idx]
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
-       int i,j;
+       int i, j;
 
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
 
        /* apply mask */
        for (i = 0; i < par->gamma.num_curves; i++)
                for (j = 0; j < par->gamma.num_values; j++)
-                       CURVE(i,j) &= 0b111111;
+                       CURVE(i, j) &= 0b111111;
 
        for (i = 0; i < par->gamma.num_curves; i++)
                write_reg(par, 0xE0 + i,
                        CURVE(i, 0), CURVE(i, 1), CURVE(i, 2), CURVE(i, 3),
                        CURVE(i, 4), CURVE(i, 5), CURVE(i, 6), CURVE(i, 7),
                        CURVE(i, 8), CURVE(i, 9), CURVE(i, 10), CURVE(i, 11),
-                       CURVE(i, 12), CURVE(i, 13), CURVE(i, 14), CURVE(i,15));
+                       CURVE(i, 12), CURVE(i, 13), CURVE(i, 14), CURVE(i, 15));
 
        return 0;
 }
index 8738c7a7bfda31119d0275e4f74e3f151d1b7598..fcd38bf2ed79f9f66f37a1fa2811ebfb89c4586e 100644 (file)
@@ -127,7 +127,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
                ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH);
                if (ret < 0) {
                        dev_err(par->info->device,
-                               "%s: write failed and returned: %d\n", __func__, ret);
+                               "write failed and returned: %d\n", ret);
                        break;
                }
        }
index d70ac524278c79d88732cc2349ba5e14304309d8..26d669b57916c659c09c88f8cd1ac6fc0381f02c 100644 (file)
@@ -183,7 +183,8 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        }
 
        if (ret < 0)
-               dev_err(par->info->device, "%s: write failed and returned: %d\n", __func__, ret);
+               dev_err(par->info->device, "write failed and returned: %d\n",
+                       ret);
 
        return ret;
 }
index fff57b330ba20711359d37c1c77ea51e36bbca0d..176c2106d7245e2e37804393a2d35e3a981c4270 100644 (file)
@@ -47,84 +47,84 @@ static int init_display(struct fbtft_par *par)
        /* Initialization sequence from Lib_UTFT */
 
        /* register reset */
-       write_reg(par, 0x0003,0x0001);  /* Soft reset */
+       write_reg(par, 0x0003, 0x0001); /* Soft reset */
 
        /* oscillator start */
-       write_reg(par, 0x003A,0x0001);  /*Oscillator 0: stop, 1: operation */
+       write_reg(par, 0x003A, 0x0001); /*Oscillator 0: stop, 1: operation */
        udelay(100);
 
        /* y-setting */
-       write_reg(par, 0x0024,0x007B);  /* amplitude setting */
+       write_reg(par, 0x0024, 0x007B); /* amplitude setting */
        udelay(10);
-       write_reg(par, 0x0025,0x003B);  /* amplitude setting */
-       write_reg(par, 0x0026,0x0034);  /* amplitude setting */
+       write_reg(par, 0x0025, 0x003B); /* amplitude setting */
+       write_reg(par, 0x0026, 0x0034); /* amplitude setting */
        udelay(10);
-       write_reg(par, 0x0027,0x0004);  /* amplitude setting */
-       write_reg(par, 0x0052,0x0025);  /* circuit setting 1 */
+       write_reg(par, 0x0027, 0x0004); /* amplitude setting */
+       write_reg(par, 0x0052, 0x0025); /* circuit setting 1 */
        udelay(10);
-       write_reg(par, 0x0053,0x0033);  /* circuit setting 2 */
-       write_reg(par, 0x0061,0x001C);  /* adjustment V10 positive polarity */
+       write_reg(par, 0x0053, 0x0033); /* circuit setting 2 */
+       write_reg(par, 0x0061, 0x001C); /* adjustment V10 positive polarity */
        udelay(10);
-       write_reg(par, 0x0062,0x002C);  /* adjustment V9 negative polarity */
-       write_reg(par, 0x0063,0x0022);  /* adjustment V34 positive polarity */
+       write_reg(par, 0x0062, 0x002C); /* adjustment V9 negative polarity */
+       write_reg(par, 0x0063, 0x0022); /* adjustment V34 positive polarity */
        udelay(10);
-       write_reg(par, 0x0064,0x0027);  /* adjustment V31 negative polarity */
+       write_reg(par, 0x0064, 0x0027); /* adjustment V31 negative polarity */
        udelay(10);
-       write_reg(par, 0x0065,0x0014);  /* adjustment V61 negative polarity */
+       write_reg(par, 0x0065, 0x0014); /* adjustment V61 negative polarity */
        udelay(10);
-       write_reg(par, 0x0066,0x0010);  /* adjustment V61 negative polarity */
-       
+       write_reg(par, 0x0066, 0x0010); /* adjustment V61 negative polarity */
+
        /* Basical clock for 1 line (BASECOUNT[7:0]) number specified */
-       write_reg(par, 0x002E,0x002D);
-       
+       write_reg(par, 0x002E, 0x002D);
+
        /* Power supply setting */
-       write_reg(par, 0x0019,0x0000);  /* DC/DC output setting */
+       write_reg(par, 0x0019, 0x0000); /* DC/DC output setting */
        udelay(200);
-       write_reg(par, 0x001A,0x1000);  /* DC/DC frequency setting */
-       write_reg(par, 0x001B,0x0023);  /* DC/DC rising setting */
-       write_reg(par, 0x001C,0x0C01);  /* Regulator voltage setting */
-       write_reg(par, 0x001D,0x0000);  /* Regulator current setting */
-       write_reg(par, 0x001E,0x0009);  /* VCOM output setting */
-       write_reg(par, 0x001F,0x0035);  /* VCOM amplitude setting */
-       write_reg(par, 0x0020,0x0015);  /* VCOMM cencter setting */
-       write_reg(par, 0x0018,0x1E7B);  /* DC/DC operation setting */
+       write_reg(par, 0x001A, 0x1000); /* DC/DC frequency setting */
+       write_reg(par, 0x001B, 0x0023); /* DC/DC rising setting */
+       write_reg(par, 0x001C, 0x0C01); /* Regulator voltage setting */
+       write_reg(par, 0x001D, 0x0000); /* Regulator current setting */
+       write_reg(par, 0x001E, 0x0009); /* VCOM output setting */
+       write_reg(par, 0x001F, 0x0035); /* VCOM amplitude setting */
+       write_reg(par, 0x0020, 0x0015); /* VCOMM cencter setting */
+       write_reg(par, 0x0018, 0x1E7B); /* DC/DC operation setting */
 
        /* windows setting */
-       write_reg(par, 0x0008,0x0000);  /* Minimum X address */
-       write_reg(par, 0x0009,0x00EF);  /* Maximum X address */
-       write_reg(par, 0x000a,0x0000);  /* Minimum Y address */
-       write_reg(par, 0x000b,0x013F);  /* Maximum Y address */
+       write_reg(par, 0x0008, 0x0000); /* Minimum X address */
+       write_reg(par, 0x0009, 0x00EF); /* Maximum X address */
+       write_reg(par, 0x000a, 0x0000); /* Minimum Y address */
+       write_reg(par, 0x000b, 0x013F); /* Maximum Y address */
 
        /* LCD display area setting */
-       write_reg(par, 0x0029,0x0000);  /* [LCDSIZE]  X MIN. size set */
-       write_reg(par, 0x002A,0x0000);  /* [LCDSIZE]  Y MIN. size set */
-       write_reg(par, 0x002B,0x00EF);  /* [LCDSIZE]  X MAX. size set */
-       write_reg(par, 0x002C,0x013F);  /* [LCDSIZE]  Y MAX. size set */
+       write_reg(par, 0x0029, 0x0000); /* [LCDSIZE]  X MIN. size set */
+       write_reg(par, 0x002A, 0x0000); /* [LCDSIZE]  Y MIN. size set */
+       write_reg(par, 0x002B, 0x00EF); /* [LCDSIZE]  X MAX. size set */
+       write_reg(par, 0x002C, 0x013F); /* [LCDSIZE]  Y MAX. size set */
 
        /* Gate scan setting */
-       write_reg(par, 0x0032,0x0002);
-       
+       write_reg(par, 0x0032, 0x0002);
+
        /* n line inversion line number */
-       write_reg(par, 0x0033,0x0000);
+       write_reg(par, 0x0033, 0x0000);
 
        /* Line inversion/frame inversion/interlace setting */
-       write_reg(par, 0x0037,0x0000);
-       
+       write_reg(par, 0x0037, 0x0000);
+
        /* Gate scan operation setting register */
-       write_reg(par, 0x003B,0x0001);
-       
+       write_reg(par, 0x003B, 0x0001);
+
        /* Color mode */
        /*GS = 0: 260-k color (64 gray scale), GS = 1: 8 color (2 gray scale) */
-       write_reg(par, 0x0004,0x0000);
+       write_reg(par, 0x0004, 0x0000);
 
        /* RAM control register */
-       write_reg(par, 0x0005,0x0000);  /*Window access 00:Normal, 10:Window */
+       write_reg(par, 0x0005, 0x0000); /*Window access 00:Normal, 10:Window */
 
        /* Display setting register 2 */
-       write_reg(par, 0x0001,0x0000);
+       write_reg(par, 0x0001, 0x0000);
 
        /* display setting */
-       write_reg(par, 0x0000,0x0000);  /* display on */
+       write_reg(par, 0x0000, 0x0000); /* display on */
 
        return 0;
 }
index 975b579359f367af94c10b7976ccb3dcfba5796c..88fb2c0132d5257542c9e75964c47f164c5e36f5 100644 (file)
@@ -65,7 +65,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
        ret = par->fbtftops.write(par, par->buf, len);
        if (ret < 0) {
                dev_err(par->info->device,
-                       "%s: write() failed and returned %d\n", __func__, ret);
+                       "write() failed and returned %d\n", ret);
                return;
        }
 }
index b3cddb0b3d698a9d606ece34e49288348f9e769b..52af9cbbc2a688c8bb8d18e918ba1469821928c9 100644 (file)
@@ -111,7 +111,7 @@ void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
        ret = par->fbtftops.write(par, par->buf, (len + pad) * sizeof(u16));
        if (ret < 0) {
                dev_err(par->info->device,
-                       "%s: write() failed and returned %d\n", __func__, ret);
+                       "write() failed and returned %d\n", ret);
                return;
        }
 }
index 37dcf7eb191a22c5c3b6abb14040d76ae9bcd689..16c726030f37c886d3480b51a987d875a1b968f6 100644 (file)
 #include <linux/of_gpio.h>
 
 #include "fbtft.h"
-
-extern void fbtft_sysfs_init(struct fbtft_par *par);
-extern void fbtft_sysfs_exit(struct fbtft_par *par);
-extern void fbtft_expand_debug_value(unsigned long *debug);
-extern int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
-                                               const char *str, int size);
+#include "internal.h"
 
 static unsigned long debug;
-module_param(debug, ulong , 0);
+module_param(debug, ulong, 0);
 MODULE_PARM_DESC(debug, "override device debug level");
 
 static bool dma = true;
@@ -302,12 +297,8 @@ void fbtft_register_backlight(struct fbtft_par *par)
 
        bl_ops = devm_kzalloc(par->info->device, sizeof(struct backlight_ops),
                                GFP_KERNEL);
-       if (!bl_ops) {
-               dev_err(par->info->device,
-                       "%s: could not allocate memeory for backlight operations.\n",
-                       __func__);
+       if (!bl_ops)
                return;
-       }
 
        bl_ops->get_brightness = fbtft_backlight_get_brightness;
        bl_ops->update_status = fbtft_backlight_update_status;
@@ -379,7 +370,7 @@ static void fbtft_update_display(struct fbtft_par *par, unsigned start_line,
        int ret = 0;
 
        if (unlikely(par->debug & (DEBUG_TIME_FIRST_UPDATE | DEBUG_TIME_EACH_UPDATE))) {
-               if ((par->debug & DEBUG_TIME_EACH_UPDATE) || \
+               if ((par->debug & DEBUG_TIME_EACH_UPDATE) ||
                                ((par->debug & DEBUG_TIME_FIRST_UPDATE) && !par->first_update_done)) {
                        getnstimeofday(&ts_start);
                        timeit = true;
@@ -707,9 +698,8 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
 
        /* sanity check */
        if (display->gamma_num * display->gamma_len > FBTFT_GAMMA_MAX_VALUES_TOTAL) {
-               dev_err(dev,
-                       "%s: FBTFT_GAMMA_MAX_VALUES_TOTAL=%d is exceeded\n",
-                       __func__, FBTFT_GAMMA_MAX_VALUES_TOTAL);
+               dev_err(dev, "FBTFT_GAMMA_MAX_VALUES_TOTAL=%d is exceeded\n",
+                       FBTFT_GAMMA_MAX_VALUES_TOTAL);
                return NULL;
        }
 
@@ -1000,7 +990,7 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
        fbtft_sysfs_init(par);
 
        if (par->txbuf.buf)
-               sprintf(text1, ", %d KiB %sbuffer memory",
+               sprintf(text1, ", %zu KiB %sbuffer memory",
                        par->txbuf.len >> 10, par->txbuf.dma ? "DMA " : "");
        if (spi)
                sprintf(text2, ", spi%d.%d at %d MHz", spi->master->bus_num,
@@ -1046,7 +1036,6 @@ int fbtft_unregister_framebuffer(struct fb_info *fb_info)
 {
        struct fbtft_par *par = fb_info->par;
        struct spi_device *spi = par->spi;
-       int ret;
 
        if (spi)
                spi_set_drvdata(spi, NULL);
@@ -1055,8 +1044,7 @@ int fbtft_unregister_framebuffer(struct fb_info *fb_info)
        if (par->fbtftops.unregister_backlight)
                par->fbtftops.unregister_backlight(par);
        fbtft_sysfs_exit(par);
-       ret = unregister_framebuffer(fb_info);
-       return ret;
+       return unregister_framebuffer(fb_info);
 }
 EXPORT_SYMBOL(fbtft_unregister_framebuffer);
 
@@ -1278,7 +1266,7 @@ static int fbtft_verify_gpios(struct fbtft_par *par)
        fbtft_par_dbg(DEBUG_VERIFY_GPIOS, par, "%s()\n", __func__);
 
        pdata = par->info->device->platform_data;
-       if (pdata->display.buswidth != 9 && par->startbyte == 0 && \
+       if (pdata->display.buswidth != 9 && par->startbyte == 0 &&
                                                        par->gpio.dc < 0) {
                dev_err(par->info->device,
                        "Missing info about 'dc' gpio. Aborting.\n");
index 32155a7b2a624099f8d7d1bee727ff6dc44f58af..a6f091fb975c71262dade439dad5b22e48d2fe5b 100644 (file)
@@ -59,8 +59,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len)
        }
        if ((len % 8) != 0) {
                dev_err(par->info->device,
-                       "%s: error: len=%d must be divisible by 8\n",
-                       __func__, len);
+                       "error: len=%zu must be divisible by 8\n", len);
                return -EINVAL;
        }
 
@@ -106,8 +105,8 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len)
        if (par->startbyte) {
                if (len > 32) {
                        dev_err(par->info->device,
-                               "%s: len=%d can't be larger than 32 when using 'startbyte'\n",
-                               __func__, len);
+                               "len=%zu can't be larger than 32 when using 'startbyte'\n",
+                               len);
                        return -EINVAL;
                }
                txbuf[0] = par->startbyte | 0x3;
@@ -155,14 +154,14 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
                        for (i = 0; i < 8; i++) {
                                if ((data & 1) != (prev_data & 1))
                                        gpio_set_value(par->gpio.db[i],
-                                                               (data & 1));
+                                                               data & 1);
                                data >>= 1;
                                prev_data >>= 1;
                        }
                }
 #else
                for (i = 0; i < 8; i++) {
-                       gpio_set_value(par->gpio.db[i], (data & 1));
+                       gpio_set_value(par->gpio.db[i], data & 1);
                        data >>= 1;
                }
 #endif
@@ -205,14 +204,14 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
                        for (i = 0; i < 16; i++) {
                                if ((data & 1) != (prev_data & 1))
                                        gpio_set_value(par->gpio.db[i],
-                                                               (data & 1));
+                                                               data & 1);
                                data >>= 1;
                                prev_data >>= 1;
                        }
                }
 #else
                for (i = 0; i < 16; i++) {
-                       gpio_set_value(par->gpio.db[i], (data & 1));
+                       gpio_set_value(par->gpio.db[i], data & 1);
                        data >>= 1;
                }
 #endif
index 45f8de3d11ad45d0b9e49364550e957f23f9d1e2..e3eb1f9587b3a861bdcbb9647ce497e400313c37 100644 (file)
@@ -1,5 +1,5 @@
 #include "fbtft.h"
-
+#include "internal.h"
 
 static int get_next_ulong(char **str_p, unsigned long *val, char *sep, int base)
 {
@@ -37,10 +37,9 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
 
        fbtft_par_dbg(DEBUG_SYSFS, par, "%s\n", str);
 
-       tmp = kmalloc(size+1, GFP_KERNEL);
+       tmp = kmemdup(str, size + 1, GFP_KERNEL);
        if (!tmp)
                return -ENOMEM;
-       memcpy(tmp, str, size+1);
 
        /* replace optional separators */
        str_p = tmp;
index b9f4c30e39c6a3a91882c07078fd948a66390d70..1afeebb95c5453b1dea60955446b14de48cd877f 100644 (file)
@@ -29,8 +29,8 @@
 
 #define MAX_GPIOS 32
 
-struct spi_device *spi_device;
-struct platform_device *p_device;
+static struct spi_device *spi_device;
+static struct platform_device *p_device;
 
 static char *name;
 module_param(name, charp, 0);
@@ -109,7 +109,7 @@ module_param_array(init, int, &init_num, 0);
 MODULE_PARM_DESC(init, "Init sequence, used with the custom argument");
 
 static unsigned long debug;
-module_param(debug, ulong , 0);
+module_param(debug, ulong, 0);
 MODULE_PARM_DESC(debug,
 "level: 0-7 (the remaining 29 bits is for advanced usage)");
 
@@ -136,43 +136,69 @@ static void adafruit18_green_tab_set_addr_win(struct fbtft_par *par,
                "03 1d 07 06 2E 2C 29 2D 2E 2E 37 3F 00 00 02 10"
 
 static int hy28b_init_sequence[] = {
-       -1,0x00e7,0x0010,-1,0x0000,0x0001,-1,0x0001,0x0100,-1,0x0002,0x0700,
-       -1,0x0003,0x1030,-1,0x0004,0x0000,-1,0x0008,0x0207,-1,0x0009,0x0000,
-       -1,0x000a,0x0000,-1,0x000c,0x0001,-1,0x000d,0x0000,-1,0x000f,0x0000,
-       -1,0x0010,0x0000,-1,0x0011,0x0007,-1,0x0012,0x0000,-1,0x0013,0x0000,
-       -2,50,-1,0x0010,0x1590,-1,0x0011,0x0227,-2,50,-1,0x0012,0x009c,-2,50,
-       -1,0x0013,0x1900,-1,0x0029,0x0023,-1,0x002b,0x000e,-2,50,
-       -1,0x0020,0x0000,-1,0x0021,0x0000,-2,50,-1,0x0050,0x0000,
-       -1,0x0051,0x00ef,-1,0x0052,0x0000,-1,0x0053,0x013f,-1,0x0060,0xa700,
-       -1,0x0061,0x0001,-1,0x006a,0x0000,-1,0x0080,0x0000,-1,0x0081,0x0000,
-       -1,0x0082,0x0000,-1,0x0083,0x0000,-1,0x0084,0x0000,-1,0x0085,0x0000,
-       -1,0x0090,0x0010,-1,0x0092,0x0000,-1,0x0093,0x0003,-1,0x0095,0x0110,
-       -1,0x0097,0x0000,-1,0x0098,0x0000,-1,0x0007,0x0133,-1,0x0020,0x0000,
-       -1,0x0021,0x0000,-2,100,-3 };
+       -1, 0x00e7, 0x0010, -1, 0x0000, 0x0001,
+       -1, 0x0001, 0x0100, -1, 0x0002, 0x0700,
+       -1, 0x0003, 0x1030, -1, 0x0004, 0x0000,
+       -1, 0x0008, 0x0207, -1, 0x0009, 0x0000,
+       -1, 0x000a, 0x0000, -1, 0x000c, 0x0001,
+       -1, 0x000d, 0x0000, -1, 0x000f, 0x0000,
+       -1, 0x0010, 0x0000, -1, 0x0011, 0x0007,
+       -1, 0x0012, 0x0000, -1, 0x0013, 0x0000,
+       -2, 50, -1, 0x0010, 0x1590, -1, 0x0011,
+       0x0227, -2, 50, -1, 0x0012, 0x009c, -2, 50,
+       -1, 0x0013, 0x1900, -1, 0x0029, 0x0023,
+       -1, 0x002b, 0x000e, -2, 50,
+       -1, 0x0020, 0x0000, -1, 0x0021, 0x0000,
+       -2, 50, -1, 0x0050, 0x0000,
+       -1, 0x0051, 0x00ef, -1, 0x0052, 0x0000,
+       -1, 0x0053, 0x013f, -1, 0x0060, 0xa700,
+       -1, 0x0061, 0x0001, -1, 0x006a, 0x0000,
+       -1, 0x0080, 0x0000, -1, 0x0081, 0x0000,
+       -1, 0x0082, 0x0000, -1, 0x0083, 0x0000,
+       -1, 0x0084, 0x0000, -1, 0x0085, 0x0000,
+       -1, 0x0090, 0x0010, -1, 0x0092, 0x0000,
+       -1, 0x0093, 0x0003, -1, 0x0095, 0x0110,
+       -1, 0x0097, 0x0000, -1, 0x0098, 0x0000,
+       -1, 0x0007, 0x0133, -1, 0x0020, 0x0000,
+       -1, 0x0021, 0x0000, -2, 100, -3 };
 
 #define HY28B_GAMMA \
        "04 1F 4 7 7 0 7 7 6 0\n" \
        "0F 00 1 7 4 0 0 0 6 7"
 
 static int pitft_init_sequence[] = {
-       -1,0x01,-2,5,-1,0x28,-1,0xEF,0x03,0x80,0x02,-1,0xCF,0x00,0xC1,0x30,
-       -1,0xED,0x64,0x03,0x12,0x81,-1,0xE8,0x85,0x00,0x78,
-       -1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xF7,0x20,-1,0xEA,0x00,0x00,
-       -1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,-1,0x3A,0x55,
-       -1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,-1,0xF2,0x00,-1,0x26,0x01,
-       -1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,
-       0x0E,0x09,0x00,-1,0xE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,
-       0x08,0x0F,0x0C,0x31,0x36,0x0F,-1,0x11,-2,100,-1,0x29,-2,20,-3 };
+       -1, 0x01, -2, 5, -1, 0x28, -1, 0xEF,
+       0x03, 0x80, 0x02, -1, 0xCF, 0x00, 0xC1, 0x30,
+       -1, 0xED, 0x64, 0x03, 0x12, 0x81,
+       -1, 0xE8, 0x85, 0x00, 0x78,
+       -1, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02,
+       -1, 0xF7, 0x20, -1, 0xEA, 0x00, 0x00,
+       -1, 0xC0, 0x23, -1, 0xC1, 0x10, -1, 0xC5,
+       0x3e, 0x28, -1, 0xC7, 0x86, -1, 0x3A, 0x55,
+       -1, 0xB1, 0x00, 0x18, -1, 0xB6, 0x08, 0x82,
+       0x27, -1, 0xF2, 0x00, -1, 0x26, 0x01,
+       -1, 0xE0, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08,
+       0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03,
+       0x0E, 0x09, 0x00, -1, 0xE1, 0x00, 0x0E, 0x14,
+       0x03, 0x11, 0x07, 0x31, 0xC1, 0x48,
+       0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F, -1,
+       0x11, -2, 100, -1, 0x29, -2, 20, -3 };
 
 static int waveshare32b_init_sequence[] = {
-       -1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xCF,0x00,0xC1,0x30,
-       -1,0xE8,0x85,0x00,0x78,-1,0xEA,0x00,0x00,-1,0xED,0x64,0x03,0x12,0x81,
-       -1,0xF7,0x20,-1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,
-       -1,0x36,0x28,-1,0x3A,0x55,-1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,
-       -1,0xF2,0x00,-1,0x26,0x01,
-       -1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00,
-       -1,0xE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F,
-       -1,0x11,-2,120,-1,0x29,-1,0x2c,-3 };
+       -1, 0xCB, 0x39, 0x2C, 0x00, 0x34, 0x02,
+       -1, 0xCF, 0x00, 0xC1, 0x30,
+       -1, 0xE8, 0x85, 0x00, 0x78, -1, 0xEA, 0x00,
+       0x00, -1, 0xED, 0x64, 0x03, 0x12, 0x81,
+       -1, 0xF7, 0x20, -1, 0xC0, 0x23, -1, 0xC1,
+       0x10, -1, 0xC5, 0x3e, 0x28, -1, 0xC7, 0x86,
+       -1, 0x36, 0x28, -1, 0x3A, 0x55, -1, 0xB1, 0x00,
+       0x18, -1, 0xB6, 0x08, 0x82, 0x27,
+       -1, 0xF2, 0x00, -1, 0x26, 0x01,
+       -1, 0xE0, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E,
+       0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
+       -1, 0xE1, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31,
+       0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
+       -1, 0x11, -2, 120, -1, 0x29, -1, 0x2c, -3 };
 
 /* Supported displays in alphabetical order */
 static struct fbtft_device_display displays[] = {
@@ -486,7 +512,7 @@ static struct fbtft_device_display displays[] = {
                                },
                                .startbyte = 0b01110000,
                                .bgr = true,
-                               .fps= 50,
+                               .fps = 50,
                                .gpios = (const struct fbtft_gpio []) {
                                        { "reset", 25 },
                                        { "led", 18 },
@@ -1100,14 +1126,14 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len)
                        for (i = 0; i < 16; i++) {
                                if ((data & 1) != (prev_data & 1))
                                        gpio_set_value(par->gpio.db[i],
-                                                               (data & 1));
+                                                               data & 1);
                                data >>= 1;
                                prev_data >>= 1;
                        }
                }
 #else
                for (i = 0; i < 16; i++) {
-                       gpio_set_value(par->gpio.db[i], (data & 1));
+                       gpio_set_value(par->gpio.db[i], data & 1);
                        data >>= 1;
                }
 #endif
diff --git a/drivers/staging/fbtft/internal.h b/drivers/staging/fbtft/internal.h
new file mode 100644 (file)
index 0000000..f69db82
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2013 Noralf Tronnes
+ *
+ * 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.
+ *
+ */
+
+#ifndef __LINUX_FBTFT__INTERNAL_H
+#define __LINUX_FBTFT_INTERNAL_H
+
+void fbtft_sysfs_init(struct fbtft_par *par);
+void fbtft_sysfs_exit(struct fbtft_par *par);
+void fbtft_expand_debug_value(unsigned long *debug);
+int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
+                         const char *str, int size);
+
+#endif /* __LINUX_FBTFT_INTERNAL_H */
diff --git a/drivers/staging/fsl-mc/Kconfig b/drivers/staging/fsl-mc/Kconfig
new file mode 100644 (file)
index 0000000..32df07b
--- /dev/null
@@ -0,0 +1 @@
+source "drivers/staging/fsl-mc/bus/Kconfig"
diff --git a/drivers/staging/fsl-mc/Makefile b/drivers/staging/fsl-mc/Makefile
new file mode 100644 (file)
index 0000000..9c6a001
--- /dev/null
@@ -0,0 +1,2 @@
+# Freescale Management Complex (MC) bus drivers
+obj-$(CONFIG_FSL_MC_BUS)       += bus/
diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
new file mode 100644 (file)
index 0000000..d78288b
--- /dev/null
@@ -0,0 +1,13 @@
+* Add README file (with ASCII art) describing relationships between
+  DPAA2 objects and how combine them to make a NIC, an LS2 switch, etc.
+  Also, define all acronyms used.
+
+* Decide if multiple root fsl-mc buses will be supported per Linux instance,
+  and if so add support for this.
+
+* Add at least one device driver for a DPAA2 object (child device of the
+  fsl-mc bus).
+
+Please send any patches to Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
+german.rivera@freescale.com, devel@driverdev.osuosl.org,
+linux-kernel@vger.kernel.org
diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig
new file mode 100644 (file)
index 0000000..0d779d9
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# Freescale Management Complex (MC) bus drivers
+#
+# Copyright (C) 2014 Freescale Semiconductor, Inc.
+#
+# This file is released under the GPLv2
+#
+
+config FSL_MC_BUS
+       tristate "Freescale Management Complex (MC) bus driver"
+       depends on OF && ARM64
+       help
+         Driver to enable the bus infrastructure for the Freescale
+          QorIQ Management Complex (fsl-mc). The fsl-mc is a hardware
+         module of the QorIQ LS2 SoCs, that does resource management
+         for hardware building-blocks in the SoC that can be used
+         to dynamically create networking hardware objects such as
+         network interfaces (NICs), crypto accelerator instances,
+         or L2 switches.
+
+         Only enable this option when building the kernel for
+         Freescale QorQIQ LS2xxxx SoCs.
+
+
diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile
new file mode 100644 (file)
index 0000000..bd09fc8
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Freescale Management Complex (MC) bus drivers
+#
+# Copyright (C) 2014 Freescale Semiconductor, Inc.
+#
+# This file is released under the GPLv2
+#
+obj-$(CONFIG_FSL_MC_BUS) += mc-bus-driver.o \
+                           mc-allocator-driver.o
+
+mc-bus-driver-objs := mc-bus.o \
+                     mc-sys.o \
+                     dprc.o \
+                     dpmng.o \
+                     dprc-driver.o
+
+mc-allocator-driver-objs := mc-allocator.o \
+                           dpmcp.o \
+                           dpbp.o
diff --git a/drivers/staging/fsl-mc/bus/dpbp.c b/drivers/staging/fsl-mc/bus/dpbp.c
new file mode 100644 (file)
index 0000000..d99ab6d
--- /dev/null
@@ -0,0 +1,358 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the above-listed copyright holders nor the
+* names of any contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+*
+* ALTERNATIVELY, this software may be distributed under the terms of the
+* GNU General Public License ("GPL") as published by the Free Software
+* Foundation, either version 2 of that License or (at your option) any
+* later version.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT 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.
+*/
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "../include/dpbp.h"
+#include "../include/dpbp-cmd.h"
+
+int dpbp_open(struct fsl_mc_io *mc_io, int dpbp_id, uint16_t *token)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
+                                         MC_CMD_PRI_LOW, 0);
+       cmd.params[0] |= mc_enc(0, 32, dpbp_id);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+       return err;
+}
+EXPORT_SYMBOL(dpbp_open);
+
+int dpbp_close(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, MC_CMD_PRI_HIGH,
+                                         token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+EXPORT_SYMBOL(dpbp_close);
+
+int dpbp_create(struct fsl_mc_io *mc_io,
+               const struct dpbp_cfg *cfg,
+               uint16_t *token)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       (void)(cfg); /* unused */
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
+                                         MC_CMD_PRI_LOW, 0);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+       return 0;
+}
+
+int dpbp_destroy(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_enable(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, MC_CMD_PRI_LOW,
+                                         token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+EXPORT_SYMBOL(dpbp_enable);
+
+int dpbp_disable(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+EXPORT_SYMBOL(dpbp_disable);
+
+int dpbp_is_enabled(struct fsl_mc_io *mc_io, uint16_t token, int *en)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, MC_CMD_PRI_LOW,
+                                         token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *en = (int)mc_dec(cmd.params[0], 0, 1);
+
+       return 0;
+}
+
+int dpbp_reset(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_set_irq(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                uint8_t irq_index,
+                uint64_t irq_paddr,
+                uint32_t irq_val,
+                int user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 8, irq_index);
+       cmd.params[0] |= mc_enc(32, 32, irq_val);
+       cmd.params[1] |= mc_enc(0, 64, irq_paddr);
+       cmd.params[2] |= mc_enc(0, 32, user_irq_id);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_get_irq(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                uint8_t irq_index,
+                int *type,
+                uint64_t *irq_paddr,
+                uint32_t *irq_val,
+                int *user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *irq_val = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       *irq_paddr = (uint64_t)mc_dec(cmd.params[1], 0, 64);
+       *user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
+       *type = (int)mc_dec(cmd.params[2], 32, 32);
+       return 0;
+}
+
+int dpbp_set_irq_enable(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t en)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 8, en);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t *en)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *en = (uint8_t)mc_dec(cmd.params[0], 0, 8);
+       return 0;
+}
+
+int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t mask)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, mask);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t *mask)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *mask = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       return 0;
+}
+
+int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint32_t *status)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *status = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       return 0;
+}
+
+int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
+                         uint16_t token,
+                         uint8_t irq_index,
+                         uint32_t status)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLEAR_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, status);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpbp_get_attributes(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       struct dpbp_attr *attr)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       attr->bpid = (uint16_t)mc_dec(cmd.params[0], 16, 16);
+       attr->id = (int)mc_dec(cmd.params[0], 32, 32);
+       attr->version.major = (uint16_t)mc_dec(cmd.params[1], 0, 16);
+       attr->version.minor = (uint16_t)mc_dec(cmd.params[1], 16, 16);
+       return 0;
+}
+EXPORT_SYMBOL(dpbp_get_attributes);
diff --git a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h
new file mode 100644 (file)
index 0000000..57f326b
--- /dev/null
@@ -0,0 +1,136 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef _FSL_DPMCP_CMD_H
+#define _FSL_DPMCP_CMD_H
+
+/* DPMCP Version */
+#define DPMCP_VER_MAJOR                                2
+#define DPMCP_VER_MINOR                                0
+
+/* Command IDs */
+#define DPMCP_CMDID_CLOSE                              0x800
+#define DPMCP_CMDID_OPEN                               0x80b
+#define DPMCP_CMDID_CREATE                             0x90b
+#define DPMCP_CMDID_DESTROY                            0x900
+
+#define DPMCP_CMDID_GET_ATTR                           0x004
+#define DPMCP_CMDID_RESET                              0x005
+
+#define DPMCP_CMDID_SET_IRQ                            0x010
+#define DPMCP_CMDID_GET_IRQ                            0x011
+#define DPMCP_CMDID_SET_IRQ_ENABLE                     0x012
+#define DPMCP_CMDID_GET_IRQ_ENABLE                     0x013
+#define DPMCP_CMDID_SET_IRQ_MASK                       0x014
+#define DPMCP_CMDID_GET_IRQ_MASK                       0x015
+#define DPMCP_CMDID_GET_IRQ_STATUS                     0x016
+#define DPMCP_CMDID_CLEAR_IRQ_STATUS                   0x017
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_CREATE(cmd, cfg) \
+       MC_CMD_OP(cmd, 0, 0,  32, int,      cfg->portal_id)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_SET_IRQ(cmd, irq_index, irq_addr, irq_val, user_irq_id) \
+do { \
+       MC_CMD_OP(cmd, 0, 0,  8,  uint8_t,  irq_index);\
+       MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_val);\
+       MC_CMD_OP(cmd, 1, 0,  64, uint64_t, irq_addr); \
+       MC_CMD_OP(cmd, 2, 0,  32, int,      user_irq_id); \
+} while (0)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_GET_IRQ(cmd, irq_index) \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_RSP_GET_IRQ(cmd, type, irq_addr, irq_val, user_irq_id) \
+do { \
+       MC_RSP_OP(cmd, 0, 0,  32, uint32_t, irq_val); \
+       MC_RSP_OP(cmd, 1, 0,  64, uint64_t, irq_addr); \
+       MC_RSP_OP(cmd, 2, 0,  32, int,      user_irq_id); \
+       MC_RSP_OP(cmd, 2, 32, 32, int,      type); \
+} while (0)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
+do { \
+       MC_CMD_OP(cmd, 0, 0,  8,  uint8_t,  en); \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index);\
+} while (0)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_RSP_GET_IRQ_ENABLE(cmd, en) \
+       MC_RSP_OP(cmd, 0, 0,  8,  uint8_t,  en)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
+do { \
+       MC_CMD_OP(cmd, 0, 0,  32, uint32_t, mask);\
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index);\
+} while (0)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_GET_IRQ_MASK(cmd, irq_index) \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_RSP_GET_IRQ_MASK(cmd, mask) \
+       MC_RSP_OP(cmd, 0, 0,  32, uint32_t, mask)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_GET_IRQ_STATUS(cmd, irq_index) \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_RSP_GET_IRQ_STATUS(cmd, status) \
+       MC_RSP_OP(cmd, 0, 0,  32, uint32_t, status)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPMCP_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
+do { \
+       MC_CMD_OP(cmd, 0, 0,  32, uint32_t, status); \
+       MC_CMD_OP(cmd, 0, 32, 8,  uint8_t,  irq_index);\
+} while (0)
+
+/*                cmd, param, offset, width, type,     arg_name */
+#define DPMCP_RSP_GET_ATTRIBUTES(cmd, attr) \
+do { \
+       MC_RSP_OP(cmd, 0, 32, 32, int,      attr->id);\
+       MC_RSP_OP(cmd, 1, 0,  16, uint16_t, attr->version.major);\
+       MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
+} while (0)
+
+#endif /* _FSL_DPMCP_CMD_H */
diff --git a/drivers/staging/fsl-mc/bus/dpmcp.c b/drivers/staging/fsl-mc/bus/dpmcp.c
new file mode 100644 (file)
index 0000000..6b9da5b
--- /dev/null
@@ -0,0 +1,308 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "dpmcp.h"
+#include "dpmcp-cmd.h"
+
+int dpmcp_open(struct fsl_mc_io *mc_io, int dpmcp_id, uint16_t *token)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN,
+                                         MC_CMD_PRI_LOW, 0);
+       cmd.params[0] |= mc_enc(0, 32, dpmcp_id);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+       return err;
+}
+
+int dpmcp_close(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLOSE, MC_CMD_PRI_HIGH,
+                                         token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_create(struct fsl_mc_io *mc_io,
+                const struct dpmcp_cfg *cfg,
+               uint16_t *token)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE,
+                                         MC_CMD_PRI_LOW, 0);
+       cmd.params[0] |= mc_enc(0, 32, cfg->portal_id);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+       return 0;
+}
+
+int dpmcp_destroy(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_DESTROY,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_reset(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_RESET,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_set_irq(struct fsl_mc_io *mc_io,
+                 uint16_t token,
+                uint8_t irq_index,
+                uint64_t irq_addr,
+                uint32_t irq_val,
+                int user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 8, irq_index);
+       cmd.params[0] |= mc_enc(32, 32, irq_val);
+       cmd.params[1] |= mc_enc(0, 64, irq_addr);
+       cmd.params[2] |= mc_enc(0, 32, user_irq_id);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_get_irq(struct fsl_mc_io *mc_io,
+                 uint16_t token,
+                uint8_t irq_index,
+                int *type,
+                uint64_t *irq_addr,
+                uint32_t *irq_val,
+                int *user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *irq_val = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       *irq_addr = (uint64_t)mc_dec(cmd.params[1], 0, 64);
+       *user_irq_id = (int)mc_dec(cmd.params[2], 0, 32);
+       *type = (int)mc_dec(cmd.params[2], 32, 32);
+       return 0;
+}
+
+int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t en)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 8, en);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t *en)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *en = (uint8_t)mc_dec(cmd.params[0], 0, 8);
+       return 0;
+}
+
+int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io,
+                      uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t mask)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, mask);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
+                      uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t *mask)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *mask = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       return 0;
+}
+
+int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                       uint8_t irq_index,
+                       uint32_t *status)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *status = (uint32_t)mc_dec(cmd.params[0], 0, 32);
+       return 0;
+}
+
+int dpmcp_clear_irq_status(struct fsl_mc_io *mc_io,
+                          uint16_t token,
+                         uint8_t irq_index,
+                         uint32_t status)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLEAR_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, status);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                       struct dpmcp_attr *attr)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_ATTR,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       attr->id = (int)mc_dec(cmd.params[0], 32, 32);
+       attr->version.major = (uint16_t)mc_dec(cmd.params[1], 0, 16);
+       attr->version.minor = (uint16_t)mc_dec(cmd.params[1], 16, 16);
+       return 0;
+}
diff --git a/drivers/staging/fsl-mc/bus/dpmcp.h b/drivers/staging/fsl-mc/bus/dpmcp.h
new file mode 100644 (file)
index 0000000..5e7c219
--- /dev/null
@@ -0,0 +1,311 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef __FSL_DPMCP_H
+#define __FSL_DPMCP_H
+
+/* Data Path Management Command Portal API
+ * Contains initialization APIs and runtime control APIs for DPMCP
+ */
+
+struct fsl_mc_io;
+
+/**
+ * dpmcp_open() - Open a control session for the specified object.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @dpmcp_id:  DPMCP unique ID
+ * @token:     Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dpmcp_create function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_open(struct fsl_mc_io *mc_io, int dpmcp_id, uint16_t *token);
+
+/* Get portal ID from pool */
+#define DPMCP_GET_PORTAL_ID_FROM_POOL (-1)
+
+/**
+ * dpmcp_close() - Close the control session of the object
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_close(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * struct dpmcp_cfg() - Structure representing DPMCP configuration
+ * @portal_id: Portal ID; 'DPMCP_GET_PORTAL_ID_FROM_POOL' to get the portal ID
+ *             from pool
+ */
+struct dpmcp_cfg {
+       int portal_id;
+};
+
+/**
+ * dpmcp_create() - Create the DPMCP object.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cfg:       Configuration structure
+ * @token:     Returned token; use in subsequent API calls
+ *
+ * Create the DPMCP object, allocate required resources and
+ * perform required initialization.
+ *
+ * The object can be created either by declaring it in the
+ * DPL file, or by calling this function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent calls to
+ * this specific object. For objects that are created using the
+ * DPL file, call dpmcp_open function to get an authentication
+ * token first.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_create(struct fsl_mc_io      *mc_io,
+                const struct dpmcp_cfg *cfg,
+               uint16_t                *token);
+
+/**
+ * dpmcp_destroy() - Destroy the DPMCP object and release all its resources.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ *
+ * Return:     '0' on Success; error code otherwise.
+ */
+int dpmcp_destroy(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * dpmcp_reset() - Reset the DPMCP, returns the object to initial state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_reset(struct fsl_mc_io *mc_io, uint16_t token);
+
+/* IRQ */
+/*!
+ * @name dpmcp IRQ Index and Events
+ */
+#define DPMCP_IRQ_INDEX                             0
+/*!< Irq index */
+#define DPMCP_IRQ_EVENT_CMD_DONE                    0x00000001
+/*!< irq event - Indicates that the link state changed */
+/* @} */
+
+/**
+ * dpmcp_set_irq() - Set IRQ information for the DPMCP to trigger an interrupt.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: Identifies the interrupt index to configure
+ * @irq_addr:  Address that must be written to
+ *                             signal a message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: A user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_set_irq(struct fsl_mc_io     *mc_io,
+                 uint16_t              token,
+                uint8_t                irq_index,
+                uint64_t               irq_addr,
+                uint32_t               irq_val,
+                int                    user_irq_id);
+
+/**
+ * dpmcp_get_irq() - Get IRQ information from the DPMCP.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @type:      Interrupt type: 0 represents message interrupt
+ *                             type (both irq_addr and irq_val are valid)
+ * @irq_addr:  Returned address that must be written to
+ *                             signal the message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: A user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_get_irq(struct fsl_mc_io     *mc_io,
+                 uint16_t              token,
+                uint8_t                irq_index,
+                int                    *type,
+                uint64_t               *irq_addr,
+                uint32_t               *irq_val,
+                int                    *user_irq_id);
+
+/**
+ * dpmcp_set_irq_enable() - Set overall interrupt state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @en:        Interrupt state - enable = 1, disable = 0
+ *
+ * Allows GPP software to control when interrupts are generated.
+ * Each interrupt can have up to 32 causes.  The enable/disable control's the
+ * overall interrupt state. if the interrupt is disabled no causes will cause
+ * an interrupt.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_set_irq_enable(struct fsl_mc_io      *mc_io,
+                        uint16_t               token,
+                       uint8_t                 irq_index,
+                       uint8_t                 en);
+
+/**
+ * dpmcp_get_irq_enable() - Get overall interrupt state
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @en:                Returned interrupt state - enable = 1, disable = 0
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_get_irq_enable(struct fsl_mc_io      *mc_io,
+                        uint16_t               token,
+                       uint8_t                 irq_index,
+                       uint8_t                 *en);
+
+/**
+ * dpmcp_set_irq_mask() - Set interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @mask:      Event mask to trigger interrupt;
+ *                     each bit:
+ *                             0 = ignore event
+ *                             1 = consider event for asserting IRQ
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_set_irq_mask(struct fsl_mc_io        *mc_io,
+                      uint16_t         token,
+                     uint8_t           irq_index,
+                     uint32_t          mask);
+
+/**
+ * dpmcp_get_irq_mask() - Get interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @mask:      Returned event mask to trigger interrupt
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_get_irq_mask(struct fsl_mc_io        *mc_io,
+                      uint16_t         token,
+                     uint8_t           irq_index,
+                     uint32_t          *mask);
+
+/**
+ * dpmcp_get_irq_status() - Get the current status of any pending interrupts.
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @status:    Returned interrupts status - one bit per cause:
+ *                     0 = no interrupt pending
+ *                     1 = interrupt pending
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_get_irq_status(struct fsl_mc_io      *mc_io,
+                        uint16_t               token,
+                       uint8_t                 irq_index,
+                       uint32_t                *status);
+
+/**
+ * dpmcp_clear_irq_status() - Clear a pending interrupt's status
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @irq_index: The interrupt index to configure
+ * @status:    Bits to clear (W1C) - one bit per cause:
+ *                                     0 = don't change
+ *                                     1 = clear status bit
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_clear_irq_status(struct fsl_mc_io    *mc_io,
+                          uint16_t             token,
+                         uint8_t               irq_index,
+                         uint32_t              status);
+
+/**
+ * struct dpmcp_attr - Structure representing DPMCP attributes
+ * @id:                DPMCP object ID
+ * @version:   DPMCP version
+ */
+struct dpmcp_attr {
+       int id;
+       /**
+        * struct version - Structure representing DPMCP version
+        * @major:      DPMCP major version
+        * @minor:      DPMCP minor version
+        */
+       struct {
+               uint16_t major;
+               uint16_t minor;
+       } version;
+};
+
+/**
+ * dpmcp_get_attributes - Retrieve DPMCP attributes.
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPMCP object
+ * @attr:      Returned object's attributes
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmcp_get_attributes(struct fsl_mc_io      *mc_io,
+                        uint16_t               token,
+                       struct dpmcp_attr       *attr);
+
+#endif /* __FSL_DPMCP_H */
diff --git a/drivers/staging/fsl-mc/bus/dpmng-cmd.h b/drivers/staging/fsl-mc/bus/dpmng-cmd.h
new file mode 100644 (file)
index 0000000..ba8cfa9
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the above-listed copyright holders nor the
+ *       names of any contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+/*************************************************************************//*
+ dpmng-cmd.h
+
+ defines portal commands
+
+ *//**************************************************************************/
+
+#ifndef __FSL_DPMNG_CMD_H
+#define __FSL_DPMNG_CMD_H
+
+/* Command IDs */
+#define DPMNG_CMDID_GET_CONT_ID                        0x830
+#define DPMNG_CMDID_GET_VERSION                        0x831
+
+#endif /* __FSL_DPMNG_CMD_H */
diff --git a/drivers/staging/fsl-mc/bus/dpmng.c b/drivers/staging/fsl-mc/bus/dpmng.c
new file mode 100644 (file)
index 0000000..58328e8
--- /dev/null
@@ -0,0 +1,78 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the above-listed copyright holders nor the
+* names of any contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+*
+* ALTERNATIVELY, this software may be distributed under the terms of the
+* GNU General Public License ("GPL") as published by the Free Software
+* Foundation, either version 2 of that License or (at your option) any
+* later version.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT 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.
+*/
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "../include/dpmng.h"
+#include "dpmng-cmd.h"
+
+int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
+                                         MC_CMD_PRI_LOW, 0);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       mc_ver_info->revision = mc_dec(cmd.params[0], 0, 32);
+       mc_ver_info->major = mc_dec(cmd.params[0], 32, 32);
+       mc_ver_info->minor = mc_dec(cmd.params[1], 0, 32);
+
+       return 0;
+}
+
+int dpmng_get_container_id(struct fsl_mc_io *mc_io, int *container_id)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_CONT_ID,
+                                         MC_CMD_PRI_LOW, 0);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *container_id = mc_dec(cmd.params[0], 0, 32);
+
+       return 0;
+}
+
diff --git a/drivers/staging/fsl-mc/bus/dprc-cmd.h b/drivers/staging/fsl-mc/bus/dprc-cmd.h
new file mode 100644 (file)
index 0000000..0920248
--- /dev/null
@@ -0,0 +1,84 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the above-listed copyright holders nor the
+ *       names of any contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+/*************************************************************************//*
+ dprc-cmd.h
+
+ defines dprc portal commands
+
+ *//**************************************************************************/
+
+#ifndef _FSL_DPRC_CMD_H
+#define _FSL_DPRC_CMD_H
+
+/* DPRC Version */
+#define DPRC_VER_MAJOR                         3
+#define DPRC_VER_MINOR                         0
+
+/* Command IDs */
+#define DPRC_CMDID_CLOSE                       0x800
+#define DPRC_CMDID_OPEN                                0x805
+#define DPRC_CMDID_CREATE                      0x905
+
+#define DPRC_CMDID_GET_ATTR                    0x004
+#define DPRC_CMDID_RESET_CONT                  0x005
+
+#define DPRC_CMDID_SET_IRQ                     0x010
+#define DPRC_CMDID_GET_IRQ                     0x011
+#define DPRC_CMDID_SET_IRQ_ENABLE              0x012
+#define DPRC_CMDID_GET_IRQ_ENABLE              0x013
+#define DPRC_CMDID_SET_IRQ_MASK                        0x014
+#define DPRC_CMDID_GET_IRQ_MASK                        0x015
+#define DPRC_CMDID_GET_IRQ_STATUS              0x016
+#define DPRC_CMDID_CLEAR_IRQ_STATUS            0x017
+
+#define DPRC_CMDID_CREATE_CONT                 0x151
+#define DPRC_CMDID_DESTROY_CONT                        0x152
+#define DPRC_CMDID_SET_RES_QUOTA               0x155
+#define DPRC_CMDID_GET_RES_QUOTA               0x156
+#define DPRC_CMDID_ASSIGN                      0x157
+#define DPRC_CMDID_UNASSIGN                    0x158
+#define DPRC_CMDID_GET_OBJ_COUNT               0x159
+#define DPRC_CMDID_GET_OBJ                     0x15A
+#define DPRC_CMDID_GET_RES_COUNT               0x15B
+#define DPRC_CMDID_GET_RES_IDS                 0x15C
+#define DPRC_CMDID_GET_OBJ_REG                 0x15E
+
+#define DPRC_CMDID_CONNECT                     0x167
+#define DPRC_CMDID_DISCONNECT                  0x168
+#define DPRC_CMDID_GET_POOL                    0x169
+#define DPRC_CMDID_GET_POOL_COUNT              0x16A
+#define DPRC_CMDID_GET_PORTAL_PADDR            0x16B
+
+#define DPRC_CMDID_GET_CONNECTION              0x16C
+
+#endif /* _FSL_DPRC_CMD_H */
diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c
new file mode 100644 (file)
index 0000000..65de1d7
--- /dev/null
@@ -0,0 +1,486 @@
+/*
+ * Freescale data path resource container (DPRC) driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <German.Rivera@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include "../include/mc-sys.h"
+#include <linux/module.h>
+#include <linux/slab.h>
+#include "dprc-cmd.h"
+
+struct dprc_child_objs {
+       int child_count;
+       struct dprc_obj_desc *child_array;
+};
+
+static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)
+{
+       int i;
+       struct dprc_child_objs *objs;
+       struct fsl_mc_device *mc_dev;
+
+       WARN_ON(!dev);
+       WARN_ON(!data);
+       mc_dev = to_fsl_mc_device(dev);
+       objs = data;
+
+       for (i = 0; i < objs->child_count; i++) {
+               struct dprc_obj_desc *obj_desc = &objs->child_array[i];
+
+               if (strlen(obj_desc->type) != 0 &&
+                   FSL_MC_DEVICE_MATCH(mc_dev, obj_desc))
+                       break;
+       }
+
+       if (i == objs->child_count)
+               fsl_mc_device_remove(mc_dev);
+
+       return 0;
+}
+
+static int __fsl_mc_device_remove(struct device *dev, void *data)
+{
+       WARN_ON(!dev);
+       WARN_ON(data);
+       fsl_mc_device_remove(to_fsl_mc_device(dev));
+       return 0;
+}
+
+/**
+ * dprc_remove_devices - Removes devices for objects removed from a DPRC
+ *
+ * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ * @obj_desc_array: array of object descriptors for child objects currently
+ * present in the DPRC in the MC.
+ * @num_child_objects_in_mc: number of entries in obj_desc_array
+ *
+ * Synchronizes the state of the Linux bus driver with the actual state of
+ * the MC by removing devices that represent MC objects that have
+ * been dynamically removed in the physical DPRC.
+ */
+static void dprc_remove_devices(struct fsl_mc_device *mc_bus_dev,
+                               struct dprc_obj_desc *obj_desc_array,
+                               int num_child_objects_in_mc)
+{
+       if (num_child_objects_in_mc != 0) {
+               /*
+                * Remove child objects that are in the DPRC in Linux,
+                * but not in the MC:
+                */
+               struct dprc_child_objs objs;
+
+               objs.child_count = num_child_objects_in_mc;
+               objs.child_array = obj_desc_array;
+               device_for_each_child(&mc_bus_dev->dev, &objs,
+                                     __fsl_mc_device_remove_if_not_in_mc);
+       } else {
+               /*
+                * There are no child objects for this DPRC in the MC.
+                * So, remove all the child devices from Linux:
+                */
+               device_for_each_child(&mc_bus_dev->dev, NULL,
+                                     __fsl_mc_device_remove);
+       }
+}
+
+static int __fsl_mc_device_match(struct device *dev, void *data)
+{
+       struct dprc_obj_desc *obj_desc = data;
+       struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+
+       return FSL_MC_DEVICE_MATCH(mc_dev, obj_desc);
+}
+
+static struct fsl_mc_device *fsl_mc_device_lookup(struct dprc_obj_desc
+                                                               *obj_desc,
+                                                 struct fsl_mc_device
+                                                               *mc_bus_dev)
+{
+       struct device *dev;
+
+       dev = device_find_child(&mc_bus_dev->dev, obj_desc,
+                               __fsl_mc_device_match);
+
+       return dev ? to_fsl_mc_device(dev) : NULL;
+}
+
+/**
+ * dprc_add_new_devices - Adds devices to the logical bus for a DPRC
+ *
+ * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ * @obj_desc_array: array of device descriptors for child devices currently
+ * present in the physical DPRC.
+ * @num_child_objects_in_mc: number of entries in obj_desc_array
+ *
+ * Synchronizes the state of the Linux bus driver with the actual
+ * state of the MC by adding objects that have been newly discovered
+ * in the physical DPRC.
+ */
+static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
+                                struct dprc_obj_desc *obj_desc_array,
+                                int num_child_objects_in_mc)
+{
+       int error;
+       int i;
+
+       for (i = 0; i < num_child_objects_in_mc; i++) {
+               struct fsl_mc_device *child_dev;
+               struct fsl_mc_io *mc_io = NULL;
+               struct dprc_obj_desc *obj_desc = &obj_desc_array[i];
+
+               if (strlen(obj_desc->type) == 0)
+                       continue;
+
+               /*
+                * Check if device is already known to Linux:
+                */
+               child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
+               if (child_dev)
+                       continue;
+
+               error = fsl_mc_device_add(obj_desc, mc_io, &mc_bus_dev->dev,
+                                         &child_dev);
+               if (error < 0) {
+                       if (mc_io)
+                               fsl_destroy_mc_io(mc_io);
+
+                       continue;
+               }
+       }
+}
+
+static void dprc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
+{
+       int pool_type;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+
+       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++) {
+               struct fsl_mc_resource_pool *res_pool =
+                   &mc_bus->resource_pools[pool_type];
+
+               res_pool->type = pool_type;
+               res_pool->max_count = 0;
+               res_pool->free_count = 0;
+               res_pool->mc_bus = mc_bus;
+               INIT_LIST_HEAD(&res_pool->free_list);
+               mutex_init(&res_pool->mutex);
+       }
+}
+
+static void dprc_cleanup_resource_pool(struct fsl_mc_device *mc_bus_dev,
+                                      enum fsl_mc_pool_type pool_type)
+{
+       struct fsl_mc_resource *resource;
+       struct fsl_mc_resource *next;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       struct fsl_mc_resource_pool *res_pool =
+                                       &mc_bus->resource_pools[pool_type];
+       int free_count = 0;
+
+       WARN_ON(res_pool->type != pool_type);
+       WARN_ON(res_pool->free_count != res_pool->max_count);
+
+       list_for_each_entry_safe(resource, next, &res_pool->free_list, node) {
+               free_count++;
+               WARN_ON(resource->type != res_pool->type);
+               WARN_ON(resource->parent_pool != res_pool);
+               devm_kfree(&mc_bus_dev->dev, resource);
+       }
+
+       WARN_ON(free_count != res_pool->free_count);
+}
+
+static void dprc_cleanup_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
+{
+       int pool_type;
+
+       for (pool_type = 0; pool_type < FSL_MC_NUM_POOL_TYPES; pool_type++)
+               dprc_cleanup_resource_pool(mc_bus_dev, pool_type);
+}
+
+static void reorder_obj_desc_array(struct dprc_obj_desc *obj_desc_array,
+                                  int num_devs)
+{
+       struct dprc_obj_desc tmp;
+       struct dprc_obj_desc *top_cursor = &obj_desc_array[0];
+       struct dprc_obj_desc *bottom_cursor = &obj_desc_array[num_devs - 1];
+
+       /*
+        * Reorder entries in obj_desc_array so that all allocatable devices
+        * are placed before all non-allocatable devices:
+        *
+        * Loop Invariant: everything before top_cursor is allocatable and
+        * everything after bottom_cursor is non-allocatable.
+        */
+       while (top_cursor < bottom_cursor) {
+               if (FSL_MC_IS_ALLOCATABLE(top_cursor->type)) {
+                       top_cursor++;
+               } else {
+                       if (FSL_MC_IS_ALLOCATABLE(bottom_cursor->type)) {
+                               tmp = *bottom_cursor;
+                               *bottom_cursor = *top_cursor;
+                               *top_cursor = tmp;
+                               top_cursor++;
+                       }
+
+                       bottom_cursor--;
+               }
+       }
+}
+
+/**
+ * dprc_scan_objects - Discover objects in a DPRC
+ *
+ * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ *
+ * Detects objects added and removed from a DPRC and synchronizes the
+ * state of the Linux bus driver, MC by adding and removing
+ * devices accordingly.
+ * Two types of devices can be found in a DPRC: allocatable objects (e.g.,
+ * dpbp, dpmcp) and non-allocatable devices (e.g., dprc, dpni).
+ * All allocatable devices needed to be probed before all non-allocatable
+ * devices, to ensure that device drivers for non-allocatable
+ * devices can allocate any type of allocatable devices.
+ * That is, we need to ensure that the corresponding resource pools are
+ * populated before they can get allocation requests from probe callbacks
+ * of the device drivers for the non-allocatable devices.
+ */
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
+{
+       int num_child_objects;
+       int dprc_get_obj_failures;
+       int error;
+       struct dprc_obj_desc *child_obj_desc_array = NULL;
+
+       error = dprc_get_obj_count(mc_bus_dev->mc_io,
+                                  mc_bus_dev->mc_handle,
+                                  &num_child_objects);
+       if (error < 0) {
+               dev_err(&mc_bus_dev->dev, "dprc_get_obj_count() failed: %d\n",
+                       error);
+               return error;
+       }
+
+       if (num_child_objects != 0) {
+               int i;
+
+               child_obj_desc_array =
+                   devm_kmalloc_array(&mc_bus_dev->dev, num_child_objects,
+                                      sizeof(*child_obj_desc_array),
+                                      GFP_KERNEL);
+               if (!child_obj_desc_array)
+                       return -ENOMEM;
+
+               /*
+                * Discover objects currently present in the physical DPRC:
+                */
+               dprc_get_obj_failures = 0;
+               for (i = 0; i < num_child_objects; i++) {
+                       struct dprc_obj_desc *obj_desc =
+                           &child_obj_desc_array[i];
+
+                       error = dprc_get_obj(mc_bus_dev->mc_io,
+                                            mc_bus_dev->mc_handle,
+                                            i, obj_desc);
+                       if (error < 0) {
+                               dev_err(&mc_bus_dev->dev,
+                                       "dprc_get_obj(i=%d) failed: %d\n",
+                                       i, error);
+                               /*
+                                * Mark the obj entry as "invalid", by using the
+                                * empty string as obj type:
+                                */
+                               obj_desc->type[0] = '\0';
+                               obj_desc->id = error;
+                               dprc_get_obj_failures++;
+                               continue;
+                       }
+
+                       dev_dbg(&mc_bus_dev->dev,
+                               "Discovered object: type %s, id %d\n",
+                               obj_desc->type, obj_desc->id);
+               }
+
+               if (dprc_get_obj_failures != 0) {
+                       dev_err(&mc_bus_dev->dev,
+                               "%d out of %d devices could not be retrieved\n",
+                               dprc_get_obj_failures, num_child_objects);
+               }
+
+               reorder_obj_desc_array(child_obj_desc_array, num_child_objects);
+       }
+
+       dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
+                           num_child_objects);
+
+       dprc_add_new_devices(mc_bus_dev, child_obj_desc_array,
+                            num_child_objects);
+
+       if (child_obj_desc_array)
+               devm_kfree(&mc_bus_dev->dev, child_obj_desc_array);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(dprc_scan_objects);
+
+/**
+ * dprc_scan_container - Scans a physical DPRC and synchronizes Linux bus state
+ *
+ * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
+ *
+ * Scans the physical DPRC and synchronizes the state of the Linux
+ * bus driver with the actual state of the MC by adding and removing
+ * devices as appropriate.
+ */
+int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
+{
+       int error;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
+
+       dprc_init_all_resource_pools(mc_bus_dev);
+
+       /*
+        * Discover objects in the DPRC:
+        */
+       mutex_lock(&mc_bus->scan_mutex);
+       error = dprc_scan_objects(mc_bus_dev);
+       mutex_unlock(&mc_bus->scan_mutex);
+       if (error < 0)
+               goto error;
+
+       return 0;
+error:
+       dprc_cleanup_all_resource_pools(mc_bus_dev);
+       return error;
+}
+EXPORT_SYMBOL_GPL(dprc_scan_container);
+
+/**
+ * dprc_probe - callback invoked when a DPRC is being bound to this driver
+ *
+ * @mc_dev: Pointer to fsl-mc device representing a DPRC
+ *
+ * It opens the physical DPRC in the MC.
+ * It scans the DPRC to discover the MC objects contained in it.
+ * It creates the interrupt pool for the MC bus associated with the DPRC.
+ * It configures the interrupts for the DPRC device itself.
+ */
+static int dprc_probe(struct fsl_mc_device *mc_dev)
+{
+       int error;
+       size_t region_size;
+       struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
+
+       if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
+               return -EINVAL;
+
+       if (!mc_dev->mc_io) {
+               /*
+                * This is a child DPRC:
+                */
+               if (WARN_ON(mc_dev->obj_desc.region_count == 0))
+                       return -EINVAL;
+
+               region_size = mc_dev->regions[0].end -
+                             mc_dev->regions[0].start + 1;
+
+               error = fsl_create_mc_io(&mc_dev->dev,
+                                        mc_dev->regions[0].start,
+                                        region_size,
+                                        NULL, 0, &mc_dev->mc_io);
+               if (error < 0)
+                       return error;
+       }
+
+       error = dprc_open(mc_dev->mc_io, mc_dev->obj_desc.id,
+                         &mc_dev->mc_handle);
+       if (error < 0) {
+               dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
+               goto error_cleanup_mc_io;
+       }
+
+       mutex_init(&mc_bus->scan_mutex);
+
+       /*
+        * Discover MC objects in DPRC object:
+        */
+       error = dprc_scan_container(mc_dev);
+       if (error < 0)
+               goto error_cleanup_open;
+
+       dev_info(&mc_dev->dev, "DPRC device bound to driver");
+       return 0;
+
+error_cleanup_open:
+       (void)dprc_close(mc_dev->mc_io, mc_dev->mc_handle);
+
+error_cleanup_mc_io:
+       fsl_destroy_mc_io(mc_dev->mc_io);
+       return error;
+}
+
+/**
+ * dprc_remove - callback invoked when a DPRC is being unbound from this driver
+ *
+ * @mc_dev: Pointer to fsl-mc device representing the DPRC
+ *
+ * It removes the DPRC's child objects from Linux (not from the MC) and
+ * closes the DPRC device in the MC.
+ * It tears down the interrupts that were configured for the DPRC device.
+ * It destroys the interrupt pool associated with this MC bus.
+ */
+static int dprc_remove(struct fsl_mc_device *mc_dev)
+{
+       int error;
+
+       if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0))
+               return -EINVAL;
+       if (WARN_ON(!mc_dev->mc_io))
+               return -EINVAL;
+
+       device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
+       dprc_cleanup_all_resource_pools(mc_dev);
+       error = dprc_close(mc_dev->mc_io, mc_dev->mc_handle);
+       if (error < 0)
+               dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
+
+       dev_info(&mc_dev->dev, "DPRC device unbound from driver");
+       return 0;
+}
+
+static const struct fsl_mc_device_match_id match_id_table[] = {
+       {
+        .vendor = FSL_MC_VENDOR_FREESCALE,
+        .obj_type = "dprc",
+        .ver_major = DPRC_VER_MAJOR,
+        .ver_minor = DPRC_VER_MINOR},
+       {.vendor = 0x0},
+};
+
+static struct fsl_mc_driver dprc_driver = {
+       .driver = {
+                  .name = FSL_MC_DPRC_DRIVER_NAME,
+                  .owner = THIS_MODULE,
+                  .pm = NULL,
+                  },
+       .match_id_table = match_id_table,
+       .probe = dprc_probe,
+       .remove = dprc_remove,
+};
+
+int __init dprc_driver_init(void)
+{
+       return fsl_mc_driver_register(&dprc_driver);
+}
+
+void __exit dprc_driver_exit(void)
+{
+       fsl_mc_driver_unregister(&dprc_driver);
+}
diff --git a/drivers/staging/fsl-mc/bus/dprc.c b/drivers/staging/fsl-mc/bus/dprc.c
new file mode 100644 (file)
index 0000000..19b26e6
--- /dev/null
@@ -0,0 +1,913 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the above-listed copyright holders nor the
+* names of any contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+*
+* ALTERNATIVELY, this software may be distributed under the terms of the
+* GNU General Public License ("GPL") as published by the Free Software
+* Foundation, either version 2 of that License or (at your option) any
+* later version.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT 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.
+*/
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include "../include/dprc.h"
+#include "dprc-cmd.h"
+
+int dprc_open(struct fsl_mc_io *mc_io, int container_id, uint16_t *token)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, MC_CMD_PRI_LOW,
+                                         0);
+       cmd.params[0] |= mc_enc(0, 32, container_id);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_open);
+
+int dprc_close(struct fsl_mc_io *mc_io, uint16_t token)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLOSE, MC_CMD_PRI_HIGH,
+                                         token);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+EXPORT_SYMBOL(dprc_close);
+
+int dprc_create_container(struct fsl_mc_io *mc_io,
+                         uint16_t token,
+                         struct dprc_cfg *cfg,
+                         int *child_container_id,
+                         uint64_t *child_portal_paddr)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.params[0] |= mc_enc(32, 16, cfg->icid);
+       cmd.params[0] |= mc_enc(0, 32, cfg->options);
+       cmd.params[1] |= mc_enc(32, 32, cfg->portal_id);
+
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *child_container_id = mc_dec(cmd.params[1], 0, 32);
+       *child_portal_paddr = mc_dec(cmd.params[2], 0, 64);
+
+       return 0;
+}
+
+int dprc_destroy_container(struct fsl_mc_io *mc_io,
+                          uint16_t token,
+                          int child_container_id)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, child_container_id);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_reset_container(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                        int child_container_id)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, child_container_id);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_irq(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                uint8_t irq_index,
+                int *type,
+                uint64_t *irq_paddr,
+                uint32_t *irq_val,
+                int *user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *irq_val = mc_dec(cmd.params[0], 0, 32);
+       *irq_paddr = mc_dec(cmd.params[1], 0, 64);
+       *user_irq_id = mc_dec(cmd.params[2], 0, 32);
+       *type = mc_dec(cmd.params[2], 32, 32);
+
+       return 0;
+}
+
+int dprc_set_irq(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                uint8_t irq_index,
+                uint64_t irq_paddr,
+                uint32_t irq_val,
+                int user_irq_id)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+       cmd.params[0] |= mc_enc(0, 32, irq_val);
+       cmd.params[1] |= mc_enc(0, 64, irq_paddr);
+       cmd.params[2] |= mc_enc(0, 32, user_irq_id);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t *en)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *en = mc_dec(cmd.params[0], 0, 8);
+
+       return 0;
+}
+
+int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint8_t en)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_ENABLE,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 8, en);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t *mask)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *mask = mc_dec(cmd.params[0], 0, 32);
+
+       return 0;
+}
+
+int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t token,
+                     uint8_t irq_index,
+                     uint32_t mask)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_MASK,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, mask);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_irq_status(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       uint8_t irq_index,
+                       uint32_t *status)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *status = mc_dec(cmd.params[0], 0, 32);
+
+       return 0;
+}
+
+int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
+                         uint16_t token,
+                         uint8_t irq_index,
+                         uint32_t status)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLEAR_IRQ_STATUS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, status);
+       cmd.params[0] |= mc_enc(32, 8, irq_index);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_attributes(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       struct dprc_attributes *attr)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_ATTR,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       attr->container_id = mc_dec(cmd.params[0], 0, 32);
+       attr->icid = mc_dec(cmd.params[0], 32, 16);
+       attr->options = mc_dec(cmd.params[1], 0, 32);
+       attr->portal_id = mc_dec(cmd.params[1], 32, 32);
+       attr->version.major = mc_dec(cmd.params[2], 0, 16);
+       attr->version.minor = mc_dec(cmd.params[2], 16, 16);
+
+       return 0;
+}
+
+int dprc_set_res_quota(struct fsl_mc_io *mc_io,
+                      uint16_t token,
+                      int child_container_id,
+                      char *type,
+                      uint16_t quota)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_RES_QUOTA,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, child_container_id);
+       cmd.params[0] |= mc_enc(32, 16, quota);
+       cmd.params[1] |= mc_enc(0, 8, type[0]);
+       cmd.params[1] |= mc_enc(8, 8, type[1]);
+       cmd.params[1] |= mc_enc(16, 8, type[2]);
+       cmd.params[1] |= mc_enc(24, 8, type[3]);
+       cmd.params[1] |= mc_enc(32, 8, type[4]);
+       cmd.params[1] |= mc_enc(40, 8, type[5]);
+       cmd.params[1] |= mc_enc(48, 8, type[6]);
+       cmd.params[1] |= mc_enc(56, 8, type[7]);
+       cmd.params[2] |= mc_enc(0, 8, type[8]);
+       cmd.params[2] |= mc_enc(8, 8, type[9]);
+       cmd.params[2] |= mc_enc(16, 8, type[10]);
+       cmd.params[2] |= mc_enc(24, 8, type[11]);
+       cmd.params[2] |= mc_enc(32, 8, type[12]);
+       cmd.params[2] |= mc_enc(40, 8, type[13]);
+       cmd.params[2] |= mc_enc(48, 8, type[14]);
+       cmd.params[2] |= mc_enc(56, 8, '\0');
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_res_quota(struct fsl_mc_io *mc_io,
+                      uint16_t token,
+                      int child_container_id,
+                      char *type,
+                      uint16_t *quota)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_QUOTA,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, child_container_id);
+       cmd.params[1] |= mc_enc(0, 8, type[0]);
+       cmd.params[1] |= mc_enc(8, 8, type[1]);
+       cmd.params[1] |= mc_enc(16, 8, type[2]);
+       cmd.params[1] |= mc_enc(24, 8, type[3]);
+       cmd.params[1] |= mc_enc(32, 8, type[4]);
+       cmd.params[1] |= mc_enc(40, 8, type[5]);
+       cmd.params[1] |= mc_enc(48, 8, type[6]);
+       cmd.params[1] |= mc_enc(56, 8, type[7]);
+       cmd.params[2] |= mc_enc(0, 8, type[8]);
+       cmd.params[2] |= mc_enc(8, 8, type[9]);
+       cmd.params[2] |= mc_enc(16, 8, type[10]);
+       cmd.params[2] |= mc_enc(24, 8, type[11]);
+       cmd.params[2] |= mc_enc(32, 8, type[12]);
+       cmd.params[2] |= mc_enc(40, 8, type[13]);
+       cmd.params[2] |= mc_enc(48, 8, type[14]);
+       cmd.params[2] |= mc_enc(56, 8, '\0');
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *quota = mc_dec(cmd.params[0], 32, 16);
+
+       return 0;
+}
+
+int dprc_assign(struct fsl_mc_io *mc_io,
+               uint16_t token,
+               int container_id,
+               struct dprc_res_req *res_req)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_ASSIGN,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, container_id);
+       cmd.params[0] |= mc_enc(32, 32, res_req->options);
+       cmd.params[1] |= mc_enc(0, 32, res_req->num);
+       cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align);
+       cmd.params[2] |= mc_enc(0, 8, res_req->type[0]);
+       cmd.params[2] |= mc_enc(8, 8, res_req->type[1]);
+       cmd.params[2] |= mc_enc(16, 8, res_req->type[2]);
+       cmd.params[2] |= mc_enc(24, 8, res_req->type[3]);
+       cmd.params[2] |= mc_enc(32, 8, res_req->type[4]);
+       cmd.params[2] |= mc_enc(40, 8, res_req->type[5]);
+       cmd.params[2] |= mc_enc(48, 8, res_req->type[6]);
+       cmd.params[2] |= mc_enc(56, 8, res_req->type[7]);
+       cmd.params[3] |= mc_enc(0, 8, res_req->type[8]);
+       cmd.params[3] |= mc_enc(8, 8, res_req->type[9]);
+       cmd.params[3] |= mc_enc(16, 8, res_req->type[10]);
+       cmd.params[3] |= mc_enc(24, 8, res_req->type[11]);
+       cmd.params[3] |= mc_enc(32, 8, res_req->type[12]);
+       cmd.params[3] |= mc_enc(40, 8, res_req->type[13]);
+       cmd.params[3] |= mc_enc(48, 8, res_req->type[14]);
+       cmd.params[3] |= mc_enc(56, 8, res_req->type[15]);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_unassign(struct fsl_mc_io *mc_io,
+                 uint16_t token,
+                 int child_container_id,
+                 struct dprc_res_req *res_req)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_UNASSIGN,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, child_container_id);
+       cmd.params[0] |= mc_enc(32, 32, res_req->options);
+       cmd.params[1] |= mc_enc(0, 32, res_req->num);
+       cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align);
+       cmd.params[2] |= mc_enc(0, 8, res_req->type[0]);
+       cmd.params[2] |= mc_enc(8, 8, res_req->type[1]);
+       cmd.params[2] |= mc_enc(16, 8, res_req->type[2]);
+       cmd.params[2] |= mc_enc(24, 8, res_req->type[3]);
+       cmd.params[2] |= mc_enc(32, 8, res_req->type[4]);
+       cmd.params[2] |= mc_enc(40, 8, res_req->type[5]);
+       cmd.params[2] |= mc_enc(48, 8, res_req->type[6]);
+       cmd.params[2] |= mc_enc(56, 8, res_req->type[7]);
+       cmd.params[3] |= mc_enc(0, 8, res_req->type[8]);
+       cmd.params[3] |= mc_enc(8, 8, res_req->type[9]);
+       cmd.params[3] |= mc_enc(16, 8, res_req->type[10]);
+       cmd.params[3] |= mc_enc(24, 8, res_req->type[11]);
+       cmd.params[3] |= mc_enc(32, 8, res_req->type[12]);
+       cmd.params[3] |= mc_enc(40, 8, res_req->type[13]);
+       cmd.params[3] |= mc_enc(48, 8, res_req->type[14]);
+       cmd.params[3] |= mc_enc(56, 8, res_req->type[15]);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_pool_count(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       int *pool_count)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL_COUNT,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *pool_count = mc_dec(cmd.params[0], 0, 32);
+
+       return 0;
+}
+
+int dprc_get_pool(struct fsl_mc_io *mc_io,
+                 uint16_t token,
+                 int pool_index,
+                 char *type)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, pool_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       type[0] = mc_dec(cmd.params[1], 0, 8);
+       type[1] = mc_dec(cmd.params[1], 8, 8);
+       type[2] = mc_dec(cmd.params[1], 16, 8);
+       type[3] = mc_dec(cmd.params[1], 24, 8);
+       type[4] = mc_dec(cmd.params[1], 32, 8);
+       type[5] = mc_dec(cmd.params[1], 40, 8);
+       type[6] = mc_dec(cmd.params[1], 48, 8);
+       type[7] = mc_dec(cmd.params[1], 56, 8);
+       type[8] = mc_dec(cmd.params[2], 0, 8);
+       type[9] = mc_dec(cmd.params[2], 8, 8);
+       type[10] = mc_dec(cmd.params[2], 16, 8);
+       type[11] = mc_dec(cmd.params[2], 24, 8);
+       type[12] = mc_dec(cmd.params[2], 32, 8);
+       type[13] = mc_dec(cmd.params[2], 40, 8);
+       type[14] = mc_dec(cmd.params[2], 48, 8);
+       type[15] = '\0';
+
+       return 0;
+}
+
+int dprc_get_obj_count(struct fsl_mc_io *mc_io, uint16_t token, int *obj_count)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT,
+                                         MC_CMD_PRI_LOW, token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *obj_count = mc_dec(cmd.params[0], 32, 32);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_obj_count);
+
+int dprc_get_obj(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                int obj_index,
+                struct dprc_obj_desc *obj_desc)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, obj_index);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       obj_desc->id = mc_dec(cmd.params[0], 32, 32);
+       obj_desc->vendor = mc_dec(cmd.params[1], 0, 16);
+       obj_desc->irq_count = mc_dec(cmd.params[1], 16, 8);
+       obj_desc->region_count = mc_dec(cmd.params[1], 24, 8);
+       obj_desc->state = mc_dec(cmd.params[1], 32, 32);
+       obj_desc->ver_major = mc_dec(cmd.params[2], 0, 16);
+       obj_desc->ver_minor = mc_dec(cmd.params[2], 16, 16);
+       obj_desc->type[0] = mc_dec(cmd.params[3], 0, 8);
+       obj_desc->type[1] = mc_dec(cmd.params[3], 8, 8);
+       obj_desc->type[2] = mc_dec(cmd.params[3], 16, 8);
+       obj_desc->type[3] = mc_dec(cmd.params[3], 24, 8);
+       obj_desc->type[4] = mc_dec(cmd.params[3], 32, 8);
+       obj_desc->type[5] = mc_dec(cmd.params[3], 40, 8);
+       obj_desc->type[6] = mc_dec(cmd.params[3], 48, 8);
+       obj_desc->type[7] = mc_dec(cmd.params[3], 56, 8);
+       obj_desc->type[8] = mc_dec(cmd.params[4], 0, 8);
+       obj_desc->type[9] = mc_dec(cmd.params[4], 8, 8);
+       obj_desc->type[10] = mc_dec(cmd.params[4], 16, 8);
+       obj_desc->type[11] = mc_dec(cmd.params[4], 24, 8);
+       obj_desc->type[12] = mc_dec(cmd.params[4], 32, 8);
+       obj_desc->type[13] = mc_dec(cmd.params[4], 40, 8);
+       obj_desc->type[14] = mc_dec(cmd.params[4], 48, 8);
+       obj_desc->type[15] = '\0';
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_obj);
+
+int dprc_get_res_count(struct fsl_mc_io *mc_io,
+                      uint16_t token,
+                      char *type,
+                      int *res_count)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       *res_count = 0;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[1] |= mc_enc(0, 8, type[0]);
+       cmd.params[1] |= mc_enc(8, 8, type[1]);
+       cmd.params[1] |= mc_enc(16, 8, type[2]);
+       cmd.params[1] |= mc_enc(24, 8, type[3]);
+       cmd.params[1] |= mc_enc(32, 8, type[4]);
+       cmd.params[1] |= mc_enc(40, 8, type[5]);
+       cmd.params[1] |= mc_enc(48, 8, type[6]);
+       cmd.params[1] |= mc_enc(56, 8, type[7]);
+       cmd.params[2] |= mc_enc(0, 8, type[8]);
+       cmd.params[2] |= mc_enc(8, 8, type[9]);
+       cmd.params[2] |= mc_enc(16, 8, type[10]);
+       cmd.params[2] |= mc_enc(24, 8, type[11]);
+       cmd.params[2] |= mc_enc(32, 8, type[12]);
+       cmd.params[2] |= mc_enc(40, 8, type[13]);
+       cmd.params[2] |= mc_enc(48, 8, type[14]);
+       cmd.params[2] |= mc_enc(56, 8, '\0');
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *res_count = mc_dec(cmd.params[0], 0, 32);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_res_count);
+
+int dprc_get_res_ids(struct fsl_mc_io *mc_io,
+                    uint16_t token,
+                    char *type,
+                    struct dprc_res_ids_range_desc *range_desc)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(42, 7, range_desc->iter_status);
+       cmd.params[1] |= mc_enc(0, 32, range_desc->base_id);
+       cmd.params[1] |= mc_enc(32, 32, range_desc->last_id);
+       cmd.params[2] |= mc_enc(0, 8, type[0]);
+       cmd.params[2] |= mc_enc(8, 8, type[1]);
+       cmd.params[2] |= mc_enc(16, 8, type[2]);
+       cmd.params[2] |= mc_enc(24, 8, type[3]);
+       cmd.params[2] |= mc_enc(32, 8, type[4]);
+       cmd.params[2] |= mc_enc(40, 8, type[5]);
+       cmd.params[2] |= mc_enc(48, 8, type[6]);
+       cmd.params[2] |= mc_enc(56, 8, type[7]);
+       cmd.params[3] |= mc_enc(0, 8, type[8]);
+       cmd.params[3] |= mc_enc(8, 8, type[9]);
+       cmd.params[3] |= mc_enc(16, 8, type[10]);
+       cmd.params[3] |= mc_enc(24, 8, type[11]);
+       cmd.params[3] |= mc_enc(32, 8, type[12]);
+       cmd.params[3] |= mc_enc(40, 8, type[13]);
+       cmd.params[3] |= mc_enc(48, 8, type[14]);
+       cmd.params[3] |= mc_enc(56, 8, '\0');
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       range_desc->iter_status = mc_dec(cmd.params[0], 42, 7);
+       range_desc->base_id = mc_dec(cmd.params[1], 0, 32);
+       range_desc->last_id = mc_dec(cmd.params[1], 32, 32);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_res_ids);
+
+int dprc_get_portal_paddr(struct fsl_mc_io *mc_io,
+                         uint16_t token,
+                         int portal_id,
+                         uint64_t *portal_addr)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_PORTAL_PADDR,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, portal_id);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       *portal_addr = mc_dec(cmd.params[1], 0, 64);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_portal_paddr);
+
+int dprc_get_obj_region(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                       char *obj_type,
+                       int obj_id,
+                       uint8_t region_index,
+                       struct dprc_region_desc *region_desc)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG,
+                                         MC_CMD_PRI_LOW, token);
+       cmd.params[0] |= mc_enc(0, 32, obj_id);
+       cmd.params[0] |= mc_enc(48, 8, region_index);
+       cmd.params[3] |= mc_enc(0, 8, obj_type[0]);
+       cmd.params[3] |= mc_enc(8, 8, obj_type[1]);
+       cmd.params[3] |= mc_enc(16, 8, obj_type[2]);
+       cmd.params[3] |= mc_enc(24, 8, obj_type[3]);
+       cmd.params[3] |= mc_enc(32, 8, obj_type[4]);
+       cmd.params[3] |= mc_enc(40, 8, obj_type[5]);
+       cmd.params[3] |= mc_enc(48, 8, obj_type[6]);
+       cmd.params[3] |= mc_enc(56, 8, obj_type[7]);
+       cmd.params[4] |= mc_enc(0, 8, obj_type[8]);
+       cmd.params[4] |= mc_enc(8, 8, obj_type[9]);
+       cmd.params[4] |= mc_enc(16, 8, obj_type[10]);
+       cmd.params[4] |= mc_enc(24, 8, obj_type[11]);
+       cmd.params[4] |= mc_enc(32, 8, obj_type[12]);
+       cmd.params[4] |= mc_enc(40, 8, obj_type[13]);
+       cmd.params[4] |= mc_enc(48, 8, obj_type[14]);
+       cmd.params[4] |= mc_enc(56, 8, '\0');
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       region_desc->base_paddr = mc_dec(cmd.params[1], 0, 64);
+       region_desc->size = mc_dec(cmd.params[2], 0, 32);
+
+       return 0;
+}
+EXPORT_SYMBOL(dprc_get_obj_region);
+
+int dprc_connect(struct fsl_mc_io *mc_io,
+                uint16_t token,
+                const struct dprc_endpoint *endpoint1,
+                const struct dprc_endpoint *endpoint2)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, endpoint1->id);
+       cmd.params[0] |= mc_enc(32, 32, endpoint1->interface_id);
+       cmd.params[1] |= mc_enc(0, 32, endpoint2->id);
+       cmd.params[1] |= mc_enc(32, 32, endpoint2->interface_id);
+       cmd.params[2] |= mc_enc(0, 8, endpoint1->type[0]);
+       cmd.params[2] |= mc_enc(8, 8, endpoint1->type[1]);
+       cmd.params[2] |= mc_enc(16, 8, endpoint1->type[2]);
+       cmd.params[2] |= mc_enc(24, 8, endpoint1->type[3]);
+       cmd.params[2] |= mc_enc(32, 8, endpoint1->type[4]);
+       cmd.params[2] |= mc_enc(40, 8, endpoint1->type[5]);
+       cmd.params[2] |= mc_enc(48, 8, endpoint1->type[6]);
+       cmd.params[2] |= mc_enc(56, 8, endpoint1->type[7]);
+       cmd.params[3] |= mc_enc(0, 8, endpoint1->type[8]);
+       cmd.params[3] |= mc_enc(8, 8, endpoint1->type[9]);
+       cmd.params[3] |= mc_enc(16, 8, endpoint1->type[10]);
+       cmd.params[3] |= mc_enc(24, 8, endpoint1->type[11]);
+       cmd.params[3] |= mc_enc(32, 8, endpoint1->type[12]);
+       cmd.params[3] |= mc_enc(40, 8, endpoint1->type[13]);
+       cmd.params[3] |= mc_enc(48, 8, endpoint1->type[14]);
+       cmd.params[3] |= mc_enc(56, 8, endpoint1->type[15]);
+       cmd.params[5] |= mc_enc(0, 8, endpoint2->type[0]);
+       cmd.params[5] |= mc_enc(8, 8, endpoint2->type[1]);
+       cmd.params[5] |= mc_enc(16, 8, endpoint2->type[2]);
+       cmd.params[5] |= mc_enc(24, 8, endpoint2->type[3]);
+       cmd.params[5] |= mc_enc(32, 8, endpoint2->type[4]);
+       cmd.params[5] |= mc_enc(40, 8, endpoint2->type[5]);
+       cmd.params[5] |= mc_enc(48, 8, endpoint2->type[6]);
+       cmd.params[5] |= mc_enc(56, 8, endpoint2->type[7]);
+       cmd.params[6] |= mc_enc(0, 8, endpoint2->type[8]);
+       cmd.params[6] |= mc_enc(8, 8, endpoint2->type[9]);
+       cmd.params[6] |= mc_enc(16, 8, endpoint2->type[10]);
+       cmd.params[6] |= mc_enc(24, 8, endpoint2->type[11]);
+       cmd.params[6] |= mc_enc(32, 8, endpoint2->type[12]);
+       cmd.params[6] |= mc_enc(40, 8, endpoint2->type[13]);
+       cmd.params[6] |= mc_enc(48, 8, endpoint2->type[14]);
+       cmd.params[6] |= mc_enc(56, 8, endpoint2->type[15]);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_disconnect(struct fsl_mc_io *mc_io,
+                   uint16_t token,
+                   const struct dprc_endpoint *endpoint)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, endpoint->id);
+       cmd.params[0] |= mc_enc(32, 32, endpoint->interface_id);
+       cmd.params[1] |= mc_enc(0, 8, endpoint->type[0]);
+       cmd.params[1] |= mc_enc(8, 8, endpoint->type[1]);
+       cmd.params[1] |= mc_enc(16, 8, endpoint->type[2]);
+       cmd.params[1] |= mc_enc(24, 8, endpoint->type[3]);
+       cmd.params[1] |= mc_enc(32, 8, endpoint->type[4]);
+       cmd.params[1] |= mc_enc(40, 8, endpoint->type[5]);
+       cmd.params[1] |= mc_enc(48, 8, endpoint->type[6]);
+       cmd.params[1] |= mc_enc(56, 8, endpoint->type[7]);
+       cmd.params[2] |= mc_enc(0, 8, endpoint->type[8]);
+       cmd.params[2] |= mc_enc(8, 8, endpoint->type[9]);
+       cmd.params[2] |= mc_enc(16, 8, endpoint->type[10]);
+       cmd.params[2] |= mc_enc(24, 8, endpoint->type[11]);
+       cmd.params[2] |= mc_enc(32, 8, endpoint->type[12]);
+       cmd.params[2] |= mc_enc(40, 8, endpoint->type[13]);
+       cmd.params[2] |= mc_enc(48, 8, endpoint->type[14]);
+       cmd.params[2] |= mc_enc(56, 8, endpoint->type[15]);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dprc_get_connection(struct fsl_mc_io *mc_io,
+                       uint16_t token,
+                                       const struct dprc_endpoint *endpoint1,
+                                       struct dprc_endpoint *endpoint2,
+                                       int *state)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION,
+                                         MC_CMD_PRI_LOW,
+                                         token);
+       cmd.params[0] |= mc_enc(0, 32, endpoint1->id);
+       cmd.params[0] |= mc_enc(32, 32, endpoint1->interface_id);
+       cmd.params[1] |= mc_enc(0, 8, endpoint1->type[0]);
+       cmd.params[1] |= mc_enc(8, 8, endpoint1->type[1]);
+       cmd.params[1] |= mc_enc(16, 8, endpoint1->type[2]);
+       cmd.params[1] |= mc_enc(24, 8, endpoint1->type[3]);
+       cmd.params[1] |= mc_enc(32, 8, endpoint1->type[4]);
+       cmd.params[1] |= mc_enc(40, 8, endpoint1->type[5]);
+       cmd.params[1] |= mc_enc(48, 8, endpoint1->type[6]);
+       cmd.params[1] |= mc_enc(56, 8, endpoint1->type[7]);
+       cmd.params[2] |= mc_enc(0, 8, endpoint1->type[8]);
+       cmd.params[2] |= mc_enc(8, 8, endpoint1->type[9]);
+       cmd.params[2] |= mc_enc(16, 8, endpoint1->type[10]);
+       cmd.params[2] |= mc_enc(24, 8, endpoint1->type[11]);
+       cmd.params[2] |= mc_enc(32, 8, endpoint1->type[12]);
+       cmd.params[2] |= mc_enc(40, 8, endpoint1->type[13]);
+       cmd.params[2] |= mc_enc(48, 8, endpoint1->type[14]);
+       cmd.params[2] |= mc_enc(56, 8, endpoint1->type[15]);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       endpoint2->id = mc_dec(cmd.params[3], 0, 32);
+       endpoint2->interface_id = mc_dec(cmd.params[3], 32, 32);
+       endpoint2->type[0] = mc_dec(cmd.params[4], 0, 8);
+       endpoint2->type[1] = mc_dec(cmd.params[4], 8, 8);
+       endpoint2->type[2] = mc_dec(cmd.params[4], 16, 8);
+       endpoint2->type[3] = mc_dec(cmd.params[4], 24, 8);
+       endpoint2->type[4] = mc_dec(cmd.params[4], 32, 8);
+       endpoint2->type[5] = mc_dec(cmd.params[4], 40, 8);
+       endpoint2->type[6] = mc_dec(cmd.params[4], 48, 8);
+       endpoint2->type[7] = mc_dec(cmd.params[4], 56, 8);
+       endpoint2->type[8] = mc_dec(cmd.params[5], 0, 8);
+       endpoint2->type[9] = mc_dec(cmd.params[5], 8, 8);
+       endpoint2->type[10] = mc_dec(cmd.params[5], 16, 8);
+       endpoint2->type[11] = mc_dec(cmd.params[5], 24, 8);
+       endpoint2->type[12] = mc_dec(cmd.params[5], 32, 8);
+       endpoint2->type[13] = mc_dec(cmd.params[5], 40, 8);
+       endpoint2->type[14] = mc_dec(cmd.params[5], 48, 8);
+       endpoint2->type[15] = mc_dec(cmd.params[5], 56, 8);
+       *state = mc_dec(cmd.params[6], 0, 32);
+
+       return 0;
+}
diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c b/drivers/staging/fsl-mc/bus/mc-allocator.c
new file mode 100644 (file)
index 0000000..cc4a7d3
--- /dev/null
@@ -0,0 +1,569 @@
+/*
+ * Freescale MC object device allocator driver
+ *
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include "../include/mc-sys.h"
+#include <linux/module.h>
+#include "../include/dpbp-cmd.h"
+#include "../include/dpcon-cmd.h"
+#include "dpmcp-cmd.h"
+#include "dpmcp.h"
+
+/**
+ * fsl_mc_resource_pool_add_device - add allocatable device to a resource
+ * pool of a given MC bus
+ *
+ * @mc_bus: pointer to the MC bus
+ * @pool_type: MC bus pool type
+ * @mc_dev: Pointer to allocatable MC object device
+ *
+ * It adds an allocatable MC object device to a container's resource pool of
+ * the given resource type
+ */
+static int __must_check fsl_mc_resource_pool_add_device(struct fsl_mc_bus
+                                                               *mc_bus,
+                                                       enum fsl_mc_pool_type
+                                                               pool_type,
+                                                       struct fsl_mc_device
+                                                               *mc_dev)
+{
+       struct fsl_mc_resource_pool *res_pool;
+       struct fsl_mc_resource *resource;
+       struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+       int error = -EINVAL;
+       bool mutex_locked = false;
+
+       if (WARN_ON(pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES))
+               goto out;
+       if (WARN_ON(!FSL_MC_IS_ALLOCATABLE(mc_dev->obj_desc.type)))
+               goto out;
+       if (WARN_ON(mc_dev->resource))
+               goto out;
+
+       res_pool = &mc_bus->resource_pools[pool_type];
+       if (WARN_ON(res_pool->type != pool_type))
+               goto out;
+       if (WARN_ON(res_pool->mc_bus != mc_bus))
+               goto out;
+
+       mutex_lock(&res_pool->mutex);
+       mutex_locked = true;
+
+       if (WARN_ON(res_pool->max_count < 0))
+               goto out;
+       if (WARN_ON(res_pool->free_count < 0 ||
+                   res_pool->free_count > res_pool->max_count))
+               goto out;
+
+       resource = devm_kzalloc(&mc_bus_dev->dev, sizeof(*resource),
+                               GFP_KERNEL);
+       if (!resource) {
+               error = -ENOMEM;
+               dev_err(&mc_bus_dev->dev,
+                       "Failed to allocate memory for fsl_mc_resource\n");
+               goto out;
+       }
+
+       resource->type = pool_type;
+       resource->id = mc_dev->obj_desc.id;
+       resource->data = mc_dev;
+       resource->parent_pool = res_pool;
+       INIT_LIST_HEAD(&resource->node);
+       list_add_tail(&resource->node, &res_pool->free_list);
+       mc_dev->resource = resource;
+       res_pool->free_count++;
+       res_pool->max_count++;
+       error = 0;
+out:
+       if (mutex_locked)
+               mutex_unlock(&res_pool->mutex);
+
+       return error;
+}
+
+/**
+ * fsl_mc_resource_pool_remove_device - remove an allocatable device from a
+ * resource pool
+ *
+ * @mc_dev: Pointer to allocatable MC object device
+ *
+ * It permanently removes an allocatable MC object device from the resource
+ * pool, the device is currently in, as long as it is in the pool's free list.
+ */
+static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
+                                                                  *mc_dev)
+{
+       struct fsl_mc_device *mc_bus_dev;
+       struct fsl_mc_bus *mc_bus;
+       struct fsl_mc_resource_pool *res_pool;
+       struct fsl_mc_resource *resource;
+       int error = -EINVAL;
+       bool mutex_locked = false;
+
+       if (WARN_ON(!FSL_MC_IS_ALLOCATABLE(mc_dev->obj_desc.type)))
+               goto out;
+
+       resource = mc_dev->resource;
+       if (WARN_ON(resource->data != mc_dev))
+               goto out;
+
+       mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+       mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       res_pool = resource->parent_pool;
+       if (WARN_ON(res_pool != &mc_bus->resource_pools[resource->type]))
+               goto out;
+
+       mutex_lock(&res_pool->mutex);
+       mutex_locked = true;
+
+       if (WARN_ON(res_pool->max_count <= 0))
+               goto out;
+       if (WARN_ON(res_pool->free_count <= 0 ||
+                   res_pool->free_count > res_pool->max_count))
+               goto out;
+
+       /*
+        * If the device is currently allocated, its resource is not
+        * in the free list and thus, the device cannot be removed.
+        */
+       if (list_empty(&resource->node)) {
+               error = -EBUSY;
+               dev_err(&mc_bus_dev->dev,
+                       "Device %s cannot be removed from resource pool\n",
+                       dev_name(&mc_dev->dev));
+               goto out;
+       }
+
+       list_del(&resource->node);
+       INIT_LIST_HEAD(&resource->node);
+       res_pool->free_count--;
+       res_pool->max_count--;
+
+       devm_kfree(&mc_bus_dev->dev, resource);
+       mc_dev->resource = NULL;
+       error = 0;
+out:
+       if (mutex_locked)
+               mutex_unlock(&res_pool->mutex);
+
+       return error;
+}
+
+static const char *const fsl_mc_pool_type_strings[] = {
+       [FSL_MC_POOL_DPMCP] = "dpmcp",
+       [FSL_MC_POOL_DPBP] = "dpbp",
+       [FSL_MC_POOL_DPCON] = "dpcon",
+};
+
+static int __must_check object_type_to_pool_type(const char *object_type,
+                                                enum fsl_mc_pool_type
+                                                               *pool_type)
+{
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(fsl_mc_pool_type_strings); i++) {
+               if (strcmp(object_type, fsl_mc_pool_type_strings[i]) == 0) {
+                       *pool_type = i;
+                       return 0;
+               }
+       }
+
+       return -EINVAL;
+}
+
+int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
+                                         enum fsl_mc_pool_type pool_type,
+                                         struct fsl_mc_resource **new_resource)
+{
+       struct fsl_mc_resource_pool *res_pool;
+       struct fsl_mc_resource *resource;
+       struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
+       int error = -EINVAL;
+       bool mutex_locked = false;
+
+       BUILD_BUG_ON(ARRAY_SIZE(fsl_mc_pool_type_strings) !=
+                    FSL_MC_NUM_POOL_TYPES);
+
+       *new_resource = NULL;
+       if (WARN_ON(pool_type < 0 || pool_type >= FSL_MC_NUM_POOL_TYPES))
+               goto error;
+
+       res_pool = &mc_bus->resource_pools[pool_type];
+       if (WARN_ON(res_pool->mc_bus != mc_bus))
+               goto error;
+
+       mutex_lock(&res_pool->mutex);
+       mutex_locked = true;
+       resource = list_first_entry_or_null(&res_pool->free_list,
+                                           struct fsl_mc_resource, node);
+
+       if (!resource) {
+               WARN_ON(res_pool->free_count != 0);
+               error = -ENXIO;
+               dev_err(&mc_bus_dev->dev,
+                       "No more resources of type %s left\n",
+                       fsl_mc_pool_type_strings[pool_type]);
+               goto error;
+       }
+
+       if (WARN_ON(resource->type != pool_type))
+               goto error;
+       if (WARN_ON(resource->parent_pool != res_pool))
+               goto error;
+       if (WARN_ON(res_pool->free_count <= 0 ||
+                   res_pool->free_count > res_pool->max_count))
+               goto error;
+
+       list_del(&resource->node);
+       INIT_LIST_HEAD(&resource->node);
+
+       res_pool->free_count--;
+       mutex_unlock(&res_pool->mutex);
+       *new_resource = resource;
+       return 0;
+error:
+       if (mutex_locked)
+               mutex_unlock(&res_pool->mutex);
+
+       return error;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_resource_allocate);
+
+void fsl_mc_resource_free(struct fsl_mc_resource *resource)
+{
+       struct fsl_mc_resource_pool *res_pool;
+       bool mutex_locked = false;
+
+       res_pool = resource->parent_pool;
+       if (WARN_ON(resource->type != res_pool->type))
+               goto out;
+
+       mutex_lock(&res_pool->mutex);
+       mutex_locked = true;
+       if (WARN_ON(res_pool->free_count < 0 ||
+                   res_pool->free_count >= res_pool->max_count))
+               goto out;
+
+       if (WARN_ON(!list_empty(&resource->node)))
+               goto out;
+
+       list_add_tail(&resource->node, &res_pool->free_list);
+       res_pool->free_count++;
+out:
+       if (mutex_locked)
+               mutex_unlock(&res_pool->mutex);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_resource_free);
+
+/**
+ * fsl_mc_portal_allocate - Allocates an MC portal
+ *
+ * @mc_dev: MC device for which the MC portal is to be allocated
+ * @mc_io_flags: Flags for the fsl_mc_io object that wraps the allocated
+ * MC portal.
+ * @new_mc_io: Pointer to area where the pointer to the fsl_mc_io object
+ * that wraps the allocated MC portal is to be returned
+ *
+ * This function allocates an MC portal from the device's parent DPRC,
+ * from the corresponding MC bus' pool of MC portals and wraps
+ * it in a new fsl_mc_io object. If 'mc_dev' is a DPRC itself, the
+ * portal is allocated from its own MC bus.
+ */
+int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
+                                       uint16_t mc_io_flags,
+                                       struct fsl_mc_io **new_mc_io)
+{
+       struct fsl_mc_device *mc_bus_dev;
+       struct fsl_mc_bus *mc_bus;
+       phys_addr_t mc_portal_phys_addr;
+       size_t mc_portal_size;
+       struct fsl_mc_device *mc_adev;
+       int error = -EINVAL;
+       struct fsl_mc_resource *resource = NULL;
+       struct fsl_mc_io *mc_io = NULL;
+
+       if (mc_dev->flags & FSL_MC_IS_DPRC) {
+               mc_bus_dev = mc_dev;
+       } else {
+               if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
+                       return error;
+
+               mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+       }
+
+       mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       *new_mc_io = NULL;
+       error = fsl_mc_resource_allocate(mc_bus, FSL_MC_POOL_DPMCP, &resource);
+       if (error < 0)
+               return error;
+
+       mc_adev = resource->data;
+       if (WARN_ON(!mc_adev))
+               goto error_cleanup_resource;
+
+       if (WARN_ON(mc_adev->obj_desc.region_count == 0))
+               goto error_cleanup_resource;
+
+       mc_portal_phys_addr = mc_adev->regions[0].start;
+       mc_portal_size = mc_adev->regions[0].end -
+                        mc_adev->regions[0].start + 1;
+
+       if (WARN_ON(mc_portal_size != mc_bus_dev->mc_io->portal_size))
+               goto error_cleanup_resource;
+
+       error = fsl_create_mc_io(&mc_bus_dev->dev,
+                                mc_portal_phys_addr,
+                                mc_portal_size, resource,
+                                mc_io_flags, &mc_io);
+       if (error < 0)
+               goto error_cleanup_resource;
+
+       *new_mc_io = mc_io;
+       return 0;
+
+error_cleanup_resource:
+       fsl_mc_resource_free(resource);
+       return error;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_portal_allocate);
+
+/**
+ * fsl_mc_portal_free - Returns an MC portal to the pool of free MC portals
+ * of a given MC bus
+ *
+ * @mc_io: Pointer to the fsl_mc_io object that wraps the MC portal to free
+ */
+void fsl_mc_portal_free(struct fsl_mc_io *mc_io)
+{
+       struct fsl_mc_resource *resource;
+
+       resource = mc_io->resource;
+       if (WARN_ON(resource->type != FSL_MC_POOL_DPMCP))
+               return;
+       if (WARN_ON(!resource->data))
+               return;
+
+       fsl_destroy_mc_io(mc_io);
+       fsl_mc_resource_free(resource);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_portal_free);
+
+/**
+ * fsl_mc_portal_reset - Resets the dpmcp object for a given fsl_mc_io object
+ *
+ * @mc_io: Pointer to the fsl_mc_io object that wraps the MC portal to free
+ */
+int fsl_mc_portal_reset(struct fsl_mc_io *mc_io)
+{
+       int error;
+       uint16_t token;
+       struct fsl_mc_resource *resource = mc_io->resource;
+       struct fsl_mc_device *mc_dev = resource->data;
+
+       if (WARN_ON(resource->type != FSL_MC_POOL_DPMCP))
+               return -EINVAL;
+
+       if (WARN_ON(!mc_dev))
+               return -EINVAL;
+
+       error = dpmcp_open(mc_io, mc_dev->obj_desc.id, &token);
+       if (error < 0) {
+               dev_err(&mc_dev->dev, "dpmcp_open() failed: %d\n", error);
+               return error;
+       }
+
+       error = dpmcp_reset(mc_io, token);
+       if (error < 0) {
+               dev_err(&mc_dev->dev, "dpmcp_reset() failed: %d\n", error);
+               return error;
+       }
+
+       error = dpmcp_close(mc_io, token);
+       if (error < 0) {
+               dev_err(&mc_dev->dev, "dpmcp_close() failed: %d\n", error);
+               return error;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_portal_reset);
+
+/**
+ * fsl_mc_object_allocate - Allocates a MC object device of the given
+ * pool type from a given MC bus
+ *
+ * @mc_dev: MC device for which the MC object device is to be allocated
+ * @pool_type: MC bus resource pool type
+ * @new_mc_dev: Pointer to area where the pointer to the allocated
+ * MC object device is to be returned
+ *
+ * This function allocates a MC object device from the device's parent DPRC,
+ * from the corresponding MC bus' pool of allocatable MC object devices of
+ * the given resource type. mc_dev cannot be a DPRC itself.
+ *
+ * NOTE: pool_type must be different from FSL_MC_POOL_MCP, since MC
+ * portals are allocated using fsl_mc_portal_allocate(), instead of
+ * this function.
+ */
+int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
+                                       enum fsl_mc_pool_type pool_type,
+                                       struct fsl_mc_device **new_mc_adev)
+{
+       struct fsl_mc_device *mc_bus_dev;
+       struct fsl_mc_bus *mc_bus;
+       struct fsl_mc_device *mc_adev;
+       int error = -EINVAL;
+       struct fsl_mc_resource *resource = NULL;
+
+       *new_mc_adev = NULL;
+       if (WARN_ON(mc_dev->flags & FSL_MC_IS_DPRC))
+               goto error;
+
+       if (WARN_ON(mc_dev->dev.parent->bus != &fsl_mc_bus_type))
+               goto error;
+
+       if (WARN_ON(pool_type == FSL_MC_POOL_DPMCP))
+               goto error;
+
+       mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+       mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       error = fsl_mc_resource_allocate(mc_bus, pool_type, &resource);
+       if (error < 0)
+               goto error;
+
+       mc_adev = resource->data;
+       if (WARN_ON(!mc_adev))
+               goto error;
+
+       *new_mc_adev = mc_adev;
+       return 0;
+error:
+       if (resource)
+               fsl_mc_resource_free(resource);
+
+       return error;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_object_allocate);
+
+/**
+ * fsl_mc_object_free - Returns an allocatable MC object device to the
+ * corresponding resource pool of a given MC bus.
+ *
+ * @mc_adev: Pointer to the MC object device
+ */
+void fsl_mc_object_free(struct fsl_mc_device *mc_adev)
+{
+       struct fsl_mc_resource *resource;
+
+       resource = mc_adev->resource;
+       if (WARN_ON(resource->type == FSL_MC_POOL_DPMCP))
+               return;
+       if (WARN_ON(resource->data != mc_adev))
+               return;
+
+       fsl_mc_resource_free(resource);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_object_free);
+
+/**
+ * fsl_mc_allocator_probe - callback invoked when an allocatable device is
+ * being added to the system
+ */
+static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)
+{
+       enum fsl_mc_pool_type pool_type;
+       struct fsl_mc_device *mc_bus_dev;
+       struct fsl_mc_bus *mc_bus;
+       int error = -EINVAL;
+
+       if (WARN_ON(!FSL_MC_IS_ALLOCATABLE(mc_dev->obj_desc.type)))
+               goto error;
+
+       mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+       if (WARN_ON(mc_bus_dev->dev.bus != &fsl_mc_bus_type))
+               goto error;
+
+       mc_bus = to_fsl_mc_bus(mc_bus_dev);
+       error = object_type_to_pool_type(mc_dev->obj_desc.type, &pool_type);
+       if (error < 0)
+               goto error;
+
+       error = fsl_mc_resource_pool_add_device(mc_bus, pool_type, mc_dev);
+       if (error < 0)
+               goto error;
+
+       dev_info(&mc_dev->dev,
+                "Allocatable MC object device bound to fsl_mc_allocator driver");
+       return 0;
+error:
+
+       return error;
+}
+
+/**
+ * fsl_mc_allocator_remove - callback invoked when an allocatable device is
+ * being removed from the system
+ */
+static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
+{
+       int error = -EINVAL;
+
+       if (WARN_ON(!FSL_MC_IS_ALLOCATABLE(mc_dev->obj_desc.type)))
+               goto out;
+
+       error = fsl_mc_resource_pool_remove_device(mc_dev);
+       if (error < 0)
+               goto out;
+
+       dev_info(&mc_dev->dev,
+                "Allocatable MC object device unbound from fsl_mc_allocator driver");
+       error = 0;
+out:
+       return error;
+}
+
+static const struct fsl_mc_device_match_id match_id_table[] = {
+       {
+        .vendor = FSL_MC_VENDOR_FREESCALE,
+        .obj_type = "dpbp",
+        .ver_major = DPBP_VER_MAJOR,
+        .ver_minor = DPBP_VER_MINOR
+       },
+       {
+        .vendor = FSL_MC_VENDOR_FREESCALE,
+        .obj_type = "dpmcp",
+        .ver_major = DPMCP_VER_MAJOR,
+        .ver_minor = DPMCP_VER_MINOR
+       },
+       {
+        .vendor = FSL_MC_VENDOR_FREESCALE,
+        .obj_type = "dpcon",
+        .ver_major = DPCON_VER_MAJOR,
+        .ver_minor = DPCON_VER_MINOR
+       },
+       {.vendor = 0x0},
+};
+
+static struct fsl_mc_driver fsl_mc_allocator_driver = {
+       .driver = {
+                  .name = "fsl_mc_allocator",
+                  .owner = THIS_MODULE,
+                  .pm = NULL,
+                  },
+       .match_id_table = match_id_table,
+       .probe = fsl_mc_allocator_probe,
+       .remove = fsl_mc_allocator_remove,
+};
+
+module_fsl_mc_driver(fsl_mc_allocator_driver);
+
+MODULE_AUTHOR("Freescale Semiconductor Inc.");
+MODULE_DESCRIPTION("Freescale's MC object device allocator");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
new file mode 100644 (file)
index 0000000..b4e9022
--- /dev/null
@@ -0,0 +1,763 @@
+/*
+ * Freescale Management Complex (MC) bus driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <German.Rivera@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include "../include/mc-private.h"
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_address.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/limits.h>
+#include "../include/dpmng.h"
+#include "../include/mc-sys.h"
+#include "dprc-cmd.h"
+
+static struct kmem_cache *mc_dev_cache;
+
+/**
+ * fsl_mc_bus_match - device to driver matching callback
+ * @dev: the MC object device structure to match against
+ * @drv: the device driver to search for matching MC object device id
+ * structures
+ *
+ * Returns 1 on success, 0 otherwise.
+ */
+static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv)
+{
+       const struct fsl_mc_device_match_id *id;
+       struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+       struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv);
+       bool found = false;
+
+       if (WARN_ON(!fsl_mc_bus_type.dev_root))
+               goto out;
+
+       if (!mc_drv->match_id_table)
+               goto out;
+
+       /*
+        * If the object is not 'plugged' don't match.
+        * Only exception is the root DPRC, which is a special case.
+        */
+       if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 &&
+           &mc_dev->dev != fsl_mc_bus_type.dev_root)
+               goto out;
+
+       /*
+        * Traverse the match_id table of the given driver, trying to find
+        * a matching for the given MC object device.
+        */
+       for (id = mc_drv->match_id_table; id->vendor != 0x0; id++) {
+               if (id->vendor == mc_dev->obj_desc.vendor &&
+                   strcmp(id->obj_type, mc_dev->obj_desc.type) == 0 &&
+                   id->ver_major == mc_dev->obj_desc.ver_major &&
+                   id->ver_minor == mc_dev->obj_desc.ver_minor) {
+                       found = true;
+                       break;
+               }
+       }
+
+out:
+       dev_dbg(dev, "%smatched\n", found ? "" : "not ");
+       return found;
+}
+
+/**
+ * fsl_mc_bus_uevent - callback invoked when a device is added
+ */
+static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+       pr_debug("%s invoked\n", __func__);
+       return 0;
+}
+
+struct bus_type fsl_mc_bus_type = {
+       .name = "fsl-mc",
+       .match = fsl_mc_bus_match,
+       .uevent = fsl_mc_bus_uevent,
+};
+EXPORT_SYMBOL_GPL(fsl_mc_bus_type);
+
+static int fsl_mc_driver_probe(struct device *dev)
+{
+       struct fsl_mc_driver *mc_drv;
+       struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+       int error;
+
+       if (WARN_ON(!dev->driver))
+               return -EINVAL;
+
+       mc_drv = to_fsl_mc_driver(dev->driver);
+       if (WARN_ON(!mc_drv->probe))
+               return -EINVAL;
+
+       error = mc_drv->probe(mc_dev);
+       if (error < 0) {
+               dev_err(dev, "MC object device probe callback failed: %d\n",
+                       error);
+               return error;
+       }
+
+       return 0;
+}
+
+static int fsl_mc_driver_remove(struct device *dev)
+{
+       struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
+       struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+       int error;
+
+       if (WARN_ON(!dev->driver))
+               return -EINVAL;
+
+       error = mc_drv->remove(mc_dev);
+       if (error < 0) {
+               dev_err(dev,
+                       "MC object device remove callback failed: %d\n",
+                       error);
+               return error;
+       }
+
+       return 0;
+}
+
+static void fsl_mc_driver_shutdown(struct device *dev)
+{
+       struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
+       struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
+
+       mc_drv->shutdown(mc_dev);
+}
+
+/**
+ * __fsl_mc_driver_register - registers a child device driver with the
+ * MC bus
+ *
+ * This function is implicitly invoked from the registration function of
+ * fsl_mc device drivers, which is generated by the
+ * module_fsl_mc_driver() macro.
+ */
+int __fsl_mc_driver_register(struct fsl_mc_driver *mc_driver,
+                            struct module *owner)
+{
+       int error;
+
+       mc_driver->driver.owner = owner;
+       mc_driver->driver.bus = &fsl_mc_bus_type;
+
+       if (mc_driver->probe)
+               mc_driver->driver.probe = fsl_mc_driver_probe;
+
+       if (mc_driver->remove)
+               mc_driver->driver.remove = fsl_mc_driver_remove;
+
+       if (mc_driver->shutdown)
+               mc_driver->driver.shutdown = fsl_mc_driver_shutdown;
+
+       error = driver_register(&mc_driver->driver);
+       if (error < 0) {
+               pr_err("driver_register() failed for %s: %d\n",
+                      mc_driver->driver.name, error);
+               return error;
+       }
+
+       pr_info("MC object device driver %s registered\n",
+               mc_driver->driver.name);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(__fsl_mc_driver_register);
+
+/**
+ * fsl_mc_driver_unregister - unregisters a device driver from the
+ * MC bus
+ */
+void fsl_mc_driver_unregister(struct fsl_mc_driver *mc_driver)
+{
+       driver_unregister(&mc_driver->driver);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister);
+
+static int get_dprc_icid(struct fsl_mc_io *mc_io,
+                        int container_id, uint16_t *icid)
+{
+       uint16_t dprc_handle;
+       struct dprc_attributes attr;
+       int error;
+
+       error = dprc_open(mc_io, container_id, &dprc_handle);
+       if (error < 0) {
+               pr_err("dprc_open() failed: %d\n", error);
+               return error;
+       }
+
+       memset(&attr, 0, sizeof(attr));
+       error = dprc_get_attributes(mc_io, dprc_handle, &attr);
+       if (error < 0) {
+               pr_err("dprc_get_attributes() failed: %d\n", error);
+               goto common_cleanup;
+       }
+
+       *icid = attr.icid;
+       error = 0;
+
+common_cleanup:
+       (void)dprc_close(mc_io, dprc_handle);
+       return error;
+}
+
+static int translate_mc_addr(uint64_t mc_addr, phys_addr_t *phys_addr)
+{
+       int i;
+       struct fsl_mc *mc = dev_get_drvdata(fsl_mc_bus_type.dev_root->parent);
+
+       if (mc->num_translation_ranges == 0) {
+               /*
+                * Do identity mapping:
+                */
+               *phys_addr = mc_addr;
+               return 0;
+       }
+
+       for (i = 0; i < mc->num_translation_ranges; i++) {
+               struct fsl_mc_addr_translation_range *range =
+                       &mc->translation_ranges[i];
+
+               if (mc_addr >= range->start_mc_addr &&
+                   mc_addr < range->end_mc_addr) {
+                       *phys_addr = range->start_phys_addr +
+                                    (mc_addr - range->start_mc_addr);
+                       return 0;
+               }
+       }
+
+       return -EFAULT;
+}
+
+static int fsl_mc_device_get_mmio_regions(struct fsl_mc_device *mc_dev,
+                                         struct fsl_mc_device *mc_bus_dev)
+{
+       int i;
+       int error;
+       struct resource *regions;
+       struct dprc_obj_desc *obj_desc = &mc_dev->obj_desc;
+       struct device *parent_dev = mc_dev->dev.parent;
+
+       regions = kmalloc_array(obj_desc->region_count,
+                               sizeof(regions[0]), GFP_KERNEL);
+       if (!regions)
+               return -ENOMEM;
+
+       for (i = 0; i < obj_desc->region_count; i++) {
+               struct dprc_region_desc region_desc;
+
+               error = dprc_get_obj_region(mc_bus_dev->mc_io,
+                                           mc_bus_dev->mc_handle,
+                                           obj_desc->type,
+                                           obj_desc->id, i, &region_desc);
+               if (error < 0) {
+                       dev_err(parent_dev,
+                               "dprc_get_obj_region() failed: %d\n", error);
+                       goto error_cleanup_regions;
+               }
+
+               WARN_ON(region_desc.base_paddr == 0x0);
+               WARN_ON(region_desc.size == 0);
+               error = translate_mc_addr(region_desc.base_paddr,
+                                         &regions[i].start);
+               if (error < 0) {
+                       dev_err(parent_dev,
+                               "Invalid MC address: %#llx\n",
+                               region_desc.base_paddr);
+                       goto error_cleanup_regions;
+               }
+
+               regions[i].end = regions[i].start + region_desc.size - 1;
+               regions[i].name = "fsl-mc object MMIO region";
+               regions[i].flags = IORESOURCE_IO;
+       }
+
+       mc_dev->regions = regions;
+       return 0;
+
+error_cleanup_regions:
+       kfree(regions);
+       return error;
+}
+
+/**
+ * Add a newly discovered MC object device to be visible in Linux
+ */
+int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
+                     struct fsl_mc_io *mc_io,
+                     struct device *parent_dev,
+                     struct fsl_mc_device **new_mc_dev)
+{
+       int error;
+       struct fsl_mc_device *mc_dev = NULL;
+       struct fsl_mc_bus *mc_bus = NULL;
+       struct fsl_mc_device *parent_mc_dev;
+
+       if (parent_dev->bus == &fsl_mc_bus_type)
+               parent_mc_dev = to_fsl_mc_device(parent_dev);
+       else
+               parent_mc_dev = NULL;
+
+       if (strcmp(obj_desc->type, "dprc") == 0) {
+               /*
+                * Allocate an MC bus device object:
+                */
+               mc_bus = devm_kzalloc(parent_dev, sizeof(*mc_bus), GFP_KERNEL);
+               if (!mc_bus)
+                       return -ENOMEM;
+
+               mc_dev = &mc_bus->mc_dev;
+       } else {
+               /*
+                * Allocate a regular fsl_mc_device object:
+                */
+               mc_dev = kmem_cache_zalloc(mc_dev_cache, GFP_KERNEL);
+               if (!mc_dev)
+                       return -ENOMEM;
+       }
+
+       mc_dev->obj_desc = *obj_desc;
+       mc_dev->mc_io = mc_io;
+       device_initialize(&mc_dev->dev);
+       mc_dev->dev.parent = parent_dev;
+       mc_dev->dev.bus = &fsl_mc_bus_type;
+       dev_set_name(&mc_dev->dev, "%s.%x", obj_desc->type, obj_desc->id);
+
+       if (strcmp(obj_desc->type, "dprc") == 0) {
+               struct fsl_mc_io *mc_io2;
+
+               mc_dev->flags |= FSL_MC_IS_DPRC;
+
+               /*
+                * To get the DPRC's ICID, we need to open the DPRC
+                * in get_dprc_icid(). For child DPRCs, we do so using the
+                * parent DPRC's MC portal instead of the child DPRC's MC
+                * portal, in case the child DPRC is already opened with
+                * its own portal (e.g., the DPRC used by AIOP).
+                *
+                * NOTE: There cannot be more than one active open for a
+                * given MC object, using the same MC portal.
+                */
+               if (parent_mc_dev) {
+                       /*
+                        * device being added is a child DPRC device
+                        */
+                       mc_io2 = parent_mc_dev->mc_io;
+               } else {
+                       /*
+                        * device being added is the root DPRC device
+                        */
+                       if (WARN_ON(!mc_io)) {
+                               error = -EINVAL;
+                               goto error_cleanup_dev;
+                       }
+
+                       mc_io2 = mc_io;
+
+                       if (!fsl_mc_bus_type.dev_root)
+                               fsl_mc_bus_type.dev_root = &mc_dev->dev;
+               }
+
+               error = get_dprc_icid(mc_io2, obj_desc->id, &mc_dev->icid);
+               if (error < 0)
+                       goto error_cleanup_dev;
+       } else {
+               /*
+                * A non-DPRC MC object device has to be a child of another
+                * MC object (specifically a DPRC object)
+                */
+               mc_dev->icid = parent_mc_dev->icid;
+               mc_dev->dma_mask = FSL_MC_DEFAULT_DMA_MASK;
+               mc_dev->dev.dma_mask = &mc_dev->dma_mask;
+       }
+
+       /*
+        * Get MMIO regions for the device from the MC:
+        *
+        * NOTE: the root DPRC is a special case as its MMIO region is
+        * obtained from the device tree
+        */
+       if (parent_mc_dev && obj_desc->region_count != 0) {
+               error = fsl_mc_device_get_mmio_regions(mc_dev,
+                                                      parent_mc_dev);
+               if (error < 0)
+                       goto error_cleanup_dev;
+       }
+
+       /*
+        * The device-specific probe callback will get invoked by device_add()
+        */
+       error = device_add(&mc_dev->dev);
+       if (error < 0) {
+               dev_err(parent_dev,
+                       "device_add() failed for device %s: %d\n",
+                       dev_name(&mc_dev->dev), error);
+               goto error_cleanup_dev;
+       }
+
+       (void)get_device(&mc_dev->dev);
+       dev_dbg(parent_dev, "Added MC object device %s\n",
+               dev_name(&mc_dev->dev));
+
+       *new_mc_dev = mc_dev;
+       return 0;
+
+error_cleanup_dev:
+       kfree(mc_dev->regions);
+       if (mc_bus)
+               devm_kfree(parent_dev, mc_bus);
+       else
+               kmem_cache_free(mc_dev_cache, mc_dev);
+
+       return error;
+}
+EXPORT_SYMBOL_GPL(fsl_mc_device_add);
+
+/**
+ * fsl_mc_device_remove - Remove a MC object device from being visible to
+ * Linux
+ *
+ * @mc_dev: Pointer to a MC object device object
+ */
+void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
+{
+       struct fsl_mc_bus *mc_bus = NULL;
+
+       kfree(mc_dev->regions);
+
+       /*
+        * The device-specific remove callback will get invoked by device_del()
+        */
+       device_del(&mc_dev->dev);
+       put_device(&mc_dev->dev);
+
+       if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) {
+               struct fsl_mc_io *mc_io = mc_dev->mc_io;
+
+               mc_bus = to_fsl_mc_bus(mc_dev);
+               fsl_destroy_mc_io(mc_io);
+               if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
+                       fsl_mc_bus_type.dev_root = NULL;
+       }
+
+       mc_dev->mc_io = NULL;
+       if (mc_bus)
+               devm_kfree(mc_dev->dev.parent, mc_bus);
+       else
+               kmem_cache_free(mc_dev_cache, mc_dev);
+}
+EXPORT_SYMBOL_GPL(fsl_mc_device_remove);
+
+static int parse_mc_ranges(struct device *dev,
+                          int *paddr_cells,
+                          int *mc_addr_cells,
+                          int *mc_size_cells,
+                          const __be32 **ranges_start,
+                          uint8_t *num_ranges)
+{
+       const __be32 *prop;
+       int range_tuple_cell_count;
+       int ranges_len;
+       int tuple_len;
+       struct device_node *mc_node = dev->of_node;
+
+       *ranges_start = of_get_property(mc_node, "ranges", &ranges_len);
+       if (!(*ranges_start) || !ranges_len) {
+               dev_warn(dev,
+                        "missing or empty ranges property for device tree node '%s'\n",
+                        mc_node->name);
+
+               *num_ranges = 0;
+               return 0;
+       }
+
+       *paddr_cells = of_n_addr_cells(mc_node);
+
+       prop = of_get_property(mc_node, "#address-cells", NULL);
+       if (prop)
+               *mc_addr_cells = be32_to_cpup(prop);
+       else
+               *mc_addr_cells = *paddr_cells;
+
+       prop = of_get_property(mc_node, "#size-cells", NULL);
+       if (prop)
+               *mc_size_cells = be32_to_cpup(prop);
+       else
+               *mc_size_cells = of_n_size_cells(mc_node);
+
+       range_tuple_cell_count = *paddr_cells + *mc_addr_cells +
+                                *mc_size_cells;
+
+       tuple_len = range_tuple_cell_count * sizeof(__be32);
+       if (ranges_len % tuple_len != 0) {
+               dev_err(dev, "malformed ranges property '%s'\n", mc_node->name);
+               return -EINVAL;
+       }
+
+       *num_ranges = ranges_len / tuple_len;
+       return 0;
+}
+
+static int get_mc_addr_translation_ranges(struct device *dev,
+                                         struct fsl_mc_addr_translation_range
+                                               **ranges,
+                                         uint8_t *num_ranges)
+{
+       int error;
+       int paddr_cells;
+       int mc_addr_cells;
+       int mc_size_cells;
+       int i;
+       const __be32 *ranges_start;
+       const __be32 *cell;
+
+       error = parse_mc_ranges(dev,
+                               &paddr_cells,
+                               &mc_addr_cells,
+                               &mc_size_cells,
+                               &ranges_start,
+                               num_ranges);
+       if (error < 0)
+               return error;
+
+       if (!(*num_ranges)) {
+               /*
+                * Missing or empty ranges property ("ranges;") for the
+                * 'fsl,qoriq-mc' node. In this case, identity mapping
+                * will be used.
+                */
+               *ranges = NULL;
+               return 0;
+       }
+
+       *ranges = devm_kcalloc(dev, *num_ranges,
+                              sizeof(struct fsl_mc_addr_translation_range),
+                              GFP_KERNEL);
+       if (!(*ranges))
+               return -ENOMEM;
+
+       cell = ranges_start;
+       for (i = 0; i < *num_ranges; ++i) {
+               struct fsl_mc_addr_translation_range *range = &(*ranges)[i];
+
+               range->start_mc_addr = of_read_number(cell, mc_addr_cells);
+               cell += mc_addr_cells;
+               range->start_phys_addr = of_read_number(cell, paddr_cells);
+               cell += paddr_cells;
+               range->end_mc_addr = range->start_mc_addr +
+                                    of_read_number(cell, mc_size_cells);
+
+               cell += mc_size_cells;
+       }
+
+       return 0;
+}
+
+/**
+ * fsl_mc_bus_probe - callback invoked when the root MC bus is being
+ * added
+ */
+static int fsl_mc_bus_probe(struct platform_device *pdev)
+{
+       struct dprc_obj_desc obj_desc;
+       int error;
+       struct fsl_mc *mc;
+       struct fsl_mc_device *mc_bus_dev = NULL;
+       struct fsl_mc_io *mc_io = NULL;
+       int container_id;
+       phys_addr_t mc_portal_phys_addr;
+       uint32_t mc_portal_size;
+       struct mc_version mc_version;
+       struct resource res;
+
+       dev_info(&pdev->dev, "Root MC bus device probed");
+
+       mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
+       if (!mc)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, mc);
+
+       /*
+        * Get physical address of MC portal for the root DPRC:
+        */
+       error = of_address_to_resource(pdev->dev.of_node, 0, &res);
+       if (error < 0) {
+               dev_err(&pdev->dev,
+                       "of_address_to_resource() failed for %s\n",
+                       pdev->dev.of_node->full_name);
+               return error;
+       }
+
+       mc_portal_phys_addr = res.start;
+       mc_portal_size = resource_size(&res);
+       error = fsl_create_mc_io(&pdev->dev, mc_portal_phys_addr,
+                                mc_portal_size, NULL, 0, &mc_io);
+       if (error < 0)
+               return error;
+
+       error = mc_get_version(mc_io, &mc_version);
+       if (error != 0) {
+               dev_err(&pdev->dev,
+                       "mc_get_version() failed with error %d\n", error);
+               goto error_cleanup_mc_io;
+       }
+
+       dev_info(&pdev->dev,
+                "Freescale Management Complex Firmware version: %u.%u.%u\n",
+                mc_version.major, mc_version.minor, mc_version.revision);
+
+       if (mc_version.major < MC_VER_MAJOR) {
+               dev_err(&pdev->dev,
+                       "ERROR: MC firmware version not supported by driver (driver version: %u.%u)\n",
+                       MC_VER_MAJOR, MC_VER_MINOR);
+               error = -ENOTSUPP;
+               goto error_cleanup_mc_io;
+       }
+
+       if (mc_version.major > MC_VER_MAJOR) {
+               dev_warn(&pdev->dev,
+                        "WARNING: driver may not support newer MC firmware features (driver version: %u.%u)\n",
+                        MC_VER_MAJOR, MC_VER_MINOR);
+       }
+
+       error = get_mc_addr_translation_ranges(&pdev->dev,
+                                              &mc->translation_ranges,
+                                              &mc->num_translation_ranges);
+       if (error < 0)
+               goto error_cleanup_mc_io;
+
+       error = dpmng_get_container_id(mc_io, &container_id);
+       if (error < 0) {
+               dev_err(&pdev->dev,
+                       "dpmng_get_container_id() failed: %d\n", error);
+               goto error_cleanup_mc_io;
+       }
+
+       obj_desc.vendor = FSL_MC_VENDOR_FREESCALE;
+       strcpy(obj_desc.type, "dprc");
+       obj_desc.id = container_id;
+       obj_desc.ver_major = DPRC_VER_MAJOR;
+       obj_desc.ver_minor = DPRC_VER_MINOR;
+       obj_desc.region_count = 0;
+
+       error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, &mc_bus_dev);
+       if (error < 0)
+               goto error_cleanup_mc_io;
+
+       mc->root_mc_bus_dev = mc_bus_dev;
+       return 0;
+
+error_cleanup_mc_io:
+       fsl_destroy_mc_io(mc_io);
+       return error;
+}
+
+/**
+ * fsl_mc_bus_remove - callback invoked when the root MC bus is being
+ * removed
+ */
+static int fsl_mc_bus_remove(struct platform_device *pdev)
+{
+       struct fsl_mc *mc = platform_get_drvdata(pdev);
+
+       if (WARN_ON(&mc->root_mc_bus_dev->dev != fsl_mc_bus_type.dev_root))
+               return -EINVAL;
+
+       fsl_mc_device_remove(mc->root_mc_bus_dev);
+       dev_info(&pdev->dev, "Root MC bus device removed");
+       return 0;
+}
+
+static const struct of_device_id fsl_mc_bus_match_table[] = {
+       {.compatible = "fsl,qoriq-mc",},
+       {},
+};
+
+MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table);
+
+static struct platform_driver fsl_mc_bus_driver = {
+       .driver = {
+                  .name = "fsl_mc_bus",
+                  .owner = THIS_MODULE,
+                  .pm = NULL,
+                  .of_match_table = fsl_mc_bus_match_table,
+                  },
+       .probe = fsl_mc_bus_probe,
+       .remove = fsl_mc_bus_remove,
+};
+
+static int __init fsl_mc_bus_driver_init(void)
+{
+       int error;
+
+       mc_dev_cache = kmem_cache_create("fsl_mc_device",
+                                        sizeof(struct fsl_mc_device), 0, 0,
+                                        NULL);
+       if (!mc_dev_cache) {
+               pr_err("Could not create fsl_mc_device cache\n");
+               return -ENOMEM;
+       }
+
+       error = bus_register(&fsl_mc_bus_type);
+       if (error < 0) {
+               pr_err("fsl-mc bus type registration failed: %d\n", error);
+               goto error_cleanup_cache;
+       }
+
+       pr_info("fsl-mc bus type registered\n");
+
+       error = platform_driver_register(&fsl_mc_bus_driver);
+       if (error < 0) {
+               pr_err("platform_driver_register() failed: %d\n", error);
+               goto error_cleanup_bus;
+       }
+
+       error = dprc_driver_init();
+       if (error < 0)
+               goto error_cleanup_driver;
+
+       return 0;
+
+error_cleanup_driver:
+       platform_driver_unregister(&fsl_mc_bus_driver);
+
+error_cleanup_bus:
+       bus_unregister(&fsl_mc_bus_type);
+
+error_cleanup_cache:
+       kmem_cache_destroy(mc_dev_cache);
+       return error;
+}
+
+postcore_initcall(fsl_mc_bus_driver_init);
+
+static void __exit fsl_mc_bus_driver_exit(void)
+{
+       if (WARN_ON(!mc_dev_cache))
+               return;
+
+       dprc_driver_exit();
+       platform_driver_unregister(&fsl_mc_bus_driver);
+       bus_unregister(&fsl_mc_bus_type);
+       kmem_cache_destroy(mc_dev_cache);
+       pr_info("MC bus unregistered\n");
+}
+
+module_exit(fsl_mc_bus_driver_exit);
+
+MODULE_AUTHOR("Freescale Semiconductor Inc.");
+MODULE_DESCRIPTION("Freescale Management Complex (MC) bus driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/fsl-mc/bus/mc-sys.c b/drivers/staging/fsl-mc/bus/mc-sys.c
new file mode 100644 (file)
index 0000000..5737f59
--- /dev/null
@@ -0,0 +1,287 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+ *
+ * I/O services to send MC commands to the MC hardware
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the above-listed copyright holders nor the
+ *       names of any contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+#include "../include/mc-sys.h"
+#include "../include/mc-cmd.h"
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+
+/**
+ * Timeout in jiffies to wait for the completion of an MC command
+ */
+#define MC_CMD_COMPLETION_TIMEOUT_JIFFIES   (HZ / 2)   /* 500 ms */
+
+/*
+ * usleep_range() min and max values used to throttle down polling
+ * iterations while waiting for MC command completion
+ */
+#define MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS    10
+#define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS    500
+
+#define MC_CMD_HDR_READ_CMDID(_hdr) \
+       ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S))
+
+/**
+ * Creates an MC I/O object
+ *
+ * @dev: device to be associated with the MC I/O object
+ * @mc_portal_phys_addr: physical address of the MC portal to use
+ * @mc_portal_size: size in bytes of the MC portal
+ * @resource: Pointer to MC bus object allocator resource associated
+ * with this MC I/O object or NULL if none.
+ * @flags: flags for the new MC I/O object
+ * @new_mc_io: Area to return pointer to newly created MC I/O object
+ *
+ * Returns '0' on Success; Error code otherwise.
+ */
+int __must_check fsl_create_mc_io(struct device *dev,
+                                 phys_addr_t mc_portal_phys_addr,
+                                 uint32_t mc_portal_size,
+                                 struct fsl_mc_resource *resource,
+                                 uint32_t flags, struct fsl_mc_io **new_mc_io)
+{
+       struct fsl_mc_io *mc_io;
+       void __iomem *mc_portal_virt_addr;
+       struct resource *res;
+
+       mc_io = devm_kzalloc(dev, sizeof(*mc_io), GFP_KERNEL);
+       if (!mc_io)
+               return -ENOMEM;
+
+       mc_io->dev = dev;
+       mc_io->flags = flags;
+       mc_io->portal_phys_addr = mc_portal_phys_addr;
+       mc_io->portal_size = mc_portal_size;
+       mc_io->resource = resource;
+       res = devm_request_mem_region(dev,
+                                     mc_portal_phys_addr,
+                                     mc_portal_size,
+                                     "mc_portal");
+       if (!res) {
+               dev_err(dev,
+                       "devm_request_mem_region failed for MC portal %#llx\n",
+                       mc_portal_phys_addr);
+               return -EBUSY;
+       }
+
+       mc_portal_virt_addr = devm_ioremap_nocache(dev,
+                                                  mc_portal_phys_addr,
+                                                  mc_portal_size);
+       if (!mc_portal_virt_addr) {
+               dev_err(dev,
+                       "devm_ioremap_nocache failed for MC portal %#llx\n",
+                       mc_portal_phys_addr);
+               return -ENXIO;
+       }
+
+       mc_io->portal_virt_addr = mc_portal_virt_addr;
+       *new_mc_io = mc_io;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(fsl_create_mc_io);
+
+/**
+ * Destroys an MC I/O object
+ *
+ * @mc_io: MC I/O object to destroy
+ */
+void fsl_destroy_mc_io(struct fsl_mc_io *mc_io)
+{
+       devm_iounmap(mc_io->dev, mc_io->portal_virt_addr);
+       devm_release_mem_region(mc_io->dev,
+                               mc_io->portal_phys_addr,
+                               mc_io->portal_size);
+
+       mc_io->portal_virt_addr = NULL;
+       devm_kfree(mc_io->dev, mc_io);
+}
+EXPORT_SYMBOL_GPL(fsl_destroy_mc_io);
+
+static int mc_status_to_error(enum mc_cmd_status status)
+{
+       static const int mc_status_to_error_map[] = {
+               [MC_CMD_STATUS_OK] = 0,
+               [MC_CMD_STATUS_AUTH_ERR] = -EACCES,
+               [MC_CMD_STATUS_NO_PRIVILEGE] = -EPERM,
+               [MC_CMD_STATUS_DMA_ERR] = -EIO,
+               [MC_CMD_STATUS_CONFIG_ERR] = -ENXIO,
+               [MC_CMD_STATUS_TIMEOUT] = -ETIMEDOUT,
+               [MC_CMD_STATUS_NO_RESOURCE] = -ENAVAIL,
+               [MC_CMD_STATUS_NO_MEMORY] = -ENOMEM,
+               [MC_CMD_STATUS_BUSY] = -EBUSY,
+               [MC_CMD_STATUS_UNSUPPORTED_OP] = -ENOTSUPP,
+               [MC_CMD_STATUS_INVALID_STATE] = -ENODEV,
+       };
+
+       if (WARN_ON((u32)status >= ARRAY_SIZE(mc_status_to_error_map)))
+               return -EINVAL;
+
+       return mc_status_to_error_map[status];
+}
+
+static const char *mc_status_to_string(enum mc_cmd_status status)
+{
+       static const char *const status_strings[] = {
+               [MC_CMD_STATUS_OK] = "Command completed successfully",
+               [MC_CMD_STATUS_READY] = "Command ready to be processed",
+               [MC_CMD_STATUS_AUTH_ERR] = "Authentication error",
+               [MC_CMD_STATUS_NO_PRIVILEGE] = "No privilege",
+               [MC_CMD_STATUS_DMA_ERR] = "DMA or I/O error",
+               [MC_CMD_STATUS_CONFIG_ERR] = "Configuration error",
+               [MC_CMD_STATUS_TIMEOUT] = "Operation timed out",
+               [MC_CMD_STATUS_NO_RESOURCE] = "No resources",
+               [MC_CMD_STATUS_NO_MEMORY] = "No memory available",
+               [MC_CMD_STATUS_BUSY] = "Device is busy",
+               [MC_CMD_STATUS_UNSUPPORTED_OP] = "Unsupported operation",
+               [MC_CMD_STATUS_INVALID_STATE] = "Invalid state"
+       };
+
+       if ((unsigned int)status >= ARRAY_SIZE(status_strings))
+               return "Unknown MC error";
+
+       return status_strings[status];
+}
+
+/**
+ * mc_write_command - writes a command to a Management Complex (MC) portal
+ *
+ * @portal: pointer to an MC portal
+ * @cmd: pointer to a filled command
+ */
+static inline void mc_write_command(struct mc_command __iomem *portal,
+                                   struct mc_command *cmd)
+{
+       int i;
+
+       /* copy command parameters into the portal */
+       for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
+               writeq(cmd->params[i], &portal->params[i]);
+
+       /* submit the command by writing the header */
+       writeq(cmd->header, &portal->header);
+}
+
+/**
+ * mc_read_response - reads the response for the last MC command from a
+ * Management Complex (MC) portal
+ *
+ * @portal: pointer to an MC portal
+ * @resp: pointer to command response buffer
+ *
+ * Returns MC_CMD_STATUS_OK on Success; Error code otherwise.
+ */
+static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem *
+                                                 portal,
+                                                 struct mc_command *resp)
+{
+       int i;
+       enum mc_cmd_status status;
+
+       /* Copy command response header from MC portal: */
+       resp->header = readq(&portal->header);
+       status = MC_CMD_HDR_READ_STATUS(resp->header);
+       if (status != MC_CMD_STATUS_OK)
+               return status;
+
+       /* Copy command response data from MC portal: */
+       for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
+               resp->params[i] = readq(&portal->params[i]);
+
+       return status;
+}
+
+/**
+ * Sends an command to the MC device using the given MC I/O object
+ *
+ * @mc_io: MC I/O object to be used
+ * @cmd: command to be sent
+ *
+ * Returns '0' on Success; Error code otherwise.
+ *
+ * NOTE: This function cannot be invoked from from atomic contexts.
+ */
+int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
+{
+       enum mc_cmd_status status;
+       unsigned long jiffies_until_timeout =
+           jiffies + MC_CMD_COMPLETION_TIMEOUT_JIFFIES;
+
+       /*
+        * Send command to the MC hardware:
+        */
+       mc_write_command(mc_io->portal_virt_addr, cmd);
+
+       /*
+        * Wait for response from the MC hardware:
+        */
+       for (;;) {
+               status = mc_read_response(mc_io->portal_virt_addr, cmd);
+               if (status != MC_CMD_STATUS_READY)
+                       break;
+
+               /*
+                * TODO: When MC command completion interrupts are supported
+                * call wait function here instead of usleep_range()
+                */
+               usleep_range(MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS,
+                            MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS);
+
+               if (time_after_eq(jiffies, jiffies_until_timeout)) {
+                       pr_debug("MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
+                                mc_io->portal_phys_addr,
+                                (unsigned int)
+                                       MC_CMD_HDR_READ_TOKEN(cmd->header),
+                                (unsigned int)
+                                       MC_CMD_HDR_READ_CMDID(cmd->header));
+
+                       return -ETIMEDOUT;
+               }
+       }
+
+       if (status != MC_CMD_STATUS_OK) {
+               pr_debug("MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n",
+                        mc_io->portal_phys_addr,
+                        (unsigned int)MC_CMD_HDR_READ_TOKEN(cmd->header),
+                        (unsigned int)MC_CMD_HDR_READ_CMDID(cmd->header),
+                        mc_status_to_string(status),
+                        (unsigned int)status);
+
+               return mc_status_to_error(status);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(mc_send_command);
diff --git a/drivers/staging/fsl-mc/include/dpbp-cmd.h b/drivers/staging/fsl-mc/include/dpbp-cmd.h
new file mode 100644 (file)
index 0000000..1fd70a2
--- /dev/null
@@ -0,0 +1,60 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the above-listed copyright holders nor the
+* names of any contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+*
+* ALTERNATIVELY, this software may be distributed under the terms of the
+* GNU General Public License ("GPL") as published by the Free Software
+* Foundation, either version 2 of that License or (at your option) any
+* later version.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT 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.
+*/
+#ifndef _FSL_DPBP_CMD_H
+#define _FSL_DPBP_CMD_H
+
+/* DPBP Version */
+#define DPBP_VER_MAJOR                         2
+#define DPBP_VER_MINOR                         0
+
+/* Command IDs */
+#define DPBP_CMDID_CLOSE                               0x800
+#define DPBP_CMDID_OPEN                                        0x804
+#define DPBP_CMDID_CREATE                              0x904
+#define DPBP_CMDID_DESTROY                             0x900
+
+#define DPBP_CMDID_ENABLE                              0x002
+#define DPBP_CMDID_DISABLE                             0x003
+#define DPBP_CMDID_GET_ATTR                            0x004
+#define DPBP_CMDID_RESET                               0x005
+#define DPBP_CMDID_IS_ENABLED                          0x006
+
+#define DPBP_CMDID_SET_IRQ                             0x010
+#define DPBP_CMDID_GET_IRQ                             0x011
+#define DPBP_CMDID_SET_IRQ_ENABLE                      0x012
+#define DPBP_CMDID_GET_IRQ_ENABLE                      0x013
+#define DPBP_CMDID_SET_IRQ_MASK                                0x014
+#define DPBP_CMDID_GET_IRQ_MASK                                0x015
+#define DPBP_CMDID_GET_IRQ_STATUS                      0x016
+#define DPBP_CMDID_CLEAR_IRQ_STATUS                    0x017
+
+#endif /* _FSL_DPBP_CMD_H */
diff --git a/drivers/staging/fsl-mc/include/dpbp.h b/drivers/staging/fsl-mc/include/dpbp.h
new file mode 100644 (file)
index 0000000..5f3c8e7
--- /dev/null
@@ -0,0 +1,330 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef __FSL_DPBP_H
+#define __FSL_DPBP_H
+
+/* Data Path Buffer Pool API
+ * Contains initialization APIs and runtime control APIs for DPBP
+ */
+
+struct fsl_mc_io;
+
+/**
+ * dpbp_open() - Open a control session for the specified object.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @dpbp_id:   DPBP unique ID
+ * @token:     Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dpbp_create function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_open(struct fsl_mc_io *mc_io, int dpbp_id, uint16_t *token);
+
+/**
+ * dpbp_close() - Close the control session of the object
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_close(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * struct dpbp_cfg() - Structure representing DPBP configuration
+ * @options:   place holder
+ */
+struct dpbp_cfg {
+       uint32_t options;
+};
+
+/**
+ * dpbp_create() - Create the DPBP object.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cfg:       Configuration structure
+ * @token:     Returned token; use in subsequent API calls
+ *
+ * Create the DPBP object, allocate required resources and
+ * perform required initialization.
+ *
+ * The object can be created either by declaring it in the
+ * DPL file, or by calling this function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent calls to
+ * this specific object. For objects that are created using the
+ * DPL file, call dpbp_open function to get an authentication
+ * token first.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_create(struct fsl_mc_io       *mc_io,
+               const struct dpbp_cfg   *cfg,
+               uint16_t                *token);
+
+/**
+ * dpbp_destroy() - Destroy the DPBP object and release all its resources.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ *
+ * Return:     '0' on Success; error code otherwise.
+ */
+int dpbp_destroy(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * dpbp_enable() - Enable the DPBP.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_enable(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * dpbp_disable() - Disable the DPBP.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_disable(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * dpbp_is_enabled() - Check if the DPBP is enabled.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @en:                Returns '1' if object is enabled; '0' otherwise
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_is_enabled(struct fsl_mc_io *mc_io, uint16_t token, int *en);
+
+/**
+ * dpbp_reset() - Reset the DPBP, returns the object to initial state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_reset(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * dpbp_set_irq() - Set IRQ information for the DPBP to trigger an interrupt.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: Identifies the interrupt index to configure
+ * @irq_addr:  Address that must be written to
+ *                             signal a message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: A user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_set_irq(struct fsl_mc_io      *mc_io,
+                uint16_t               token,
+                uint8_t                irq_index,
+                uint64_t               irq_addr,
+                uint32_t               irq_val,
+                int                    user_irq_id);
+
+/**
+ * dpbp_get_irq() - Get IRQ information from the DPBP.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @type:      Interrupt type: 0 represents message interrupt
+ *                             type (both irq_addr and irq_val are valid)
+ * @irq_addr:  Returned address that must be written to
+ *                             signal the message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: A user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_get_irq(struct fsl_mc_io      *mc_io,
+                uint16_t               token,
+                uint8_t                irq_index,
+                int                    *type,
+                uint64_t               *irq_addr,
+                uint32_t               *irq_val,
+                int                    *user_irq_id);
+
+/**
+ * dpbp_set_irq_enable() - Set overall interrupt state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @en:        Interrupt state - enable = 1, disable = 0
+ *
+ * Allows GPP software to control when interrupts are generated.
+ * Each interrupt can have up to 32 causes.  The enable/disable control's the
+ * overall interrupt state. if the interrupt is disabled no causes will cause
+ * an interrupt.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_set_irq_enable(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint8_t                 en);
+
+/**
+ * dpbp_get_irq_enable() - Get overall interrupt state
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @en:                Returned interrupt state - enable = 1, disable = 0
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_get_irq_enable(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint8_t                 *en);
+
+/**
+ * dpbp_set_irq_mask() - Set interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @mask:      Event mask to trigger interrupt;
+ *                     each bit:
+ *                             0 = ignore event
+ *                             1 = consider event for asserting IRQ
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t          token,
+                     uint8_t           irq_index,
+                     uint32_t          mask);
+
+/**
+ * dpbp_get_irq_mask() - Get interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @mask:      Returned event mask to trigger interrupt
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t          token,
+                     uint8_t           irq_index,
+                     uint32_t          *mask);
+
+/**
+ * dpbp_get_irq_status() - Get the current status of any pending interrupts.
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @status:    Returned interrupts status - one bit per cause:
+ *                     0 = no interrupt pending
+ *                     1 = interrupt pending
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_get_irq_status(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint32_t                *status);
+
+/**
+ * dpbp_clear_irq_status() - Clear a pending interrupt's status
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @irq_index: The interrupt index to configure
+ * @status:    Bits to clear (W1C) - one bit per cause:
+ *                                     0 = don't change
+ *                                     1 = clear status bit
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_clear_irq_status(struct fsl_mc_io     *mc_io,
+                         uint16_t              token,
+                         uint8_t               irq_index,
+                         uint32_t              status);
+
+/**
+ * struct dpbp_attr - Structure representing DPBP attributes
+ * @id:                DPBP object ID
+ * @version:   DPBP version
+ * @bpid:      Hardware buffer pool ID; should be used as an argument in
+ *             acquire/release operations on buffers
+ */
+struct dpbp_attr {
+       int id;
+       /**
+        * struct version - Structure representing DPBP version
+        * @major:      DPBP major version
+        * @minor:      DPBP minor version
+        */
+       struct {
+               uint16_t major;
+               uint16_t minor;
+       } version;
+       uint16_t bpid;
+};
+
+/**
+ * dpbp_get_attributes - Retrieve DPBP attributes.
+ *
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPBP object
+ * @attr:      Returned object's attributes
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpbp_get_attributes(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       struct dpbp_attr        *attr);
+
+/** @} */
+
+#endif /* __FSL_DPBP_H */
diff --git a/drivers/staging/fsl-mc/include/dpcon-cmd.h b/drivers/staging/fsl-mc/include/dpcon-cmd.h
new file mode 100644 (file)
index 0000000..c878d33
--- /dev/null
@@ -0,0 +1,62 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the above-listed copyright holders nor the
+* names of any contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+*
+* ALTERNATIVELY, this software may be distributed under the terms of the
+* GNU General Public License ("GPL") as published by the Free Software
+* Foundation, either version 2 of that License or (at your option) any
+* later version.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT 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.
+*/
+#ifndef _FSL_DPCON_CMD_H
+#define _FSL_DPCON_CMD_H
+
+/* DPCON Version */
+#define DPCON_VER_MAJOR                                2
+#define DPCON_VER_MINOR                                0
+
+/* Command IDs */
+#define DPCON_CMDID_CLOSE                              0x800
+#define DPCON_CMDID_OPEN                               0x808
+#define DPCON_CMDID_CREATE                             0x908
+#define DPCON_CMDID_DESTROY                            0x900
+
+#define DPCON_CMDID_ENABLE                             0x002
+#define DPCON_CMDID_DISABLE                            0x003
+#define DPCON_CMDID_GET_ATTR                           0x004
+#define DPCON_CMDID_RESET                              0x005
+#define DPCON_CMDID_IS_ENABLED                         0x006
+
+#define DPCON_CMDID_SET_IRQ                            0x010
+#define DPCON_CMDID_GET_IRQ                            0x011
+#define DPCON_CMDID_SET_IRQ_ENABLE                     0x012
+#define DPCON_CMDID_GET_IRQ_ENABLE                     0x013
+#define DPCON_CMDID_SET_IRQ_MASK                       0x014
+#define DPCON_CMDID_GET_IRQ_MASK                       0x015
+#define DPCON_CMDID_GET_IRQ_STATUS                     0x016
+#define DPCON_CMDID_CLEAR_IRQ_STATUS                   0x017
+
+#define DPCON_CMDID_SET_NOTIFICATION                   0x100
+
+#endif /* _FSL_DPCON_CMD_H */
diff --git a/drivers/staging/fsl-mc/include/dpmng.h b/drivers/staging/fsl-mc/include/dpmng.h
new file mode 100644 (file)
index 0000000..0fc0a57
--- /dev/null
@@ -0,0 +1,80 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef __FSL_DPMNG_H
+#define __FSL_DPMNG_H
+
+/* Management Complex General API
+ * Contains general API for the Management Complex firmware
+ */
+
+struct fsl_mc_io;
+
+/**
+ * Management Complex firmware version information
+ */
+#define MC_VER_MAJOR 5
+#define MC_VER_MINOR 0
+
+/**
+ * struct mc_versoin
+ * @major: Major version number: incremented on API compatibility changes
+ * @minor: Minor version number: incremented on API additions (that are
+ *             backward compatible); reset when major version is incremented
+ * @revision: Internal revision number: incremented on implementation changes
+ *             and/or bug fixes that have no impact on API
+ */
+struct mc_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t revision;
+};
+
+/**
+ * mc_get_version() - Retrieves the Management Complex firmware
+ *                     version information
+ * @mc_io:             Pointer to opaque I/O object
+ * @mc_ver_info:       Returned version information structure
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info);
+
+/**
+ * dpmng_get_container_id() - Get container ID associated with a given portal.
+ * @mc_io:             Pointer to MC portal's I/O object
+ * @container_id:      Requested container ID
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpmng_get_container_id(struct fsl_mc_io *mc_io, int *container_id);
+
+#endif /* __FSL_DPMNG_H */
diff --git a/drivers/staging/fsl-mc/include/dprc.h b/drivers/staging/fsl-mc/include/dprc.h
new file mode 100644 (file)
index 0000000..f1862a7
--- /dev/null
@@ -0,0 +1,801 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef _FSL_DPRC_H
+#define _FSL_DPRC_H
+
+/* Data Path Resource Container API
+ * Contains DPRC API for managing and querying DPAA resources
+ */
+
+struct fsl_mc_io;
+
+/**
+ * Set this value as the icid value in dprc_cfg structure when creating a
+ * container, in case the ICID is not selected by the user and should be
+ * allocated by the DPRC from the pool of ICIDs.
+ */
+#define DPRC_GET_ICID_FROM_POOL                        (uint16_t)(~(0))
+
+/**
+ * Set this value as the portal_id value in dprc_cfg structure when creating a
+ * container, in case the portal ID is not specifically selected by the
+ * user and should be allocated by the DPRC from the pool of portal ids.
+ */
+#define DPRC_GET_PORTAL_ID_FROM_POOL   (int)(~(0))
+
+/**
+ * dprc_open() - Open DPRC object for use
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @container_id: Container ID to open
+ * @token:     Returned token of DPRC object
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ *
+ * @warning    Required before any operation on the object.
+ */
+int dprc_open(struct fsl_mc_io *mc_io, int container_id, uint16_t *token);
+
+/**
+ * dprc_close() - Close the control session of the object
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_close(struct fsl_mc_io *mc_io, uint16_t token);
+
+/**
+ * Container general options
+ *
+ * These options may be selected at container creation by the container creator
+ * and can be retrieved using dprc_get_attributes()
+ */
+
+/* Spawn Policy Option allowed - Indicates that the new container is allowed
+ * to spawn and have its own child containers.
+ */
+#define DPRC_CFG_OPT_SPAWN_ALLOWED             0x00000001
+
+/* General Container allocation policy - Indicates that the new container is
+ * allowed to allocate requested resources from its parent container; if not
+ * set, the container is only allowed to use resources in its own pools; Note
+ * that this is a container's global policy, but the parent container may
+ * override it and set specific quota per resource type.
+ */
+#define DPRC_CFG_OPT_ALLOC_ALLOWED             0x00000002
+
+/* Object initialization allowed - software context associated with this
+ * container is allowed to invoke object initialization operations.
+ */
+#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED        0x00000004
+
+/* Topology change allowed - software context associated with this
+ * container is allowed to invoke topology operations, such as attach/detach
+ * of network objects.
+ */
+#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED  0x00000008
+
+/* IOMMU bypass - indicates whether objects of this container are permitted
+ * to bypass the IOMMU.
+ */
+#define DPRC_CFG_OPT_IOMMU_BYPASS              0x00000010
+
+/* AIOP - Indicates that container belongs to AIOP.  */
+#define DPRC_CFG_OPT_AIOP                      0x00000020
+
+/**
+ * struct dprc_cfg - Container configuration options
+ * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
+ *             ICID value is allocated by the DPRC
+ * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
+ *             portal ID is allocated by the DPRC
+ * @options: Combination of 'DPRC_CFG_OPT_<X>' options
+ */
+struct dprc_cfg {
+       uint16_t icid;
+       int portal_id;
+       uint64_t options;
+};
+
+/**
+ * dprc_create_container() - Create child container
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @cfg:       Child container configuration
+ * @child_container_id:        Returned child container ID
+ * @child_portal_paddr:        Returned base physical address of the
+ *                                     child portal
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_create_container(struct fsl_mc_io     *mc_io,
+                         uint16_t              token,
+                         struct dprc_cfg       *cfg,
+                         int                   *child_container_id,
+                         uint64_t              *child_portal_paddr);
+
+/**
+ * dprc_destroy_container() - Destroy child container.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @child_container_id:        ID of the container to destroy
+ *
+ * This function terminates the child container, so following this call the
+ * child container ID becomes invalid.
+ *
+ * Notes:
+ * - All resources and objects of the destroyed container are returned to the
+ * parent container or destroyed if were created be the destroyed container.
+ * - This function destroy all the child containers of the specified
+ *   container prior to destroying the container itself.
+ *
+ * warning: Only the parent container is allowed to destroy a child policy
+ *             Container 0 can't be destroyed
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ *
+ */
+int dprc_destroy_container(struct fsl_mc_io    *mc_io,
+                          uint16_t             token,
+                          int                  child_container_id);
+
+/**
+ * dprc_reset_container - Reset child container.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @child_container_id:        ID of the container to reset
+ *
+ * In case a software context crashes or becomes non-responsive, the parent
+ * may wish to reset its resources container before the software context is
+ * restarted.
+ *
+ * This routine informs all objects assigned to the child container that the
+ * container is being reset, so they may perform any cleanup operations that are
+ * needed. All objects handles that were owned by the child container shall be
+ * closed.
+ *
+ * Note that such request may be submitted even if the child software context
+ * has not crashed, but the resulting object cleanup operations will not be
+ * aware of that.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_reset_container(struct fsl_mc_io *mc_io,
+                        uint16_t token,
+                        int child_container_id);
+
+/* IRQ */
+
+/* Number of dprc's IRQs */
+#define DPRC_NUM_OF_IRQS               1
+
+/* Object irq events */
+
+/* IRQ event - Indicates that a new object assigned to the container */
+#define DPRC_IRQ_EVENT_OBJ_ADDED               0x00000001
+/* IRQ event - Indicates that an object was unassigned from the container */
+#define DPRC_IRQ_EVENT_OBJ_REMOVED             0x00000002
+/* IRQ event - Indicates that resources assigned to the container */
+#define DPRC_IRQ_EVENT_RES_ADDED               0x00000004
+/* IRQ event - Indicates that resources unassigned from the container */
+#define DPRC_IRQ_EVENT_RES_REMOVED             0x00000008
+/* IRQ event - Indicates that one of the descendant containers that opened by
+ * this container is destroyed
+ */
+#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED     0x00000010
+
+/* IRQ event - Indicates that on one of the container's opened object is
+ * destroyed
+ */
+#define DPRC_IRQ_EVENT_OBJ_DESTROYED           0x00000020
+
+/* Irq event - Indicates that object is created at the container */
+#define DPRC_IRQ_EVENT_OBJ_CREATED             0x00000040
+
+/**
+ * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: Identifies the interrupt index to configure
+ * @irq_addr:  Address that must be written to
+ *                     signal a message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: Returned a user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_set_irq(struct fsl_mc_io      *mc_io,
+                uint16_t               token,
+                uint8_t                irq_index,
+                uint64_t               irq_addr,
+                uint32_t               irq_val,
+                int                    user_irq_id);
+
+/**
+ * dprc_get_irq() - Get IRQ information from the DPRC.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @type:      Returned interrupt type: 0 represents message interrupt
+ *                     type (both irq_addr and irq_val are valid)
+ * @irq_addr:  Returned address that must be written to
+ *                     signal the message-based interrupt
+ * @irq_val:   Value to write into irq_addr address
+ * @user_irq_id: A user defined number associated with this IRQ
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_irq(struct fsl_mc_io      *mc_io,
+                uint16_t               token,
+                uint8_t                irq_index,
+                int                    *type,
+                uint64_t               *irq_addr,
+                uint32_t               *irq_val,
+                int                    *user_irq_id);
+
+/**
+ * dprc_set_irq_enable() - Set overall interrupt state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @en:                Interrupt state - enable = 1, disable = 0
+ *
+ * Allows GPP software to control when interrupts are generated.
+ * Each interrupt can have up to 32 causes.  The enable/disable control's the
+ * overall interrupt state. if the interrupt is disabled no causes will cause
+ * an interrupt.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_set_irq_enable(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint8_t                 en);
+
+/**
+ * dprc_get_irq_enable() - Get overall interrupt state.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index:  The interrupt index to configure
+ * @en:                Returned interrupt state - enable = 1, disable = 0
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_irq_enable(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint8_t                 *en);
+
+/**
+ * dprc_set_irq_mask() - Set interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @mask:      event mask to trigger interrupt;
+ *                     each bit:
+ *                             0 = ignore event
+ *                             1 = consider event for asserting irq
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t          token,
+                     uint8_t           irq_index,
+                     uint32_t          mask);
+
+/**
+ * dprc_get_irq_mask() - Get interrupt mask.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @mask:      Returned event mask to trigger interrupt
+ *
+ * Every interrupt can have up to 32 causes and the interrupt model supports
+ * masking/unmasking each cause independently
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
+                     uint16_t          token,
+                     uint8_t           irq_index,
+                     uint32_t          *mask);
+
+/**
+ * dprc_get_irq_status() - Get the current status of any pending interrupts.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @status:    Returned interrupts status - one bit per cause:
+ *                     0 = no interrupt pending
+ *                     1 = interrupt pending
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_irq_status(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       uint8_t                 irq_index,
+                       uint32_t                *status);
+
+/**
+ * dprc_clear_irq_status() - Clear a pending interrupt's status
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @irq_index: The interrupt index to configure
+ * @status:    bits to clear (W1C) - one bit per cause:
+ *                                     0 = don't change
+ *                                     1 = clear status bit
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_clear_irq_status(struct fsl_mc_io     *mc_io,
+                         uint16_t              token,
+                         uint8_t               irq_index,
+                         uint32_t              status);
+
+/**
+ * struct dprc_attributes - Container attributes
+ * @container_id: Container's ID
+ * @icid: Container's ICID
+ * @portal_id: Container's portal ID
+ * @options: Container's options as set at container's creation
+ * @version: DPRC version
+ */
+struct dprc_attributes {
+       int container_id;
+       uint16_t icid;
+       int portal_id;
+       uint64_t options;
+       /**
+        * struct version - DPRC version
+        * @major: DPRC major version
+        * @minor: DPRC minor version
+        */
+       struct {
+               uint16_t major;
+               uint16_t minor;
+       } version;
+};
+
+/**
+ * dprc_get_attributes() - Obtains container attributes
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @attributes Returned container attributes
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_attributes(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       struct dprc_attributes  *attributes);
+
+/**
+ * dprc_set_res_quota() - Set allocation policy for a specific resource/object
+ *             type in a child container
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @child_container_id:        ID of the child container
+ * @type:      Resource/object type
+ * @quota:     Sets the maximum number of resources of the selected type
+ *             that the child container is allowed to allocate from its parent;
+ *             when quota is set to -1, the policy is the same as container's
+ *             general policy.
+ *
+ * Allocation policy determines whether or not a container may allocate
+ * resources from its parent. Each container has a 'global' allocation policy
+ * that is set when the container is created.
+ *
+ * This function sets allocation policy for a specific resource type.
+ * The default policy for all resource types matches the container's 'global'
+ * allocation policy.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ *
+ * @warning    Only the parent container is allowed to change a child policy.
+ */
+int dprc_set_res_quota(struct fsl_mc_io        *mc_io,
+                      uint16_t         token,
+                      int              child_container_id,
+                      char             *type,
+                      uint16_t         quota);
+
+/**
+ * dprc_get_res_quota() - Gets the allocation policy of a specific
+ *             resource/object type in a child container
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @child_container_id;        ID of the child container
+ * @type:      resource/object type
+ * @quota:     Returnes the maximum number of resources of the selected type
+ *             that the child container is allowed to allocate from the parent;
+ *             when quota is set to -1, the policy is the same as container's
+ *             general policy.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_res_quota(struct fsl_mc_io        *mc_io,
+                      uint16_t         token,
+                      int              child_container_id,
+                      char             *type,
+                      uint16_t         *quota);
+
+/* Resource request options */
+
+/* Explicit resource ID request - The requested objects/resources
+ * are explicit and sequential (in case of resources).
+ * The base ID is given at res_req at base_align field
+ */
+#define DPRC_RES_REQ_OPT_EXPLICIT              0x00000001
+
+/* Aligned resources request - Relevant only for resources
+ * request (and not objects). Indicates that resources base ID should be
+ * sequential and aligned to the value given at dprc_res_req base_align field
+ */
+#define DPRC_RES_REQ_OPT_ALIGNED               0x00000002
+
+/* Plugged Flag - Relevant only for object assignment request.
+ * Indicates that after all objects assigned. An interrupt will be invoked at
+ * the relevant GPP. The assigned object will be marked as plugged.
+ * plugged objects can't be assigned from their container
+ */
+#define DPRC_RES_REQ_OPT_PLUGGED               0x00000004
+
+/**
+ * struct dprc_res_req - Resource request descriptor, to be used in assignment
+ *                     or un-assignment of resources and objects.
+ * @type: Resource/object type: Represent as a NULL terminated string.
+ *     This string may received by using dprc_get_pool() to get resource
+ *     type and dprc_get_obj() to get object type;
+ *     Note: it is not possible to assign/un-assign DPRC objects
+ * @num: Number of resources
+ * @options: Request options: combination of DPRC_RES_REQ_OPT_ options
+ * @id_base_align: In case of explicit assignment (DPRC_RES_REQ_OPT_EXPLICIT
+ *             is set at option), this field represents the required base ID
+ *             for resource allocation; In case of aligned assignment
+ *             (DPRC_RES_REQ_OPT_ALIGNED is set at option), this field
+ *             indicates the required alignment for the resource ID(s) -
+ *             use 0 if there is no alignment or explicit ID requirements
+ */
+struct dprc_res_req {
+       char type[16];
+       uint32_t num;
+       uint32_t options;
+       int id_base_align;
+};
+
+/**
+ * dprc_assign() - Assigns objects or resource to a child container.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @container_id: ID of the child container
+ * @res_req:   Describes the type and amount of resources to
+ *                     assign to the given container
+ *
+ * Assignment is usually done by a parent (this DPRC) to one of its child
+ * containers.
+ *
+ * According to the DPRC allocation policy, the assigned resources may be taken
+ * (allocated) from the container's ancestors, if not enough resources are
+ * available in the container itself.
+ *
+ * The type of assignment depends on the dprc_res_req options, as follows:
+ * - DPRC_RES_REQ_OPT_EXPLICIT: indicates that assigned resources should have
+ *   the explicit base ID specified at the id_base_align field of res_req.
+ * - DPRC_RES_REQ_OPT_ALIGNED: indicates that the assigned resources should be
+ *   aligned to the value given at id_base_align field of res_req.
+ * - DPRC_RES_REQ_OPT_PLUGGED: Relevant only for object assignment,
+ *   and indicates that the object must be set to the plugged state.
+ *
+ * A container may use this function with its own ID in order to change a
+ * object state to plugged or unplugged.
+ *
+ * If IRQ information has been set in the child DPRC, it will signal an
+ * interrupt following every change in its object assignment.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_assign(struct fsl_mc_io       *mc_io,
+               uint16_t                token,
+               int                     container_id,
+               struct dprc_res_req     *res_req);
+
+/**
+ * dprc_unassign() - Un-assigns objects or resources from a child container
+ *             and moves them into this (parent) DPRC.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @child_container_id:        ID of the child container
+ * @res_req:   Describes the type and amount of resources to un-assign from
+ *             the child container
+ *
+ * Un-assignment of objects can succeed only if the object is not in the
+ * plugged or opened state.
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_unassign(struct fsl_mc_io     *mc_io,
+                 uint16_t              token,
+                 int                   child_container_id,
+                 struct dprc_res_req   *res_req);
+
+/**
+ * dprc_get_pool_count() - Get the number of dprc's pools
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @pool_count:        Returned number of resource pools in the dprc
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_pool_count(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       int                     *pool_count);
+
+/**
+ * dprc_get_pool() - Get the type (string) of a certain dprc's pool
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @pool_index;        Index of the pool to be queried (< pool_count)
+ * @type:      The type of the pool
+ *
+ * The pool types retrieved one by one by incrementing
+ * pool_index up to (not including) the value of pool_count returned
+ * from dprc_get_pool_count(). dprc_get_pool_count() must
+ * be called prior to dprc_get_pool().
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_pool(struct fsl_mc_io     *mc_io,
+                 uint16_t              token,
+                 int                   pool_index,
+                 char                  *type);
+
+/**
+ * dprc_get_obj_count() - Obtains the number of objects in the DPRC
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @obj_count: Number of objects assigned to the DPRC
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_obj_count(struct fsl_mc_io *mc_io, uint16_t token, int *obj_count);
+
+/* Objects Attributes Flags */
+
+/* Opened state - Indicates that an object is open by at least one owner */
+#define DPRC_OBJ_STATE_OPEN            0x00000001
+/* Plugged state - Indicates that the object is plugged */
+#define DPRC_OBJ_STATE_PLUGGED         0x00000002
+
+/**
+ * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
+ * @type: Type of object: NULL terminated string
+ * @id: ID of logical object resource
+ * @vendor: Object vendor identifier
+ * @ver_major: Major version number
+ * @ver_minor:  Minor version number
+ * @irq_count: Number of interrupts supported by the object
+ * @region_count: Number of mappable regions supported by the object
+ * @state: Object state: combination of DPRC_OBJ_STATE_ states
+ */
+struct dprc_obj_desc {
+       char type[16];
+       int id;
+       uint16_t vendor;
+       uint16_t ver_major;
+       uint16_t ver_minor;
+       uint8_t irq_count;
+       uint8_t region_count;
+       uint32_t state;
+};
+
+/**
+ * dprc_get_obj() - Get general information on an object
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @obj_index: Index of the object to be queried (< obj_count)
+ * @obj_desc:  Returns the requested object descriptor
+ *
+ * The object descriptors are retrieved one by one by incrementing
+ * obj_index up to (not including) the value of obj_count returned
+ * from dprc_get_obj_count(). dprc_get_obj_count() must
+ * be called prior to dprc_get_obj().
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_obj(struct fsl_mc_io      *mc_io,
+                uint16_t               token,
+                int                    obj_index,
+                struct dprc_obj_desc   *obj_desc);
+
+/**
+ * dprc_get_res_count() - Obtains the number of free resources that are assigned
+ *             to this container, by pool type
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @type:      pool type
+ * @res_count: Returned number of free resources of the given
+ *                     resource type that are assigned to this DPRC
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_res_count(struct fsl_mc_io        *mc_io,
+                      uint16_t         token,
+                      char             *type,
+                      int              *res_count);
+
+/**
+ * enum dprc_iter_status - Iteration status
+ * @DPRC_ITER_STATUS_FIRST: Perform first iteration
+ * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
+ * @DPRC_ITER_STATUS_LAST: Indicates last iteration
+ */
+enum dprc_iter_status {
+       DPRC_ITER_STATUS_FIRST = 0,
+       DPRC_ITER_STATUS_MORE = 1,
+       DPRC_ITER_STATUS_LAST = 2
+};
+
+/**
+ * struct dprc_res_ids_range_desc - Resource ID range descriptor
+ * @base_id: Base resource ID of this range
+ * @last_id: Last resource ID of this range
+ * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
+ *     first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
+ *     additional iterations are needed, until the returned marker is
+ *     DPRC_ITER_STATUS_LAST
+ */
+struct dprc_res_ids_range_desc {
+       int base_id;
+       int last_id;
+       enum dprc_iter_status iter_status;
+};
+
+/**
+ * dprc_get_res_ids() - Obtains IDs of free resources in the container
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @type:      pool type
+ * @range_desc:        range descriptor
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_res_ids(struct fsl_mc_io                  *mc_io,
+                    uint16_t                           token,
+                    char                               *type,
+                    struct dprc_res_ids_range_desc     *range_desc);
+
+/**
+ * dprc_get_portal_paddr() - Get the physical address of MC portals
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @portal_id: MC portal ID
+ * @portal_addr: The physical address of the MC portal ID
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_portal_paddr(struct fsl_mc_io     *mc_io,
+                         uint16_t              token,
+                         int                   portal_id,
+                         uint64_t              *portal_addr);
+
+/**
+ * struct dprc_region_desc - Mappable region descriptor
+ * @base_paddr: Region base physical address
+ * @size: Region size (in bytes)
+ */
+struct dprc_region_desc {
+       uint64_t base_paddr;
+       uint32_t size;
+};
+
+/**
+ * dprc_get_obj_region() - Get region information for a specified object.
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @obj_type;  Object type as returned in dprc_get_obj()
+ * @obj_id:    Unique object instance as returned in dprc_get_obj()
+ * @region_index: The specific region to query
+ * @region_desc:  Returns the requested region descriptor
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_get_obj_region(struct fsl_mc_io       *mc_io,
+                       uint16_t                token,
+                       char                    *obj_type,
+                       int                     obj_id,
+                       uint8_t                 region_index,
+                       struct dprc_region_desc *region_desc);
+
+/**
+ * struct dprc_endpoint - Endpoint description for link connect/disconnect
+ *                     operations
+ * @type: Endpoint object type: NULL terminated string
+ * @id: Endpoint object ID
+ * @interface_id: Interface ID; should be set for endpoints with multiple
+ *             interfaces ("dpsw", "dpdmux"); for others, always set to 0
+ */
+struct dprc_endpoint {
+       char type[16];
+       int id;
+       int interface_id;
+};
+
+/**
+ * dprc_connect() - Connect two endpoints to create a network link between them
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @endpoint1: Endpoint 1 configuration parameters
+ * @endpoint2: Endpoint 2 configuration parameters
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_connect(struct fsl_mc_io              *mc_io,
+                uint16_t                       token,
+                const struct dprc_endpoint     *endpoint1,
+                const struct dprc_endpoint     *endpoint2);
+
+/**
+ * dprc_disconnect() - Disconnect one endpoint to remove its network connection
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @token:     Token of DPRC object
+ * @endpoint:  Endpoint configuration parameters
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dprc_disconnect(struct fsl_mc_io           *mc_io,
+                   uint16_t                    token,
+                   const struct dprc_endpoint  *endpoint);
+
+/**
+* dprc_get_connection() - Get connected endpoint and link status if connection
+*                      exists.
+* @mc_io               Pointer to MC portal's I/O object
+* @token               Token of DPRC object
+* @endpoint1   Endpoint 1 configuration parameters
+* @endpoint2   Returned endpoint 2 configuration parameters
+* @state:      Returned link state: 1 - link is up, 0 - link is down
+*
+* Return:     '0' on Success; -ENAVAIL if connection does not exist.
+*/
+int dprc_get_connection(struct fsl_mc_io               *mc_io,
+                       uint16_t                        token,
+                       const struct dprc_endpoint      *endpoint1,
+                       struct dprc_endpoint            *endpoint2,
+                       int                             *state);
+
+#endif /* _FSL_DPRC_H */
+
diff --git a/drivers/staging/fsl-mc/include/mc-cmd.h b/drivers/staging/fsl-mc/include/mc-cmd.h
new file mode 100644 (file)
index 0000000..32501e0
--- /dev/null
@@ -0,0 +1,113 @@
+/* Copyright 2013-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+#ifndef __FSL_MC_CMD_H
+#define __FSL_MC_CMD_H
+
+#define MC_CMD_NUM_OF_PARAMS   7
+
+#define MAKE_UMASK64(_width) \
+       ((uint64_t)((_width) < 64 ? ((uint64_t)1 << (_width)) - 1 : -1))
+
+static inline uint64_t mc_enc(int lsoffset, int width, uint64_t val)
+{
+       return (uint64_t)(((uint64_t)val & MAKE_UMASK64(width)) << lsoffset);
+}
+
+static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width)
+{
+       return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width));
+}
+
+struct mc_command {
+       uint64_t header;
+       uint64_t params[MC_CMD_NUM_OF_PARAMS];
+};
+
+enum mc_cmd_status {
+       MC_CMD_STATUS_OK = 0x0, /* Completed successfully */
+       MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */
+       MC_CMD_STATUS_AUTH_ERR = 0x3, /* Authentication error */
+       MC_CMD_STATUS_NO_PRIVILEGE = 0x4, /* No privilege */
+       MC_CMD_STATUS_DMA_ERR = 0x5, /* DMA or I/O error */
+       MC_CMD_STATUS_CONFIG_ERR = 0x6, /* Configuration error */
+       MC_CMD_STATUS_TIMEOUT = 0x7, /* Operation timed out */
+       MC_CMD_STATUS_NO_RESOURCE = 0x8, /* No resources */
+       MC_CMD_STATUS_NO_MEMORY = 0x9, /* No memory available */
+       MC_CMD_STATUS_BUSY = 0xA, /* Device is busy */
+       MC_CMD_STATUS_UNSUPPORTED_OP = 0xB, /* Unsupported operation */
+       MC_CMD_STATUS_INVALID_STATE = 0xC /* Invalid state */
+};
+
+#define MC_CMD_HDR_CMDID_O     52      /* Command ID field offset */
+#define MC_CMD_HDR_CMDID_S     12      /* Command ID field size */
+#define MC_CMD_HDR_TOKEN_O     38      /* Token field offset */
+#define MC_CMD_HDR_TOKEN_S     10      /* Token field size */
+#define MC_CMD_HDR_STATUS_O    16      /* Status field offset */
+#define MC_CMD_HDR_STATUS_S    8       /* Status field size*/
+#define MC_CMD_HDR_PRI_O       15      /* Priority field offset */
+#define MC_CMD_HDR_PRI_S       1       /* Priority field size */
+
+#define MC_CMD_HDR_READ_STATUS(_hdr) \
+       ((enum mc_cmd_status)mc_dec((_hdr), \
+               MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S))
+
+#define MC_CMD_HDR_READ_TOKEN(_hdr) \
+       ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S))
+
+#define MC_CMD_PRI_LOW         0 /* Low Priority command indication */
+#define MC_CMD_PRI_HIGH                1 /* High Priority command indication */
+
+#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \
+       ((_ext)[_param] |= mc_enc((_offset), (_width), _arg))
+
+#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \
+       ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
+
+#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \
+       (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width)))
+
+static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id,
+                                           uint8_t priority,
+                                           uint16_t token)
+{
+       uint64_t hdr;
+
+       hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id);
+       hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token);
+       hdr |= mc_enc(MC_CMD_HDR_PRI_O, MC_CMD_HDR_PRI_S, priority);
+       hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S,
+                      MC_CMD_STATUS_READY);
+
+       return hdr;
+}
+
+#endif /* __FSL_MC_CMD_H */
diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h
new file mode 100644 (file)
index 0000000..8e67075
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Freescale Management Complex (MC) bus private declarations
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <German.Rivera@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#ifndef _FSL_MC_PRIVATE_H_
+#define _FSL_MC_PRIVATE_H_
+
+#include "../include/mc.h"
+#include <linux/mutex.h>
+#include <linux/stringify.h>
+
+#define FSL_MC_DPRC_DRIVER_NAME    "fsl_mc_dprc"
+
+#define FSL_MC_DEVICE_MATCH(_mc_dev, _obj_desc) \
+       (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \
+        (_mc_dev)->obj_desc.id == (_obj_desc)->id)
+
+#define FSL_MC_IS_ALLOCATABLE(_obj_type) \
+       (strcmp(_obj_type, "dpbp") == 0 || \
+        strcmp(_obj_type, "dpmcp") == 0 || \
+        strcmp(_obj_type, "dpcon") == 0)
+
+/**
+ * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device
+ * @root_mc_bus_dev: MC object device representing the root DPRC
+ * @addr_translation_ranges: array of bus to system address translation ranges
+ */
+struct fsl_mc {
+       struct fsl_mc_device *root_mc_bus_dev;
+       uint8_t num_translation_ranges;
+       struct fsl_mc_addr_translation_range *translation_ranges;
+};
+
+/**
+ * struct fsl_mc_addr_translation_range - bus to system address translation
+ * range
+ * @start_mc_addr: Start MC address of the range being translated
+ * @end_mc_addr: MC address of the first byte after the range (last MC
+ * address of the range is end_mc_addr - 1)
+ * @start_phys_addr: system physical address corresponding to start_mc_addr
+ */
+struct fsl_mc_addr_translation_range {
+       uint64_t start_mc_addr;
+       uint64_t end_mc_addr;
+       phys_addr_t start_phys_addr;
+};
+
+/**
+ * struct fsl_mc_resource_pool - Pool of MC resources of a given
+ * type
+ * @type: type of resources in the pool
+ * @max_count: maximum number of resources in the pool
+ * @free_count: number of free resources in the pool
+ * @mutex: mutex to serialize access to the pool's free list
+ * @free_list: anchor node of list of free resources in the pool
+ * @mc_bus: pointer to the MC bus that owns this resource pool
+ */
+struct fsl_mc_resource_pool {
+       enum fsl_mc_pool_type type;
+       int16_t max_count;
+       int16_t free_count;
+       struct mutex mutex;     /* serializes access to free_list */
+       struct list_head free_list;
+       struct fsl_mc_bus *mc_bus;
+};
+
+/**
+ * struct fsl_mc_bus - logical bus that corresponds to a physical DPRC
+ * @mc_dev: fsl-mc device for the bus device itself.
+ * @resource_pools: array of resource pools (one pool per resource type)
+ * for this MC bus. These resources represent allocatable entities
+ * from the physical DPRC.
+ * @scan_mutex: Serializes bus scanning
+ */
+struct fsl_mc_bus {
+       struct fsl_mc_device mc_dev;
+       struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES];
+       struct mutex scan_mutex;    /* serializes bus scanning */
+};
+
+#define to_fsl_mc_bus(_mc_dev) \
+       container_of(_mc_dev, struct fsl_mc_bus, mc_dev)
+
+int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
+                                  struct fsl_mc_io *mc_io,
+                                  struct device *parent_dev,
+                                  struct fsl_mc_device **new_mc_dev);
+
+void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
+
+int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
+
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev);
+
+int __init dprc_driver_init(void);
+
+void __exit dprc_driver_exit(void);
+
+int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
+                                         enum fsl_mc_pool_type pool_type,
+                                         struct fsl_mc_resource
+                                                         **new_resource);
+
+void fsl_mc_resource_free(struct fsl_mc_resource *resource);
+
+#endif /* _FSL_MC_PRIVATE_H_ */
diff --git a/drivers/staging/fsl-mc/include/mc-sys.h b/drivers/staging/fsl-mc/include/mc-sys.h
new file mode 100644 (file)
index 0000000..cb3b5a2
--- /dev/null
@@ -0,0 +1,76 @@
+/* Copyright 2013-2014 Freescale Semiconductor Inc.
+ *
+ * Interface of the I/O services to send MC commands to the MC hardware
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the above-listed copyright holders nor the
+ *       names of any contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT 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.
+ */
+
+#ifndef _FSL_MC_SYS_H
+#define _FSL_MC_SYS_H
+
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/io.h>
+#include <linux/dma-mapping.h>
+
+struct fsl_mc_resource;
+struct mc_command;
+
+/**
+ * struct fsl_mc_io - MC I/O object to be passed-in to mc_send_command()
+ * @dev: device associated with this Mc I/O object
+ * @flags: flags for mc_send_command()
+ * @portal_size: MC command portal size in bytes
+ * @portal_phys_addr: MC command portal physical address
+ * @portal_virt_addr: MC command portal virtual address
+ * @resource: generic resource associated with the MC portal if
+ * the MC portal came from a resource pool, or NULL if the MC portal
+ * is permanently bound to a device (e.g., a DPRC)
+ */
+struct fsl_mc_io {
+       struct device *dev;
+       uint32_t flags;
+       uint32_t portal_size;
+       phys_addr_t portal_phys_addr;
+       void __iomem *portal_virt_addr;
+       struct fsl_mc_resource *resource;
+};
+
+int __must_check fsl_create_mc_io(struct device *dev,
+                                 phys_addr_t mc_portal_phys_addr,
+                                 uint32_t mc_portal_size,
+                                 struct fsl_mc_resource *resource,
+                                 uint32_t flags, struct fsl_mc_io **new_mc_io);
+
+void fsl_destroy_mc_io(struct fsl_mc_io *mc_io);
+
+int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd);
+
+#endif /* _FSL_MC_SYS_H */
diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h
new file mode 100644 (file)
index 0000000..fa02ef0
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Freescale Management Complex (MC) bus public interface
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <German.Rivera@freescale.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#ifndef _FSL_MC_H_
+#define _FSL_MC_H_
+
+#include <linux/device.h>
+#include <linux/mod_devicetable.h>
+#include <linux/list.h>
+#include "../include/dprc.h"
+
+#define FSL_MC_VENDOR_FREESCALE        0x1957
+
+struct fsl_mc_device;
+struct fsl_mc_io;
+
+/**
+ * struct fsl_mc_driver - MC object device driver object
+ * @driver: Generic device driver
+ * @match_id_table: table of supported device matching Ids
+ * @probe: Function called when a device is added
+ * @remove: Function called when a device is removed
+ * @shutdown: Function called at shutdown time to quiesce the device
+ * @suspend: Function called when a device is stopped
+ * @resume: Function called when a device is resumed
+ *
+ * Generic DPAA device driver object for device drivers that are registered
+ * with a DPRC bus. This structure is to be embedded in each device-specific
+ * driver structure.
+ */
+struct fsl_mc_driver {
+       struct device_driver driver;
+       const struct fsl_mc_device_match_id *match_id_table;
+       int (*probe)(struct fsl_mc_device *dev);
+       int (*remove)(struct fsl_mc_device *dev);
+       void (*shutdown)(struct fsl_mc_device *dev);
+       int (*suspend)(struct fsl_mc_device *dev, pm_message_t state);
+       int (*resume)(struct fsl_mc_device *dev);
+};
+
+#define to_fsl_mc_driver(_drv) \
+       container_of(_drv, struct fsl_mc_driver, driver)
+
+/**
+ * struct fsl_mc_device_match_id - MC object device Id entry for driver matching
+ * @vendor: vendor ID
+ * @obj_type: MC object type
+ * @ver_major: MC object version major number
+ * @ver_minor: MC object version minor number
+ *
+ * Type of entries in the "device Id" table for MC object devices supported by
+ * a MC object device driver. The last entry of the table has vendor set to 0x0
+ */
+struct fsl_mc_device_match_id {
+       uint16_t vendor;
+       const char obj_type[16];
+       uint32_t ver_major;
+       uint32_t ver_minor;
+};
+
+/**
+ * enum fsl_mc_pool_type - Types of allocatable MC bus resources
+ *
+ * Entries in these enum are used as indices in the array of resource
+ * pools of an fsl_mc_bus object.
+ */
+enum fsl_mc_pool_type {
+       FSL_MC_POOL_DPMCP = 0x0,    /* corresponds to "dpmcp" in the MC */
+       FSL_MC_POOL_DPBP,           /* corresponds to "dpbp" in the MC */
+       FSL_MC_POOL_DPCON,          /* corresponds to "dpcon" in the MC */
+
+       /*
+        * NOTE: New resource pool types must be added before this entry
+        */
+       FSL_MC_NUM_POOL_TYPES
+};
+
+/**
+ * struct fsl_mc_resource - MC generic resource
+ * @type: type of resource
+ * @id: unique MC resource Id within the resources of the same type
+ * @data: pointer to resource-specific data if the resource is currently
+ * allocated, or NULL if the resource is not currently allocated.
+ * @parent_pool: pointer to the parent resource pool from which this
+ * resource is allocated from.
+ * @node: Node in the free list of the corresponding resource pool
+ *
+ * NOTE: This structure is to be embedded as a field of specific
+ * MC resource structures.
+ */
+struct fsl_mc_resource {
+       enum fsl_mc_pool_type type;
+       int32_t id;
+       void *data;
+       struct fsl_mc_resource_pool *parent_pool;
+       struct list_head node;
+};
+
+/**
+ * Bit masks for a MC object device (struct fsl_mc_device) flags
+ */
+#define FSL_MC_IS_DPRC 0x0001
+
+/**
+ * Default DMA mask for devices on a fsl-mc bus
+ */
+#define FSL_MC_DEFAULT_DMA_MASK        (~0ULL)
+
+/**
+ * struct fsl_mc_device - MC object device object
+ * @dev: Linux driver model device object
+ * @dma_mask: Default DMA mask
+ * @flags: MC object device flags
+ * @icid: Isolation context ID for the device
+ * @mc_handle: MC handle for the corresponding MC object opened
+ * @mc_io: Pointer to MC IO object assigned to this device or
+ * NULL if none.
+ * @obj_desc: MC description of the DPAA device
+ * @regions: pointer to array of MMIO region entries
+ * @resource: generic resource associated with this MC object device, if any.
+ *
+ * Generic device object for MC object devices that are "attached" to a
+ * MC bus.
+ *
+ * NOTES:
+ * - For a non-DPRC object its icid is the same as its parent DPRC's icid.
+ * - The SMMU notifier callback gets invoked after device_add() has been
+ *   called for an MC object device, but before the device-specific probe
+ *   callback gets called.
+ * - DP_OBJ_DPRC objects are the only MC objects that have built-in MC
+ *   portals. For all other MC objects, their device drivers are responsible for
+ *   allocating MC portals for them by calling fsl_mc_portal_allocate().
+ * - Some types of MC objects (e.g., DP_OBJ_DPBP, DP_OBJ_DPCON) are
+ *   treated as resources that can be allocated/deallocated from the
+ *   corresponding resource pool in the object's parent DPRC, using the
+ *   fsl_mc_object_allocate()/fsl_mc_object_free() functions. These MC objects
+ *   are known as "allocatable" objects. For them, the corresponding
+ *   fsl_mc_device's 'resource' points to the associated resource object.
+ *   For MC objects that are not allocatable (e.g., DP_OBJ_DPRC, DP_OBJ_DPNI),
+ *   'resource' is NULL.
+ */
+struct fsl_mc_device {
+       struct device dev;
+       uint64_t dma_mask;
+       uint16_t flags;
+       uint16_t icid;
+       uint16_t mc_handle;
+       struct fsl_mc_io *mc_io;
+       struct dprc_obj_desc obj_desc;
+       struct resource *regions;
+       struct fsl_mc_resource *resource;
+};
+
+#define to_fsl_mc_device(_dev) \
+       container_of(_dev, struct fsl_mc_device, dev)
+
+/*
+ * module_fsl_mc_driver() - Helper macro for drivers that don't 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_fsl_mc_driver(__fsl_mc_driver) \
+       module_driver(__fsl_mc_driver, fsl_mc_driver_register, \
+                     fsl_mc_driver_unregister)
+
+/*
+ * Macro to avoid include chaining to get THIS_MODULE
+ */
+#define fsl_mc_driver_register(drv) \
+       __fsl_mc_driver_register(drv, THIS_MODULE)
+
+int __must_check __fsl_mc_driver_register(struct fsl_mc_driver *fsl_mc_driver,
+                                         struct module *owner);
+
+void fsl_mc_driver_unregister(struct fsl_mc_driver *driver);
+
+int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
+                                       uint16_t mc_io_flags,
+                                       struct fsl_mc_io **new_mc_io);
+
+void fsl_mc_portal_free(struct fsl_mc_io *mc_io);
+
+int fsl_mc_portal_reset(struct fsl_mc_io *mc_io);
+
+int __must_check fsl_mc_object_allocate(struct fsl_mc_device *mc_dev,
+                                       enum fsl_mc_pool_type pool_type,
+                                       struct fsl_mc_device **new_mc_adev);
+
+void fsl_mc_object_free(struct fsl_mc_device *mc_adev);
+
+extern struct bus_type fsl_mc_bus_type;
+
+#endif /* _FSL_MC_H_ */
index 922478e1cb576cd87a41ae70e544318910b40ff7..e5cc5bedf031e3f061d04c4aab8f80b6ec47cde4 100644 (file)
@@ -155,15 +155,4 @@ static struct pcmcia_driver ft1000_cs_driver = {
        .resume         = ft1000_resume,
 };
 
-static int __init init_ft1000_cs(void)
-{
-       return pcmcia_register_driver(&ft1000_cs_driver);
-}
-
-static void __exit exit_ft1000_cs(void)
-{
-       pcmcia_unregister_driver(&ft1000_cs_driver);
-}
-
-module_init(init_ft1000_cs);
-module_exit(exit_ft1000_cs);
+module_pcmcia_driver(ft1000_cs_driver);
index 06b0e9cfb9b17011a579b18ed1c948ced4f5565a..ddb74665fae951e9b208753d25b98e5369005b79 100644 (file)
@@ -276,8 +276,8 @@ u16 hdr_checksum(struct pseudo_hdr *pHdr)
        u16 *usPtr = (u16 *)pHdr;
        u16 chksum;
 
-       chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^
-                   usPtr[4]) ^ usPtr[5]) ^ usPtr[6]);
+       chksum = (((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^
+                   usPtr[4]) ^ usPtr[5]) ^ usPtr[6];
 
        return chksum;
 }
@@ -713,10 +713,10 @@ int card_download(struct net_device *dev, const u8 *pFileStart,
 
                                /* Get buffer for provisioning data */
                                pbuffer =
-                                       kmalloc((usHdrLength + sizeof(struct pseudo_hdr)),
+                                       kmalloc(usHdrLength + sizeof(struct pseudo_hdr),
                                                GFP_ATOMIC);
                                if (pbuffer) {
-                                       memcpy(pbuffer, (void *)pUcFile,
+                                       memcpy(pbuffer, pUcFile,
                                               (u32) (usHdrLength +
                                                      sizeof(struct pseudo_hdr)));
                                        /* link provisioning data */
index 017c3b92f51bff3d4835dd0f83ccd0eab43f19bd..0afe37f1255db46d09bed1a1853cce0694abf9ba 100644 (file)
@@ -327,7 +327,7 @@ static void ft1000_reset_asic(struct net_device *dev)
         */
        if (info->AsicID == MAGNEMITE_ID) {
                ft1000_write_reg(dev, FT1000_REG_RESET,
-                                (DSP_RESET_BIT | ASIC_RESET_BIT));
+                                DSP_RESET_BIT | ASIC_RESET_BIT);
        }
        mdelay(1);
        if (info->AsicID == ELECTRABUZZ_ID) {
@@ -364,6 +364,7 @@ static int ft1000_reset_card(struct net_device *dev)
        int i;
        unsigned long flags;
        struct prov_record *ptr;
+       struct prov_record *tmp;
 
        info->CardReady = 0;
        info->ProgConStat = 0;
@@ -373,9 +374,8 @@ static int ft1000_reset_card(struct net_device *dev)
        /* del_timer(&poll_timer); */
 
        /* Make sure we free any memory reserve for provisioning */
-       while (list_empty(&info->prov_list) == 0) {
+       list_for_each_entry_safe(ptr, tmp, &info->prov_list, list) {
                pr_debug("deleting provisioning record\n");
-               ptr = list_entry(info->prov_list.next, struct prov_record, list);
                list_del(&ptr->list);
                kfree(ptr->pprov_data);
                kfree(ptr);
@@ -387,7 +387,7 @@ static int ft1000_reset_card(struct net_device *dev)
        } else {
                pr_debug("resetting ASIC and DSP\n");
                ft1000_write_reg(dev, FT1000_REG_RESET,
-                                (DSP_RESET_BIT | ASIC_RESET_BIT));
+                                DSP_RESET_BIT | ASIC_RESET_BIT);
        }
 
        /* Copy DSP session record into info block if this is not a coldstart */
@@ -459,9 +459,8 @@ static int ft1000_reset_card(struct net_device *dev)
        if (card_download(dev, fw_entry->data, fw_entry->size)) {
                pr_debug("card download unsuccessful\n");
                return false;
-       } else {
-               pr_debug("card download successful\n");
        }
+       pr_debug("card download successful\n");
 
        mdelay(10);
 
@@ -860,64 +859,63 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,
        if (size > maxsz) {
                pr_debug("Invalid command length = %d\n", size);
                return false;
+       }
+       ppseudohdr = (u16 *)pbuffer;
+       spin_lock_irqsave(&info->dpram_lock, flags);
+       if (info->AsicID == ELECTRABUZZ_ID) {
+               ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
+                                FT1000_DPRAM_RX_BASE + 2);
+               for (i = 0; i <= (size >> 1); i++) {
+                       tempword =
+                               ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
+                       *pbuffer++ = ntohs(tempword);
+               }
        } else {
-               ppseudohdr = (u16 *)pbuffer;
-               spin_lock_irqsave(&info->dpram_lock, flags);
-               if (info->AsicID == ELECTRABUZZ_ID) {
-                       ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
-                                        FT1000_DPRAM_RX_BASE + 2);
-                       for (i = 0; i <= (size >> 1); i++) {
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
-                               *pbuffer++ = ntohs(tempword);
-                       }
-               } else {
-                       ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
-                                        FT1000_DPRAM_MAG_RX_BASE);
-                       *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
-                       pr_debug("received data = 0x%x\n", *pbuffer);
-                       pbuffer++;
-                       ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
-                                        FT1000_DPRAM_MAG_RX_BASE + 1);
-                       for (i = 0; i <= (size >> 2); i++) {
-                               *pbuffer =
-                                       inw(dev->base_addr +
-                                           FT1000_REG_MAG_DPDATAL);
-                               pbuffer++;
-                               *pbuffer =
-                                       inw(dev->base_addr +
-                                           FT1000_REG_MAG_DPDATAH);
-                               pbuffer++;
-                       }
-                       /* copy odd aligned word */
-                       *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);
-                       pr_debug("received data = 0x%x\n", *pbuffer);
+               ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
+                                FT1000_DPRAM_MAG_RX_BASE);
+               *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
+               pr_debug("received data = 0x%x\n", *pbuffer);
+               pbuffer++;
+               ft1000_write_reg(dev, FT1000_REG_DPRAM_ADDR,
+                                FT1000_DPRAM_MAG_RX_BASE + 1);
+               for (i = 0; i <= (size >> 2); i++) {
+                       *pbuffer =
+                               inw(dev->base_addr +
+                                   FT1000_REG_MAG_DPDATAL);
                        pbuffer++;
-                       *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
-                       pr_debug("received data = 0x%x\n", *pbuffer);
+                       *pbuffer =
+                               inw(dev->base_addr +
+                                   FT1000_REG_MAG_DPDATAH);
                        pbuffer++;
                }
-               if (size & 0x0001) {
-                       /* copy odd byte from fifo */
-                       tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
-                       *pbuffer = ntohs(tempword);
-               }
-               spin_unlock_irqrestore(&info->dpram_lock, flags);
+               /* copy odd aligned word */
+               *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAL);
+               pr_debug("received data = 0x%x\n", *pbuffer);
+               pbuffer++;
+               *pbuffer = inw(dev->base_addr + FT1000_REG_MAG_DPDATAH);
+               pr_debug("received data = 0x%x\n", *pbuffer);
+               pbuffer++;
+       }
+       if (size & 0x0001) {
+               /* copy odd byte from fifo */
+               tempword = ft1000_read_reg(dev, FT1000_REG_DPRAM_DATA);
+               *pbuffer = ntohs(tempword);
+       }
+       spin_unlock_irqrestore(&info->dpram_lock, flags);
 
-               /*
-                * Check if pseudo header checksum is good
-                * Calculate pseudo header checksum
-                */
-               tempword = *ppseudohdr++;
-               for (i = 1; i < 7; i++)
-                       tempword ^= *ppseudohdr++;
-               if ((tempword != *ppseudohdr)) {
-                       pr_debug("Pseudo header checksum mismatch\n");
-                       /* Drop this message */
-                       return false;
-               }
-               return true;
+       /*
+        * Check if pseudo header checksum is good
+        * Calculate pseudo header checksum
+        */
+       tempword = *ppseudohdr++;
+       for (i = 1; i < 7; i++)
+               tempword ^= *ppseudohdr++;
+       if (tempword != *ppseudohdr) {
+               pr_debug("Pseudo header checksum mismatch\n");
+               /* Drop this message */
+               return false;
        }
+       return true;
 }
 
 /*---------------------------------------------------------------------------
@@ -1129,7 +1127,9 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                                info->DSPInfoBlk[8] = 0x7200;
                                info->DSPInfoBlk[9] =
                                        htons(info->DSPInfoBlklen);
-                               ft1000_send_cmd(dev, (u16 *)info->DSPInfoBlk, (u16)(info->DSPInfoBlklen+4), 0);
+                               ft1000_send_cmd(dev, info->DSPInfoBlk,
+                                               (u16)(info->DSPInfoBlklen+4),
+                                               0);
                        }
 
                        break;
@@ -1295,9 +1295,9 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
                                          2) >> 8) & 0xff;
                        } else {
                                portid =
-                                       (ft1000_read_dpram_mag_16
+                                       ft1000_read_dpram_mag_16
                                         (dev, FT1000_MAG_PORT_ID,
-                                         FT1000_MAG_PORT_ID_INDX) & 0xff);
+                                         FT1000_MAG_PORT_ID_INDX) & 0xff;
                        }
                        pr_debug("DSP_QID = 0x%x\n", portid);
 
@@ -1400,105 +1400,104 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
                info->DrvErrNum = DrvErrNum;
                ft1000_reset_card(dev);
                return;
-       } else {
-               /* Flush corrupted pkt from FIFO */
-               i = 0;
-               do {
+       }
+       /* Flush corrupted pkt from FIFO */
+       i = 0;
+       do {
+               if (info->AsicID == ELECTRABUZZ_ID) {
+                       tempword =
+                               ft1000_read_reg(dev, FT1000_REG_DFIFO);
+                       tempword =
+                               ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
+               } else {
+                       templong =
+                               inl(dev->base_addr + FT1000_REG_MAG_DFR);
+                       tempword =
+                               inw(dev->base_addr + FT1000_REG_MAG_DFSR);
+               }
+               i++;
+               /*
+                * This should never happen unless the ASIC is broken.
+                * We must reset to recover.
+                */
+               if ((i > 2048) || (tempword == 0)) {
                        if (info->AsicID == ELECTRABUZZ_ID) {
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DFIFO);
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
+                               info->DSP_TIME[0] =
+                                       ft1000_read_dpram(dev,
+                                                         FT1000_DSP_TIMER0);
+                               info->DSP_TIME[1] =
+                                       ft1000_read_dpram(dev,
+                                                         FT1000_DSP_TIMER1);
+                               info->DSP_TIME[2] =
+                                       ft1000_read_dpram(dev,
+                                                         FT1000_DSP_TIMER2);
+                               info->DSP_TIME[3] =
+                                       ft1000_read_dpram(dev,
+                                                         FT1000_DSP_TIMER3);
                        } else {
-                               templong =
-                                       inl(dev->base_addr + FT1000_REG_MAG_DFR);
-                               tempword =
-                                       inw(dev->base_addr + FT1000_REG_MAG_DFSR);
+                               info->DSP_TIME[0] =
+                                       ft1000_read_dpram_mag_16(dev,
+                                                                FT1000_MAG_DSP_TIMER0,
+                                                                FT1000_MAG_DSP_TIMER0_INDX);
+                               info->DSP_TIME[1] =
+                                       ft1000_read_dpram_mag_16(dev,
+                                                                FT1000_MAG_DSP_TIMER1,
+                                                                FT1000_MAG_DSP_TIMER1_INDX);
+                               info->DSP_TIME[2] =
+                                       ft1000_read_dpram_mag_16(dev,
+                                                                FT1000_MAG_DSP_TIMER2,
+                                                                FT1000_MAG_DSP_TIMER2_INDX);
+                               info->DSP_TIME[3] =
+                                       ft1000_read_dpram_mag_16(dev,
+                                                                FT1000_MAG_DSP_TIMER3,
+                                                                FT1000_MAG_DSP_TIMER3_INDX);
                        }
-                       i++;
-                       /*
-                        * This should never happen unless the ASIC is broken.
-                        * We must reset to recover.
-                        */
-                       if ((i > 2048) || (tempword == 0)) {
-                               if (info->AsicID == ELECTRABUZZ_ID) {
-                                       info->DSP_TIME[0] =
-                                               ft1000_read_dpram(dev,
-                                                                 FT1000_DSP_TIMER0);
-                                       info->DSP_TIME[1] =
-                                               ft1000_read_dpram(dev,
-                                                                 FT1000_DSP_TIMER1);
-                                       info->DSP_TIME[2] =
-                                               ft1000_read_dpram(dev,
-                                                                 FT1000_DSP_TIMER2);
-                                       info->DSP_TIME[3] =
-                                               ft1000_read_dpram(dev,
-                                                                 FT1000_DSP_TIMER3);
-                               } else {
-                                       info->DSP_TIME[0] =
-                                               ft1000_read_dpram_mag_16(dev,
-                                                                        FT1000_MAG_DSP_TIMER0,
-                                                                        FT1000_MAG_DSP_TIMER0_INDX);
-                                       info->DSP_TIME[1] =
-                                               ft1000_read_dpram_mag_16(dev,
-                                                                        FT1000_MAG_DSP_TIMER1,
-                                                                        FT1000_MAG_DSP_TIMER1_INDX);
-                                       info->DSP_TIME[2] =
-                                               ft1000_read_dpram_mag_16(dev,
-                                                                        FT1000_MAG_DSP_TIMER2,
-                                                                        FT1000_MAG_DSP_TIMER2_INDX);
-                                       info->DSP_TIME[3] =
-                                               ft1000_read_dpram_mag_16(dev,
-                                                                        FT1000_MAG_DSP_TIMER3,
-                                                                        FT1000_MAG_DSP_TIMER3_INDX);
-                               }
+                       if (tempword == 0) {
+                               /*
+                                * Let's check if ASIC reads are still ok by reading the Mask register
+                                * which is never zero at this point of the code.
+                                */
+                               tempword =
+                                       inw(dev->base_addr +
+                                           FT1000_REG_SUP_IMASK);
                                if (tempword == 0) {
-                                       /*
-                                        * Let's check if ASIC reads are still ok by reading the Mask register
-                                        * which is never zero at this point of the code.
-                                        */
-                                       tempword =
-                                               inw(dev->base_addr +
-                                                   FT1000_REG_SUP_IMASK);
-                                       if (tempword == 0) {
-                                               /* This indicates that we can not communicate with the ASIC */
-                                               info->DrvErrNum =
-                                                       FIFO_FLUSH_BADCNT;
-                                       } else {
-                                               /* Let's assume that we really flush the FIFO */
-                                               pcmcia->PktIntfErr++;
-                                               return;
-                                       }
+                                       /* This indicates that we can not communicate with the ASIC */
+                                       info->DrvErrNum =
+                                               FIFO_FLUSH_BADCNT;
                                } else {
-                                       info->DrvErrNum = FIFO_FLUSH_MAXLIMIT;
+                                       /* Let's assume that we really flush the FIFO */
+                                       pcmcia->PktIntfErr++;
+                                       return;
                                }
-                               return;
+                       } else {
+                               info->DrvErrNum = FIFO_FLUSH_MAXLIMIT;
                        }
-                       tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
-               } while ((tempword & 0x03) != 0x03);
-               if (info->AsicID == ELECTRABUZZ_ID) {
-                       i++;
-                       pr_debug("Flushing FIFO complete = %x\n", tempword);
-                       /* Flush last word in FIFO. */
-                       tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
-                       /* Update FIFO counter for DSP */
-                       i = i * 2;
-                       pr_debug("Flush Data byte count to dsp = %d\n", i);
-                       info->fifo_cnt += i;
-                       ft1000_write_dpram(dev, FT1000_FIFO_LEN,
-                                          info->fifo_cnt);
-               } else {
-                       pr_debug("Flushing FIFO complete = %x\n", tempword);
-                       /* Flush last word in FIFO */
-                       templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
-                       tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
-                       pr_debug("FT1000_REG_SUP_STAT = 0x%x\n", tempword);
-                       tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR);
-                       pr_debug("FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
+                       return;
                }
-               if (DrvErrNum)
-                       pcmcia->PktIntfErr++;
+               tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
+       } while ((tempword & 0x03) != 0x03);
+       if (info->AsicID == ELECTRABUZZ_ID) {
+               i++;
+               pr_debug("Flushing FIFO complete = %x\n", tempword);
+               /* Flush last word in FIFO. */
+               tempword = ft1000_read_reg(dev, FT1000_REG_DFIFO);
+               /* Update FIFO counter for DSP */
+               i = i * 2;
+               pr_debug("Flush Data byte count to dsp = %d\n", i);
+               info->fifo_cnt += i;
+               ft1000_write_dpram(dev, FT1000_FIFO_LEN,
+                                  info->fifo_cnt);
+       } else {
+               pr_debug("Flushing FIFO complete = %x\n", tempword);
+               /* Flush last word in FIFO */
+               templong = inl(dev->base_addr + FT1000_REG_MAG_DFR);
+               tempword = inw(dev->base_addr + FT1000_REG_SUP_STAT);
+               pr_debug("FT1000_REG_SUP_STAT = 0x%x\n", tempword);
+               tempword = inw(dev->base_addr + FT1000_REG_MAG_DFSR);
+               pr_debug("FT1000_REG_MAG_DFSR = 0x%x\n", tempword);
        }
+       if (DrvErrNum)
+               pcmcia->PktIntfErr++;
 }
 
 /*---------------------------------------------------------------------------
@@ -1948,11 +1947,10 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
                                                ft1000_read_reg(dev,
                                                                FT1000_REG_MAG_DFSR);
                                }
-                               if (tempword & 0x1f) {
+                               if (tempword & 0x1f)
                                        ft1000_copy_up_pkt(dev);
-                               } else {
+                               else
                                        break;
-                               }
                                cnt++;
                        } while (cnt < MAX_RCV_LOOP);
 
@@ -1975,6 +1973,7 @@ void stop_ft1000_card(struct net_device *dev)
 {
        struct ft1000_info *info = netdev_priv(dev);
        struct prov_record *ptr;
+       struct prov_record *tmp;
        /* int cnt; */
 
        info->CardReady = 0;
@@ -1983,8 +1982,7 @@ void stop_ft1000_card(struct net_device *dev)
        ft1000_disable_interrupts(dev);
 
        /* Make sure we free any memory reserve for provisioning */
-       while (list_empty(&info->prov_list) == 0) {
-               ptr = list_entry(info->prov_list.next, struct prov_record, list);
+       list_for_each_entry_safe(ptr, tmp, &info->prov_list, list) {
                list_del(&ptr->list);
                kfree(ptr->pprov_data);
                kfree(ptr);
@@ -2008,6 +2006,7 @@ static void ft1000_get_drvinfo(struct net_device *dev,
                               struct ethtool_drvinfo *info)
 {
        struct ft1000_info *ft_info;
+
        ft_info = netdev_priv(dev);
 
        strlcpy(info->driver, "ft1000", sizeof(info->driver));
index c8d2782299403349a22f8be34cbe54178712f5b5..2d758fb26eac3c818f5e6adb91f08ec9171a7487 100644 (file)
@@ -190,7 +190,7 @@ int ft1000_create_dev(struct ft1000_usb *dev)
        tmp->dent = dir;
        tmp->file = file;
        tmp->int_number = dev->CardNumber;
-       list_add(&(tmp->list), &(dev->nodes.list));
+       list_add(&tmp->list, &dev->nodes.list);
 
        pr_debug("registered debugfs directory \"%s\"\n", dev->DeviceName);
 
@@ -301,7 +301,7 @@ static int ft1000_open(struct inode *inode, struct file *file)
        struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private;
        int i, num;
 
-       num = (MINOR(inode->i_rdev) & 0xf);
+       num = MINOR(inode->i_rdev) & 0xf;
        pr_debug("minor number=%d\n", num);
 
        info = file->private_data = netdev_priv(dev->net);
@@ -317,9 +317,8 @@ static int ft1000_open(struct inode *inode, struct file *file)
 
        /* Search for available application info block */
        for (i = 0; i < MAX_NUM_APP; i++) {
-               if ((dev->app_info[i].fileobject == NULL)) {
+               if ((dev->app_info[i].fileobject == NULL))
                        break;
-               }
        }
 
        /* Fail due to lack of application info block */
@@ -478,14 +477,14 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                /* Connect Message */
                pr_debug("IOCTL_FT1000_CONNECT\n");
                ConnectionMsg[79] = 0xfc;
-               result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
+               result = card_send_command(ft1000dev, ConnectionMsg, 0x4c);
 
                break;
        case IOCTL_DISCONNECT:
                /* Disconnect Message */
                pr_debug("IOCTL_FT1000_DISCONNECT\n");
                ConnectionMsg[79] = 0xfd;
-               result = card_send_command(ft1000dev, (unsigned short *)ConnectionMsg, 0x4c);
+               result = card_send_command(ft1000dev, ConnectionMsg, 0x4c);
                break;
        case IOCTL_GET_DSP_STAT_CMD:
                /* pr_debug("IOCTL_FT1000_GET_DSP_STAT\n"); */
@@ -545,7 +544,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                if (ft1000dev->fProvComplete == 0)
                        return -EACCES;
 
-               ft1000dev->fAppMsgPend = 1;
+               ft1000dev->fAppMsgPend = true;
 
                if (info->CardReady) {
 
@@ -575,9 +574,8 @@ 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 (ft1000dev->app_info[i].fileobject == &file->f_owner) {
+                                       if (ft1000dev->app_info[i].fileobject == &file->f_owner)
                                                break;
-                                       }
                                }
                                if (i == MAX_NUM_APP) {
                                        pr_debug("No matching application fileobject\n");
@@ -629,9 +627,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                                                pmsg = (u16 *)&dpram_data->pseudohdr;
                                                ppseudo_hdr = (struct pseudo_hdr *)pmsg;
                                                total_len = msgsz+2;
-                                               if (total_len & 0x1) {
+                                               if (total_len & 0x1)
                                                        total_len++;
-                                               }
 
                                                /* Insert slow queue sequence number */
                                                ppseudo_hdr->seq_num = info->squeseqnum++;
@@ -645,7 +642,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                                                }
                                                pmsg++;
                                                ppseudo_hdr = (struct pseudo_hdr *)pmsg;
-                                               result = card_send_command(ft1000dev, (unsigned short *)dpram_data, total_len+2);
+                                               result = card_send_command(ft1000dev, dpram_data, total_len+2);
 
 
                                                ft1000dev->app_info[app_index].nTxMsg++;
@@ -722,7 +719,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
                result = -ENOTTY;
                break;
        }
-       ft1000dev->fAppMsgPend = 0;
+       ft1000dev->fAppMsgPend = false;
        return result;
 }
 
@@ -745,6 +742,7 @@ static int ft1000_release(struct inode *inode, struct file *file)
        struct ft1000_usb *ft1000dev;
        int i;
        struct dpram_blk *pdpram_blk;
+       struct dpram_blk *tmp;
 
        dev = file->private_data;
        info = netdev_priv(dev);
@@ -766,9 +764,8 @@ static int ft1000_release(struct inode *inode, struct file *file)
        if (i == MAX_NUM_APP)
                return 0;
 
-       while (list_empty(&ft1000dev->app_info[i].app_sqlist) == 0) {
+       list_for_each_entry_safe(pdpram_blk, tmp, &ft1000dev->app_info[i].app_sqlist, list) {
                pr_debug("Remove and free memory queue up on slow queue\n");
-               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);
        }
index e8126325877b4bc1616fcbedc10d40177b3523fe..5def347beb082df3bd442e9f8c9a47713c47feaf 100644 (file)
@@ -230,7 +230,7 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)
        while (loopcnt < 100) {
                if (ft1000dev->usbboot == 2) {
                        status = ft1000_read_dpram32(ft1000dev, 0,
-                                                    (u8 *)&(ft1000dev->tempbuf[0]), 64);
+                                                    (u8 *)&ft1000dev->tempbuf[0], 64);
                        for (temp = 0; temp < 16; temp++) {
                                pr_debug("tempbuf %d = 0x%x\n",
                                         temp, ft1000dev->tempbuf[temp]);
@@ -368,8 +368,8 @@ static u16 hdr_checksum(struct pseudo_hdr *pHdr)
        u16   chksum;
 
 
-       chksum = ((((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^
-                   usPtr[4]) ^ usPtr[5]) ^ usPtr[6]);
+       chksum = (((((usPtr[0] ^ usPtr[1]) ^ usPtr[2]) ^ usPtr[3]) ^
+                   usPtr[4]) ^ usPtr[5]) ^ usPtr[6];
 
        return chksum;
 }
@@ -538,7 +538,7 @@ static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile,
                          usb_sndbulkpipe(ft1000dev->dev,
                                          ft1000dev->bulk_out_endpointAddr),
                          ft1000dev->tx_buf, byte_length, usb_dnld_complete,
-                         (void *)ft1000dev);
+                         ft1000dev);
 
        usb_submit_urb(ft1000dev->tx_urb, GFP_ATOMIC);
 
@@ -704,7 +704,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                case REQUEST_CODE_SEGMENT:
                                        status = request_code_segment(ft1000dev,
                                                                      &s_file, &c_file,
-                                                                     (const u8 *)boot_end,
+                                                                     boot_end,
                                                                      true);
                                        break;
                                default:
@@ -799,7 +799,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
 
                                        status = request_code_segment(ft1000dev,
                                                                      &s_file, &c_file,
-                                                                     (const u8 *)code_end,
+                                                                     code_end,
                                                                      false);
 
                                        break;
@@ -971,11 +971,11 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
 
                                /* Get buffer for provisioning data */
                                pbuffer =
-                                       kmalloc((pseudo_header_len +
-                                                sizeof(struct pseudo_hdr)),
+                                       kmalloc(pseudo_header_len +
+                                                sizeof(struct pseudo_hdr),
                                                GFP_ATOMIC);
                                if (pbuffer) {
-                                       memcpy(pbuffer, (void *)c_file,
+                                       memcpy(pbuffer, c_file,
                                               (u32) (pseudo_header_len +
                                                      sizeof(struct
                                                             pseudo_hdr)));
index f0ac438384617f81b9d0d067ef64a74b03808f38..e6fb066e0dd23c77acde3c677753a26a7763c13c 100644 (file)
@@ -339,7 +339,7 @@ int card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,
        commandbuf = kmalloc(size + 2, GFP_KERNEL);
        if (!commandbuf)
                return -ENOMEM;
-       memcpy((void *)commandbuf + 2, (void *)ptempbuffer, size);
+       memcpy((void *)commandbuf + 2, ptempbuffer, size);
 
        if (temp & 0x0100)
                usleep_range(900, 1100);
@@ -429,7 +429,7 @@ static void ft1000_reset_asic(struct net_device *dev)
        /* Let's use the register provided by the Magnemite ASIC to reset the
         * ASIC and DSP.
         */
-       ft1000_write_register(ft1000dev, (DSP_RESET_BIT | ASIC_RESET_BIT),
+       ft1000_write_register(ft1000dev, DSP_RESET_BIT | ASIC_RESET_BIT,
                              FT1000_REG_RESET);
 
        mdelay(1);
@@ -451,16 +451,15 @@ static int ft1000_reset_card(struct net_device *dev)
        struct ft1000_usb *ft1000dev = info->priv;
        u16 tempword;
        struct prov_record *ptr;
+       struct prov_record *tmp;
 
        ft1000dev->fCondResetPend = true;
        info->CardReady = 0;
        ft1000dev->fProvComplete = false;
 
        /* Make sure we free any memory reserve for provisioning */
-       while (list_empty(&info->prov_list) == 0) {
+       list_for_each_entry_safe(ptr, tmp, &info->prov_list, list) {
                pr_debug("deleting provisioning record\n");
-               ptr =
-                       list_entry(info->prov_list.next, struct prov_record, list);
                list_del(&ptr->list);
                kfree(ptr->pprov_data);
                kfree(ptr);
@@ -542,7 +541,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len)
                hdr.portdest ^ hdr.portsrc ^ hdr.sh_str_id ^ hdr.control;
 
        memcpy(&pFt1000Dev->tx_buf[0], &hdr, sizeof(hdr));
-       memcpy(&(pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)]), packet, len);
+       memcpy(&pFt1000Dev->tx_buf[sizeof(struct pseudo_hdr)], packet, len);
 
        netif_stop_queue(netdev);
 
@@ -551,7 +550,7 @@ static int ft1000_copy_down_pkt(struct net_device *netdev, u8 *packet, u16 len)
                          usb_sndbulkpipe(pFt1000Dev->dev,
                                          pFt1000Dev->bulk_out_endpointAddr),
                          pFt1000Dev->tx_buf, count,
-                         ft1000_usb_transmit_complete, (void *)pFt1000Dev);
+                         ft1000_usb_transmit_complete, pFt1000Dev);
 
        t = (u8 *)pFt1000Dev->tx_urb->transfer_buffer;
 
@@ -606,7 +605,7 @@ static int ft1000_start_xmit(struct sk_buff *skb, struct net_device *dev)
                goto err;
        }
 
-       ft1000_copy_down_pkt(dev, (pdata + ENET_HEADER_SIZE - 2),
+       ft1000_copy_down_pkt(dev, pdata + ENET_HEADER_SIZE - 2,
                             skb->len - ENET_HEADER_SIZE + 2);
 
 err:
@@ -1558,19 +1557,19 @@ int ft1000_poll(void *dev_id)
                                /* Reset ASIC and DSP */
                                status = ft1000_read_dpram16(dev,
                                                             FT1000_MAG_DSP_TIMER0,
-                                                            (u8 *)&(info->DSP_TIME[0]),
+                                                            (u8 *)&info->DSP_TIME[0],
                                                             FT1000_MAG_DSP_TIMER0_INDX);
                                status = ft1000_read_dpram16(dev,
                                                             FT1000_MAG_DSP_TIMER1,
-                                                            (u8 *)&(info->DSP_TIME[1]),
+                                                            (u8 *)&info->DSP_TIME[1],
                                                             FT1000_MAG_DSP_TIMER1_INDX);
                                status = ft1000_read_dpram16(dev,
                                                             FT1000_MAG_DSP_TIMER2,
-                                                            (u8 *)&(info->DSP_TIME[2]),
+                                                            (u8 *)&info->DSP_TIME[2],
                                                             FT1000_MAG_DSP_TIMER2_INDX);
                                status = ft1000_read_dpram16(dev,
                                                             FT1000_MAG_DSP_TIMER3,
-                                                            (u8 *)&(info->DSP_TIME[3]),
+                                                            (u8 *)&info->DSP_TIME[3],
                                                             FT1000_MAG_DSP_TIMER3_INDX);
                                info->CardReady = 0;
                                info->DrvErrNum = DSP_CONDRESET_INFO;
index a6b55f42c07c177ee29aa69fd2a09cea52c3a01d..3b303b6b1b272da247f06533d3242c9e59ef5115 100644 (file)
@@ -136,7 +136,7 @@ static int ft1000_probe(struct usb_interface *interface,
 
        ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev);
        if (ret < 0) {
-               pr_err("Error request_firmware()\n");
+               dev_err(interface->usb_dev, "Error request_firmware()\n");
                goto err_fw;
        }
 
@@ -164,7 +164,8 @@ static int ft1000_probe(struct usb_interface *interface,
        pr_debug("pft1000info=%p\n", pft1000info);
        ret = dsp_reload(ft1000dev);
        if (ret) {
-               pr_err("Problem with DSP image loading\n");
+               dev_err(interface->usb_dev,
+                       "Problem with DSP image loading\n");
                goto err_load;
        }
 
index 73deae3cd9ebf6178c73c6309aa7ca125e0d2184..fdb2418c5f888b070111ab38a98f7898e9b060e6 100644 (file)
@@ -1186,7 +1186,7 @@ static void fwtty_unthrottle(struct tty_struct *tty)
 {
        struct fwtty_port *port = tty->driver_data;
 
-       fwtty_dbg(port, "CRTSCTS: %d\n", (C_CRTSCTS(tty) != 0));
+       fwtty_dbg(port, "CRTSCTS: %d\n", C_CRTSCTS(tty) != 0);
 
        fwtty_profile_fifo(port, port->stats.unthrottle);
 
index 7c4a77bb94aa991913e35f1f49f54aa425a60af8..a8d2cffb411cb8bf7460dfb2b6537343ba10e37c 100644 (file)
@@ -889,7 +889,7 @@ int register_lte_device(struct phy_dev *phy_dev,
                /* Allocate netdev */
                net = alloc_netdev(sizeof(struct nic), pdn_dev_name,
                                   NET_NAME_UNKNOWN, ether_setup);
-               if (net == NULL) {
+               if (!net) {
                        pr_err("alloc_netdev failed\n");
                        ret = -ENOMEM;
                        goto err;
index d1ab996b3305af1a9c4d45a2343184e3bafe9503..8199b0a697bb5f8b672aabad8f9685c8c51a8f5e 100644 (file)
@@ -270,7 +270,7 @@ static void gdm_mux_rcv_complete(struct urb *urb)
 
        if (urb->status) {
                if (mux_dev->usb_state == PM_NORMAL)
-                       pr_err("%s: urb status error %d\n",
+                       dev_err(&urb->dev->dev, "%s: urb status error %d\n",
                               __func__, urb->status);
                put_rx_struct(rx, r);
        } else {
@@ -342,7 +342,7 @@ static void gdm_mux_send_complete(struct urb *urb)
        struct mux_tx *t = urb->context;
 
        if (urb->status == -ECONNRESET) {
-               pr_info("CONNRESET\n");
+               dev_info(&urb->dev->dev, "CONNRESET\n");
                free_mux_tx(t);
                return;
        }
@@ -608,7 +608,7 @@ static int gdm_mux_suspend(struct usb_interface *intf, pm_message_t pm_msg)
        rx = &mux_dev->rx;
 
        if (mux_dev->usb_state != PM_NORMAL) {
-               pr_err("usb suspend - invalid state\n");
+               dev_err(intf->usb_dev, "usb suspend - invalid state\n");
                return -1;
        }
 
@@ -637,7 +637,7 @@ static int gdm_mux_resume(struct usb_interface *intf)
        mux_dev = tty_dev->priv_dev;
 
        if (mux_dev->usb_state != PM_SUSPEND) {
-               pr_err("usb resume - invalid state\n");
+               dev_err(intf->usb_dev, "usb resume - invalid state\n");
                return -1;
        }
 
index d2a3b350ba6d10ca77728c7cb5eb8c792f6612e2..ed1a12f504e2183e459bc3e43e171255caaf9c38 100644 (file)
@@ -480,7 +480,7 @@ static void gdm_usb_rcv_complete(struct urb *urb)
                spin_unlock_irqrestore(&rx->to_host_lock, flags);
        } else {
                if (urb->status && udev->usb_state == PM_NORMAL)
-                       pr_err("%s: urb status error %d\n",
+                       dev_err(&urb->dev->dev, "%s: urb status error %d\n",
                               __func__, urb->status);
 
                put_rx_struct(rx, r);
@@ -557,7 +557,7 @@ static void gdm_usb_send_complete(struct urb *urb)
        unsigned long flags;
 
        if (urb->status == -ECONNRESET) {
-               pr_info("CONNRESET\n");
+               dev_info(&urb->dev->dev, "CONNRESET\n");
                return;
        }
 
@@ -590,7 +590,8 @@ static int send_tx_packet(struct usb_device *usbdev, struct usb_tx *t, u32 len)
        ret = usb_submit_urb(t->urb, GFP_ATOMIC);
 
        if (ret)
-               pr_err("usb_submit_urb failed: %d\n", ret);
+               dev_err(&usbdev->dev, "usb_submit_urb failed: %d\n",
+                       ret);
 
        usb_mark_last_busy(usbdev);
 
@@ -848,7 +849,7 @@ static int gdm_usb_probe(struct usb_interface *intf,
        udev->usbdev = usbdev;
        ret = init_usb(udev);
        if (ret < 0) {
-               pr_err("init_usb func failed\n");
+               dev_err(intf->usb_dev, "init_usb func failed\n");
                goto err_init_usb;
        }
        udev->intf = intf;
@@ -867,7 +868,7 @@ static int gdm_usb_probe(struct usb_interface *intf,
 
        ret = request_mac_address(udev);
        if (ret < 0) {
-               pr_err("request Mac address failed\n");
+               dev_err(intf->usb_dev, "request Mac address failed\n");
                goto err_mac_address;
        }
 
@@ -928,7 +929,7 @@ static int gdm_usb_suspend(struct usb_interface *intf, pm_message_t pm_msg)
        udev = phy_dev->priv_dev;
        rx = &udev->rx;
        if (udev->usb_state != PM_NORMAL) {
-               pr_err("usb suspend - invalid state\n");
+               dev_err(intf->usb_dev, "usb suspend - invalid state\n");
                return -1;
        }
 
@@ -961,7 +962,7 @@ static int gdm_usb_resume(struct usb_interface *intf)
        rx = &udev->rx;
 
        if (udev->usb_state != PM_SUSPEND) {
-               pr_err("usb resume - invalid state\n");
+               dev_err(intf->usb_dev, "usb resume - invalid state\n");
                return -1;
        }
        udev->usb_state = PM_NORMAL;
index af24c57b82322a8cac7a1712125fe40a8a0ea51e..96bf2bf87ff4b657a8ba9770e553543a74878378 100644 (file)
@@ -54,8 +54,7 @@ static void *alloc_qos_entry(void)
        }
        spin_unlock_irqrestore(&qos_free_list.lock, flags);
 
-       entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
-       return entry;
+       return kmalloc(sizeof(*entry), GFP_ATOMIC);
 }
 
 static void free_qos_entry(void *entry)
index 7a0a0f2214180dc2da684e3df31f6ba480bbc346..a5fd0794842ee0a9af21577a62b6b2f5ddc83e86 100644 (file)
@@ -223,8 +223,7 @@ static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len)
                if (ret < 0) {
                        if (ret != -ENOMEDIUM)
                                dev_err(&func->dev,
-                                       "gdmwms: %s error: ret = %d\n",
-                                       __func__, ret);
+                                       "gdmwms:  error: ret = %d\n", ret);
                        goto end_io;
                }
        }
@@ -237,8 +236,7 @@ static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len)
                if (ret < 0) {
                        if (ret != -ENOMEDIUM)
                                dev_err(&func->dev,
-                                       "gdmwms: %s error: ret = %d\n",
-                                       __func__, ret);
+                                       "gdmwms:  error: ret = %d\n", ret);
                        goto end_io;
                }
        }
index 9cab54bfa6f4d6f21f42dd257743d546d6d5baa4..61d168e820110d6ddacdad0481a7672f3a831d65 100644 (file)
@@ -129,11 +129,11 @@ static void __gdm_wimax_event_send(struct work_struct *work)
        int idx;
        unsigned long flags;
        struct evt_entry *e;
+       struct evt_entry *tmp;
 
        spin_lock_irqsave(&wm_event.evt_lock, flags);
 
-       while (!list_empty(&wm_event.evtq)) {
-               e = list_entry(wm_event.evtq.next, struct evt_entry, list);
+       list_for_each_entry_safe(e, tmp, &wm_event.evtq, list) {
                spin_unlock_irqrestore(&wm_event.evt_lock, flags);
 
                if (sscanf(e->dev->name, "wm%d", &idx) == 1)
@@ -749,7 +749,7 @@ int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev)
        dev = alloc_netdev(sizeof(*nic), "wm%d", NET_NAME_UNKNOWN,
                           ether_setup);
 
-       if (dev == NULL) {
+       if (!dev) {
                pr_err("alloc_etherdev failed\n");
                return -ENOMEM;
        }
index f200359c44439d5cd4d00decdcd50afbf31d5dad..702ae04df91227603426e8d7a70e3ab45a8ec880 100644 (file)
@@ -40,12 +40,12 @@ struct goldfish_audio {
        spinlock_t lock;
        wait_queue_head_t wait;
 
-       char __iomem *buffer_virt;      /* combined buffer virtual address */
+       char *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 */
+       char *write_buffer1;            /* write buffer 1 virtual address */
+       char *write_buffer2;            /* write buffer 2 virtual address */
+       char *read_buffer;              /* read buffer virtual address */
        int buffer_status;
        int read_supported;         /* true if we have audio input support */
 };
@@ -125,8 +125,8 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf,
                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));
+               wait_event_interruptible(data->wait, data->buffer_status &
+                                        AUDIO_INT_READ_BUFFER_FULL);
 
                length = AUDIO_READ(data, AUDIO_READ_BUFFER_AVAILABLE);
 
@@ -147,16 +147,16 @@ static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf,
        struct goldfish_audio *data = fp->private_data;
        unsigned long irq_flags;
        ssize_t result = 0;
-       char __iomem *kbuf;
+       char *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 &
+               wait_event_interruptible(data->wait, data->buffer_status &
                                        (AUDIO_INT_WRITE_BUFFER_1_EMPTY |
-                                       AUDIO_INT_WRITE_BUFFER_2_EMPTY)));
+                                       AUDIO_INT_WRITE_BUFFER_2_EMPTY));
 
                if ((data->buffer_status & AUDIO_INT_WRITE_BUFFER_1_EMPTY) != 0)
                        kbuf = data->write_buffer1;
@@ -273,7 +273,7 @@ static int goldfish_audio_probe(struct platform_device *pdev)
        dma_addr_t buf_addr;
 
        data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
-       if (data == NULL)
+       if (!data)
                return -ENOMEM;
        spin_lock_init(&data->lock);
        init_waitqueue_head(&data->wait);
index d68f216a7e77f7c9e51079d628adb2f61d77bc09..213877a2c43039a7a999fb141462ed79159bd0e7 100644 (file)
@@ -330,7 +330,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev,
        mtd->priv = nand;
 
        name = devm_kzalloc(&pdev->dev, name_len + 1, GFP_KERNEL);
-       if (name == NULL)
+       if (!name)
                return -ENOMEM;
        mtd->name = name;
 
@@ -383,7 +383,7 @@ static int goldfish_nand_probe(struct platform_device *pdev)
                return -ENODEV;
 
        base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
-       if (base == NULL)
+       if (!base)
                return -ENOMEM;
 
        version = readl(base + NAND_VERSION);
@@ -399,7 +399,7 @@ static int goldfish_nand_probe(struct platform_device *pdev)
 
        nand = devm_kzalloc(&pdev->dev, sizeof(*nand) +
                                sizeof(struct mtd_info) * num_dev, GFP_KERNEL);
-       if (nand == NULL)
+       if (!nand)
                return -ENOMEM;
 
        mutex_init(&nand->lock);
index 6da72858d28c87c89ff9633f14aa3063819ce7c7..a3a10f9a2a2b684c33481a1e8582649041f6f23f 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/device.h>
 #include <linux/string.h>
index 7aa0339aea056f3ec723f4ef3baa63b80da21f4e..43e357eeeb672a5325538a1f0c25bf43c7dacaf0 100644 (file)
@@ -69,7 +69,8 @@ static ssize_t i2o_bus_store_scan(struct device *d,
        struct i2o_device *i2o_dev = to_i2o_device(d);
        int rc;
 
-       if ((rc = i2o_bus_scan(i2o_dev)))
+       rc = i2o_bus_scan(i2o_dev);
+       if (rc)
                osm_warn("bus scan failed %d\n", rc);
 
        return count;
index 519f52f9f68819ade9816ec6e89610fbe2adb826..45091ac66154b27c614443f4381f2a3d39d25f9d 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/namei.h>
 #include <linux/fs.h>
 
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #define OSM_NAME       "config-osm"
 #define OSM_VERSION    "1.323"
index 7a16114ed8ea39cf70c9dd8e241e5b8e8babf824..12b783b2a86c8f37afbf8618ddbea2b4bbfbffee 100644 (file)
@@ -5,7 +5,7 @@
 
 static void i2o_report_util_cmd(u8 cmd);
 static void i2o_report_exec_cmd(u8 cmd);
-static void i2o_report_fail_status(u8 req_status, u32 * msg);
+static void i2o_report_fail_status(u8 req_status, u32 *msg);
 static void i2o_report_common_status(u8 req_status);
 static void i2o_report_common_dsc(u16 detailed_status);
 
@@ -22,7 +22,7 @@ void i2o_report_status(const char *severity, const char *str,
        u16 detailed_status = msg[4] & 0xFFFF;
 
        if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
-               return;         // No status in this reply
+               return;         /* No status in this reply */
 
        printk("%s%s: ", severity, str);
 
@@ -54,6 +54,7 @@ void i2o_dump_message(struct i2o_message *m)
 #ifdef DEBUG
        u32 *msg = (u32 *) m;
        int i;
+
        printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
               msg[0] >> 16 & 0xffff, msg);
        for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
@@ -66,7 +67,7 @@ void i2o_dump_message(struct i2o_message *m)
  * Following fail status are common to all classes.
  * The preserved message must be handled in the reply handler.
  */
-static void i2o_report_fail_status(u8 req_status, u32 * msg)
+static void i2o_report_fail_status(u8 req_status, u32 *msg)
 {
        static char *FAIL_STATUS[] = {
                "0x80",         /* not used */
index 2af22553dd4e8fdbf7c4bde3bcceabb5ed23e44c..e47496cb0ac21864afcfcf9476a848a2ee292453 100644 (file)
@@ -565,10 +565,8 @@ int i2o_parm_table_get(struct i2o_device *dev, int oper, int group,
                size += 4 - size % 4;
 
        opblk = kmalloc(size, GFP_KERNEL);
-       if (opblk == NULL) {
-               printk(KERN_ERR "i2o: no memory for query buffer.\n");
+       if (opblk == NULL)
                return -ENOMEM;
-       }
 
        opblk[0] = 1;           /* operation count */
        opblk[1] = 0;           /* pad */
index 111c3edde035d5bee7ca8e5b659a126c06e87ff0..06119bb3eb5fb56d62afdb64e5503254433a0076 100644 (file)
@@ -102,8 +102,7 @@ int i2o_driver_register(struct i2o_driver *drv)
 
        for (i = 0; i2o_drivers[i]; i++)
                if (i >= i2o_max_drivers) {
-                       osm_err("too many drivers registered, increase "
-                               "max_drivers\n");
+                       osm_err("too many drivers registered, increase max_drivers\n");
                        spin_unlock_irqrestore(&i2o_drivers_lock, flags);
                        rc = -EFAULT;
                        goto out;
@@ -244,8 +243,8 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
        }
 
        if (unlikely(!drv->reply)) {
-               osm_debug("%s: Reply to driver %s, but no reply function"
-                         " defined!\n", c->name, drv->name);
+               osm_debug("%s: Reply to driver %s, but no reply function defined!\n",
+                       c->name, drv->name);
                return -EIO;
        }
 
index 16d857d5e65541738c1fecb9db03d5cd04084f67..dce16e425a6e5f9bb723832c14ce774d270afe21 100644 (file)
@@ -507,8 +507,8 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
         * to aid in debugging.
         *
         */
-       printk(KERN_WARNING "%s: Unsolicited message reply sent to core!"
-              "Message dumped to syslog\n", c->name);
+       printk(KERN_WARNING "%s: Unsolicited message reply sent to core! Message dumped to syslog\n",
+                       c->name);
        i2o_dump_message(msg);
 
        return -EFAULT;
index 0a13c64ce000b9884132eae097af5c343aa4d9d0..77847875c38be00f63d8ac9e8bf176055d0fc71c 100644 (file)
@@ -1028,7 +1028,7 @@ static int i2o_block_probe(struct device *dev)
        struct i2o_block_device *i2o_blk_dev;
        struct gendisk *gd;
        struct request_queue *queue;
-       static int unit = 0;
+       static int unit;
        int rc;
        u64 size;
        u32 blocksize;
index 04bd3b6de40188bebf7f083750ed547c38265ec2..cd7ca5eb18ff30e00dfaef9252c476ad966c0a5e 100644 (file)
@@ -34,8 +34,7 @@
 #include <linux/mutex.h>
 #include <linux/compat.h>
 #include <linux/slab.h>
-
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include "core.h"
 
@@ -65,7 +64,7 @@ struct i2o_cfg_info {
        struct i2o_cfg_info *next;
 };
 static struct i2o_cfg_info *open_files = NULL;
-static ulong i2o_cfg_info_id = 0;
+static ulong i2o_cfg_info_id;
 
 static int i2o_cfg_getiops(unsigned long arg)
 {
index ad84f3304f3cd3ea2b1863e87e360d06f8a77ced..780fee3224ead8beb1397c626d20de53955aeb87 100644 (file)
@@ -48,9 +48,9 @@
 #include <linux/errno.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
+#include <linux/uaccess.h>
 
 #include <asm/io.h>
-#include <asm/uaccess.h>
 #include <asm/byteorder.h>
 
 /* Structure used to define /proc entries */
@@ -85,9 +85,8 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
        switch (serialno[0]) {
        case I2O_SNFORMAT_BINARY:       /* Binary */
                seq_printf(seq, "0x");
-               for (i = 0; i < serialno[1]; i++) {
+               for (i = 0; i < serialno[1]; i++)
                        seq_printf(seq, "%02X", serialno[2 + i]);
-               }
                break;
 
        case I2O_SNFORMAT_ASCII:        /* ASCII */
@@ -101,9 +100,8 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
                        seq_printf(seq, "%s", &serialno[2]);
                } else {
                        /* print chars for specified length */
-                       for (i = 0; i < serialno[1]; i++) {
+                       for (i = 0; i < serialno[1]; i++)
                                seq_printf(seq, "%c", serialno[2 + i]);
-                       }
                }
                break;
 
@@ -266,16 +264,22 @@ static int i2o_report_query_status(struct seq_file *seq, int block_status,
 {
        switch (block_status) {
        case -ETIMEDOUT:
-               return seq_printf(seq, "Timeout reading group %s.\n", group);
+               seq_printf(seq, "Timeout reading group %s.\n", group);
+               break;
        case -ENOMEM:
-               return seq_printf(seq, "No free memory to read the table.\n");
+               seq_puts(seq, "No free memory to read the table.\n");
+               break;
        case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
-               return seq_printf(seq, "Group %s not supported.\n", group);
+               seq_printf(seq, "Group %s not supported.\n", group);
+               break;
        default:
-               return seq_printf(seq,
-                                 "Error reading group %s. BlockStatus 0x%02X\n",
-                                 group, -block_status);
+               seq_printf(seq,
+                          "Error reading group %s. BlockStatus 0x%02X\n",
+                          group, -block_status);
+               break;
        }
+
+       return 0;
 }
 
 static char *bus_strings[] = {
index 52334fc8b547002857c015380b50f1ecd612fc7d..23bdbe4aa480216845cf7d58f185799f4990aaf7 100644 (file)
@@ -1042,7 +1042,7 @@ static void i2o_iop_release(struct device *dev)
  */
 struct i2o_controller *i2o_iop_alloc(void)
 {
-       static int unit = 0;    /* 0 and 1 are NULL IOP and Local Host */
+       static int unit;        /* 0 and 1 are NULL IOP and Local Host */
        struct i2o_controller *c;
        char poolname[32];
 
@@ -1096,7 +1096,8 @@ int i2o_iop_add(struct i2o_controller *c)
 {
        int rc;
 
-       if ((rc = device_add(&c->device))) {
+       rc = device_add(&c->device);
+       if (rc) {
                osm_err("%s: could not add controller\n", c->name);
                goto iop_reset;
        }
@@ -1105,24 +1106,28 @@ int i2o_iop_add(struct i2o_controller *c)
        osm_info("%s: This may take a few minutes if there are many devices\n",
                 c->name);
 
-       if ((rc = i2o_iop_activate(c))) {
+       rc = i2o_iop_activate(c);
+       if (rc) {
                osm_err("%s: could not activate controller\n", c->name);
                goto device_del;
        }
 
        osm_debug("%s: building sys table...\n", c->name);
 
-       if ((rc = i2o_systab_build()))
+       rc = i2o_systab_build();
+       if (rc)
                goto device_del;
 
        osm_debug("%s: online controller...\n", c->name);
 
-       if ((rc = i2o_iop_online(c)))
+       rc = i2o_iop_online(c);
+       if (rc)
                goto device_del;
 
        osm_debug("%s: getting LCT...\n", c->name);
 
-       if ((rc = i2o_exec_lct_get(c)))
+       rc = i2o_exec_lct_get(c);
+       if (rc)
                goto device_del;
 
        list_add(&c->list, &i2o_controllers);
@@ -1192,13 +1197,16 @@ static int __init i2o_iop_init(void)
 
        printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
 
-       if ((rc = i2o_driver_init()))
+       rc = i2o_driver_init();
+       if (rc)
                goto exit;
 
-       if ((rc = i2o_exec_init()))
+       rc = i2o_exec_init();
+       if (rc)
                goto driver_exit;
 
-       if ((rc = i2o_pci_init()))
+       rc = i2o_pci_init();
+       if (rc)
                goto exec_exit;
 
        return 0;
index 8f9509d275a46f4b66d399d932d5a472a9639741..78b702c185371b464c4a884a9eeb1131b3ee61bc 100644 (file)
@@ -270,10 +270,9 @@ EXPORT_SYMBOL_GPL(i2o_dma_realloc);
 int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
                                 size_t size, int min_nr)
 {
-       pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
+       pool->name = kstrdup(name, GFP_KERNEL);
        if (!pool->name)
                goto exit;
-       strcpy(pool->name, name);
 
        pool->slab =
            kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
index b3b8a61dd4a6d7e25d2def976995b8dddf298205..49804c9cf74f23722cad7492f3099900e425dd63 100644 (file)
@@ -329,7 +329,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                return -ENODEV;
        }
 
-       if ((rc = pci_enable_device(pdev))) {
+       rc = pci_enable_device(pdev);
+       if (rc) {
                printk(KERN_WARNING "i2o: couldn't enable device %s\n",
                       pci_name(pdev));
                return rc;
@@ -410,7 +411,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 #endif
        }
 
-       if ((rc = i2o_pci_alloc(c))) {
+       rc = i2o_pci_alloc(c);
+       if (rc) {
                printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
                       "failed\n", c->name);
                goto free_controller;
@@ -422,7 +424,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                goto free_pci;
        }
 
-       if ((rc = i2o_iop_add(c)))
+       rc = i2o_iop_add(c);
+       if (rc)
                goto uninstall;
 
        if (i960)
index de4647e2495e9a645da8c96fb34718926422e803..59b250545d4c849dc1b112e0730446e98c5b4ccb 100644 (file)
@@ -72,7 +72,7 @@ void print2byte(int input, struct iio_channel_info *info)
         * Shift before conversion to avoid sign extension
         * of left aligned data
         */
-       input = input >> info->shift;
+       input >>= info->shift;
        if (info->is_signed) {
                int16_t val = input;
 
index 568eff06f803169474f3caebf99431efb0db30bb..bd6982c12d0def7c1fb0185aebb51228da0ec877 100644 (file)
@@ -6,6 +6,8 @@
  * under the terms of the GNU General Public License version 2 as published by
  * the Free Software Foundation.
  */
+#ifndef _IIO_UTILS_H
+#define _IIO_UTILS_H
 
 #include <string.h>
 #include <stdlib.h>
@@ -681,3 +683,5 @@ error_free:
        free(temp);
        return ret;
 }
+
+#endif /* _IIO_UTILS_H */
index d478f5130a0fb461ff039a72cb48a75f79e7beff..0396f24f455818af32d80f64e68e82726038787b 100644 (file)
@@ -28,16 +28,15 @@ static ssize_t adis16220_read_16bit(struct device *dev,
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct adis16220_state *st = iio_priv(indio_dev);
        ssize_t ret;
-       s16 val = 0;
+       u16 val;
 
        /* Take the iio_dev status lock */
        mutex_lock(&indio_dev->mlock);
-       ret = adis_read_reg_16(&st->adis, this_attr->address,
-                                       (u16 *)&val);
+       ret = adis_read_reg_16(&st->adis, this_attr->address, &val);
        mutex_unlock(&indio_dev->mlock);
        if (ret)
                return ret;
-       return sprintf(buf, "%d\n", val);
+       return sprintf(buf, "%u\n", val);
 }
 
 static ssize_t adis16220_write_16bit(struct device *dev,
index 3f46086eab3a30d86c464d2016255e7edb46f91c..e2f8affc4c15d420d7a324d2370f90c251a782cd 100644 (file)
@@ -46,7 +46,7 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
        if (val & ADIS16240_ERROR_ACTIVE)
                adis_check_status(st);
 
-       val = ((s16)(val << shift) >> shift);
+       val = (s16)(val << shift) >> shift;
        return sprintf(buf, "%d\n", val);
 }
 
index 1fd90090a633580dbc2dbbd1cd985ffc06d49f8e..e6101bbc7fbda9d768d54f6e6ab042caae7349e1 100644 (file)
@@ -118,7 +118,7 @@ static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
        int scan_count = bitmap_weight(indio_dev->active_scan_mask,
                                       indio_dev->masklength);
 
-       rx_array = kzalloc(4 * scan_count, GFP_KERNEL);
+       rx_array = kcalloc(4, scan_count, GFP_KERNEL);
        if (rx_array == NULL)
                return -ENOMEM;
        ret = lis3l02dq_read_all(indio_dev, rx_array);
index b284e5a6cac1d3d4b5e38a0127fde360ac516196..9c8a9587df7d6fa3e79163bff8a2b2dc18027b26 100644 (file)
@@ -38,6 +38,9 @@
  * Can probably alleviate this by reading the interrupt register on start, but
  * that is really just brushing the problem under the carpet.
  */
+#ifndef _SCA3000
+#define _SCA3000
+
 #define SCA3000_WRITE_REG(a) (((a) << 2) | 0x02)
 #define SCA3000_READ_REG(a) ((a) << 2)
 
@@ -272,4 +275,4 @@ static inline void sca3000_ring_int_process(u8 val, void *ring)
 }
 
 #endif
-
+#endif /* _SCA3000 */
index 31fb2182c198267caff8af6554767d37146c4072..b614f272b5f4b1b40071d4ea5e11678453a1f431 100644 (file)
@@ -870,7 +870,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
                                            struct device_attribute *attr,
                                            char *buf)
 {
-       int ret, len;
+       int ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct sca3000_state *st = iio_priv(indio_dev);
        int val;
@@ -881,9 +881,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
        mutex_unlock(&st->lock);
        if (ret < 0)
                return ret;
-       len = sprintf(buf, "%d\n",
-                     !!(val & SCA3000_FREE_FALL_DETECT));
-       return len;
+       return sprintf(buf, "%d\n", !!(val & SCA3000_FREE_FALL_DETECT));
 }
 
 /**
index 4d4870787eede59fd6a73d23ba4ca29df48bbe2e..e7d45ee2fac6cb24748e1abbd9f3971b7624f4b8 100644 (file)
@@ -547,8 +547,9 @@ static int ad7280_attr_init(struct ad7280_state *st)
 {
        int dev, ch, cnt;
 
-       st->iio_attr = kzalloc(sizeof(*st->iio_attr) * (st->slave_num + 1) *
-                               AD7280A_CELLS_PER_DEV * 2, GFP_KERNEL);
+       st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) *
+                              (st->slave_num + 1) * AD7280A_CELLS_PER_DEV,
+                              GFP_KERNEL);
        if (st->iio_attr == NULL)
                return -ENOMEM;
 
index cf68159a584815aef3afdb73d24a7680ff3f8935..a861fe0149b1b3f8e706acece201d760942ba71f 100644 (file)
@@ -24,8 +24,8 @@
 
 static unsigned long ad9832_calc_freqreg(unsigned long mclk, unsigned long fout)
 {
-       unsigned long long freqreg = (u64) fout *
-                                    (u64) ((u64) 1L << AD9832_FREQ_BITS);
+       unsigned long long freqreg = (u64)fout *
+                                    (u64)((u64)1L << AD9832_FREQ_BITS);
        do_div(freqreg, mclk);
        return freqreg;
 }
@@ -59,7 +59,7 @@ static int ad9832_write_frequency(struct ad9832_state *st,
 static int ad9832_write_phase(struct ad9832_state *st,
                              unsigned long addr, unsigned long phase)
 {
-       if (phase > (1 << AD9832_PHASE_BITS))
+       if (phase > BIT(AD9832_PHASE_BITS))
                return -EINVAL;
 
        st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
@@ -86,7 +86,7 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr,
                goto error_ret;
 
        mutex_lock(&indio_dev->mlock);
-       switch ((u32) this_attr->address) {
+       switch ((u32)this_attr->address) {
        case AD9832_FREQ0HM:
        case AD9832_FREQ1HM:
                ret = ad9832_write_frequency(st, this_attr->address, val);
@@ -220,7 +220,7 @@ static int ad9832_probe(struct spi_device *spi)
        }
 
        indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-       if (indio_dev == NULL) {
+       if (!indio_dev) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
index 386f4dc8c9a11bb9b7043019b8c3454b41fd64c3..d32323b46be68f70888de6de1852c1e15eaa387c 100644 (file)
 #define AD9832_CMD_SYNCSELSRC  0x8
 #define AD9832_CMD_SLEEPRESCLR 0xC
 
-#define AD9832_FREQ            (1 << 11)
+#define AD9832_FREQ            BIT(11)
 #define AD9832_PHASE(x)                (((x) & 3) << 9)
-#define AD9832_SYNC            (1 << 13)
-#define AD9832_SELSRC          (1 << 12)
-#define AD9832_SLEEP           (1 << 13)
-#define AD9832_RESET           (1 << 12)
-#define AD9832_CLR             (1 << 11)
+#define AD9832_SYNC            BIT(13)
+#define AD9832_SELSRC          BIT(12)
+#define AD9832_SLEEP           BIT(13)
+#define AD9832_RESET           BIT(12)
+#define AD9832_CLR             BIT(11)
 #define CMD_SHIFT              12
 #define ADD_SHIFT              8
 #define AD9832_FREQ_BITS       32
index 5c803191c2cea9a4ed9567d7e0799d7738b1884b..d02bb44fb8fc1bbec82882bf7a4910bc1b7f94c7 100644 (file)
@@ -27,7 +27,7 @@
 
 static unsigned int ad9834_calc_freqreg(unsigned long mclk, unsigned long fout)
 {
-       unsigned long long freqreg = (u64) fout * (u64) (1 << AD9834_FREQ_BITS);
+       unsigned long long freqreg = (u64)fout * (u64)BIT(AD9834_FREQ_BITS);
 
        do_div(freqreg, mclk);
        return freqreg;
@@ -53,9 +53,9 @@ static int ad9834_write_frequency(struct ad9834_state *st,
 }
 
 static int ad9834_write_phase(struct ad9834_state *st,
-                                 unsigned long addr, unsigned long phase)
+                             unsigned long addr, unsigned long phase)
 {
-       if (phase > (1 << AD9834_PHASE_BITS))
+       if (phase > BIT(AD9834_PHASE_BITS))
                return -EINVAL;
        st->data = cpu_to_be16(addr | phase);
 
@@ -63,9 +63,9 @@ static int ad9834_write_phase(struct ad9834_state *st,
 }
 
 static ssize_t ad9834_write(struct device *dev,
-               struct device_attribute *attr,
-               const char *buf,
-               size_t len)
+                           struct device_attribute *attr,
+                           const char *buf,
+                           size_t len)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ad9834_state *st = iio_priv(indio_dev);
@@ -78,7 +78,7 @@ static ssize_t ad9834_write(struct device *dev,
                goto error_ret;
 
        mutex_lock(&indio_dev->mlock);
-       switch ((u32) this_attr->address) {
+       switch ((u32)this_attr->address) {
        case AD9834_REG_FREQ0:
        case AD9834_REG_FREQ1:
                ret = ad9834_write_frequency(st, this_attr->address, val);
@@ -111,9 +111,9 @@ static ssize_t ad9834_write(struct device *dev,
                break;
        case AD9834_FSEL:
        case AD9834_PSEL:
-               if (val == 0)
+               if (val == 0) {
                        st->control &= ~(this_attr->address | AD9834_PIN_SW);
-               else if (val == 1) {
+               else if (val == 1) {
                        st->control |= this_attr->address;
                        st->control &= ~AD9834_PIN_SW;
                } else {
@@ -142,9 +142,9 @@ error_ret:
 }
 
 static ssize_t ad9834_store_wavetype(struct device *dev,
-                                struct device_attribute *attr,
-                                const char *buf,
-                                size_t len)
+                                    struct device_attribute *attr,
+                                    const char *buf,
+                                    size_t len)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ad9834_state *st = iio_priv(indio_dev);
@@ -154,7 +154,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       switch ((u32) this_attr->address) {
+       switch ((u32)this_attr->address) {
        case 0:
                if (sysfs_streq(buf, "sine")) {
                        st->control &= ~AD9834_MODE;
@@ -179,7 +179,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
                break;
        case 1:
                if (sysfs_streq(buf, "square") &&
-                       !(st->control & AD9834_MODE)) {
+                   !(st->control & AD9834_MODE)) {
                        st->control &= ~AD9834_MODE;
                        st->control |= AD9834_OPBITEN;
                } else {
@@ -200,9 +200,10 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
        return ret ? ret : len;
 }
 
-static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
-                                               struct device_attribute *attr,
-                                               char *buf)
+static
+ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
+                                           struct device_attribute *attr,
+                                           char *buf)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ad9834_state *st = iio_priv(indio_dev);
@@ -218,13 +219,13 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
        return sprintf(buf, "%s\n", str);
 }
 
-
 static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, S_IRUGO,
                       ad9834_show_out0_wavetype_available, NULL, 0);
 
-static ssize_t ad9834_show_out1_wavetype_available(struct device *dev,
-                                               struct device_attribute *attr,
-                                               char *buf)
+static
+ssize_t ad9834_show_out1_wavetype_available(struct device *dev,
+                                           struct device_attribute *attr,
+                                           char *buf)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ad9834_state *st = iio_priv(indio_dev);
@@ -336,7 +337,7 @@ static int ad9834_probe(struct spi_device *spi)
        }
 
        indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-       if (indio_dev == NULL) {
+       if (!indio_dev) {
                ret = -ENOMEM;
                goto error_disable_reg;
        }
index 8ca6e52bae6ba67fa7dd7b65b110dc1f57029221..40fdd5da7bd0038fc1ff3d43676d377798084283 100644 (file)
 
 /* Registers */
 
-#define AD9834_REG_CMD         (0 << 14)
-#define AD9834_REG_FREQ0       (1 << 14)
-#define AD9834_REG_FREQ1       (2 << 14)
-#define AD9834_REG_PHASE0      (6 << 13)
-#define AD9834_REG_PHASE1      (7 << 13)
+#define AD9834_REG_CMD         0
+#define AD9834_REG_FREQ0       BIT(14)
+#define AD9834_REG_FREQ1       BIT(15)
+#define AD9834_REG_PHASE0      (BIT(15) | BIT(14))
+#define AD9834_REG_PHASE1      (BIT(15) | BIT(14) | BIT(13))
 
 /* Command Control Bits */
 
-#define AD9834_B28             (1 << 13)
-#define AD9834_HLB             (1 << 12)
-#define AD9834_FSEL            (1 << 11)
-#define AD9834_PSEL            (1 << 10)
-#define AD9834_PIN_SW          (1 << 9)
-#define AD9834_RESET           (1 << 8)
-#define AD9834_SLEEP1          (1 << 7)
-#define AD9834_SLEEP12         (1 << 6)
-#define AD9834_OPBITEN         (1 << 5)
-#define AD9834_SIGN_PIB                (1 << 4)
-#define AD9834_DIV2            (1 << 3)
-#define AD9834_MODE            (1 << 1)
+#define AD9834_B28             BIT(13)
+#define AD9834_HLB             BIT(12)
+#define AD9834_FSEL            BIT(11)
+#define AD9834_PSEL            BIT(10)
+#define AD9834_PIN_SW          BIT(9)
+#define AD9834_RESET           BIT(8)
+#define AD9834_SLEEP1          BIT(7)
+#define AD9834_SLEEP12         BIT(6)
+#define AD9834_OPBITEN         BIT(5)
+#define AD9834_SIGN_PIB                BIT(4)
+#define AD9834_DIV2            BIT(3)
+#define AD9834_MODE            BIT(1)
 
 #define AD9834_FREQ_BITS       28
 #define AD9834_PHASE_BITS      12
 
-#define RES_MASK(bits) ((1 << (bits)) - 1)
+#define RES_MASK(bits) (BIT(bits) - 1)
 
 /**
  * struct ad9834_state - driver instance specific data
@@ -69,7 +69,6 @@ struct ad9834_state {
        __be16                          freq_data[2];
 };
 
-
 /*
  * TODO: struct ad7887_platform_data needs to go into include/linux/iio
  */
index 611e2b0cfc4cde3614080f07ff8018fd2dbb702f..fe53e7324c9458fb64d69b85b80e0d18b85474c0 100644 (file)
@@ -5,6 +5,8 @@
  *
  * Licensed under the GPL-2 or later.
  */
+#ifndef IIO_DDS_H_
+#define IIO_DDS_H_
 
 /**
  * /sys/bus/iio/devices/.../out_altvoltageX_frequencyY
 #define IIO_CONST_ATTR_OUT_WAVETYPES_AVAILABLE(_channel, _output, _modes)\
        IIO_CONST_ATTR(                                                 \
        out_altvoltage##_channel##_out##_output##_wavetype_available, _modes)
+
+#endif /* IIO_DDS_H_ */
index e4520213f627fe431597817ac8c4099bde40f1c4..8341dce82f10b2645d8cf3d1c5356c50a3d83067 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
index 6440e3b293ca53201714b57ea590a5f397368abf..e5b2fdc2334b71792355b718b209606be04c73f6 100644 (file)
@@ -441,15 +441,15 @@ static int isl29028_chip_init(struct isl29028_chip *chip)
 
        ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling);
        if (ret < 0) {
-               dev_err(chip->dev, "%s(): setting the proximity, err = %d\n",
-                       __func__, ret);
+               dev_err(chip->dev, "setting the proximity, err = %d\n",
+                       ret);
                return ret;
        }
 
        ret = isl29028_set_als_scale(chip, chip->lux_scale);
        if (ret < 0)
-               dev_err(chip->dev, "%s(): setting als scale failed, err = %d\n",
-                       __func__, ret);
+               dev_err(chip->dev,
+                       "setting als scale failed, err = %d\n", ret);
        return ret;
 }
 
index 8afae8e33d56e0fcd32f81d862ad5a60ba56870d..b5e1b8b0a6f0db24d7a5da3f1e51d2dbc2cc50ce 100644 (file)
@@ -471,14 +471,12 @@ static int taos_chip_on(struct iio_dev *indio_dev)
 static int taos_chip_off(struct iio_dev *indio_dev)
 {
        struct tsl2583_chip *chip = iio_priv(indio_dev);
-       int ret;
 
        /* turn device off */
        chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
-       ret = i2c_smbus_write_byte_data(chip->client,
+       return i2c_smbus_write_byte_data(chip->client,
                                        TSL258X_CMD_REG | TSL258X_CNTRL,
                                        0x00);
-       return ret;
 }
 
 /* Sysfs Interface Functions */
index 4a5dc26fed4c2a20078a48061d45108e16db23b2..010e607dd8804fb1f74ef56fc8c3555cc66af22e 100644 (file)
@@ -301,8 +301,7 @@ tsl2x7x_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
        /* select register to write */
        ret = i2c_smbus_write_byte(client, (TSL2X7X_CMD_REG | reg));
        if (ret < 0) {
-               dev_err(&client->dev, "%s: failed to write register %x\n"
-                               , __func__, reg);
+               dev_err(&client->dev, "failed to write register %x\n", reg);
                return ret;
        }
 
@@ -311,8 +310,7 @@ tsl2x7x_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
        if (ret >= 0)
                *val = (u8)ret;
        else
-               dev_err(&client->dev, "%s: failed to read register %x\n"
-                                               , __func__, reg);
+               dev_err(&client->dev, "failed to read register %x\n", reg);
 
        return ret;
 }
@@ -377,7 +375,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
                        &buf[i]);
                if (ret < 0) {
                        dev_err(&chip->client->dev,
-                               "%s: failed to read. err=%x\n", __func__, ret);
+                               "failed to read. err=%x\n", ret);
                        goto out_unlock;
                }
        }
@@ -389,8 +387,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
                                TSL2X7X_CMD_ALS_INT_CLR));
        if (ret < 0) {
                dev_err(&chip->client->dev,
-               "%s: i2c_write_command failed - err = %d\n",
-                       __func__, ret);
+                       "i2c_write_command failed - err = %d\n", ret);
                goto out_unlock; /* have no data, so return failure */
        }
 
@@ -493,8 +490,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
        ret = tsl2x7x_i2c_read(chip->client,
                (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &status);
        if (ret < 0) {
-               dev_err(&chip->client->dev,
-               "%s: i2c err=%d\n", __func__, ret);
+               dev_err(&chip->client->dev, "i2c err=%d\n", ret);
                goto prox_poll_err;
        }
 
@@ -583,8 +579,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
                        (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
        if (ret < 0) {
                dev_err(&chip->client->dev,
-               "%s: failed to write CNTRL register, ret=%d\n",
-               __func__, ret);
+                       "failed to write CNTRL register, ret=%d\n", ret);
                return ret;
        }
 
@@ -600,8 +595,7 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
                        (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
        if (ret < 0) {
                dev_err(&chip->client->dev,
-                       "%s: failed to write ctrl reg: ret=%d\n",
-                       __func__, ret);
+                       "failed to write ctrl reg: ret=%d\n", ret);
                return ret;
        }
 
@@ -619,8 +613,8 @@ static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
                return lux_val;
        }
 
-       gain_trim_val =  (((chip->tsl2x7x_settings.als_cal_target)
-                       * chip->tsl2x7x_settings.als_gain_trim) / lux_val);
+       gain_trim_val =  ((chip->tsl2x7x_settings.als_cal_target)
+                       * chip->tsl2x7x_settings.als_gain_trim) / lux_val;
        if ((gain_trim_val < 250) || (gain_trim_val > 4000))
                return -ERANGE;
 
@@ -720,7 +714,7 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
                                TSL2X7X_CMD_REG + i, *dev_reg++);
                if (ret < 0) {
                        dev_err(&chip->client->dev,
-                       "%s: failed on write to reg %d.\n", __func__, i);
+                               "failed on write to reg %d.\n", i);
                        return ret;
                }
        }
@@ -871,8 +865,8 @@ static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
 
        if (chip->tsl2x7x_settings.prox_max_samples_cal > MAX_SAMPLES_CAL) {
                dev_err(&chip->client->dev,
-                       "%s: max prox samples cal is too big: %d\n",
-                       __func__, chip->tsl2x7x_settings.prox_max_samples_cal);
+                       "max prox samples cal is too big: %d\n",
+                       chip->tsl2x7x_settings.prox_max_samples_cal);
                chip->tsl2x7x_settings.prox_max_samples_cal = MAX_SAMPLES_CAL;
        }
 
@@ -1563,8 +1557,8 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
                TSL2X7X_CMD_PROXALS_INT_CLR);
        if (ret < 0)
                dev_err(&chip->client->dev,
-                       "%s: Failed to clear irq from event handler. err = %d\n",
-                       __func__, ret);
+                       "Failed to clear irq from event handler. err = %d\n",
+                       ret);
 
        return IRQ_HANDLED;
 }
@@ -1893,8 +1887,8 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
 
        ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
        if (ret < 0) {
-               dev_err(&clientp->dev, "%s: write to cmd reg failed. err = %d\n",
-                               __func__, ret);
+               dev_err(&clientp->dev, "write to cmd reg failed. err = %d\n",
+                       ret);
                return ret;
        }
 
index b784e3eb4591edec159129f709f5a72672bfe460..332a75c3a4fb6423ddb93acced54100070781b79 100644 (file)
@@ -10,7 +10,6 @@
  *
  * */
 
-
 #ifndef HMC5843_CORE_H
 #define HMC5843_CORE_H
 
@@ -41,7 +40,7 @@ struct hmc5843_data {
 };
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-               enum hmc5843_ids id);
+                        enum hmc5843_ids id);
 int hmc5843_common_remove(struct device *dev);
 
 int hmc5843_common_suspend(struct device *dev);
index fd171d8b38fbcc444f3e7118bb66b2d51bdf698c..0074af2750a5248a6b85fae522c1b940e9bb17dc 100644 (file)
@@ -122,7 +122,7 @@ static s32 hmc5843_set_mode(struct hmc5843_data *data, u8 operating_mode)
 
        mutex_lock(&data->lock);
        ret = regmap_update_bits(data->regmap, HMC5843_MODE_REG,
-                       HMC5843_MODE_MASK, operating_mode);
+                                HMC5843_MODE_MASK, operating_mode);
        mutex_unlock(&data->lock);
 
        return ret;
@@ -165,7 +165,7 @@ static int hmc5843_read_measurement(struct hmc5843_data *data,
                return ret;
        }
        ret = regmap_bulk_read(data->regmap, HMC5843_DATA_OUT_MSB_REGS,
-                       values, sizeof(values));
+                              values, sizeof(values));
        mutex_unlock(&data->lock);
        if (ret < 0)
                return ret;
@@ -198,15 +198,16 @@ static int hmc5843_set_meas_conf(struct hmc5843_data *data, u8 meas_conf)
 
        mutex_lock(&data->lock);
        ret = regmap_update_bits(data->regmap, HMC5843_CONFIG_REG_A,
-                       HMC5843_MEAS_CONF_MASK, meas_conf);
+                                HMC5843_MEAS_CONF_MASK, meas_conf);
        mutex_unlock(&data->lock);
 
        return ret;
 }
 
-static ssize_t hmc5843_show_measurement_configuration(struct device *dev,
-                                               struct device_attribute *attr,
-                                               char *buf)
+static
+ssize_t hmc5843_show_measurement_configuration(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf)
 {
        struct hmc5843_data *data = iio_priv(dev_to_iio_dev(dev));
        unsigned int val;
@@ -220,10 +221,11 @@ static ssize_t hmc5843_show_measurement_configuration(struct device *dev,
        return sprintf(buf, "%d\n", val);
 }
 
-static ssize_t hmc5843_set_measurement_configuration(struct device *dev,
-                                               struct device_attribute *attr,
-                                               const char *buf,
-                                               size_t count)
+static
+ssize_t hmc5843_set_measurement_configuration(struct device *dev,
+                                             struct device_attribute *attr,
+                                             const char *buf,
+                                             size_t count)
 {
        struct hmc5843_data *data = iio_priv(dev_to_iio_dev(dev));
        unsigned long meas_conf = 0;
@@ -246,8 +248,9 @@ static IIO_DEVICE_ATTR(meas_conf,
                        hmc5843_set_measurement_configuration,
                        0);
 
-static ssize_t hmc5843_show_samp_freq_avail(struct device *dev,
-                               struct device_attribute *attr, char *buf)
+static
+ssize_t hmc5843_show_samp_freq_avail(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
 {
        struct hmc5843_data *data = iio_priv(dev_to_iio_dev(dev));
        size_t len = 0;
@@ -272,20 +275,21 @@ static int hmc5843_set_samp_freq(struct hmc5843_data *data, u8 rate)
 
        mutex_lock(&data->lock);
        ret = regmap_update_bits(data->regmap, HMC5843_CONFIG_REG_A,
-                       HMC5843_RATE_MASK, rate << HMC5843_RATE_OFFSET);
+                                HMC5843_RATE_MASK,
+                                rate << HMC5843_RATE_OFFSET);
        mutex_unlock(&data->lock);
 
        return ret;
 }
 
 static int hmc5843_get_samp_freq_index(struct hmc5843_data *data,
-                                  int val, int val2)
+                                      int val, int val2)
 {
        int i;
 
        for (i = 0; i < data->variant->n_regval_to_samp_freq; i++)
                if (val == data->variant->regval_to_samp_freq[i][0] &&
-                       val2 == data->variant->regval_to_samp_freq[i][1])
+                   val2 == data->variant->regval_to_samp_freq[i][1])
                        return i;
 
        return -EINVAL;
@@ -297,15 +301,16 @@ static int hmc5843_set_range_gain(struct hmc5843_data *data, u8 range)
 
        mutex_lock(&data->lock);
        ret = regmap_update_bits(data->regmap, HMC5843_CONFIG_REG_B,
-                       HMC5843_RANGE_GAIN_MASK,
-                       range << HMC5843_RANGE_GAIN_OFFSET);
+                                HMC5843_RANGE_GAIN_MASK,
+                                range << HMC5843_RANGE_GAIN_OFFSET);
        mutex_unlock(&data->lock);
 
        return ret;
 }
 
 static ssize_t hmc5843_show_scale_avail(struct device *dev,
-                               struct device_attribute *attr, char *buf)
+                                       struct device_attribute *attr,
+                                       char *buf)
 {
        struct hmc5843_data *data = iio_priv(dev_to_iio_dev(dev));
 
@@ -396,7 +401,8 @@ static int hmc5843_write_raw(struct iio_dev *indio_dev,
 }
 
 static int hmc5843_write_raw_get_fmt(struct iio_dev *indio_dev,
-                              struct iio_chan_spec const *chan, long mask)
+                                    struct iio_chan_spec const *chan,
+                                    long mask)
 {
        switch (mask) {
        case IIO_CHAN_INFO_SAMP_FREQ:
@@ -423,14 +429,14 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
        }
 
        ret = regmap_bulk_read(data->regmap, HMC5843_DATA_OUT_MSB_REGS,
-                       data->buffer, 3 * sizeof(__be16));
+                              data->buffer, 3 * sizeof(__be16));
 
        mutex_unlock(&data->lock);
        if (ret < 0)
                goto done;
 
        iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
-               iio_get_time_ns());
+                                          iio_get_time_ns());
 
 done:
        iio_trigger_notify_done(indio_dev->trig);
@@ -526,7 +532,7 @@ static int hmc5843_init(struct hmc5843_data *data)
        u8 id[3];
 
        ret = regmap_bulk_read(data->regmap, HMC5843_ID_REG,
-                       id, ARRAY_SIZE(id));
+                              id, ARRAY_SIZE(id));
        if (ret < 0)
                return ret;
        if (id[0] != 'H' || id[1] != '4' || id[2] != '3') {
@@ -556,7 +562,6 @@ static const struct iio_info hmc5843_info = {
 
 static const unsigned long hmc5843_scan_masks[] = {0x7, 0};
 
-
 int hmc5843_common_suspend(struct device *dev)
 {
        return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
@@ -567,19 +572,19 @@ EXPORT_SYMBOL(hmc5843_common_suspend);
 int hmc5843_common_resume(struct device *dev)
 {
        return hmc5843_set_mode(iio_priv(dev_get_drvdata(dev)),
-                       HMC5843_MODE_SLEEP);
+                               HMC5843_MODE_SLEEP);
 }
 EXPORT_SYMBOL(hmc5843_common_resume);
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
-               enum hmc5843_ids id)
+                        enum hmc5843_ids id)
 {
        struct hmc5843_data *data;
        struct iio_dev *indio_dev;
        int ret;
 
        indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
-       if (indio_dev == NULL)
+       if (!indio_dev)
                return -ENOMEM;
 
        dev_set_drvdata(dev, indio_dev);
@@ -592,6 +597,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
        mutex_init(&data->lock);
 
        indio_dev->dev.parent = dev;
+       indio_dev->name = dev->driver->name;
        indio_dev->info = &hmc5843_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = data->variant->channels;
@@ -603,7 +609,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
                return ret;
 
        ret = iio_triggered_buffer_setup(indio_dev, NULL,
-               hmc5843_trigger_handler, NULL);
+                                        hmc5843_trigger_handler, NULL);
        if (ret < 0)
                return ret;
 
index 6acd614cdbc6529ae22d4df7c53548f1e3852455..6b4c74236916fd5729efb2e6f4b1a4e99ca6ce1a 100644 (file)
@@ -56,11 +56,11 @@ static struct regmap_config hmc5843_i2c_regmap_config = {
                .cache_type = REGCACHE_RBTREE,
 };
 
-static int hmc5843_i2c_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int hmc5843_i2c_probe(struct i2c_client *cli,
+                            const struct i2c_device_id *id)
 {
-       return hmc5843_common_probe(&client->dev,
-                       devm_regmap_init_i2c(client, &hmc5843_i2c_regmap_config),
+       return hmc5843_common_probe(&cli->dev,
+                       devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
                        id->driver_data);
 }
 
index 78e8f560eeec564aa19e94fb5e1f103b76236b4c..ffc7f0ddff14c7cc24eee0c109b6f6beefa1a928 100644 (file)
@@ -411,7 +411,7 @@ static ssize_t ade7753_write_frequency(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       t = (27900 / val);
+       t = 27900 / val;
        if (t > 0)
                t--;
 
@@ -517,11 +517,7 @@ static int ade7753_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
-       ret = iio_device_register(indio_dev);
-       if (ret)
-               return ret;
-
-       return 0;
+       return iio_device_register(indio_dev);
 }
 
 /* fixme, confirm ordering in this function */
index 81f67318974ad77322c3f66138f25d3385463af9..8dc5089772a39549e28e3df387c69b080646cb20 100644 (file)
@@ -432,7 +432,7 @@ static ssize_t ade7754_write_frequency(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       t = (26000 / val);
+       t = 26000 / val;
        if (t > 0)
                t--;
 
@@ -540,11 +540,7 @@ static int ade7754_probe(struct spi_device *spi)
        ret = ade7754_initial_setup(indio_dev);
        if (ret)
                return ret;
-       ret = iio_device_register(indio_dev);
-       if (ret)
-               return ret;
-
-       return 0;
+       return iio_device_register(indio_dev);
 }
 
 /* fixme, confirm ordering in this function */
index 70e96b20c2ebfbc8f57e6f280ddc4a9989bffce3..652aa1069b066e88227fd3e47450c99027cdfc38 100644 (file)
@@ -303,14 +303,15 @@ static int ade7758_reset(struct device *dev)
        int ret;
        u8 val;
 
-       ade7758_spi_read_reg_8(dev,
-                       ADE7758_OPMODE,
-                       &val);
+       ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
+       if (ret < 0) {
+               dev_err(dev, "Failed to read opmode reg\n");
+               return ret;
+       }
        val |= 1 << 6; /* Software Chip Reset */
-       ret = ade7758_spi_write_reg_8(dev,
-                       ADE7758_OPMODE,
-                       val);
-
+       ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
+       if (ret < 0)
+               dev_err(dev, "Failed to write opmode reg\n");
        return ret;
 }
 
@@ -444,14 +445,15 @@ static int ade7758_stop_device(struct device *dev)
        int ret;
        u8 val;
 
-       ade7758_spi_read_reg_8(dev,
-                       ADE7758_OPMODE,
-                       &val);
+       ret = ade7758_spi_read_reg_8(dev, ADE7758_OPMODE, &val);
+       if (ret < 0) {
+               dev_err(dev, "Failed to read opmode reg\n");
+               return ret;
+       }
        val |= 7 << 3;  /* ADE7758 powered down */
-       ret = ade7758_spi_write_reg_8(dev,
-                       ADE7758_OPMODE,
-                       val);
-
+       ret = ade7758_spi_write_reg_8(dev, ADE7758_OPMODE, val);
+       if (ret < 0)
+               dev_err(dev, "Failed to write opmode reg\n");
        return ret;
 }
 
@@ -483,7 +485,7 @@ static ssize_t ade7758_read_frequency(struct device *dev,
                struct device_attribute *attr,
                char *buf)
 {
-       int ret, len = 0;
+       int ret;
        u8 t;
        int sps;
 
@@ -496,8 +498,7 @@ static ssize_t ade7758_read_frequency(struct device *dev,
        t = (t >> 5) & 0x3;
        sps = 26040 / (1 << t);
 
-       len = sprintf(buf, "%d SPS\n", sps);
-       return len;
+       return sprintf(buf, "%d SPS\n", sps);
 }
 
 static ssize_t ade7758_write_frequency(struct device *dev,
index 3792b57616456c99c55ac6a35cb7b8adc97671dc..ead38a50b25b9aac0baa6c61152766c3adac69db 100644 (file)
@@ -119,10 +119,8 @@ int ade7758_configure_ring(struct iio_dev *indio_dev)
        int ret = 0;
 
        buffer = iio_kfifo_allocate();
-       if (!buffer) {
-               ret = -ENOMEM;
-               return ret;
-       }
+       if (!buffer)
+               return -ENOMEM;
 
        iio_device_attach_buffer(indio_dev, buffer);
 
index b0c7dbc8a4283c88de229bc2332676a82412e9a5..7eef8b9573fc85faaae975457966857d76dfdafc 100644 (file)
@@ -215,18 +215,15 @@ error_ret:
 
 static int ade7759_reset(struct device *dev)
 {
-       int ret;
        u16 val;
 
        ade7759_spi_read_reg_16(dev,
                        ADE7759_MODE,
                        &val);
        val |= 1 << 6; /* Software Chip Reset */
-       ret = ade7759_spi_write_reg_16(dev,
+       return ade7759_spi_write_reg_16(dev,
                        ADE7759_MODE,
                        val);
-
-       return ret;
 }
 
 static IIO_DEV_ATTR_AENERGY(ade7759_read_40bit, ADE7759_AENERGY);
@@ -374,7 +371,7 @@ static ssize_t ade7759_write_frequency(struct device *dev,
 
        mutex_lock(&indio_dev->mlock);
 
-       t = (27900 / val);
+       t = 27900 / val;
        if (t > 0)
                t--;
 
@@ -465,11 +462,7 @@ static int ade7759_probe(struct spi_device *spi)
        if (ret)
                return ret;
 
-       ret = iio_device_register(indio_dev);
-       if (ret)
-               return ret;
-
-       return 0;
+       return iio_device_register(indio_dev);
 }
 
 /* fixme, confirm ordering in this function */
index 5b33c7f1aa9108652fb4d6f7d8ceb81048646113..07cfe28b24e2a2c1ebcc03e3b98d494167498d8e 100644 (file)
@@ -16,8 +16,8 @@
 #include "ade7854.h"
 
 static int ade7854_i2c_write_reg_8(struct device *dev,
-               u16 reg_address,
-               u8 value)
+                                  u16 reg_address,
+                                  u8 value)
 {
        int ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -35,8 +35,8 @@ static int ade7854_i2c_write_reg_8(struct device *dev,
 }
 
 static int ade7854_i2c_write_reg_16(struct device *dev,
-               u16 reg_address,
-               u16 value)
+                                   u16 reg_address,
+                                   u16 value)
 {
        int ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -55,8 +55,8 @@ static int ade7854_i2c_write_reg_16(struct device *dev,
 }
 
 static int ade7854_i2c_write_reg_24(struct device *dev,
-               u16 reg_address,
-               u32 value)
+                                   u16 reg_address,
+                                   u32 value)
 {
        int ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -76,8 +76,8 @@ static int ade7854_i2c_write_reg_24(struct device *dev,
 }
 
 static int ade7854_i2c_write_reg_32(struct device *dev,
-               u16 reg_address,
-               u32 value)
+                                   u16 reg_address,
+                                   u32 value)
 {
        int ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -98,8 +98,8 @@ static int ade7854_i2c_write_reg_32(struct device *dev,
 }
 
 static int ade7854_i2c_read_reg_8(struct device *dev,
-               u16 reg_address,
-               u8 *val)
+                                 u16 reg_address,
+                                 u8 *val)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ade7854_state *st = iio_priv(indio_dev);
@@ -124,8 +124,8 @@ out:
 }
 
 static int ade7854_i2c_read_reg_16(struct device *dev,
-               u16 reg_address,
-               u16 *val)
+                                  u16 reg_address,
+                                  u16 *val)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ade7854_state *st = iio_priv(indio_dev);
@@ -150,8 +150,8 @@ out:
 }
 
 static int ade7854_i2c_read_reg_24(struct device *dev,
-               u16 reg_address,
-               u32 *val)
+                                  u16 reg_address,
+                                  u32 *val)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ade7854_state *st = iio_priv(indio_dev);
@@ -176,8 +176,8 @@ out:
 }
 
 static int ade7854_i2c_read_reg_32(struct device *dev,
-               u16 reg_address,
-               u32 *val)
+                                  u16 reg_address,
+                                  u32 *val)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct ade7854_state *st = iio_priv(indio_dev);
@@ -195,21 +195,21 @@ static int ade7854_i2c_read_reg_32(struct device *dev,
        if (ret)
                goto out;
 
-       *val = (st->rx[0] << 24) | (st->rx[1] << 16) | (st->rx[2] << 8) | st->rx[3];
+       *val = (st->rx[0] << 24) | (st->rx[1] << 16) |
+               (st->rx[2] << 8) | st->rx[3];
 out:
        mutex_unlock(&st->buf_lock);
        return ret;
 }
 
 static int ade7854_i2c_probe(struct i2c_client *client,
-               const struct i2c_device_id *id)
+                            const struct i2c_device_id *id)
 {
-       int ret;
        struct ade7854_state *st;
        struct iio_dev *indio_dev;
 
        indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
-       if (indio_dev == NULL)
+       if (!indio_dev)
                return -ENOMEM;
        st = iio_priv(indio_dev);
        i2c_set_clientdata(client, indio_dev);
@@ -224,9 +224,7 @@ static int ade7854_i2c_probe(struct i2c_client *client,
        st->i2c = client;
        st->irq = client->irq;
 
-       ret = ade7854_probe(indio_dev, &client->dev);
-
-       return ret;
+       return ade7854_probe(indio_dev, &client->dev);
 }
 
 static int ade7854_i2c_remove(struct i2c_client *client)
index 94f73bbbc0fd28ec65153b401ef5a401d32d24d2..9b255a5f62c33822ecb8d255799887c6a4ee7cf6 100644 (file)
@@ -274,7 +274,6 @@ error_ret:
 
 static int ade7854_spi_probe(struct spi_device *spi)
 {
-       int ret;
        struct ade7854_state *st;
        struct iio_dev *indio_dev;
 
@@ -294,10 +293,7 @@ static int ade7854_spi_probe(struct spi_device *spi)
        st->irq = spi->irq;
        st->spi = spi;
 
-
-       ret = ade7854_probe(indio_dev, &spi->dev);
-
-       return ret;
+       return ade7854_probe(indio_dev, &spi->dev);
 }
 
 static int ade7854_spi_remove(struct spi_device *spi)
index 8f0de02839b73c72d7ff83998133e8801c91979a..dfba510f29be6c764a42f94e538a7ab7ab910e93 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _METER_H
+#define _METER_H
+
 #include <linux/iio/sysfs.h>
 
 /* metering ic types of attribute */
 #define IIO_EVENT_ATTR_VPKLVL_EXC(_evlist, _show, _store, _mask) \
        IIO_EVENT_ATTR_SH(vpklvl_exc, _evlist, _show, _store, _mask)
 
+#endif /* _METER_H */
index b4c14ba5fdee3dca1a2585b43e5858f03b53af5c..5b1daeacac7a22ef0576f861acf94a591734d5ef 100644 (file)
@@ -151,7 +151,7 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st)
 
        fcw = (unsigned char)(st->fexcit * (1 << 15) / st->fclkin);
        if (fcw < AD2S1210_MIN_FCW || fcw > AD2S1210_MAX_FCW) {
-               pr_err("ad2s1210: FCW out of range\n");
+               dev_err(&st->sdev->dev, "ad2s1210: FCW out of range\n");
                return -ERANGE;
        }
 
@@ -214,7 +214,7 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev,
        if (ret)
                return ret;
        if (fclkin < AD2S1210_MIN_CLKIN || fclkin > AD2S1210_MAX_CLKIN) {
-               pr_err("ad2s1210: fclkin out of range\n");
+               dev_err(dev, "ad2s1210: fclkin out of range\n");
                return -EINVAL;
        }
 
@@ -252,7 +252,8 @@ static ssize_t ad2s1210_store_fexcit(struct device *dev,
        if (ret < 0)
                return ret;
        if (fexcit < AD2S1210_MIN_EXCIT || fexcit > AD2S1210_MAX_EXCIT) {
-               pr_err("ad2s1210: excitation frequency out of range\n");
+               dev_err(dev,
+                       "ad2s1210: excitation frequency out of range\n");
                return -EINVAL;
        }
        mutex_lock(&st->lock);
@@ -307,7 +308,8 @@ static ssize_t ad2s1210_store_control(struct device *dev,
                goto error_ret;
        if (ret & AD2S1210_MSB_IS_HIGH) {
                ret = -EIO;
-               pr_err("ad2s1210: write control register fail\n");
+               dev_err(dev,
+                       "ad2s1210: write control register fail\n");
                goto error_ret;
        }
        st->resolution
@@ -315,7 +317,7 @@ static ssize_t ad2s1210_store_control(struct device *dev,
        if (st->pdata->gpioin) {
                data = ad2s1210_read_resolution_pin(st);
                if (data != st->resolution)
-                       pr_warn("ad2s1210: resolution settings not match\n");
+                       dev_warn(dev, "ad2s1210: resolution settings not match\n");
        } else
                ad2s1210_set_resolution_pin(st);
 
@@ -346,7 +348,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
 
        ret = kstrtou8(buf, 10, &udata);
        if (ret || udata < 10 || udata > 16) {
-               pr_err("ad2s1210: resolution out of range\n");
+               dev_err(dev, "ad2s1210: resolution out of range\n");
                return -EINVAL;
        }
        mutex_lock(&st->lock);
@@ -368,7 +370,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
        data = ret;
        if (data & AD2S1210_MSB_IS_HIGH) {
                ret = -EIO;
-               pr_err("ad2s1210: setting resolution fail\n");
+               dev_err(dev, "ad2s1210: setting resolution fail\n");
                goto error_ret;
        }
        st->resolution
@@ -376,7 +378,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
        if (st->pdata->gpioin) {
                data = ad2s1210_read_resolution_pin(st);
                if (data != st->resolution)
-                       pr_warn("ad2s1210: resolution settings not match\n");
+                       dev_warn(dev, "ad2s1210: resolution settings not match\n");
        } else
                ad2s1210_set_resolution_pin(st);
        ret = len;
index aec0bdca16a48d13de38b8196a722fc3537c65a4..c7158f6e61c23c7fa0090bc2f19f63f19acbcb62 100644 (file)
@@ -8,6 +8,8 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#ifndef _AD2S1210_H
+#define _AD2S1210_H
 
 struct ad2s1210_platform_data {
        unsigned sample;
@@ -15,3 +17,4 @@ struct ad2s1210_platform_data {
        unsigned res[2];
        bool gpioin;
 };
+#endif /* _AD2S1210_H */
index 2af8d677d4ed88b59b094a62a4e7bc9ef4064a47..3c1c8c6c4a6c8ea224edab37c1f64f8d87f8d9e2 100644 (file)
@@ -183,7 +183,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
        int ret;
 
        st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
-       if (st == NULL)
+       if (!st)
                return -ENOMEM;
 
        st->irq = platform_get_irq(pdev, 0);
index 2e5a9e5965b13883cf89cac70da77264e5b2cf26..8251ac932e37b22110c0cf5deacde6c53ecc4e78 100644 (file)
@@ -196,7 +196,7 @@ do {                                                                \
               .msg_fn     = __func__,                          \
               .msg_line   = __LINE__,                          \
               .msg_cdls   = (cdls)      };                     \
-       dataname.msg_mask   = (mask);
+       dataname.msg_mask   = (mask)
 
 /**
  * Filters out logging messages based on mask and subsystem.
@@ -244,12 +244,12 @@ do {                                                                      \
 
 int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata,
                            const char *format1, ...)
-       __attribute__ ((format (printf, 2, 3)));
+       __printf(2, 3);
 
 int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
                              const char *format1,
                              va_list args, const char *format2, ...)
-       __attribute__ ((format (printf, 4, 5)));
+       __printf(4, 5);
 
 /* other external symbols that tracefile provides: */
 int cfs_trace_copyin_string(char *knl_buffer, int knl_buffer_nob,
index 808e49411a300a1c4f8f9b079ee7f88d442f5997..c408145911899d353cbb5e589369b3663108cd09 100644 (file)
@@ -469,7 +469,7 @@ cfs_hash_key(struct cfs_hash *hs, struct hlist_node *hnode)
 static inline void
 cfs_hash_keycpy(struct cfs_hash *hs, struct hlist_node *hnode, void *key)
 {
-        if (hs->hs_ops->hs_keycpy)
+       if (hs->hs_ops->hs_keycpy)
                hs->hs_ops->hs_keycpy(hnode, key);
 }
 
@@ -785,8 +785,8 @@ static inline void __cfs_hash_set_theta(struct cfs_hash *hs, int min, int max)
 
 /* Generic debug formatting routines mainly for proc handler */
 struct seq_file;
-int cfs_hash_debug_header(struct seq_file *m);
-int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m);
+void cfs_hash_debug_header(struct seq_file *m);
+void cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m);
 
 /*
  * Generic djb2 hash algorithm for character arrays.
index f19a121a37cd5fb4f8a090284eea39f22165af0e..a989d2666230e9d70371c25c0869fc47a8e28deb 100644 (file)
@@ -58,7 +58,7 @@ struct kuc_hdr {
        __u8  kuc_flags;
        __u16 kuc_msgtype;    /* Message type or opcode, transport-specific */
        __u16 kuc_msglen;     /* Including header */
-} __attribute__((aligned(sizeof(__u64))));
+} __aligned(sizeof(__u64));
 
 #define KUC_CHANGELOG_MSG_MAXSIZE (sizeof(struct kuc_hdr)+CR_MAXSIZE)
 
@@ -107,7 +107,7 @@ typedef struct lustre_kernelcomm {
        __u32 lk_group;
        __u32 lk_data;
        __u32 lk_flags;
-} __attribute__((packed)) lustre_kernelcomm;
+} __packed lustre_kernelcomm;
 
 /* Userspace methods */
 int libcfs_ukuc_start(lustre_kernelcomm *l, int groups);
index 3d86fb5b548192678f675cf6c7a7ab98101bfe88..fef882530455f2b4f6c8c57daf8f66638f68a0ad 100644 (file)
@@ -335,8 +335,8 @@ do {                                                            \
 #define LASSERT_ATOMIC_ZERO(a)           LASSERT_ATOMIC_EQ(a, 0)
 #define LASSERT_ATOMIC_POS(a)             LASSERT_ATOMIC_GT(a, 0)
 
-#define CFS_ALLOC_PTR(ptr)      LIBCFS_ALLOC(ptr, sizeof(*(ptr)));
-#define CFS_FREE_PTR(ptr)       LIBCFS_FREE(ptr, sizeof(*(ptr)));
+#define CFS_ALLOC_PTR(ptr)      LIBCFS_ALLOC(ptr, sizeof(*(ptr)))
+#define CFS_FREE_PTR(ptr)       LIBCFS_FREE(ptr, sizeof(*(ptr)))
 
 /*
  * percpu partition lock
index 65101691966915d2ace2204b18e6a4590696ff8d..b04bb2ebe33751318b959db75e97d360d0d89986 100644 (file)
@@ -147,7 +147,7 @@ kiblnd_unpack_rd(kib_msg_t *msg, int flip)
        int             n;
        int             i;
 
-       LASSERT (msg->ibm_type == IBLND_MSG_GET_REQ ||
+       LASSERT(msg->ibm_type == IBLND_MSG_GET_REQ ||
                 msg->ibm_type == IBLND_MSG_PUT_ACK);
 
        rd = msg->ibm_type == IBLND_MSG_GET_REQ ?
@@ -167,7 +167,7 @@ kiblnd_unpack_rd(kib_msg_t *msg, int flip)
                return 1;
        }
 
-       nob = offsetof (kib_msg_t, ibm_u) +
+       nob = offsetof(kib_msg_t, ibm_u) +
              kiblnd_rd_msg_size(rd, msg->ibm_type, n);
 
        if (msg->ibm_nob < nob) {
@@ -188,7 +188,7 @@ kiblnd_unpack_rd(kib_msg_t *msg, int flip)
 }
 
 void
-kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
+kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version,
                 int credits, lnet_nid_t dstnid, __u64 dststamp)
 {
        kib_net_t *net = ni->ni_data;
@@ -269,8 +269,8 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
        if (flip) {
                /* leave magic unflipped as a clue to peer endianness */
                msg->ibm_version = version;
-               CLASSERT (sizeof(msg->ibm_type) == 1);
-               CLASSERT (sizeof(msg->ibm_credits) == 1);
+               CLASSERT(sizeof(msg->ibm_type) == 1);
+               CLASSERT(sizeof(msg->ibm_credits) == 1);
                msg->ibm_nob     = msg_nob;
                __swab64s(&msg->ibm_srcnid);
                __swab64s(&msg->ibm_srcstamp);
@@ -356,7 +356,7 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
        /* always called with a ref on ni, which prevents ni being shutdown */
-       LASSERT (net->ibn_shutdown == 0);
+       LASSERT(net->ibn_shutdown == 0);
 
        /* npeers only grows with the global lock held */
        atomic_inc(&net->ibn_npeers);
@@ -368,17 +368,17 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
 }
 
 void
-kiblnd_destroy_peer (kib_peer_t *peer)
+kiblnd_destroy_peer(kib_peer_t *peer)
 {
        kib_net_t *net = peer->ibp_ni->ni_data;
 
-       LASSERT (net != NULL);
-       LASSERT (atomic_read(&peer->ibp_refcount) == 0);
-       LASSERT (!kiblnd_peer_active(peer));
-       LASSERT (peer->ibp_connecting == 0);
-       LASSERT (peer->ibp_accepting == 0);
-       LASSERT (list_empty(&peer->ibp_conns));
-       LASSERT (list_empty(&peer->ibp_tx_queue));
+       LASSERT(net != NULL);
+       LASSERT(atomic_read(&peer->ibp_refcount) == 0);
+       LASSERT(!kiblnd_peer_active(peer));
+       LASSERT(peer->ibp_connecting == 0);
+       LASSERT(peer->ibp_accepting == 0);
+       LASSERT(list_empty(&peer->ibp_conns));
+       LASSERT(list_empty(&peer->ibp_tx_queue));
 
        LIBCFS_FREE(peer, sizeof(*peer));
 
@@ -390,7 +390,7 @@ kiblnd_destroy_peer (kib_peer_t *peer)
 }
 
 kib_peer_t *
-kiblnd_find_peer_locked (lnet_nid_t nid)
+kiblnd_find_peer_locked(lnet_nid_t nid)
 {
        /* the caller is responsible for accounting the additional reference
         * that this creates */
@@ -398,11 +398,11 @@ kiblnd_find_peer_locked (lnet_nid_t nid)
        struct list_head       *tmp;
        kib_peer_t       *peer;
 
-       list_for_each (tmp, peer_list) {
+       list_for_each(tmp, peer_list) {
 
                peer = list_entry(tmp, kib_peer_t, ibp_list);
 
-               LASSERT (peer->ibp_connecting > 0 || /* creating conns */
+               LASSERT(peer->ibp_connecting > 0 || /* creating conns */
                         peer->ibp_accepting > 0 ||
                         !list_empty(&peer->ibp_conns));  /* active conn */
 
@@ -419,11 +419,11 @@ kiblnd_find_peer_locked (lnet_nid_t nid)
 }
 
 void
-kiblnd_unlink_peer_locked (kib_peer_t *peer)
+kiblnd_unlink_peer_locked(kib_peer_t *peer)
 {
-       LASSERT (list_empty(&peer->ibp_conns));
+       LASSERT(list_empty(&peer->ibp_conns));
 
-       LASSERT (kiblnd_peer_active(peer));
+       LASSERT(kiblnd_peer_active(peer));
        list_del_init(&peer->ibp_list);
        /* lose peerlist's ref */
        kiblnd_peer_decref(peer);
@@ -442,10 +442,10 @@ kiblnd_get_peer_info(lnet_ni_t *ni, int index,
 
        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
 
-               list_for_each (ptmp, &kiblnd_data.kib_peers[i]) {
+               list_for_each(ptmp, &kiblnd_data.kib_peers[i]) {
 
                        peer = list_entry(ptmp, kib_peer_t, ibp_list);
-                       LASSERT (peer->ibp_connecting > 0 ||
+                       LASSERT(peer->ibp_connecting > 0 ||
                                 peer->ibp_accepting > 0 ||
                                 !list_empty(&peer->ibp_conns));
 
@@ -478,7 +478,7 @@ kiblnd_del_peer_locked(kib_peer_t *peer)
        if (list_empty(&peer->ibp_conns)) {
                kiblnd_unlink_peer_locked(peer);
        } else {
-               list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
+               list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
                        conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
                        kiblnd_close_conn_locked(conn, 0);
@@ -492,7 +492,7 @@ kiblnd_del_peer_locked(kib_peer_t *peer)
 static int
 kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
 {
-       LIST_HEAD        (zombies);
+       LIST_HEAD(zombies);
        struct list_head            *ptmp;
        struct list_head            *pnxt;
        kib_peer_t          *peer;
@@ -512,9 +512,9 @@ kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
        }
 
        for (i = lo; i <= hi; i++) {
-               list_for_each_safe (ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
+               list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
                        peer = list_entry(ptmp, kib_peer_t, ibp_list);
-                       LASSERT (peer->ibp_connecting > 0 ||
+                       LASSERT(peer->ibp_connecting > 0 ||
                                 peer->ibp_accepting > 0 ||
                                 !list_empty(&peer->ibp_conns));
 
@@ -525,7 +525,7 @@ kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
                                continue;
 
                        if (!list_empty(&peer->ibp_tx_queue)) {
-                               LASSERT (list_empty(&peer->ibp_conns));
+                               LASSERT(list_empty(&peer->ibp_conns));
 
                                list_splice_init(&peer->ibp_tx_queue,
                                                     &zombies);
@@ -556,17 +556,17 @@ kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
-               list_for_each (ptmp, &kiblnd_data.kib_peers[i]) {
+               list_for_each(ptmp, &kiblnd_data.kib_peers[i]) {
 
                        peer = list_entry(ptmp, kib_peer_t, ibp_list);
-                       LASSERT (peer->ibp_connecting > 0 ||
+                       LASSERT(peer->ibp_connecting > 0 ||
                                 peer->ibp_accepting > 0 ||
                                 !list_empty(&peer->ibp_conns));
 
                        if (peer->ibp_ni != ni)
                                continue;
 
-                       list_for_each (ctmp, &peer->ibp_conns) {
+                       list_for_each(ctmp, &peer->ibp_conns) {
                                if (index-- > 0)
                                        continue;
 
@@ -615,7 +615,7 @@ kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
                return;
 
        mtu = kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu);
-       LASSERT (mtu >= 0);
+       LASSERT(mtu >= 0);
        if (mtu != 0)
                cmid->route.path_rec->mtu = mtu;
 }
@@ -638,8 +638,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
                return 0;
 
        /* hash NID to CPU id in this partition... */
-       off = do_div(nid, cpus_weight(*mask));
-       for_each_cpu_mask(i, *mask) {
+       off = do_div(nid, cpumask_weight(mask));
+       for_each_cpu(i, mask) {
                if (off-- == 0)
                        return i % vectors;
        }
@@ -835,7 +835,7 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
        }
 
        /* Init successful! */
-       LASSERT (state == IBLND_CONN_ACTIVE_CONNECT ||
+       LASSERT(state == IBLND_CONN_ACTIVE_CONNECT ||
                 state == IBLND_CONN_PASSIVE_WAIT);
        conn->ibc_state = state;
 
@@ -852,22 +852,22 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
 }
 
 void
-kiblnd_destroy_conn (kib_conn_t *conn)
+kiblnd_destroy_conn(kib_conn_t *conn)
 {
        struct rdma_cm_id *cmid = conn->ibc_cmid;
        kib_peer_t      *peer = conn->ibc_peer;
        int             rc;
 
-       LASSERT (!in_interrupt());
-       LASSERT (atomic_read(&conn->ibc_refcount) == 0);
-       LASSERT (list_empty(&conn->ibc_early_rxs));
-       LASSERT (list_empty(&conn->ibc_tx_noops));
-       LASSERT (list_empty(&conn->ibc_tx_queue));
-       LASSERT (list_empty(&conn->ibc_tx_queue_rsrvd));
-       LASSERT (list_empty(&conn->ibc_tx_queue_nocred));
-       LASSERT (list_empty(&conn->ibc_active_txs));
-       LASSERT (conn->ibc_noops_posted == 0);
-       LASSERT (conn->ibc_nsends_posted == 0);
+       LASSERT(!in_interrupt());
+       LASSERT(atomic_read(&conn->ibc_refcount) == 0);
+       LASSERT(list_empty(&conn->ibc_early_rxs));
+       LASSERT(list_empty(&conn->ibc_tx_noops));
+       LASSERT(list_empty(&conn->ibc_tx_queue));
+       LASSERT(list_empty(&conn->ibc_tx_queue_rsrvd));
+       LASSERT(list_empty(&conn->ibc_tx_queue_nocred));
+       LASSERT(list_empty(&conn->ibc_active_txs));
+       LASSERT(conn->ibc_noops_posted == 0);
+       LASSERT(conn->ibc_nsends_posted == 0);
 
        switch (conn->ibc_state) {
        default:
@@ -876,7 +876,7 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 
        case IBLND_CONN_DISCONNECTED:
                /* connvars should have been freed already */
-               LASSERT (conn->ibc_connvars == NULL);
+               LASSERT(conn->ibc_connvars == NULL);
                break;
 
        case IBLND_CONN_INIT:
@@ -920,14 +920,14 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 }
 
 int
-kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
+kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
 {
        kib_conn_t           *conn;
        struct list_head             *ctmp;
        struct list_head             *cnxt;
        int                  count = 0;
 
-       list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
+       list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
                conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
                CDEBUG(D_NET, "Closing conn -> %s, version: %x, reason: %d\n",
@@ -942,7 +942,7 @@ kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
 }
 
 int
-kiblnd_close_stale_conns_locked (kib_peer_t *peer,
+kiblnd_close_stale_conns_locked(kib_peer_t *peer,
                                 int version, __u64 incarnation)
 {
        kib_conn_t           *conn;
@@ -950,7 +950,7 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer,
        struct list_head             *cnxt;
        int                  count = 0;
 
-       list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
+       list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
                conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
                if (conn->ibc_version     == version &&
@@ -991,10 +991,10 @@ kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
        }
 
        for (i = lo; i <= hi; i++) {
-               list_for_each_safe (ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
+               list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) {
 
                        peer = list_entry(ptmp, kib_peer_t, ibp_list);
-                       LASSERT (peer->ibp_connecting > 0 ||
+                       LASSERT(peer->ibp_connecting > 0 ||
                                 peer->ibp_accepting > 0 ||
                                 !list_empty(&peer->ibp_conns));
 
@@ -1049,7 +1049,7 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
                        break;
                }
 
-               LASSERT (conn->ibc_cmid != NULL);
+               LASSERT(conn->ibc_cmid != NULL);
                data->ioc_nid = conn->ibc_peer->ibp_nid;
                if (conn->ibc_cmid->route.path_rec == NULL)
                        data->ioc_u32[0] = 0; /* iWarp has no path MTU */
@@ -1072,7 +1072,7 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
 }
 
 void
-kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
+kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
 {
        unsigned long   last_alive = 0;
        unsigned long   now = cfs_time_current();
@@ -1084,7 +1084,7 @@ kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
 
        peer = kiblnd_find_peer_locked(nid);
        if (peer != NULL) {
-               LASSERT (peer->ibp_connecting > 0 || /* creating conns */
+               LASSERT(peer->ibp_connecting > 0 || /* creating conns */
                         peer->ibp_accepting > 0 ||
                         !list_empty(&peer->ibp_conns));  /* active conn */
                last_alive = peer->ibp_last_alive;
@@ -1103,7 +1103,6 @@ kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
        CDEBUG(D_NET, "Peer %s %p, alive %ld secs ago\n",
               libcfs_nid2str(nid), peer,
               last_alive ? cfs_duration_sec(now - last_alive) : -1);
-       return;
 }
 
 void
@@ -1157,13 +1156,13 @@ kiblnd_unmap_rx_descs(kib_conn_t *conn)
        kib_rx_t *rx;
        int       i;
 
-       LASSERT (conn->ibc_rxs != NULL);
-       LASSERT (conn->ibc_hdev != NULL);
+       LASSERT(conn->ibc_rxs != NULL);
+       LASSERT(conn->ibc_hdev != NULL);
 
        for (i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++) {
                rx = &conn->ibc_rxs[i];
 
-               LASSERT (rx->rx_nob >= 0); /* not posted */
+               LASSERT(rx->rx_nob >= 0); /* not posted */
 
                kiblnd_dma_unmap_single(conn->ibc_hdev->ibh_ibdev,
                                        KIBLND_UNMAP_ADDR(rx, rx_msgunmap,
@@ -1196,7 +1195,7 @@ kiblnd_map_rx_descs(kib_conn_t *conn)
                rx->rx_msgaddr = kiblnd_dma_map_single(conn->ibc_hdev->ibh_ibdev,
                                                       rx->rx_msg, IBLND_MSG_SIZE,
                                                       DMA_FROM_DEVICE);
-               LASSERT (!kiblnd_dma_mapping_error(conn->ibc_hdev->ibh_ibdev,
+               LASSERT(!kiblnd_dma_mapping_error(conn->ibc_hdev->ibh_ibdev,
                                                   rx->rx_msgaddr));
                KIBLND_UNMAP_ADDR_SET(rx, rx_msgunmap, rx->rx_msgaddr);
 
@@ -1205,12 +1204,12 @@ kiblnd_map_rx_descs(kib_conn_t *conn)
                       lnet_page2phys(pg) + pg_off);
 
                pg_off += IBLND_MSG_SIZE;
-               LASSERT (pg_off <= PAGE_SIZE);
+               LASSERT(pg_off <= PAGE_SIZE);
 
                if (pg_off == PAGE_SIZE) {
                        pg_off = 0;
                        ipg++;
-                       LASSERT (ipg <= IBLND_RX_MSG_PAGES(conn->ibc_version));
+                       LASSERT(ipg <= IBLND_RX_MSG_PAGES(conn->ibc_version));
                }
        }
 }
@@ -1222,7 +1221,7 @@ kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
        kib_tx_t       *tx;
        int          i;
 
-       LASSERT (tpo->tpo_pool.po_allocated == 0);
+       LASSERT(tpo->tpo_pool.po_allocated == 0);
 
        if (hdev == NULL)
                return;
@@ -1278,15 +1277,15 @@ kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
        int          ipage;
        int          i;
 
-       LASSERT (net != NULL);
+       LASSERT(net != NULL);
 
        dev = net->ibn_dev;
 
        /* pre-mapped messages are not bigger than 1 page */
-       CLASSERT (IBLND_MSG_SIZE <= PAGE_SIZE);
+       CLASSERT(IBLND_MSG_SIZE <= PAGE_SIZE);
 
        /* No fancy arithmetic when we do the buffer calculations */
-       CLASSERT (PAGE_SIZE % IBLND_MSG_SIZE == 0);
+       CLASSERT(PAGE_SIZE % IBLND_MSG_SIZE == 0);
 
        tpo->tpo_hdev = kiblnd_current_hdev(dev);
 
@@ -1300,19 +1299,19 @@ kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
                tx->tx_msgaddr = kiblnd_dma_map_single(
                        tpo->tpo_hdev->ibh_ibdev, tx->tx_msg,
                        IBLND_MSG_SIZE, DMA_TO_DEVICE);
-               LASSERT (!kiblnd_dma_mapping_error(tpo->tpo_hdev->ibh_ibdev,
+               LASSERT(!kiblnd_dma_mapping_error(tpo->tpo_hdev->ibh_ibdev,
                                                   tx->tx_msgaddr));
                KIBLND_UNMAP_ADDR_SET(tx, tx_msgunmap, tx->tx_msgaddr);
 
                list_add(&tx->tx_list, &pool->po_free_list);
 
                page_offset += IBLND_MSG_SIZE;
-               LASSERT (page_offset <= PAGE_SIZE);
+               LASSERT(page_offset <= PAGE_SIZE);
 
                if (page_offset == PAGE_SIZE) {
                        page_offset = 0;
                        ipage++;
-                       LASSERT (ipage <= txpgs->ibp_npages);
+                       LASSERT(ipage <= txpgs->ibp_npages);
                }
        }
 }
@@ -1322,7 +1321,7 @@ kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size)
 {
        __u64   index;
 
-       LASSERT (hdev->ibh_mrs[0] != NULL);
+       LASSERT(hdev->ibh_mrs[0] != NULL);
 
        if (hdev->ibh_nmrs == 1)
                return hdev->ibh_mrs[0];
@@ -1343,7 +1342,7 @@ kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
        struct ib_mr *mr;
        int        i;
 
-       LASSERT (hdev->ibh_mrs[0] != NULL);
+       LASSERT(hdev->ibh_mrs[0] != NULL);
 
        if (*kiblnd_tunables.kib_map_on_demand > 0 &&
            *kiblnd_tunables.kib_map_on_demand <= rd->rd_nfrags)
@@ -1373,7 +1372,7 @@ kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
 static void
 kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
 {
-       LASSERT (pool->fpo_map_count == 0);
+       LASSERT(pool->fpo_map_count == 0);
 
        if (pool->fpo_fmr_pool != NULL)
                ib_destroy_fmr_pool(pool->fpo_fmr_pool);
@@ -1519,7 +1518,7 @@ kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
 void
 kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
 {
-       LIST_HEAD     (zombies);
+       LIST_HEAD(zombies);
        kib_fmr_pool_t    *fpo = fmr->fmr_pool;
        kib_fmr_poolset_t *fps = fpo->fpo_owner;
        unsigned long    now = cfs_time_current();
@@ -1527,11 +1526,11 @@ kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
        int             rc;
 
        rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
-       LASSERT (rc == 0);
+       LASSERT(rc == 0);
 
        if (status != 0) {
                rc = ib_flush_fmr_pool(fpo->fpo_fmr_pool);
-               LASSERT (rc == 0);
+               LASSERT(rc == 0);
        }
 
        fmr->fmr_pool = NULL;
@@ -1630,8 +1629,8 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
 static void
 kiblnd_fini_pool(kib_pool_t *pool)
 {
-       LASSERT (list_empty(&pool->po_free_list));
-       LASSERT (pool->po_allocated == 0);
+       LASSERT(list_empty(&pool->po_free_list));
+       LASSERT(pool->po_allocated == 0);
 
        CDEBUG(D_NET, "Finalize %s pool\n", pool->po_owner->ps_name);
 }
@@ -1657,7 +1656,7 @@ kiblnd_destroy_pool_list(struct list_head *head)
                pool = list_entry(head->next, kib_pool_t, po_list);
                list_del(&pool->po_list);
 
-               LASSERT (pool->po_owner != NULL);
+               LASSERT(pool->po_owner != NULL);
                pool->po_owner->ps_pool_destroy(pool);
        }
 }
@@ -1740,7 +1739,7 @@ kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
 void
 kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
 {
-       LIST_HEAD  (zombies);
+       LIST_HEAD(zombies);
        kib_poolset_t  *ps = pool->po_owner;
        kib_pool_t     *tmp;
        unsigned long      now = cfs_time_current();
@@ -1750,7 +1749,7 @@ kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
        if (ps->ps_node_fini != NULL)
                ps->ps_node_fini(pool, node);
 
-       LASSERT (pool->po_allocated > 0);
+       LASSERT(pool->po_allocated > 0);
        list_add(node, &pool->po_free_list);
        pool->po_allocated--;
 
@@ -1894,14 +1893,12 @@ kiblnd_destroy_pmr_pool(kib_pool_t *pool)
 {
        kib_pmr_pool_t *ppo = container_of(pool, kib_pmr_pool_t, ppo_pool);
        kib_phys_mr_t  *pmr;
+       kib_phys_mr_t *tmp;
 
-       LASSERT (pool->po_allocated == 0);
+       LASSERT(pool->po_allocated == 0);
 
-       while (!list_empty(&pool->po_free_list)) {
-               pmr = list_entry(pool->po_free_list.next,
-                                    kib_phys_mr_t, pmr_list);
-
-               LASSERT (pmr->pmr_mr == NULL);
+       list_for_each_entry_safe(pmr, tmp, &pool->po_free_list, pmr_list) {
+               LASSERT(pmr->pmr_mr == NULL);
                list_del(&pmr->pmr_list);
 
                if (pmr->pmr_ipb != NULL) {
@@ -1976,7 +1973,7 @@ kiblnd_destroy_tx_pool(kib_pool_t *pool)
        kib_tx_pool_t  *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
        int          i;
 
-       LASSERT (pool->po_allocated == 0);
+       LASSERT(pool->po_allocated == 0);
 
        if (tpo->tpo_tx_pages != NULL) {
                kiblnd_unmap_tx_pool(tpo);
@@ -2442,7 +2439,7 @@ kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
                        return PTR_ERR(mr);
                }
 
-               LASSERT (iova == ipb.addr);
+               LASSERT(iova == ipb.addr);
 
                hdev->ibh_mrs[i] = mr;
        }
@@ -2519,9 +2516,9 @@ kiblnd_dev_need_failover(kib_dev_t *dev)
 int
 kiblnd_dev_failover(kib_dev_t *dev)
 {
-       LIST_HEAD      (zombie_tpo);
-       LIST_HEAD      (zombie_ppo);
-       LIST_HEAD      (zombie_fpo);
+       LIST_HEAD(zombie_tpo);
+       LIST_HEAD(zombie_ppo);
+       LIST_HEAD(zombie_fpo);
        struct rdma_cm_id  *cmid  = NULL;
        kib_hca_dev_t      *hdev  = NULL;
        kib_hca_dev_t      *old;
@@ -2532,7 +2529,7 @@ kiblnd_dev_failover(kib_dev_t *dev)
        int              rc = 0;
        int                 i;
 
-       LASSERT (*kiblnd_tunables.kib_dev_failover > 1 ||
+       LASSERT(*kiblnd_tunables.kib_dev_failover > 1 ||
                 dev->ibd_can_failover ||
                 dev->ibd_hdev == NULL);
 
@@ -2656,10 +2653,10 @@ kiblnd_dev_failover(kib_dev_t *dev)
 }
 
 void
-kiblnd_destroy_dev (kib_dev_t *dev)
+kiblnd_destroy_dev(kib_dev_t *dev)
 {
-       LASSERT (dev->ibd_nnets == 0);
-       LASSERT (list_empty(&dev->ibd_nets));
+       LASSERT(dev->ibd_nnets == 0);
+       LASSERT(list_empty(&dev->ibd_nets));
 
        list_del(&dev->ibd_fail_list);
        list_del(&dev->ibd_list);
@@ -2729,7 +2726,7 @@ kiblnd_base_shutdown(void)
        struct kib_sched_info   *sched;
        int                     i;
 
-       LASSERT (list_empty(&kiblnd_data.kib_devs));
+       LASSERT(list_empty(&kiblnd_data.kib_devs));
 
        CDEBUG(D_MALLOC, "before LND base cleanup: kmem %d\n",
               atomic_read(&libcfs_kmemory));
@@ -2740,12 +2737,12 @@ kiblnd_base_shutdown(void)
 
        case IBLND_INIT_ALL:
        case IBLND_INIT_DATA:
-               LASSERT (kiblnd_data.kib_peers != NULL);
+               LASSERT(kiblnd_data.kib_peers != NULL);
                for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) {
-                       LASSERT (list_empty(&kiblnd_data.kib_peers[i]));
+                       LASSERT(list_empty(&kiblnd_data.kib_peers[i]));
                }
-               LASSERT (list_empty(&kiblnd_data.kib_connd_zombies));
-               LASSERT (list_empty(&kiblnd_data.kib_connd_conns));
+               LASSERT(list_empty(&kiblnd_data.kib_connd_zombies));
+               LASSERT(list_empty(&kiblnd_data.kib_connd_conns));
 
                /* flag threads to terminate; wake and wait for them to die */
                kiblnd_data.kib_shutdown = 1;
@@ -2792,7 +2789,7 @@ kiblnd_base_shutdown(void)
 }
 
 void
-kiblnd_shutdown (lnet_ni_t *ni)
+kiblnd_shutdown(lnet_ni_t *ni)
 {
        kib_net_t       *net = ni->ni_data;
        rwlock_t     *g_lock = &kiblnd_data.kib_global_lock;
@@ -2842,7 +2839,7 @@ kiblnd_shutdown (lnet_ni_t *ni)
                /* fall through */
 
        case IBLND_INIT_NOTHING:
-               LASSERT (atomic_read(&net->ibn_nconns) == 0);
+               LASSERT(atomic_read(&net->ibn_nconns) == 0);
 
                if (net->ibn_dev != NULL &&
                    net->ibn_dev->ibd_nnets == 0)
@@ -2862,7 +2859,6 @@ kiblnd_shutdown (lnet_ni_t *ni)
 out:
        if (list_empty(&kiblnd_data.kib_devs))
                kiblnd_base_shutdown();
-       return;
 }
 
 static int
@@ -2872,7 +2868,7 @@ kiblnd_base_startup(void)
        int                     rc;
        int                     i;
 
-       LASSERT (kiblnd_data.kib_init == IBLND_INIT_NOTHING);
+       LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING);
 
        try_module_get(THIS_MODULE);
        memset(&kiblnd_data, 0, sizeof(kiblnd_data)); /* zero pointers, flags etc */
@@ -2974,12 +2970,13 @@ kiblnd_start_schedulers(struct kib_sched_info *sched)
        } else {
                LASSERT(sched->ibs_nthreads <= sched->ibs_nthreads_max);
                /* increase one thread if there is new interface */
-               nthrs = (sched->ibs_nthreads < sched->ibs_nthreads_max);
+               nthrs = sched->ibs_nthreads < sched->ibs_nthreads_max;
        }
 
        for (i = 0; i < nthrs; i++) {
                long    id;
                char    name[20];
+
                id = KIB_THREAD_ID(sched->ibs_cpt, sched->ibs_nthreads + i);
                snprintf(name, sizeof(name), "kiblnd_sd_%02ld_%02ld",
                         KIB_THREAD_CPT(id), KIB_THREAD_TID(id));
@@ -3056,7 +3053,7 @@ kiblnd_dev_search(char *ifname)
 }
 
 int
-kiblnd_startup (lnet_ni_t *ni)
+kiblnd_startup(lnet_ni_t *ni)
 {
        char                 *ifname;
        kib_dev_t               *ibdev = NULL;
@@ -3066,7 +3063,7 @@ kiblnd_startup (lnet_ni_t *ni)
        int                    rc;
        int                       newdev;
 
-       LASSERT (ni->ni_lnd == &the_o2iblnd);
+       LASSERT(ni->ni_lnd == &the_o2iblnd);
 
        if (kiblnd_data.kib_init == IBLND_INIT_NOTHING) {
                rc = kiblnd_base_startup();
@@ -3090,7 +3087,7 @@ kiblnd_startup (lnet_ni_t *ni)
        if (ni->ni_interfaces[0] != NULL) {
                /* Use the IPoIB interface specified in 'networks=' */
 
-               CLASSERT (LNET_MAX_INTERFACES > 1);
+               CLASSERT(LNET_MAX_INTERFACES > 1);
                if (ni->ni_interfaces[1] != NULL) {
                        CERROR("Multiple interfaces not supported\n");
                        goto failed;
@@ -3151,20 +3148,20 @@ net_failed:
 }
 
 static void __exit
-kiblnd_module_fini (void)
+kiblnd_module_fini(void)
 {
        lnet_unregister_lnd(&the_o2iblnd);
 }
 
 static int __init
-kiblnd_module_init (void)
+kiblnd_module_init(void)
 {
        int    rc;
 
-       CLASSERT (sizeof(kib_msg_t) <= IBLND_MSG_SIZE);
-       CLASSERT (offsetof(kib_msg_t, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
+       CLASSERT(sizeof(kib_msg_t) <= IBLND_MSG_SIZE);
+       CLASSERT(offsetof(kib_msg_t, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
                  <= IBLND_MSG_SIZE);
-       CLASSERT (offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
+       CLASSERT(offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
                  <= IBLND_MSG_SIZE);
 
        rc = kiblnd_tunables_init();
index ab128dee9483bb7784e6ede69256f449e8d26dab..cd664d025f418da9f118423061f01d6670adfd36 100644 (file)
@@ -46,8 +46,8 @@
 #include <linux/errno.h>
 #include <linux/unistd.h>
 #include <linux/uio.h>
+#include <linux/uaccess.h>
 
-#include <asm/uaccess.h>
 #include <asm/io.h>
 
 #include <linux/fs.h>
index 48d885dc51d93abf9c3504de3ea319433ef46388..2e156a995e55589d36000cf3ffb9f024f05fe494 100644 (file)
 #include "o2iblnd.h"
 
 static void
-kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
+kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx)
 {
        lnet_msg_t *lntmsg[2];
        kib_net_t  *net = ni->ni_data;
        int      rc;
        int      i;
 
-       LASSERT (net != NULL);
-       LASSERT (!in_interrupt());
-       LASSERT (!tx->tx_queued);              /* mustn't be queued for sending */
-       LASSERT (tx->tx_sending == 0);    /* mustn't be awaiting sent callback */
-       LASSERT (!tx->tx_waiting);            /* mustn't be awaiting peer response */
-       LASSERT (tx->tx_pool != NULL);
+       LASSERT(net != NULL);
+       LASSERT(!in_interrupt());
+       LASSERT(!tx->tx_queued);               /* mustn't be queued for sending */
+       LASSERT(tx->tx_sending == 0);     /* mustn't be awaiting sent callback */
+       LASSERT(!tx->tx_waiting);             /* mustn't be awaiting peer response */
+       LASSERT(tx->tx_pool != NULL);
 
        kiblnd_unmap_tx(ni, tx);
 
@@ -63,7 +63,7 @@ kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
        rc = tx->tx_status;
 
        if (tx->tx_conn != NULL) {
-               LASSERT (ni == tx->tx_conn->ibc_peer->ibp_ni);
+               LASSERT(ni == tx->tx_conn->ibc_peer->ibp_ni);
 
                kiblnd_conn_decref(tx->tx_conn);
                tx->tx_conn = NULL;
@@ -84,12 +84,12 @@ kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
 }
 
 void
-kiblnd_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int status)
+kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status)
 {
        kib_tx_t *tx;
 
-       while (!list_empty (txlist)) {
-               tx = list_entry (txlist->next, kib_tx_t, tx_list);
+       while (!list_empty(txlist)) {
+               tx = list_entry(txlist->next, kib_tx_t, tx_list);
 
                list_del(&tx->tx_list);
                /* complete now */
@@ -113,16 +113,16 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
                return NULL;
        tx = container_of(node, kib_tx_t, tx_list);
 
-       LASSERT (tx->tx_nwrq == 0);
-       LASSERT (!tx->tx_queued);
-       LASSERT (tx->tx_sending == 0);
-       LASSERT (!tx->tx_waiting);
-       LASSERT (tx->tx_status == 0);
-       LASSERT (tx->tx_conn == NULL);
-       LASSERT (tx->tx_lntmsg[0] == NULL);
-       LASSERT (tx->tx_lntmsg[1] == NULL);
-       LASSERT (tx->tx_u.pmr == NULL);
-       LASSERT (tx->tx_nfrags == 0);
+       LASSERT(tx->tx_nwrq == 0);
+       LASSERT(!tx->tx_queued);
+       LASSERT(tx->tx_sending == 0);
+       LASSERT(!tx->tx_waiting);
+       LASSERT(tx->tx_status == 0);
+       LASSERT(tx->tx_conn == NULL);
+       LASSERT(tx->tx_lntmsg[0] == NULL);
+       LASSERT(tx->tx_lntmsg[1] == NULL);
+       LASSERT(tx->tx_u.pmr == NULL);
+       LASSERT(tx->tx_nfrags == 0);
 
        return tx;
 }
@@ -143,7 +143,7 @@ kiblnd_drop_rx(kib_rx_t *rx)
 }
 
 int
-kiblnd_post_rx (kib_rx_t *rx, int credit)
+kiblnd_post_rx(kib_rx_t *rx, int credit)
 {
        kib_conn_t       *conn = rx->rx_conn;
        kib_net_t         *net = conn->ibc_peer->ibp_ni->ni_data;
@@ -151,14 +151,14 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
        struct ib_mr       *mr;
        int              rc;
 
-       LASSERT (net != NULL);
-       LASSERT (!in_interrupt());
-       LASSERT (credit == IBLND_POSTRX_NO_CREDIT ||
+       LASSERT(net != NULL);
+       LASSERT(!in_interrupt());
+       LASSERT(credit == IBLND_POSTRX_NO_CREDIT ||
                 credit == IBLND_POSTRX_PEER_CREDIT ||
                 credit == IBLND_POSTRX_RSRVD_CREDIT);
 
        mr = kiblnd_find_dma_mr(conn->ibc_hdev, rx->rx_msgaddr, IBLND_MSG_SIZE);
-       LASSERT (mr != NULL);
+       LASSERT(mr != NULL);
 
        rx->rx_sge.lkey   = mr->lkey;
        rx->rx_sge.addr   = rx->rx_msgaddr;
@@ -169,8 +169,8 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
        rx->rx_wrq.num_sge = 1;
        rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX);
 
-       LASSERT (conn->ibc_state >= IBLND_CONN_INIT);
-       LASSERT (rx->rx_nob >= 0);            /* not posted */
+       LASSERT(conn->ibc_state >= IBLND_CONN_INIT);
+       LASSERT(rx->rx_nob >= 0);             /* not posted */
 
        if (conn->ibc_state > IBLND_CONN_ESTABLISHED) {
                kiblnd_drop_rx(rx);          /* No more posts for this rx */
@@ -217,8 +217,8 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
        list_for_each(tmp, &conn->ibc_active_txs) {
                kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list);
 
-               LASSERT (!tx->tx_queued);
-               LASSERT (tx->tx_sending != 0 || tx->tx_waiting);
+               LASSERT(!tx->tx_queued);
+               LASSERT(tx->tx_sending != 0 || tx->tx_waiting);
 
                if (tx->tx_cookie != cookie)
                        continue;
@@ -293,7 +293,7 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie)
 }
 
 static void
-kiblnd_handle_rx (kib_rx_t *rx)
+kiblnd_handle_rx(kib_rx_t *rx)
 {
        kib_msg_t    *msg = rx->rx_msg;
        kib_conn_t   *conn = rx->rx_conn;
@@ -304,9 +304,9 @@ kiblnd_handle_rx (kib_rx_t *rx)
        int        rc2;
        int        post_credit;
 
-       LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
+       LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
-       CDEBUG (D_NET, "Received %x[%d] from %s\n",
+       CDEBUG(D_NET, "Received %x[%d] from %s\n",
                msg->ibm_type, credits,
                libcfs_nid2str(conn->ibc_peer->ibp_nid));
 
@@ -377,7 +377,7 @@ kiblnd_handle_rx (kib_rx_t *rx)
                break;
 
        case IBLND_MSG_PUT_NAK:
-               CWARN ("PUT_NACK from %s\n",
+               CWARN("PUT_NACK from %s\n",
                       libcfs_nid2str(conn->ibc_peer->ibp_nid));
                post_credit = IBLND_POSTRX_RSRVD_CREDIT;
                kiblnd_handle_completion(conn, IBLND_MSG_PUT_REQ,
@@ -402,7 +402,7 @@ kiblnd_handle_rx (kib_rx_t *rx)
                        break;
                }
 
-               LASSERT (tx->tx_waiting);
+               LASSERT(tx->tx_waiting);
                /* CAVEAT EMPTOR: I could be racing with tx_complete, but...
                 * (a) I can overwrite tx_msg since my peer has received it!
                 * (b) tx_waiting set tells tx_complete() it's not done. */
@@ -454,7 +454,7 @@ kiblnd_handle_rx (kib_rx_t *rx)
 }
 
 static void
-kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
+kiblnd_rx_complete(kib_rx_t *rx, int status, int nob)
 {
        kib_msg_t    *msg = rx->rx_msg;
        kib_conn_t   *conn = rx->rx_conn;
@@ -463,8 +463,8 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
        int        rc;
        int        err = -EIO;
 
-       LASSERT (net != NULL);
-       LASSERT (rx->rx_nob < 0);              /* was posted */
+       LASSERT(net != NULL);
+       LASSERT(rx->rx_nob < 0);               /* was posted */
        rx->rx_nob = 0;                  /* isn't now */
 
        if (conn->ibc_state > IBLND_CONN_ESTABLISHED)
@@ -476,12 +476,12 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
                goto failed;
        }
 
-       LASSERT (nob >= 0);
+       LASSERT(nob >= 0);
        rx->rx_nob = nob;
 
        rc = kiblnd_unpack_msg(msg, rx->rx_nob);
        if (rc != 0) {
-               CERROR ("Error %d unpacking rx from %s\n",
+               CERROR("Error %d unpacking rx from %s\n",
                        rc, libcfs_nid2str(conn->ibc_peer->ibp_nid));
                goto failed;
        }
@@ -490,7 +490,7 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
            msg->ibm_dstnid != ni->ni_nid ||
            msg->ibm_srcstamp != conn->ibc_incarnation ||
            msg->ibm_dststamp != net->ibn_incarnation) {
-               CERROR ("Stale rx from %s\n",
+               CERROR("Stale rx from %s\n",
                        libcfs_nid2str(conn->ibc_peer->ibp_nid));
                err = -ESTALE;
                goto failed;
@@ -525,13 +525,13 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
 }
 
 static struct page *
-kiblnd_kvaddr_to_page (unsigned long vaddr)
+kiblnd_kvaddr_to_page(unsigned long vaddr)
 {
        struct page *page;
 
        if (is_vmalloc_addr((void *)vaddr)) {
-               page = vmalloc_to_page ((void *)vaddr);
-               LASSERT (page != NULL);
+               page = vmalloc_to_page((void *)vaddr);
+               LASSERT(page != NULL);
                return page;
        }
 #ifdef CONFIG_HIGHMEM
@@ -542,8 +542,8 @@ kiblnd_kvaddr_to_page (unsigned long vaddr)
                LBUG();
        }
 #endif
-       page = virt_to_page (vaddr);
-       LASSERT (page != NULL);
+       page = virt_to_page(vaddr);
+       LASSERT(page != NULL);
        return page;
 }
 
@@ -577,7 +577,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
        fps = net->ibn_fmr_ps[cpt];
        rc = kiblnd_fmr_pool_map(fps, pages, npages, 0, &tx->tx_u.fmr);
        if (rc != 0) {
-               CERROR ("Can't map %d pages: %d\n", npages, rc);
+               CERROR("Can't map %d pages: %d\n", npages, rc);
                return rc;
        }
 
@@ -706,26 +706,26 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
        int              fragnob;
        int              page_offset;
 
-       LASSERT (nob > 0);
-       LASSERT (niov > 0);
-       LASSERT (net != NULL);
+       LASSERT(nob > 0);
+       LASSERT(niov > 0);
+       LASSERT(net != NULL);
 
        while (offset >= iov->iov_len) {
                offset -= iov->iov_len;
                niov--;
                iov++;
-               LASSERT (niov > 0);
+               LASSERT(niov > 0);
        }
 
        sg = tx->tx_frags;
        do {
-               LASSERT (niov > 0);
+               LASSERT(niov > 0);
 
                vaddr = ((unsigned long)iov->iov_base) + offset;
                page_offset = vaddr & (PAGE_SIZE - 1);
                page = kiblnd_kvaddr_to_page(vaddr);
                if (page == NULL) {
-                       CERROR ("Can't find page\n");
+                       CERROR("Can't find page\n");
                        return -EFAULT;
                }
 
@@ -749,7 +749,7 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
 }
 
 static int
-kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
+kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
                      int nkiov, lnet_kiov_t *kiov, int offset, int nob)
 {
        kib_net_t         *net = ni->ni_data;
@@ -758,20 +758,20 @@ kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
 
        CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob);
 
-       LASSERT (nob > 0);
-       LASSERT (nkiov > 0);
-       LASSERT (net != NULL);
+       LASSERT(nob > 0);
+       LASSERT(nkiov > 0);
+       LASSERT(net != NULL);
 
        while (offset >= kiov->kiov_len) {
                offset -= kiov->kiov_len;
                nkiov--;
                kiov++;
-               LASSERT (nkiov > 0);
+               LASSERT(nkiov > 0);
        }
 
        sg = tx->tx_frags;
        do {
-               LASSERT (nkiov > 0);
+               LASSERT(nkiov > 0);
 
                fragnob = min((int)(kiov->kiov_len - offset), nob);
 
@@ -789,7 +789,7 @@ kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
 }
 
 static int
-kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
+kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
        __releases(conn->ibc_lock)
        __acquires(conn->ibc_lock)
 {
@@ -800,16 +800,16 @@ kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
        int             done;
        struct ib_send_wr *bad_wrq;
 
-       LASSERT (tx->tx_queued);
+       LASSERT(tx->tx_queued);
        /* We rely on this for QP sizing */
-       LASSERT (tx->tx_nwrq > 0);
-       LASSERT (tx->tx_nwrq <= 1 + IBLND_RDMA_FRAGS(ver));
+       LASSERT(tx->tx_nwrq > 0);
+       LASSERT(tx->tx_nwrq <= 1 + IBLND_RDMA_FRAGS(ver));
 
-       LASSERT (credit == 0 || credit == 1);
-       LASSERT (conn->ibc_outstanding_credits >= 0);
-       LASSERT (conn->ibc_outstanding_credits <= IBLND_MSG_QUEUE_SIZE(ver));
-       LASSERT (conn->ibc_credits >= 0);
-       LASSERT (conn->ibc_credits <= IBLND_MSG_QUEUE_SIZE(ver));
+       LASSERT(credit == 0 || credit == 1);
+       LASSERT(conn->ibc_outstanding_credits >= 0);
+       LASSERT(conn->ibc_outstanding_credits <= IBLND_MSG_QUEUE_SIZE(ver));
+       LASSERT(conn->ibc_credits >= 0);
+       LASSERT(conn->ibc_credits <= IBLND_MSG_QUEUE_SIZE(ver));
 
        if (conn->ibc_nsends_posted == IBLND_CONCURRENT_SENDS(ver)) {
                /* tx completions outstanding... */
@@ -923,7 +923,7 @@ kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
 }
 
 void
-kiblnd_check_sends (kib_conn_t *conn)
+kiblnd_check_sends(kib_conn_t *conn)
 {
        int     ver = conn->ibc_version;
        lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
@@ -938,10 +938,10 @@ kiblnd_check_sends (kib_conn_t *conn)
 
        spin_lock(&conn->ibc_lock);
 
-       LASSERT (conn->ibc_nsends_posted <= IBLND_CONCURRENT_SENDS(ver));
-       LASSERT (!IBLND_OOB_CAPABLE(ver) ||
+       LASSERT(conn->ibc_nsends_posted <= IBLND_CONCURRENT_SENDS(ver));
+       LASSERT(!IBLND_OOB_CAPABLE(ver) ||
                 conn->ibc_noops_posted <= IBLND_OOB_MSGS(ver));
-       LASSERT (conn->ibc_reserved_credits >= 0);
+       LASSERT(conn->ibc_reserved_credits >= 0);
 
        while (conn->ibc_reserved_credits > 0 &&
               !list_empty(&conn->ibc_tx_queue_rsrvd)) {
@@ -974,7 +974,7 @@ kiblnd_check_sends (kib_conn_t *conn)
                        tx = list_entry(conn->ibc_tx_queue_nocred.next,
                                            kib_tx_t, tx_list);
                } else if (!list_empty(&conn->ibc_tx_noops)) {
-                       LASSERT (!IBLND_OOB_CAPABLE(ver));
+                       LASSERT(!IBLND_OOB_CAPABLE(ver));
                        credit = 1;
                        tx = list_entry(conn->ibc_tx_noops.next,
                                        kib_tx_t, tx_list);
@@ -995,13 +995,13 @@ kiblnd_check_sends (kib_conn_t *conn)
 }
 
 static void
-kiblnd_tx_complete (kib_tx_t *tx, int status)
+kiblnd_tx_complete(kib_tx_t *tx, int status)
 {
        int        failed = (status != IB_WC_SUCCESS);
        kib_conn_t   *conn = tx->tx_conn;
        int        idle;
 
-       LASSERT (tx->tx_sending > 0);
+       LASSERT(tx->tx_sending > 0);
 
        if (failed) {
                if (conn->ibc_state == IBLND_CONN_ESTABLISHED)
@@ -1049,22 +1049,22 @@ kiblnd_tx_complete (kib_tx_t *tx, int status)
 }
 
 void
-kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
+kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
 {
        kib_hca_dev_t     *hdev = tx->tx_pool->tpo_hdev;
        struct ib_sge     *sge = &tx->tx_sge[tx->tx_nwrq];
        struct ib_send_wr *wrq = &tx->tx_wrq[tx->tx_nwrq];
-       int             nob = offsetof (kib_msg_t, ibm_u) + body_nob;
+       int             nob = offsetof(kib_msg_t, ibm_u) + body_nob;
        struct ib_mr      *mr;
 
-       LASSERT (tx->tx_nwrq >= 0);
-       LASSERT (tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1);
-       LASSERT (nob <= IBLND_MSG_SIZE);
+       LASSERT(tx->tx_nwrq >= 0);
+       LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1);
+       LASSERT(nob <= IBLND_MSG_SIZE);
 
        kiblnd_init_msg(tx->tx_msg, type, body_nob);
 
        mr = kiblnd_find_dma_mr(hdev, tx->tx_msgaddr, nob);
-       LASSERT (mr != NULL);
+       LASSERT(mr != NULL);
 
        sge->lkey   = mr->lkey;
        sge->addr   = tx->tx_msgaddr;
@@ -1083,7 +1083,7 @@ kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
 }
 
 int
-kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
+kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
                  int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie)
 {
        kib_msg_t        *ibmsg = tx->tx_msg;
@@ -1095,9 +1095,9 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
        int             dstidx;
        int             wrknob;
 
-       LASSERT (!in_interrupt());
-       LASSERT (tx->tx_nwrq == 0);
-       LASSERT (type == IBLND_MSG_GET_DONE ||
+       LASSERT(!in_interrupt());
+       LASSERT(tx->tx_nwrq == 0);
+       LASSERT(type == IBLND_MSG_GET_DONE ||
                 type == IBLND_MSG_PUT_DONE);
 
        srcidx = dstidx = 0;
@@ -1162,19 +1162,19 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
        ibmsg->ibm_u.completion.ibcm_status = rc;
        ibmsg->ibm_u.completion.ibcm_cookie = dstcookie;
        kiblnd_init_tx_msg(conn->ibc_peer->ibp_ni, tx,
-                          type, sizeof (kib_completion_msg_t));
+                          type, sizeof(kib_completion_msg_t));
 
        return rc;
 }
 
 void
-kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
+kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn)
 {
        struct list_head   *q;
 
-       LASSERT (tx->tx_nwrq > 0);            /* work items set up */
-       LASSERT (!tx->tx_queued);              /* not queued for sending already */
-       LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
+       LASSERT(tx->tx_nwrq > 0);             /* work items set up */
+       LASSERT(!tx->tx_queued);               /* not queued for sending already */
+       LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        tx->tx_queued = 1;
        tx->tx_deadline = jiffies + (*kiblnd_tunables.kib_timeout * HZ);
@@ -1182,11 +1182,11 @@ kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
        if (tx->tx_conn == NULL) {
                kiblnd_conn_addref(conn);
                tx->tx_conn = conn;
-               LASSERT (tx->tx_msg->ibm_type != IBLND_MSG_PUT_DONE);
+               LASSERT(tx->tx_msg->ibm_type != IBLND_MSG_PUT_DONE);
        } else {
                /* PUT_DONE first attached to conn as a PUT_REQ */
-               LASSERT (tx->tx_conn == conn);
-               LASSERT (tx->tx_msg->ibm_type == IBLND_MSG_PUT_DONE);
+               LASSERT(tx->tx_conn == conn);
+               LASSERT(tx->tx_msg->ibm_type == IBLND_MSG_PUT_DONE);
        }
 
        switch (tx->tx_msg->ibm_type) {
@@ -1221,7 +1221,7 @@ kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
 }
 
 void
-kiblnd_queue_tx (kib_tx_t *tx, kib_conn_t *conn)
+kiblnd_queue_tx(kib_tx_t *tx, kib_conn_t *conn)
 {
        spin_lock(&conn->ibc_lock);
        kiblnd_queue_tx_locked(tx, conn);
@@ -1268,7 +1268,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid,
 }
 
 static void
-kiblnd_connect_peer (kib_peer_t *peer)
+kiblnd_connect_peer(kib_peer_t *peer)
 {
        struct rdma_cm_id *cmid;
        kib_dev_t        *dev;
@@ -1277,8 +1277,8 @@ kiblnd_connect_peer (kib_peer_t *peer)
        struct sockaddr_in dstaddr;
        int             rc;
 
-       LASSERT (net != NULL);
-       LASSERT (peer->ibp_connecting > 0);
+       LASSERT(net != NULL);
+       LASSERT(peer->ibp_connecting > 0);
 
        cmid = kiblnd_rdma_create_id(kiblnd_cm_callback, peer, RDMA_PS_TCP,
                                     IB_QPT_RC);
@@ -1318,7 +1318,7 @@ kiblnd_connect_peer (kib_peer_t *peer)
                goto failed2;
        }
 
-       LASSERT (cmid->device != NULL);
+       LASSERT(cmid->device != NULL);
        CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n",
               libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
               &dev->ibd_ifip, cmid->device->name);
@@ -1333,7 +1333,7 @@ kiblnd_connect_peer (kib_peer_t *peer)
 }
 
 void
-kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
+kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 {
        kib_peer_t      *peer;
        kib_peer_t      *peer2;
@@ -1345,8 +1345,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
        /* If I get here, I've committed to send, so I complete the tx with
         * failure on any problems */
 
-       LASSERT (tx == NULL || tx->tx_conn == NULL); /* only set when assigned a conn */
-       LASSERT (tx == NULL || tx->tx_nwrq > 0);     /* work items have been set up */
+       LASSERT(tx == NULL || tx->tx_conn == NULL); /* only set when assigned a conn */
+       LASSERT(tx == NULL || tx->tx_nwrq > 0);     /* work items have been set up */
 
        /* First time, just use a read lock since I expect to find my peer
         * connected */
@@ -1374,7 +1374,7 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
        if (peer != NULL) {
                if (list_empty(&peer->ibp_conns)) {
                        /* found a peer, but it's still connecting... */
-                       LASSERT (peer->ibp_connecting != 0 ||
+                       LASSERT(peer->ibp_connecting != 0 ||
                                 peer->ibp_accepting != 0);
                        if (tx != NULL)
                                list_add_tail(&tx->tx_list,
@@ -1413,7 +1413,7 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
        if (peer2 != NULL) {
                if (list_empty(&peer2->ibp_conns)) {
                        /* found a peer, but it's still connecting... */
-                       LASSERT (peer2->ibp_connecting != 0 ||
+                       LASSERT(peer2->ibp_connecting != 0 ||
                                 peer2->ibp_accepting != 0);
                        if (tx != NULL)
                                list_add_tail(&tx->tx_list,
@@ -1435,11 +1435,11 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
        }
 
        /* Brand new peer */
-       LASSERT (peer->ibp_connecting == 0);
+       LASSERT(peer->ibp_connecting == 0);
        peer->ibp_connecting = 1;
 
        /* always called with a ref on ni, which prevents ni being shutdown */
-       LASSERT (((kib_net_t *)ni->ni_data)->ibn_shutdown == 0);
+       LASSERT(((kib_net_t *)ni->ni_data)->ibn_shutdown == 0);
 
        if (tx != NULL)
                list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
@@ -1454,7 +1454,7 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 }
 
 int
-kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
+kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 {
        lnet_hdr_t       *hdr = &lntmsg->msg_hdr;
        int            type = lntmsg->msg_type;
@@ -1476,13 +1476,13 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
        CDEBUG(D_NET, "sending %d bytes in %d frags to %s\n",
               payload_nob, payload_niov, libcfs_id2str(target));
 
-       LASSERT (payload_nob == 0 || payload_niov > 0);
-       LASSERT (payload_niov <= LNET_MAX_IOV);
+       LASSERT(payload_nob == 0 || payload_niov > 0);
+       LASSERT(payload_niov <= LNET_MAX_IOV);
 
        /* Thread context */
-       LASSERT (!in_interrupt());
+       LASSERT(!in_interrupt());
        /* payload is either all vaddrs or all pages */
-       LASSERT (!(payload_kiov != NULL && payload_iov != NULL));
+       LASSERT(!(payload_kiov != NULL && payload_iov != NULL));
 
        switch (type) {
        default:
@@ -1490,7 +1490,7 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                return -EIO;
 
        case LNET_MSG_ACK:
-               LASSERT (payload_nob == 0);
+               LASSERT(payload_nob == 0);
                break;
 
        case LNET_MSG_GET:
@@ -1592,12 +1592,12 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 
        /* send IMMEDIATE */
 
-       LASSERT (offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob])
+       LASSERT(offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob])
                 <= IBLND_MSG_SIZE);
 
        tx = kiblnd_get_idle_tx(ni, target.nid);
        if (tx == NULL) {
-               CERROR ("Can't send %d to %s: tx descs exhausted\n",
+               CERROR("Can't send %d to %s: tx descs exhausted\n",
                        type, libcfs_nid2str(target.nid));
                return -ENOMEM;
        }
@@ -1625,7 +1625,7 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
 }
 
 static void
-kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
+kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
 {
        lnet_process_id_t target = lntmsg->msg_target;
        unsigned int      niov = lntmsg->msg_niov;
@@ -1687,7 +1687,7 @@ kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
 }
 
 int
-kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
+kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
             unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
             unsigned int offset, unsigned int mlen, unsigned int rlen)
 {
@@ -1700,10 +1700,10 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
        int       post_credit = IBLND_POSTRX_PEER_CREDIT;
        int       rc = 0;
 
-       LASSERT (mlen <= rlen);
-       LASSERT (!in_interrupt());
+       LASSERT(mlen <= rlen);
+       LASSERT(!in_interrupt());
        /* Either all pages or all vaddrs */
-       LASSERT (!(kiov != NULL && iov != NULL));
+       LASSERT(!(kiov != NULL && iov != NULL));
 
        switch (rxmsg->ibm_type) {
        default:
@@ -1712,7 +1712,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
        case IBLND_MSG_IMMEDIATE:
                nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[rlen]);
                if (nob > rx->rx_nob) {
-                       CERROR ("Immediate message from %s too big: %d(%d)\n",
+                       CERROR("Immediate message from %s too big: %d(%d)\n",
                                libcfs_nid2str(rxmsg->ibm_u.immediate.ibim_hdr.src_nid),
                                nob, rx->rx_nob);
                        rc = -EPROTO;
@@ -1729,7 +1729,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
                                           IBLND_MSG_SIZE, rxmsg,
                                           offsetof(kib_msg_t, ibm_u.immediate.ibim_payload),
                                           mlen);
-               lnet_finalize (ni, lntmsg, 0);
+               lnet_finalize(ni, lntmsg, 0);
                break;
 
        case IBLND_MSG_PUT_REQ:
@@ -1812,13 +1812,13 @@ kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name)
 }
 
 static void
-kiblnd_thread_fini (void)
+kiblnd_thread_fini(void)
 {
-       atomic_dec (&kiblnd_data.kib_nthreads);
+       atomic_dec(&kiblnd_data.kib_nthreads);
 }
 
 void
-kiblnd_peer_alive (kib_peer_t *peer)
+kiblnd_peer_alive(kib_peer_t *peer)
 {
        /* This is racy, but everyone's only writing cfs_time_current() */
        peer->ibp_last_alive = cfs_time_current();
@@ -1826,7 +1826,7 @@ kiblnd_peer_alive (kib_peer_t *peer)
 }
 
 static void
-kiblnd_peer_notify (kib_peer_t *peer)
+kiblnd_peer_notify(kib_peer_t *peer)
 {
        int        error = 0;
        unsigned long    last_alive = 0;
@@ -1852,7 +1852,7 @@ kiblnd_peer_notify (kib_peer_t *peer)
 }
 
 void
-kiblnd_close_conn_locked (kib_conn_t *conn, int error)
+kiblnd_close_conn_locked(kib_conn_t *conn, int error)
 {
        /* This just does the immediate housekeeping.  'error' is zero for a
         * normal shutdown which can happen only after the connection has been
@@ -1864,7 +1864,7 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
        kib_dev_t       *dev;
        unsigned long     flags;
 
-       LASSERT (error != 0 || conn->ibc_state >= IBLND_CONN_ESTABLISHED);
+       LASSERT(error != 0 || conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        if (error != 0 && conn->ibc_comms_error == 0)
                conn->ibc_comms_error = error;
@@ -1894,7 +1894,7 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
        list_del(&conn->ibc_list);
        /* connd (see below) takes over ibc_list's ref */
 
-       if (list_empty (&peer->ibp_conns) &&    /* no more conns */
+       if (list_empty(&peer->ibp_conns) &&    /* no more conns */
            kiblnd_peer_active(peer)) {  /* still in peer table */
                kiblnd_unlink_peer_locked(peer);
 
@@ -1936,14 +1936,13 @@ kiblnd_handle_early_rxs(kib_conn_t *conn)
 {
        unsigned long    flags;
        kib_rx_t        *rx;
+       kib_rx_t *tmp;
 
        LASSERT(!in_interrupt());
        LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
-       while (!list_empty(&conn->ibc_early_rxs)) {
-               rx = list_entry(conn->ibc_early_rxs.next,
-                                   kib_rx_t, rx_list);
+       list_for_each_entry_safe(rx, tmp, &conn->ibc_early_rxs, rx_list) {
                list_del(&rx->rx_list);
                write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
@@ -1957,22 +1956,22 @@ kiblnd_handle_early_rxs(kib_conn_t *conn)
 static void
 kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
 {
-       LIST_HEAD       (zombies);
+       LIST_HEAD(zombies);
        struct list_head          *tmp;
        struct list_head          *nxt;
        kib_tx_t            *tx;
 
        spin_lock(&conn->ibc_lock);
 
-       list_for_each_safe (tmp, nxt, txs) {
-               tx = list_entry (tmp, kib_tx_t, tx_list);
+       list_for_each_safe(tmp, nxt, txs) {
+               tx = list_entry(tmp, kib_tx_t, tx_list);
 
                if (txs == &conn->ibc_active_txs) {
-                       LASSERT (!tx->tx_queued);
-                       LASSERT (tx->tx_waiting ||
+                       LASSERT(!tx->tx_queued);
+                       LASSERT(tx->tx_waiting ||
                                 tx->tx_sending != 0);
                } else {
-                       LASSERT (tx->tx_queued);
+                       LASSERT(tx->tx_queued);
                }
 
                tx->tx_status = -ECONNABORTED;
@@ -1980,8 +1979,8 @@ kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
 
                if (tx->tx_sending == 0) {
                        tx->tx_queued = 0;
-                       list_del (&tx->tx_list);
-                       list_add (&tx->tx_list, &zombies);
+                       list_del(&tx->tx_list);
+                       list_add(&tx->tx_list, &zombies);
                }
        }
 
@@ -1991,10 +1990,10 @@ kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
 }
 
 static void
-kiblnd_finalise_conn (kib_conn_t *conn)
+kiblnd_finalise_conn(kib_conn_t *conn)
 {
-       LASSERT (!in_interrupt());
-       LASSERT (conn->ibc_state > IBLND_CONN_INIT);
+       LASSERT(!in_interrupt());
+       LASSERT(conn->ibc_state > IBLND_CONN_INIT);
 
        kiblnd_set_conn_state(conn, IBLND_CONN_DISCONNECTED);
 
@@ -2016,21 +2015,21 @@ kiblnd_finalise_conn (kib_conn_t *conn)
 }
 
 void
-kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error)
+kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error)
 {
-       LIST_HEAD    (zombies);
+       LIST_HEAD(zombies);
        unsigned long     flags;
 
-       LASSERT (error != 0);
-       LASSERT (!in_interrupt());
+       LASSERT(error != 0);
+       LASSERT(!in_interrupt());
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
        if (active) {
-               LASSERT (peer->ibp_connecting > 0);
+               LASSERT(peer->ibp_connecting > 0);
                peer->ibp_connecting--;
        } else {
-               LASSERT (peer->ibp_accepting > 0);
+               LASSERT(peer->ibp_accepting > 0);
                peer->ibp_accepting--;
        }
 
@@ -2053,14 +2052,14 @@ kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error)
                peer->ibp_error = error;
        } else {
                /* Can't have blocked transmits if there are connections */
-               LASSERT (list_empty(&peer->ibp_tx_queue));
+               LASSERT(list_empty(&peer->ibp_tx_queue));
        }
 
        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
        kiblnd_peer_notify(peer);
 
-       if (list_empty (&zombies))
+       if (list_empty(&zombies))
                return;
 
        CNETERR("Deleting messages for %s: connection failed\n",
@@ -2074,6 +2073,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
 {
        kib_peer_t      *peer = conn->ibc_peer;
        kib_tx_t          *tx;
+       kib_tx_t *tmp;
        struct list_head         txs;
        unsigned long      flags;
        int             active;
@@ -2084,8 +2084,8 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
               libcfs_nid2str(peer->ibp_nid), active,
               conn->ibc_version, status);
 
-       LASSERT (!in_interrupt());
-       LASSERT ((conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT &&
+       LASSERT(!in_interrupt());
+       LASSERT((conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT &&
                  peer->ibp_connecting > 0) ||
                 (conn->ibc_state == IBLND_CONN_PASSIVE_WAIT &&
                  peer->ibp_accepting > 0));
@@ -2150,8 +2150,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
 
        /* Schedule blocked txs */
        spin_lock(&conn->ibc_lock);
-       while (!list_empty(&txs)) {
-               tx = list_entry(txs.next, kib_tx_t, tx_list);
+       list_for_each_entry_safe(tx, tmp, &txs, tx_list) {
                list_del(&tx->tx_list);
 
                kiblnd_queue_tx_locked(tx, conn);
@@ -2176,7 +2175,7 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
 }
 
 static int
-kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
+kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
 {
        rwlock_t                *g_lock = &kiblnd_data.kib_global_lock;
        kib_msg_t            *reqmsg = priv;
@@ -2194,11 +2193,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
        unsigned long     flags;
        int                 rc;
        struct sockaddr_in    *peer_addr;
-       LASSERT (!in_interrupt());
+       LASSERT(!in_interrupt());
 
        /* cmid inherits 'context' from the corresponding listener id */
        ibdev = (kib_dev_t *)cmid->context;
-       LASSERT (ibdev != NULL);
+       LASSERT(ibdev != NULL);
 
        memset(&rej, 0, sizeof(rej));
        rej.ibr_magic           = IBLND_MSG_MAGIC;
@@ -2366,8 +2365,8 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                peer = peer2;
        } else {
                /* Brand new peer */
-               LASSERT (peer->ibp_accepting == 0);
-               LASSERT (peer->ibp_version == 0 &&
+               LASSERT(peer->ibp_accepting == 0);
+               LASSERT(peer->ibp_version == 0 &&
                         peer->ibp_incarnation == 0);
 
                peer->ibp_accepting   = 1;
@@ -2375,7 +2374,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                peer->ibp_incarnation = reqmsg->ibm_srcstamp;
 
                /* I have a ref on ni that prevents it being shutdown */
-               LASSERT (net->ibn_shutdown == 0);
+               LASSERT(net->ibn_shutdown == 0);
 
                kiblnd_peer_addref(peer);
                list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
@@ -2397,7 +2396,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
        conn->ibc_incarnation      = reqmsg->ibm_srcstamp;
        conn->ibc_credits         = IBLND_MSG_QUEUE_SIZE(version);
        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(version);
-       LASSERT (conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version)
+       LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version)
                 <= IBLND_RX_MSGS(version));
 
        ackmsg = &conn->ibc_connvars->cv_msg;
@@ -2449,7 +2448,7 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
 }
 
 static void
-kiblnd_reconnect (kib_conn_t *conn, int version,
+kiblnd_reconnect(kib_conn_t *conn, int version,
                  __u64 incarnation, int why, kib_connparams_t *cp)
 {
        kib_peer_t    *peer = conn->ibc_peer;
@@ -2457,8 +2456,8 @@ kiblnd_reconnect (kib_conn_t *conn, int version,
        int         retry = 0;
        unsigned long  flags;
 
-       LASSERT (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
-       LASSERT (peer->ibp_connecting > 0);     /* 'conn' at least */
+       LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
+       LASSERT(peer->ibp_connecting > 0);     /* 'conn' at least */
 
        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
@@ -2512,12 +2511,12 @@ kiblnd_reconnect (kib_conn_t *conn, int version,
 }
 
 static void
-kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob)
+kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
 {
        kib_peer_t    *peer = conn->ibc_peer;
 
-       LASSERT (!in_interrupt());
-       LASSERT (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
+       LASSERT(!in_interrupt());
+       LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
 
        switch (reason) {
        case IB_CM_REJ_STALE_CONN:
@@ -2651,7 +2650,7 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob)
 }
 
 static void
-kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
+kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
 {
        kib_peer_t    *peer = conn->ibc_peer;
        lnet_ni_t     *ni   = peer->ibp_ni;
@@ -2661,7 +2660,7 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
        int         rc   = kiblnd_unpack_msg(msg, priv_nob);
        unsigned long  flags;
 
-       LASSERT (net != NULL);
+       LASSERT(net != NULL);
 
        if (rc != 0) {
                CERROR("Can't unpack connack from %s: %d\n",
@@ -2730,7 +2729,7 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
        conn->ibc_incarnation      = msg->ibm_srcstamp;
        conn->ibc_credits         =
        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(ver);
-       LASSERT (conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver)
+       LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver)
                 <= IBLND_RX_MSGS(ver));
 
        kiblnd_connreq_done(conn, 0);
@@ -2742,13 +2741,13 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
         * kiblnd_connreq_done(0) moves the conn state to ESTABLISHED, but then
         * immediately tears it down. */
 
-       LASSERT (rc != 0);
+       LASSERT(rc != 0);
        conn->ibc_comms_error = rc;
        kiblnd_connreq_done(conn, 0);
 }
 
 static int
-kiblnd_active_connect (struct rdma_cm_id *cmid)
+kiblnd_active_connect(struct rdma_cm_id *cmid)
 {
        kib_peer_t            *peer = (kib_peer_t *)cmid->context;
        kib_conn_t            *conn;
@@ -2913,7 +2912,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                        LBUG();
 
                case IBLND_CONN_PASSIVE_WAIT:
-                       CERROR ("%s: REJECTED %d\n",
+                       CERROR("%s: REJECTED %d\n",
                                libcfs_nid2str(conn->ibc_peer->ibp_nid),
                                event->status);
                        kiblnd_connreq_done(conn, -ECONNRESET);
@@ -2987,17 +2986,17 @@ kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs)
        kib_tx_t          *tx;
        struct list_head        *ttmp;
 
-       list_for_each (ttmp, txs) {
-               tx = list_entry (ttmp, kib_tx_t, tx_list);
+       list_for_each(ttmp, txs) {
+               tx = list_entry(ttmp, kib_tx_t, tx_list);
 
                if (txs != &conn->ibc_active_txs) {
-                       LASSERT (tx->tx_queued);
+                       LASSERT(tx->tx_queued);
                } else {
-                       LASSERT (!tx->tx_queued);
-                       LASSERT (tx->tx_waiting || tx->tx_sending != 0);
+                       LASSERT(!tx->tx_queued);
+                       LASSERT(tx->tx_waiting || tx->tx_sending != 0);
                }
 
-               if (cfs_time_aftereq (jiffies, tx->tx_deadline)) {
+               if (cfs_time_aftereq(jiffies, tx->tx_deadline)) {
                        CERROR("Timed out tx: %s, %lu seconds\n",
                               kiblnd_queue2str(conn, txs),
                               cfs_duration_sec(jiffies - tx->tx_deadline));
@@ -3019,14 +3018,15 @@ kiblnd_conn_timed_out_locked(kib_conn_t *conn)
 }
 
 static void
-kiblnd_check_conns (int idx)
+kiblnd_check_conns(int idx)
 {
-       LIST_HEAD (closes);
-       LIST_HEAD (checksends);
+       LIST_HEAD(closes);
+       LIST_HEAD(checksends);
        struct list_head    *peers = &kiblnd_data.kib_peers[idx];
        struct list_head    *ptmp;
        kib_peer_t    *peer;
        kib_conn_t    *conn;
+       kib_conn_t *tmp;
        struct list_head    *ctmp;
        unsigned long  flags;
 
@@ -3035,16 +3035,16 @@ kiblnd_check_conns (int idx)
         * take a look... */
        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
 
-       list_for_each (ptmp, peers) {
-               peer = list_entry (ptmp, kib_peer_t, ibp_list);
+       list_for_each(ptmp, peers) {
+               peer = list_entry(ptmp, kib_peer_t, ibp_list);
 
-               list_for_each (ctmp, &peer->ibp_conns) {
+               list_for_each(ctmp, &peer->ibp_conns) {
                        int timedout;
                        int sendnoop;
 
                        conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                       LASSERT (conn->ibc_state == IBLND_CONN_ESTABLISHED);
+                       LASSERT(conn->ibc_state == IBLND_CONN_ESTABLISHED);
 
                        spin_lock(&conn->ibc_lock);
 
@@ -3080,9 +3080,7 @@ kiblnd_check_conns (int idx)
        /* Handle timeout by closing the whole
         * connection. We can only be sure RDMA activity
         * has ceased once the QP has been modified. */
-       while (!list_empty(&closes)) {
-               conn = list_entry(closes.next,
-                                     kib_conn_t, ibc_connd_list);
+       list_for_each_entry_safe(conn, tmp, &closes, ibc_connd_list) {
                list_del(&conn->ibc_connd_list);
                kiblnd_close_conn(conn, -ETIMEDOUT);
                kiblnd_conn_decref(conn);
@@ -3101,11 +3099,11 @@ kiblnd_check_conns (int idx)
 }
 
 static void
-kiblnd_disconnect_conn (kib_conn_t *conn)
+kiblnd_disconnect_conn(kib_conn_t *conn)
 {
-       LASSERT (!in_interrupt());
-       LASSERT (current == kiblnd_data.kib_connd);
-       LASSERT (conn->ibc_state == IBLND_CONN_CLOSING);
+       LASSERT(!in_interrupt());
+       LASSERT(current == kiblnd_data.kib_connd);
+       LASSERT(conn->ibc_state == IBLND_CONN_CLOSING);
 
        rdma_disconnect(conn->ibc_cmid);
        kiblnd_finalise_conn(conn);
@@ -3114,7 +3112,7 @@ kiblnd_disconnect_conn (kib_conn_t *conn)
 }
 
 int
-kiblnd_connd (void *arg)
+kiblnd_connd(void *arg)
 {
        wait_queue_t     wait;
        unsigned long      flags;
@@ -3125,7 +3123,7 @@ kiblnd_connd (void *arg)
        int             peer_index = 0;
        unsigned long      deadline = jiffies;
 
-       cfs_block_allsigs ();
+       cfs_block_allsigs();
 
        init_waitqueue_entry(&wait, current);
        kiblnd_data.kib_connd = current;
@@ -3136,7 +3134,7 @@ kiblnd_connd (void *arg)
 
                dropped_lock = 0;
 
-               if (!list_empty (&kiblnd_data.kib_connd_zombies)) {
+               if (!list_empty(&kiblnd_data.kib_connd_zombies)) {
                        conn = list_entry(kiblnd_data. \
                                              kib_connd_zombies.next,
                                              kib_conn_t, ibc_list);
@@ -3239,7 +3237,7 @@ kiblnd_qp_event(struct ib_event *event, void *arg)
 }
 
 static void
-kiblnd_complete (struct ib_wc *wc)
+kiblnd_complete(struct ib_wc *wc)
 {
        switch (kiblnd_wreqid2type(wc->wr_id)) {
        default:
@@ -3440,9 +3438,9 @@ kiblnd_failover_thread(void *arg)
        unsigned long      flags;
        int             rc;
 
-       LASSERT (*kiblnd_tunables.kib_dev_failover != 0);
+       LASSERT(*kiblnd_tunables.kib_dev_failover != 0);
 
-       cfs_block_allsigs ();
+       cfs_block_allsigs();
 
        init_waitqueue_entry(&wait, current);
        write_lock_irqsave(glock, flags);
@@ -3469,7 +3467,7 @@ kiblnd_failover_thread(void *arg)
 
                        write_lock_irqsave(glock, flags);
 
-                       LASSERT (dev->ibd_failover);
+                       LASSERT(dev->ibd_failover);
                        dev->ibd_failover = 0;
                        if (rc >= 0) { /* Device is OK or failover succeed */
                                dev->ibd_next_failover = cfs_time_shift(3);
index 8b4a8e9a29b4dddb0f79bfefb785d8b1a37c779e..eedf01afd57f72d74a91e55e88d2a28b4774c75d 100644 (file)
@@ -44,7 +44,7 @@ static int service = 987;
 module_param(service, int, 0444);
 MODULE_PARM_DESC(service, "service number (within RDMA_PS_TCP)");
 
-static int cksum = 0;
+static int cksum;
 module_param(cksum, int, 0644);
 MODULE_PARM_DESC(cksum, "set non-zero to enable message (not RDMA) checksums");
 
@@ -72,11 +72,11 @@ static int peer_credits = 8;
 module_param(peer_credits, int, 0444);
 MODULE_PARM_DESC(peer_credits, "# concurrent sends to 1 peer");
 
-static int peer_credits_hiw = 0;
+static int peer_credits_hiw;
 module_param(peer_credits_hiw, int, 0444);
 MODULE_PARM_DESC(peer_credits_hiw, "when eagerly to return credits");
 
-static int peer_buffer_credits = 0;
+static int peer_buffer_credits;
 module_param(peer_buffer_credits, int, 0444);
 MODULE_PARM_DESC(peer_buffer_credits, "# per-peer router buffer credits");
 
@@ -100,15 +100,15 @@ static int keepalive = 100;
 module_param(keepalive, int, 0644);
 MODULE_PARM_DESC(keepalive, "Idle time in seconds before sending a keepalive");
 
-static int ib_mtu = 0;
+static int ib_mtu;
 module_param(ib_mtu, int, 0444);
 MODULE_PARM_DESC(ib_mtu, "IB MTU 256/512/1024/2048/4096");
 
-static int concurrent_sends = 0;
+static int concurrent_sends;
 module_param(concurrent_sends, int, 0444);
 MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing");
 
-static int map_on_demand = 0;
+static int map_on_demand;
 module_param(map_on_demand, int, 0444);
 MODULE_PARM_DESC(map_on_demand, "map on demand");
 
@@ -136,12 +136,12 @@ MODULE_PARM_DESC(pmr_pool_size, "size of MR cache pmr pool on each CPT");
  * 1: enable failover if necessary
  * 2: force to failover (for debug)
  */
-static int dev_failover = 0;
+static int dev_failover;
 module_param(dev_failover, int, 0444);
 MODULE_PARM_DESC(dev_failover, "HCA failover for bonding (0 off, 1 on, other values reserved)");
 
 
-static int require_privileged_port = 0;
+static int require_privileged_port;
 module_param(require_privileged_port, int, 0644);
 MODULE_PARM_DESC(require_privileged_port, "require privileged port when accepting connection");
 
@@ -177,7 +177,7 @@ kib_tunables_t kiblnd_tunables = {
 };
 
 int
-kiblnd_tunables_init (void)
+kiblnd_tunables_init(void)
 {
        if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
                CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
index 5956dbac5d047c116872843f7e7ed7514e40ac15..7586b7e4040bdc1d6c476c162eea3b19e257cfd8 100644 (file)
@@ -65,15 +65,15 @@ ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip)
 }
 
 static ksock_route_t *
-ksocknal_create_route (__u32 ipaddr, int port)
+ksocknal_create_route(__u32 ipaddr, int port)
 {
        ksock_route_t *route;
 
-       LIBCFS_ALLOC (route, sizeof (*route));
+       LIBCFS_ALLOC(route, sizeof(*route));
        if (route == NULL)
                return NULL;
 
-       atomic_set (&route->ksnr_refcount, 1);
+       atomic_set(&route->ksnr_refcount, 1);
        route->ksnr_peer = NULL;
        route->ksnr_retry_interval = 0;  /* OK to connect at any time */
        route->ksnr_ipaddr = ipaddr;
@@ -89,43 +89,43 @@ ksocknal_create_route (__u32 ipaddr, int port)
 }
 
 void
-ksocknal_destroy_route (ksock_route_t *route)
+ksocknal_destroy_route(ksock_route_t *route)
 {
-       LASSERT (atomic_read(&route->ksnr_refcount) == 0);
+       LASSERT(atomic_read(&route->ksnr_refcount) == 0);
 
        if (route->ksnr_peer != NULL)
                ksocknal_peer_decref(route->ksnr_peer);
 
-       LIBCFS_FREE (route, sizeof (*route));
+       LIBCFS_FREE(route, sizeof(*route));
 }
 
 static int
-ksocknal_create_peer (ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
+ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
 {
        ksock_net_t   *net = ni->ni_data;
        ksock_peer_t  *peer;
 
-       LASSERT (id.nid != LNET_NID_ANY);
-       LASSERT (id.pid != LNET_PID_ANY);
-       LASSERT (!in_interrupt());
+       LASSERT(id.nid != LNET_NID_ANY);
+       LASSERT(id.pid != LNET_PID_ANY);
+       LASSERT(!in_interrupt());
 
-       LIBCFS_ALLOC (peer, sizeof (*peer));
+       LIBCFS_ALLOC(peer, sizeof(*peer));
        if (peer == NULL)
                return -ENOMEM;
 
        peer->ksnp_ni = ni;
        peer->ksnp_id = id;
-       atomic_set (&peer->ksnp_refcount, 1);   /* 1 ref for caller */
+       atomic_set(&peer->ksnp_refcount, 1);   /* 1 ref for caller */
        peer->ksnp_closing = 0;
        peer->ksnp_accepting = 0;
        peer->ksnp_proto = NULL;
        peer->ksnp_last_alive = 0;
        peer->ksnp_zc_next_cookie = SOCKNAL_KEEPALIVE_PING + 1;
 
-       INIT_LIST_HEAD (&peer->ksnp_conns);
-       INIT_LIST_HEAD (&peer->ksnp_routes);
-       INIT_LIST_HEAD (&peer->ksnp_tx_queue);
-       INIT_LIST_HEAD (&peer->ksnp_zc_req_list);
+       INIT_LIST_HEAD(&peer->ksnp_conns);
+       INIT_LIST_HEAD(&peer->ksnp_routes);
+       INIT_LIST_HEAD(&peer->ksnp_tx_queue);
+       INIT_LIST_HEAD(&peer->ksnp_zc_req_list);
        spin_lock_init(&peer->ksnp_lock);
 
        spin_lock_bh(&net->ksnn_lock);
@@ -147,21 +147,21 @@ ksocknal_create_peer (ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
 }
 
 void
-ksocknal_destroy_peer (ksock_peer_t *peer)
+ksocknal_destroy_peer(ksock_peer_t *peer)
 {
        ksock_net_t    *net = peer->ksnp_ni->ni_data;
 
-       CDEBUG (D_NET, "peer %s %p deleted\n",
+       CDEBUG(D_NET, "peer %s %p deleted\n",
                libcfs_id2str(peer->ksnp_id), peer);
 
-       LASSERT (atomic_read (&peer->ksnp_refcount) == 0);
-       LASSERT (peer->ksnp_accepting == 0);
-       LASSERT (list_empty (&peer->ksnp_conns));
-       LASSERT (list_empty (&peer->ksnp_routes));
-       LASSERT (list_empty (&peer->ksnp_tx_queue));
-       LASSERT (list_empty (&peer->ksnp_zc_req_list));
+       LASSERT(atomic_read(&peer->ksnp_refcount) == 0);
+       LASSERT(peer->ksnp_accepting == 0);
+       LASSERT(list_empty(&peer->ksnp_conns));
+       LASSERT(list_empty(&peer->ksnp_routes));
+       LASSERT(list_empty(&peer->ksnp_tx_queue));
+       LASSERT(list_empty(&peer->ksnp_zc_req_list));
 
-       LIBCFS_FREE (peer, sizeof (*peer));
+       LIBCFS_FREE(peer, sizeof(*peer));
 
        /* NB a peer's connections and routes keep a reference on their peer
         * until they are destroyed, so we can be assured that _all_ state to
@@ -173,17 +173,17 @@ ksocknal_destroy_peer (ksock_peer_t *peer)
 }
 
 ksock_peer_t *
-ksocknal_find_peer_locked (lnet_ni_t *ni, lnet_process_id_t id)
+ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id)
 {
        struct list_head       *peer_list = ksocknal_nid2peerlist(id.nid);
        struct list_head       *tmp;
        ksock_peer_t     *peer;
 
-       list_for_each (tmp, peer_list) {
+       list_for_each(tmp, peer_list) {
 
-               peer = list_entry (tmp, ksock_peer_t, ksnp_list);
+               peer = list_entry(tmp, ksock_peer_t, ksnp_list);
 
-               LASSERT (!peer->ksnp_closing);
+               LASSERT(!peer->ksnp_closing);
 
                if (peer->ksnp_ni != ni)
                        continue;
@@ -201,7 +201,7 @@ ksocknal_find_peer_locked (lnet_ni_t *ni, lnet_process_id_t id)
 }
 
 ksock_peer_t *
-ksocknal_find_peer (lnet_ni_t *ni, lnet_process_id_t id)
+ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id)
 {
        ksock_peer_t     *peer;
 
@@ -215,37 +215,37 @@ ksocknal_find_peer (lnet_ni_t *ni, lnet_process_id_t id)
 }
 
 static void
-ksocknal_unlink_peer_locked (ksock_peer_t *peer)
+ksocknal_unlink_peer_locked(ksock_peer_t *peer)
 {
        int             i;
        __u32         ip;
        ksock_interface_t *iface;
 
        for (i = 0; i < peer->ksnp_n_passive_ips; i++) {
-               LASSERT (i < LNET_MAX_INTERFACES);
+               LASSERT(i < LNET_MAX_INTERFACES);
                ip = peer->ksnp_passive_ips[i];
 
                iface = ksocknal_ip2iface(peer->ksnp_ni, ip);
                /* All IPs in peer->ksnp_passive_ips[] come from the
                 * interface list, therefore the call must succeed. */
-               LASSERT (iface != NULL);
+               LASSERT(iface != NULL);
 
                CDEBUG(D_NET, "peer=%p iface=%p ksni_nroutes=%d\n",
                       peer, iface, iface->ksni_nroutes);
                iface->ksni_npeers--;
        }
 
-       LASSERT (list_empty(&peer->ksnp_conns));
-       LASSERT (list_empty(&peer->ksnp_routes));
-       LASSERT (!peer->ksnp_closing);
+       LASSERT(list_empty(&peer->ksnp_conns));
+       LASSERT(list_empty(&peer->ksnp_routes));
+       LASSERT(!peer->ksnp_closing);
        peer->ksnp_closing = 1;
-       list_del (&peer->ksnp_list);
+       list_del(&peer->ksnp_list);
        /* lose peerlist's ref */
        ksocknal_peer_decref(peer);
 }
 
 static int
-ksocknal_get_peer_info (lnet_ni_t *ni, int index,
+ksocknal_get_peer_info(lnet_ni_t *ni, int index,
                        lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip,
                        int *port, int *conn_count, int *share_count)
 {
@@ -261,8 +261,8 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index,
 
        for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
 
-               list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) {
-                       peer = list_entry (ptmp, ksock_peer_t, ksnp_list);
+               list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
                        if (peer->ksnp_ni != ni)
                                continue;
@@ -296,7 +296,7 @@ ksocknal_get_peer_info (lnet_ni_t *ni, int index,
                                goto out;
                        }
 
-                       list_for_each (rtmp, &peer->ksnp_routes) {
+                       list_for_each(rtmp, &peer->ksnp_routes) {
                                if (index-- > 0)
                                        continue;
 
@@ -364,17 +364,17 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
 }
 
 static void
-ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route)
+ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route)
 {
        struct list_head        *tmp;
        ksock_conn_t      *conn;
        ksock_route_t     *route2;
 
-       LASSERT (!peer->ksnp_closing);
-       LASSERT (route->ksnr_peer == NULL);
-       LASSERT (!route->ksnr_scheduled);
-       LASSERT (!route->ksnr_connecting);
-       LASSERT (route->ksnr_connected == 0);
+       LASSERT(!peer->ksnp_closing);
+       LASSERT(route->ksnr_peer == NULL);
+       LASSERT(!route->ksnr_scheduled);
+       LASSERT(!route->ksnr_connecting);
+       LASSERT(route->ksnr_connected == 0);
 
        /* LASSERT(unique) */
        list_for_each(tmp, &peer->ksnp_routes) {
@@ -405,7 +405,7 @@ ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route)
 }
 
 static void
-ksocknal_del_route_locked (ksock_route_t *route)
+ksocknal_del_route_locked(ksock_route_t *route)
 {
        ksock_peer_t      *peer = route->ksnr_peer;
        ksock_interface_t *iface;
@@ -413,16 +413,16 @@ ksocknal_del_route_locked (ksock_route_t *route)
        struct list_head        *ctmp;
        struct list_head        *cnxt;
 
-       LASSERT (!route->ksnr_deleted);
+       LASSERT(!route->ksnr_deleted);
 
        /* Close associated conns */
-       list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) {
+       list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
                conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
 
                if (conn->ksnc_route != route)
                        continue;
 
-               ksocknal_close_conn_locked (conn, 0);
+               ksocknal_close_conn_locked(conn, 0);
        }
 
        if (route->ksnr_myipaddr != 0) {
@@ -433,19 +433,19 @@ ksocknal_del_route_locked (ksock_route_t *route)
        }
 
        route->ksnr_deleted = 1;
-       list_del (&route->ksnr_list);
+       list_del(&route->ksnr_list);
        ksocknal_route_decref(route);        /* drop peer's ref */
 
-       if (list_empty (&peer->ksnp_routes) &&
-           list_empty (&peer->ksnp_conns)) {
+       if (list_empty(&peer->ksnp_routes) &&
+           list_empty(&peer->ksnp_conns)) {
                /* I've just removed the last route to a peer with no active
                 * connections */
-               ksocknal_unlink_peer_locked (peer);
+               ksocknal_unlink_peer_locked(peer);
        }
 }
 
 int
-ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
+ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
 {
        struct list_head        *tmp;
        ksock_peer_t      *peer;
@@ -463,7 +463,7 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
        if (rc != 0)
                return rc;
 
-       route = ksocknal_create_route (ipaddr, port);
+       route = ksocknal_create_route(ipaddr, port);
        if (route == NULL) {
                ksocknal_peer_decref(peer);
                return -ENOMEM;
@@ -472,20 +472,20 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
        write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
        /* always called with a ref on ni, so shutdown can't have started */
-       LASSERT (((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
+       LASSERT(((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
 
-       peer2 = ksocknal_find_peer_locked (ni, id);
+       peer2 = ksocknal_find_peer_locked(ni, id);
        if (peer2 != NULL) {
                ksocknal_peer_decref(peer);
                peer = peer2;
        } else {
                /* peer table takes my ref on peer */
-               list_add_tail (&peer->ksnp_list,
-                                  ksocknal_nid2peerlist (id.nid));
+               list_add_tail(&peer->ksnp_list,
+                                  ksocknal_nid2peerlist(id.nid));
        }
 
        route2 = NULL;
-       list_for_each (tmp, &peer->ksnp_routes) {
+       list_for_each(tmp, &peer->ksnp_routes) {
                route2 = list_entry(tmp, ksock_route_t, ksnr_list);
 
                if (route2->ksnr_ipaddr == ipaddr)
@@ -507,7 +507,7 @@ ksocknal_add_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
 }
 
 static void
-ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
+ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip)
 {
        ksock_conn_t     *conn;
        ksock_route_t    *route;
@@ -515,12 +515,12 @@ ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
        struct list_head       *nxt;
        int            nshared;
 
-       LASSERT (!peer->ksnp_closing);
+       LASSERT(!peer->ksnp_closing);
 
        /* Extra ref prevents peer disappearing until I'm done with it */
        ksocknal_peer_addref(peer);
 
-       list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
+       list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
                route = list_entry(tmp, ksock_route_t, ksnr_list);
 
                /* no match */
@@ -529,11 +529,11 @@ ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
 
                route->ksnr_share_count = 0;
                /* This deletes associated conns too */
-               ksocknal_del_route_locked (route);
+               ksocknal_del_route_locked(route);
        }
 
        nshared = 0;
-       list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
+       list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
                route = list_entry(tmp, ksock_route_t, ksnr_list);
                nshared += route->ksnr_share_count;
        }
@@ -542,15 +542,15 @@ ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
                /* remove everything else if there are no explicit entries
                 * left */
 
-               list_for_each_safe (tmp, nxt, &peer->ksnp_routes) {
+               list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
                        route = list_entry(tmp, ksock_route_t, ksnr_list);
 
                        /* we should only be removing auto-entries */
                        LASSERT(route->ksnr_share_count == 0);
-                       ksocknal_del_route_locked (route);
+                       ksocknal_del_route_locked(route);
                }
 
-               list_for_each_safe (tmp, nxt, &peer->ksnp_conns) {
+               list_for_each_safe(tmp, nxt, &peer->ksnp_conns) {
                        conn = list_entry(tmp, ksock_conn_t, ksnc_list);
 
                        ksocknal_close_conn_locked(conn, 0);
@@ -562,9 +562,9 @@ ksocknal_del_peer_locked (ksock_peer_t *peer, __u32 ip)
 }
 
 static int
-ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
+ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
 {
-       LIST_HEAD     (zombies);
+       LIST_HEAD(zombies);
        struct list_head        *ptmp;
        struct list_head        *pnxt;
        ksock_peer_t      *peer;
@@ -583,9 +583,9 @@ ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
        }
 
        for (i = lo; i <= hi; i++) {
-               list_for_each_safe (ptmp, pnxt,
+               list_for_each_safe(ptmp, pnxt,
                                        &ksocknal_data.ksnd_peers[i]) {
-                       peer = list_entry (ptmp, ksock_peer_t, ksnp_list);
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
                        if (peer->ksnp_ni != ni)
                                continue;
@@ -596,12 +596,12 @@ ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
 
                        ksocknal_peer_addref(peer);     /* a ref for me... */
 
-                       ksocknal_del_peer_locked (peer, ip);
+                       ksocknal_del_peer_locked(peer, ip);
 
                        if (peer->ksnp_closing &&
                            !list_empty(&peer->ksnp_tx_queue)) {
-                               LASSERT (list_empty(&peer->ksnp_conns));
-                               LASSERT (list_empty(&peer->ksnp_routes));
+                               LASSERT(list_empty(&peer->ksnp_conns));
+                               LASSERT(list_empty(&peer->ksnp_routes));
 
                                list_splice_init(&peer->ksnp_tx_queue,
                                                     &zombies);
@@ -621,7 +621,7 @@ ksocknal_del_peer (lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
 }
 
 static ksock_conn_t *
-ksocknal_get_conn_by_idx (lnet_ni_t *ni, int index)
+ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index)
 {
        ksock_peer_t      *peer;
        struct list_head        *ptmp;
@@ -632,19 +632,19 @@ ksocknal_get_conn_by_idx (lnet_ni_t *ni, int index)
        read_lock(&ksocknal_data.ksnd_global_lock);
 
        for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-               list_for_each (ptmp, &ksocknal_data.ksnd_peers[i]) {
-                       peer = list_entry (ptmp, ksock_peer_t, ksnp_list);
+               list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
-                       LASSERT (!peer->ksnp_closing);
+                       LASSERT(!peer->ksnp_closing);
 
                        if (peer->ksnp_ni != ni)
                                continue;
 
-                       list_for_each (ctmp, &peer->ksnp_conns) {
+                       list_for_each(ctmp, &peer->ksnp_conns) {
                                if (index-- > 0)
                                        continue;
 
-                               conn = list_entry (ctmp, ksock_conn_t,
+                               conn = list_entry(ctmp, ksock_conn_t,
                                                       ksnc_list);
                                ksocknal_conn_addref(conn);
                                read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -681,7 +681,7 @@ ksocknal_choose_scheduler_locked(unsigned int cpt)
 }
 
 static int
-ksocknal_local_ipvec (lnet_ni_t *ni, __u32 *ipaddrs)
+ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs)
 {
        ksock_net_t       *net = ni->ni_data;
        int             i;
@@ -690,7 +690,7 @@ ksocknal_local_ipvec (lnet_ni_t *ni, __u32 *ipaddrs)
        read_lock(&ksocknal_data.ksnd_global_lock);
 
        nip = net->ksnn_ninterfaces;
-       LASSERT (nip <= LNET_MAX_INTERFACES);
+       LASSERT(nip <= LNET_MAX_INTERFACES);
 
        /* Only offer interfaces for additional connections if I have
         * more than one. */
@@ -701,7 +701,7 @@ ksocknal_local_ipvec (lnet_ni_t *ni, __u32 *ipaddrs)
 
        for (i = 0; i < nip; i++) {
                ipaddrs[i] = net->ksnn_interfaces[i].ksni_ipaddr;
-               LASSERT (ipaddrs[i] != 0);
+               LASSERT(ipaddrs[i] != 0);
        }
 
        read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -709,7 +709,7 @@ ksocknal_local_ipvec (lnet_ni_t *ni, __u32 *ipaddrs)
 }
 
 static int
-ksocknal_match_peerip (ksock_interface_t *iface, __u32 *ips, int nips)
+ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips)
 {
        int   best_netmatch = 0;
        int   best_xor      = 0;
@@ -722,7 +722,7 @@ ksocknal_match_peerip (ksock_interface_t *iface, __u32 *ips, int nips)
                if (ips[i] == 0)
                        continue;
 
-               this_xor = (ips[i] ^ iface->ksni_ipaddr);
+               this_xor = ips[i] ^ iface->ksni_ipaddr;
                this_netmatch = ((this_xor & iface->ksni_netmask) == 0) ? 1 : 0;
 
                if (!(best < 0 ||
@@ -736,7 +736,7 @@ ksocknal_match_peerip (ksock_interface_t *iface, __u32 *ips, int nips)
                best_xor = this_xor;
        }
 
-       LASSERT (best >= 0);
+       LASSERT(best >= 0);
        return best;
 }
 
@@ -767,8 +767,8 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
 
        write_lock_bh(global_lock);
 
-       LASSERT (n_peerips <= LNET_MAX_INTERFACES);
-       LASSERT (net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
+       LASSERT(n_peerips <= LNET_MAX_INTERFACES);
+       LASSERT(net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
 
        /* Only match interfaces for additional connections
         * if I have > 1 interface */
@@ -791,7 +791,7 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
 
                } else {
                        /* choose a new interface */
-                       LASSERT (i == peer->ksnp_n_passive_ips);
+                       LASSERT(i == peer->ksnp_n_passive_ips);
 
                        best_iface = NULL;
                        best_netmatch = 0;
@@ -809,7 +809,7 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
                                        continue;
 
                                k = ksocknal_match_peerip(iface, peerips, n_peerips);
-                               xor = (ip ^ peerips[k]);
+                               xor = ip ^ peerips[k];
                                this_netmatch = ((xor & iface->ksni_netmask) == 0) ? 1 : 0;
 
                                if (!(best_iface == NULL ||
@@ -874,7 +874,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
                return;
        }
 
-       LASSERT (npeer_ipaddrs <= LNET_MAX_INTERFACES);
+       LASSERT(npeer_ipaddrs <= LNET_MAX_INTERFACES);
 
        for (i = 0; i < npeer_ipaddrs; i++) {
                if (newroute != NULL) {
@@ -911,7 +911,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
                best_nroutes = 0;
                best_netmatch = 0;
 
-               LASSERT (net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
+               LASSERT(net->ksnn_ninterfaces <= LNET_MAX_INTERFACES);
 
                /* Select interface to connect from */
                for (j = 0; j < net->ksnn_ninterfaces; j++) {
@@ -961,7 +961,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
 }
 
 int
-ksocknal_accept (lnet_ni_t *ni, struct socket *sock)
+ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
 {
        ksock_connreq_t    *cr;
        int              rc;
@@ -969,7 +969,7 @@ ksocknal_accept (lnet_ni_t *ni, struct socket *sock)
        int              peer_port;
 
        rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
-       LASSERT (rc == 0);                    /* we succeeded before */
+       LASSERT(rc == 0);                     /* we succeeded before */
 
        LIBCFS_ALLOC(cr, sizeof(*cr));
        if (cr == NULL) {
@@ -992,11 +992,11 @@ ksocknal_accept (lnet_ni_t *ni, struct socket *sock)
 }
 
 static int
-ksocknal_connecting (ksock_peer_t *peer, __u32 ipaddr)
+ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr)
 {
        ksock_route_t   *route;
 
-       list_for_each_entry (route, &peer->ksnp_routes, ksnr_list) {
+       list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) {
 
                if (route->ksnr_ipaddr == ipaddr)
                        return route->ksnr_connecting;
@@ -1005,11 +1005,11 @@ ksocknal_connecting (ksock_peer_t *peer, __u32 ipaddr)
 }
 
 int
-ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
+ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
                      struct socket *sock, int type)
 {
        rwlock_t                *global_lock = &ksocknal_data.ksnd_global_lock;
-       LIST_HEAD     (zombies);
+       LIST_HEAD(zombies);
        lnet_process_id_t  peerid;
        struct list_head        *tmp;
        __u64         incarnation;
@@ -1028,7 +1028,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
        active = (route != NULL);
 
-       LASSERT (active == (type != SOCKLND_CONN_NONE));
+       LASSERT(active == (type != SOCKLND_CONN_NONE));
 
        LIBCFS_ALLOC(conn, sizeof(*conn));
        if (conn == NULL) {
@@ -1041,19 +1041,19 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
        conn->ksnc_sock = sock;
        /* 2 ref, 1 for conn, another extra ref prevents socket
         * being closed before establishment of connection */
-       atomic_set (&conn->ksnc_sock_refcount, 2);
+       atomic_set(&conn->ksnc_sock_refcount, 2);
        conn->ksnc_type = type;
        ksocknal_lib_save_callback(sock, conn);
-       atomic_set (&conn->ksnc_conn_refcount, 1); /* 1 ref for me */
+       atomic_set(&conn->ksnc_conn_refcount, 1); /* 1 ref for me */
 
        conn->ksnc_rx_ready = 0;
        conn->ksnc_rx_scheduled = 0;
 
-       INIT_LIST_HEAD (&conn->ksnc_tx_queue);
+       INIT_LIST_HEAD(&conn->ksnc_tx_queue);
        conn->ksnc_tx_ready = 0;
        conn->ksnc_tx_scheduled = 0;
        conn->ksnc_tx_carrier = NULL;
-       atomic_set (&conn->ksnc_tx_nob, 0);
+       atomic_set(&conn->ksnc_tx_nob, 0);
 
        LIBCFS_ALLOC(hello, offsetof(ksock_hello_msg_t,
                                     kshm_ips[LNET_MAX_INTERFACES]));
@@ -1063,7 +1063,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
        }
 
        /* stash conn's local and remote addrs */
-       rc = ksocknal_lib_get_conn_addrs (conn);
+       rc = ksocknal_lib_get_conn_addrs(conn);
        if (rc != 0)
                goto failed_1;
 
@@ -1094,7 +1094,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 #endif
                }
 
-               rc = ksocknal_send_hello (ni, conn, peerid.nid, hello);
+               rc = ksocknal_send_hello(ni, conn, peerid.nid, hello);
                if (rc != 0)
                        goto failed_1;
        } else {
@@ -1105,13 +1105,13 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                conn->ksnc_proto = NULL;
        }
 
-       rc = ksocknal_recv_hello (ni, conn, hello, &peerid, &incarnation);
+       rc = ksocknal_recv_hello(ni, conn, hello, &peerid, &incarnation);
        if (rc < 0)
                goto failed_1;
 
-       LASSERT (rc == 0 || active);
-       LASSERT (conn->ksnc_proto != NULL);
-       LASSERT (peerid.nid != LNET_NID_ANY);
+       LASSERT(rc == 0 || active);
+       LASSERT(conn->ksnc_proto != NULL);
+       LASSERT(peerid.nid != LNET_NID_ANY);
 
        cpt = lnet_cpt_of_nid(peerid.nid);
 
@@ -1126,7 +1126,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                write_lock_bh(global_lock);
 
                /* called with a ref on ni, so shutdown can't have started */
-               LASSERT (((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
+               LASSERT(((ksock_net_t *) ni->ni_data)->ksnn_shutdown == 0);
 
                peer2 = ksocknal_find_peer_locked(ni, peerid);
                if (peer2 == NULL) {
@@ -1166,7 +1166,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                 * NB recv_hello may have returned EPROTO to signal my peer
                 * wants a different protocol than the one I asked for.
                 */
-               LASSERT (list_empty(&peer->ksnp_conns));
+               LASSERT(list_empty(&peer->ksnp_conns));
 
                peer->ksnp_proto = conn->ksnc_proto;
                peer->ksnp_incarnation = incarnation;
@@ -1211,7 +1211,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
                        /* Reply on a passive connection attempt so the peer
                         * realises we're connected. */
-                       LASSERT (rc == 0);
+                       LASSERT(rc == 0);
                        if (!active)
                                rc = EALREADY;
 
@@ -1235,7 +1235,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
         * create an association.  This allows incoming connections created
         * by routes in my peer to match my own route entries so I don't
         * continually create duplicate routes. */
-       list_for_each (tmp, &peer->ksnp_routes) {
+       list_for_each(tmp, &peer->ksnp_routes) {
                route = list_entry(tmp, ksock_route_t, ksnr_list);
 
                if (route->ksnr_ipaddr != conn->ksnc_ipaddr)
@@ -1260,7 +1260,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
        conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
        mb();   /* order with adding to peer's conn list */
 
-       list_add (&conn->ksnc_list, &peer->ksnp_conns);
+       list_add(&conn->ksnc_list, &peer->ksnp_conns);
        ksocknal_conn_addref(conn);
 
        ksocknal_new_packet(conn, 0);
@@ -1272,8 +1272,8 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                if (conn->ksnc_proto->pro_match_tx(conn, tx, tx->tx_nonblk) == SOCKNAL_MATCH_NO)
                                continue;
 
-               list_del (&tx->tx_list);
-               ksocknal_queue_tx_locked (tx, conn);
+               list_del(&tx->tx_list);
+               ksocknal_queue_tx_locked(tx, conn);
        }
 
        write_unlock_bh(global_lock);
@@ -1343,8 +1343,8 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
  failed_2:
        if (!peer->ksnp_closing &&
-           list_empty (&peer->ksnp_conns) &&
-           list_empty (&peer->ksnp_routes)) {
+           list_empty(&peer->ksnp_conns) &&
+           list_empty(&peer->ksnp_routes)) {
                list_add(&zombies, &peer->ksnp_tx_queue);
                list_del_init(&peer->ksnp_tx_queue);
                ksocknal_unlink_peer_locked(peer);
@@ -1383,7 +1383,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t,
                                            kshm_ips[LNET_MAX_INTERFACES]));
 
-       LIBCFS_FREE (conn, sizeof(*conn));
+       LIBCFS_FREE(conn, sizeof(*conn));
 
  failed_0:
        libcfs_sock_release(sock);
@@ -1391,7 +1391,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 }
 
 void
-ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
+ksocknal_close_conn_locked(ksock_conn_t *conn, int error)
 {
        /* This just does the immmediate housekeeping, and queues the
         * connection for the reaper to terminate.
@@ -1401,18 +1401,18 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
        ksock_conn_t      *conn2;
        struct list_head        *tmp;
 
-       LASSERT (peer->ksnp_error == 0);
-       LASSERT (!conn->ksnc_closing);
+       LASSERT(peer->ksnp_error == 0);
+       LASSERT(!conn->ksnc_closing);
        conn->ksnc_closing = 1;
 
        /* ksnd_deathrow_conns takes over peer's ref */
-       list_del (&conn->ksnc_list);
+       list_del(&conn->ksnc_list);
 
        route = conn->ksnc_route;
        if (route != NULL) {
                /* dissociate conn from route... */
-               LASSERT (!route->ksnr_deleted);
-               LASSERT ((route->ksnr_connected & (1 << conn->ksnc_type)) != 0);
+               LASSERT(!route->ksnr_deleted);
+               LASSERT((route->ksnr_connected & (1 << conn->ksnc_type)) != 0);
 
                conn2 = NULL;
                list_for_each(tmp, &peer->ksnp_conns) {
@@ -1431,19 +1431,19 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
 
 #if 0     /* irrelevant with only eager routes */
                /* make route least favourite */
-               list_del (&route->ksnr_list);
-               list_add_tail (&route->ksnr_list, &peer->ksnp_routes);
+               list_del(&route->ksnr_list);
+               list_add_tail(&route->ksnr_list, &peer->ksnp_routes);
 #endif
                ksocknal_route_decref(route);     /* drop conn's ref on route */
        }
 
-       if (list_empty (&peer->ksnp_conns)) {
+       if (list_empty(&peer->ksnp_conns)) {
                /* No more connections to this peer */
 
                if (!list_empty(&peer->ksnp_tx_queue)) {
                        ksock_tx_t *tx;
 
-                       LASSERT (conn->ksnc_proto == &ksocknal_protocol_v3x);
+                       LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x);
 
                        /* throw them to the last connection...,
                         * these TXs will be send to /dev/null by scheduler */
@@ -1460,10 +1460,10 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
                peer->ksnp_proto = NULL;        /* renegotiate protocol version */
                peer->ksnp_error = error;       /* stash last conn close reason */
 
-               if (list_empty (&peer->ksnp_routes)) {
+               if (list_empty(&peer->ksnp_routes)) {
                        /* I've just closed last conn belonging to a
                         * peer with no routes to it */
-                       ksocknal_unlink_peer_locked (peer);
+                       ksocknal_unlink_peer_locked(peer);
                }
        }
 
@@ -1477,7 +1477,7 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
 }
 
 void
-ksocknal_peer_failed (ksock_peer_t *peer)
+ksocknal_peer_failed(ksock_peer_t *peer)
 {
        int     notify = 0;
        unsigned long last_alive = 0;
@@ -1499,7 +1499,7 @@ ksocknal_peer_failed (ksock_peer_t *peer)
        read_unlock(&ksocknal_data.ksnd_global_lock);
 
        if (notify)
-               lnet_notify (peer->ksnp_ni, peer->ksnp_id.nid, 0,
+               lnet_notify(peer->ksnp_ni, peer->ksnp_id.nid, 0,
                             last_alive);
 }
 
@@ -1509,11 +1509,11 @@ ksocknal_finalize_zcreq(ksock_conn_t *conn)
        ksock_peer_t     *peer = conn->ksnc_peer;
        ksock_tx_t       *tx;
        ksock_tx_t       *tmp;
-       LIST_HEAD    (zlist);
+       LIST_HEAD(zlist);
 
        /* NB safe to finalize TXs because closing of socket will
         * abort all buffered data */
-       LASSERT (conn->ksnc_sock == NULL);
+       LASSERT(conn->ksnc_sock == NULL);
 
        spin_lock(&peer->ksnp_lock);
 
@@ -1521,7 +1521,7 @@ ksocknal_finalize_zcreq(ksock_conn_t *conn)
                if (tx->tx_conn != conn)
                        continue;
 
-               LASSERT (tx->tx_msg.ksm_zc_cookies[0] != 0);
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] != 0);
 
                tx->tx_msg.ksm_zc_cookies[0] = 0;
                tx->tx_zc_aborted = 1; /* mark it as not-acked */
@@ -1540,7 +1540,7 @@ ksocknal_finalize_zcreq(ksock_conn_t *conn)
 }
 
 void
-ksocknal_terminate_conn (ksock_conn_t *conn)
+ksocknal_terminate_conn(ksock_conn_t *conn)
 {
        /* This gets called by the reaper (guaranteed thread context) to
         * disengage the socket from its callbacks and close it.
@@ -1560,13 +1560,13 @@ ksocknal_terminate_conn (ksock_conn_t *conn)
 
        if (!conn->ksnc_tx_scheduled &&
            !list_empty(&conn->ksnc_tx_queue)) {
-               list_add_tail (&conn->ksnc_tx_list,
+               list_add_tail(&conn->ksnc_tx_list,
                               &sched->kss_tx_conns);
                conn->ksnc_tx_scheduled = 1;
                /* extra ref for scheduler */
                ksocknal_conn_addref(conn);
 
-               wake_up (&sched->kss_waitq);
+               wake_up(&sched->kss_waitq);
        }
 
        spin_unlock_bh(&sched->kss_lock);
@@ -1582,7 +1582,7 @@ ksocknal_terminate_conn (ksock_conn_t *conn)
 
        if (peer->ksnp_error != 0) {
                /* peer's last conn closed in error */
-               LASSERT (list_empty (&peer->ksnp_conns));
+               LASSERT(list_empty(&peer->ksnp_conns));
                failed = 1;
                peer->ksnp_error = 0;     /* avoid multiple notifications */
        }
@@ -1601,7 +1601,7 @@ ksocknal_terminate_conn (ksock_conn_t *conn)
 }
 
 void
-ksocknal_queue_zombie_conn (ksock_conn_t *conn)
+ksocknal_queue_zombie_conn(ksock_conn_t *conn)
 {
        /* Queue the conn for the reaper to destroy */
 
@@ -1615,20 +1615,20 @@ ksocknal_queue_zombie_conn (ksock_conn_t *conn)
 }
 
 void
-ksocknal_destroy_conn (ksock_conn_t *conn)
+ksocknal_destroy_conn(ksock_conn_t *conn)
 {
        unsigned long      last_rcv;
 
        /* Final coup-de-grace of the reaper */
-       CDEBUG (D_NET, "connection %p\n", conn);
+       CDEBUG(D_NET, "connection %p\n", conn);
 
-       LASSERT (atomic_read (&conn->ksnc_conn_refcount) == 0);
-       LASSERT (atomic_read (&conn->ksnc_sock_refcount) == 0);
-       LASSERT (conn->ksnc_sock == NULL);
-       LASSERT (conn->ksnc_route == NULL);
-       LASSERT (!conn->ksnc_tx_scheduled);
-       LASSERT (!conn->ksnc_rx_scheduled);
-       LASSERT (list_empty(&conn->ksnc_tx_queue));
+       LASSERT(atomic_read(&conn->ksnc_conn_refcount) == 0);
+       LASSERT(atomic_read(&conn->ksnc_sock_refcount) == 0);
+       LASSERT(conn->ksnc_sock == NULL);
+       LASSERT(conn->ksnc_route == NULL);
+       LASSERT(!conn->ksnc_tx_scheduled);
+       LASSERT(!conn->ksnc_rx_scheduled);
+       LASSERT(list_empty(&conn->ksnc_tx_queue));
 
        /* complete current receive if any */
        switch (conn->ksnc_rx_state) {
@@ -1641,7 +1641,7 @@ ksocknal_destroy_conn (ksock_conn_t *conn)
                       conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left,
                       cfs_duration_sec(cfs_time_sub(cfs_time_current(),
                                                     last_rcv)));
-               lnet_finalize (conn->ksnc_peer->ksnp_ni,
+               lnet_finalize(conn->ksnc_peer->ksnp_ni,
                               conn->ksnc_cookie, -EIO);
                break;
        case SOCKNAL_RX_LNET_HEADER:
@@ -1665,30 +1665,30 @@ ksocknal_destroy_conn (ksock_conn_t *conn)
                               &conn->ksnc_ipaddr, conn->ksnc_port);
               break;
        default:
-               LBUG ();
+               LBUG();
                break;
        }
 
        ksocknal_peer_decref(conn->ksnc_peer);
 
-       LIBCFS_FREE (conn, sizeof (*conn));
+       LIBCFS_FREE(conn, sizeof(*conn));
 }
 
 int
-ksocknal_close_peer_conns_locked (ksock_peer_t *peer, __u32 ipaddr, int why)
+ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why)
 {
        ksock_conn_t       *conn;
        struct list_head         *ctmp;
        struct list_head         *cnxt;
        int              count = 0;
 
-       list_for_each_safe (ctmp, cnxt, &peer->ksnp_conns) {
-               conn = list_entry (ctmp, ksock_conn_t, ksnc_list);
+       list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
+               conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
 
                if (ipaddr == 0 ||
                    conn->ksnc_ipaddr == ipaddr) {
                        count++;
-                       ksocknal_close_conn_locked (conn, why);
+                       ksocknal_close_conn_locked(conn, why);
                }
        }
 
@@ -1696,7 +1696,7 @@ ksocknal_close_peer_conns_locked (ksock_peer_t *peer, __u32 ipaddr, int why)
 }
 
 int
-ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why)
+ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why)
 {
        ksock_peer_t     *peer = conn->ksnc_peer;
        __u32        ipaddr = conn->ksnc_ipaddr;
@@ -1704,7 +1704,7 @@ ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why)
 
        write_lock_bh(&ksocknal_data.ksnd_global_lock);
 
-       count = ksocknal_close_peer_conns_locked (peer, ipaddr, why);
+       count = ksocknal_close_peer_conns_locked(peer, ipaddr, why);
 
        write_unlock_bh(&ksocknal_data.ksnd_global_lock);
 
@@ -1712,7 +1712,7 @@ ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why)
 }
 
 int
-ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr)
+ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr)
 {
        ksock_peer_t       *peer;
        struct list_head         *ptmp;
@@ -1732,16 +1732,16 @@ ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr)
        }
 
        for (i = lo; i <= hi; i++) {
-               list_for_each_safe (ptmp, pnxt,
+               list_for_each_safe(ptmp, pnxt,
                                        &ksocknal_data.ksnd_peers[i]) {
 
-                       peer = list_entry (ptmp, ksock_peer_t, ksnp_list);
+                       peer = list_entry(ptmp, ksock_peer_t, ksnp_list);
 
                        if (!((id.nid == LNET_NID_ANY || id.nid == peer->ksnp_id.nid) &&
                              (id.pid == LNET_PID_ANY || id.pid == peer->ksnp_id.pid)))
                                continue;
 
-                       count += ksocknal_close_peer_conns_locked (peer, ipaddr, 0);
+                       count += ksocknal_close_peer_conns_locked(peer, ipaddr, 0);
                }
        }
 
@@ -1758,7 +1758,7 @@ ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr)
 }
 
 void
-ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
+ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
 {
        /* The router is telling me she's been notified of a change in
         * gateway state.... */
@@ -1767,12 +1767,12 @@ ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
        id.nid = gw_nid;
        id.pid = LNET_PID_ANY;
 
-       CDEBUG (D_NET, "gw %s %s\n", libcfs_nid2str(gw_nid),
+       CDEBUG(D_NET, "gw %s %s\n", libcfs_nid2str(gw_nid),
                alive ? "up" : "down");
 
        if (!alive) {
                /* If the gateway crashed, close all open connections... */
-               ksocknal_close_matching_conns (id, 0);
+               ksocknal_close_matching_conns(id, 0);
                return;
        }
 
@@ -1781,7 +1781,7 @@ ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
 }
 
 void
-ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
+ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
 {
        int             connect = 1;
        unsigned long    last_alive = 0;
@@ -1798,7 +1798,7 @@ ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
                ksock_conn_t     *conn;
                int            bufnob;
 
-               list_for_each (tmp, &peer->ksnp_conns) {
+               list_for_each(tmp, &peer->ksnp_conns) {
                        conn = list_entry(tmp, ksock_conn_t, ksnc_list);
                        bufnob = conn->ksnc_sock->sk->sk_wmem_queued;
 
@@ -1842,7 +1842,7 @@ ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
 }
 
 static void
-ksocknal_push_peer (ksock_peer_t *peer)
+ksocknal_push_peer(ksock_peer_t *peer)
 {
        int            index;
        int            i;
@@ -1855,9 +1855,9 @@ ksocknal_push_peer (ksock_peer_t *peer)
                i = 0;
                conn = NULL;
 
-               list_for_each (tmp, &peer->ksnp_conns) {
+               list_for_each(tmp, &peer->ksnp_conns) {
                        if (i++ == index) {
-                               conn = list_entry (tmp, ksock_conn_t,
+                               conn = list_entry(tmp, ksock_conn_t,
                                                       ksnc_list);
                                ksocknal_conn_addref(conn);
                                break;
@@ -1869,13 +1869,13 @@ ksocknal_push_peer (ksock_peer_t *peer)
                if (conn == NULL)
                        break;
 
-               ksocknal_lib_push_conn (conn);
+               ksocknal_lib_push_conn(conn);
                ksocknal_conn_decref(conn);
        }
 }
 
 static int
-ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
+ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
 {
        ksock_peer_t      *peer;
        struct list_head        *tmp;
@@ -1891,7 +1891,7 @@ ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
                        index = 0;
                        peer = NULL;
 
-                       list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) {
+                       list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
                                peer = list_entry(tmp, ksock_peer_t,
                                                      ksnp_list);
 
@@ -1913,7 +1913,7 @@ ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
 
                        if (peer != NULL) {
                                rc = 0;
-                               ksocknal_push_peer (peer);
+                               ksocknal_push_peer(peer);
                                ksocknal_peer_decref(peer);
                        }
                }
@@ -2005,7 +2005,7 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
                }
 
        list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
-               route = list_entry (tmp, ksock_route_t, ksnr_list);
+               route = list_entry(tmp, ksock_route_t, ksnr_list);
 
                if (route->ksnr_myipaddr != ipaddr)
                        continue;
@@ -2022,7 +2022,7 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
                conn = list_entry(tmp, ksock_conn_t, ksnc_list);
 
                if (conn->ksnc_myipaddr == ipaddr)
-                       ksocknal_close_conn_locked (conn, 0);
+                       ksocknal_close_conn_locked(conn, 0);
        }
 }
 
@@ -2139,21 +2139,21 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
        case IOC_LIBCFS_ADD_PEER:
                id.nid = data->ioc_nid;
                id.pid = LUSTRE_SRV_LNET_PID;
-               return ksocknal_add_peer (ni, id,
+               return ksocknal_add_peer(ni, id,
                                          data->ioc_u32[0], /* IP */
                                          data->ioc_u32[1]); /* port */
 
        case IOC_LIBCFS_DEL_PEER:
                id.nid = data->ioc_nid;
                id.pid = LNET_PID_ANY;
-               return ksocknal_del_peer (ni, id,
+               return ksocknal_del_peer(ni, id,
                                          data->ioc_u32[0]); /* IP */
 
        case IOC_LIBCFS_GET_CONN: {
                int        txmem;
                int        rxmem;
                int        nagle;
-               ksock_conn_t *conn = ksocknal_get_conn_by_idx (ni, data->ioc_count);
+               ksock_conn_t *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count);
 
                if (conn == NULL)
                        return -ENOENT;
@@ -2177,7 +2177,7 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
        case IOC_LIBCFS_CLOSE_CONNECTION:
                id.nid = data->ioc_nid;
                id.pid = LNET_PID_ANY;
-               return ksocknal_close_matching_conns (id,
+               return ksocknal_close_matching_conns(id,
                                                      data->ioc_u32[0]);
 
        case IOC_LIBCFS_REGISTER_MYNID:
@@ -2202,9 +2202,9 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
 }
 
 static void
-ksocknal_free_buffers (void)
+ksocknal_free_buffers(void)
 {
-       LASSERT (atomic_read(&ksocknal_data.ksnd_nactive_txs) == 0);
+       LASSERT(atomic_read(&ksocknal_data.ksnd_nactive_txs) == 0);
 
        if (ksocknal_data.ksnd_sched_info != NULL) {
                struct ksock_sched_info *info;
@@ -2220,8 +2220,8 @@ ksocknal_free_buffers (void)
                cfs_percpt_free(ksocknal_data.ksnd_sched_info);
        }
 
-       LIBCFS_FREE (ksocknal_data.ksnd_peers,
-                    sizeof (struct list_head) *
+       LIBCFS_FREE(ksocknal_data.ksnd_peers,
+                    sizeof(struct list_head) *
                     ksocknal_data.ksnd_peer_hash_size);
 
        spin_lock(&ksocknal_data.ksnd_tx_lock);
@@ -2253,25 +2253,25 @@ ksocknal_base_shutdown(void)
        int                     j;
 
        CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n",
-              atomic_read (&libcfs_kmemory));
-       LASSERT (ksocknal_data.ksnd_nnets == 0);
+              atomic_read(&libcfs_kmemory));
+       LASSERT(ksocknal_data.ksnd_nnets == 0);
 
        switch (ksocknal_data.ksnd_init) {
        default:
-               LASSERT (0);
+               LASSERT(0);
 
        case SOCKNAL_INIT_ALL:
        case SOCKNAL_INIT_DATA:
-               LASSERT (ksocknal_data.ksnd_peers != NULL);
+               LASSERT(ksocknal_data.ksnd_peers != NULL);
                for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-                       LASSERT (list_empty (&ksocknal_data.ksnd_peers[i]));
+                       LASSERT(list_empty(&ksocknal_data.ksnd_peers[i]));
                }
 
                LASSERT(list_empty(&ksocknal_data.ksnd_nets));
-               LASSERT (list_empty (&ksocknal_data.ksnd_enomem_conns));
-               LASSERT (list_empty (&ksocknal_data.ksnd_zombie_conns));
-               LASSERT (list_empty (&ksocknal_data.ksnd_connd_connreqs));
-               LASSERT (list_empty (&ksocknal_data.ksnd_connd_routes));
+               LASSERT(list_empty(&ksocknal_data.ksnd_enomem_conns));
+               LASSERT(list_empty(&ksocknal_data.ksnd_zombie_conns));
+               LASSERT(list_empty(&ksocknal_data.ksnd_connd_connreqs));
+               LASSERT(list_empty(&ksocknal_data.ksnd_connd_routes));
 
                if (ksocknal_data.ksnd_sched_info != NULL) {
                        cfs_percpt_for_each(info, i,
@@ -2332,13 +2332,13 @@ ksocknal_base_shutdown(void)
        }
 
        CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n",
-              atomic_read (&libcfs_kmemory));
+              atomic_read(&libcfs_kmemory));
 
        module_put(THIS_MODULE);
 }
 
 static __u64
-ksocknal_new_incarnation (void)
+ksocknal_new_incarnation(void)
 {
 
        /* The incarnation number is the time this module loaded and it
@@ -2354,14 +2354,14 @@ ksocknal_base_startup(void)
        int                     rc;
        int                     i;
 
-       LASSERT (ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING);
-       LASSERT (ksocknal_data.ksnd_nnets == 0);
+       LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING);
+       LASSERT(ksocknal_data.ksnd_nnets == 0);
 
-       memset (&ksocknal_data, 0, sizeof (ksocknal_data)); /* zero pointers */
+       memset(&ksocknal_data, 0, sizeof(ksocknal_data)); /* zero pointers */
 
        ksocknal_data.ksnd_peer_hash_size = SOCKNAL_PEER_HASH_SIZE;
-       LIBCFS_ALLOC (ksocknal_data.ksnd_peers,
-                     sizeof (struct list_head) *
+       LIBCFS_ALLOC(ksocknal_data.ksnd_peers,
+                     sizeof(struct list_head) *
                      ksocknal_data.ksnd_peer_hash_size);
        if (ksocknal_data.ksnd_peers == NULL)
                return -ENOMEM;
@@ -2373,18 +2373,18 @@ ksocknal_base_startup(void)
        INIT_LIST_HEAD(&ksocknal_data.ksnd_nets);
 
        spin_lock_init(&ksocknal_data.ksnd_reaper_lock);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_enomem_conns);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_zombie_conns);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_deathrow_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_enomem_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_zombie_conns);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_deathrow_conns);
        init_waitqueue_head(&ksocknal_data.ksnd_reaper_waitq);
 
        spin_lock_init(&ksocknal_data.ksnd_connd_lock);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_connd_connreqs);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_connd_routes);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_connd_connreqs);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_connd_routes);
        init_waitqueue_head(&ksocknal_data.ksnd_connd_waitq);
 
        spin_lock_init(&ksocknal_data.ksnd_tx_lock);
-       INIT_LIST_HEAD (&ksocknal_data.ksnd_idle_noop_txs);
+       INIT_LIST_HEAD(&ksocknal_data.ksnd_idle_noop_txs);
 
        /* NB memset above zeros whole of ksocknal_data */
 
@@ -2465,7 +2465,7 @@ ksocknal_base_startup(void)
 
        rc = ksocknal_thread_start(ksocknal_reaper, NULL, "socknal_reaper");
        if (rc != 0) {
-               CERROR ("Can't spawn socknal reaper: %d\n", rc);
+               CERROR("Can't spawn socknal reaper: %d\n", rc);
                goto failed;
        }
 
@@ -2480,7 +2480,7 @@ ksocknal_base_startup(void)
 }
 
 static void
-ksocknal_debug_peerhash (lnet_ni_t *ni)
+ksocknal_debug_peerhash(lnet_ni_t *ni)
 {
        ksock_peer_t    *peer = NULL;
        struct list_head        *tmp;
@@ -2489,8 +2489,8 @@ ksocknal_debug_peerhash (lnet_ni_t *ni)
        read_lock(&ksocknal_data.ksnd_global_lock);
 
        for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
-               list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) {
-                       peer = list_entry (tmp, ksock_peer_t, ksnp_list);
+               list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) {
+                       peer = list_entry(tmp, ksock_peer_t, ksnp_list);
 
                        if (peer->ksnp_ni == ni)
                                break;
@@ -2512,7 +2512,7 @@ ksocknal_debug_peerhash (lnet_ni_t *ni)
                      !list_empty(&peer->ksnp_tx_queue),
                      !list_empty(&peer->ksnp_zc_req_list));
 
-               list_for_each (tmp, &peer->ksnp_routes) {
+               list_for_each(tmp, &peer->ksnp_routes) {
                        route = list_entry(tmp, ksock_route_t, ksnr_list);
                        CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n",
                              atomic_read(&route->ksnr_refcount),
@@ -2520,9 +2520,9 @@ ksocknal_debug_peerhash (lnet_ni_t *ni)
                              route->ksnr_connected, route->ksnr_deleted);
                }
 
-               list_for_each (tmp, &peer->ksnp_conns) {
+               list_for_each(tmp, &peer->ksnp_conns) {
                        conn = list_entry(tmp, ksock_conn_t, ksnc_list);
-                       CWARN ("Conn: ref %d, sref %d, t %d, c %d\n",
+                       CWARN("Conn: ref %d, sref %d, t %d, c %d\n",
                               atomic_read(&conn->ksnc_conn_refcount),
                               atomic_read(&conn->ksnc_sock_refcount),
                               conn->ksnc_type, conn->ksnc_closing);
@@ -2534,7 +2534,7 @@ ksocknal_debug_peerhash (lnet_ni_t *ni)
 }
 
 void
-ksocknal_shutdown (lnet_ni_t *ni)
+ksocknal_shutdown(lnet_ni_t *ni)
 {
        ksock_net_t      *net = ni->ni_data;
        int            i;
@@ -2573,8 +2573,8 @@ ksocknal_shutdown (lnet_ni_t *ni)
        spin_unlock_bh(&net->ksnn_lock);
 
        for (i = 0; i < net->ksnn_ninterfaces; i++) {
-               LASSERT (net->ksnn_interfaces[i].ksni_npeers == 0);
-               LASSERT (net->ksnn_interfaces[i].ksni_nroutes == 0);
+               LASSERT(net->ksnn_interfaces[i].ksni_npeers == 0);
+               LASSERT(net->ksnn_interfaces[i].ksni_nroutes == 0);
        }
 
        list_del(&net->ksnn_list);
@@ -2757,13 +2757,13 @@ ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts)
 }
 
 int
-ksocknal_startup (lnet_ni_t *ni)
+ksocknal_startup(lnet_ni_t *ni)
 {
        ksock_net_t  *net;
        int        rc;
        int        i;
 
-       LASSERT (ni->ni_lnd == &the_ksocklnd);
+       LASSERT(ni->ni_lnd == &the_ksocklnd);
 
        if (ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING) {
                rc = ksocknal_base_startup();
@@ -2843,19 +2843,19 @@ ksocknal_startup (lnet_ni_t *ni)
 
 
 static void __exit
-ksocknal_module_fini (void)
+ksocknal_module_fini(void)
 {
        lnet_unregister_lnd(&the_ksocklnd);
 }
 
 static int __init
-ksocknal_module_init (void)
+ksocknal_module_init(void)
 {
        int    rc;
 
        /* check ksnr_connected/connecting field large enough */
-       CLASSERT (SOCKLND_CONN_NTYPES <= 4);
-       CLASSERT (SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN);
+       CLASSERT(SOCKLND_CONN_NTYPES <= 4);
+       CLASSERT(SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN);
 
        /* initialize the_ksocklnd */
        the_ksocklnd.lnd_type     = SOCKLND;
index 03488d289c74be6425a8fa955c2fb6012fbdacb3..c54c9955164eda319d9ac277cf9c6d04949790a5 100644 (file)
@@ -406,7 +406,7 @@ ksocknal_route_mask(void)
 }
 
 static inline struct list_head *
-ksocknal_nid2peerlist (lnet_nid_t nid)
+ksocknal_nid2peerlist(lnet_nid_t nid)
 {
        unsigned int hash = ((unsigned int)nid) % ksocknal_data.ksnd_peer_hash_size;
 
@@ -414,25 +414,25 @@ ksocknal_nid2peerlist (lnet_nid_t nid)
 }
 
 static inline void
-ksocknal_conn_addref (ksock_conn_t *conn)
+ksocknal_conn_addref(ksock_conn_t *conn)
 {
-       LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0);
+       LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0);
        atomic_inc(&conn->ksnc_conn_refcount);
 }
 
-extern void ksocknal_queue_zombie_conn (ksock_conn_t *conn);
+extern void ksocknal_queue_zombie_conn(ksock_conn_t *conn);
 extern void ksocknal_finalize_zcreq(ksock_conn_t *conn);
 
 static inline void
-ksocknal_conn_decref (ksock_conn_t *conn)
+ksocknal_conn_decref(ksock_conn_t *conn)
 {
-       LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0);
+       LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0);
        if (atomic_dec_and_test(&conn->ksnc_conn_refcount))
                ksocknal_queue_zombie_conn(conn);
 }
 
 static inline int
-ksocknal_connsock_addref (ksock_conn_t *conn)
+ksocknal_connsock_addref(ksock_conn_t *conn)
 {
        int   rc = -ESHUTDOWN;
 
@@ -448,11 +448,11 @@ ksocknal_connsock_addref (ksock_conn_t *conn)
 }
 
 static inline void
-ksocknal_connsock_decref (ksock_conn_t *conn)
+ksocknal_connsock_decref(ksock_conn_t *conn)
 {
-       LASSERT (atomic_read(&conn->ksnc_sock_refcount) > 0);
+       LASSERT(atomic_read(&conn->ksnc_sock_refcount) > 0);
        if (atomic_dec_and_test(&conn->ksnc_sock_refcount)) {
-               LASSERT (conn->ksnc_closing);
+               LASSERT(conn->ksnc_closing);
                libcfs_sock_release(conn->ksnc_sock);
                conn->ksnc_sock = NULL;
                ksocknal_finalize_zcreq(conn);
@@ -460,61 +460,61 @@ ksocknal_connsock_decref (ksock_conn_t *conn)
 }
 
 static inline void
-ksocknal_tx_addref (ksock_tx_t *tx)
+ksocknal_tx_addref(ksock_tx_t *tx)
 {
-       LASSERT (atomic_read(&tx->tx_refcount) > 0);
+       LASSERT(atomic_read(&tx->tx_refcount) > 0);
        atomic_inc(&tx->tx_refcount);
 }
 
-extern void ksocknal_tx_prep (ksock_conn_t *, ksock_tx_t *tx);
-extern void ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx);
+extern void ksocknal_tx_prep(ksock_conn_t *, ksock_tx_t *tx);
+extern void ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx);
 
 static inline void
-ksocknal_tx_decref (ksock_tx_t *tx)
+ksocknal_tx_decref(ksock_tx_t *tx)
 {
-       LASSERT (atomic_read(&tx->tx_refcount) > 0);
+       LASSERT(atomic_read(&tx->tx_refcount) > 0);
        if (atomic_dec_and_test(&tx->tx_refcount))
                ksocknal_tx_done(NULL, tx);
 }
 
 static inline void
-ksocknal_route_addref (ksock_route_t *route)
+ksocknal_route_addref(ksock_route_t *route)
 {
-       LASSERT (atomic_read(&route->ksnr_refcount) > 0);
+       LASSERT(atomic_read(&route->ksnr_refcount) > 0);
        atomic_inc(&route->ksnr_refcount);
 }
 
-extern void ksocknal_destroy_route (ksock_route_t *route);
+extern void ksocknal_destroy_route(ksock_route_t *route);
 
 static inline void
-ksocknal_route_decref (ksock_route_t *route)
+ksocknal_route_decref(ksock_route_t *route)
 {
-       LASSERT (atomic_read (&route->ksnr_refcount) > 0);
+       LASSERT(atomic_read(&route->ksnr_refcount) > 0);
        if (atomic_dec_and_test(&route->ksnr_refcount))
-               ksocknal_destroy_route (route);
+               ksocknal_destroy_route(route);
 }
 
 static inline void
-ksocknal_peer_addref (ksock_peer_t *peer)
+ksocknal_peer_addref(ksock_peer_t *peer)
 {
-       LASSERT (atomic_read (&peer->ksnp_refcount) > 0);
+       LASSERT(atomic_read(&peer->ksnp_refcount) > 0);
        atomic_inc(&peer->ksnp_refcount);
 }
 
-extern void ksocknal_destroy_peer (ksock_peer_t *peer);
+extern void ksocknal_destroy_peer(ksock_peer_t *peer);
 
 static inline void
-ksocknal_peer_decref (ksock_peer_t *peer)
+ksocknal_peer_decref(ksock_peer_t *peer)
 {
-       LASSERT (atomic_read (&peer->ksnp_refcount) > 0);
+       LASSERT(atomic_read(&peer->ksnp_refcount) > 0);
        if (atomic_dec_and_test(&peer->ksnp_refcount))
-               ksocknal_destroy_peer (peer);
+               ksocknal_destroy_peer(peer);
 }
 
-int ksocknal_startup (lnet_ni_t *ni);
-void ksocknal_shutdown (lnet_ni_t *ni);
+int ksocknal_startup(lnet_ni_t *ni);
+void ksocknal_shutdown(lnet_ni_t *ni);
 int ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
-int ksocknal_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
+int ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
 int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
                  int delayed, unsigned int niov,
                  struct kvec *iov, lnet_kiov_t *kiov,
@@ -522,44 +522,44 @@ int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
 int ksocknal_accept(lnet_ni_t *ni, struct socket *sock);
 
 extern int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip, int port);
-extern ksock_peer_t *ksocknal_find_peer_locked (lnet_ni_t *ni, lnet_process_id_t id);
-extern ksock_peer_t *ksocknal_find_peer (lnet_ni_t *ni, lnet_process_id_t id);
-extern void ksocknal_peer_failed (ksock_peer_t *peer);
-extern int ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
+extern ksock_peer_t *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id);
+extern ksock_peer_t *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id);
+extern void ksocknal_peer_failed(ksock_peer_t *peer);
+extern int ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
                                 struct socket *sock, int type);
-extern void ksocknal_close_conn_locked (ksock_conn_t *conn, int why);
-extern void ksocknal_terminate_conn (ksock_conn_t *conn);
-extern void ksocknal_destroy_conn (ksock_conn_t *conn);
-extern int  ksocknal_close_peer_conns_locked (ksock_peer_t *peer,
+extern void ksocknal_close_conn_locked(ksock_conn_t *conn, int why);
+extern void ksocknal_terminate_conn(ksock_conn_t *conn);
+extern void ksocknal_destroy_conn(ksock_conn_t *conn);
+extern int  ksocknal_close_peer_conns_locked(ksock_peer_t *peer,
                                              __u32 ipaddr, int why);
-extern int ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why);
-extern int ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr);
+extern int ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why);
+extern int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr);
 extern ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer,
                                               ksock_tx_t *tx, int nonblk);
 
 extern int  ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx,
                                   lnet_process_id_t id);
 extern ksock_tx_t *ksocknal_alloc_tx(int type, int size);
-extern void ksocknal_free_tx (ksock_tx_t *tx);
+extern void ksocknal_free_tx(ksock_tx_t *tx);
 extern ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
 extern void ksocknal_next_tx_carrier(ksock_conn_t *conn);
-extern void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn);
-extern void ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist,
+extern void ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn);
+extern void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist,
                                  int error);
-extern void ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
-extern void ksocknal_query (struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
+extern void ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
+extern void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when);
 extern int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
-extern void ksocknal_thread_fini (void);
-extern void ksocknal_launch_all_connections_locked (ksock_peer_t *peer);
-extern ksock_route_t *ksocknal_find_connectable_route_locked (ksock_peer_t *peer);
-extern ksock_route_t *ksocknal_find_connecting_route_locked (ksock_peer_t *peer);
-extern int ksocknal_new_packet (ksock_conn_t *conn, int skip);
-extern int ksocknal_scheduler (void *arg);
-extern int ksocknal_connd (void *arg);
-extern int ksocknal_reaper (void *arg);
-extern int ksocknal_send_hello (lnet_ni_t *ni, ksock_conn_t *conn,
+extern void ksocknal_thread_fini(void);
+extern void ksocknal_launch_all_connections_locked(ksock_peer_t *peer);
+extern ksock_route_t *ksocknal_find_connectable_route_locked(ksock_peer_t *peer);
+extern ksock_route_t *ksocknal_find_connecting_route_locked(ksock_peer_t *peer);
+extern int ksocknal_new_packet(ksock_conn_t *conn, int skip);
+extern int ksocknal_scheduler(void *arg);
+extern int ksocknal_connd(void *arg);
+extern int ksocknal_reaper(void *arg);
+extern int ksocknal_send_hello(lnet_ni_t *ni, ksock_conn_t *conn,
                                lnet_nid_t peer_nid, ksock_hello_msg_t *hello);
-extern int ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
+extern int ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn,
                                ksock_hello_msg_t *hello, lnet_process_id_t *id,
                                __u64 *incarnation);
 extern void ksocknal_read_callback(ksock_conn_t *conn);
@@ -569,15 +569,15 @@ extern int ksocknal_lib_zc_capable(ksock_conn_t *conn);
 extern void ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn);
 extern void ksocknal_lib_set_callback(struct socket *sock,  ksock_conn_t *conn);
 extern void ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn);
-extern void ksocknal_lib_push_conn (ksock_conn_t *conn);
-extern int ksocknal_lib_get_conn_addrs (ksock_conn_t *conn);
-extern int ksocknal_lib_setup_sock (struct socket *so);
-extern int ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx);
-extern int ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx);
-extern void ksocknal_lib_eager_ack (ksock_conn_t *conn);
-extern int ksocknal_lib_recv_iov (ksock_conn_t *conn);
-extern int ksocknal_lib_recv_kiov (ksock_conn_t *conn);
-extern int ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem,
+extern void ksocknal_lib_push_conn(ksock_conn_t *conn);
+extern int ksocknal_lib_get_conn_addrs(ksock_conn_t *conn);
+extern int ksocknal_lib_setup_sock(struct socket *so);
+extern int ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx);
+extern int ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx);
+extern void ksocknal_lib_eager_ack(ksock_conn_t *conn);
+extern int ksocknal_lib_recv_iov(ksock_conn_t *conn);
+extern int ksocknal_lib_recv_kiov(ksock_conn_t *conn);
+extern int ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem,
                                           int *rxmem, int *nagle);
 
 extern int ksocknal_tunables_init(void);
index 92760fe94184cf7ee2455ac64364d155cbc3944e..fa7ad883bda9332509d433b3a7524fd15b2d6813 100644 (file)
@@ -1374,9 +1374,9 @@ ksocknal_sched_cansleep(ksock_sched_t *sched)
 
        spin_lock_bh(&sched->kss_lock);
 
-       rc = (!ksocknal_data.ksnd_shuttingdown &&
+       rc = !ksocknal_data.ksnd_shuttingdown &&
              list_empty(&sched->kss_rx_conns) &&
-             list_empty(&sched->kss_tx_conns));
+             list_empty(&sched->kss_tx_conns);
 
        spin_unlock_bh(&sched->kss_lock);
        return rc;
index 66cc509295e5f81339bc424d36a3b36267ab0587..f5e8ab06070c1ab45864f7855f5783225aecd730 100644 (file)
 #include "socklnd.h"
 
 int
-ksocknal_lib_get_conn_addrs (ksock_conn_t *conn)
+ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
 {
        int rc = libcfs_sock_getaddr(conn->ksnc_sock, 1,
                                     &conn->ksnc_ipaddr,
                                     &conn->ksnc_port);
 
        /* Didn't need the {get,put}connsock dance to deref ksnc_sock... */
-       LASSERT (!conn->ksnc_closing);
+       LASSERT(!conn->ksnc_closing);
 
        if (rc != 0) {
-               CERROR ("Error %d getting sock peer IP\n", rc);
+               CERROR("Error %d getting sock peer IP\n", rc);
                return rc;
        }
 
        rc = libcfs_sock_getaddr(conn->ksnc_sock, 0,
                                 &conn->ksnc_myipaddr, NULL);
        if (rc != 0) {
-               CERROR ("Error %d getting sock local IP\n", rc);
+               CERROR("Error %d getting sock local IP\n", rc);
                return rc;
        }
 
@@ -75,7 +75,7 @@ ksocknal_lib_zc_capable(ksock_conn_t *conn)
 }
 
 int
-ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
+ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
 {
        struct socket *sock = conn->ksnc_sock;
        int         nob;
@@ -117,7 +117,7 @@ ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
 }
 
 int
-ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
+ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
 {
        struct socket *sock = conn->ksnc_sock;
        lnet_kiov_t   *kiov = tx->tx_kiov;
@@ -125,7 +125,7 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
        int         nob;
 
        /* Not NOOP message */
-       LASSERT (tx->tx_lnetmsg != NULL);
+       LASSERT(tx->tx_lnetmsg != NULL);
 
        /* NB we can't trust socket ops to either consume our iovs
         * or leave them alone. */
@@ -185,7 +185,7 @@ ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
 }
 
 void
-ksocknal_lib_eager_ack (ksock_conn_t *conn)
+ksocknal_lib_eager_ack(ksock_conn_t *conn)
 {
        int         opt = 1;
        struct socket *sock = conn->ksnc_sock;
@@ -196,11 +196,11 @@ ksocknal_lib_eager_ack (ksock_conn_t *conn)
         * peer. */
 
        kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
-                              (char *)&opt, sizeof (opt));
+                              (char *)&opt, sizeof(opt));
 }
 
 int
-ksocknal_lib_recv_iov (ksock_conn_t *conn)
+ksocknal_lib_recv_iov(ksock_conn_t *conn)
 {
 #if SOCKNAL_SINGLE_FRAG_RX
        struct kvec  scratch;
@@ -223,13 +223,13 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn)
 
        /* NB we can't trust socket ops to either consume our iovs
         * or leave them alone. */
-       LASSERT (niov > 0);
+       LASSERT(niov > 0);
 
        for (nob = i = 0; i < niov; i++) {
                scratchiov[i] = iov[i];
                nob += scratchiov[i].iov_len;
        }
-       LASSERT (nob <= conn->ksnc_rx_nob_wanted);
+       LASSERT(nob <= conn->ksnc_rx_nob_wanted);
 
        rc = kernel_recvmsg(conn->ksnc_sock, &msg,
                scratchiov, niov, nob, MSG_DONTWAIT);
@@ -243,7 +243,7 @@ ksocknal_lib_recv_iov (ksock_conn_t *conn)
        if (saved_csum != 0) {
                /* accumulate checksum */
                for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
-                       LASSERT (i < niov);
+                       LASSERT(i < niov);
 
                        fragnob = iov[i].iov_len;
                        if (fragnob > sum)
@@ -278,7 +278,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
        if (!*ksocknal_tunables.ksnd_zc_recv || pages == NULL)
                return NULL;
 
-       LASSERT (niov <= LNET_MAX_IOV);
+       LASSERT(niov <= LNET_MAX_IOV);
 
        if (niov < 2 ||
            niov < *ksocknal_tunables.ksnd_zc_recv_min_nfrags)
@@ -304,7 +304,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
 }
 
 int
-ksocknal_lib_recv_kiov (ksock_conn_t *conn)
+ksocknal_lib_recv_kiov(ksock_conn_t *conn)
 {
 #if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
        struct kvec   scratch;
@@ -348,14 +348,14 @@ ksocknal_lib_recv_kiov (ksock_conn_t *conn)
                n = niov;
        }
 
-       LASSERT (nob <= conn->ksnc_rx_nob_wanted);
+       LASSERT(nob <= conn->ksnc_rx_nob_wanted);
 
        rc = kernel_recvmsg(conn->ksnc_sock, &msg,
                        (struct kvec *)scratchiov, n, nob, MSG_DONTWAIT);
 
        if (conn->ksnc_msg.ksm_csum != 0) {
                for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
-                       LASSERT (i < niov);
+                       LASSERT(i < niov);
 
                        /* Dang! have to kmap again because I have nowhere to stash the
                         * mapped address.  But by doing it while the page is still
@@ -423,7 +423,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx)
 }
 
 int
-ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
+ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
 {
        struct socket *sock = conn->ksnc_sock;
        int         len;
@@ -431,7 +431,7 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int
 
        rc = ksocknal_connsock_addref(conn);
        if (rc != 0) {
-               LASSERT (conn->ksnc_closing);
+               LASSERT(conn->ksnc_closing);
                *txmem = *rxmem = *nagle = 0;
                return -ESHUTDOWN;
        }
@@ -454,7 +454,7 @@ ksocknal_lib_get_conn_tunables (ksock_conn_t *conn, int *txmem, int *rxmem, int
 }
 
 int
-ksocknal_lib_setup_sock (struct socket *sock)
+ksocknal_lib_setup_sock(struct socket *sock)
 {
        int          rc;
        int          option;
@@ -473,17 +473,17 @@ ksocknal_lib_setup_sock (struct socket *sock)
        linger.l_linger = 0;
 
        rc = kernel_setsockopt(sock, SOL_SOCKET, SO_LINGER,
-                             (char *)&linger, sizeof (linger));
+                             (char *)&linger, sizeof(linger));
        if (rc != 0) {
-               CERROR ("Can't set SO_LINGER: %d\n", rc);
+               CERROR("Can't set SO_LINGER: %d\n", rc);
                return rc;
        }
 
        option = -1;
        rc = kernel_setsockopt(sock, SOL_TCP, TCP_LINGER2,
-                                   (char *)&option, sizeof (option));
+                                   (char *)&option, sizeof(option));
        if (rc != 0) {
-               CERROR ("Can't set SO_LINGER2: %d\n", rc);
+               CERROR("Can't set SO_LINGER2: %d\n", rc);
                return rc;
        }
 
@@ -491,9 +491,9 @@ ksocknal_lib_setup_sock (struct socket *sock)
                option = 1;
 
                rc = kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
-                                           (char *)&option, sizeof (option));
+                                           (char *)&option, sizeof(option));
                if (rc != 0) {
-                       CERROR ("Can't disable nagle: %d\n", rc);
+                       CERROR("Can't disable nagle: %d\n", rc);
                        return rc;
                }
        }
@@ -502,7 +502,7 @@ ksocknal_lib_setup_sock (struct socket *sock)
                                *ksocknal_tunables.ksnd_tx_buffer_size,
                                *ksocknal_tunables.ksnd_rx_buffer_size);
        if (rc != 0) {
-               CERROR ("Can't set buffer tx %d, rx %d buffers: %d\n",
+               CERROR("Can't set buffer tx %d, rx %d buffers: %d\n",
                        *ksocknal_tunables.ksnd_tx_buffer_size,
                        *ksocknal_tunables.ksnd_rx_buffer_size, rc);
                return rc;
@@ -519,9 +519,9 @@ ksocknal_lib_setup_sock (struct socket *sock)
 
        option = (do_keepalive ? 1 : 0);
        rc = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
-                             (char *)&option, sizeof (option));
+                             (char *)&option, sizeof(option));
        if (rc != 0) {
-               CERROR ("Can't set SO_KEEPALIVE: %d\n", rc);
+               CERROR("Can't set SO_KEEPALIVE: %d\n", rc);
                return rc;
        }
 
@@ -529,23 +529,23 @@ ksocknal_lib_setup_sock (struct socket *sock)
                return 0;
 
        rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
-                                   (char *)&keep_idle, sizeof (keep_idle));
+                                   (char *)&keep_idle, sizeof(keep_idle));
        if (rc != 0) {
-               CERROR ("Can't set TCP_KEEPIDLE: %d\n", rc);
+               CERROR("Can't set TCP_KEEPIDLE: %d\n", rc);
                return rc;
        }
 
        rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
-                                   (char *)&keep_intvl, sizeof (keep_intvl));
+                                   (char *)&keep_intvl, sizeof(keep_intvl));
        if (rc != 0) {
-               CERROR ("Can't set TCP_KEEPINTVL: %d\n", rc);
+               CERROR("Can't set TCP_KEEPINTVL: %d\n", rc);
                return rc;
        }
 
        rc = kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
-                                   (char *)&keep_count, sizeof (keep_count));
+                                   (char *)&keep_count, sizeof(keep_count));
        if (rc != 0) {
-               CERROR ("Can't set TCP_KEEPCNT: %d\n", rc);
+               CERROR("Can't set TCP_KEEPCNT: %d\n", rc);
                return rc;
        }
 
@@ -553,7 +553,7 @@ ksocknal_lib_setup_sock (struct socket *sock)
 }
 
 void
-ksocknal_lib_push_conn (ksock_conn_t *conn)
+ksocknal_lib_push_conn(ksock_conn_t *conn)
 {
        struct sock    *sk;
        struct tcp_sock *tp;
@@ -568,29 +568,29 @@ ksocknal_lib_push_conn (ksock_conn_t *conn)
        sk = conn->ksnc_sock->sk;
        tp = tcp_sk(sk);
 
-       lock_sock (sk);
+       lock_sock(sk);
        nonagle = tp->nonagle;
        tp->nonagle = 1;
-       release_sock (sk);
+       release_sock(sk);
 
        rc = kernel_setsockopt(conn->ksnc_sock, SOL_TCP, TCP_NODELAY,
-                                     (char *)&val, sizeof (val));
-       LASSERT (rc == 0);
+                                     (char *)&val, sizeof(val));
+       LASSERT(rc == 0);
 
-       lock_sock (sk);
+       lock_sock(sk);
        tp->nonagle = nonagle;
-       release_sock (sk);
+       release_sock(sk);
 
        ksocknal_connsock_decref(conn);
 }
 
-extern void ksocknal_read_callback (ksock_conn_t *conn);
-extern void ksocknal_write_callback (ksock_conn_t *conn);
+extern void ksocknal_read_callback(ksock_conn_t *conn);
+extern void ksocknal_write_callback(ksock_conn_t *conn);
 /*
  * socket call back in Linux
  */
 static void
-ksocknal_data_ready (struct sock *sk)
+ksocknal_data_ready(struct sock *sk)
 {
        ksock_conn_t  *conn;
 
@@ -600,8 +600,8 @@ ksocknal_data_ready (struct sock *sk)
 
        conn = sk->sk_user_data;
        if (conn == NULL) {          /* raced with ksocknal_terminate_conn */
-               LASSERT (sk->sk_data_ready != &ksocknal_data_ready);
-               sk->sk_data_ready (sk);
+               LASSERT(sk->sk_data_ready != &ksocknal_data_ready);
+               sk->sk_data_ready(sk);
        } else
                ksocknal_read_callback(conn);
 
@@ -609,7 +609,7 @@ ksocknal_data_ready (struct sock *sk)
 }
 
 static void
-ksocknal_write_space (struct sock *sk)
+ksocknal_write_space(struct sock *sk)
 {
        ksock_conn_t  *conn;
        int         wspace;
@@ -629,12 +629,12 @@ ksocknal_write_space (struct sock *sk)
                                      " ready" : " blocked"),
               (conn == NULL) ? "" : (conn->ksnc_tx_scheduled ?
                                      " scheduled" : " idle"),
-              (conn == NULL) ? "" : (list_empty (&conn->ksnc_tx_queue) ?
+              (conn == NULL) ? "" : (list_empty(&conn->ksnc_tx_queue) ?
                                      " empty" : " queued"));
 
        if (conn == NULL) {          /* raced with ksocknal_terminate_conn */
-               LASSERT (sk->sk_write_space != &ksocknal_write_space);
-               sk->sk_write_space (sk);
+               LASSERT(sk->sk_write_space != &ksocknal_write_space);
+               sk->sk_write_space(sk);
 
                read_unlock(&ksocknal_data.ksnd_global_lock);
                return;
@@ -647,7 +647,7 @@ ksocknal_write_space (struct sock *sk)
                 * ENOMEM check in ksocknal_transmit is race-free (think about
                 * it). */
 
-               clear_bit (SOCK_NOSPACE, &sk->sk_socket->flags);
+               clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
        }
 
        read_unlock(&ksocknal_data.ksnd_global_lock);
index 7a793d2d3582b14bdac5e73e65ab6c020d522e2c..f5563881b25c0cceba0f68a608841a3d1de40220 100644 (file)
@@ -50,8 +50,8 @@
 #include <net/tcp.h>
 #include <linux/uio.h>
 #include <linux/if.h>
+#include <linux/uaccess.h>
 
-#include <asm/uaccess.h>
 #include <asm/irq.h>
 
 #include <linux/fs.h>
index 66d78c9be650a8e4606d5d085806f18b5f21e235..86b88db1cf2086c6842c45725018e4132385ade1 100644 (file)
@@ -72,7 +72,7 @@ static int typed_conns = 1;
 module_param(typed_conns, int, 0444);
 MODULE_PARM_DESC(typed_conns, "use different sockets for bulk");
 
-static int min_bulk = (1<<10);
+static int min_bulk = 1<<10;
 module_param(min_bulk, int, 0644);
 MODULE_PARM_DESC(min_bulk, "smallest 'large' message");
 
@@ -122,7 +122,7 @@ static int nonblk_zcack = 1;
 module_param(nonblk_zcack, int, 0644);
 MODULE_PARM_DESC(nonblk_zcack, "always send ZC-ACK on non-blocking connection");
 
-static unsigned int zc_min_payload = (16 << 10);
+static unsigned int zc_min_payload = 16 << 10;
 module_param(zc_min_payload, int, 0644);
 MODULE_PARM_DESC(zc_min_payload, "minimum payload size to zero copy");
 
@@ -182,7 +182,7 @@ int ksocknal_tunables_init(void)
 #endif
 
        if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
-               *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10);
+               *ksocknal_tunables.ksnd_zc_min_payload = 2 << 10;
 
        return 0;
 };
index b2f88eb47bbad8171c76551f2ce9e14542f42620..8596581f54ff6056c334347b80fe29af20c2be33 100644 (file)
@@ -55,8 +55,8 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn)
        ksock_tx_t     *tx = conn->ksnc_tx_carrier;
 
        /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
-       LASSERT (!list_empty(&conn->ksnc_tx_queue));
-       LASSERT (tx != NULL);
+       LASSERT(!list_empty(&conn->ksnc_tx_queue));
+       LASSERT(tx != NULL);
 
        /* Next TX that can carry ZC-ACK or LNet message */
        if (tx->tx_list.next == &conn->ksnc_tx_queue) {
@@ -65,7 +65,7 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn)
        } else {
                conn->ksnc_tx_carrier = list_entry(tx->tx_list.next,
                                                       ksock_tx_t, tx_list);
-               LASSERT (conn->ksnc_tx_carrier->tx_msg.ksm_type == tx->tx_msg.ksm_type);
+               LASSERT(conn->ksnc_tx_carrier->tx_msg.ksm_type == tx->tx_msg.ksm_type);
        }
 }
 
@@ -75,7 +75,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
 {
        ksock_tx_t *tx = conn->ksnc_tx_carrier;
 
-       LASSERT (tx_ack == NULL ||
+       LASSERT(tx_ack == NULL ||
                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
        /*
@@ -139,7 +139,7 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg)
                return NULL;
        }
 
-       LASSERT (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+       LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
        /* There is a noop zc-ack can be piggybacked */
        tx_msg->tx_msg.ksm_zc_cookies[1] = tx->tx_msg.ksm_zc_cookies[1];
@@ -162,7 +162,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
                return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
 
        /* non-blocking ZC-ACK (to router) */
-       LASSERT (tx_ack == NULL ||
+       LASSERT(tx_ack == NULL ||
                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
        tx = conn->ksnc_tx_carrier;
@@ -185,7 +185,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
 
        if (tx->tx_msg.ksm_zc_cookies[1] == SOCKNAL_KEEPALIVE_PING) {
                /* replace the keepalive PING with a real ACK */
-               LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] == 0);
                tx->tx_msg.ksm_zc_cookies[1] = cookie;
                return 1;
        }
@@ -220,7 +220,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
                __u64   tmp = 0;
 
                /* two separated cookies: (a+2, a) or (a+1, a) */
-               LASSERT (tx->tx_msg.ksm_zc_cookies[0] -
+               LASSERT(tx->tx_msg.ksm_zc_cookies[0] -
                         tx->tx_msg.ksm_zc_cookies[1] <= 2);
 
                if (tx->tx_msg.ksm_zc_cookies[0] -
@@ -408,7 +408,7 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
        ksock_peer_t      *peer = conn->ksnc_peer;
        ksock_tx_t      *tx;
        ksock_tx_t      *tmp;
-       LIST_HEAD     (zlist);
+       LIST_HEAD(zlist);
        int             count;
 
        if (cookie1 == 0)
@@ -450,7 +450,7 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
 }
 
 static int
-ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
+ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
 {
        struct socket   *sock = conn->ksnc_sock;
        lnet_hdr_t        *hdr;
@@ -526,7 +526,7 @@ out:
 }
 
 static int
-ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
+ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
 {
        struct socket *sock = conn->ksnc_sock;
        int          rc;
@@ -584,12 +584,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
        }
 
        rc = libcfs_sock_read(sock, &hdr->src_nid,
-                             sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid),
+                             sizeof(*hdr) - offsetof(lnet_hdr_t, src_nid),
                              timeout);
        if (rc != 0) {
                CERROR("Error %d reading rest of HELLO hdr from %pI4h\n",
                        rc, &conn->ksnc_ipaddr);
-               LASSERT (rc < 0 && rc != -EALREADY);
+               LASSERT(rc < 0 && rc != -EALREADY);
                goto out;
        }
 
@@ -602,12 +602,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
                goto out;
        }
 
-       hello->kshm_src_nid      = le64_to_cpu (hdr->src_nid);
-       hello->kshm_src_pid      = le32_to_cpu (hdr->src_pid);
-       hello->kshm_src_incarnation = le64_to_cpu (hdr->msg.hello.incarnation);
-       hello->kshm_ctype          = le32_to_cpu (hdr->msg.hello.type);
-       hello->kshm_nips            = le32_to_cpu (hdr->payload_length) /
-                                        sizeof (__u32);
+       hello->kshm_src_nid      = le64_to_cpu(hdr->src_nid);
+       hello->kshm_src_pid      = le32_to_cpu(hdr->src_pid);
+       hello->kshm_src_incarnation = le64_to_cpu(hdr->msg.hello.incarnation);
+       hello->kshm_ctype          = le32_to_cpu(hdr->msg.hello.type);
+       hello->kshm_nips            = le32_to_cpu(hdr->payload_length) /
+                                        sizeof(__u32);
 
        if (hello->kshm_nips > LNET_MAX_INTERFACES) {
                CERROR("Bad nips %d from ip %pI4h\n",
@@ -645,7 +645,7 @@ out:
 }
 
 static int
-ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
+ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
 {
        struct socket   *sock = conn->ksnc_sock;
        int             rc;
index 863cc3735edfdf9714920cb5d0414c52d98aec0b..5470148f5b64a235fa9c6d35ebca7542cc1a658d 100644 (file)
@@ -81,9 +81,8 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
 
        count = cfs_power2_roundup(count);
 
-       if (callback != LNET_EQ_HANDLER_NONE && count != 0) {
+       if (callback != LNET_EQ_HANDLER_NONE && count != 0)
                CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count);
-       }
 
        /* count can be 0 if only need callback, we can eliminate
         * overhead of enqueue event */
index 52ec0ab7e3c3960184fe403bd008e8f296e0bb98..8510bae4822a8f593f166fbdcd0bb24034801039 100644 (file)
@@ -107,7 +107,8 @@ lnet_peers_start_down(void)
 }
 
 void
-lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, unsigned long when)
+lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
+                  unsigned long when)
 {
        if (time_before(when, lp->lp_timestamp)) { /* out of date information */
                CDEBUG(D_NET, "Out of date\n");
@@ -225,7 +226,7 @@ lnet_rtr_decref_locked(lnet_peer_t *lp)
 }
 
 lnet_remotenet_t *
-lnet_find_net_locked (__u32 net)
+lnet_find_net_locked(__u32 net)
 {
        lnet_remotenet_t        *rnet;
        struct list_head                *tmp;
@@ -269,12 +270,11 @@ static void lnet_shuffle_seed(void)
        do_gettimeofday(&tv);
        cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
        seeded = 1;
-       return;
 }
 
 /* NB expects LNET_LOCK held */
 static void
-lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route)
+lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route)
 {
        unsigned int      len = 0;
        unsigned int      offset = 0;
@@ -282,13 +282,13 @@ lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route)
 
        lnet_shuffle_seed();
 
-       list_for_each (e, &rnet->lrn_routes) {
+       list_for_each(e, &rnet->lrn_routes) {
                len++;
        }
 
        /* len+1 positions to add a new entry, also prevents division by 0 */
        offset = cfs_rand() % (len + 1);
-       list_for_each (e, &rnet->lrn_routes) {
+       list_for_each(e, &rnet->lrn_routes) {
                if (offset == 0)
                        break;
                offset--;
@@ -354,17 +354,16 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
                LIBCFS_FREE(route, sizeof(*route));
                LIBCFS_FREE(rnet, sizeof(*rnet));
 
-               if (rc == -EHOSTUNREACH) /* gateway is not on a local net */
+               if (rc == -EHOSTUNREACH) /* gateway is not on a local net */
                        return 0;       /* ignore the route entry */
-               } else {
-                       CERROR("Error %d creating route %s %d %s\n", rc,
-                              libcfs_net2str(net), hops,
-                              libcfs_nid2str(gateway));
-               }
+               CERROR("Error %d creating route %s %d %s\n", rc,
+                      libcfs_net2str(net), hops,
+                      libcfs_nid2str(gateway));
+
                return rc;
        }
 
-       LASSERT (!the_lnet.ln_shutdown);
+       LASSERT(!the_lnet.ln_shutdown);
 
        rnet2 = lnet_find_net_locked(net);
        if (rnet2 == NULL) {
@@ -375,7 +374,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
 
        /* Search for a duplicate route (it's a NOOP if it is) */
        add_route = 1;
-       list_for_each (e, &rnet2->lrn_routes) {
+       list_for_each(e, &rnet2->lrn_routes) {
                lnet_route_t *route2 = list_entry(e, lnet_route_t, lr_list);
 
                if (route2->lr_gateway == route->lr_gateway) {
@@ -384,7 +383,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
                }
 
                /* our lookups must be true */
-               LASSERT (route2->lr_gateway->lp_nid != gateway);
+               LASSERT(route2->lr_gateway->lp_nid != gateway);
        }
 
        if (add_route) {
@@ -546,7 +545,7 @@ lnet_del_route(__u32 net, lnet_nid_t gw_nid)
 }
 
 void
-lnet_destroy_routes (void)
+lnet_destroy_routes(void)
 {
        lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
 }
@@ -606,7 +605,6 @@ lnet_swap_pinginfo(lnet_ping_info_t *info)
                __swab64s(&stat->ns_nid);
                __swab32s(&stat->ns_status);
        }
-       return;
 }
 
 /**
@@ -758,13 +756,13 @@ lnet_wait_known_routerstate(void)
        struct list_head          *entry;
        int               all_known;
 
-       LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
+       LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
 
        for (;;) {
                int     cpt = lnet_net_lock_current();
 
                all_known = 1;
-               list_for_each (entry, &the_lnet.ln_routers) {
+               list_for_each(entry, &the_lnet.ln_routers) {
                        rtr = list_entry(entry, lnet_peer_t, lp_rtr_list);
 
                        if (rtr->lp_alive_count == 0) {
@@ -886,7 +884,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway)
        }
        rcd->rcd_pinginfo = pi;
 
-       LASSERT (!LNetHandleIsInvalid(the_lnet.ln_rc_eqh));
+       LASSERT(!LNetHandleIsInvalid(the_lnet.ln_rc_eqh));
        rc = LNetMDBind((lnet_md_t){.start     = pi,
                                    .user_ptr  = rcd,
                                    .length    = LNET_PINGINFO_SIZE,
@@ -929,7 +927,7 @@ lnet_create_rc_data_locked(lnet_peer_t *gateway)
 }
 
 static int
-lnet_router_check_interval (lnet_peer_t *rtr)
+lnet_router_check_interval(lnet_peer_t *rtr)
 {
        int secs;
 
@@ -942,7 +940,7 @@ lnet_router_check_interval (lnet_peer_t *rtr)
 }
 
 static void
-lnet_ping_router_locked (lnet_peer_t *rtr)
+lnet_ping_router_locked(lnet_peer_t *rtr)
 {
        lnet_rc_data_t *rcd = NULL;
        unsigned long      now = cfs_time_current();
@@ -1010,7 +1008,6 @@ lnet_ping_router_locked (lnet_peer_t *rtr)
        }
 
        lnet_peer_decref_locked(rtr);
-       return;
 }
 
 int
@@ -1019,7 +1016,7 @@ lnet_router_checker_start(void)
        int       rc;
        int       eqsz;
 
-       LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
+       LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
 
        if (check_routers_before_use &&
            dead_router_check_interval <= 0) {
@@ -1067,14 +1064,14 @@ lnet_router_checker_start(void)
 }
 
 void
-lnet_router_checker_stop (void)
+lnet_router_checker_stop(void)
 {
        int rc;
 
        if (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN)
                return;
 
-       LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
+       LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
        the_lnet.ln_rc_state = LNET_RC_STATE_STOPPING;
 
        /* block until event callback signals exit */
@@ -1082,8 +1079,7 @@ lnet_router_checker_stop (void)
        LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
 
        rc = LNetEQFree(the_lnet.ln_rc_eqh);
-       LASSERT (rc == 0);
-       return;
+       LASSERT(rc == 0);
 }
 
 static void
@@ -1178,7 +1174,7 @@ lnet_router_checker(void *arg)
 
        cfs_block_allsigs();
 
-       LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
+       LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
 
        while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
                __u64   version;
@@ -1291,11 +1287,11 @@ lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
        if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */
                return;
 
-       LASSERT (list_empty(&rbp->rbp_msgs));
-       LASSERT (rbp->rbp_credits == rbp->rbp_nbuffers);
+       LASSERT(list_empty(&rbp->rbp_msgs));
+       LASSERT(rbp->rbp_credits == rbp->rbp_nbuffers);
 
        while (!list_empty(&rbp->rbp_bufs)) {
-               LASSERT (rbp->rbp_credits > 0);
+               LASSERT(rbp->rbp_credits > 0);
 
                rb = list_entry(rbp->rbp_bufs.next,
                                    lnet_rtrbuf_t, rb_list);
@@ -1304,8 +1300,8 @@ lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
                nbuffers++;
        }
 
-       LASSERT (rbp->rbp_nbuffers == nbuffers);
-       LASSERT (rbp->rbp_credits == nbuffers);
+       LASSERT(rbp->rbp_nbuffers == nbuffers);
+       LASSERT(rbp->rbp_credits == nbuffers);
 
        rbp->rbp_nbuffers = rbp->rbp_credits = 0;
 }
@@ -1317,7 +1313,7 @@ lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
        int         i;
 
        if (rbp->rbp_nbuffers != 0) {
-               LASSERT (rbp->rbp_nbuffers == nbufs);
+               LASSERT(rbp->rbp_nbuffers == nbufs);
                return 0;
        }
 
@@ -1337,10 +1333,10 @@ lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
 
                /* No allocation "under fire" */
                /* Otherwise we'd need code to schedule blocked msgs etc */
-               LASSERT (!the_lnet.ln_routing);
+               LASSERT(!the_lnet.ln_routing);
        }
 
-       LASSERT (rbp->rbp_credits == nbufs);
+       LASSERT(rbp->rbp_credits == nbufs);
        return 0;
 }
 
@@ -1435,7 +1431,7 @@ int
 lnet_rtrpools_alloc(int im_a_router)
 {
        lnet_rtrbufpool_t *rtrp;
-       int     large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+       int     large_pages;
        int     small_pages = 1;
        int     nrb_tiny;
        int     nrb_small;
@@ -1443,6 +1439,8 @@ lnet_rtrpools_alloc(int im_a_router)
        int     rc;
        int     i;
 
+       large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+
        if (!strcmp(forwarding, "")) {
                /* not set either way */
                if (!im_a_router)
@@ -1513,16 +1511,16 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
        unsigned long           now = cfs_time_current();
        int                     cpt = lnet_cpt_of_nid(nid);
 
-       LASSERT (!in_interrupt ());
+       LASSERT(!in_interrupt ());
 
-       CDEBUG (D_NET, "%s notifying %s: %s\n",
+       CDEBUG(D_NET, "%s notifying %s: %s\n",
                (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
                libcfs_nid2str(nid),
                alive ? "up" : "down");
 
        if (ni != NULL &&
            LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
-               CWARN ("Ignoring notification of %s %s by %s (different net)\n",
+               CWARN("Ignoring notification of %s %s by %s (different net)\n",
                        libcfs_nid2str(nid), alive ? "birth" : "death",
                        libcfs_nid2str(ni->ni_nid));
                return -EINVAL;
@@ -1577,21 +1575,20 @@ lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
 EXPORT_SYMBOL(lnet_notify);
 
 void
-lnet_get_tunables (void)
+lnet_get_tunables(void)
 {
-       return;
 }
 
 #else
 
 int
-lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
+lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
 {
        return -EOPNOTSUPP;
 }
 
 void
-lnet_router_checker (void)
+lnet_router_checker(void)
 {
        static time_t last;
        static int    running;
@@ -1643,7 +1640,7 @@ lnet_router_checker (void)
                        abort();
                }
 
-               LASSERT (rc == 1);
+               LASSERT(rc == 1);
 
                lnet_router_checker_event(&ev);
        }
@@ -1655,26 +1652,25 @@ lnet_router_checker (void)
                return;
        }
 
-       LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
+       LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
 
        lnet_net_lock(0);
 
        version = the_lnet.ln_routers_version;
-       list_for_each_entry (rtr, &the_lnet.ln_routers, lp_rtr_list) {
+       list_for_each_entry(rtr, &the_lnet.ln_routers, lp_rtr_list) {
                lnet_ping_router_locked(rtr);
-               LASSERT (version == the_lnet.ln_routers_version);
+               LASSERT(version == the_lnet.ln_routers_version);
        }
 
        lnet_net_unlock(0);
 
        running = 0; /* lock only needed for the recursion check */
-       return;
 }
 
 /* NB lnet_peers_start_down depends on me,
  * so must be called before any peer creation */
 void
-lnet_get_tunables (void)
+lnet_get_tunables(void)
 {
        char *s;
 
index fbff84cea52fc65774b2548c5c22ca220922d012..371a54df4f2fe546f1168ea237e375b84ea51a0e 100644 (file)
@@ -203,7 +203,7 @@ lst_group_add_ioctl(lstio_group_add_args_t *args)
        if (args->lstio_grp_key != console_session.ses_key)
                return -EACCES;
 
-       if (args->lstio_grp_namep == NULL||
+       if (args->lstio_grp_namep == NULL ||
            args->lstio_grp_nmlen <= 0 ||
            args->lstio_grp_nmlen > LST_NAME_SIZE)
                return -EINVAL;
index 1e0afc2868479739e1e6c211a2c4aebd9451760c..2b5f53c7a730013a4d804417608ce55052f7c74f 100644 (file)
@@ -64,7 +64,7 @@ lstcon_session_t      console_session;
 static void
 lstcon_node_get(lstcon_node_t *nd)
 {
-       LASSERT (nd->nd_ref >= 1);
+       LASSERT(nd->nd_ref >= 1);
 
        nd->nd_ref++;
 }
@@ -75,7 +75,7 @@ lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create)
        lstcon_ndlink_t *ndl;
        unsigned int     idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE;
 
-       LASSERT (id.nid != LNET_NID_ANY);
+       LASSERT(id.nid != LNET_NID_ANY);
 
        list_for_each_entry(ndl, &console_session.ses_ndl_hash[idx], ndl_hlink) {
                if (ndl->ndl_node->nd_id.nid != id.nid ||
@@ -119,15 +119,15 @@ lstcon_node_put(lstcon_node_t *nd)
 {
        lstcon_ndlink_t  *ndl;
 
-       LASSERT (nd->nd_ref > 0);
+       LASSERT(nd->nd_ref > 0);
 
        if (--nd->nd_ref > 0)
                return;
 
        ndl = (lstcon_ndlink_t *)(nd + 1);
 
-       LASSERT (!list_empty(&ndl->ndl_link));
-       LASSERT (!list_empty(&ndl->ndl_hlink));
+       LASSERT(!list_empty(&ndl->ndl_link));
+       LASSERT(!list_empty(&ndl->ndl_hlink));
 
        /* remove from session */
        list_del(&ndl->ndl_link);
@@ -184,8 +184,8 @@ lstcon_ndlink_find(struct list_head *hash,
 static void
 lstcon_ndlink_release(lstcon_ndlink_t *ndl)
 {
-       LASSERT (list_empty(&ndl->ndl_link));
-       LASSERT (!list_empty(&ndl->ndl_hlink));
+       LASSERT(list_empty(&ndl->ndl_link));
+       LASSERT(!list_empty(&ndl->ndl_hlink));
 
        list_del(&ndl->ndl_hlink); /* delete from hash */
        lstcon_node_put(ndl->ndl_node);
@@ -254,7 +254,7 @@ lstcon_group_decref(lstcon_group_t *grp)
        lstcon_group_drain(grp, 0);
 
        for (i = 0; i < LST_NODE_HASHSIZE; i++) {
-               LASSERT (list_empty(&grp->grp_ndl_hash[i]));
+               LASSERT(list_empty(&grp->grp_ndl_hash[i]));
        }
 
        LIBCFS_FREE(grp, offsetof(lstcon_group_t,
@@ -552,8 +552,8 @@ lstcon_nodes_add(char *name, int count, lnet_process_id_t *ids_up,
        lstcon_group_t   *grp;
        int                  rc;
 
-       LASSERT (count > 0);
-       LASSERT (ids_up != NULL);
+       LASSERT(count > 0);
+       LASSERT(ids_up != NULL);
 
        rc = lstcon_group_find(name, &grp);
        if (rc != 0) {
@@ -726,8 +726,8 @@ lstcon_group_list(int index, int len, char *name_up)
 {
        lstcon_group_t *grp;
 
-       LASSERT (index >= 0);
-       LASSERT (name_up != NULL);
+       LASSERT(index >= 0);
+       LASSERT(name_up != NULL);
 
        list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) {
                if (index-- == 0) {
@@ -748,10 +748,10 @@ lstcon_nodes_getent(struct list_head *head, int *index_p,
        int            count = 0;
        int            index = 0;
 
-       LASSERT (index_p != NULL && count_p != NULL);
-       LASSERT (dents_up != NULL);
-       LASSERT (*index_p >= 0);
-       LASSERT (*count_p > 0);
+       LASSERT(index_p != NULL && count_p != NULL);
+       LASSERT(dents_up != NULL);
+       LASSERT(*index_p >= 0);
+       LASSERT(*count_p > 0);
 
        list_for_each_entry(ndl, head, ndl_link) {
                if (index++ < *index_p)
@@ -905,8 +905,8 @@ lstcon_batch_list(int index, int len, char *name_up)
 {
        lstcon_batch_t    *bat;
 
-       LASSERT (name_up != NULL);
-       LASSERT (index >= 0);
+       LASSERT(name_up != NULL);
+       LASSERT(index >= 0);
 
        list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
                if (index-- == 0) {
@@ -1093,7 +1093,7 @@ lstcon_batch_destroy(lstcon_batch_t *bat)
        while (!list_empty(&bat->bat_test_list)) {
                test = list_entry(bat->bat_test_list.next,
                                      lstcon_test_t, tes_link);
-               LASSERT (list_empty(&test->tes_trans_list));
+               LASSERT(list_empty(&test->tes_trans_list));
 
                list_del(&test->tes_link);
 
@@ -1104,7 +1104,7 @@ lstcon_batch_destroy(lstcon_batch_t *bat)
                                           tes_param[test->tes_paramlen]));
        }
 
-       LASSERT (list_empty(&bat->bat_trans_list));
+       LASSERT(list_empty(&bat->bat_trans_list));
 
        while (!list_empty(&bat->bat_cli_list)) {
                ndl = list_entry(bat->bat_cli_list.next,
@@ -1123,8 +1123,8 @@ lstcon_batch_destroy(lstcon_batch_t *bat)
        }
 
        for (i = 0; i < LST_NODE_HASHSIZE; i++) {
-               LASSERT (list_empty(&bat->bat_cli_hash[i]));
-               LASSERT (list_empty(&bat->bat_srv_hash[i]));
+               LASSERT(list_empty(&bat->bat_cli_hash[i]));
+               LASSERT(list_empty(&bat->bat_srv_hash[i]));
        }
 
        LIBCFS_FREE(bat->bat_cli_hash,
@@ -1144,10 +1144,10 @@ lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
        struct list_head       *head;
 
        test = (lstcon_test_t *)arg;
-       LASSERT (test != NULL);
+       LASSERT(test != NULL);
 
        batch = test->tes_batch;
-       LASSERT (batch != NULL);
+       LASSERT(batch != NULL);
 
        if (test->tes_oneside &&
            transop == LST_TRANS_TSBSRVADD)
@@ -1161,13 +1161,13 @@ lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
                head = &batch->bat_cli_list;
 
        } else {
-               LASSERT (transop == LST_TRANS_TSBSRVADD);
+               LASSERT(transop == LST_TRANS_TSBSRVADD);
 
                hash = batch->bat_srv_hash;
                head = &batch->bat_srv_list;
        }
 
-       LASSERT (nd->nd_id.nid != LNET_NID_ANY);
+       LASSERT(nd->nd_id.nid != LNET_NID_ANY);
 
        if (lstcon_ndlink_find(hash, nd->nd_id, &ndl, 1) != 0)
                return -ENOMEM;
@@ -1186,8 +1186,8 @@ lstcon_test_nodes_add(lstcon_test_t *test, struct list_head *result_up)
        int                  transop;
        int                  rc;
 
-       LASSERT (test->tes_src_grp != NULL);
-       LASSERT (test->tes_dst_grp != NULL);
+       LASSERT(test->tes_src_grp != NULL);
+       LASSERT(test->tes_dst_grp != NULL);
 
        transop = LST_TRANS_TSBSRVADD;
        grp  = test->tes_dst_grp;
@@ -1382,7 +1382,7 @@ lstcon_tsbrpc_readent(int transop, srpc_msg_t *msg,
 {
        srpc_batch_reply_t *rep = &msg->msg_body.bat_reply;
 
-       LASSERT (transop == LST_TRANS_TSBCLIQRY ||
+       LASSERT(transop == LST_TRANS_TSBCLIQRY ||
                 transop == LST_TRANS_TSBSRVQRY);
 
        /* positive errno, framework error code */
@@ -1691,7 +1691,7 @@ lstcon_new_session_id(lst_sid_t *sid)
 {
        lnet_process_id_t      id;
 
-       LASSERT (console_session.ses_state == LST_SESSION_NONE);
+       LASSERT(console_session.ses_state == LST_SESSION_NONE);
 
        LNetGetId(1, &id);
        sid->ses_nid   = id.nid;
@@ -1806,7 +1806,7 @@ lstcon_session_end(void)
        lstcon_batch_t     *bat;
        int              rc = 0;
 
-       LASSERT (console_session.ses_state == LST_SESSION_ACTIVE);
+       LASSERT(console_session.ses_state == LST_SESSION_ACTIVE);
 
        rc = lstcon_rpc_trans_ndlist(&console_session.ses_ndl_list,
                                     NULL, LST_TRANS_SESEND, NULL,
@@ -1846,13 +1846,13 @@ lstcon_session_end(void)
        while (!list_empty(&console_session.ses_grp_list)) {
                grp = list_entry(console_session.ses_grp_list.next,
                                     lstcon_group_t, grp_link);
-               LASSERT (grp->grp_ref == 1);
+               LASSERT(grp->grp_ref == 1);
 
                lstcon_group_put(grp);
        }
 
        /* all nodes should be released */
-       LASSERT (list_empty(&console_session.ses_ndl_list));
+       LASSERT(list_empty(&console_session.ses_ndl_list));
 
        console_session.ses_shutdown = 0;
        console_session.ses_expired  = 0;
@@ -1892,7 +1892,7 @@ lstcon_session_feats_check(unsigned feats)
 }
 
 static int
-lstcon_acceptor_handle (srpc_server_rpc_t *rpc)
+lstcon_acceptor_handle(srpc_server_rpc_t *rpc)
 {
        srpc_msg_t      *rep  = &rpc->srpc_replymsg;
        srpc_msg_t      *req  = &rpc->srpc_reqstbuf->buf_msg;
@@ -2026,7 +2026,7 @@ lstcon_console_init(void)
        lstcon_init_acceptor_service();
 
        rc = srpc_add_service(&lstcon_acceptor_service);
-       LASSERT (rc != -EBUSY);
+       LASSERT(rc != -EBUSY);
        if (rc != 0) {
                LIBCFS_FREE(console_session.ses_ndl_hash,
                            sizeof(struct list_head) * LST_GLOBAL_HASHSIZE);
@@ -2078,13 +2078,13 @@ lstcon_console_fini(void)
 
        mutex_unlock(&console_session.ses_mutex);
 
-       LASSERT (list_empty(&console_session.ses_ndl_list));
-       LASSERT (list_empty(&console_session.ses_grp_list));
-       LASSERT (list_empty(&console_session.ses_bat_list));
-       LASSERT (list_empty(&console_session.ses_trans_list));
+       LASSERT(list_empty(&console_session.ses_ndl_list));
+       LASSERT(list_empty(&console_session.ses_grp_list));
+       LASSERT(list_empty(&console_session.ses_bat_list));
+       LASSERT(list_empty(&console_session.ses_trans_list));
 
        for (i = 0; i < LST_NODE_HASHSIZE; i++) {
-               LASSERT (list_empty(&console_session.ses_ndl_hash[i]));
+               LASSERT(list_empty(&console_session.ses_ndl_hash[i]));
        }
 
        LIBCFS_FREE(console_session.ses_ndl_hash,
index 570914828b8c959cd0059c9bb06afc1e40d46c29..a93a90de0f8580be538f4d9d7f1a2d38633387f2 100644 (file)
@@ -115,18 +115,18 @@ static struct smoketest_framework {
 } sfw_data;
 
 /* forward ref's */
-int sfw_stop_batch (sfw_batch_t *tsb, int force);
-void sfw_destroy_session (sfw_session_t *sn);
+int sfw_stop_batch(sfw_batch_t *tsb, int force);
+void sfw_destroy_session(sfw_session_t *sn);
 
 static inline sfw_test_case_t *
 sfw_find_test_case(int id)
 {
        sfw_test_case_t *tsc;
 
-       LASSERT (id <= SRPC_SERVICE_MAX_ID);
-       LASSERT (id > SRPC_FRAMEWORK_SERVICE_MAX_ID);
+       LASSERT(id <= SRPC_SERVICE_MAX_ID);
+       LASSERT(id > SRPC_FRAMEWORK_SERVICE_MAX_ID);
 
-       list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
+       list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) {
                if (tsc->tsc_srv_service->sv_id == id)
                        return tsc;
        }
@@ -135,12 +135,12 @@ sfw_find_test_case(int id)
 }
 
 static int
-sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops)
+sfw_register_test(srpc_service_t *service, sfw_test_client_ops_t *cliops)
 {
        sfw_test_case_t *tsc;
 
        if (sfw_find_test_case(service->sv_id) != NULL) {
-               CERROR ("Failed to register test %s (%d)\n",
+               CERROR("Failed to register test %s (%d)\n",
                        service->sv_name, service->sv_id);
                return -EEXIST;
        }
@@ -157,17 +157,17 @@ sfw_register_test (srpc_service_t *service, sfw_test_client_ops_t *cliops)
 }
 
 static void
-sfw_add_session_timer (void)
+sfw_add_session_timer(void)
 {
        sfw_session_t *sn = sfw_data.fw_session;
        stt_timer_t   *timer = &sn->sn_timer;
 
-       LASSERT (!sfw_data.fw_shuttingdown);
+       LASSERT(!sfw_data.fw_shuttingdown);
 
        if (sn == NULL || sn->sn_timeout == 0)
                return;
 
-       LASSERT (!sn->sn_timer_active);
+       LASSERT(!sn->sn_timer_active);
 
        sn->sn_timer_active = 1;
        timer->stt_expires = cfs_time_add(sn->sn_timeout,
@@ -177,14 +177,14 @@ sfw_add_session_timer (void)
 }
 
 static int
-sfw_del_session_timer (void)
+sfw_del_session_timer(void)
 {
        sfw_session_t *sn = sfw_data.fw_session;
 
        if (sn == NULL || !sn->sn_timer_active)
                return 0;
 
-       LASSERT (sn->sn_timeout != 0);
+       LASSERT(sn->sn_timeout != 0);
 
        if (stt_del_timer(&sn->sn_timer)) { /* timer defused */
                sn->sn_timer_active = 0;
@@ -195,7 +195,7 @@ sfw_del_session_timer (void)
 }
 
 static void
-sfw_deactivate_session (void)
+sfw_deactivate_session(void)
        __must_hold(&sfw_data.fw_lock)
 {
        sfw_session_t *sn = sfw_data.fw_session;
@@ -205,7 +205,7 @@ sfw_deactivate_session (void)
 
        if (sn == NULL) return;
 
-       LASSERT (!sn->sn_timer_active);
+       LASSERT(!sn->sn_timer_active);
 
        sfw_data.fw_session = NULL;
        atomic_inc(&sfw_data.fw_nzombies);
@@ -219,7 +219,7 @@ sfw_deactivate_session (void)
 
        spin_lock(&sfw_data.fw_lock);
 
-       list_for_each_entry (tsb, &sn->sn_batches, bat_list) {
+       list_for_each_entry(tsb, &sn->sn_batches, bat_list) {
                if (sfw_batch_active(tsb)) {
                        nactive++;
                        sfw_stop_batch(tsb, 1);
@@ -239,16 +239,16 @@ sfw_deactivate_session (void)
 
 
 static void
-sfw_session_expired (void *data)
+sfw_session_expired(void *data)
 {
        sfw_session_t *sn = data;
 
        spin_lock(&sfw_data.fw_lock);
 
-       LASSERT (sn->sn_timer_active);
-       LASSERT (sn == sfw_data.fw_session);
+       LASSERT(sn->sn_timer_active);
+       LASSERT(sn == sfw_data.fw_session);
 
-       CWARN ("Session expired! sid: %s-%llu, name: %s\n",
+       CWARN("Session expired! sid: %s-%llu, name: %s\n",
               libcfs_nid2str(sn->sn_id.ses_nid),
               sn->sn_id.ses_stamp, &sn->sn_name[0]);
 
@@ -290,7 +290,7 @@ sfw_server_rpc_done(struct srpc_server_rpc *rpc)
        struct srpc_service     *sv     = rpc->srpc_scd->scd_svc;
        int                     status  = rpc->srpc_status;
 
-       CDEBUG (D_NET,
+       CDEBUG(D_NET,
                "Incoming framework RPC done: service %s, peer %s, status %s:%d\n",
                sv->sv_name, libcfs_id2str(rpc->srpc_peer),
                swi_state2str(rpc->srpc_wi.swi_state),
@@ -302,13 +302,13 @@ sfw_server_rpc_done(struct srpc_server_rpc *rpc)
 }
 
 static void
-sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
+sfw_client_rpc_fini(srpc_client_rpc_t *rpc)
 {
-       LASSERT (rpc->crpc_bulk.bk_niov == 0);
-       LASSERT (list_empty(&rpc->crpc_list));
-       LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
+       LASSERT(rpc->crpc_bulk.bk_niov == 0);
+       LASSERT(list_empty(&rpc->crpc_list));
+       LASSERT(atomic_read(&rpc->crpc_refcount) == 0);
 
-       CDEBUG (D_NET,
+       CDEBUG(D_NET,
                "Outgoing framework RPC done: service %d, peer %s, status %s:%d:%d\n",
                rpc->crpc_service, libcfs_id2str(rpc->crpc_dest),
                swi_state2str(rpc->crpc_wi.swi_state),
@@ -324,14 +324,14 @@ sfw_client_rpc_fini (srpc_client_rpc_t *rpc)
 }
 
 static sfw_batch_t *
-sfw_find_batch (lst_bid_t bid)
+sfw_find_batch(lst_bid_t bid)
 {
        sfw_session_t *sn = sfw_data.fw_session;
        sfw_batch_t   *bat;
 
-       LASSERT (sn != NULL);
+       LASSERT(sn != NULL);
 
-       list_for_each_entry (bat, &sn->sn_batches, bat_list) {
+       list_for_each_entry(bat, &sn->sn_batches, bat_list) {
                if (bat->bat_id.bat_id == bid.bat_id)
                        return bat;
        }
@@ -340,12 +340,12 @@ sfw_find_batch (lst_bid_t bid)
 }
 
 static sfw_batch_t *
-sfw_bid2batch (lst_bid_t bid)
+sfw_bid2batch(lst_bid_t bid)
 {
        sfw_session_t *sn = sfw_data.fw_session;
        sfw_batch_t   *bat;
 
-       LASSERT (sn != NULL);
+       LASSERT(sn != NULL);
 
        bat = sfw_find_batch(bid);
        if (bat != NULL)
@@ -366,7 +366,7 @@ sfw_bid2batch (lst_bid_t bid)
 }
 
 static int
-sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
+sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
 {
        sfw_session_t  *sn = sfw_data.fw_session;
        sfw_counters_t *cnt = &reply->str_fw;
@@ -399,7 +399,7 @@ sfw_get_stats (srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
        cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);
 
        cnt->active_batches = 0;
-       list_for_each_entry (bat, &sn->sn_batches, bat_list) {
+       list_for_each_entry(bat, &sn->sn_batches, bat_list) {
                if (atomic_read(&bat->bat_nactive) > 0)
                        cnt->active_batches++;
        }
@@ -456,7 +456,7 @@ sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
        /* brand new or create by force */
        LIBCFS_ALLOC(sn, sizeof(sfw_session_t));
        if (sn == NULL) {
-               CERROR ("Dropping RPC (mksn) under memory pressure.\n");
+               CERROR("Dropping RPC (mksn) under memory pressure.\n");
                return -ENOMEM;
        }
 
@@ -478,7 +478,7 @@ sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
 }
 
 static int
-sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
+sfw_remove_session(srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
 
@@ -510,7 +510,7 @@ sfw_remove_session (srpc_rmsn_reqst_t *request, srpc_rmsn_reply_t *reply)
 }
 
 static int
-sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
+sfw_debug_session(srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
 
@@ -531,13 +531,13 @@ sfw_debug_session (srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
 }
 
 static void
-sfw_test_rpc_fini (srpc_client_rpc_t *rpc)
+sfw_test_rpc_fini(srpc_client_rpc_t *rpc)
 {
        sfw_test_unit_t     *tsu = rpc->crpc_priv;
        sfw_test_instance_t *tsi = tsu->tsu_instance;
 
        /* Called with hold of tsi->tsi_lock */
-       LASSERT (list_empty(&rpc->crpc_list));
+       LASSERT(list_empty(&rpc->crpc_list));
        list_add(&rpc->crpc_list, &tsi->tsi_free_rpcs);
 }
 
@@ -608,7 +608,7 @@ sfw_unload_test(struct sfw_test_instance *tsi)
 }
 
 static void
-sfw_destroy_test_instance (sfw_test_instance_t *tsi)
+sfw_destroy_test_instance(sfw_test_instance_t *tsi)
 {
        srpc_client_rpc_t *rpc;
        sfw_test_unit_t   *tsu;
@@ -617,9 +617,9 @@ sfw_destroy_test_instance (sfw_test_instance_t *tsi)
 
        tsi->tsi_ops->tso_fini(tsi);
 
-       LASSERT (!tsi->tsi_stopping);
-       LASSERT (list_empty(&tsi->tsi_active_rpcs));
-       LASSERT (!sfw_test_active(tsi));
+       LASSERT(!tsi->tsi_stopping);
+       LASSERT(list_empty(&tsi->tsi_active_rpcs));
+       LASSERT(!sfw_test_active(tsi));
 
        while (!list_empty(&tsi->tsi_units)) {
                tsu = list_entry(tsi->tsi_units.next,
@@ -642,12 +642,12 @@ clean:
 }
 
 static void
-sfw_destroy_batch (sfw_batch_t *tsb)
+sfw_destroy_batch(sfw_batch_t *tsb)
 {
        sfw_test_instance_t *tsi;
 
-       LASSERT (!sfw_batch_active(tsb));
-       LASSERT (list_empty(&tsb->bat_list));
+       LASSERT(!sfw_batch_active(tsb));
+       LASSERT(list_empty(&tsb->bat_list));
 
        while (!list_empty(&tsb->bat_tests)) {
                tsi = list_entry(tsb->bat_tests.next,
@@ -661,12 +661,12 @@ sfw_destroy_batch (sfw_batch_t *tsb)
 }
 
 void
-sfw_destroy_session (sfw_session_t *sn)
+sfw_destroy_session(sfw_session_t *sn)
 {
        sfw_batch_t *batch;
 
-       LASSERT (list_empty(&sn->sn_list));
-       LASSERT (sn != sfw_data.fw_session);
+       LASSERT(list_empty(&sn->sn_list));
+       LASSERT(sn != sfw_data.fw_session);
 
        while (!list_empty(&sn->sn_batches)) {
                batch = list_entry(sn->sn_batches.next,
@@ -685,13 +685,13 @@ sfw_unpack_addtest_req(srpc_msg_t *msg)
 {
        srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
 
-       LASSERT (msg->msg_type == SRPC_MSG_TEST_REQST);
-       LASSERT (req->tsr_is_client);
+       LASSERT(msg->msg_type == SRPC_MSG_TEST_REQST);
+       LASSERT(req->tsr_is_client);
 
        if (msg->msg_magic == SRPC_MSG_MAGIC)
                return; /* no flipping needed */
 
-       LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
+       LASSERT(msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
 
        if (req->tsr_service == SRPC_SERVICE_BRW) {
                if ((msg->msg_ses_feats & LST_FEAT_BULK_LEN) == 0) {
@@ -721,12 +721,12 @@ sfw_unpack_addtest_req(srpc_msg_t *msg)
                return;
        }
 
-       LBUG ();
+       LBUG();
        return;
 }
 
 static int
-sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
+sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
 {
        srpc_msg_t        *msg = &rpc->srpc_reqstbuf->buf_msg;
        srpc_test_reqst_t   *req = &msg->msg_body.tes_reqst;
@@ -739,7 +739,7 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
 
        LIBCFS_ALLOC(tsi, sizeof(*tsi));
        if (tsi == NULL) {
-               CERROR ("Can't allocate test instance for batch: %llu\n",
+               CERROR("Can't allocate test instance for batch: %llu\n",
                        tsb->bat_id.bat_id);
                return -ENOMEM;
        }
@@ -764,7 +764,7 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
                return rc;
        }
 
-       LASSERT (!sfw_batch_active(tsb));
+       LASSERT(!sfw_batch_active(tsb));
 
        if (!tsi->tsi_is_client) {
                /* it's test server, just add it to tsb */
@@ -772,8 +772,8 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
                return 0;
        }
 
-       LASSERT (bk != NULL);
-       LASSERT (bk->bk_niov * SFW_ID_PER_PAGE >= (unsigned int)ndest);
+       LASSERT(bk != NULL);
+       LASSERT(bk->bk_niov * SFW_ID_PER_PAGE >= (unsigned int)ndest);
        LASSERT((unsigned int)bk->bk_len >=
                sizeof(lnet_process_id_packed_t) * ndest);
 
@@ -786,7 +786,7 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
                int                    j;
 
                dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page);
-               LASSERT (dests != NULL);  /* my pages are within KVM always */
+               LASSERT(dests != NULL);  /* my pages are within KVM always */
                id = dests[i % SFW_ID_PER_PAGE];
                if (msg->msg_magic != SRPC_MSG_MAGIC)
                        sfw_unpack_id(id);
@@ -795,7 +795,7 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
                        LIBCFS_ALLOC(tsu, sizeof(sfw_test_unit_t));
                        if (tsu == NULL) {
                                rc = -ENOMEM;
-                               CERROR ("Can't allocate tsu for %d\n",
+                               CERROR("Can't allocate tsu for %d\n",
                                        tsi->tsi_service);
                                goto error;
                        }
@@ -815,19 +815,19 @@ sfw_add_test_instance (sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
        }
 
 error:
-       LASSERT (rc != 0);
+       LASSERT(rc != 0);
        sfw_destroy_test_instance(tsi);
        return rc;
 }
 
 static void
-sfw_test_unit_done (sfw_test_unit_t *tsu)
+sfw_test_unit_done(sfw_test_unit_t *tsu)
 {
        sfw_test_instance_t *tsi = tsu->tsu_instance;
        sfw_batch_t      *tsb = tsi->tsi_batch;
        sfw_session_t       *sn = tsb->bat_session;
 
-       LASSERT (sfw_test_active(tsi));
+       LASSERT(sfw_test_active(tsi));
 
        if (!atomic_dec_and_test(&tsi->tsi_nactive))
                return;
@@ -847,9 +847,9 @@ sfw_test_unit_done (sfw_test_unit_t *tsu)
                return;
        }
 
-       LASSERT (!list_empty(&sn->sn_list)); /* I'm a zombie! */
+       LASSERT(!list_empty(&sn->sn_list)); /* I'm a zombie! */
 
-       list_for_each_entry (tsb, &sn->sn_batches, bat_list) {
+       list_for_each_entry(tsb, &sn->sn_batches, bat_list) {
                if (sfw_batch_active(tsb)) {
                        spin_unlock(&sfw_data.fw_lock);
                        return;
@@ -864,7 +864,7 @@ sfw_test_unit_done (sfw_test_unit_t *tsu)
 }
 
 static void
-sfw_test_rpc_done (srpc_client_rpc_t *rpc)
+sfw_test_rpc_done(srpc_client_rpc_t *rpc)
 {
        sfw_test_unit_t     *tsu = rpc->crpc_priv;
        sfw_test_instance_t *tsi = tsu->tsu_instance;
@@ -874,8 +874,8 @@ sfw_test_rpc_done (srpc_client_rpc_t *rpc)
 
        spin_lock(&tsi->tsi_lock);
 
-       LASSERT (sfw_test_active(tsi));
-       LASSERT (!list_empty(&rpc->crpc_list));
+       LASSERT(sfw_test_active(tsi));
+       LASSERT(!list_empty(&rpc->crpc_list));
 
        list_del_init(&rpc->crpc_list);
 
@@ -909,13 +909,13 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
 
        spin_lock(&tsi->tsi_lock);
 
-       LASSERT (sfw_test_active(tsi));
+       LASSERT(sfw_test_active(tsi));
 
        if (!list_empty(&tsi->tsi_free_rpcs)) {
                /* pick request from buffer */
                rpc = list_entry(tsi->tsi_free_rpcs.next,
                                     srpc_client_rpc_t, crpc_list);
-               LASSERT (nblk == rpc->crpc_bulk.bk_niov);
+               LASSERT(nblk == rpc->crpc_bulk.bk_niov);
                list_del_init(&rpc->crpc_list);
        }
 
@@ -943,20 +943,20 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
 }
 
 static int
-sfw_run_test (swi_workitem_t *wi)
+sfw_run_test(swi_workitem_t *wi)
 {
        sfw_test_unit_t     *tsu = wi->swi_workitem.wi_data;
        sfw_test_instance_t *tsi = tsu->tsu_instance;
        srpc_client_rpc_t   *rpc = NULL;
 
-       LASSERT (wi == &tsu->tsu_worker);
+       LASSERT(wi == &tsu->tsu_worker);
 
        if (tsi->tsi_ops->tso_prep_rpc(tsu, tsu->tsu_dest, &rpc) != 0) {
-               LASSERT (rpc == NULL);
+               LASSERT(rpc == NULL);
                goto test_done;
        }
 
-       LASSERT (rpc != NULL);
+       LASSERT(rpc != NULL);
 
        spin_lock(&tsi->tsi_lock);
 
@@ -993,7 +993,7 @@ test_done:
 }
 
 static int
-sfw_run_batch (sfw_batch_t *tsb)
+sfw_run_batch(sfw_batch_t *tsb)
 {
        swi_workitem_t      *wi;
        sfw_test_unit_t     *tsu;
@@ -1005,16 +1005,16 @@ sfw_run_batch (sfw_batch_t *tsb)
                return 0;
        }
 
-       list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
+       list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) {
                if (!tsi->tsi_is_client) /* skip server instances */
                        continue;
 
-               LASSERT (!tsi->tsi_stopping);
-               LASSERT (!sfw_test_active(tsi));
+               LASSERT(!tsi->tsi_stopping);
+               LASSERT(!sfw_test_active(tsi));
 
                atomic_inc(&tsb->bat_nactive);
 
-               list_for_each_entry (tsu, &tsi->tsi_units, tsu_list) {
+               list_for_each_entry(tsu, &tsi->tsi_units, tsu_list) {
                        atomic_inc(&tsi->tsi_nactive);
                        tsu->tsu_loop = tsi->tsi_loop;
                        wi = &tsu->tsu_worker;
@@ -1029,7 +1029,7 @@ sfw_run_batch (sfw_batch_t *tsb)
 }
 
 int
-sfw_stop_batch (sfw_batch_t *tsb, int force)
+sfw_stop_batch(sfw_batch_t *tsb, int force)
 {
        sfw_test_instance_t *tsi;
        srpc_client_rpc_t   *rpc;
@@ -1039,7 +1039,7 @@ sfw_stop_batch (sfw_batch_t *tsb, int force)
                return 0;
        }
 
-       list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
+       list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) {
                spin_lock(&tsi->tsi_lock);
 
                if (!tsi->tsi_is_client ||
@@ -1071,7 +1071,7 @@ sfw_stop_batch (sfw_batch_t *tsb, int force)
 }
 
 static int
-sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
+sfw_query_batch(sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
 {
        sfw_test_instance_t *tsi;
 
@@ -1083,7 +1083,7 @@ sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
                return 0;
        }
 
-       list_for_each_entry (tsi, &tsb->bat_tests, tsi_list) {
+       list_for_each_entry(tsi, &tsb->bat_tests, tsi_list) {
                if (testidx-- > 1)
                        continue;
 
@@ -1095,7 +1095,7 @@ sfw_query_batch (sfw_batch_t *tsb, int testidx, srpc_batch_reply_t *reply)
 }
 
 void
-sfw_free_pages (srpc_server_rpc_t *rpc)
+sfw_free_pages(srpc_server_rpc_t *rpc)
 {
        srpc_free_bulk(rpc->srpc_bulk);
        rpc->srpc_bulk = NULL;
@@ -1116,7 +1116,7 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
 }
 
 static int
-sfw_add_test (srpc_server_rpc_t *rpc)
+sfw_add_test(srpc_server_rpc_t *rpc)
 {
        sfw_session_t     *sn = sfw_data.fw_session;
        srpc_test_reply_t *reply = &rpc->srpc_replymsg.msg_body.tes_reply;
@@ -1147,7 +1147,7 @@ sfw_add_test (srpc_server_rpc_t *rpc)
 
        bat = sfw_bid2batch(request->tsr_bid);
        if (bat == NULL) {
-               CERROR ("Dropping RPC (%s) from %s under memory pressure.\n",
+               CERROR("Dropping RPC (%s) from %s under memory pressure.\n",
                        rpc->srpc_scd->scd_svc->sv_name,
                        libcfs_id2str(rpc->srpc_peer));
                return -ENOMEM;
@@ -1175,7 +1175,7 @@ sfw_add_test (srpc_server_rpc_t *rpc)
        }
 
        rc = sfw_add_test_instance(bat, rpc);
-       CDEBUG (rc == 0 ? D_NET : D_WARNING,
+       CDEBUG(rc == 0 ? D_NET : D_WARNING,
                "%s test: sv %d %s, loop %d, concur %d, ndest %d\n",
                rc == 0 ? "Added" : "Failed to add", request->tsr_service,
                request->tsr_is_client ? "client" : "server",
@@ -1186,7 +1186,7 @@ sfw_add_test (srpc_server_rpc_t *rpc)
 }
 
 static int
-sfw_control_batch (srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
+sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
 {
        sfw_session_t *sn = sfw_data.fw_session;
        int         rc = 0;
@@ -1285,7 +1285,7 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
 
        switch (sv->sv_id) {
        default:
-               LBUG ();
+               LBUG();
        case SRPC_SERVICE_TEST:
                rc = sfw_add_test(rpc);
                break;
@@ -1387,8 +1387,8 @@ sfw_create_rpc(lnet_process_id_t peer, int service,
 
        spin_lock(&sfw_data.fw_lock);
 
-       LASSERT (!sfw_data.fw_shuttingdown);
-       LASSERT (service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
+       LASSERT(!sfw_data.fw_shuttingdown);
+       LASSERT(service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
 
        if (nbulkiov == 0 && !list_empty(&sfw_data.fw_zombie_rpcs)) {
                rpc = list_entry(sfw_data.fw_zombie_rpcs.next,
@@ -1416,13 +1416,13 @@ sfw_create_rpc(lnet_process_id_t peer, int service,
 }
 
 void
-sfw_unpack_message (srpc_msg_t *msg)
+sfw_unpack_message(srpc_msg_t *msg)
 {
        if (msg->msg_magic == SRPC_MSG_MAGIC)
                return; /* no flipping needed */
 
        /* srpc module should guarantee I wouldn't get crap */
-       LASSERT (msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
+       LASSERT(msg->msg_magic == __swab32(SRPC_MSG_MAGIC));
 
        if (msg->msg_type == SRPC_MSG_STAT_REQST) {
                srpc_stat_reqst_t *req = &msg->msg_body.stat_reqst;
@@ -1555,12 +1555,12 @@ sfw_unpack_message (srpc_msg_t *msg)
                return;
        }
 
-       LBUG ();
+       LBUG();
        return;
 }
 
 void
-sfw_abort_rpc (srpc_client_rpc_t *rpc)
+sfw_abort_rpc(srpc_client_rpc_t *rpc)
 {
        LASSERT(atomic_read(&rpc->crpc_refcount) > 0);
        LASSERT(rpc->crpc_service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
@@ -1572,14 +1572,14 @@ sfw_abort_rpc (srpc_client_rpc_t *rpc)
 }
 
 void
-sfw_post_rpc (srpc_client_rpc_t *rpc)
+sfw_post_rpc(srpc_client_rpc_t *rpc)
 {
        spin_lock(&rpc->crpc_lock);
 
-       LASSERT (!rpc->crpc_closed);
-       LASSERT (!rpc->crpc_aborted);
-       LASSERT (list_empty(&rpc->crpc_list));
-       LASSERT (!sfw_data.fw_shuttingdown);
+       LASSERT(!rpc->crpc_closed);
+       LASSERT(!rpc->crpc_aborted);
+       LASSERT(list_empty(&rpc->crpc_list));
+       LASSERT(!sfw_data.fw_shuttingdown);
 
        rpc->crpc_timeout = rpc_timeout;
        srpc_post_rpc(rpc);
@@ -1638,7 +1638,7 @@ extern void brw_init_test_service(void);
 
 
 int
-sfw_startup (void)
+sfw_startup(void)
 {
        int           i;
        int           rc;
@@ -1648,13 +1648,13 @@ sfw_startup (void)
 
 
        if (session_timeout < 0) {
-               CERROR ("Session timeout must be non-negative: %d\n",
+               CERROR("Session timeout must be non-negative: %d\n",
                        session_timeout);
                return -EINVAL;
        }
 
        if (rpc_timeout < 0) {
-               CERROR ("RPC timeout must be non-negative: %d\n",
+               CERROR("RPC timeout must be non-negative: %d\n",
                        rpc_timeout);
                return -EINVAL;
        }
@@ -1678,21 +1678,21 @@ sfw_startup (void)
        brw_init_test_client();
        brw_init_test_service();
        rc = sfw_register_test(&brw_test_service, &brw_test_client);
-       LASSERT (rc == 0);
+       LASSERT(rc == 0);
 
        ping_init_test_client();
        ping_init_test_service();
        rc = sfw_register_test(&ping_test_service, &ping_test_client);
-       LASSERT (rc == 0);
+       LASSERT(rc == 0);
 
        error = 0;
-       list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
+       list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) {
                sv = tsc->tsc_srv_service;
 
                rc = srpc_add_service(sv);
-               LASSERT (rc != -EBUSY);
+               LASSERT(rc != -EBUSY);
                if (rc != 0) {
-                       CWARN ("Failed to add %s service: %d\n",
+                       CWARN("Failed to add %s service: %d\n",
                               sv->sv_name, rc);
                        error = rc;
                }
@@ -1709,9 +1709,9 @@ sfw_startup (void)
                        sv->sv_bulk_ready = sfw_bulk_ready;
 
                rc = srpc_add_service(sv);
-               LASSERT (rc != -EBUSY);
+               LASSERT(rc != -EBUSY);
                if (rc != 0) {
-                       CWARN ("Failed to add %s service: %d\n",
+                       CWARN("Failed to add %s service: %d\n",
                               sv->sv_name, rc);
                        error = rc;
                }
@@ -1733,7 +1733,7 @@ sfw_startup (void)
 }
 
 void
-sfw_shutdown (void)
+sfw_shutdown(void)
 {
        srpc_service_t  *sv;
        sfw_test_case_t *tsc;
@@ -1766,7 +1766,7 @@ sfw_shutdown (void)
                srpc_remove_service(sv);
        }
 
-       list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
+       list_for_each_entry(tsc, &sfw_data.fw_tests, tsc_list) {
                sv = tsc->tsc_srv_service;
                srpc_shutdown_service(sv);
                srpc_remove_service(sv);
index 1f7d9a6248db870b585ba09e8798a8769084f44c..080788ab749ef969fec02cf30cacb6729608d445 100644 (file)
@@ -71,16 +71,16 @@ srpc_serv_portal(int svc_id)
 }
 
 /* forward ref's */
-int srpc_handle_rpc (swi_workitem_t *wi);
+int srpc_handle_rpc(swi_workitem_t *wi);
 
-void srpc_get_counters (srpc_counters_t *cnt)
+void srpc_get_counters(srpc_counters_t *cnt)
 {
        spin_lock(&srpc_data.rpc_glock);
        *cnt = srpc_data.rpc_counters;
        spin_unlock(&srpc_data.rpc_glock);
 }
 
-void srpc_set_counters (const srpc_counters_t *cnt)
+void srpc_set_counters(const srpc_counters_t *cnt)
 {
        spin_lock(&srpc_data.rpc_glock);
        srpc_data.rpc_counters = *cnt;
@@ -102,16 +102,17 @@ srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
 }
 
 void
-srpc_free_bulk (srpc_bulk_t *bk)
+srpc_free_bulk(srpc_bulk_t *bk)
 {
        int      i;
        struct page *pg;
 
-       LASSERT (bk != NULL);
+       LASSERT(bk != NULL);
 
        for (i = 0; i < bk->bk_niov; i++) {
                pg = bk->bk_iovs[i].kiov_page;
-               if (pg == NULL) break;
+               if (pg == NULL)
+                       break;
 
                __free_page(pg);
        }
@@ -160,7 +161,7 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
 }
 
 static inline __u64
-srpc_next_id (void)
+srpc_next_id(void)
 {
        __u64 id;
 
@@ -335,7 +336,7 @@ srpc_add_service(struct srpc_service *sv)
 }
 
 int
-srpc_remove_service (srpc_service_t *sv)
+srpc_remove_service(srpc_service_t *sv)
 {
        int id = sv->sv_id;
 
@@ -363,8 +364,8 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
        rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK,
                          local ? LNET_INS_LOCAL : LNET_INS_AFTER, &meh);
        if (rc != 0) {
-               CERROR ("LNetMEAttach failed: %d\n", rc);
-               LASSERT (rc == -ENOMEM);
+               CERROR("LNetMEAttach failed: %d\n", rc);
+               LASSERT(rc == -ENOMEM);
                return -ENOMEM;
        }
 
@@ -377,15 +378,15 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
 
        rc = LNetMDAttach(meh, md, LNET_UNLINK, mdh);
        if (rc != 0) {
-               CERROR ("LNetMDAttach failed: %d\n", rc);
-               LASSERT (rc == -ENOMEM);
+               CERROR("LNetMDAttach failed: %d\n", rc);
+               LASSERT(rc == -ENOMEM);
 
                rc = LNetMEUnlink(meh);
-               LASSERT (rc == 0);
+               LASSERT(rc == 0);
                return -ENOMEM;
        }
 
-       CDEBUG (D_NET,
+       CDEBUG(D_NET,
                "Posted passive RDMA: peer %s, portal %d, matchbits %#llx\n",
                libcfs_id2str(peer), portal, matchbits);
        return 0;
@@ -408,8 +409,8 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
 
        rc = LNetMDBind(md, LNET_UNLINK, mdh);
        if (rc != 0) {
-               CERROR ("LNetMDBind failed: %d\n", rc);
-               LASSERT (rc == -ENOMEM);
+               CERROR("LNetMDBind failed: %d\n", rc);
+               LASSERT(rc == -ENOMEM);
                return -ENOMEM;
        }
 
@@ -420,13 +421,13 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
                rc = LNetPut(self, *mdh, LNET_NOACK_REQ, peer,
                             portal, matchbits, 0, 0);
        } else {
-               LASSERT ((options & LNET_MD_OP_GET) != 0);
+               LASSERT((options & LNET_MD_OP_GET) != 0);
 
                rc = LNetGet(self, *mdh, peer, portal, matchbits, 0);
        }
 
        if (rc != 0) {
-               CERROR ("LNet%s(%s, %d, %lld) failed: %d\n",
+               CERROR("LNet%s(%s, %d, %lld) failed: %d\n",
                        ((options & LNET_MD_OP_PUT) != 0) ? "Put" : "Get",
                        libcfs_id2str(peer), portal, matchbits, rc);
 
@@ -434,9 +435,9 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
                 * with failure, so fall through and return success here.
                 */
                rc = LNetMDUnlink(*mdh);
-               LASSERT (rc == 0);
+               LASSERT(rc == 0);
        } else {
-               CDEBUG (D_NET,
+               CDEBUG(D_NET,
                        "Posted active RDMA: peer %s, portal %u, matchbits %#llx\n",
                        libcfs_id2str(peer), portal, matchbits);
        }
@@ -788,7 +789,7 @@ srpc_shutdown_service(srpc_service_t *sv)
 }
 
 static int
-srpc_send_request (srpc_client_rpc_t *rpc)
+srpc_send_request(srpc_client_rpc_t *rpc)
 {
        srpc_event_t *ev = &rpc->crpc_reqstev;
        int        rc;
@@ -801,14 +802,14 @@ srpc_send_request (srpc_client_rpc_t *rpc)
                                     &rpc->crpc_reqstmsg, sizeof(srpc_msg_t),
                                     &rpc->crpc_reqstmdh, ev);
        if (rc != 0) {
-               LASSERT (rc == -ENOMEM);
+               LASSERT(rc == -ENOMEM);
                ev->ev_fired = 1;  /* no more event expected */
        }
        return rc;
 }
 
 static int
-srpc_prepare_reply (srpc_client_rpc_t *rpc)
+srpc_prepare_reply(srpc_client_rpc_t *rpc)
 {
        srpc_event_t *ev = &rpc->crpc_replyev;
        __u64   *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid;
@@ -825,14 +826,14 @@ srpc_prepare_reply (srpc_client_rpc_t *rpc)
                                    LNET_MD_OP_PUT, rpc->crpc_dest,
                                    &rpc->crpc_replymdh, ev);
        if (rc != 0) {
-               LASSERT (rc == -ENOMEM);
+               LASSERT(rc == -ENOMEM);
                ev->ev_fired = 1;  /* no more event expected */
        }
        return rc;
 }
 
 static int
-srpc_prepare_bulk (srpc_client_rpc_t *rpc)
+srpc_prepare_bulk(srpc_client_rpc_t *rpc)
 {
        srpc_bulk_t  *bk = &rpc->crpc_bulk;
        srpc_event_t *ev = &rpc->crpc_bulkev;
@@ -840,9 +841,10 @@ srpc_prepare_bulk (srpc_client_rpc_t *rpc)
        int        rc;
        int        opt;
 
-       LASSERT (bk->bk_niov <= LNET_MAX_IOV);
+       LASSERT(bk->bk_niov <= LNET_MAX_IOV);
 
-       if (bk->bk_niov == 0) return 0; /* nothing to do */
+       if (bk->bk_niov == 0)
+               return 0; /* nothing to do */
 
        opt = bk->bk_sink ? LNET_MD_OP_PUT : LNET_MD_OP_GET;
        opt |= LNET_MD_KIOV;
@@ -857,14 +859,14 @@ srpc_prepare_bulk (srpc_client_rpc_t *rpc)
                                    &bk->bk_iovs[0], bk->bk_niov, opt,
                                    rpc->crpc_dest, &bk->bk_mdh, ev);
        if (rc != 0) {
-               LASSERT (rc == -ENOMEM);
+               LASSERT(rc == -ENOMEM);
                ev->ev_fired = 1;  /* no more event expected */
        }
        return rc;
 }
 
 static int
-srpc_do_bulk (srpc_server_rpc_t *rpc)
+srpc_do_bulk(srpc_server_rpc_t *rpc)
 {
        srpc_event_t  *ev = &rpc->srpc_ev;
        srpc_bulk_t   *bk = rpc->srpc_bulk;
@@ -872,7 +874,7 @@ srpc_do_bulk (srpc_server_rpc_t *rpc)
        int         rc;
        int         opt;
 
-       LASSERT (bk != NULL);
+       LASSERT(bk != NULL);
 
        opt = bk->bk_sink ? LNET_MD_OP_GET : LNET_MD_OP_PUT;
        opt |= LNET_MD_KIOV;
@@ -898,11 +900,11 @@ srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
        struct srpc_service     *sv  = scd->scd_svc;
        srpc_buffer_t           *buffer;
 
-       LASSERT (status != 0 || rpc->srpc_wi.swi_state == SWI_STATE_DONE);
+       LASSERT(status != 0 || rpc->srpc_wi.swi_state == SWI_STATE_DONE);
 
        rpc->srpc_status = status;
 
-       CDEBUG_LIMIT (status == 0 ? D_NET : D_NETERROR,
+       CDEBUG_LIMIT(status == 0 ? D_NET : D_NETERROR,
                "Server RPC %p done: service %s, peer %s, status %s:%d\n",
                rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer),
                swi_state2str(rpc->srpc_wi.swi_state), status);
@@ -985,7 +987,7 @@ srpc_handle_rpc(swi_workitem_t *wi)
 
        switch (wi->swi_state) {
        default:
-               LBUG ();
+               LBUG();
        case SWI_STATE_NEWBORN: {
                srpc_msg_t         *msg;
                srpc_generic_reply_t *reply;
@@ -1023,12 +1025,12 @@ srpc_handle_rpc(swi_workitem_t *wi)
                        if (rc == 0)
                                return 0; /* wait for bulk */
 
-                       LASSERT (ev->ev_fired);
+                       LASSERT(ev->ev_fired);
                        ev->ev_status = rc;
                }
        }
        case SWI_STATE_BULK_STARTED:
-               LASSERT (rpc->srpc_bulk == NULL || ev->ev_fired);
+               LASSERT(rpc->srpc_bulk == NULL || ev->ev_fired);
 
                if (rpc->srpc_bulk != NULL) {
                        rc = ev->ev_status;
@@ -1055,7 +1057,7 @@ srpc_handle_rpc(swi_workitem_t *wi)
                               rpc, rpc->srpc_bulk, sv->sv_id);
                        CERROR("Event: status %d, type %d, lnet %d\n",
                               ev->ev_status, ev->ev_type, ev->ev_lnet);
-                       LASSERT (ev->ev_fired);
+                       LASSERT(ev->ev_fired);
                }
 
                wi->swi_state = SWI_STATE_DONE;
@@ -1067,11 +1069,11 @@ srpc_handle_rpc(swi_workitem_t *wi)
 }
 
 static void
-srpc_client_rpc_expired (void *data)
+srpc_client_rpc_expired(void *data)
 {
        srpc_client_rpc_t *rpc = data;
 
-       CWARN ("Client RPC expired: service %d, peer %s, timeout %d.\n",
+       CWARN("Client RPC expired: service %d, peer %s, timeout %d.\n",
               rpc->crpc_service, libcfs_id2str(rpc->crpc_dest),
               rpc->crpc_timeout);
 
@@ -1088,11 +1090,12 @@ srpc_client_rpc_expired (void *data)
 }
 
 inline void
-srpc_add_client_rpc_timer (srpc_client_rpc_t *rpc)
+srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc)
 {
        stt_timer_t *timer = &rpc->crpc_timer;
 
-       if (rpc->crpc_timeout == 0) return;
+       if (rpc->crpc_timeout == 0)
+               return;
 
        INIT_LIST_HEAD(&timer->stt_list);
        timer->stt_data    = rpc;
@@ -1109,7 +1112,7 @@ srpc_add_client_rpc_timer (srpc_client_rpc_t *rpc)
  * Upon exit the RPC expiry timer is not queued and the handler is not
  * running on any CPU. */
 static void
-srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc)
+srpc_del_client_rpc_timer(srpc_client_rpc_t *rpc)
 {
        /* timer not planted or already exploded */
        if (rpc->crpc_timeout == 0)
@@ -1130,7 +1133,7 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc)
 }
 
 static void
-srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
+srpc_client_rpc_done(srpc_client_rpc_t *rpc, int status)
 {
        swi_workitem_t *wi = &rpc->crpc_wi;
 
@@ -1144,7 +1147,7 @@ srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
 
        srpc_del_client_rpc_timer(rpc);
 
-       CDEBUG_LIMIT ((status == 0) ? D_NET : D_NETERROR,
+       CDEBUG_LIMIT((status == 0) ? D_NET : D_NETERROR,
                "Client RPC done: service %d, peer %s, status %s:%d:%d\n",
                rpc->crpc_service, libcfs_id2str(rpc->crpc_dest),
                swi_state2str(wi->swi_state), rpc->crpc_aborted, status);
@@ -1157,7 +1160,7 @@ srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
         *   scheduling me.
         * Cancel pending schedules and prevent future schedule attempts:
         */
-       LASSERT (!srpc_event_pending(rpc));
+       LASSERT(!srpc_event_pending(rpc));
        swi_exit_workitem(wi);
 
        spin_unlock(&rpc->crpc_lock);
@@ -1168,7 +1171,7 @@ srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
 
 /* sends an outgoing RPC */
 int
-srpc_send_rpc (swi_workitem_t *wi)
+srpc_send_rpc(swi_workitem_t *wi)
 {
        int             rc = 0;
        srpc_client_rpc_t *rpc;
@@ -1179,8 +1182,8 @@ srpc_send_rpc (swi_workitem_t *wi)
 
        rpc = wi->swi_workitem.wi_data;
 
-       LASSERT (rpc != NULL);
-       LASSERT (wi == &rpc->crpc_wi);
+       LASSERT(rpc != NULL);
+       LASSERT(wi == &rpc->crpc_wi);
 
        reply = &rpc->crpc_replymsg;
        do_bulk = rpc->crpc_bulk.bk_niov > 0;
@@ -1196,9 +1199,9 @@ srpc_send_rpc (swi_workitem_t *wi)
 
        switch (wi->swi_state) {
        default:
-               LBUG ();
+               LBUG();
        case SWI_STATE_NEWBORN:
-               LASSERT (!srpc_event_pending(rpc));
+               LASSERT(!srpc_event_pending(rpc));
 
                rc = srpc_prepare_reply(rpc);
                if (rc != 0) {
@@ -1207,7 +1210,8 @@ srpc_send_rpc (swi_workitem_t *wi)
                }
 
                rc = srpc_prepare_bulk(rpc);
-               if (rc != 0) break;
+               if (rc != 0)
+                       break;
 
                wi->swi_state = SWI_STATE_REQUEST_SUBMITTED;
                rc = srpc_send_request(rpc);
@@ -1217,20 +1221,24 @@ srpc_send_rpc (swi_workitem_t *wi)
                /* CAVEAT EMPTOR: rqtev, rpyev, and bulkev may come in any
                 * order; however, they're processed in a strict order:
                 * rqt, rpy, and bulk. */
-               if (!rpc->crpc_reqstev.ev_fired) break;
+               if (!rpc->crpc_reqstev.ev_fired)
+                       break;
 
                rc = rpc->crpc_reqstev.ev_status;
-               if (rc != 0) break;
+               if (rc != 0)
+                       break;
 
                wi->swi_state = SWI_STATE_REQUEST_SENT;
                /* perhaps more events, fall thru */
        case SWI_STATE_REQUEST_SENT: {
                srpc_msg_type_t type = srpc_service2reply(rpc->crpc_service);
 
-               if (!rpc->crpc_replyev.ev_fired) break;
+               if (!rpc->crpc_replyev.ev_fired)
+                       break;
 
                rc = rpc->crpc_replyev.ev_status;
-               if (rc != 0) break;
+               if (rc != 0)
+                       break;
 
                srpc_unpack_msg_hdr(reply);
                if (reply->msg_type != type ||
@@ -1254,7 +1262,8 @@ srpc_send_rpc (swi_workitem_t *wi)
                wi->swi_state = SWI_STATE_REPLY_RECEIVED;
        }
        case SWI_STATE_REPLY_RECEIVED:
-               if (do_bulk && !rpc->crpc_bulkev.ev_fired) break;
+               if (do_bulk && !rpc->crpc_bulkev.ev_fired)
+                       break;
 
                rc = do_bulk ? rpc->crpc_bulkev.ev_status : 0;
 
@@ -1292,7 +1301,7 @@ abort:
 }
 
 srpc_client_rpc_t *
-srpc_create_client_rpc (lnet_process_id_t peer, int service,
+srpc_create_client_rpc(lnet_process_id_t peer, int service,
                        int nbulkiov, int bulklen,
                        void (*rpc_done)(srpc_client_rpc_t *),
                        void (*rpc_fini)(srpc_client_rpc_t *), void *priv)
@@ -1311,15 +1320,15 @@ srpc_create_client_rpc (lnet_process_id_t peer, int service,
 
 /* called with rpc->crpc_lock held */
 void
-srpc_abort_rpc (srpc_client_rpc_t *rpc, int why)
+srpc_abort_rpc(srpc_client_rpc_t *rpc, int why)
 {
-       LASSERT (why != 0);
+       LASSERT(why != 0);
 
        if (rpc->crpc_aborted || /* already aborted */
            rpc->crpc_closed)    /* callback imminent */
                return;
 
-       CDEBUG (D_NET,
+       CDEBUG(D_NET,
                "Aborting RPC: service %d, peer %s, state %s, why %d\n",
                rpc->crpc_service, libcfs_id2str(rpc->crpc_dest),
                swi_state2str(rpc->crpc_wi.swi_state), why);
@@ -1332,12 +1341,12 @@ srpc_abort_rpc (srpc_client_rpc_t *rpc, int why)
 
 /* called with rpc->crpc_lock held */
 void
-srpc_post_rpc (srpc_client_rpc_t *rpc)
+srpc_post_rpc(srpc_client_rpc_t *rpc)
 {
-       LASSERT (!rpc->crpc_aborted);
-       LASSERT (srpc_data.rpc_state == SRPC_STATE_RUNNING);
+       LASSERT(!rpc->crpc_aborted);
+       LASSERT(srpc_data.rpc_state == SRPC_STATE_RUNNING);
 
-       CDEBUG (D_NET, "Posting RPC: peer %s, service %d, timeout %d\n",
+       CDEBUG(D_NET, "Posting RPC: peer %s, service %d, timeout %d\n",
                libcfs_id2str(rpc->crpc_dest), rpc->crpc_service,
                rpc->crpc_timeout);
 
@@ -1403,7 +1412,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
        srpc_msg_t      *msg;
        srpc_msg_type_t    type;
 
-       LASSERT (!in_interrupt());
+       LASSERT(!in_interrupt());
 
        if (ev->status != 0) {
                spin_lock(&srpc_data.rpc_glock);
@@ -1417,7 +1426,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
        default:
                CERROR("Unknown event: status %d, type %d, lnet %d\n",
                       rpcev->ev_status, rpcev->ev_type, rpcev->ev_lnet);
-               LBUG ();
+               LBUG();
        case SRPC_REQUEST_SENT:
                if (ev->status == 0 && ev->type != LNET_EVENT_UNLINK) {
                        spin_lock(&srpc_data.rpc_glock);
@@ -1436,7 +1445,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
                               &crpc->crpc_replyev, &crpc->crpc_bulkev);
                        CERROR("Bad event: status %d, type %d, lnet %d\n",
                               rpcev->ev_status, rpcev->ev_type, rpcev->ev_lnet);
-                       LBUG ();
+                       LBUG();
                }
 
                spin_lock(&crpc->crpc_lock);
@@ -1458,10 +1467,10 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
 
                spin_lock(&scd->scd_lock);
 
-               LASSERT (ev->unlinked);
-               LASSERT (ev->type == LNET_EVENT_PUT ||
+               LASSERT(ev->unlinked);
+               LASSERT(ev->type == LNET_EVENT_PUT ||
                         ev->type == LNET_EVENT_UNLINK);
-               LASSERT (ev->type != LNET_EVENT_UNLINK ||
+               LASSERT(ev->type != LNET_EVENT_UNLINK ||
                         sv->sv_shuttingdown);
 
                buffer = container_of(ev->md.start, srpc_buffer_t, buf_msg);
@@ -1536,7 +1545,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
                break;
 
        case SRPC_BULK_GET_RPLD:
-               LASSERT (ev->type == LNET_EVENT_SEND ||
+               LASSERT(ev->type == LNET_EVENT_SEND ||
                         ev->type == LNET_EVENT_REPLY ||
                         ev->type == LNET_EVENT_UNLINK);
 
@@ -1574,7 +1583,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev)
 
 
 int
-srpc_startup (void)
+srpc_startup(void)
 {
        int rc;
 
@@ -1590,7 +1599,7 @@ srpc_startup (void)
 
        rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
        if (rc < 0) {
-               CERROR ("LNetNIInit() has failed: %d\n", rc);
+               CERROR("LNetNIInit() has failed: %d\n", rc);
                return rc;
        }
 
@@ -1622,7 +1631,7 @@ bail:
 }
 
 void
-srpc_shutdown (void)
+srpc_shutdown(void)
 {
        int i;
        int rc;
@@ -1633,14 +1642,14 @@ srpc_shutdown (void)
 
        switch (state) {
        default:
-               LBUG ();
+               LBUG();
        case SRPC_STATE_RUNNING:
                spin_lock(&srpc_data.rpc_glock);
 
                for (i = 0; i <= SRPC_SERVICE_MAX_ID; i++) {
                        srpc_service_t *sv = srpc_data.rpc_services[i];
 
-                       LASSERTF (sv == NULL,
+                       LASSERTF(sv == NULL,
                                  "service not empty: id %d, name %s\n",
                                  i, sv->sv_name);
                }
@@ -1652,9 +1661,9 @@ srpc_shutdown (void)
        case SRPC_STATE_EQ_INIT:
                rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
                rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
-               LASSERT (rc == 0);
+               LASSERT(rc == 0);
                rc = LNetEQFree(srpc_data.rpc_lnet_eq);
-               LASSERT (rc == 0); /* the EQ should have no user by now */
+               LASSERT(rc == 0); /* the EQ should have no user by now */
 
        case SRPC_STATE_NI_INIT:
                LNetNIFini();
index 6a21f078fefa310491ece705544e31d784cd8867..783939dbd4db134c4494f272eaeec00fd36a7eb8 100644 (file)
@@ -120,15 +120,14 @@ static int
 lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
 {
        struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
-       int rc;
 
        LASSERT(seq != NULL);
 
        mutex_lock(&seq->lcs_mutex);
-       rc = seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
+       seq_printf(m, "[%#llx - %#llx]:%x:%s\n", PRANGE(&seq->lcs_space));
        mutex_unlock(&seq->lcs_mutex);
 
-       return rc;
+       return 0;
 }
 
 static ssize_t lprocfs_fid_width_seq_write(struct file *file,
@@ -170,30 +169,28 @@ static int
 lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
 {
        struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
-       int rc;
 
        LASSERT(seq != NULL);
 
        mutex_lock(&seq->lcs_mutex);
-       rc = seq_printf(m, "%llu\n", seq->lcs_width);
+       seq_printf(m, "%llu\n", seq->lcs_width);
        mutex_unlock(&seq->lcs_mutex);
 
-       return rc;
+       return 0;
 }
 
 static int
 lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
 {
        struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
-       int rc;
 
        LASSERT(seq != NULL);
 
        mutex_lock(&seq->lcs_mutex);
-       rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid));
+       seq_printf(m, DFID "\n", PFID(&seq->lcs_fid));
        mutex_unlock(&seq->lcs_mutex);
 
-       return rc;
+       return 0;
 }
 
 static int
@@ -201,17 +198,17 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
 {
        struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
        struct client_obd *cli;
-       int rc;
 
        LASSERT(seq != NULL);
 
        if (seq->lcs_exp != NULL) {
                cli = &seq->lcs_exp->exp_obd->u.cli;
-               rc = seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
+               seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
        } else {
-               rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
+               seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
        }
-       return rc;
+
+       return 0;
 }
 
 LPROC_SEQ_FOPS(lprocfs_fid_space);
index 6125bbe822b55f72c23979daafc5a029c29ebd95..68bec76584632a0a75445991ad268770aebb1bf9 100644 (file)
@@ -142,7 +142,7 @@ extern struct lu_fld_hash fld_hash[];
 int fld_client_rpc(struct obd_export *exp,
                   struct lu_seq_range *range, __u32 fld_op);
 
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 extern struct lprocfs_vars fld_client_proc_list[];
 #endif
 
index b8d17e109a961a1d30e3b016173a42378eff0d25..6ac225e90ee079ab29df68cff3abd133512b36be 100644 (file)
@@ -217,10 +217,9 @@ int fld_client_add_target(struct lu_client_fld *fld,
                CERROR("%s: Attempt to add target %s (idx %llu) on fly - skip it\n",
                        fld->lcf_name, name, tar->ft_idx);
                return 0;
-       } else {
-               CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n",
-                      fld->lcf_name, name, tar->ft_idx);
        }
+       CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n",
+                       fld->lcf_name, name, tar->ft_idx);
 
        OBD_ALLOC_PTR(target);
        if (target == NULL)
@@ -280,7 +279,7 @@ EXPORT_SYMBOL(fld_client_del_target);
 
 static struct proc_dir_entry *fld_type_proc_dir;
 
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 static int fld_client_proc_init(struct lu_client_fld *fld)
 {
        int rc;
@@ -327,7 +326,6 @@ static int fld_client_proc_init(struct lu_client_fld *fld)
 
 void fld_client_proc_fini(struct lu_client_fld *fld)
 {
-       return;
 }
 #endif
 EXPORT_SYMBOL(fld_client_proc_fini);
index 8c5a65704a37173117c01b1f4995ef5e1ac33596..f53fdcfae34e2ad7ed10a4f183fed38a867d8e70 100644 (file)
@@ -168,4 +168,5 @@ struct lprocfs_vars fld_client_proc_list[] = {
        { "targets", &fld_proc_targets_fops },
        { "hash", &fld_proc_hash_fops },
        { "cache_flush", &fld_proc_cache_flush_fops },
-       { NULL }};
+       { NULL }
+};
index 8a25cf6f6825be6bd58fbf476ea25a7250c56714..d030847e51bada4637fbbc11abfa3492033bc59c 100644 (file)
@@ -679,7 +679,7 @@ extern int lprocfs_seq_release(struct inode *, struct file *);
        }                                      \
 } while (0)
 #define LPROCFS_CLIMP_EXIT(obd)                 \
-       up_read(&(obd)->u.cli.cl_sem);
+       up_read(&(obd)->u.cli.cl_sem)
 
 
 /* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
@@ -723,7 +723,7 @@ static struct file_operations name##_fops = {                               \
                return lprocfs_wr_##type(file, buffer,                  \
                                         count, seq->private);          \
        }                                                               \
-       LPROC_SEQ_FOPS(name##_##type);
+       LPROC_SEQ_FOPS(name##_##type)
 
 #define LPROC_SEQ_FOPS_WR_ONLY(name, type)                             \
        static ssize_t name##_##type##_write(struct file *file,         \
@@ -740,7 +740,7 @@ static struct file_operations name##_fops = {                               \
                .open   = name##_##type##_open,                         \
                .write  = name##_##type##_write,                        \
                .release = lprocfs_single_release,                      \
-       };
+       }
 
 /* lproc_ptlrpc.c */
 struct ptlrpc_request;
index 2ddb2b054d8d5ac618ebaff9765990f6ed7da36f..c8cc48f0002690f130a1b246fdfb3870d1c99781 100644 (file)
@@ -192,7 +192,7 @@ struct lu_object_conf {
  */
 typedef int (*lu_printer_t)(const struct lu_env *env,
                            void *cookie, const char *format, ...)
-       __attribute__ ((format (printf, 3, 4)));
+       __printf(3, 4);
 
 /**
  * Operations specific for particular lu_object.
index 83bc0a9d7d4cd380c7779f9691c31989543d50d5..bac9902b56bbf48a4840116fe9efd154acb36a06 100644 (file)
@@ -1075,7 +1075,7 @@ extern char *ldlm_it2str(int it);
 void _ldlm_lock_debug(struct ldlm_lock *lock,
                      struct libcfs_debug_msg_data *data,
                      const char *fmt, ...)
-       __attribute__ ((format (printf, 3, 4)));
+       __printf(3, 4);
 
 /**
  * Rate-limited version of lock printing function.
index 36396d1c94dc9eecc81e4f2446462ff23122e6c8..e2805bd1acf1070b176b22f974515dd567f9e2a9 100644 (file)
@@ -1673,7 +1673,7 @@ ptlrpc_rqphase2str(struct ptlrpc_request *req)
 
 void _debug_req(struct ptlrpc_request *req,
                struct libcfs_debug_msg_data *data, const char *fmt, ...)
-       __attribute__ ((format (printf, 3, 4)));
+       __printf(3, 4);
 
 /**
  * Helper that decides if we need to print request according to current debug
index 23095bb75226b1aace10df936ba754e3803e806c..ab6cb419302fb2f0cf7cff2c3e9d97b4d8678575 100644 (file)
@@ -828,7 +828,8 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
                                 * --bug 17336 */
                                loff_t size = cl_isize_read(inode);
                                loff_t cur_index = start >> PAGE_CACHE_SHIFT;
-                               loff_t size_index = ((size - 1) >> PAGE_CACHE_SHIFT);
+                               loff_t size_index = (size - 1) >>
+                                                   PAGE_CACHE_SHIFT;
 
                                if ((size == 0 && cur_index != 0) ||
                                    size_index < cur_index)
@@ -1263,7 +1264,7 @@ __u32 cl_fid_build_gen(const struct lu_fid *fid)
                return gen;
        }
 
-       gen = (fid_flatten(fid) >> 32);
+       gen = fid_flatten(fid) >> 32;
        return gen;
 }
 
index a89eebaedabfe54fa9391fcc531ea88f42f8d9b1..fd9b059361f934ea2c67ca191d82c24b691626a2 100644 (file)
@@ -151,7 +151,8 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 
        LASSERT(mode != 0);
        LASSERT(IS_PO2(mode));
-       for (index = -1; mode; index++, mode >>= 1) ;
+       for (index = -1; mode; index++)
+               mode >>= 1;
        LASSERT(index < LCK_MODE_NUM);
        return index;
 }
index 20e64cddb1f4ef53a3da6381a14217a29d249677..5bf948810594700f99eb00c8e08b1d4c9bfe42ca 100644 (file)
@@ -131,12 +131,12 @@ struct ldlm_cb_set_arg {
        union ldlm_gl_desc              *gl_desc; /* glimpse AST descriptor */
 };
 
-typedef enum {
+enum ldlm_desc_ast_t {
        LDLM_WORK_BL_AST,
        LDLM_WORK_CP_AST,
        LDLM_WORK_REVOKE_AST,
        LDLM_WORK_GL_AST
-} ldlm_desc_ast_t;
+};
 
 void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list);
 int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill,
@@ -155,7 +155,7 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *, __u32 mode);
 void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
                            struct list_head *work_list);
 int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
-                     ldlm_desc_ast_t ast_type);
+                     enum ldlm_desc_ast_t ast_type);
 int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq);
 int ldlm_lock_remove_from_lru(struct ldlm_lock *lock);
 int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock);
@@ -177,6 +177,10 @@ int ldlm_bl_to_thread_list(struct ldlm_namespace *ns,
 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
                             struct ldlm_lock_desc *ld, struct ldlm_lock *lock);
 
+extern struct kmem_cache *ldlm_resource_slab;
+
+/* ldlm_lockd.c & ldlm_lock.c */
+extern struct kmem_cache *ldlm_lock_slab;
 
 /* ldlm_extent.c */
 void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
index 8191005464b165f8d660ed90229b76c1825d4455..84b111eb48fad5060a0b32565d46662de3170cc8 100644 (file)
@@ -151,8 +151,6 @@ char *ldlm_it2str(int it)
 }
 EXPORT_SYMBOL(ldlm_it2str);
 
-extern struct kmem_cache *ldlm_lock_slab;
-
 
 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg)
 {
@@ -1805,7 +1803,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
  * one.
  */
 int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
-                     ldlm_desc_ast_t ast_type)
+                     enum ldlm_desc_ast_t ast_type)
 {
        struct ldlm_cb_set_arg *arg;
        set_producer_func       work_ast_lock;
index 98fbd3f7e751e248b1aacd06dfe47b28d437fda6..08a91f5d91b1663514889833796fdf6786c554c1 100644 (file)
@@ -55,8 +55,6 @@ static char *ldlm_cpts;
 module_param(ldlm_cpts, charp, 0444);
 MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on");
 
-extern struct kmem_cache *ldlm_resource_slab;
-extern struct kmem_cache *ldlm_lock_slab;
 static struct mutex    ldlm_ref_mutex;
 static int ldlm_refcount;
 
@@ -154,7 +152,7 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
        if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK)
                lock->l_flags |= LDLM_FL_CANCEL;
 
-       do_ast = (!lock->l_readers && !lock->l_writers);
+       do_ast = !lock->l_readers && !lock->l_writers;
        unlock_res_and_lock(lock);
 
        if (do_ast) {
index d20d277dc2f7648a99640ce7d8a8fc6c4dd87836..7574502919ca17e0f50e0a749728e67732939d45 100644 (file)
@@ -689,8 +689,8 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
                              "  GP:  %d\n",
                              grant_step, grant_plan);
        }
-       seq_printf(m, "  GR:  %d\n" "  CR:  %d\n" "  GS:  %d\n"
-                     "  G:   %d\n" "  L:   %d\n",
+       seq_printf(m, "  GR:  %d\n  CR:  %d\n  GS:  %d\n"
+                     "  G:   %d\n  L:   %d\n",
                      grant_rate, cancel_rate, grant_speed,
                      granted, limit);
 
index 287da325d92874291c47186ade8a2d761805fbcd..4f713183145bb823a955a51b4dff94cb8ba17cbb 100644 (file)
@@ -307,7 +307,7 @@ int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock)
        int do_ast;
 
        lock->l_flags |= LDLM_FL_CBPENDING;
-       do_ast = (!lock->l_readers && !lock->l_writers);
+       do_ast = !lock->l_readers && !lock->l_writers;
        unlock_res_and_lock(lock);
 
        if (do_ast) {
@@ -1779,7 +1779,6 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res,
                if (opaque != NULL && lock->l_ast_data != opaque) {
                        LDLM_ERROR(lock, "data %p doesn't match opaque %p",
                                   lock->l_ast_data, opaque);
-                       //LBUG();
                        continue;
                }
 
index fcecbd2271afcbd1fc0c2eb51307c48822f8f140..2996a48a31fb673c668b8a329050e065a4c5020c 100644 (file)
@@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += libcfs.o
 libcfs-linux-objs := linux-tracefile.o linux-debug.o
 libcfs-linux-objs += linux-prim.o linux-cpu.o
 libcfs-linux-objs += linux-tcpip.o
-libcfs-linux-objs += linux-proc.o linux-curproc.o
+libcfs-linux-objs += linux-curproc.o
 libcfs-linux-objs += linux-module.o
 libcfs-linux-objs += linux-crypto.o
 libcfs-linux-objs += linux-crypto-adler.o
index 76c62e87a415afd1bd7f7d9e60bdec9b94299894..021c92fa0333f2cd92c91b10762fcbceac7ed723 100644 (file)
@@ -409,8 +409,8 @@ int libcfs_debug_init(unsigned long bufsize)
        if (max > cfs_trace_max_debug_mb() || max < num_possible_cpus()) {
                max = TCD_MAX_PAGES;
        } else {
-               max = (max / num_possible_cpus());
-               max = max << (20 - PAGE_CACHE_SHIFT);
+               max = max / num_possible_cpus();
+               max <<= (20 - PAGE_CACHE_SHIFT);
        }
        rc = cfs_tracefile_init(max);
 
index ec3a2a8b8b2cdbae9799475f5351662c7b5d88b7..a55567e0de9eee87c055c5c2fdf85b08bf70fcc3 100644 (file)
@@ -2008,13 +2008,10 @@ void cfs_hash_rehash_key(struct cfs_hash *hs, const void *old_key,
 }
 EXPORT_SYMBOL(cfs_hash_rehash_key);
 
-int cfs_hash_debug_header(struct seq_file *m)
+void cfs_hash_debug_header(struct seq_file *m)
 {
-       return seq_printf(m, "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%8s%8s%8s%s\n",
-                CFS_HASH_BIGNAME_LEN,
-                "name", "cur", "min", "max", "theta", "t-min", "t-max",
-                "flags", "rehash", "count", "maxdep", "maxdepb",
-                " distribution");
+       seq_printf(m, "%-*s   cur   min   max theta t-min t-max flags rehash   count  maxdep maxdepb distribution\n",
+                  CFS_HASH_BIGNAME_LEN, "name");
 }
 EXPORT_SYMBOL(cfs_hash_debug_header);
 
@@ -2042,7 +2039,7 @@ cfs_hash_full_nbkt(struct cfs_hash *hs)
               CFS_HASH_RH_NBKT(hs) : CFS_HASH_NBKT(hs);
 }
 
-int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m)
+void cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m)
 {
        int                 dist[8] = { 0, };
        int                 maxdep  = -1;
@@ -2097,7 +2094,5 @@ int cfs_hash_debug_str(struct cfs_hash *hs, struct seq_file *m)
                seq_printf(m, "%d%c",  dist[i], (i == 7) ? '\n' : '/');
 
        cfs_hash_unlock(hs, 0);
-
-       return 0;
 }
 EXPORT_SYMBOL(cfs_hash_debug_str);
index 05f7595f18aa55f51ba8c86c3aec2b4d572a48de..cc3ab351943e195a454d33d3f8d8529694f5ac0d 100644 (file)
@@ -204,7 +204,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
                }
 
                tmp += rc;
-               for_each_cpu_mask(j, *cptab->ctb_parts[i].cpt_cpumask) {
+               for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
                        rc = snprintf(tmp, len, "%d ", j);
                        len -= rc;
                        if (len <= 0) {
@@ -240,8 +240,8 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
        LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
 
        return cpt == CFS_CPT_ANY ?
-              cpus_weight(*cptab->ctb_cpumask) :
-              cpus_weight(*cptab->ctb_parts[cpt].cpt_cpumask);
+              cpumask_weight(cptab->ctb_cpumask) :
+              cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask);
 }
 EXPORT_SYMBOL(cfs_cpt_weight);
 
@@ -251,8 +251,10 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
        LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
 
        return cpt == CFS_CPT_ANY ?
-              any_online_cpu(*cptab->ctb_cpumask) != NR_CPUS :
-              any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) != NR_CPUS;
+              cpumask_any_and(cptab->ctb_cpumask,
+                              cpu_online_mask) < nr_cpu_ids :
+              cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask,
+                              cpu_online_mask) < nr_cpu_ids;
 }
 EXPORT_SYMBOL(cfs_cpt_online);
 
@@ -283,7 +285,7 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
 
        LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts);
 
-       if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu)) {
+       if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) {
                CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu);
                return 0;
        }
@@ -296,11 +298,11 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
 
        cptab->ctb_cpu2cpt[cpu] = cpt;
 
-       LASSERT(!cpu_isset(cpu, *cptab->ctb_cpumask));
-       LASSERT(!cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask));
+       LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
+       LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
 
-       cpu_set(cpu, *cptab->ctb_cpumask);
-       cpu_set(cpu, *cptab->ctb_parts[cpt].cpt_cpumask);
+       cpumask_set_cpu(cpu, cptab->ctb_cpumask);
+       cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
 
        node = cpu_to_node(cpu);
 
@@ -324,7 +326,7 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
 
        LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
 
-       if (cpu < 0 || cpu >= NR_CPUS) {
+       if (cpu < 0 || cpu >= nr_cpu_ids) {
                CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu);
                return;
        }
@@ -344,11 +346,11 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
                return;
        }
 
-       LASSERT(cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask));
-       LASSERT(cpu_isset(cpu, *cptab->ctb_cpumask));
+       LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
+       LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask));
 
-       cpu_clear(cpu, *cptab->ctb_parts[cpt].cpt_cpumask);
-       cpu_clear(cpu, *cptab->ctb_cpumask);
+       cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+       cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
        cptab->ctb_cpu2cpt[cpu] = -1;
 
        node = cpu_to_node(cpu);
@@ -356,22 +358,22 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
        LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask));
        LASSERT(node_isset(node, *cptab->ctb_nodemask));
 
-       for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) {
+       for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) {
                /* this CPT has other CPU belonging to this node? */
                if (cpu_to_node(i) == node)
                        break;
        }
 
-       if (i == NR_CPUS)
+       if (i >= nr_cpu_ids)
                node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask);
 
-       for_each_cpu_mask(i, *cptab->ctb_cpumask) {
+       for_each_cpu(i, cptab->ctb_cpumask) {
                /* this CPT-table has other CPU belonging to this node? */
                if (cpu_to_node(i) == node)
                        break;
        }
 
-       if (i == NR_CPUS)
+       if (i >= nr_cpu_ids)
                node_clear(node, *cptab->ctb_nodemask);
 
        return;
@@ -383,13 +385,14 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
 {
        int     i;
 
-       if (cpus_weight(*mask) == 0 || any_online_cpu(*mask) == NR_CPUS) {
+       if (cpumask_weight(mask) == 0 ||
+           cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
                CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n",
                       cpt);
                return 0;
        }
 
-       for_each_cpu_mask(i, *mask) {
+       for_each_cpu(i, mask) {
                if (!cfs_cpt_set_cpu(cptab, cpt, i))
                        return 0;
        }
@@ -403,7 +406,7 @@ cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
 {
        int     i;
 
-       for_each_cpu_mask(i, *mask)
+       for_each_cpu(i, mask)
                cfs_cpt_unset_cpu(cptab, cpt, i);
 }
 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
@@ -493,7 +496,7 @@ cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
        }
 
        for (; cpt <= last; cpt++) {
-               for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask)
+               for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask)
                        cfs_cpt_unset_cpu(cptab, cpt, i);
        }
 }
@@ -554,7 +557,7 @@ EXPORT_SYMBOL(cfs_cpt_current);
 int
 cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu)
 {
-       LASSERT(cpu >= 0 && cpu < NR_CPUS);
+       LASSERT(cpu >= 0 && cpu < nr_cpu_ids);
 
        return cptab->ctb_cpu2cpt[cpu];
 }
@@ -578,14 +581,14 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
                nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
        }
 
-       if (any_online_cpu(*cpumask) == NR_CPUS) {
+       if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids) {
                CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n",
                       cpt);
                return -EINVAL;
        }
 
        for_each_online_cpu(i) {
-               if (cpu_isset(i, *cpumask))
+               if (cpumask_test_cpu(i, cpumask))
                        continue;
 
                rc = set_cpus_allowed_ptr(current, cpumask);
@@ -616,14 +619,14 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
 
        LASSERT(number > 0);
 
-       if (number >= cpus_weight(*node)) {
-               while (!cpus_empty(*node)) {
-                       cpu = first_cpu(*node);
+       if (number >= cpumask_weight(node)) {
+               while (!cpumask_empty(node)) {
+                       cpu = cpumask_first(node);
 
                        rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
                        if (!rc)
                                return -EINVAL;
-                       cpu_clear(cpu, *node);
+                       cpumask_clear_cpu(cpu, node);
                }
                return 0;
        }
@@ -636,27 +639,27 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
                goto out;
        }
 
-       while (!cpus_empty(*node)) {
-               cpu = first_cpu(*node);
+       while (!cpumask_empty(node)) {
+               cpu = cpumask_first(node);
 
                /* get cpumask for cores in the same socket */
                cfs_cpu_core_siblings(cpu, socket);
-               cpus_and(*socket, *socket, *node);
+               cpumask_and(socket, socket, node);
 
-               LASSERT(!cpus_empty(*socket));
+               LASSERT(!cpumask_empty(socket));
 
-               while (!cpus_empty(*socket)) {
+               while (!cpumask_empty(socket)) {
                        int     i;
 
                        /* get cpumask for hts in the same core */
                        cfs_cpu_ht_siblings(cpu, core);
-                       cpus_and(*core, *core, *node);
+                       cpumask_and(core, core, node);
 
-                       LASSERT(!cpus_empty(*core));
+                       LASSERT(!cpumask_empty(core));
 
-                       for_each_cpu_mask(i, *core) {
-                               cpu_clear(i, *socket);
-                               cpu_clear(i, *node);
+                       for_each_cpu(i, core) {
+                               cpumask_clear_cpu(i, socket);
+                               cpumask_clear_cpu(i, node);
 
                                rc = cfs_cpt_set_cpu(cptab, cpt, i);
                                if (!rc) {
@@ -667,7 +670,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
                                if (--number == 0)
                                        goto out;
                        }
-                       cpu = first_cpu(*socket);
+                       cpu = cpumask_first(socket);
                }
        }
 
@@ -767,7 +770,7 @@ cfs_cpt_table_create(int ncpt)
        for_each_online_node(i) {
                cfs_node_to_cpumask(i, mask);
 
-               while (!cpus_empty(*mask)) {
+               while (!cpumask_empty(mask)) {
                        struct cfs_cpu_partition *part;
                        int    n;
 
@@ -776,24 +779,24 @@ cfs_cpt_table_create(int ncpt)
 
                        part = &cptab->ctb_parts[cpt];
 
-                       n = num - cpus_weight(*part->cpt_cpumask);
+                       n = num - cpumask_weight(part->cpt_cpumask);
                        LASSERT(n > 0);
 
                        rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n);
                        if (rc < 0)
                                goto failed;
 
-                       LASSERT(num >= cpus_weight(*part->cpt_cpumask));
-                       if (num == cpus_weight(*part->cpt_cpumask))
+                       LASSERT(num >= cpumask_weight(part->cpt_cpumask));
+                       if (num == cpumask_weight(part->cpt_cpumask))
                                cpt++;
                }
        }
 
        if (cpt != ncpt ||
-           num != cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
+           num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) {
                CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n",
                       cptab->ctb_nparts, num, cpt,
-                      cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask));
+                      cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask));
                goto failed;
        }
 
@@ -845,7 +848,7 @@ cfs_cpt_table_create_pattern(char *pattern)
                return NULL;
        }
 
-       high = node ? MAX_NUMNODES - 1 : NR_CPUS - 1;
+       high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
 
        cptab = cfs_cpt_table_alloc(ncpt);
        if (cptab == NULL) {
@@ -965,7 +968,8 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
                mutex_lock(&cpt_data.cpt_mutex);
                /* if all HTs in a core are offline, it may break affinity */
                cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask);
-               warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids;
+               warn = cpumask_any_and(cpt_data.cpt_cpumask,
+                                      cpu_online_mask) >= nr_cpu_ids;
                mutex_unlock(&cpt_data.cpt_mutex);
                CDEBUG(warn ? D_WARNING : D_INFO,
                       "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n",
index 12005a71aa736599d0813fde935fed9d28534866..4545d54f71c6f3d93cbbb6ed3c021ba82d6c483e 100644 (file)
@@ -50,7 +50,7 @@
 #include <linux/interrupt.h>
 #include <linux/completion.h>
 #include <linux/fs.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/miscdevice.h>
 
 # define DEBUG_SUBSYSTEM S_LNET
index 19f405e64e6811d4773a0952645d5541104e503e..838f5f3bd6af450579b7cedb2fe08713d882c65f 100644 (file)
@@ -43,7 +43,7 @@
 #include "../../../include/linux/libcfs/libcfs.h"
 
 #if defined(CONFIG_KGDB)
-#include <asm/kgdb.h>
+#include <linux/kgdb.h>
 #endif
 
 /**
@@ -117,11 +117,12 @@ EXPORT_SYMBOL(cfs_timer_deadline);
 void cfs_enter_debugger(void)
 {
 #if defined(CONFIG_KGDB)
-//     BREAKPOINT();
+       /* BREAKPOINT(); */
 #else
        /* nothing */
 #endif
 }
+EXPORT_SYMBOL(cfs_enter_debugger);
 
 
 sigset_t
@@ -138,6 +139,7 @@ cfs_block_allsigs(void)
 
        return old;
 }
+EXPORT_SYMBOL(cfs_block_allsigs);
 
 sigset_t cfs_block_sigs(unsigned long sigs)
 {
@@ -151,6 +153,7 @@ sigset_t cfs_block_sigs(unsigned long sigs)
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
        return old;
 }
+EXPORT_SYMBOL(cfs_block_sigs);
 
 /* Block all signals except for the @sigs */
 sigset_t cfs_block_sigsinv(unsigned long sigs)
@@ -166,9 +169,10 @@ sigset_t cfs_block_sigsinv(unsigned long sigs)
 
        return old;
 }
+EXPORT_SYMBOL(cfs_block_sigsinv);
 
 void
-cfs_restore_sigs (sigset_t old)
+cfs_restore_sigs(sigset_t old)
 {
        unsigned long  flags;
 
@@ -177,12 +181,14 @@ cfs_restore_sigs (sigset_t old)
        recalc_sigpending();
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
 }
+EXPORT_SYMBOL(cfs_restore_sigs);
 
 int
 cfs_signal_pending(void)
 {
        return signal_pending(current);
 }
+EXPORT_SYMBOL(cfs_signal_pending);
 
 void
 cfs_clear_sigpending(void)
@@ -193,25 +199,19 @@ cfs_clear_sigpending(void)
        clear_tsk_thread_flag(current, TIF_SIGPENDING);
        spin_unlock_irqrestore(&current->sighand->siglock, flags);
 }
+EXPORT_SYMBOL(cfs_clear_sigpending);
 
 int
 libcfs_arch_init(void)
 {
        return 0;
 }
+EXPORT_SYMBOL(libcfs_arch_init);
 
 void
 libcfs_arch_cleanup(void)
 {
        return;
 }
-
-EXPORT_SYMBOL(libcfs_arch_init);
 EXPORT_SYMBOL(libcfs_arch_cleanup);
-EXPORT_SYMBOL(cfs_enter_debugger);
-EXPORT_SYMBOL(cfs_block_allsigs);
-EXPORT_SYMBOL(cfs_block_sigs);
-EXPORT_SYMBOL(cfs_block_sigsinv);
-EXPORT_SYMBOL(cfs_restore_sigs);
-EXPORT_SYMBOL(cfs_signal_pending);
-EXPORT_SYMBOL(cfs_clear_sigpending);
+
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
deleted file mode 100644 (file)
index c539e37..0000000
+++ /dev/null
@@ -1,577 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * libcfs/libcfs/linux/linux-proc.c
- *
- * Author: Zach Brown <zab@zabbo.net>
- * Author: Peter J. Braam <braam@clusterfs.com>
- * Author: Phil Schwan <phil@clusterfs.com>
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/unistd.h>
-#include <net/sock.h>
-#include <linux/uio.h>
-
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/list.h>
-
-#include <linux/proc_fs.h>
-#include <linux/sysctl.h>
-
-# define DEBUG_SUBSYSTEM S_LNET
-
-#include "../../../include/linux/libcfs/libcfs.h"
-#include <asm/div64.h>
-#include "../tracefile.h"
-
-static struct ctl_table_header *lnet_table_header = NULL;
-extern char lnet_upcall[1024];
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
-
-#define CTL_LNET       (0x100)
-enum {
-       PSDEV_DEBUG = 1,          /* control debugging */
-       PSDEV_SUBSYSTEM_DEBUG,    /* control debugging */
-       PSDEV_PRINTK,        /* force all messages to console */
-       PSDEV_CONSOLE_RATELIMIT,  /* ratelimit console messages */
-       PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */
-       PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */
-       PSDEV_CONSOLE_BACKOFF,    /* delay increase factor */
-       PSDEV_DEBUG_PATH,        /* crashdump log location */
-       PSDEV_DEBUG_DUMP_PATH,    /* crashdump tracelog location */
-       PSDEV_CPT_TABLE,          /* information about cpu partitions */
-       PSDEV_LNET_UPCALL,      /* User mode upcall script  */
-       PSDEV_LNET_MEMUSED,       /* bytes currently PORTAL_ALLOCated */
-       PSDEV_LNET_CATASTROPHE,   /* if we have LBUGged or panic'd */
-       PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */
-       PSDEV_LNET_DUMP_KERNEL,   /* snapshot kernel debug buffer to file */
-       PSDEV_LNET_DAEMON_FILE,   /* spool kernel debug buffer to file */
-       PSDEV_LNET_DEBUG_MB,      /* size of debug buffer */
-       PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
-       PSDEV_LNET_WATCHDOG_RATELIMIT,  /* ratelimit watchdog messages  */
-       PSDEV_LNET_FORCE_LBUG,    /* hook to force an LBUG */
-       PSDEV_LNET_FAIL_LOC,      /* control test failures instrumentation */
-       PSDEV_LNET_FAIL_VAL,      /* userdata for fail loc */
-};
-
-static int proc_call_handler(void *data, int write, loff_t *ppos,
-               void __user *buffer, size_t *lenp,
-               int (*handler)(void *data, int write,
-               loff_t pos, void __user *buffer, int len))
-{
-       int rc = handler(data, write, *ppos, buffer, *lenp);
-
-       if (rc < 0)
-               return rc;
-
-       if (write) {
-               *ppos += *lenp;
-       } else {
-               *lenp = rc;
-               *ppos += rc;
-       }
-       return 0;
-}
-
-static int __proc_dobitmasks(void *data, int write,
-                            loff_t pos, void __user *buffer, int nob)
-{
-       const int     tmpstrlen = 512;
-       char     *tmpstr;
-       int        rc;
-       unsigned int *mask = data;
-       int        is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0;
-       int        is_printk = (mask == &libcfs_printk) ? 1 : 0;
-
-       rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen);
-       if (rc < 0)
-               return rc;
-
-       if (!write) {
-               libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys);
-               rc = strlen(tmpstr);
-
-               if (pos >= rc) {
-                       rc = 0;
-               } else {
-                       rc = cfs_trace_copyout_string(buffer, nob,
-                                                     tmpstr + pos, "\n");
-               }
-       } else {
-               rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
-               if (rc < 0) {
-                       cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
-                       return rc;
-               }
-
-               rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys);
-               /* Always print LBUG/LASSERT to console, so keep this mask */
-               if (is_printk)
-                       *mask |= D_EMERG;
-       }
-
-       cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
-       return rc;
-}
-
-static int proc_dobitmasks(struct ctl_table *table, int write,
-                          void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_dobitmasks);
-}
-
-static int min_watchdog_ratelimit = 0;   /* disable ratelimiting */
-static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
-
-static int __proc_dump_kernel(void *data, int write,
-                             loff_t pos, void __user *buffer, int nob)
-{
-       if (!write)
-               return 0;
-
-       return cfs_trace_dump_debug_buffer_usrstr(buffer, nob);
-}
-
-static int proc_dump_kernel(struct ctl_table *table, int write,
-                           void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_dump_kernel);
-}
-
-static int __proc_daemon_file(void *data, int write,
-                             loff_t pos, void __user *buffer, int nob)
-{
-       if (!write) {
-               int len = strlen(cfs_tracefile);
-
-               if (pos >= len)
-                       return 0;
-
-               return cfs_trace_copyout_string(buffer, nob,
-                                               cfs_tracefile + pos, "\n");
-       }
-
-       return cfs_trace_daemon_command_usrstr(buffer, nob);
-}
-
-static int proc_daemon_file(struct ctl_table *table, int write,
-                           void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_daemon_file);
-}
-
-static int __proc_debug_mb(void *data, int write,
-                          loff_t pos, void __user *buffer, int nob)
-{
-       if (!write) {
-               char tmpstr[32];
-               int  len = snprintf(tmpstr, sizeof(tmpstr), "%d",
-                                   cfs_trace_get_debug_mb());
-
-               if (pos >= len)
-                       return 0;
-
-               return cfs_trace_copyout_string(buffer, nob, tmpstr + pos,
-                      "\n");
-       }
-
-       return cfs_trace_set_debug_mb_usrstr(buffer, nob);
-}
-
-static int proc_debug_mb(struct ctl_table *table, int write,
-                        void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_debug_mb);
-}
-
-static int proc_console_max_delay_cs(struct ctl_table *table, int write,
-                                    void __user *buffer, size_t *lenp,
-                                    loff_t *ppos)
-{
-       int rc, max_delay_cs;
-       struct ctl_table dummy = *table;
-       long d;
-
-       dummy.data = &max_delay_cs;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100);
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       max_delay_cs = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (max_delay_cs <= 0)
-               return -EINVAL;
-
-       d = cfs_time_seconds(max_delay_cs) / 100;
-       if (d == 0 || d < libcfs_console_min_delay)
-               return -EINVAL;
-       libcfs_console_max_delay = d;
-
-       return rc;
-}
-
-static int proc_console_min_delay_cs(struct ctl_table *table, int write,
-                                    void __user *buffer, size_t *lenp,
-                                    loff_t *ppos)
-{
-       int rc, min_delay_cs;
-       struct ctl_table dummy = *table;
-       long d;
-
-       dummy.data = &min_delay_cs;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100);
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       min_delay_cs = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (min_delay_cs <= 0)
-               return -EINVAL;
-
-       d = cfs_time_seconds(min_delay_cs) / 100;
-       if (d == 0 || d > libcfs_console_max_delay)
-               return -EINVAL;
-       libcfs_console_min_delay = d;
-
-       return rc;
-}
-
-static int proc_console_backoff(struct ctl_table *table, int write,
-                               void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int rc, backoff;
-       struct ctl_table dummy = *table;
-
-       dummy.data = &backoff;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               backoff= libcfs_console_backoff;
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       backoff = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (backoff <= 0)
-               return -EINVAL;
-
-       libcfs_console_backoff = backoff;
-
-       return rc;
-}
-
-static int libcfs_force_lbug(struct ctl_table *table, int write,
-                            void __user *buffer,
-                            size_t *lenp, loff_t *ppos)
-{
-       if (write)
-               LBUG();
-       return 0;
-}
-
-static int proc_fail_loc(struct ctl_table *table, int write,
-                        void __user *buffer,
-                        size_t *lenp, loff_t *ppos)
-{
-       int rc;
-       long old_fail_loc = cfs_fail_loc;
-
-       rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
-       if (old_fail_loc != cfs_fail_loc)
-               wake_up(&cfs_race_waitq);
-       return rc;
-}
-
-static int __proc_cpt_table(void *data, int write,
-                           loff_t pos, void __user *buffer, int nob)
-{
-       char *buf = NULL;
-       int   len = 4096;
-       int   rc  = 0;
-
-       if (write)
-               return -EPERM;
-
-       LASSERT(cfs_cpt_table != NULL);
-
-       while (1) {
-               LIBCFS_ALLOC(buf, len);
-               if (buf == NULL)
-                       return -ENOMEM;
-
-               rc = cfs_cpt_table_print(cfs_cpt_table, buf, len);
-               if (rc >= 0)
-                       break;
-
-               if (rc == -EFBIG) {
-                       LIBCFS_FREE(buf, len);
-                       len <<= 1;
-                       continue;
-               }
-               goto out;
-       }
-
-       if (pos >= rc) {
-               rc = 0;
-               goto out;
-       }
-
-       rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
- out:
-       if (buf != NULL)
-               LIBCFS_FREE(buf, len);
-       return rc;
-}
-
-static int proc_cpt_table(struct ctl_table *table, int write,
-                          void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       return proc_call_handler(table->data, write, ppos, buffer, lenp,
-                                __proc_cpt_table);
-}
-
-static struct ctl_table lnet_table[] = {
-       /*
-        * NB No .strategy entries have been provided since sysctl(8) prefers
-        * to go via /proc for portability.
-        */
-       {
-               .procname = "debug",
-               .data     = &libcfs_debug,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dobitmasks,
-       },
-       {
-               .procname = "subsystem_debug",
-               .data     = &libcfs_subsystem_debug,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dobitmasks,
-       },
-       {
-               .procname = "printk",
-               .data     = &libcfs_printk,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dobitmasks,
-       },
-       {
-               .procname = "console_ratelimit",
-               .data     = &libcfs_console_ratelimit,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-               .procname = "console_max_delay_centisecs",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_max_delay_cs
-       },
-       {
-               .procname = "console_min_delay_centisecs",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_min_delay_cs
-       },
-       {
-               .procname = "console_backoff",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_backoff
-       },
-
-       {
-               .procname = "debug_path",
-               .data     = libcfs_debug_file_path_arr,
-               .maxlen   = sizeof(libcfs_debug_file_path_arr),
-               .mode     = 0644,
-               .proc_handler = &proc_dostring,
-       },
-
-       {
-               .procname = "cpu_partition_table",
-               .maxlen   = 128,
-               .mode     = 0444,
-               .proc_handler = &proc_cpt_table,
-       },
-
-       {
-               .procname = "upcall",
-               .data     = lnet_upcall,
-               .maxlen   = sizeof(lnet_upcall),
-               .mode     = 0644,
-               .proc_handler = &proc_dostring,
-       },
-       {
-               .procname = "debug_log_upcall",
-               .data     = lnet_debug_log_upcall,
-               .maxlen   = sizeof(lnet_debug_log_upcall),
-               .mode     = 0644,
-               .proc_handler = &proc_dostring,
-       },
-       {
-               .procname = "lnet_memused",
-               .data     = (int *)&libcfs_kmemory.counter,
-               .maxlen   = sizeof(int),
-               .mode     = 0444,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "catastrophe",
-               .data     = &libcfs_catastrophe,
-               .maxlen   = sizeof(int),
-               .mode     = 0444,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "panic_on_lbug",
-               .data     = &libcfs_panic_on_lbug,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec,
-       },
-       {
-               .procname = "dump_kernel",
-               .maxlen   = 256,
-               .mode     = 0200,
-               .proc_handler = &proc_dump_kernel,
-       },
-       {
-               .procname = "daemon_file",
-               .mode     = 0644,
-               .maxlen   = 256,
-               .proc_handler = &proc_daemon_file,
-       },
-       {
-               .procname = "debug_mb",
-               .mode     = 0644,
-               .proc_handler = &proc_debug_mb,
-       },
-       {
-               .procname = "watchdog_ratelimit",
-               .data     = &libcfs_watchdog_ratelimit,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec_minmax,
-               .extra1   = &min_watchdog_ratelimit,
-               .extra2   = &max_watchdog_ratelimit,
-       },
-       {
-               .procname = "force_lbug",
-               .data     = NULL,
-               .maxlen   = 0,
-               .mode     = 0200,
-               .proc_handler = &libcfs_force_lbug
-       },
-       {
-               .procname = "fail_loc",
-               .data     = &cfs_fail_loc,
-               .maxlen   = sizeof(cfs_fail_loc),
-               .mode     = 0644,
-               .proc_handler = &proc_fail_loc
-       },
-       {
-               .procname = "fail_val",
-               .data     = &cfs_fail_val,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_dointvec
-       },
-       {
-       }
-};
-
-static struct ctl_table top_table[] = {
-       {
-               .procname = "lnet",
-               .mode     = 0555,
-               .data     = NULL,
-               .maxlen   = 0,
-               .child    = lnet_table,
-       },
-       {
-       }
-};
-
-int insert_proc(void)
-{
-       if (lnet_table_header == NULL)
-               lnet_table_header = register_sysctl_table(top_table);
-       return 0;
-}
-
-void remove_proc(void)
-{
-       if (lnet_table_header != NULL)
-               unregister_sysctl_table(lnet_table_header);
-
-       lnet_table_header = NULL;
-}
index cd2fc01dea4cfb446851a47a61bd40e0ea412a3b..f2462e7f04bc40dd4b4dd3798eecdad08b52f3ff 100644 (file)
@@ -543,19 +543,17 @@ libcfs_sock_accept (struct socket **newsockp, struct socket *sock)
 
        newsock->ops = sock->ops;
 
-       set_current_state(TASK_INTERRUPTIBLE);
-       add_wait_queue(sk_sleep(sock->sk), &wait);
-
        rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
        if (rc == -EAGAIN) {
                /* Nothing ready, so wait for activity */
+               set_current_state(TASK_INTERRUPTIBLE);
+               add_wait_queue(sk_sleep(sock->sk), &wait);
                schedule();
+               remove_wait_queue(sk_sleep(sock->sk), &wait);
+               set_current_state(TASK_RUNNING);
                rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
        }
 
-       remove_wait_queue(sk_sleep(sock->sk), &wait);
-       set_current_state(TASK_RUNNING);
-
        if (rc != 0)
                goto failed;
 
index 7dc77dd402b857df067c92f8937353fe6959d9d2..f0ee76abfd5a4ad8d2d34096688fbafb5c7e3f90 100644 (file)
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/stat.h>
+#include <linux/errno.h>
+#include <linux/unistd.h>
+#include <net/sock.h>
+#include <linux/uio.h>
 
-#define DEBUG_SUBSYSTEM S_LNET
+#include <linux/uaccess.h>
+
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/list.h>
+
+#include <linux/proc_fs.h>
+#include <linux/sysctl.h>
+
+# define DEBUG_SUBSYSTEM S_LNET
 
 #include "../../include/linux/libcfs/libcfs.h"
+#include <asm/div64.h>
+
 #include "../../include/linux/libcfs/libcfs_crypto.h"
 #include "../../include/linux/lnet/lib-lnet.h"
 #include "../../include/linux/lnet/lnet.h"
 #include "tracefile.h"
 
+MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
+MODULE_DESCRIPTION("Portals v3.1");
+MODULE_LICENSE("GPL");
+
+extern struct miscdevice libcfs_dev;
+extern struct rw_semaphore cfs_tracefile_sem;
+extern struct mutex cfs_trace_thread_mutex;
+extern struct cfs_wi_sched *cfs_sched_rehash;
+extern void libcfs_init_nidstrings(void);
+
+static int insert_proc(void);
+static void remove_proc(void);
+
+static struct ctl_table_header *lnet_table_header;
+extern char lnet_upcall[1024];
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_debug_log_upcall[1024];
+
+#define CTL_LNET       (0x100)
+
+enum {
+       PSDEV_DEBUG = 1,          /* control debugging */
+       PSDEV_SUBSYSTEM_DEBUG,    /* control debugging */
+       PSDEV_PRINTK,        /* force all messages to console */
+       PSDEV_CONSOLE_RATELIMIT,  /* ratelimit console messages */
+       PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */
+       PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */
+       PSDEV_CONSOLE_BACKOFF,    /* delay increase factor */
+       PSDEV_DEBUG_PATH,        /* crashdump log location */
+       PSDEV_DEBUG_DUMP_PATH,    /* crashdump tracelog location */
+       PSDEV_CPT_TABLE,          /* information about cpu partitions */
+       PSDEV_LNET_UPCALL,      /* User mode upcall script  */
+       PSDEV_LNET_MEMUSED,       /* bytes currently PORTAL_ALLOCated */
+       PSDEV_LNET_CATASTROPHE,   /* if we have LBUGged or panic'd */
+       PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */
+       PSDEV_LNET_DUMP_KERNEL,   /* snapshot kernel debug buffer to file */
+       PSDEV_LNET_DAEMON_FILE,   /* spool kernel debug buffer to file */
+       PSDEV_LNET_DEBUG_MB,      /* size of debug buffer */
+       PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
+       PSDEV_LNET_WATCHDOG_RATELIMIT,  /* ratelimit watchdog messages  */
+       PSDEV_LNET_FORCE_LBUG,    /* hook to force an LBUG */
+       PSDEV_LNET_FAIL_LOC,      /* control test failures instrumentation */
+       PSDEV_LNET_FAIL_VAL,      /* userdata for fail loc */
+};
+
 static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
 {
        struct page **level0p = &ldu->ldu_memhog_root_page;
@@ -320,19 +387,6 @@ struct cfs_psdev_ops libcfs_psdev_ops = {
        libcfs_ioctl
 };
 
-extern int insert_proc(void);
-extern void remove_proc(void);
-MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Portals v3.1");
-MODULE_LICENSE("GPL");
-
-extern struct miscdevice libcfs_dev;
-extern struct rw_semaphore cfs_tracefile_sem;
-extern struct mutex cfs_trace_thread_mutex;
-extern struct cfs_wi_sched *cfs_sched_rehash;
-
-extern void libcfs_init_nidstrings(void);
-
 static int init_libcfs_module(void)
 {
        int rc;
@@ -347,7 +401,7 @@ static int init_libcfs_module(void)
 
        rc = libcfs_debug_init(5 * 1024 * 1024);
        if (rc < 0) {
-               printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc);
+               pr_err("LustreError: libcfs_debug_init: %d\n", rc);
                return rc;
        }
 
@@ -433,12 +487,490 @@ static void exit_libcfs_module(void)
 
        rc = libcfs_debug_cleanup();
        if (rc)
-               printk(KERN_ERR "LustreError: libcfs_debug_cleanup: %d\n",
-                      rc);
+               pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
 
        libcfs_arch_cleanup();
 }
 
+static int proc_call_handler(void *data, int write, loff_t *ppos,
+               void __user *buffer, size_t *lenp,
+               int (*handler)(void *data, int write,
+               loff_t pos, void __user *buffer, int len))
+{
+       int rc = handler(data, write, *ppos, buffer, *lenp);
+
+       if (rc < 0)
+               return rc;
+
+       if (write) {
+               *ppos += *lenp;
+       } else {
+               *lenp = rc;
+               *ppos += rc;
+       }
+       return 0;
+}
+
+static int __proc_dobitmasks(void *data, int write,
+                            loff_t pos, void __user *buffer, int nob)
+{
+       const int     tmpstrlen = 512;
+       char     *tmpstr;
+       int        rc;
+       unsigned int *mask = data;
+       int        is_subsys = (mask == &libcfs_subsystem_debug) ? 1 : 0;
+       int        is_printk = (mask == &libcfs_printk) ? 1 : 0;
+
+       rc = cfs_trace_allocate_string_buffer(&tmpstr, tmpstrlen);
+       if (rc < 0)
+               return rc;
+
+       if (!write) {
+               libcfs_debug_mask2str(tmpstr, tmpstrlen, *mask, is_subsys);
+               rc = strlen(tmpstr);
+
+               if (pos >= rc) {
+                       rc = 0;
+               } else {
+                       rc = cfs_trace_copyout_string(buffer, nob,
+                                                     tmpstr + pos, "\n");
+               }
+       } else {
+               rc = cfs_trace_copyin_string(tmpstr, tmpstrlen, buffer, nob);
+               if (rc < 0) {
+                       cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+                       return rc;
+               }
+
+               rc = libcfs_debug_str2mask(mask, tmpstr, is_subsys);
+               /* Always print LBUG/LASSERT to console, so keep this mask */
+               if (is_printk)
+                       *mask |= D_EMERG;
+       }
+
+       cfs_trace_free_string_buffer(tmpstr, tmpstrlen);
+       return rc;
+}
+
+static int proc_dobitmasks(struct ctl_table *table, int write,
+                          void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return proc_call_handler(table->data, write, ppos, buffer, lenp,
+                                __proc_dobitmasks);
+}
+
+static int min_watchdog_ratelimit;       /* disable ratelimiting */
+static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
+
+static int __proc_dump_kernel(void *data, int write,
+                             loff_t pos, void __user *buffer, int nob)
+{
+       if (!write)
+               return 0;
+
+       return cfs_trace_dump_debug_buffer_usrstr(buffer, nob);
+}
+
+static int proc_dump_kernel(struct ctl_table *table, int write,
+                           void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return proc_call_handler(table->data, write, ppos, buffer, lenp,
+                                __proc_dump_kernel);
+}
+
+static int __proc_daemon_file(void *data, int write,
+                             loff_t pos, void __user *buffer, int nob)
+{
+       if (!write) {
+               int len = strlen(cfs_tracefile);
+
+               if (pos >= len)
+                       return 0;
+
+               return cfs_trace_copyout_string(buffer, nob,
+                                               cfs_tracefile + pos, "\n");
+       }
+
+       return cfs_trace_daemon_command_usrstr(buffer, nob);
+}
+
+static int proc_daemon_file(struct ctl_table *table, int write,
+                           void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return proc_call_handler(table->data, write, ppos, buffer, lenp,
+                                __proc_daemon_file);
+}
+
+static int __proc_debug_mb(void *data, int write,
+                          loff_t pos, void __user *buffer, int nob)
+{
+       if (!write) {
+               char tmpstr[32];
+               int  len = snprintf(tmpstr, sizeof(tmpstr), "%d",
+                                   cfs_trace_get_debug_mb());
+
+               if (pos >= len)
+                       return 0;
+
+               return cfs_trace_copyout_string(buffer, nob, tmpstr + pos,
+                      "\n");
+       }
+
+       return cfs_trace_set_debug_mb_usrstr(buffer, nob);
+}
+
+static int proc_debug_mb(struct ctl_table *table, int write,
+                        void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return proc_call_handler(table->data, write, ppos, buffer, lenp,
+                                __proc_debug_mb);
+}
+
+static int proc_console_max_delay_cs(struct ctl_table *table, int write,
+                                    void __user *buffer, size_t *lenp,
+                                    loff_t *ppos)
+{
+       int rc, max_delay_cs;
+       struct ctl_table dummy = *table;
+       long d;
+
+       dummy.data = &max_delay_cs;
+       dummy.proc_handler = &proc_dointvec;
+
+       if (!write) { /* read */
+               max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100);
+               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+               return rc;
+       }
+
+       /* write */
+       max_delay_cs = 0;
+       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+       if (rc < 0)
+               return rc;
+       if (max_delay_cs <= 0)
+               return -EINVAL;
+
+       d = cfs_time_seconds(max_delay_cs) / 100;
+       if (d == 0 || d < libcfs_console_min_delay)
+               return -EINVAL;
+       libcfs_console_max_delay = d;
+
+       return rc;
+}
+
+static int proc_console_min_delay_cs(struct ctl_table *table, int write,
+                                    void __user *buffer, size_t *lenp,
+                                    loff_t *ppos)
+{
+       int rc, min_delay_cs;
+       struct ctl_table dummy = *table;
+       long d;
+
+       dummy.data = &min_delay_cs;
+       dummy.proc_handler = &proc_dointvec;
+
+       if (!write) { /* read */
+               min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100);
+               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+               return rc;
+       }
+
+       /* write */
+       min_delay_cs = 0;
+       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+       if (rc < 0)
+               return rc;
+       if (min_delay_cs <= 0)
+               return -EINVAL;
+
+       d = cfs_time_seconds(min_delay_cs) / 100;
+       if (d == 0 || d > libcfs_console_max_delay)
+               return -EINVAL;
+       libcfs_console_min_delay = d;
+
+       return rc;
+}
+
+static int proc_console_backoff(struct ctl_table *table, int write,
+                               void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       int rc, backoff;
+       struct ctl_table dummy = *table;
+
+       dummy.data = &backoff;
+       dummy.proc_handler = &proc_dointvec;
+
+       if (!write) { /* read */
+               backoff = libcfs_console_backoff;
+               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+               return rc;
+       }
+
+       /* write */
+       backoff = 0;
+       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
+       if (rc < 0)
+               return rc;
+       if (backoff <= 0)
+               return -EINVAL;
+
+       libcfs_console_backoff = backoff;
+
+       return rc;
+}
+
+static int libcfs_force_lbug(struct ctl_table *table, int write,
+                            void __user *buffer,
+                            size_t *lenp, loff_t *ppos)
+{
+       if (write)
+               LBUG();
+       return 0;
+}
+
+static int proc_fail_loc(struct ctl_table *table, int write,
+                        void __user *buffer,
+                        size_t *lenp, loff_t *ppos)
+{
+       int rc;
+       long old_fail_loc = cfs_fail_loc;
+
+       rc = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
+       if (old_fail_loc != cfs_fail_loc)
+               wake_up(&cfs_race_waitq);
+       return rc;
+}
+
+static int __proc_cpt_table(void *data, int write,
+                           loff_t pos, void __user *buffer, int nob)
+{
+       char *buf = NULL;
+       int   len = 4096;
+       int   rc  = 0;
+
+       if (write)
+               return -EPERM;
+
+       LASSERT(cfs_cpt_table != NULL);
+
+       while (1) {
+               LIBCFS_ALLOC(buf, len);
+               if (buf == NULL)
+                       return -ENOMEM;
+
+               rc = cfs_cpt_table_print(cfs_cpt_table, buf, len);
+               if (rc >= 0)
+                       break;
+
+               if (rc == -EFBIG) {
+                       LIBCFS_FREE(buf, len);
+                       len <<= 1;
+                       continue;
+               }
+               goto out;
+       }
+
+       if (pos >= rc) {
+               rc = 0;
+               goto out;
+       }
+
+       rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
+ out:
+       if (buf != NULL)
+               LIBCFS_FREE(buf, len);
+       return rc;
+}
+
+static int proc_cpt_table(struct ctl_table *table, int write,
+                          void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       return proc_call_handler(table->data, write, ppos, buffer, lenp,
+                                __proc_cpt_table);
+}
+
+static struct ctl_table lnet_table[] = {
+       /*
+        * NB No .strategy entries have been provided since sysctl(8) prefers
+        * to go via /proc for portability.
+        */
+       {
+               .procname = "debug",
+               .data     = &libcfs_debug,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dobitmasks,
+       },
+       {
+               .procname = "subsystem_debug",
+               .data     = &libcfs_subsystem_debug,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dobitmasks,
+       },
+       {
+               .procname = "printk",
+               .data     = &libcfs_printk,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dobitmasks,
+       },
+       {
+               .procname = "console_ratelimit",
+               .data     = &libcfs_console_ratelimit,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dointvec
+       },
+       {
+               .procname = "console_max_delay_centisecs",
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_console_max_delay_cs
+       },
+       {
+               .procname = "console_min_delay_centisecs",
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_console_min_delay_cs
+       },
+       {
+               .procname = "console_backoff",
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_console_backoff
+       },
+
+       {
+               .procname = "debug_path",
+               .data     = libcfs_debug_file_path_arr,
+               .maxlen   = sizeof(libcfs_debug_file_path_arr),
+               .mode     = 0644,
+               .proc_handler = &proc_dostring,
+       },
+
+       {
+               .procname = "cpu_partition_table",
+               .maxlen   = 128,
+               .mode     = 0444,
+               .proc_handler = &proc_cpt_table,
+       },
+
+       {
+               .procname = "upcall",
+               .data     = lnet_upcall,
+               .maxlen   = sizeof(lnet_upcall),
+               .mode     = 0644,
+               .proc_handler = &proc_dostring,
+       },
+       {
+               .procname = "debug_log_upcall",
+               .data     = lnet_debug_log_upcall,
+               .maxlen   = sizeof(lnet_debug_log_upcall),
+               .mode     = 0644,
+               .proc_handler = &proc_dostring,
+       },
+       {
+               .procname = "lnet_memused",
+               .data     = (int *)&libcfs_kmemory.counter,
+               .maxlen   = sizeof(int),
+               .mode     = 0444,
+               .proc_handler = &proc_dointvec,
+       },
+       {
+               .procname = "catastrophe",
+               .data     = &libcfs_catastrophe,
+               .maxlen   = sizeof(int),
+               .mode     = 0444,
+               .proc_handler = &proc_dointvec,
+       },
+       {
+               .procname = "panic_on_lbug",
+               .data     = &libcfs_panic_on_lbug,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dointvec,
+       },
+       {
+               .procname = "dump_kernel",
+               .maxlen   = 256,
+               .mode     = 0200,
+               .proc_handler = &proc_dump_kernel,
+       },
+       {
+               .procname = "daemon_file",
+               .mode     = 0644,
+               .maxlen   = 256,
+               .proc_handler = &proc_daemon_file,
+       },
+       {
+               .procname = "debug_mb",
+               .mode     = 0644,
+               .proc_handler = &proc_debug_mb,
+       },
+       {
+               .procname = "watchdog_ratelimit",
+               .data     = &libcfs_watchdog_ratelimit,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dointvec_minmax,
+               .extra1   = &min_watchdog_ratelimit,
+               .extra2   = &max_watchdog_ratelimit,
+       },
+       {
+               .procname = "force_lbug",
+               .data     = NULL,
+               .maxlen   = 0,
+               .mode     = 0200,
+               .proc_handler = &libcfs_force_lbug
+       },
+       {
+               .procname = "fail_loc",
+               .data     = &cfs_fail_loc,
+               .maxlen   = sizeof(cfs_fail_loc),
+               .mode     = 0644,
+               .proc_handler = &proc_fail_loc
+       },
+       {
+               .procname = "fail_val",
+               .data     = &cfs_fail_val,
+               .maxlen   = sizeof(int),
+               .mode     = 0644,
+               .proc_handler = &proc_dointvec
+       },
+       {
+       }
+};
+
+static struct ctl_table top_table[] = {
+       {
+               .procname = "lnet",
+               .mode     = 0555,
+               .data     = NULL,
+               .maxlen   = 0,
+               .child    = lnet_table,
+       },
+       {
+       }
+};
+
+static int insert_proc(void)
+{
+       if (lnet_table_header == NULL)
+               lnet_table_header = register_sysctl_table(top_table);
+       return 0;
+}
+
+static void remove_proc(void)
+{
+       if (lnet_table_header != NULL)
+               unregister_sysctl_table(lnet_table_header);
+
+       lnet_table_header = NULL;
+}
+
 MODULE_VERSION("1.0.0");
+
 module_init(init_libcfs_module);
 module_exit(exit_libcfs_module);
index eb65b50f832deb36a2e8b3227ef54de58bc85176..c86394f7f4d9c32294eeb52a650255e4c24d208d 100644 (file)
@@ -53,7 +53,7 @@ char cfs_tracefile[TRACEFILE_NAME_SIZE];
 long long cfs_tracefile_size = CFS_TRACEFILE_SIZE;
 static struct tracefiled_ctl trace_tctl;
 struct mutex cfs_trace_thread_mutex;
-static int thread_running = 0;
+static int thread_running;
 
 static atomic_t cfs_tage_allocated = ATOMIC_INIT(0);
 
@@ -224,8 +224,7 @@ static struct cfs_trace_page *cfs_trace_get_tage(struct cfs_trace_cpu_data *tcd,
         */
 
        if (len > PAGE_CACHE_SIZE) {
-               printk(KERN_ERR
-                      "cowardly refusing to write %lu bytes in a page\n", len);
+               pr_err("cowardly refusing to write %lu bytes in a page\n", len);
                return NULL;
        }
 
@@ -688,8 +687,8 @@ int cfs_tracefile_dump_all_pages(char *filename)
        if (IS_ERR(filp)) {
                rc = PTR_ERR(filp);
                filp = NULL;
-               printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n",
-                     filename, rc);
+               pr_err("LustreError: can't open %s for dump: rc %d\n",
+                       filename, rc);
                goto out;
        }
 
@@ -726,7 +725,7 @@ int cfs_tracefile_dump_all_pages(char *filename)
        MMSPACE_CLOSE;
        rc = vfs_fsync(filp, 1);
        if (rc)
-               printk(KERN_ERR "sync returns %d\n", rc);
+               pr_err("sync returns %d\n", rc);
 close:
        filp_close(filp, NULL);
 out:
@@ -1048,22 +1047,21 @@ static int tracefiled(void *arg)
                        int i;
 
                        printk(KERN_ALERT "Lustre: trace pages aren't empty\n");
-                       printk(KERN_ERR "total cpus(%d): ",
-                              num_possible_cpus());
+                       pr_err("total cpus(%d): ",
+                               num_possible_cpus());
                        for (i = 0; i < num_possible_cpus(); i++)
                                if (cpu_online(i))
-                                       printk(KERN_ERR "%d(on) ", i);
+                                       pr_cont("%d(on) ", i);
                                else
-                                       printk(KERN_ERR "%d(off) ", i);
-                       printk(KERN_ERR "\n");
+                                       pr_cont("%d(off) ", i);
+                       pr_cont("\n");
 
                        i = 0;
                        list_for_each_entry_safe(tage, tmp, &pc.pc_pages,
                                                     linkage)
-                               printk(KERN_ERR "page %d belongs to cpu %d\n",
-                                      ++i, tage->cpu);
-                       printk(KERN_ERR "There are %d pages unwritten\n",
-                              i);
+                               pr_err("page %d belongs to cpu %d\n",
+                                       ++i, tage->cpu);
+                       pr_err("There are %d pages unwritten\n", i);
                }
                __LASSERT(list_empty(&pc.pc_pages));
 end_loop:
index c4afaeaf83105d42b59d920351fb4582a7867700..48009b7758456acae626aa1ae576acea5c20078d 100644 (file)
@@ -442,7 +442,7 @@ cfs_wi_startup(void)
 }
 
 void
-cfs_wi_shutdown (void)
+cfs_wi_shutdown(void)
 {
        struct cfs_wi_sched     *sched;
 
index ddf1fa9f67f8f80fbb8237260a0b4bef3a74b0d4..fe1fd05423e9b6aec1d1cd55e38937a3d1f32d73 100644 (file)
@@ -128,7 +128,7 @@ static int find_cbdata(struct inode *inode)
        rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode),
                            return_if_equal, NULL);
        if (rc != 0)
-                return rc;
+               return rc;
 
        lsm = ccc_inode_lsm_get(inode);
        if (lsm == NULL)
@@ -339,13 +339,10 @@ static int ll_revalidate_dentry(struct dentry *dentry,
  */
 static int ll_revalidate_nd(struct dentry *dentry, unsigned int flags)
 {
-       int rc;
-
        CDEBUG(D_VFSTRACE, "VFS Op:name=%pd, flags=%u\n",
               dentry, flags);
 
-       rc = ll_revalidate_dentry(dentry, flags);
-       return rc;
+       return ll_revalidate_dentry(dentry, flags);
 }
 
 
index a18201913273d0ddd444de2ed5561ec27f1bbe6f..a5bc694dcb64aa1193b66a6f8614fd71a0d2b43b 100644 (file)
@@ -41,7 +41,7 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/mm.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/buffer_head.h>   /* for wait_on_buffer */
 #include <linux/pagevec.h>
 #include <linux/prefetch.h>
@@ -1518,6 +1518,7 @@ out_rmdir:
                        lump = (struct lov_user_md *)arg;
                } else {
                        struct lov_user_mds_data *lmdp;
+
                        lmdp = (struct lov_user_mds_data *)arg;
                        lump = &lmdp->lmd_lmm;
                }
@@ -1909,21 +1910,21 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin)
 
        mutex_lock(&inode->i_mutex);
        switch (origin) {
-               case SEEK_SET:
-                       break;
-               case SEEK_CUR:
-                       offset += file->f_pos;
-                       break;
-               case SEEK_END:
-                       if (offset > 0)
-                               goto out;
-                       if (api32)
-                               offset += LL_DIR_END_OFF_32BIT;
-                       else
-                               offset += LL_DIR_END_OFF;
-                       break;
-               default:
+       case SEEK_SET:
+               break;
+       case SEEK_CUR:
+               offset += file->f_pos;
+               break;
+       case SEEK_END:
+               if (offset > 0)
                        goto out;
+               if (api32)
+                       offset += LL_DIR_END_OFF_32BIT;
+               else
+                       offset += LL_DIR_END_OFF;
+               break;
+       default:
+               goto out;
        }
 
        if (offset >= 0 &&
index 5ebee6ca0a108330711cd02aefea5f87eaccd771..6dab3baa80635f5674509aebbbce7b0425a78be1 100644 (file)
@@ -161,7 +161,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp,
                op_data->op_lease_handle = och->och_lease_handle;
                op_data->op_attr.ia_valid |= ATTR_SIZE | ATTR_BLOCKS;
        }
-       epoch_close = (op_data->op_flags & MF_EPOCH_CLOSE);
+       epoch_close = op_data->op_flags & MF_EPOCH_CLOSE;
        rc = md_close(md_exp, op_data, och->och_mod, &req);
        if (rc == -EAGAIN) {
                /* This close must have the epoch closed. */
@@ -197,6 +197,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp,
        }
        if (rc == 0 && op_data->op_bias & MDS_HSM_RELEASE) {
                struct mdt_body *body;
+
                body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
                if (!(body->valid & OBD_MD_FLRELEASED))
                        rc = -EBUSY;
@@ -269,7 +270,7 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
        int lockmode;
        __u64 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
        struct lustre_handle lockh;
-       ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
+       ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_OPEN}};
        int rc = 0;
 
        /* clear group lock, if present */
@@ -692,7 +693,7 @@ restart:
 out_och_free:
        if (rc) {
                if (och_p && *och_p) {
-                       OBD_FREE(*och_p, sizeof (struct obd_client_handle));
+                       OBD_FREE(*och_p, sizeof(struct obd_client_handle));
                        *och_p = NULL; /* OBD_FREE writes some magic there */
                        (*och_usecount)--;
                }
@@ -2821,7 +2822,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits,  ldlm_mode_t l_req_mode)
        int i;
 
        if (!inode)
-              return 0;
+               return 0;
 
        fid = &ll_i2info(inode)->lli_fid;
        CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid),
@@ -3233,6 +3234,7 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd)
 
        return in_data;
 }
+EXPORT_SYMBOL(ll_iocontrol_register);
 
 void ll_iocontrol_unregister(void *magic)
 {
@@ -3257,8 +3259,6 @@ void ll_iocontrol_unregister(void *magic)
 
        CWARN("didn't find iocontrol register block with magic: %p\n", magic);
 }
-
-EXPORT_SYMBOL(ll_iocontrol_register);
 EXPORT_SYMBOL(ll_iocontrol_unregister);
 
 static enum llioc_iter
index 21b4a50267765d1f214b934be5221d83b6c9bb0d..a94ba02ccf02ea843db696875eb8a8cd1fef1cbe 100644 (file)
@@ -284,10 +284,8 @@ static void ll_done_writing(struct inode *inode)
        LASSERT(exp_connect_som(ll_i2mdexp(inode)));
 
        op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
-       if (!op_data) {
-               CERROR("can't allocate op_data\n");
+       if (!op_data)
                return;
-       }
 
        ll_prepare_done_writing(inode, op_data, &och);
        /* If there is no @och, we do not do D_W yet. */
index 0c1b583a4ea1fe77fd5e694e2f35e312cf0ae271..bf1ec277a1dc72072592551563e4b534f1ef7532 100644 (file)
@@ -87,11 +87,10 @@ static struct ll_sb_info *ll_init_sbi(void)
 
        si_meminfo(&si);
        pages = si.totalram - si.totalhigh;
-       if (pages >> (20 - PAGE_CACHE_SHIFT) < 512) {
+       if (pages >> (20 - PAGE_CACHE_SHIFT) < 512)
                lru_page_max = pages / 2;
-       } else {
+       else
                lru_page_max = (pages / 4) * 3;
-       }
 
        /* initialize lru data */
        atomic_set(&sbi->ll_cache.ccc_users, 0);
@@ -621,7 +620,7 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
        rc = obd_get_info(NULL, sbi->ll_md_exp, sizeof(KEY_MAX_EASIZE),
                          KEY_MAX_EASIZE, &size, lmmsize, NULL);
        if (rc)
-               CERROR("Get max mdsize error rc %d \n", rc);
+               CERROR("Get max mdsize error rc %d\n", rc);
 
        return rc;
 }
@@ -978,19 +977,17 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
        CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
               lprof->lp_md, lprof->lp_dt);
 
-       dt = kzalloc(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS);
+       dt = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
        if (!dt) {
                err = -ENOMEM;
                goto out_free;
        }
-       sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
 
-       md = kzalloc(strlen(lprof->lp_md) + instlen + 2, GFP_NOFS);
+       md = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_md, cfg->cfg_instance);
        if (!md) {
                err = -ENOMEM;
                goto out_free;
        }
-       sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
 
        /* connections, registrations, sb setup */
        err = client_common_fill_super(sb, md, dt, mnt);
@@ -1432,7 +1429,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
 
        if (attr->ia_valid & (ATTR_SIZE |
                              ATTR_ATIME | ATTR_ATIME_SET |
-                             ATTR_MTIME | ATTR_MTIME_SET))
+                             ATTR_MTIME | ATTR_MTIME_SET)) {
                /* For truncate and utimes sending attributes to OSTs, setting
                 * mtime/atime to the past will be performed under PW [0:EOF]
                 * extent lock (new_size:EOF for truncate).  It may seem
@@ -1444,6 +1441,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
                rc = ll_setattr_ost(inode, attr);
                if (attr->ia_valid & ATTR_SIZE)
                        up_write(&lli->lli_trunc_sem);
+       }
 out:
        if (op_data) {
                if (op_data->op_ioepoch) {
@@ -1608,7 +1606,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
        struct lov_stripe_md *lsm = md->lsm;
        struct ll_sb_info *sbi = ll_i2sbi(inode);
 
-       LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
+       LASSERT((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
        if (lsm != NULL) {
                if (!lli->lli_has_smd &&
                    !(sbi->ll_flags & LL_SBI_LAYOUT_LOCK))
@@ -2152,7 +2150,8 @@ int ll_process_config(struct lustre_cfg *lcfg)
        ptr = strrchr(lustre_cfg_string(lcfg, 0), '-');
        if (!ptr || !*(++ptr))
                return -EINVAL;
-       if (sscanf(ptr, "%lx", &x) != 1)
+       rc = kstrtoul(ptr, 16, &x);
+       if (rc != 0)
                return -EINVAL;
        sb = (void *)x;
        /* This better be a real Lustre superblock! */
index 479bf428780ce766c18faaf211372126f732a28d..a90214bb84ddfe7f3e32d47d8a901935c1af97bd 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/stat.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include <linux/fs.h>
 #include <linux/pagemap.h>
@@ -312,7 +312,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf)
                vio->u.fault.ft_vmpage    = NULL;
                vio->u.fault.fault.ft_vmf = vmf;
                vio->u.fault.fault.ft_flags = 0;
-               vio->u.fault.fault.ft_flags_valid = 0;
+               vio->u.fault.fault.ft_flags_valid = false;
 
                result = cl_io_loop(env, io);
 
index 031248840642a5dc3d40d6d3b03c1f589db4f625..413a8408e3f5b97cb74518a82aaeb3e25d2b8d0d 100644 (file)
 #include <linux/highmem.h>
 #include <linux/gfp.h>
 #include <linux/pagevec.h>
-
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include "../include/lustre_lib.h"
 #include "../include/lustre_lite.h"
@@ -349,7 +348,7 @@ static void loop_make_request(struct request_queue *q, struct bio *old_bio)
               old_bio->bi_iter.bi_size);
 
        spin_lock_irq(&lo->lo_lock);
-       inactive = (lo->lo_state != LLOOP_BOUND);
+       inactive = lo->lo_state != LLOOP_BOUND;
        spin_unlock_irq(&lo->lo_lock);
        if (inactive)
                goto err;
index aaa13bd3e8dea86eab9c3980c442183f532bedcc..83a9b85474e1291ec45257aa0d83a94fdfb48606 100644 (file)
@@ -59,7 +59,7 @@ static int ll_blksize_seq_show(struct seq_file *m, void *v)
                                cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                                OBD_STATFS_NODELAY);
        if (!rc)
-             rc = seq_printf(m, "%u\n", osfs.os_bsize);
+               seq_printf(m, "%u\n", osfs.os_bsize);
 
        return rc;
 }
@@ -82,8 +82,9 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 LPROC_SEQ_FOPS_RO(ll_kbytestotal);
@@ -105,8 +106,9 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 LPROC_SEQ_FOPS_RO(ll_kbytesfree);
@@ -128,8 +130,9 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 LPROC_SEQ_FOPS_RO(ll_kbytesavail);
@@ -145,7 +148,8 @@ static int ll_filestotal_seq_show(struct seq_file *m, void *v)
                                cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                                OBD_STATFS_NODELAY);
        if (!rc)
-                rc = seq_printf(m, "%llu\n", osfs.os_files);
+               seq_printf(m, "%llu\n", osfs.os_files);
+
        return rc;
 }
 LPROC_SEQ_FOPS_RO(ll_filestotal);
@@ -161,7 +165,8 @@ static int ll_filesfree_seq_show(struct seq_file *m, void *v)
                                cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                                OBD_STATFS_NODELAY);
        if (!rc)
-                rc = seq_printf(m, "%llu\n", osfs.os_ffree);
+               seq_printf(m, "%llu\n", osfs.os_ffree);
+
        return rc;
 }
 LPROC_SEQ_FOPS_RO(ll_filesfree);
@@ -169,16 +174,15 @@ LPROC_SEQ_FOPS_RO(ll_filesfree);
 static int ll_client_type_seq_show(struct seq_file *m, void *v)
 {
        struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
-       int rc;
 
        LASSERT(sbi != NULL);
 
        if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
-               rc = seq_printf(m, "remote client\n");
+               seq_puts(m, "remote client\n");
        else
-               rc = seq_printf(m, "local client\n");
+               seq_puts(m, "local client\n");
 
-       return rc;
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_client_type);
 
@@ -187,7 +191,8 @@ static int ll_fstype_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = (struct super_block *)m->private;
 
        LASSERT(sb != NULL);
-       return seq_printf(m, "%s\n", sb->s_type->name);
+       seq_printf(m, "%s\n", sb->s_type->name);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_fstype);
 
@@ -196,7 +201,8 @@ static int ll_sb_uuid_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = (struct super_block *)m->private;
 
        LASSERT(sb != NULL);
-       return seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
+       seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_sb_uuid);
 
@@ -353,17 +359,18 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v)
 
        max_cached_mb = cache->ccc_lru_max >> shift;
        unused_mb = atomic_read(&cache->ccc_lru_left) >> shift;
-       return seq_printf(m,
-                       "users: %d\n"
-                       "max_cached_mb: %d\n"
-                       "used_mb: %d\n"
-                       "unused_mb: %d\n"
-                       "reclaim_count: %u\n",
-                       atomic_read(&cache->ccc_users),
-                       max_cached_mb,
-                       max_cached_mb - unused_mb,
-                       unused_mb,
-                       cache->ccc_lru_shrinkers);
+       seq_printf(m,
+                  "users: %d\n"
+                  "max_cached_mb: %d\n"
+                  "used_mb: %d\n"
+                  "unused_mb: %d\n"
+                  "reclaim_count: %u\n",
+                  atomic_read(&cache->ccc_users),
+                  max_cached_mb,
+                  max_cached_mb - unused_mb,
+                  unused_mb,
+                  cache->ccc_lru_shrinkers);
+       return 0;
 }
 
 static ssize_t ll_max_cached_mb_seq_write(struct file *file,
@@ -467,7 +474,8 @@ static int ll_checksum_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
-       return seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
+       seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
+       return 0;
 }
 
 static ssize_t ll_checksum_seq_write(struct file *file,
@@ -503,7 +511,8 @@ static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
 
-       return seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
+       seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
+       return 0;
 }
 
 static ssize_t ll_max_rw_chunk_seq_write(struct file *file,
@@ -525,15 +534,14 @@ static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type)
 {
        struct super_block *sb = m->private;
 
-       if (ll_s2sbi(sb)->ll_stats_track_type == type) {
-               return seq_printf(m, "%d\n",
-                               ll_s2sbi(sb)->ll_stats_track_id);
+       if (ll_s2sbi(sb)->ll_stats_track_type == type)
+               seq_printf(m, "%d\n", ll_s2sbi(sb)->ll_stats_track_id);
+       else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL)
+               seq_puts(m, "0 (all)\n");
+       else
+               seq_puts(m, "untracked\n");
 
-       } else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL) {
-               return seq_printf(m, "0 (all)\n");
-       } else {
-               return seq_printf(m, "untracked\n");
-       }
+       return 0;
 }
 
 static int ll_wr_track_id(const char __user *buffer, unsigned long count,
@@ -601,7 +609,8 @@ static int ll_statahead_max_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
-       return seq_printf(m, "%u\n", sbi->ll_sa_max);
+       seq_printf(m, "%u\n", sbi->ll_sa_max);
+       return 0;
 }
 
 static ssize_t ll_statahead_max_seq_write(struct file *file,
@@ -631,8 +640,8 @@ static int ll_statahead_agl_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
-       return seq_printf(m, "%u\n",
-                       sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
+       seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
+       return 0;
 }
 
 static ssize_t ll_statahead_agl_seq_write(struct file *file,
@@ -661,13 +670,14 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
-       return seq_printf(m,
-                       "statahead total: %u\n"
-                       "statahead wrong: %u\n"
-                       "agl total: %u\n",
-                       atomic_read(&sbi->ll_sa_total),
-                       atomic_read(&sbi->ll_sa_wrong),
-                       atomic_read(&sbi->ll_agl_total));
+       seq_printf(m,
+                  "statahead total: %u\n"
+                  "statahead wrong: %u\n"
+                  "agl total: %u\n",
+                  atomic_read(&sbi->ll_sa_total),
+                  atomic_read(&sbi->ll_sa_wrong),
+                  atomic_read(&sbi->ll_agl_total));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_statahead_stats);
 
@@ -676,8 +686,8 @@ static int ll_lazystatfs_seq_show(struct seq_file *m, void *v)
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
 
-       return seq_printf(m, "%u\n",
-                       (sbi->ll_flags & LL_SBI_LAZYSTATFS) ? 1 : 0);
+       seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0);
+       return 0;
 }
 
 static ssize_t ll_lazystatfs_seq_write(struct file *file,
@@ -712,11 +722,12 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v)
        if (rc)
                return rc;
 
-       return seq_printf(m, "%u\n", ealen);
+       seq_printf(m, "%u\n", ealen);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_max_easize);
 
-static int ll_defult_easize_seq_show(struct seq_file *m, void *v)
+static int ll_default_easize_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -727,9 +738,10 @@ static int ll_defult_easize_seq_show(struct seq_file *m, void *v)
        if (rc)
                return rc;
 
-       return seq_printf(m, "%u\n", ealen);
+       seq_printf(m, "%u\n", ealen);
+       return 0;
 }
-LPROC_SEQ_FOPS_RO(ll_defult_easize);
+LPROC_SEQ_FOPS_RO(ll_default_easize);
 
 static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
 {
@@ -742,11 +754,12 @@ static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
        if (rc)
                return rc;
 
-       return seq_printf(m, "%u\n", cookielen);
+       seq_printf(m, "%u\n", cookielen);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ll_max_cookiesize);
 
-static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v)
+static int ll_default_cookiesize_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
@@ -757,9 +770,10 @@ static int ll_defult_cookiesize_seq_show(struct seq_file *m, void *v)
        if (rc)
                return rc;
 
-       return seq_printf(m, "%u\n", cookielen);
+       seq_printf(m, "%u\n", cookielen);
+       return 0;
 }
-LPROC_SEQ_FOPS_RO(ll_defult_cookiesize);
+LPROC_SEQ_FOPS_RO(ll_default_cookiesize);
 
 static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
 {
@@ -789,11 +803,10 @@ static int ll_xattr_cache_seq_show(struct seq_file *m, void *v)
 {
        struct super_block *sb = m->private;
        struct ll_sb_info *sbi = ll_s2sbi(sb);
-       int rc;
 
-       rc = seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled);
+       seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled);
 
-       return rc;
+       return 0;
 }
 
 static ssize_t ll_xattr_cache_seq_write(struct file *file,
@@ -849,9 +862,9 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
        { "statahead_stats",  &ll_statahead_stats_fops, NULL, 0 },
        { "lazystatfs",       &ll_lazystatfs_fops, NULL },
        { "max_easize",       &ll_max_easize_fops, NULL, 0 },
-       { "default_easize",   &ll_defult_easize_fops, NULL, 0 },
+       { "default_easize",   &ll_default_easize_fops, NULL, 0 },
        { "max_cookiesize",   &ll_max_cookiesize_fops, NULL, 0 },
-       { "default_cookiesize", &ll_defult_cookiesize_fops, NULL, 0 },
+       { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 },
        { "sbi_flags",        &ll_sbi_flags_fops, NULL, 0 },
        { "xattr_cache",      &ll_xattr_cache_fops, NULL, 0 },
        { NULL }
index 890ac190f5faf3300ab8461f08cfe63182078c27..49f1cb067ea2d8514e977ccfc8add30095dd51fc 100644 (file)
@@ -83,7 +83,8 @@ static int ll_set_inode(struct inode *inode, void *opaque)
 
        lli->lli_fid = body->fid1;
        if (unlikely(!(body->valid & OBD_MD_FLTYPE))) {
-               CERROR("Can not initialize inode " DFID " without object type: valid = %#llx\n",
+               CERROR("Can not initialize inode " DFID
+                      " without object type: valid = %#llx\n",
                       PFID(&lli->lli_fid), body->valid);
                return -EINVAL;
        }
@@ -600,7 +601,8 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
        long long lookup_flags = LOOKUP_OPEN;
        int rc = 0;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:name=%pd,dir=%lu/%u(%p),file %p,open_flags %x,mode %x opened %d\n",
+       CDEBUG(D_VFSTRACE,
+              "VFS Op:name=%pd,dir=%lu/%u(%p),file %p,open_flags %x,mode %x opened %d\n",
               dentry, dir->i_ino,
               dir->i_generation, dir, file, open_flags, mode, *opened);
 
@@ -974,11 +976,12 @@ out:
  * Instead, ll_ddelete() and ll_d_iput() will update it based upon if there
  * is any lock existing. They will recycle dentries and inodes based upon locks
  * too. b=20433 */
-static int ll_unlink(struct inode * dir, struct dentry *dentry)
+static int ll_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct ptlrpc_request *request = NULL;
        struct md_op_data *op_data;
        int rc;
+
        CDEBUG(D_VFSTRACE, "VFS Op:name=%pd,dir=%lu/%u(%p)\n",
               dentry, dir->i_ino, dir->i_generation, dir);
 
@@ -1033,7 +1036,7 @@ static int ll_rmdir(struct inode *dir, struct dentry *dentry)
               dentry, dir->i_ino, dir->i_generation, dir);
 
        op_data = ll_prep_md_op_data(NULL, dir, NULL,
-                                    dentry->d_name.name, 
+                                    dentry->d_name.name,
                                     dentry->d_name.len,
                                     S_IFDIR, LUSTRE_OPC_ANY, NULL);
        if (IS_ERR(op_data))
@@ -1111,10 +1114,9 @@ static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
        int err;
 
        CDEBUG(D_VFSTRACE,
-              "VFS Op:oldname=%pd,src_dir=%lu/%u(%p),newname=%pd,"
-              "tgt_dir=%lu/%u(%p)\n", old_dentry,
-              old_dir->i_ino, old_dir->i_generation, old_dir, new_dentry,
-              new_dir->i_ino, new_dir->i_generation, new_dir);
+              "VFS Op:oldname=%pd,src_dir=%lu/%u(%p),newname=%pd,tgt_dir=%lu/%u(%p)\n",
+              old_dentry, old_dir->i_ino, old_dir->i_generation, old_dir,
+              new_dentry, new_dir->i_ino, new_dir->i_generation, new_dir);
 
        op_data = ll_prep_md_op_data(NULL, old_dir, new_dir, NULL, 0, 0,
                                     LUSTRE_OPC_ANY, NULL);
index 10a0421366d08941415eda26c6f65ab14b3a6e87..991d20c5065d3d0e83b169614cc474c54fa6d46d 100644 (file)
@@ -45,7 +45,7 @@
 #include <linux/errno.h>
 #include <linux/unistd.h>
 #include <linux/writeback.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include <linux/fs.h>
 #include <linux/pagemap.h>
@@ -750,7 +750,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io,
                /* Note: we only trim the RPC, instead of extending the RPC
                 * to the boundary, so to avoid reading too much pages during
                 * random reading. */
-               rpc_boundary = ((end + 1) & (~(PTLRPC_MAX_BRW_PAGES - 1)));
+               rpc_boundary = (end + 1) & (~(PTLRPC_MAX_BRW_PAGES - 1));
                if (rpc_boundary > 0)
                        rpc_boundary--;
 
index 2f21304046aa9335e438b36f462be4aa62cbebd3..91442fab57255df1f4ebd41fa0bfaaf83b24dca2 100644 (file)
@@ -44,7 +44,7 @@
 #include <linux/stat.h>
 #include <linux/errno.h>
 #include <linux/unistd.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include <linux/migrate.h>
 #include <linux/fs.h>
index 6ad9dd0fe2b3d9d7da842e9af2d895a1097c42e6..b75562c6b5de95700b6ee1ee8eeae6e6e54931a6 100644 (file)
@@ -84,7 +84,7 @@ struct ll_sa_entry {
        struct qstr          se_qstr;
 };
 
-static unsigned int sai_generation = 0;
+static unsigned int sai_generation;
 static DEFINE_SPINLOCK(sai_generation_lock);
 
 static inline int ll_sa_entry_unhashed(struct ll_sa_entry *entry)
@@ -706,11 +706,21 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
        struct ll_inode_info     *lli = ll_i2info(dir);
        struct ll_statahead_info *sai = NULL;
        struct ll_sa_entry       *entry;
+       __u64                     handle = 0;
        int                    wakeup;
 
        if (it_disposition(it, DISP_LOOKUP_NEG))
                rc = -ENOENT;
 
+       if (rc == 0) {
+               /* release ibits lock ASAP to avoid deadlock when statahead
+                * thread enqueues lock on parent in readdir and another
+                * process enqueues lock on child with parent lock held, eg.
+                * unlink. */
+               handle = it->d.lustre.it_lock_handle;
+               ll_intent_drop_lock(it);
+       }
+
        spin_lock(&lli->lli_sa_lock);
        /* stale entry */
        if (unlikely(lli->lli_sai == NULL ||
@@ -745,8 +755,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
                         * when statahead thread tries to enqueue lock on parent
                         * for readpage and other tries to enqueue lock on child
                         * with parent's lock held, for example: unlink. */
-                       entry->se_handle = it->d.lustre.it_lock_handle;
-                       ll_intent_drop_lock(it);
+                       entry->se_handle = handle;
                        wakeup = sa_received_empty(sai);
                        list_add_tail(&entry->se_list,
                                          &sai->sai_entries_received);
index 7c1e02a031ba1705bd8462337494e0de8ce5fc08..a494f6271fa0b6394e4d182b4f47725b88ca86d4 100644 (file)
@@ -152,9 +152,7 @@ static int __init init_lustre_lite(void)
 
        do_gettimeofday(&tv);
        cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
-
-       init_timer(&ll_capa_timer);
-       ll_capa_timer.function = ll_capa_timer_callback;
+       setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0);
        rc = ll_capa_thread_start();
        if (rc != 0)
                goto out_proc;
index 5a1078a4198d7b94d61431a04dabb4c810ceb629..fde41d7c5e3d8e1aaa12da5514281732d0c8cb25 100644 (file)
@@ -63,12 +63,12 @@ static struct lu_kmem_descr vvp_caches[] = {
        {
                .ckd_cache = &vvp_thread_kmem,
                .ckd_name  = "vvp_thread_kmem",
-               .ckd_size  = sizeof (struct vvp_thread_info),
+               .ckd_size  = sizeof(struct vvp_thread_info),
        },
        {
                .ckd_cache = &vvp_session_kmem,
                .ckd_name  = "vvp_session_kmem",
-               .ckd_size  = sizeof (struct vvp_session)
+               .ckd_size  = sizeof(struct vvp_session)
        },
        {
                .ckd_cache = NULL
@@ -90,6 +90,7 @@ static void vvp_key_fini(const struct lu_context *ctx,
                         struct lu_context_key *key, void *data)
 {
        struct vvp_thread_info *info = data;
+
        OBD_SLAB_FREE_PTR(info, vvp_thread_kmem);
 }
 
@@ -108,6 +109,7 @@ static void vvp_session_key_fini(const struct lu_context *ctx,
                                 struct lu_context_key *key, void *data)
 {
        struct vvp_session *session = data;
+
        OBD_SLAB_FREE_PTR(session, vvp_session_kmem);
 }
 
@@ -286,7 +288,7 @@ static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id)
 
        id->vpi_index  = pos & 0xffffffff;
        id->vpi_depth  = (pos >> PGC_DEPTH_SHIFT) & 0xf;
-       id->vpi_bucket = ((unsigned long long)pos >> PGC_OBJ_SHIFT);
+       id->vpi_bucket = (unsigned long long)pos >> PGC_OBJ_SHIFT;
 }
 
 static loff_t vvp_pgcache_id_pack(struct vvp_pgcache_id *id)
index e2badf17d95e6b439d21c5214b2f3be07e80c6c4..da190f92d14079fc97c7be2c188c47d8c257f4db 100644 (file)
@@ -132,14 +132,10 @@ static int ll_xattr_cache_add(struct list_head *cache,
                       xattr->xe_namelen);
                goto err_name;
        }
-       xattr->xe_value = kzalloc(xattr_val_len, GFP_NOFS);
-       if (!xattr->xe_value) {
-               CDEBUG(D_CACHE, "failed to alloc xattr value %d\n",
-                      xattr_val_len);
+       xattr->xe_value = kmemdup(xattr_val, xattr_val_len, GFP_NOFS);
+       if (!xattr->xe_value)
                goto err_value;
-       }
 
-       memcpy(xattr->xe_value, xattr_val, xattr_val_len);
        xattr->xe_vallen = xattr_val_len;
        list_add(&xattr->xe_list, cache);
 
index b779f47384c52053eeee5a3147280ad141e85f5a..b9459faf8645a6dffe781c2e05f82ae3e9cbc514 100644 (file)
@@ -43,7 +43,7 @@
 #include <asm/div64.h>
 #include <linux/seq_file.h>
 #include <linux/namei.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include "../include/lustre/lustre_idl.h"
 #include "../include/obd_support.h"
@@ -487,7 +487,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                __u32 oldsize = 0;
 
                while (newsize < index + 1)
-                       newsize = newsize << 1;
+                       newsize <<= 1;
                OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
                if (newtgts == NULL) {
                        lmv_init_unlock(lmv);
index 5be4176829d314076766cf4230190103d906bb67..d5bc0fbdf7900757fdb307f1c2d4e1b8d49a6b27 100644 (file)
@@ -48,7 +48,8 @@ static int lmv_numobd_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lmv.desc;
-       return seq_printf(m, "%u\n", desc->ld_tgt_count);
+       seq_printf(m, "%u\n", desc->ld_tgt_count);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lmv_numobd);
 
@@ -82,7 +83,8 @@ static int lmv_placement_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        lmv = &dev->u.lmv;
-       return seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
+       seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
+       return 0;
 }
 
 #define MAX_POLICY_STRING_SIZE 64
@@ -130,7 +132,8 @@ static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lmv.desc;
-       return seq_printf(m, "%u\n", desc->ld_active_tgt_count);
+       seq_printf(m, "%u\n", desc->ld_active_tgt_count);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lmv_activeobd);
 
@@ -141,7 +144,8 @@ static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        lmv = &dev->u.lmv;
-       return seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
+       seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
 
@@ -171,8 +175,10 @@ static int lmv_tgt_seq_show(struct seq_file *p, void *v)
 
        if (tgt == NULL)
                return 0;
-       return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_idx,
-                         tgt->ltd_uuid.uuid, tgt->ltd_active ? "" : "IN");
+       seq_printf(p, "%d: %s %sACTIVE\n",
+                  tgt->ltd_idx, tgt->ltd_uuid.uuid,
+                  tgt->ltd_active ? "" : "IN");
+       return 0;
 }
 
 static struct seq_operations lmv_tgt_sops = {
index 796a015d070ca50143161779566913c3cff2d1e2..711b837ddba23aa8fa6028a828f06f8753ce979b 100644 (file)
@@ -60,7 +60,7 @@ struct kmem_cache *lovsub_req_kmem;
 struct kmem_cache *lov_lock_link_kmem;
 
 /** Lock class of lov_device::ld_mutex. */
-struct lock_class_key cl_lov_device_mutex_class;
+static struct lock_class_key cl_lov_device_mutex_class;
 
 struct lu_kmem_descr lov_caches[] = {
        {
index e9ec39c5a6c2eb506e7d24a49a15b50b5fccbe66..d1b0417d50583a2b2d3a99c049020ae6d6de5f87 100644 (file)
@@ -209,8 +209,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
        return lsm_lmm_verify_common(lmm, lmm_bytes, *stripe_count);
 }
 
-int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
-                   struct lov_mds_md_v1 *lmm)
+static int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
+                          struct lov_mds_md_v1 *lmm)
 {
        struct lov_oinfo *loi;
        int i;
@@ -287,8 +287,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes,
                                     *stripe_count);
 }
 
-int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
-                   struct lov_mds_md *lmmv1)
+static int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
+                          struct lov_mds_md *lmmv1)
 {
        struct lov_mds_md_v3 *lmm;
        struct lov_oinfo *loi;
index ea503d2a19f8bc90d2d54844279c10631109cf6b..b2ed52f20afbf9cadf9e563164a094bdf7d94654 100644 (file)
@@ -553,7 +553,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
 
                newsize = max_t(__u32, lov->lov_tgt_size, 2);
                while (newsize < index + 1)
-                       newsize = newsize << 1;
+                       newsize <<= 1;
                OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
                if (newtgts == NULL) {
                        mutex_unlock(&lov->lov_lock);
@@ -1601,9 +1601,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
  * \param fm_end logical end of mapping
  * \param start_stripe starting stripe will be returned in this
  */
-u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap,
-                                  struct lov_stripe_md *lsm, u64 fm_start,
-                                  u64 fm_end, int *start_stripe)
+static u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap,
+                                    struct lov_stripe_md *lsm, u64 fm_start,
+                                    u64 fm_end, int *start_stripe)
 {
        u64 local_end = fiemap->fm_extents[0].fe_logical;
        u64 lun_start, lun_end;
@@ -1658,17 +1658,17 @@ u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap,
  *
  * \retval last_stripe return the last stripe of the mapping
  */
-int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, u64 fm_start,
-                           u64 fm_end, int start_stripe,
-                           int *stripe_count)
+static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, u64 fm_start,
+                                  u64 fm_end, int start_stripe,
+                                  int *stripe_count)
 {
        int last_stripe;
        u64 obd_start, obd_end;
        int i, j;
 
        if (fm_end - fm_start > lsm->lsm_stripe_size * lsm->lsm_stripe_count) {
-               last_stripe = (start_stripe < 1 ? lsm->lsm_stripe_count - 1 :
-                                                             start_stripe - 1);
+               last_stripe = start_stripe < 1 ? lsm->lsm_stripe_count - 1 :
+                                                             start_stripe - 1;
                *stripe_count = lsm->lsm_stripe_count;
        } else {
                for (j = 0, i = start_stripe; j < lsm->lsm_stripe_count;
@@ -1694,10 +1694,10 @@ int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, u64 fm_start,
  * \param ext_count number of extents to be copied
  * \param current_extent where to start copying in main extent array
  */
-void fiemap_prepare_and_copy_exts(struct ll_user_fiemap *fiemap,
-                                 struct ll_fiemap_extent *lcl_fm_ext,
-                                 int ost_index, unsigned int ext_count,
-                                 int current_extent)
+static void fiemap_prepare_and_copy_exts(struct ll_user_fiemap *fiemap,
+                                        struct ll_fiemap_extent *lcl_fm_ext,
+                                        int ost_index, unsigned int ext_count,
+                                        int current_extent)
 {
        char *to;
        int ext;
@@ -2290,7 +2290,7 @@ out:
        return rc;
 }
 
-struct obd_ops lov_obd_ops = {
+static struct obd_ops lov_obd_ops = {
        .o_owner               = THIS_MODULE,
        .o_setup               = lov_setup,
        .o_precleanup     = lov_precleanup,
@@ -2324,7 +2324,7 @@ struct obd_ops lov_obd_ops = {
 
 struct kmem_cache *lov_oinfo_slab;
 
-int __init lov_init(void)
+static int __init lov_init(void)
 {
        struct lprocfs_static_vars lvars = { NULL };
        int rc;
index 4cab730ab429b2898e6a1d9312c977e3d0caf696..d69a0354baf51a4875b1cb0dfeebc830c4ed8928 100644 (file)
@@ -563,7 +563,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
 /**
  * Return lov_layout_type associated with a given lsm
  */
-enum lov_layout_type lov_type(struct lov_stripe_md *lsm)
+static enum lov_layout_type lov_type(struct lov_stripe_md *lsm)
 {
        if (lsm == NULL)
                return LLT_EMPTY;
index 0e0ea60de4c867b68bfff83e2d481a8e19bc6ce7..d96163de773f75542eadad37d740164eac60bb35 100644 (file)
@@ -71,7 +71,7 @@ void lov_pool_putref(struct pool_desc *pool)
        }
 }
 
-void lov_pool_putref_locked(struct pool_desc *pool)
+static void lov_pool_putref_locked(struct pool_desc *pool)
 {
        CDEBUG(D_INFO, "pool %p\n", pool);
        LASSERT(atomic_read(&pool->pool_refcount) > 1);
index c99f2f44ec62e2b69a25c6155550e4636263f337..174cbf5c138f87f7be3591d288c32ef07d2805b9 100644 (file)
@@ -35,7 +35,7 @@
  */
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include <asm/statfs.h>
+#include <linux/statfs.h>
 #include "../include/lprocfs_status.h"
 #include "../include/obd_class.h"
 #include <linux/seq_file.h>
@@ -48,7 +48,8 @@ static int lov_stripesize_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%llu\n", desc->ld_default_stripe_size);
+       seq_printf(m, "%llu\n", desc->ld_default_stripe_size);
+       return 0;
 }
 
 static ssize_t lov_stripesize_seq_write(struct file *file,
@@ -79,7 +80,8 @@ static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%llu\n", desc->ld_default_stripe_offset);
+       seq_printf(m, "%llu\n", desc->ld_default_stripe_offset);
+       return 0;
 }
 
 static ssize_t lov_stripeoffset_seq_write(struct file *file,
@@ -109,7 +111,8 @@ static int lov_stripetype_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%u\n", desc->ld_pattern);
+       seq_printf(m, "%u\n", desc->ld_pattern);
+       return 0;
 }
 
 static ssize_t lov_stripetype_seq_write(struct file *file,
@@ -139,8 +142,8 @@ static int lov_stripecount_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%d\n",
-                       (__s16)(desc->ld_default_stripe_count + 1) - 1);
+       seq_printf(m, "%d\n", (__s16)(desc->ld_default_stripe_count + 1) - 1);
+       return 0;
 }
 
 static ssize_t lov_stripecount_seq_write(struct file *file,
@@ -170,7 +173,8 @@ static int lov_numobd_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%u\n", desc->ld_tgt_count);
+       seq_printf(m, "%u\n", desc->ld_tgt_count);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lov_numobd);
 
@@ -181,7 +185,8 @@ static int lov_activeobd_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        desc = &dev->u.lov.desc;
-       return seq_printf(m, "%u\n", desc->ld_active_tgt_count);
+       seq_printf(m, "%u\n", desc->ld_active_tgt_count);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lov_activeobd);
 
@@ -192,7 +197,8 @@ static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
 
        LASSERT(dev != NULL);
        lov = &dev->u.lov;
-       return seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
+       seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(lov_desc_uuid);
 
@@ -228,12 +234,14 @@ static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
 static int lov_tgt_seq_show(struct seq_file *p, void *v)
 {
        struct lov_tgt_desc *tgt = v;
-       return seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
-                         obd_uuid2str(&tgt->ltd_uuid),
-                         tgt->ltd_active ? "" : "IN");
+
+       seq_printf(p, "%d: %s %sACTIVE\n",
+                  tgt->ltd_index, obd_uuid2str(&tgt->ltd_uuid),
+                  tgt->ltd_active ? "" : "IN");
+       return 0;
 }
 
-struct seq_operations lov_tgt_sops = {
+static const struct seq_operations lov_tgt_sops = {
        .start = lov_tgt_seq_start,
        .stop = lov_tgt_seq_stop,
        .next = lov_tgt_seq_next,
@@ -262,7 +270,7 @@ LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
 LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
 
-struct lprocfs_vars lprocfs_lov_obd_vars[] = {
+static struct lprocfs_vars lprocfs_lov_obd_vars[] = {
        { "uuid",         &lov_uuid_fops,         NULL, 0 },
        { "stripesize",   &lov_stripesize_fops,   NULL },
        { "stripeoffset", &lov_stripeoffset_fops, NULL },
index c791941bd810426346220ca47e526725f126ceb5..a4fb29496850fa270238d6bc9d7e22e39ddfd744 100644 (file)
@@ -43,12 +43,12 @@ static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+       seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 
 static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
index ef2744700d8bb7c55537b4601226b1b435cc3fc8..c04eec5c603e99c40ec42d4df93490f26b447754 100644 (file)
@@ -2707,14 +2707,12 @@ static struct md_ops mdc_md_ops = {
 
 static int __init mdc_init(void)
 {
-       int rc;
        struct lprocfs_static_vars lvars = { NULL };
 
        lprocfs_mdc_init_vars(&lvars);
 
-       rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
+       return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
                                 LUSTRE_MDC_NAME, NULL);
-       return rc;
 }
 
 static void /*__exit*/ mdc_exit(void)
index 60d2b0f12693939191a45b0701557a93ff6fb8a4..0375bfe29a7de559d6aa638052fa300de2312137 100644 (file)
@@ -160,7 +160,7 @@ struct config_llog_data *config_log_find(char *logname,
 {
        struct config_llog_data *cld;
        struct config_llog_data *found = NULL;
-       void *             instance;
+       void *instance;
 
        LASSERT(logname != NULL);
 
@@ -479,7 +479,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
 #define RQ_NOW     0x2
 #define RQ_LATER   0x4
 #define RQ_STOP    0x8
-static int                 rq_state = 0;
+static int rq_state;
 static wait_queue_head_t           rq_waitq;
 static DECLARE_COMPLETION(rq_exit);
 
@@ -690,8 +690,6 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 
 static int mgc_cleanup(struct obd_device *obd)
 {
-       int rc;
-
        /* COMPAT_146 - old config logs may have added profiles we don't
           know about */
        if (obd->obd_type->typ_refcnt <= 1)
@@ -701,8 +699,7 @@ static int mgc_cleanup(struct obd_device *obd)
        lprocfs_obd_cleanup(obd);
        ptlrpcd_decref();
 
-       rc = client_obd_cleanup(obd);
-       return rc;
+       return client_obd_cleanup(obd);
 }
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
index e7be26ec7521e397f2bce877c27414adb93021df..b1eee0a6dc9a1effdae32918133e46d16834321a 100644 (file)
@@ -424,11 +424,8 @@ EXPORT_SYMBOL(dt_find_or_create);
 /* dt class init function. */
 int dt_global_init(void)
 {
-       int result;
-
        LU_CONTEXT_KEY_INIT(&dt_key);
-       result = lu_context_key_register(&dt_key);
-       return result;
+       return lu_context_key_register(&dt_key);
 }
 
 void dt_global_fini(void)
index 82508210465eeb7090aee285725d4b7156319836..01858b0af01c4d5b786e89c1c393ecd1d0d2bd31 100644 (file)
@@ -1221,7 +1221,7 @@ int class_connected_export(struct obd_export *exp)
        if (exp) {
                int connected;
                spin_lock(&exp->exp_lock);
-               connected = (exp->exp_conn_cnt > 0);
+               connected = exp->exp_conn_cnt > 0;
                spin_unlock(&exp->exp_lock);
                return connected;
        }
@@ -1559,7 +1559,7 @@ void obd_exports_barrier(struct obd_device *obd)
 EXPORT_SYMBOL(obd_exports_barrier);
 
 /* Total amount of zombies to be destroyed */
-static int zombies_count = 0;
+static int zombies_count;
 
 /**
  * kill zombie imports and exports
index b94aeac18a37759bb71b0d448ebfc7fdcec9099d..75e704dc89449f2e8ffd7a8aa53f66b0c003e216 100644 (file)
@@ -219,21 +219,23 @@ struct miscdevice obd_psdev = {
 #if defined (CONFIG_PROC_FS)
 int obd_proc_version_seq_show(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "lustre: %s\nkernel: %s\nbuild:  %s\n",
-                       LUSTRE_VERSION_STRING, "patchless_client",
-                       BUILD_VERSION);
+       seq_printf(m, "lustre: %s\nkernel: %s\nbuild:  %s\n",
+                  LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(obd_proc_version);
 
 int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "%s\n", "on");
+       seq_printf(m, "%s\n", "on");
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(obd_proc_pinger);
 
 static int obd_proc_health_seq_show(struct seq_file *m, void *v)
 {
-       int rc = 0, i;
+       bool healthy = true;
+       int i;
 
        if (libcfs_catastrophe)
                seq_printf(m, "LBUG\n");
@@ -255,25 +257,27 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
 
                if (obd_health_check(NULL, obd)) {
                        seq_printf(m, "device %s reported unhealthy\n",
-                                     obd->obd_name);
-                       rc++;
+                                  obd->obd_name);
+                       healthy = false;
                }
                class_decref(obd, __func__, current);
                read_lock(&obd_dev_lock);
        }
        read_unlock(&obd_dev_lock);
 
-       if (rc == 0)
-               return seq_printf(m, "healthy\n");
+       if (healthy)
+               seq_puts(m, "healthy\n");
+       else
+               seq_puts(m, "NOT HEALTHY\n");
 
-       seq_printf(m, "NOT HEALTHY\n");
        return 0;
 }
 LPROC_SEQ_FOPS_RO(obd_proc_health);
 
 static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "%s\n", obd_jobid_var);
+       seq_printf(m, "%s\n", obd_jobid_var);
+       return 0;
 }
 
 static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
@@ -299,7 +303,8 @@ LPROC_SEQ_FOPS(obd_proc_jobid_var);
 
 static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "%s\n", obd_jobid_var);
+       seq_printf(m, "%s\n", obd_jobid_var);
+       return 0;
 }
 
 static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
@@ -378,10 +383,11 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v)
        else
                status = "--";
 
-       return seq_printf(p, "%3d %s %s %s %s %d\n",
-                         (int)index, status, obd->obd_type->typ_name,
-                         obd->obd_name, obd->obd_uuid.uuid,
-                         atomic_read(&obd->obd_refcount));
+       seq_printf(p, "%3d %s %s %s %s %d\n",
+                  (int)index, status, obd->obd_type->typ_name,
+                  obd->obd_name, obd->obd_uuid.uuid,
+                  atomic_read(&obd->obd_refcount));
+       return 0;
 }
 
 struct seq_operations obd_device_list_sops = {
index dd46e73581608bc6a73cdb4314dd2a79fb55f02e..4b62d25764ad79423979c7f52add70580c49a627 100644 (file)
@@ -79,6 +79,7 @@ enum {
 };
 
 
+#ifdef CONFIG_SYSCTL
 static int proc_set_timeout(struct ctl_table *table, int write,
                        void __user *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -205,7 +206,7 @@ static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
                        CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n",
                               obd_max_dirty_pages,
                               ((totalram_pages / 10) * 9));
-                       obd_max_dirty_pages = ((totalram_pages / 10) * 9);
+                       obd_max_dirty_pages = (totalram_pages / 10) * 9;
                } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
                        obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
                }
@@ -258,7 +259,6 @@ static int proc_alloc_fail_rate(struct ctl_table *table, int write,
        return rc;
 }
 
-#ifdef CONFIG_SYSCTL
 static struct ctl_table obd_table[] = {
        {
                .procname = "timeout",
index 4b850fc5f5d9aeb1dab4fb921ef4d65928e1c858..08afdf332531640e8d4a704d505e43c877bad920 100644 (file)
@@ -526,8 +526,9 @@ int llog_cat_cancel_records(const struct lu_env *env,
 }
 EXPORT_SYMBOL(llog_cat_cancel_records);
 
-int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh,
-                       struct llog_rec_hdr *rec, void *data)
+static int llog_cat_process_cb(const struct lu_env *env,
+                              struct llog_handle *cat_llh,
+                              struct llog_rec_hdr *rec, void *data)
 {
        struct llog_process_data *d = data;
        struct llog_logid_rec *lir = (struct llog_logid_rec *)rec;
index ddab94d7ee82649cf2764e6a66fa4b0b5f07523c..c171c6c6c457cda82fedc82c29880ae3e0618dcd 100644 (file)
@@ -223,7 +223,7 @@ EXPORT_SYMBOL(lprocfs_write_frac_helper);
 
 #if defined (CONFIG_PROC_FS)
 
-static int lprocfs_no_percpu_stats = 0;
+static int lprocfs_no_percpu_stats;
 module_param(lprocfs_no_percpu_stats, int, 0644);
 MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
 
@@ -377,7 +377,8 @@ EXPORT_SYMBOL(lprocfs_register);
 /* Generic callbacks */
 int lprocfs_rd_uint(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%u\n", *(unsigned int *)data);
+       seq_printf(m, "%u\n", *(unsigned int *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uint);
 
@@ -403,7 +404,8 @@ EXPORT_SYMBOL(lprocfs_wr_uint);
 
 int lprocfs_rd_u64(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%llu\n", *(__u64 *)data);
+       seq_printf(m, "%llu\n", *(__u64 *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_u64);
 
@@ -411,7 +413,8 @@ int lprocfs_rd_atomic(struct seq_file *m, void *data)
 {
        atomic_t *atom = data;
        LASSERT(atom != NULL);
-       return seq_printf(m, "%d\n", atomic_read(atom));
+       seq_printf(m, "%d\n", atomic_read(atom));
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_atomic);
 
@@ -439,7 +442,8 @@ int lprocfs_rd_uuid(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uuid);
 
@@ -448,7 +452,8 @@ int lprocfs_rd_name(struct seq_file *m, void *data)
        struct obd_device *dev = data;
 
        LASSERT(dev != NULL);
-       return seq_printf(m, "%s\n", dev->obd_name);
+       seq_printf(m, "%s\n", dev->obd_name);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_name);
 
@@ -460,7 +465,8 @@ int lprocfs_rd_blksize(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%u\n", osfs.os_bsize);
+               seq_printf(m, "%u\n", osfs.os_bsize);
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_blksize);
@@ -479,8 +485,9 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
@@ -499,8 +506,9 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
@@ -519,8 +527,9 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
@@ -533,7 +542,7 @@ int lprocfs_rd_filestotal(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%llu\n", osfs.os_files);
+               seq_printf(m, "%llu\n", osfs.os_files);
 
        return rc;
 }
@@ -547,7 +556,8 @@ int lprocfs_rd_filesfree(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%llu\n", osfs.os_ffree);
+               seq_printf(m, "%llu\n", osfs.os_ffree);
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_filesfree);
@@ -557,17 +567,18 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
        struct obd_device *obd = data;
        struct obd_import *imp;
        char *imp_state_name = NULL;
-       int rc = 0;
 
        LASSERT(obd != NULL);
        LPROCFS_CLIMP_CHECK(obd);
        imp = obd->u.cli.cl_import;
        imp_state_name = ptlrpc_import_state_name(imp->imp_state);
-       rc = seq_printf(m, "%s\t%s%s\n", obd2cli_tgt(obd), imp_state_name,
-                       imp->imp_deactive ? "\tDEACTIVATED" : "");
+       seq_printf(m, "%s\t%s%s\n",
+                  obd2cli_tgt(obd), imp_state_name,
+                  imp->imp_deactive ? "\tDEACTIVATED" : "");
 
        LPROCFS_CLIMP_EXIT(obd);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_server_uuid);
 
@@ -575,19 +586,19 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
 {
        struct obd_device *obd = data;
        struct ptlrpc_connection *conn;
-       int rc = 0;
 
        LASSERT(obd != NULL);
 
        LPROCFS_CLIMP_CHECK(obd);
        conn = obd->u.cli.cl_import->imp_connection;
        if (conn && obd->u.cli.cl_import)
-               rc = seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
+               seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
        else
-               rc = seq_printf(m, "%s\n", "<none>");
+               seq_puts(m, "<none>\n");
 
        LPROCFS_CLIMP_EXIT(obd);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_conn_uuid);
 
@@ -924,7 +935,8 @@ int lprocfs_rd_num_exports(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%u\n", obd->obd_num_exports);
+       seq_printf(m, "%u\n", obd->obd_num_exports);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_num_exports);
 
@@ -933,7 +945,8 @@ int lprocfs_rd_numrefs(struct seq_file *m, void *data)
        struct obd_type *class = (struct obd_type *) data;
 
        LASSERT(class != NULL);
-       return seq_printf(m, "%d\n", class->typ_refcnt);
+       seq_printf(m, "%d\n", class->typ_refcnt);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_numrefs);
 
@@ -1200,41 +1213,33 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
        struct lprocfs_counter_header   *hdr;
        struct lprocfs_counter           ctr;
        int                              idx    = *(loff_t *)v;
-       int                              rc     = 0;
 
        if (idx == 0) {
                struct timeval now;
                do_gettimeofday(&now);
-               rc = seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
-                               "snapshot_time", now.tv_sec, (unsigned long)now.tv_usec);
-               if (rc < 0)
-                       return rc;
+               seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
+                          "snapshot_time",
+                          now.tv_sec, (unsigned long)now.tv_usec);
        }
+
        hdr = &stats->ls_cnt_header[idx];
        lprocfs_stats_collect(stats, idx, &ctr);
 
-       if (ctr.lc_count == 0)
-               goto out;
-
-       rc = seq_printf(p, "%-25s %lld samples [%s]", hdr->lc_name,
-                       ctr.lc_count, hdr->lc_units);
+       if (ctr.lc_count != 0) {
+               seq_printf(p, "%-25s %lld samples [%s]",
+                          hdr->lc_name, ctr.lc_count, hdr->lc_units);
 
-       if (rc < 0)
-               goto out;
-
-       if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ctr.lc_count > 0)) {
-               rc = seq_printf(p, " %lld %lld %lld",
-                               ctr.lc_min, ctr.lc_max, ctr.lc_sum);
-               if (rc < 0)
-                       goto out;
-               if (hdr->lc_config & LPROCFS_CNTR_STDDEV)
-                       rc = seq_printf(p, " %lld", ctr.lc_sumsquare);
-               if (rc < 0)
-                       goto out;
+               if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) &&
+                   (ctr.lc_count > 0)) {
+                       seq_printf(p, " %lld %lld %lld",
+                                  ctr.lc_min, ctr.lc_max, ctr.lc_sum);
+                       if (hdr->lc_config & LPROCFS_CNTR_STDDEV)
+                               seq_printf(p, " %lld", ctr.lc_sumsquare);
+               }
+               seq_putc(p, '\n');
        }
-       rc = seq_printf(p, "\n");
-out:
-       return (rc < 0) ? rc : 0;
+
+       return 0;
 }
 
 static const struct seq_operations lprocfs_stats_seq_sops = {
@@ -1606,8 +1611,9 @@ LPROC_SEQ_FOPS_RO(lproc_exp_hash);
 
 int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%s\n",
-                         "Write into this file to clear all nid stats and stale nid entries");
+       seq_printf(m, "%s\n",
+                  "Write into this file to clear all nid stats and stale nid entries");
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
 
@@ -2041,12 +2047,12 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data)
 {
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
+       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc);
 
index 83bf168c2939f0bd6bd4d6f21c8f520e78a54ac1..20c0779951fd7c7db9d21513eb5e5ebb820ecb2c 100644 (file)
@@ -1308,7 +1308,7 @@ static DEFINE_SPINLOCK(lu_keys_guard);
  * lu_context_refill(). No locking is provided, as initialization and shutdown
  * are supposed to be externally serialized.
  */
-static unsigned key_set_version = 0;
+static unsigned key_set_version;
 
 /**
  * Register new key.
@@ -1769,8 +1769,6 @@ EXPORT_SYMBOL(lu_env_refill);
 int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags,
                          __u32 stags)
 {
-       int    result;
-
        if ((env->le_ctx.lc_tags & ctags) != ctags) {
                env->le_ctx.lc_version = 0;
                env->le_ctx.lc_tags |= ctags;
@@ -1781,9 +1779,7 @@ int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags,
                env->le_ses->lc_tags |= stags;
        }
 
-       result = lu_env_refill(env);
-
-       return result;
+       return lu_env_refill(env);
 }
 EXPORT_SYMBOL(lu_env_refill_by_tags);
 
@@ -2014,18 +2010,19 @@ int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
        memset(&stats, 0, sizeof(stats));
        lu_site_stats_get(s->ls_obj_hash, &stats, 1);
 
-       return seq_printf(m, "%d/%d %d/%d %d %d %d %d %d %d %d\n",
-                       stats.lss_busy,
-                       stats.lss_total,
-                       stats.lss_populated,
-                       CFS_HASH_NHLIST(s->ls_obj_hash),
-                       stats.lss_max_search,
-                       ls_stats_read(s->ls_stats, LU_SS_CREATED),
-                       ls_stats_read(s->ls_stats, LU_SS_CACHE_HIT),
-                       ls_stats_read(s->ls_stats, LU_SS_CACHE_MISS),
-                       ls_stats_read(s->ls_stats, LU_SS_CACHE_RACE),
-                       ls_stats_read(s->ls_stats, LU_SS_CACHE_DEATH_RACE),
-                       ls_stats_read(s->ls_stats, LU_SS_LRU_PURGED));
+       seq_printf(m, "%d/%d %d/%d %d %d %d %d %d %d %d\n",
+                  stats.lss_busy,
+                  stats.lss_total,
+                  stats.lss_populated,
+                  CFS_HASH_NHLIST(s->ls_obj_hash),
+                  stats.lss_max_search,
+                  ls_stats_read(s->ls_stats, LU_SS_CREATED),
+                  ls_stats_read(s->ls_stats, LU_SS_CACHE_HIT),
+                  ls_stats_read(s->ls_stats, LU_SS_CACHE_MISS),
+                  ls_stats_read(s->ls_stats, LU_SS_CACHE_RACE),
+                  ls_stats_read(s->ls_stats, LU_SS_CACHE_DEATH_RACE),
+                  ls_stats_read(s->ls_stats, LU_SS_LRU_PURGED));
+       return 0;
 }
 EXPORT_SYMBOL(lu_site_stats_print);
 
index 3c0c9109cefd31ffd6946977cbfc2933272cdc3d..3a74041483086a7f985936a9f8b3063840714aa7 100644 (file)
@@ -645,10 +645,10 @@ int lustre_put_lsi(struct super_block *sb)
 }
 
 /*** SERVER NAME ***
- * <FSNAME><SEPERATOR><TYPE><INDEX>
+ * <FSNAME><SEPARATOR><TYPE><INDEX>
  * FSNAME is between 1 and 8 characters (inclusive).
  *     Excluded characters are '/' and ':'
- * SEPERATOR is either ':' or '-'
+ * SEPARATOR is either ':' or '-'
  * TYPE: "OST", "MDT", etc.
  * INDEX: Hex representation of the index
  */
index 5f6d9441bc4435698e17efad3d3aa78a26c7213d..d542e06d6cd38ef8cb394a4758038d77721fb5b7 100644 (file)
@@ -146,6 +146,7 @@ static struct lu_context_key echo_thread_key;
 static inline struct echo_thread_info *echo_env_info(const struct lu_env *env)
 {
        struct echo_thread_info *info;
+
        info = lu_context_key_get(&env->le_ctx, &echo_thread_key);
        LASSERT(info != NULL);
        return info;
@@ -195,22 +196,22 @@ static struct lu_kmem_descr echo_caches[] = {
        {
                .ckd_cache = &echo_lock_kmem,
                .ckd_name  = "echo_lock_kmem",
-               .ckd_size  = sizeof (struct echo_lock)
+               .ckd_size  = sizeof(struct echo_lock)
        },
        {
                .ckd_cache = &echo_object_kmem,
                .ckd_name  = "echo_object_kmem",
-               .ckd_size  = sizeof (struct echo_object)
+               .ckd_size  = sizeof(struct echo_object)
        },
        {
                .ckd_cache = &echo_thread_kmem,
                .ckd_name  = "echo_thread_kmem",
-               .ckd_size  = sizeof (struct echo_thread_info)
+               .ckd_size  = sizeof(struct echo_thread_info)
        },
        {
                .ckd_cache = &echo_session_kmem,
                .ckd_name  = "echo_session_kmem",
-               .ckd_size  = sizeof (struct echo_session_info)
+               .ckd_size  = sizeof(struct echo_session_info)
        },
        {
                .ckd_cache = NULL
@@ -637,6 +638,7 @@ static void echo_thread_key_fini(const struct lu_context *ctx,
                         struct lu_context_key *key, void *data)
 {
        struct echo_thread_info *info = data;
+
        OBD_SLAB_FREE_PTR(info, echo_thread_kmem);
 }
 
@@ -667,6 +669,7 @@ static void echo_session_key_fini(const struct lu_context *ctx,
                                 struct lu_context_key *key, void *data)
 {
        struct echo_session_info *session = data;
+
        OBD_SLAB_FREE_PTR(session, echo_session_kmem);
 }
 
@@ -783,6 +786,7 @@ out:
        switch (cleanup) {
        case 4: {
                int rc2;
+
                rc2 = echo_client_cleanup(obd);
                if (rc2)
                        CERROR("Cleanup obd device %s error(%d)\n",
@@ -958,11 +962,13 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d,
        if (d->ed_next) {
                if (!d->ed_next_islov) {
                        struct lov_oinfo *oinfo = lsm->lsm_oinfo[0];
+
                        LASSERT(oinfo != NULL);
                        oinfo->loi_oi = lsm->lsm_oi;
                        conf->eoc_cl.u.coc_oinfo = oinfo;
                } else {
                        struct lustre_md *md;
+
                        md = &info->eti_md;
                        memset(md, 0, sizeof(*md));
                        md->lsm = lsm;
@@ -1011,6 +1017,7 @@ static int cl_echo_object_put(struct echo_object *eco)
        /* an external function to kill an object? */
        if (eco->eo_deleted) {
                struct lu_object_header *loh = obj->co_lu.lo_header;
+
                LASSERT(&eco->eo_hdr == luh2coh(loh));
                set_bit(LU_OBJECT_HEARD_BANSHEE, &loh->loh_flags);
        }
@@ -1022,7 +1029,7 @@ static int cl_echo_object_put(struct echo_object *eco)
 
 static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco,
                            u64 start, u64 end, int mode,
-                           __u64 *cookie , __u32 enqflags)
+                           __u64 *cookie, __u32 enqflags)
 {
        struct cl_io *io;
        struct cl_lock *lck;
@@ -1106,8 +1113,8 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
 
        LASSERT(ec != NULL);
        spin_lock(&ec->ec_lock);
-       list_for_each (el, &ec->ec_locks) {
-               ecl = list_entry (el, struct echo_lock, el_chain);
+       list_for_each(el, &ec->ec_locks) {
+               ecl = list_entry(el, struct echo_lock, el_chain);
                CDEBUG(D_INFO, "ecl: %p, cookie: %#llx\n", ecl, ecl->el_cookie);
                found = (ecl->el_cookie == cookie);
                if (found) {
@@ -1152,6 +1159,7 @@ static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io,
 
        cl_page_list_for_each_safe(clp, temp, &queue->c2_qin) {
                int rc;
+
                rc = cl_page_cache_add(env, io, clp, CRT_WRITE);
                if (rc == 0)
                        continue;
@@ -1257,20 +1265,20 @@ out:
 static u64 last_object_id;
 
 static int
-echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
+echo_copyout_lsm(struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
 {
        struct lov_stripe_md *ulsm = _ulsm;
        int nob, i;
 
-       nob = offsetof (struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]);
+       nob = offsetof(struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]);
        if (nob > ulsm_nob)
                return -EINVAL;
 
-       if (copy_to_user (ulsm, lsm, sizeof(*ulsm)))
+       if (copy_to_user(ulsm, lsm, sizeof(*ulsm)))
                return -EFAULT;
 
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               if (copy_to_user (ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i],
+               if (copy_to_user(ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i],
                                      sizeof(lsm->lsm_oinfo[0])))
                        return -EFAULT;
        }
@@ -1278,16 +1286,16 @@ echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
 }
 
 static int
-echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm,
+echo_copyin_lsm(struct echo_device *ed, struct lov_stripe_md *lsm,
                 void *ulsm, int ulsm_nob)
 {
        struct echo_client_obd *ec = ed->ed_ec;
        int                  i;
 
-       if (ulsm_nob < sizeof (*lsm))
+       if (ulsm_nob < sizeof(*lsm))
                return -EINVAL;
 
-       if (copy_from_user (lsm, ulsm, sizeof (*lsm)))
+       if (copy_from_user(lsm, ulsm, sizeof(*lsm)))
                return -EFAULT;
 
        if (lsm->lsm_stripe_count > ec->ec_nstripes ||
@@ -1320,7 +1328,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
        if ((oa->o_valid & OBD_MD_FLID) == 0 && /* no obj id */
            (on_target ||                      /* set_stripe */
             ec->ec_nstripes != 0)) {      /* LOV */
-               CERROR ("No valid oid\n");
+               CERROR("No valid oid\n");
                return -EINVAL;
        }
 
@@ -1333,7 +1341,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
        if (ulsm != NULL) {
                int i, idx;
 
-               rc = echo_copyin_lsm (ed, lsm, ulsm, ulsm_nob);
+               rc = echo_copyin_lsm(ed, lsm, ulsm, ulsm_nob);
                if (rc != 0)
                        goto failed;
 
@@ -1409,7 +1417,7 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed,
 
        if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) {
                /* disallow use of object id 0 */
-               CERROR ("No valid oid\n");
+               CERROR("No valid oid\n");
                return -EINVAL;
        }
 
@@ -1459,7 +1467,7 @@ echo_get_stripe_off_id(struct lov_stripe_md *lsm, u64 *offp, u64 *idp)
        width = stripe_size * stripe_count;
 
        /* woffset = offset within a width; offset = whole number of widths */
-       woffset = do_div (offset, width);
+       woffset = do_div(offset, width);
 
        stripe_index = woffset / stripe_size;
 
@@ -1517,13 +1525,13 @@ static int echo_client_page_debug_check(struct lov_stripe_md *lsm,
        for (rc = delta = 0; delta < PAGE_CACHE_SIZE; delta += OBD_ECHO_BLOCK_SIZE) {
                stripe_off = offset + delta;
                stripe_id = id;
-               echo_get_stripe_off_id (lsm, &stripe_off, &stripe_id);
+               echo_get_stripe_off_id(lsm, &stripe_off, &stripe_id);
 
                rc2 = block_debug_check("test_brw",
                                        addr + delta, OBD_ECHO_BLOCK_SIZE,
                                        stripe_off, stripe_id);
                if (rc2 != 0) {
-                       CERROR ("Error in echo object %#llx\n", id);
+                       CERROR("Error in echo object %#llx\n", id);
                        rc = rc2;
                }
        }
@@ -1583,7 +1591,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
             i < npages;
             i++, pgp++, off += PAGE_CACHE_SIZE) {
 
-               LASSERT (pgp->pg == NULL);      /* for cleanup */
+               LASSERT(pgp->pg == NULL);      /* for cleanup */
 
                rc = -ENOMEM;
                OBD_PAGE_ALLOC(pgp->pg, gfp_mask);
@@ -1615,6 +1623,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
 
                if (verify) {
                        int vrc;
+
                        vrc = echo_client_page_debug_check(lsm, pgp->pg,
                                                           ostid_id(&oa->o_oi),
                                                           pgp->off, pgp->count);
@@ -1812,7 +1821,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa,
            (nob & (~CFS_PAGE_MASK)) != 0)
                return -EINVAL;
 
-       rc = echo_get_object (&eco, ed, oa);
+       rc = echo_get_object(&eco, ed, oa);
        if (rc != 0)
                return rc;
 
@@ -1911,6 +1920,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                rc = echo_get_object(&eco, ed, oa);
                if (rc == 0) {
                        struct obd_info oinfo = { { { 0 } } };
+
                        oinfo.oi_md = eco->eo_lsm;
                        oinfo.oi_oa = oa;
                        rc = obd_getattr(env, ec->ec_exp, &oinfo);
@@ -1927,6 +1937,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                rc = echo_get_object(&eco, ed, oa);
                if (rc == 0) {
                        struct obd_info oinfo = { { { 0 } } };
+
                        oinfo.oi_oa = oa;
                        oinfo.oi_md = eco->eo_lsm;
 
@@ -1992,7 +2003,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                goto out;
 
        default:
-               CERROR ("echo_ioctl(): unrecognised ioctl %#x\n", cmd);
+               CERROR("echo_ioctl(): unrecognised ioctl %#x\n", cmd);
                rc = -ENOTTY;
                goto out;
        }
@@ -2034,8 +2045,8 @@ static int echo_client_setup(const struct lu_env *env,
        }
 
        spin_lock_init(&ec->ec_lock);
-       INIT_LIST_HEAD (&ec->ec_objects);
-       INIT_LIST_HEAD (&ec->ec_locks);
+       INIT_LIST_HEAD(&ec->ec_objects);
+       INIT_LIST_HEAD(&ec->ec_locks);
        ec->ec_unique = 0;
        ec->ec_nstripes = 0;
 
@@ -2158,7 +2169,6 @@ void echo_client_exit(void)
 static int __init obdecho_init(void)
 {
        struct lprocfs_static_vars lvars;
-       int rc;
 
        LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
 
@@ -2167,9 +2177,7 @@ static int __init obdecho_init(void)
        lprocfs_echo_init_vars(&lvars);
 
 
-       rc = echo_client_init();
-
-       return rc;
+       return echo_client_init();
 }
 
 static void /*__exit*/ obdecho_exit(void)
index 1d3bf6c931297aef5bd905adc54525558ab3f91b..0beb97db7c7d9d377bee945139eccc242bd9bc52 100644 (file)
@@ -36,7 +36,7 @@
 #include "../include/lprocfs_status.h"
 #include "../include/obd_class.h"
 
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
 static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
        { "uuid",        &echo_uuid_fops,       NULL, 0 },
index 1795d3a7a02954d28a5de04e8e9c220a4045a75f..15a66209831c56b38beb5b3393b8c32f2b0c4e87 100644 (file)
@@ -35,7 +35,7 @@
  */
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include <asm/statfs.h>
+#include <linux/statfs.h>
 #include "../include/obd_cksum.h"
 #include "../include/obd_class.h"
 #include "../include/lprocfs_status.h"
 static int osc_active_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
-       int rc;
 
        LPROCFS_CLIMP_CHECK(dev);
-       rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
+       seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
        LPROCFS_CLIMP_EXIT(dev);
-       return rc;
+
+       return 0;
 }
 
 static ssize_t osc_active_seq_write(struct file *file,
@@ -80,12 +80,12 @@ static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+       seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 
 static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
@@ -164,16 +164,15 @@ static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
        int shift = 20 - PAGE_CACHE_SHIFT;
-       int rc;
 
-       rc = seq_printf(m,
-                     "used_mb: %d\n"
-                     "busy_cnt: %d\n",
-                     (atomic_read(&cli->cl_lru_in_list) +
-                       atomic_read(&cli->cl_lru_busy)) >> shift,
-                     atomic_read(&cli->cl_lru_busy));
+       seq_printf(m,
+                  "used_mb: %d\n"
+                  "busy_cnt: %d\n",
+                  (atomic_read(&cli->cl_lru_in_list) +
+                   atomic_read(&cli->cl_lru_busy)) >> shift,
+                  atomic_read(&cli->cl_lru_busy));
 
-       return rc;
+       return 0;
 }
 
 /* shrink the number of caching pages to a specific number */
@@ -215,12 +214,12 @@ static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%lu\n", cli->cl_dirty);
+       seq_printf(m, "%lu\n", cli->cl_dirty);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
 
@@ -228,12 +227,12 @@ static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%lu\n", cli->cl_avail_grant);
+       seq_printf(m, "%lu\n", cli->cl_avail_grant);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 
 static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
@@ -274,12 +273,12 @@ static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *dev = m->private;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%lu\n", cli->cl_lost_grant);
+       seq_printf(m, "%lu\n", cli->cl_lost_grant);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
 
@@ -289,8 +288,8 @@ static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
 
        if (obd == NULL)
                return 0;
-       return seq_printf(m, "%d\n",
-                       obd->u.cli.cl_grant_shrink_interval);
+       seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval);
+       return 0;
 }
 
 static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
@@ -323,8 +322,8 @@ static int osc_checksum_seq_show(struct seq_file *m, void *v)
        if (obd == NULL)
                return 0;
 
-       return seq_printf(m, "%d\n",
-                       obd->u.cli.cl_checksum ? 1 : 0);
+       seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
+       return 0;
 }
 
 static ssize_t osc_checksum_seq_write(struct file *file,
@@ -405,7 +404,8 @@ static int osc_resend_count_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *obd = m->private;
 
-       return seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
+       seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
+       return 0;
 }
 
 static ssize_t osc_resend_count_seq_write(struct file *file,
@@ -433,7 +433,8 @@ static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
        struct obd_device *obd = m->private;
        struct osc_device *od  = obd2osc_dev(obd);
 
-       return seq_printf(m, "%u\n", od->od_contention_time);
+       seq_printf(m, "%u\n", od->od_contention_time);
+       return 0;
 }
 
 static ssize_t osc_contention_seconds_seq_write(struct file *file,
@@ -453,7 +454,8 @@ static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
        struct obd_device *obd = m->private;
        struct osc_device *od  = obd2osc_dev(obd);
 
-       return seq_printf(m, "%u\n", od->od_lockless_truncate);
+       seq_printf(m, "%u\n", od->od_lockless_truncate);
+       return 0;
 }
 
 static ssize_t osc_lockless_truncate_seq_write(struct file *file,
@@ -471,8 +473,9 @@ LPROC_SEQ_FOPS(osc_lockless_truncate);
 static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
 {
        struct obd_device *obd = m->private;
-       return seq_printf(m, "%u\n",
-                       atomic_read(&obd->u.cli.cl_destroy_in_flight));
+
+       seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight));
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
 
index fad4c135f9284dda5bf7ad744fa9d86b0b2a2b93..3c7300b0651dbf94788b2de1e68458e8abd9908e 100644 (file)
@@ -417,7 +417,7 @@ static int osc_io_setattr_start(const struct lu_env *env,
 
                        if (ia_valid & ATTR_SIZE) {
                                attr->cat_size = attr->cat_kms = size;
-                               cl_valid = (CAT_SIZE | CAT_KMS);
+                               cl_valid = CAT_SIZE | CAT_KMS;
                        }
                        if (ia_valid & ATTR_MTIME_SET) {
                                attr->cat_mtime = lvb->lvb_mtime;
index 445655724904648aa90dcdf26f68a54b0aaabb8b..350ad49550ab308b9628d437be81e616bbae68ca 100644 (file)
@@ -1010,7 +1010,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env,
        struct cl_lock_descr    *descr   = &lock->cll_descr;
        struct cl_object_header *hdr     = cl_object_header(descr->cld_obj);
        struct cl_lock    *scan;
-       struct cl_lock    *conflict= NULL;
+       struct cl_lock    *conflict = NULL;
        int lockless                 = osc_lock_is_lockless(olck);
        int rc                     = 0;
 
index 0adfa707a76333364942f97cb835c74f649cf1e4..5e27e0a9b0a19e3e255d4820853fb4fe0f3d8311 100644 (file)
@@ -1165,8 +1165,8 @@ static int check_write_rcs(struct ptlrpc_request *req,
 static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
 {
        if (p1->flag != p2->flag) {
-               unsigned mask = ~(OBD_BRW_FROM_GRANT| OBD_BRW_NOCACHE|
-                                 OBD_BRW_SYNC|OBD_BRW_ASYNC|OBD_BRW_NOQUOTA);
+               unsigned mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_NOCACHE |
+                                 OBD_BRW_SYNC | OBD_BRW_ASYNC|OBD_BRW_NOQUOTA);
 
                /* warn if we try to combine flags that we don't know to be
                 * safe to combine */
index 4882dd0a448378fdadf536ef0edd3b2afc5d8a84..0fe6a641092bbcf374484a5069bf8a46fde1ba37 100644 (file)
@@ -468,7 +468,6 @@ void ptlrpc_add_rqs_to_pool(struct ptlrpc_request_pool *pool, int num_rq)
                list_add_tail(&req->rq_list, &pool->prp_req_list);
        }
        spin_unlock(&pool->prp_lock);
-       return;
 }
 EXPORT_SYMBOL(ptlrpc_add_rqs_to_pool);
 
@@ -1439,12 +1438,11 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
                if (req->rq_err) {
                        req->rq_status = rc;
                        return 1;
-               } else {
-                       spin_lock(&req->rq_lock);
-                       req->rq_wait_ctx = 1;
-                       spin_unlock(&req->rq_lock);
-                       return 0;
                }
+               spin_lock(&req->rq_lock);
+               req->rq_wait_ctx = 1;
+               spin_unlock(&req->rq_lock);
+               return 0;
        }
 
        CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:nid:opc %s:%s:%d:%llu:%s:%d\n",
@@ -2192,7 +2190,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
        if (set->set_interpret != NULL) {
                int (*interpreter)(struct ptlrpc_request_set *set, void *, int) =
                        set->set_interpret;
-               rc = interpreter (set, set->set_arg, rc);
+               rc = interpreter(set, set->set_arg, rc);
        } else {
                struct ptlrpc_set_cbdata *cbdata, *n;
                int err;
index 2a875ab579118100cbf6637fd0b0e3d02b91123d..7e27397ce384c258976d53bed4e84a1c39801234 100644 (file)
@@ -184,6 +184,7 @@ static void *
 conn_key(struct hlist_node *hnode)
 {
        struct ptlrpc_connection *conn;
+
        conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
        return &conn->c_peer;
 }
index bbef666b1d167b1f3dfce82e38490faa6304ea11..a42335e26de908de88dd0438fc4cbc69ad255925 100644 (file)
@@ -811,8 +811,8 @@ struct req_capsule;
        .rmf_name    = (name),                            \
        .rmf_flags   = (flags),                          \
        .rmf_size    = (size),                            \
-       .rmf_swabber = (void (*)(void*))(swabber),            \
-       .rmf_dumper  = (void (*)(void*))(dumper)                \
+       .rmf_swabber = (void (*)(void *))(swabber),           \
+       .rmf_dumper  = (void (*)(void *))(dumper)               \
 }
 
 struct req_msg_field RMF_GENERIC_DATA =
@@ -1839,7 +1839,7 @@ static int __req_capsule_offset(const struct req_capsule *pill,
        LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n",
                            pill->rc_fmt->rf_name,
                            field->rmf_name, offset, loc);
-       offset --;
+       offset--;
 
        LASSERT(0 <= offset && offset < REQ_MAX_FIELD_NR);
        return offset;
index 0e2071b8a36e97c09353bff50802ac196fd35d2f..9533ab976a33a21c23ec43e26f77420939b87fac 100644 (file)
@@ -181,7 +181,7 @@ static const char *ll_eopcode2str(__u32 opcode)
        return ll_eopcode_table[opcode].opname;
 }
 
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
                                    char *name,
                                    struct proc_dir_entry **procroot_ret,
@@ -267,7 +267,8 @@ ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v)
        ptlrpc_service_for_each_part(svcpt, i, svc)
                total += svcpt->scp_hist_nrqbds;
 
-       return seq_printf(m, "%d\n", total);
+       seq_printf(m, "%d\n", total);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len);
 
@@ -282,7 +283,8 @@ ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
        ptlrpc_service_for_each_part(svcpt, i, svc)
                total += svc->srv_hist_nrqbds_cpt_max;
 
-       return seq_printf(m, "%d\n", total);
+       seq_printf(m, "%d\n", total);
+       return 0;
 }
 
 static ssize_t
@@ -327,8 +329,8 @@ ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n)
 {
        struct ptlrpc_service *svc = m->private;
 
-       return seq_printf(m, "%d\n",
-                       svc->srv_nthrs_cpt_init * svc->srv_ncpts);
+       seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
+       return 0;
 }
 
 static ssize_t
@@ -371,7 +373,8 @@ ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n)
        ptlrpc_service_for_each_part(svcpt, i, svc)
                total += svcpt->scp_nthrs_running;
 
-       return seq_printf(m, "%d\n", total);
+       seq_printf(m, "%d\n", total);
+       return 0;
 }
 LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started);
 
@@ -380,8 +383,8 @@ ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n)
 {
        struct ptlrpc_service *svc = m->private;
 
-       return seq_printf(m, "%d\n",
-                       svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
+       seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
+       return 0;
 }
 
 static ssize_t
@@ -1026,7 +1029,8 @@ LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
 static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v)
 {
        struct ptlrpc_service *svc = m->private;
-       return seq_printf(m, "%d", svc->srv_hpreq_ratio);
+       seq_printf(m, "%d", svc->srv_hpreq_ratio);
+       return 0;
 }
 
 static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
@@ -1083,7 +1087,7 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
                 .data       = svc},
                {NULL}
        };
-       static struct file_operations req_history_fops = {
+       static const struct file_operations req_history_fops = {
                .owner       = THIS_MODULE,
                .open   = ptlrpc_lprocfs_svc_req_history_open,
                .read   = seq_read,
@@ -1324,13 +1328,12 @@ int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
 {
        struct obd_device *obd = m->private;
        struct obd_import *imp = obd->u.cli.cl_import;
-       int rc;
 
        LPROCFS_CLIMP_CHECK(obd);
-       rc = seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
+       seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
        LPROCFS_CLIMP_EXIT(obd);
 
-       return rc;
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_pinger_recov);
 
index f715e9a8b996119f58183bc7e986cdca2abadbf3..2fa2585584a3d81b33341a4d7a4ed9c2d639a261 100644 (file)
@@ -383,12 +383,13 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
                       req->rq_export->exp_obd->obd_minor);
        }
 
-       /* In order to keep interoprability with the client (< 2.3) which
+       /* In order to keep interoperability with the client (< 2.3) which
         * doesn't have pb_jobid in ptlrpc_body, We have to shrink the
         * ptlrpc_body in reply buffer to ptlrpc_body_v2, otherwise, the
         * reply buffer on client will be overflow.
         *
-        * XXX Remove this whenever we drop the interoprability with such client.
+        * XXX Remove this whenever we drop the interoperability with
+        * such client.
         */
        req->rq_replen = lustre_shrink_msg(req->rq_repmsg, 0,
                                           sizeof(struct ptlrpc_body_v2), 1);
index d5fd7215c72f9dcc24d2e1210d8876937f817da4..81ad7473242eda90394aa7bc432fb6ab5574948c 100644 (file)
@@ -155,9 +155,8 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs)
 {
        struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary;
 
-       if (tmp == NULL) {
+       if (tmp == NULL)
                return;
-       }
 
        nrs->nrs_policy_primary = NULL;
 
@@ -912,7 +911,6 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs)
 static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs,
                                   struct ptlrpc_service_part *svcpt)
 {
-       int                             rc;
        enum ptlrpc_nrs_queue_type      queue;
 
        LASSERT(mutex_is_locked(&nrs_core.nrs_mutex));
@@ -930,9 +928,7 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs,
        INIT_LIST_HEAD(&nrs->nrs_policy_list);
        INIT_LIST_HEAD(&nrs->nrs_policy_queued);
 
-       rc = nrs_register_policies_locked(nrs);
-
-       return rc;
+       return nrs_register_policies_locked(nrs);
 }
 
 /**
index 2f45f765783040994c2271db210834092a02eeef..b51af9bf37b70cd5bdefa892875f3e21f504f620 100644 (file)
@@ -117,13 +117,13 @@ EXPORT_SYMBOL(lustre_msg_check_version);
 /* early reply size */
 int lustre_msg_early_size(void)
 {
-       static int size = 0;
+       static int size;
        if (!size) {
-               /* Always reply old ptlrpc_body_v2 to keep interoprability
+               /* Always reply old ptlrpc_body_v2 to keep interoperability
                 * with the old client (< 2.3) which doesn't have pb_jobid
                 * in the ptlrpc_body.
                 *
-                * XXX Remove this whenever we drop interoprability with such
+                * XXX Remove this whenever we drop interoperability with such
                 *     client.
                 */
                __u32 pblen = sizeof(struct ptlrpc_body_v2);
index 340d98a64137adc25291a7ae4242a4cbbd5836f9..9dbda9332dd828289c963cc49a64b8a07ac347c3 100644 (file)
@@ -545,7 +545,7 @@ void ptlrpc_pinger_wake_up(void)
 #define PET_READY     1
 #define PET_TERMINATE 2
 
-static int            pet_refcount = 0;
+static int pet_refcount;
 static int            pet_state;
 static wait_queue_head_t       pet_waitq;
 LIST_HEAD(pet_list);
index 7fe2e584ffd7d6c27667215c17be182a251da303..a66dc3c6da419d6fa80b06a19100a4bb83647557 100644 (file)
@@ -76,7 +76,7 @@ void ptlrpc_initiate_recovery(struct obd_import *imp);
 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
 
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
                                     struct ptlrpc_service *svc);
 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
@@ -263,7 +263,7 @@ void sptlrpc_enc_pool_fini(void);
 int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
 
 /* sec_lproc.c */
-#if defined (CONFIG_PROC_FS)
+#if defined(CONFIG_PROC_FS)
 int  sptlrpc_lproc_init(void);
 void sptlrpc_lproc_fini(void);
 #else
index 4621b71fe0b6bc971db94d2b32643faa09436f80..0c178ec0e48796756202b8acdd1188277b0dcf43 100644 (file)
@@ -85,7 +85,7 @@ MODULE_PARM_DESC(ptlrpcd_bind_policy, "Ptlrpcd threads binding mode.");
 static struct ptlrpcd *ptlrpcds;
 
 struct mutex ptlrpcd_mutex;
-static int ptlrpcd_users = 0;
+static int ptlrpcd_users;
 
 void ptlrpcd_wake(struct ptlrpc_request *req)
 {
@@ -511,10 +511,10 @@ static int ptlrpcd_bind(int index, int max)
 #if defined(CONFIG_NUMA)
        {
                int i;
-               mask = *cpumask_of_node(cpu_to_node(index));
+               cpumask_copy(&mask, cpumask_of_node(cpu_to_node(index)));
                for (i = max; i < num_online_cpus(); i++)
-                       cpu_clear(i, mask);
-               pc->pc_npartners = cpus_weight(mask) - 1;
+                       cpumask_clear_cpu(i, &mask);
+               pc->pc_npartners = cpumask_weight(&mask) - 1;
                set_bit(LIOD_BIND, &pc->pc_flags);
        }
 #else
@@ -554,7 +554,7 @@ static int ptlrpcd_bind(int index, int max)
                                 * that are already initialized
                                 */
                                for (pidx = 0, i = 0; i < index; i++) {
-                                       if (cpu_isset(i, mask)) {
+                                       if (cpumask_test_cpu(i, &mask)) {
                                                ppc = &ptlrpcds->pd_threads[i];
                                                pc->pc_partners[pidx++] = ppc;
                                                ppc->pc_partners[ppc->
index 0dabd83fd46ffbcf60a63ddf993c8e7936019420..c05a8554d737dcea467e945537299ce9a0ab4446 100644 (file)
@@ -125,52 +125,50 @@ static struct ptlrpc_enc_page_pool {
  */
 int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
 {
-       int     rc;
-
        spin_lock(&page_pools.epp_lock);
 
-       rc = seq_printf(m,
-                     "physical pages:    %lu\n"
-                     "pages per pool:    %lu\n"
-                     "max pages:              %lu\n"
-                     "max pools:              %u\n"
-                     "total pages:          %lu\n"
-                     "total free:            %lu\n"
-                     "idle index:            %lu/100\n"
-                     "last shrink:          %lds\n"
-                     "last access:          %lds\n"
-                     "max pages reached:       %lu\n"
-                     "grows:              %u\n"
-                     "grows failure:      %u\n"
-                     "shrinks:          %u\n"
-                     "cache access:        %lu\n"
-                     "cache missing:      %lu\n"
-                     "low free mark:      %lu\n"
-                     "max waitqueue depth:     %u\n"
-                     "max wait time:      "CFS_TIME_T"/%u\n"
-                     ,
-                     totalram_pages,
-                     PAGES_PER_POOL,
-                     page_pools.epp_max_pages,
-                     page_pools.epp_max_pools,
-                     page_pools.epp_total_pages,
-                     page_pools.epp_free_pages,
-                     page_pools.epp_idle_idx,
-                     get_seconds() - page_pools.epp_last_shrink,
-                     get_seconds() - page_pools.epp_last_access,
-                     page_pools.epp_st_max_pages,
-                     page_pools.epp_st_grows,
-                     page_pools.epp_st_grow_fails,
-                     page_pools.epp_st_shrinks,
-                     page_pools.epp_st_access,
-                     page_pools.epp_st_missings,
-                     page_pools.epp_st_lowfree,
-                     page_pools.epp_st_max_wqlen,
-                     page_pools.epp_st_max_wait, HZ
-                    );
+       seq_printf(m,
+                  "physical pages:       %lu\n"
+                  "pages per pool:       %lu\n"
+                  "max pages:         %lu\n"
+                  "max pools:         %u\n"
+                  "total pages:             %lu\n"
+                  "total free:       %lu\n"
+                  "idle index:       %lu/100\n"
+                  "last shrink:             %lds\n"
+                  "last access:             %lds\n"
+                  "max pages reached:       %lu\n"
+                  "grows:                 %u\n"
+                  "grows failure:         %u\n"
+                  "shrinks:             %u\n"
+                  "cache access:           %lu\n"
+                  "cache missing:         %lu\n"
+                  "low free mark:         %lu\n"
+                  "max waitqueue depth:     %u\n"
+                  "max wait time:         " CFS_TIME_T "/%u\n",
+                  totalram_pages,
+                  PAGES_PER_POOL,
+                  page_pools.epp_max_pages,
+                  page_pools.epp_max_pools,
+                  page_pools.epp_total_pages,
+                  page_pools.epp_free_pages,
+                  page_pools.epp_idle_idx,
+                  get_seconds() - page_pools.epp_last_shrink,
+                  get_seconds() - page_pools.epp_last_access,
+                  page_pools.epp_st_max_pages,
+                  page_pools.epp_st_grows,
+                  page_pools.epp_st_grow_fails,
+                  page_pools.epp_st_shrinks,
+                  page_pools.epp_st_access,
+                  page_pools.epp_st_missings,
+                  page_pools.epp_st_lowfree,
+                  page_pools.epp_st_max_wqlen,
+                  page_pools.epp_st_max_wait,
+                  HZ);
 
        spin_unlock(&page_pools.epp_lock);
-       return rc;
+
+       return 0;
 }
 
 static void enc_pools_release_free_pages(long npages)
@@ -365,8 +363,8 @@ static void enc_pools_insert(struct page ***pools, int npools, int npages)
         */
        cur_npools = (page_pools.epp_total_pages + PAGES_PER_POOL - 1) /
                     PAGES_PER_POOL;
-       end_npools = (page_pools.epp_total_pages + npages + PAGES_PER_POOL - 1) /
-                    PAGES_PER_POOL;
+       end_npools = (page_pools.epp_total_pages + npages + PAGES_PER_POOL - 1)
+                    PAGES_PER_POOL;
        LASSERT(end_npools <= page_pools.epp_max_pools);
 
        np_idx = 0;
@@ -816,9 +814,8 @@ int bulk_sec_desc_unpack(struct lustre_msg *msg, int offset, int swabbed)
                return -EINVAL;
        }
 
-       if (swabbed) {
+       if (swabbed)
                __swab32s(&bsd->bsd_nob);
-       }
 
        if (unlikely(bsd->bsd_version != 0)) {
                CERROR("Unexpected version %u\n", bsd->bsd_version);
index 635b12b22cef3623352810bae476fcfa4f0a4271..8e61421515cb689e205681257fe634f9baeb72bc 100644 (file)
@@ -543,7 +543,6 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
        if (tc->tc_thr_factor != 0) {
                int       factor = tc->tc_thr_factor;
                const int fade = 4;
-               cpumask_t mask;
 
                /*
                 * User wants to increase number of threads with for
@@ -557,8 +556,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
                 * have too many threads no matter how many cores/HTs
                 * there are.
                 */
-               cpumask_copy(&mask, topology_thread_cpumask(0));
-               if (cpus_weight(mask) > 1) { /* weight is # of HTs */
+               /* weight is # of HTs */
+               if (cpumask_weight(topology_thread_cpumask(0)) > 1) {
                        /* depress thread factor for hyper-thread */
                        factor = factor - (factor >> 1) + (factor >> 3);
                }
@@ -2752,7 +2751,6 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
 
 int ptlrpc_hr_init(void)
 {
-       cpumask_t                       mask;
        struct ptlrpc_hr_partition      *hrp;
        struct ptlrpc_hr_thread         *hrt;
        int                             rc;
@@ -2770,8 +2768,7 @@ int ptlrpc_hr_init(void)
 
        init_waitqueue_head(&ptlrpc_hr.hr_waitq);
 
-       cpumask_copy(&mask, topology_thread_cpumask(0));
-       weight = cpus_weight(mask);
+       weight = cpumask_weight(topology_thread_cpumask(0));
 
        cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
                hrp->hrp_cpt = i;
index 53825066791875d20f7b289cfaa56e1b79ba189d..f28ffef0d1f0caada0f02d5e2d6ed7ea07aea3bf 100644 (file)
@@ -1448,8 +1448,8 @@ static void bcm2048_parse_rds_pi(struct bcm2048_device *bdev)
                /* Block A match, only data without crc errors taken */
                if (bdev->rds_info.radio_text[i] == BCM2048_RDS_BLOCK_A) {
 
-                       pi = ((bdev->rds_info.radio_text[i+1] << 8) +
-                               bdev->rds_info.radio_text[i+2]);
+                       pi = (bdev->rds_info.radio_text[i+1] << 8) +
+                               bdev->rds_info.radio_text[i+2];
 
                        if (!bdev->rds_info.rds_pi) {
                                bdev->rds_info.rds_pi = pi;
@@ -1503,8 +1503,8 @@ static int bcm2048_parse_rt_match_b(struct bcm2048_device *bdev, int i)
        if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
                BCM2048_RDS_BLOCK_B) {
 
-               rt_id = (bdev->rds_info.radio_text[i+1] &
-                       BCM2048_RDS_BLOCK_MASK);
+               rt_id = bdev->rds_info.radio_text[i+1] &
+                       BCM2048_RDS_BLOCK_MASK;
                rt_group_b = bdev->rds_info.radio_text[i+1] &
                        BCM2048_RDS_GROUP_AB_MASK;
                rt_ab = bdev->rds_info.radio_text[i+2] &
@@ -1792,7 +1792,7 @@ static int bcm2048_get_rds_data(struct bcm2048_device *bdev, char *data)
                goto unlock;
        }
 
-       data_buffer = kzalloc(BCM2048_MAX_RDS_RADIO_TEXT*5, GFP_KERNEL);
+       data_buffer = kcalloc(BCM2048_MAX_RDS_RADIO_TEXT, 5, GFP_KERNEL);
        if (!data_buffer) {
                err = -ENOMEM;
                goto unlock;
@@ -2245,8 +2245,7 @@ static ssize_t bcm2048_fops_read(struct file *file, char __user *buf,
 
                tmpbuf[i] = bdev->rds_info.radio_text[bdev->rd_index+i+2];
                tmpbuf[i+1] = bdev->rds_info.radio_text[bdev->rd_index+i+1];
-               tmpbuf[i+2] = ((bdev->rds_info.radio_text[bdev->rd_index+i]
-                               & 0xf0) >> 4);
+               tmpbuf[i+2] = (bdev->rds_info.radio_text[bdev->rd_index + i] & 0xf0) >> 4;
                if ((bdev->rds_info.radio_text[bdev->rd_index+i] &
                        BCM2048_RDS_CRC_MASK) == BCM2048_RDS_CRC_UNRECOVARABLE)
                        tmpbuf[i+2] |= 0x80;
@@ -2718,22 +2717,7 @@ static struct i2c_driver bcm2048_i2c_driver = {
        .id_table       = bcm2048_id,
 };
 
-/*
- *     Module Interface
- */
-static int __init bcm2048_module_init(void)
-{
-       pr_info(BCM2048_DRIVER_DESC "\n");
-
-       return i2c_add_driver(&bcm2048_i2c_driver);
-}
-module_init(bcm2048_module_init);
-
-static void __exit bcm2048_module_exit(void)
-{
-       i2c_del_driver(&bcm2048_i2c_driver);
-}
-module_exit(bcm2048_module_exit);
+module_i2c_driver(bcm2048_i2c_driver);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR(BCM2048_DRIVER_AUTHOR);
index 657ea480c6e7bed0944ea1502939860aaed589a6..692ba3e63e141dba87e8c612bbdae8bcc1f6aecc 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/i2c.h>
 #include <linux/wait.h>
 #include <linux/delay.h>
index 87d42e18377d5e3aa7a914594e7c5f02ff8faa22..17e105e7d892db8c02945f5db4c66926e0f0dbff 100644 (file)
@@ -209,10 +209,10 @@ static int ipipeif_hw_setup(struct v4l2_subdev *sd)
        /* Combine all the fields to make CFG1 register of IPIPEIF */
        tmp = val = get_oneshot_mode(ipipeif->input);
        if (tmp < 0) {
-               pr_err("ipipeif: links setup required");
+               dev_err(&sd->devnode->dev, "ipipeif: links setup required");
                return -EINVAL;
        }
-       val = val << ONESHOT_SHIFT;
+       val <<= ONESHOT_SHIFT;
 
        ipipeif_source = ipipeif_get_source(ipipeif);
        val |= ipipeif_source << INPSRC_SHIFT;
@@ -747,7 +747,6 @@ static void ipipeif_set_default_config(struct vpfe_ipipeif_device *ipipeif)
                        .clip = 4095,
                },
        };
-       memset(&ipipeif->config, 0, sizeof(struct ipipeif_params));
        memcpy(&ipipeif->config, &ipipeif_defaults,
               sizeof(struct ipipeif_params));
 }
index 75e70e14b7246dc38dd22942f1c1a443fc06ec6c..7cc8d1b4d737c4d03718862a0145568ec0a1a842 100644 (file)
@@ -907,7 +907,6 @@ resizer_set_defualt_configuration(struct vpfe_resizer_device *resizer)
                        .out_chr_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE,
                },
        };
-       memset(&resizer->config, 0, sizeof(struct resizer_params));
        memcpy(&resizer->config, &rsz_default_config,
               sizeof(struct resizer_params));
 }
index a350a20955f1a88c1e180d6ea125eee9896db496..57426199ad7af48203a349afe66eaa407db120bf 100644 (file)
@@ -226,8 +226,8 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
        if (!vpfe_cfg->num_clocks)
                return 0;
 
-       vpfe_dev->clks = kzalloc(vpfe_cfg->num_clocks *
-                                  sizeof(struct clock *), GFP_KERNEL);
+       vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
+                                sizeof(struct clock *), GFP_KERNEL);
        if (vpfe_dev->clks == NULL)
                return -ENOMEM;
 
@@ -346,7 +346,8 @@ static int register_i2c_devices(struct vpfe_device *vpfe_dev)
        i2c_adap = i2c_get_adapter(1);
        num_subdevs = vpfe_cfg->num_subdevs;
        vpfe_dev->sd =
-                 kzalloc(sizeof(struct v4l2_subdev *)*num_subdevs, GFP_KERNEL);
+                 kcalloc(num_subdevs, sizeof(struct v4l2_subdev *),
+                         GFP_KERNEL);
        if (vpfe_dev->sd == NULL)
                return -ENOMEM;
 
index 9ce7d9990e3e86981e7bd1bbd63b2ae0aae5a927..335b98a54237707c0d17823dc2cdac5b4dcec44d 100644 (file)
@@ -208,8 +208,7 @@ static void deregister_from_lirc(struct imon_context *context)
        retval = lirc_unregister_driver(minor);
        if (retval)
                dev_err(&context->usbdev->dev,
-                       ": %s: unable to deregister from lirc(%d)",
-                       __func__, retval);
+                       "unable to deregister from lirc(%d)", retval);
        else
                dev_info(&context->usbdev->dev,
                         "Deregistered iMON driver (minor:%d)\n", minor);
@@ -241,9 +240,8 @@ static int display_open(struct inode *inode, struct file *file)
        context = usb_get_intfdata(interface);
 
        if (!context) {
-               dev_err(&interface->dev,
-                       "%s: no context found for minor %d\n",
-                       __func__, subminor);
+               dev_err(&interface->dev, "no context found for minor %d\n",
+                       subminor);
                retval = -ENODEV;
                goto exit;
        }
@@ -339,13 +337,13 @@ static int send_packet(struct imon_context *context)
        context->tx_urb->actual_length = 0;
 
        init_completion(&context->tx.finished);
-       atomic_set(&(context->tx.busy), 1);
+       atomic_set(&context->tx.busy, 1);
 
        retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
        if (retval) {
-               atomic_set(&(context->tx.busy), 0);
-               dev_err(&context->usbdev->dev,
-                       "%s: error submitting urb(%d)\n", __func__, retval);
+               atomic_set(&context->tx.busy, 0);
+               dev_err(&context->usbdev->dev, "error submitting urb(%d)\n",
+                       retval);
        } else {
                /* Wait for transmission to complete (or abort) */
                mutex_unlock(&context->ctx_lock);
@@ -359,8 +357,7 @@ static int send_packet(struct imon_context *context)
                retval = context->tx.status;
                if (retval)
                        dev_err(&context->usbdev->dev,
-                               "%s: packet tx failed (%d)\n",
-                               __func__, retval);
+                               "packet tx failed (%d)\n", retval);
        }
 
        return retval;
@@ -437,8 +434,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
                retval = send_packet(context);
                if (retval) {
                        dev_err(&context->usbdev->dev,
-                               "%s: send packet failed for packet #%d\n",
-                               __func__, seq/2);
+                               "send packet failed for packet #%d\n",
+                               seq / 2);
                        goto exit;
                } else {
                        seq += 2;
@@ -454,8 +451,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
                retval = send_packet(context);
                if (retval)
                        dev_err(&context->usbdev->dev,
-                               "%s: send packet failed for packet #%d\n",
-                                       __func__, seq/2);
+                               "send packet failed for packet #%d\n",
+                               seq / 2);
        }
 
 exit:
@@ -877,8 +874,7 @@ static int imon_probe(struct usb_interface *interface,
        retval = usb_submit_urb(context->rx_urb, GFP_KERNEL);
 
        if (retval) {
-               dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n",
-                       __func__, retval);
+               dev_err(dev, "usb_submit_urb failed for intf0 (%d)\n", retval);
                alloc_status = 8;
                goto unlock;
        }
index 19c5c21babf557fed108abe5939e535fe45fceec..c1408342b1d0ebe35e35d5996a49ddec9f3c2828 100644 (file)
@@ -161,8 +161,8 @@ static unsigned int init_lirc_timer(void)
                             || (now.tv_sec == tv.tv_sec
                                 && now.tv_usec < tv.tv_usec)));
 
-       timeelapsed = ((now.tv_sec + 1 - tv.tv_sec)*1000000
-                    + (now.tv_usec - tv.tv_usec));
+       timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000
+                    + (now.tv_usec - tv.tv_usec);
        if (count >= 1000 && timeelapsed > 0) {
                if (default_timer == 0) {
                        /* autodetect timer */
@@ -336,7 +336,7 @@ static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
        set_current_state(TASK_INTERRUPTIBLE);
        while (count < n) {
                if (rptr != wptr) {
-                       if (copy_to_user(buf+count, (char *) &rbuf[rptr],
+                       if (copy_to_user(buf+count, &rbuf[rptr],
                                         sizeof(int))) {
                                result = -EFAULT;
                                break;
index 4a268200cbf55ce8d5d2cf3633697fc8fdaa8647..0c9e08247d7f7d6d8f8babc9cc8227862282f4c6 100644 (file)
@@ -172,7 +172,8 @@ static void delete_context(struct sasem_context *context)
        kfree(context);
 
        if (debug)
-               pr_info("%s: context deleted\n", __func__);
+               dev_info(&context->dev->dev, "%s: context deleted\n",
+                        __func__);
 }
 
 static void deregister_from_lirc(struct sasem_context *context)
@@ -182,10 +183,12 @@ static void deregister_from_lirc(struct sasem_context *context)
 
        retval = lirc_unregister_driver(minor);
        if (retval)
-               pr_err("%s: unable to deregister from lirc (%d)\n",
+               dev_err(&context->dev->dev,
+                       "%s: unable to deregister from lirc (%d)\n",
                       __func__, retval);
        else
-               pr_info("Deregistered Sasem driver (minor:%d)\n", minor);
+               dev_info(&context->dev->dev,
+                        "Deregistered Sasem driver (minor:%d)\n", minor);
 
 }
 
@@ -214,9 +217,8 @@ static int vfd_open(struct inode *inode, struct file *file)
        context = usb_get_intfdata(interface);
 
        if (!context) {
-               dev_err(&interface->dev,
-                       "%s: no context found for minor %d\n",
-                       __func__, subminor);
+               dev_err(&interface->dev, "no context found for minor %d\n",
+                       subminor);
                retval = -ENODEV;
                goto exit;
        }
@@ -332,13 +334,13 @@ static int send_packet(struct sasem_context *context)
        context->tx_urb->actual_length = 0;
 
        init_completion(&context->tx.finished);
-       atomic_set(&(context->tx.busy), 1);
+       atomic_set(&context->tx.busy, 1);
 
        retval =  usb_submit_urb(context->tx_urb, GFP_KERNEL);
        if (retval) {
-               atomic_set(&(context->tx.busy), 0);
-               dev_err(&context->dev->dev, "%s: error submitting urb (%d)\n",
-                       __func__, retval);
+               atomic_set(&context->tx.busy, 0);
+               dev_err(&context->dev->dev, "error submitting urb (%d)\n",
+                       retval);
        } else {
                /* Wait for transmission to complete (or abort) */
                mutex_unlock(&context->ctx_lock);
@@ -348,8 +350,7 @@ static int send_packet(struct sasem_context *context)
                retval = context->tx.status;
                if (retval)
                        dev_err(&context->dev->dev,
-                               "%s: packet tx failed (%d)\n",
-                               __func__, retval);
+                               "packet tx failed (%d)\n", retval);
        }
 
        return retval;
@@ -389,7 +390,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
                goto exit;
        }
 
-       data_buf = memdup_user((void const __user *)buf, n_bytes);
+       data_buf = memdup_user(buf, n_bytes);
        if (IS_ERR(data_buf)) {
                retval = PTR_ERR(data_buf);
                data_buf = NULL;
@@ -444,8 +445,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
                retval = send_packet(context);
                if (retval) {
                        dev_err(&context->dev->dev,
-                               "%s: send packet failed for packet #%d\n",
-                               __func__, i);
+                               "send packet failed for packet #%d\n", i);
                        goto exit;
                }
        }
@@ -509,8 +509,7 @@ static int ir_open(void *data)
 
        if (retval)
                dev_err(&context->dev->dev,
-                       "%s: usb_submit_urb failed for ir_open (%d)\n",
-                       __func__, retval);
+                       "usb_submit_urb failed for ir_open (%d)\n", retval);
        else {
                context->ir_isopen = 1;
                dev_info(&context->dev->dev, "IR port opened\n");
index 19628d0104ab88a8408182b837376f985b2fce2f..dc7984455c3a7a051ea8db668c2fbeb9f64b43f3 100644 (file)
@@ -344,7 +344,7 @@ static int init_timing_params(unsigned int new_duty_cycle,
        /* How many clocks in a microsecond?, avoiding long long divide */
        work = loops_per_sec;
        work *= 4295;  /* 4295 = 2^32 / 1e6 */
-       conv_us_to_clocks = (work >> 32);
+       conv_us_to_clocks = work >> 32;
 
        /*
         * Carrier period in clocks, approach good up to 32GHz clock,
@@ -784,7 +784,7 @@ static int lirc_serial_probe(struct platform_device *dev)
 
        result = devm_request_irq(&dev->dev, irq, lirc_irq_handler,
                             (share_irq ? IRQF_SHARED : 0),
-                            LIRC_DRIVER_NAME, (void *)&hardware);
+                            LIRC_DRIVER_NAME, &hardware);
        if (result < 0) {
                if (result == -EBUSY)
                        dev_err(&dev->dev, "IRQ %d busy\n", irq);
@@ -838,7 +838,7 @@ static int lirc_serial_probe(struct platform_device *dev)
                                nhigh++;
                        msleep(40);
                }
-               sense = (nlow >= nhigh ? 1 : 0);
+               sense = nlow >= nhigh ? 1 : 0;
                dev_info(&dev->dev, "auto-detected active %s receiver\n",
                         sense ? "low" : "high");
        } else
index 39f4733fb1ee25fea623120441d989c6624bc235..29087f66e2f40126f608babc0d4e36f568987643 100644 (file)
@@ -683,9 +683,7 @@ static int init_port(void)
        }
        pr_info("I/O port 0x%.4x, IRQ %d.\n", io, irq);
 
-       init_timer(&timerlist);
-       timerlist.function = sir_timeout;
-       timerlist.data = 0xabadcafe;
+       setup_timer(&timerlist, sir_timeout, 0);
 
        return 0;
 }
index e16627ca488e654011a00e38fe84d5d36019c9ce..261e27d6b054c183c9886eb752fdee57111d7c42 100644 (file)
@@ -1341,8 +1341,7 @@ static int close(struct inode *node, struct file *filep)
        struct IR *ir = filep->private_data;
 
        if (ir == NULL) {
-               dev_err(ir->l.dev,
-                       "close: no private_data attached to the file!\n");
+               pr_err("ir: close: no private_data attached to the file!\n");
                return -ENODEV;
        }
 
index 6eebe564e5573e6187d30777f247f084f8421eba..2a68582e7f71abc9d5c658147e1add98925d1384 100644 (file)
@@ -276,7 +276,7 @@ static int mn88472_init(struct dvb_frontend *fe)
                        remaining -= (dev->i2c_wr_max - 1)) {
                len = remaining;
                if (len > (dev->i2c_wr_max - 1))
-                       len = (dev->i2c_wr_max - 1);
+                       len = dev->i2c_wr_max - 1;
 
                ret = regmap_bulk_write(dev->regmap[0], 0xf6,
                                &fw->data[fw->size - remaining], len);
index a333744b76b958df4cfc7fb002696548f0709b90..5baeb03ab3d12d220db8f97b23d72e29b0575b3b 100644 (file)
@@ -17,7 +17,7 @@
 #include "mn88473_priv.h"
 
 static int mn88473_get_tune_settings(struct dvb_frontend *fe,
-       struct dvb_frontend_tune_settings *s)
+                                    struct dvb_frontend_tune_settings *s)
 {
        s->min_delay_ms = 1000;
        return 0;
@@ -33,10 +33,14 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
        u8 delivery_system_val, if_val[3], bw_val[7];
 
        dev_dbg(&client->dev,
-                       "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%d stream_id=%d\n",
-                       c->delivery_system, c->modulation,
-                       c->frequency, c->bandwidth_hz, c->symbol_rate,
-                       c->inversion, c->stream_id);
+               "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%d stream_id=%d\n",
+               c->delivery_system,
+               c->modulation,
+               c->frequency,
+               c->bandwidth_hz,
+               c->symbol_rate,
+               c->inversion,
+               c->stream_id);
 
        if (!dev->warm) {
                ret = -EAGAIN;
@@ -112,7 +116,7 @@ static int mn88473_set_frontend(struct dvb_frontend *fe)
                break;
        default:
                dev_err(&client->dev, "IF frequency %d not supported\n",
-                               if_frequency);
+                       if_frequency);
                ret = -EINVAL;
                goto err;
        }
@@ -229,7 +233,7 @@ static int mn88473_init(struct dvb_frontend *fe)
        }
 
        dev_info(&client->dev, "downloading firmware from file '%s'\n",
-                       fw_file);
+                fw_file);
 
        ret = regmap_write(dev->regmap[0], 0xf5, 0x03);
        if (ret)
@@ -239,13 +243,13 @@ static int mn88473_init(struct dvb_frontend *fe)
                        remaining -= (dev->i2c_wr_max - 1)) {
                len = remaining;
                if (len > (dev->i2c_wr_max - 1))
-                       len = (dev->i2c_wr_max - 1);
+                       len = dev->i2c_wr_max - 1;
 
                ret = regmap_bulk_write(dev->regmap[0], 0xf6,
-                               &fw->data[fw->size - remaining], len);
+                                       &fw->data[fw->size - remaining], len);
                if (ret) {
                        dev_err(&client->dev, "firmware download failed=%d\n",
-                                       ret);
+                               ret);
                        goto err;
                }
        }
@@ -325,7 +329,7 @@ static struct dvb_frontend_ops mn88473_ops = {
 };
 
 static int mn88473_probe(struct i2c_client *client,
-               const struct i2c_device_id *id)
+                        const struct i2c_device_id *id)
 {
        struct mn88473_config *config = client->dev.platform_data;
        struct mn88473_dev *dev;
index 44b81a2c8b6f651a09d49c0c4da16019a52eabce..e0ad5e520e2d26705f43d1862de128ea428f20a6 100644 (file)
@@ -1160,8 +1160,8 @@ iss_register_subdev_group(struct iss_device *iss,
                subdev = v4l2_i2c_new_subdev_board(&iss->v4l2_dev, adapter,
                                board_info->board_info, NULL);
                if (subdev == NULL) {
-                       dev_err(iss->dev, "%s: Unable to register subdev %s\n",
-                               __func__, board_info->board_info->type);
+                       dev_err(iss->dev, "Unable to register subdev %s\n",
+                               board_info->board_info->type);
                        continue;
                }
 
@@ -1185,16 +1185,16 @@ static int iss_register_entities(struct iss_device *iss)
        iss->media_dev.link_notify = iss_pipeline_link_notify;
        ret = media_device_register(&iss->media_dev);
        if (ret < 0) {
-               dev_err(iss->dev, "%s: Media device registration failed (%d)\n",
-                       __func__, ret);
+               dev_err(iss->dev, "Media device registration failed (%d)\n",
+                       ret);
                return ret;
        }
 
        iss->v4l2_dev.mdev = &iss->media_dev;
        ret = v4l2_device_register(iss->dev, &iss->v4l2_dev);
        if (ret < 0) {
-               dev_err(iss->dev, "%s: V4L2 device registration failed (%d)\n",
-                       __func__, ret);
+               dev_err(iss->dev, "V4L2 device registration failed (%d)\n",
+                       ret);
                goto done;
        }
 
@@ -1252,8 +1252,8 @@ static int iss_register_entities(struct iss_device *iss)
                        break;
 
                default:
-                       dev_err(iss->dev, "%s: invalid interface type %u\n",
-                               __func__, subdevs->interface);
+                       dev_err(iss->dev, "invalid interface type %u\n",
+                               subdevs->interface);
                        ret = -EINVAL;
                        goto done;
                }
index 69550445a341ff6f39a571a9c72c37ecab435a04..55938cccde7f0114c395e03e8d39ddc060a9de56 100644 (file)
@@ -1221,8 +1221,7 @@ int omap4iss_video_register(struct iss_video *video, struct v4l2_device *vdev)
        ret = video_register_device(&video->video, VFL_TYPE_GRABBER, -1);
        if (ret < 0)
                dev_err(video->iss->dev,
-                       "%s: could not register video device (%d)\n",
-                       __func__, ret);
+                       "could not register video device (%d)\n", ret);
 
        return ret;
 }
index 3b191fce45ec912d318c45892db0bdd09443ab20..7285c64bac240099743f4427d9aa50e9a4dd77c4 100644 (file)
@@ -770,7 +770,7 @@ static void spinand_cmdfunc(struct mtd_info *mtd, unsigned int command,
                break;
        case NAND_CMD_READID:
                state->buf_ptr = 0;
-               spinand_read_id(info->spi, (u8 *)state->buf);
+               spinand_read_id(info->spi, state->buf);
                break;
        case NAND_CMD_PARAM:
                state->buf_ptr = 0;
index e8aae09d16242b9fe08fc0ddec58372a67d9709d..8ae01753b011a39cd015f9e050eebd3f9cbc17ef 100644 (file)
@@ -1012,7 +1012,7 @@ static int xlr_net_probe(struct platform_device *pdev)
         * Allocate our adapter data structure and attach it to the device.
         */
        adapter = (struct xlr_adapter *)
-               devm_kzalloc(&pdev->dev, sizeof(adapter), GFP_KERNEL);
+               devm_kzalloc(&pdev->dev, sizeof(*adapter), GFP_KERNEL);
        if (!adapter) {
                err = -ENOMEM;
                return err;
index 9475e20c3d646f85c2e1d164aaf4c8c3dbe84c63..e3a89fb1a4a2547f77c5ea469b06bf76e1e76e57 100644 (file)
@@ -6,6 +6,9 @@ config MFD_NVEC
            Say Y here to enable support for a nVidia compliant embedded
            controller.
 
+           To compile this driver as a module, say M here: the module will be
+            called mfd-nvec
+
 config KEYBOARD_NVEC
        tristate "Keyboard on nVidia compliant EC"
        depends on MFD_NVEC && INPUT
@@ -13,6 +16,9 @@ config KEYBOARD_NVEC
          Say Y here to enable support for a keyboard connected to
          a nVidia compliant embedded controller.
 
+         To compile this driver as a module, say M here: the module will be
+          called keyboard-nvec
+
 config SERIO_NVEC_PS2
        tristate "PS2 on nVidia EC"
        depends on MFD_NVEC && SERIO
@@ -20,6 +26,10 @@ config SERIO_NVEC_PS2
          Say Y here to enable support for a Touchpad / Mouse connected
          to a nVidia compliant embedded controller.
 
+         To compile this driver as a module, say M here: the module will be
+          called serio-nvec-ps2
+
+
 config NVEC_POWER
        tristate "NVEC charger and battery"
        depends on MFD_NVEC && POWER_SUPPLY
@@ -27,9 +37,17 @@ config NVEC_POWER
          Say Y to enable support for battery and charger interface for
          nVidia compliant embedded controllers.
 
+         To compile this driver as a module, say M here: the module will be
+          called nvec-power
+
+
 config NVEC_PAZ00
        tristate "Support for OEM specific functions on Compal PAZ00 based devices"
        depends on MFD_NVEC && LEDS_CLASS
        help
          Say Y to enable control of the yellow side leds on Compal PAZ00 based
          devices, e.g. Toshbia AC100 and Dynabooks AZ netbooks.
+
+         To compile this driver as a module, say M here: the module will be
+          called nvec-paz00
+
index 5868ebb8389e54948f3e1efde3449343d8e320ce..1bdc8d001e65da929f6e797cf494b282f7f2f66b 100644 (file)
@@ -803,7 +803,7 @@ static int tegra_nvec_probe(struct platform_device *pdev)
        }
 
        nvec = devm_kzalloc(&pdev->dev, sizeof(struct nvec_chip), GFP_KERNEL);
-       if (nvec == NULL)
+       if (!nvec)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, nvec);
index f0cea0e43c96bb21b8bc9137d42bb38e27a036fb..68146bfee2b34ec01d0dfb88db1bd44fa6a85eab 100644 (file)
@@ -51,7 +51,7 @@ static int nvec_paz00_probe(struct platform_device *pdev)
        int ret = 0;
 
        led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
-       if (led == NULL)
+       if (!led)
                return -ENOMEM;
 
        led->cdev.max_brightness = NVEC_LED_MAX;
index 6a1459d4f8fbab1da3d1203c2f727ada62131e4c..3621b661aba80b4a3f7823e0db7122f8092949ad 100644 (file)
@@ -378,7 +378,7 @@ static int nvec_power_probe(struct platform_device *pdev)
        struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
 
        power = devm_kzalloc(&pdev->dev, sizeof(struct nvec_power), GFP_NOWAIT);
-       if (power == NULL)
+       if (!power)
                return -ENOMEM;
 
        dev_set_drvdata(&pdev->dev, power);
index 4fd63c239454ce5fda1499262a50e3812c3cfdd3..6ebbc82323c3f75f751d95b6bcfcebf935ca8357 100644 (file)
@@ -109,7 +109,7 @@ static int nvec_mouse_probe(struct platform_device *pdev)
        char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 };
 
        ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
-       if (ser_dev == NULL)
+       if (!ser_dev)
                return -ENOMEM;
 
        ser_dev->id.type = SERIO_PS_PSTHRU;
index 1daeb3125a1ff979662fc317b8ac0d303c0368e5..959123279ce837ba82b3e774b1dd7727734304b9 100644 (file)
@@ -3885,7 +3885,7 @@ static int octeon_usb_remove(struct platform_device *pdev)
        return 0;
 }
 
-static struct of_device_id octeon_usb_match[] = {
+static const struct of_device_id octeon_usb_match[] = {
        {
                .compatible = "cavium,octeon-5750-usbc",
        },
index 460e8545904fe174dc21cb68e81f9b22b0cd5e75..79f33349e93fa4be76da3173d2969d8085064c4d 100644 (file)
@@ -859,7 +859,7 @@ static int cvm_oct_remove(struct platform_device *pdev)
        return 0;
 }
 
-static struct of_device_id cvm_oct_match[] = {
+static const struct of_device_id cvm_oct_match[] = {
        {
                .compatible = "cavium,octeon-3860-pip",
        },
index 8543bb29a138c232748c0bd13f2811a5ba494e99..5ff4716b72c311485084005b9e09a36021157530 100644 (file)
@@ -280,17 +280,20 @@ static void oz_free_urb_link(struct oz_urb_link *urbl)
  */
 static struct oz_endpoint *oz_ep_alloc(int buffer_size, gfp_t mem_flags)
 {
-       struct oz_endpoint *ep =
-               kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags);
-       if (ep) {
-               INIT_LIST_HEAD(&ep->urb_list);
-               INIT_LIST_HEAD(&ep->link);
-               ep->credit = -1;
-               if (buffer_size) {
-                       ep->buffer_size = buffer_size;
-                       ep->buffer = (u8 *)(ep+1);
-               }
+       struct oz_endpoint *ep;
+
+       ep = kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags);
+       if (!ep)
+               return NULL;
+
+       INIT_LIST_HEAD(&ep->urb_list);
+       INIT_LIST_HEAD(&ep->link);
+       ep->credit = -1;
+       if (buffer_size) {
+               ep->buffer_size = buffer_size;
+               ep->buffer = (u8 *)(ep+1);
        }
+
        return ep;
 }
 
index 852c288aaf13132398263c3c3d24b49627a29892..021d74a132ddf5f4e16512321c44ac0afa88f25a 100644 (file)
@@ -102,34 +102,36 @@ void oz_pd_put(struct oz_pd *pd)
  */
 struct oz_pd *oz_pd_alloc(const u8 *mac_addr)
 {
-       struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC);
-
-       if (pd) {
-               int i;
-
-               atomic_set(&pd->ref_count, 2);
-               for (i = 0; i < OZ_NB_APPS; i++)
-                       spin_lock_init(&pd->app_lock[i]);
-               pd->last_rx_pkt_num = 0xffffffff;
-               oz_pd_set_state(pd, OZ_PD_S_IDLE);
-               pd->max_tx_size = OZ_MAX_TX_SIZE;
-               ether_addr_copy(pd->mac_addr, mac_addr);
-               oz_elt_buf_init(&pd->elt_buff);
-               spin_lock_init(&pd->tx_frame_lock);
-               INIT_LIST_HEAD(&pd->tx_queue);
-               INIT_LIST_HEAD(&pd->farewell_list);
-               pd->last_sent_frame = &pd->tx_queue;
-               spin_lock_init(&pd->stream_lock);
-               INIT_LIST_HEAD(&pd->stream_list);
-               tasklet_init(&pd->heartbeat_tasklet, oz_pd_heartbeat_handler,
-                                                       (unsigned long)pd);
-               tasklet_init(&pd->timeout_tasklet, oz_pd_timeout_handler,
-                                                       (unsigned long)pd);
-               hrtimer_init(&pd->heartbeat, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-               hrtimer_init(&pd->timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-               pd->heartbeat.function = oz_pd_heartbeat_event;
-               pd->timeout.function = oz_pd_timeout_event;
-       }
+       struct oz_pd *pd;
+       int i;
+
+       pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC);
+       if (!pd)
+               return NULL;
+
+       atomic_set(&pd->ref_count, 2);
+       for (i = 0; i < OZ_NB_APPS; i++)
+               spin_lock_init(&pd->app_lock[i]);
+       pd->last_rx_pkt_num = 0xffffffff;
+       oz_pd_set_state(pd, OZ_PD_S_IDLE);
+       pd->max_tx_size = OZ_MAX_TX_SIZE;
+       ether_addr_copy(pd->mac_addr, mac_addr);
+       oz_elt_buf_init(&pd->elt_buff);
+       spin_lock_init(&pd->tx_frame_lock);
+       INIT_LIST_HEAD(&pd->tx_queue);
+       INIT_LIST_HEAD(&pd->farewell_list);
+       pd->last_sent_frame = &pd->tx_queue;
+       spin_lock_init(&pd->stream_lock);
+       INIT_LIST_HEAD(&pd->stream_list);
+       tasklet_init(&pd->heartbeat_tasklet, oz_pd_heartbeat_handler,
+                                               (unsigned long)pd);
+       tasklet_init(&pd->timeout_tasklet, oz_pd_timeout_handler,
+                                               (unsigned long)pd);
+       hrtimer_init(&pd->heartbeat, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       hrtimer_init(&pd->timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       pd->heartbeat.function = oz_pd_heartbeat_event;
+       pd->timeout.function = oz_pd_timeout_event;
+
        return pd;
 }
 
@@ -652,8 +654,9 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num)
  */
 int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
 {
-       struct oz_isoc_stream *st =
-               kzalloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC);
+       struct oz_isoc_stream *st;
+
+       st = kzalloc(sizeof(struct oz_isoc_stream), GFP_ATOMIC);
        if (!st)
                return -ENOMEM;
        st->ep_num = ep_num;
index 3d3a3a890f73341206bc64527cbecd9e82720b24..1ba24a2aef835bca872f892b9d2a70c2c7a1d674 100644 (file)
@@ -98,7 +98,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status)
                kfree_skb(skb);
                return;
        }
-       oz_hdr->control = (OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT);
+       oz_hdr->control = OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT;
        oz_hdr->last_pkt_num = 0;
        put_unaligned(0, &oz_hdr->pkt_num);
        elt->type = OZ_ELT_CONNECT_RSP;
index 6ed35b6ecf0d1a3bf2795d4dd5d01678aa365bf7..b7ffdfb5c3e6fef1f89cb347f8b5b236978e9c6e 100644 (file)
@@ -473,8 +473,6 @@ static struct pardevice *pprt;
 
 static int keypad_initialized;
 
-static char init_in_progress;
-
 static void (*lcd_write_cmd)(int);
 static void (*lcd_write_data)(int);
 static void (*lcd_clear_fast)(void);
@@ -1718,9 +1716,6 @@ static struct miscdevice keypad_dev = {
 
 static void keypad_send_key(const char *string, int max_len)
 {
-       if (init_in_progress)
-               return;
-
        /* send the key to the device only if a process is attached to it. */
        if (!atomic_read(&keypad_available)) {
                while (max_len-- && keypad_buflen < KEYPAD_BUFFER && *string) {
@@ -2010,10 +2005,8 @@ static void init_scan_timer(void)
        if (scan_timer.function != NULL)
                return;         /* already started */
 
-       init_timer(&scan_timer);
+       setup_timer(&scan_timer, (void *)&panel_scan_timer, 0);
        scan_timer.expires = jiffies + INPUT_POLL_TIME;
-       scan_timer.data = 0;
-       scan_timer.function = (void *)&panel_scan_timer;
        add_timer(&scan_timer);
 }
 
@@ -2236,6 +2229,7 @@ static void panel_attach(struct parport *port)
                if (misc_register(&keypad_dev))
                        goto err_lcd_unreg;
        }
+       register_reboot_notifier(&panel_notifier);
        return;
 
 err_lcd_unreg:
@@ -2257,6 +2251,8 @@ static void panel_detach(struct parport *port)
                return;
        }
 
+       unregister_reboot_notifier(&panel_notifier);
+
        if (keypad.enabled && keypad_initialized) {
                misc_deregister(&keypad_dev);
                keypad_initialized = 0;
@@ -2281,7 +2277,7 @@ static struct parport_driver panel_driver = {
 /* init function */
 static int __init panel_init_module(void)
 {
-       int selected_keypad_type = NOT_SET;
+       int selected_keypad_type = NOT_SET, err;
 
        /* take care of an eventual profile */
        switch (profile) {
@@ -2323,26 +2319,6 @@ static int __init panel_init_module(void)
                break;
        }
 
-       /*
-        * Init lcd struct with load-time values to preserve exact current
-        * functionality (at least for now).
-        */
-       lcd.height = lcd_height;
-       lcd.width = lcd_width;
-       lcd.bwidth = lcd_bwidth;
-       lcd.hwidth = lcd_hwidth;
-       lcd.charset = lcd_charset;
-       lcd.proto = lcd_proto;
-       lcd.pins.e = lcd_e_pin;
-       lcd.pins.rs = lcd_rs_pin;
-       lcd.pins.rw = lcd_rw_pin;
-       lcd.pins.cl = lcd_cl_pin;
-       lcd.pins.da = lcd_da_pin;
-       lcd.pins.bl = lcd_bl_pin;
-
-       /* Leave it for now, just in case */
-       lcd.esc_seq.len = -1;
-
        /*
         * Overwrite selection with module param values (both keypad and lcd),
         * where the deprecated params have lower prio.
@@ -2361,6 +2337,28 @@ static int __init panel_init_module(void)
 
        lcd.enabled = (selected_lcd_type > 0);
 
+       if (lcd.enabled) {
+               /*
+                * Init lcd struct with load-time values to preserve exact
+                * current functionality (at least for now).
+                */
+               lcd.height = lcd_height;
+               lcd.width = lcd_width;
+               lcd.bwidth = lcd_bwidth;
+               lcd.hwidth = lcd_hwidth;
+               lcd.charset = lcd_charset;
+               lcd.proto = lcd_proto;
+               lcd.pins.e = lcd_e_pin;
+               lcd.pins.rs = lcd_rs_pin;
+               lcd.pins.rw = lcd_rw_pin;
+               lcd.pins.cl = lcd_cl_pin;
+               lcd.pins.da = lcd_da_pin;
+               lcd.pins.bl = lcd_bl_pin;
+
+               /* Leave it for now, just in case */
+               lcd.esc_seq.len = -1;
+       }
+
        switch (selected_keypad_type) {
        case KEYPAD_TYPE_OLD:
                keypad_profile = old_keypad_profile;
@@ -2376,27 +2374,17 @@ static int __init panel_init_module(void)
                break;
        }
 
-       /* tells various subsystems about the fact that we are initializing */
-       init_in_progress = 1;
-
-       if (parport_register_driver(&panel_driver)) {
-               pr_err("could not register with parport. Aborting.\n");
-               return -EIO;
-       }
-
        if (!lcd.enabled && !keypad.enabled) {
-               /* no device enabled, let's release the parport */
-               if (pprt) {
-                       parport_release(pprt);
-                       parport_unregister_device(pprt);
-                       pprt = NULL;
-               }
-               parport_unregister_driver(&panel_driver);
+               /* no device enabled, let's exit */
                pr_err("driver version " PANEL_VERSION " disabled.\n");
                return -ENODEV;
        }
 
-       register_reboot_notifier(&panel_notifier);
+       err = parport_register_driver(&panel_driver);
+       if (err) {
+               pr_err("could not register with parport. Aborting.\n");
+               return err;
+       }
 
        if (pprt)
                pr_info("driver version " PANEL_VERSION
@@ -2405,15 +2393,11 @@ static int __init panel_init_module(void)
        else
                pr_info("driver version " PANEL_VERSION
                        " not yet registered\n");
-       /* tells various subsystems about the fact that initialization
-          is finished */
-       init_in_progress = 0;
        return 0;
 }
 
 static void __exit panel_cleanup_module(void)
 {
-       unregister_reboot_notifier(&panel_notifier);
 
        if (scan_timer.function != NULL)
                del_timer_sync(&scan_timer);
index da19145c49c576146851306d44a629d838ba8558..e65ee6e858a8b15455bdd646d9fc5e5ba169f712 100644 (file)
@@ -23,6 +23,7 @@
 #include <drv_types.h>
 #include <wifi.h>
 #include <ieee80211.h>
+#include <asm/unaligned.h>
 
 #ifdef CONFIG_88EU_AP_MODE
 
@@ -78,11 +79,8 @@ static void update_BCNTIM(struct adapter *padapter)
        if (true) {
                u8 *p, *dst_ie, *premainder_ie = NULL;
                u8 *pbackup_remainder_ie = NULL;
-               __le16 tim_bitmap_le;
                uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
 
-               tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
-
                p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
                if (p != NULL && tim_ielen > 0) {
                        tim_ielen += 2;
@@ -137,9 +135,9 @@ static void update_BCNTIM(struct adapter *padapter)
                        *dst_ie++ = 0;
 
                if (tim_ielen == 4) {
-                       *dst_ie++ = *(u8 *)&tim_bitmap_le;
+                       *dst_ie++ = pstapriv->tim_bitmap & 0xff;
                } else if (tim_ielen == 5) {
-                       memcpy(dst_ie, &tim_bitmap_le, 2);
+                       put_unaligned_le16(pstapriv->tim_bitmap, dst_ie);
                        dst_ie += 2;
                }
 
index 4b43462449538e4fabf837d2c8b7dda850eca885..89b5e48ed68a08fe313406b0b189ab8e999b954c 100644 (file)
@@ -325,7 +325,8 @@ u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid,
        if (res == _SUCCESS) {
                pmlmepriv->scan_start_time = jiffies;
 
-               _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
+               mod_timer(&pmlmepriv->scan_to_timer,
+                         jiffies + msecs_to_jiffies(SCANNING_TIMEOUT));
 
                rtw_led_control(padapter, LED_CTL_SITE_SURVEY);
 
@@ -1234,9 +1235,11 @@ void rtw_survey_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
        if (pcmd->res == H2C_DROPPED) {
                /* TODO: cancel timer and do timeout handler directly... */
                /* need to make timeout handlerOS independent */
-               _set_timer(&pmlmepriv->scan_to_timer, 1);
+               mod_timer(&pmlmepriv->scan_to_timer,
+                         jiffies + msecs_to_jiffies(1));
        } else if (pcmd->res != H2C_SUCCESS) {
-               _set_timer(&pmlmepriv->scan_to_timer, 1);
+               mod_timer(&pmlmepriv->scan_to_timer,
+                         jiffies + msecs_to_jiffies(1));
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n."));
        }
 
@@ -1270,10 +1273,12 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter,  struct cmd_obj *pcmd)
        if (pcmd->res == H2C_DROPPED) {
                /* TODO: cancel timer and do timeout handler directly... */
                /* need to make timeout handlerOS independent */
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
        } else if (pcmd->res != H2C_SUCCESS) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("********Error:rtw_select_and_join_from_scanned_queue Wait Sema  Fail ************\n"));
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
        }
 
        rtw_free_cmd_obj(pcmd);
@@ -1291,7 +1296,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
 
        if (pcmd->res != H2C_SUCCESS) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback  Fail ************\n\n."));
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
        }
 
        del_timer_sync(&pmlmepriv->assoc_timer);
index 8816d116a8b8d641032602c23eaf0ffe8f70e9b9..b66746160223ab51823836ffa0fc8510e321c240 100644 (file)
@@ -139,7 +139,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
        while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) {
                /*  Check PG header for section num. */
                if ((rtemp8 & 0x1F) == 0x0F) {          /* extended header */
-                       u1temp = ((rtemp8 & 0xE0) >> 5);
+                       u1temp = (rtemp8 & 0xE0) >> 5;
                        rtemp8 = *(phymap+eFuse_Addr);
                        if ((rtemp8 & 0x0F) == 0x0F) {
                                eFuse_Addr++;
@@ -150,12 +150,12 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8  *pbuf)
                                continue;
                        } else {
                                offset = ((rtemp8 & 0xF0) >> 1) | u1temp;
-                               wren = (rtemp8 & 0x0F);
+                               wren = rtemp8 & 0x0F;
                                eFuse_Addr++;
                        }
                } else {
-                       offset = ((rtemp8 >> 4) & 0x0f);
-                       wren = (rtemp8 & 0x0f);
+                       offset = (rtemp8 >> 4) & 0x0f;
+                       wren = rtemp8 & 0x0f;
                }
 
                if (offset < EFUSE_MAX_SECTION_88E) {
index f2c3ca79c0c93026f142635028e6802d166e9976..a2055017dba219248fd72c007f5d8da375c0f84c 100644 (file)
@@ -27,7 +27,6 @@
 #include <wlan_bssdef.h>
 
 u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 };
-u16 RTW_WPA_VERSION = 1;
 u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 };
 u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 };
 u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 };
@@ -663,7 +662,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie,
 
        /* Search required WPA or WPA2 IE and copy to sec_ie[] */
 
-       cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
+       cnt = _TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_;
 
        sec_idx = 0;
 
index 2faf6b2e812915ace02727b5b8cd702fff52611d..969150a48661344387dbf16e840f9c7adfceaf03 100644 (file)
@@ -86,7 +86,8 @@ u8 rtw_do_join(struct adapter *padapter)
                select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
                if (select_ret == _SUCCESS) {
                        pmlmepriv->to_join = false;
-                       _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
+                       mod_timer(&pmlmepriv->assoc_timer,
+                                 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                } else {
                        if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) {
                                /*  submit createbss_cmd to change to a ADHOC_MASTER */
index 1b8264b978da2e22d9ba93025cb45d4a87ae0e5d..94405dc44220f6f7a53a2486b23bbb6665bdb0da 100644 (file)
@@ -22,9 +22,9 @@
 /*             Callback function of LED BlinkTimer, */
 /*             it just schedules to corresponding BlinkWorkItem/led_blink_hdl */
 /*  */
-void BlinkTimerCallback(void *data)
+void BlinkTimerCallback(unsigned long data)
 {
-       struct LED_871x *pLed = data;
+       struct LED_871x *pLed = (struct LED_871x *)data;
        struct adapter *padapter = pLed->padapter;
 
        if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped))
@@ -72,7 +72,8 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed)
 
        ResetLedStatus(pLed);
 
-       _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed);
+       setup_timer(&(pLed->BlinkTimer), BlinkTimerCallback,
+                   (unsigned long)pLed);
 
        INIT_WORK(&(pLed->BlinkWorkItem), BlinkWorkItemCallback);
 }
@@ -122,14 +123,16 @@ static void SwLedBlink1(struct LED_871x *pLed)
                        pLed->BlinkingLedState = RTW_LED_OFF;
                else
                        pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_BLINK_NORMAL:
                if (pLed->bLedOn)
                        pLed->BlinkingLedState = RTW_LED_OFF;
                else
                        pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                break;
        case LED_BLINK_SCAN:
                pLed->BlinkTimes--;
@@ -143,7 +146,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = RTW_LED_OFF;
                                else
                                        pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                        } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                                pLed->bLedNoLinkBlinkInProgress = true;
@@ -152,7 +156,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = RTW_LED_OFF;
                                else
                                        pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                        }
                        pLed->bLedScanBlinkInProgress = false;
@@ -161,7 +166,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_TXRX:
@@ -176,7 +182,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = RTW_LED_OFF;
                                else
                                        pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                        } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                                pLed->bLedNoLinkBlinkInProgress = true;
@@ -185,7 +192,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = RTW_LED_OFF;
                                else
                                        pLed->BlinkingLedState = RTW_LED_ON;
-                               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                                RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
                        }
                        pLed->BlinkTimes = 0;
@@ -195,7 +203,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_WPS:
@@ -203,7 +212,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                        pLed->BlinkingLedState = RTW_LED_OFF;
                else
                        pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
        case LED_BLINK_WPS_STOP:        /* WPS success */
                if (pLed->BlinkingLedState == RTW_LED_ON)
@@ -218,14 +228,15 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                        RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState));
 
                        pLed->bLedWPSBlinkInProgress = false;
                } else {
                        pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA));
                }
                break;
        default:
@@ -262,7 +273,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_LINK:
@@ -283,7 +295,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_SITE_SURVEY:
@@ -311,7 +324,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                 }
                break;
        case LED_CTL_TX:
@@ -334,7 +348,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_START_WPS: /* wait until xinpin finish */
@@ -362,7 +377,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                                pLed->BlinkingLedState = RTW_LED_OFF;
                        else
                                pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                 }
                break;
        case LED_CTL_STOP_WPS:
@@ -389,11 +405,12 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                pLed->CurrLedState = LED_BLINK_WPS_STOP;
                if (pLed->bLedOn) {
                        pLed->BlinkingLedState = RTW_LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA));
                } else {
                        pLed->BlinkingLedState = RTW_LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                }
                break;
        case LED_CTL_STOP_WPS_FAIL:
@@ -407,7 +424,8 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct
                        pLed->BlinkingLedState = RTW_LED_OFF;
                else
                        pLed->BlinkingLedState = RTW_LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = RTW_LED_OFF;
index d4632da50c1dd460306840576e99c299b6248be0..6c91aa58d924dc316022d9c7549490f176c27260 100644 (file)
@@ -665,7 +665,8 @@ void rtw_surveydone_event_callback(struct adapter   *adapter, u8 *pbuf)
                                set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
 
                                if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) {
-                                       _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
+                                       mod_timer(&pmlmepriv->assoc_timer,
+                                                 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                                } else {
                                        struct wlan_bssid_ex    *pdev_network = &(adapter->registrypriv.dev_network);
                                        u8 *pibss = adapter->registrypriv.dev_network.MacAddress;
@@ -692,7 +693,8 @@ void rtw_surveydone_event_callback(struct adapter   *adapter, u8 *pbuf)
                        pmlmepriv->to_join = false;
                        s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv);
                        if (_SUCCESS == s_ret) {
-                            _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
+                            mod_timer(&pmlmepriv->assoc_timer,
+                                      jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                        } else if (s_ret == 2) { /* there is no need to wait for join */
                                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                                rtw_indicate_connect(adapter);
@@ -1127,14 +1129,16 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf)
 
        } else if (pnetwork->join_res == -4) {
                rtw_reset_securitypriv(adapter);
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
 
                if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", get_fwstate(pmlmepriv)));
                        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                }
        } else { /* if join_res < 0 (join fails), then try again */
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
        }
 
@@ -1360,9 +1364,9 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf)
 * _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss
 * @adapter: pointer to struct adapter structure
 */
-void _rtw_join_timeout_handler (void *function_context)
+void _rtw_join_timeout_handler (unsigned long data)
 {
-       struct adapter *adapter = function_context;
+       struct adapter *adapter = (struct adapter *)data;
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
        int do_join_r;
 
@@ -1402,9 +1406,9 @@ void _rtw_join_timeout_handler (void *function_context)
 * rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey
 * @adapter: pointer to struct adapter structure
 */
-void rtw_scan_timeout_handler (void *function_context)
+void rtw_scan_timeout_handler (unsigned long data)
 {
-       struct adapter *adapter = function_context;
+       struct adapter *adapter = (struct adapter *)data;
        struct  mlme_priv *pmlmepriv = &adapter->mlmepriv;
 
        DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv));
@@ -1429,9 +1433,9 @@ static void rtw_auto_scan_handler(struct adapter *padapter)
        }
 }
 
-void rtw_dynamic_check_timer_handlder(void *function_context)
+void rtw_dynamic_check_timer_handlder(unsigned long data)
 {
-       struct adapter *adapter = (struct adapter *)function_context;
+       struct adapter *adapter = (struct adapter *)data;
        struct registry_priv *pregistrypriv = &adapter->registrypriv;
 
        if (!adapter)
@@ -1449,7 +1453,8 @@ void rtw_dynamic_check_timer_handlder(void *function_context)
                rtw_auto_scan_handler(adapter);
        }
 exit:
-       _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
+       mod_timer(&adapter->mlmepriv.dynamic_chk_timer,
+                 jiffies + msecs_to_jiffies(2000));
 }
 
 #define RTW_SCAN_RESULT_EXPIRE 2000
@@ -2037,7 +2042,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len)
        p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie));
        if (p && len > 0) {
                pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2);
-               max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR);
+               max_ampdu_sz = pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR;
                max_ampdu_sz = 1 << (max_ampdu_sz+3); /*  max_ampdu_sz (kbytes); */
                phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
        }
index cd12dd70dd8804065c42e4e587a644fa8b474aee..86d955fadc4b2da543431d14794efcb0acdb43d1 100644 (file)
@@ -1639,7 +1639,7 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr
                        break;
                case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */
                        status = get_unaligned_le16(&frame_body[3]);
-                       tid = ((frame_body[5] >> 2) & 0x7);
+                       tid = (frame_body[5] >> 2) & 0x7;
                        if (status == 0) {      /* successful */
                                DBG_88E("agg_enable for TID=%d\n", tid);
                                psta->htpriv.agg_enable_bitmap |= 1 << tid;
@@ -2491,7 +2491,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short
 
                /* setting IV for auth seq #3 */
                if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) {
-                       val32 = ((pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30));
+                       val32 = (pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30);
                        le_tmp32 = cpu_to_le32(val32);
                        pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &(pattrib->pktlen));
 
@@ -3331,7 +3331,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch
                        } while (pmlmeinfo->dialogToken == 0);
                        pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen));
 
-                       BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */
+                       BA_para_set = 0x1002 | ((status & 0xf) << 2); /* immediate ack & 64 buffer size */
                        le_tmp = cpu_to_le16(BA_para_set);
                        pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen));
 
@@ -3972,8 +3972,8 @@ void start_clnt_join(struct adapter *padapter)
                /* and enable a timer */
                beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval);
                set_link_timer(pmlmeext, beacon_timeout);
-               _set_timer(&padapter->mlmepriv.assoc_timer,
-                          (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout);
+               mod_timer(&padapter->mlmepriv.assoc_timer, jiffies +
+                         msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout));
 
                pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
        } else if (caps&cap_IBSS) { /* adhoc client */
@@ -4247,7 +4247,7 @@ void report_survey_event(struct adapter *padapter,
        if (pcmd_obj == NULL)
                return;
 
-       cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct survey_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (pevtcmd == NULL) {
                kfree(pcmd_obj);
@@ -4299,7 +4299,7 @@ void report_surveydone_event(struct adapter *padapter)
        if (pcmd_obj == NULL)
                return;
 
-       cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
        if (pevtcmd == NULL) {
                kfree(pcmd_obj);
@@ -4345,7 +4345,7 @@ void report_join_res(struct adapter *padapter, int res)
        if (pcmd_obj == NULL)
                return;
 
-       cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (pevtcmd == NULL) {
                kfree(pcmd_obj);
@@ -4398,7 +4398,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
        if (pcmd_obj == NULL)
                return;
 
-       cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
        if (pevtcmd == NULL) {
                kfree(pcmd_obj);
@@ -4428,7 +4428,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi
        if (psta)
                mac_id = (int)psta->mac_id;
        else
-               mac_id = (-1);
+               mac_id = -1;
 
        pdel_sta_evt->mac_id = mac_id;
 
@@ -4453,7 +4453,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int
        if (pcmd_obj == NULL)
                return;
 
-       cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_KERNEL);
        if (pevtcmd == NULL) {
                kfree(pcmd_obj);
@@ -4835,9 +4835,9 @@ void linked_status_chk(struct adapter *padapter)
        }
 }
 
-void survey_timer_hdl(void *function_context)
+void survey_timer_hdl(unsigned long data)
 {
-       struct adapter *padapter = function_context;
+       struct adapter *padapter = (struct adapter *)data;
        struct cmd_obj  *ph2c;
        struct sitesurvey_parm  *psurveyPara;
        struct cmd_priv                                 *pcmdpriv = &padapter->cmdpriv;
@@ -4875,9 +4875,9 @@ exit_survey_timer_hdl:
        return;
 }
 
-void link_timer_hdl(void *function_context)
+void link_timer_hdl(unsigned long data)
 {
-       struct adapter *padapter = (struct adapter *)function_context;
+       struct adapter *padapter = (struct adapter *)data;
        struct mlme_ext_priv    *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info    *pmlmeinfo = &(pmlmeext->mlmext_info);
 
@@ -4912,9 +4912,9 @@ void link_timer_hdl(void *function_context)
        return;
 }
 
-void addba_timer_hdl(void *function_context)
+void addba_timer_hdl(unsigned long data)
 {
-       struct sta_info *psta = function_context;
+       struct sta_info *psta = (struct sta_info *)data;
        struct ht_priv  *phtpriv;
 
        if (!psta)
@@ -5356,7 +5356,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf)
 
                psta = rtw_get_stainfo(pstapriv, pparm->addr);
                if (psta) {
-                       ctrl = (BIT(15) | ((pparm->algorithm) << 2));
+                       ctrl = BIT(15) | ((pparm->algorithm) << 2);
 
                        DBG_88E("r871x_set_stakey_hdl(): enc_algorithm=%d\n", pparm->algorithm);
 
@@ -5365,7 +5365,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf)
                                return H2C_REJECTED;
                        }
 
-                       cam_id = (psta->mac_id + 3);/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */
+                       cam_id = psta->mac_id + 3;/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */
 
                        DBG_88E("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, cam_entry=%d\n", pparm->addr[0],
                                pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4],
@@ -5406,7 +5406,8 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf)
        if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) ||
            ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) {
                issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid);
-               _set_timer(&psta->addba_retry_timer, ADDBA_TO);
+               mod_timer(&psta->addba_retry_timer,
+                         jiffies + msecs_to_jiffies(ADDBA_TO));
        } else {
                psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid);
        }
index df463a29b6410182b9d3f7aede6f1f38f18216b1..ec0a8a4cdc6e65c29aa9b6b42b752028090d7b6f 100644 (file)
@@ -281,9 +281,9 @@ exit:
        pwrpriv->ps_processing = false;
 }
 
-static void pwr_state_check_handler(void *FunctionContext)
+static void pwr_state_check_handler(unsigned long data)
 {
-       struct adapter *padapter = FunctionContext;
+       struct adapter *padapter = (struct adapter *)data;
        rtw_ps_cmd(padapter);
 }
 
@@ -544,7 +544,9 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter)
 
        pwrctrlpriv->btcoex_rfon = false;
 
-       _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter);
+       setup_timer(&pwrctrlpriv->pwr_state_check_timer,
+                   pwr_state_check_handler,
+                   (unsigned long)padapter);
 }
 
 inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
index bd79e9e7105acc5820439fa7fa6ab9ebea890f9f..cda725a8f9cdf22af090f6a0e35bf7a62cfa949b 100644 (file)
@@ -41,7 +41,7 @@ static u8 rtw_rfc1042_header[] = {
        0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
 };
 
-void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS);
+void rtw_signal_stat_timer_hdl(unsigned long data);
 
 void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
 {
@@ -98,7 +98,9 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter)
 
        res = rtw_hal_init_recv_priv(padapter);
 
-       _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter);
+       setup_timer(&precvpriv->signal_stat_timer,
+                   rtw_signal_stat_timer_hdl,
+                   (unsigned long)padapter);
 
        precvpriv->signal_stat_sampling_interval = 1000; /* ms */
 
@@ -1927,7 +1929,8 @@ static int recv_indicatepkt_reorder(struct adapter *padapter,
 
        /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */
        if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) {
-               _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME);
+               mod_timer(&preorder_ctrl->reordering_ctrl_timer,
+                         jiffies + msecs_to_jiffies(REORDER_WAIT_TIME));
                spin_unlock_bh(&ppending_recvframe_queue->lock);
        } else {
                spin_unlock_bh(&ppending_recvframe_queue->lock);
@@ -1945,9 +1948,9 @@ _err_exit:
        return _FAIL;
 }
 
-void rtw_reordering_ctrl_timeout_handler(void *pcontext)
+void rtw_reordering_ctrl_timeout_handler(unsigned long data)
 {
-       struct recv_reorder_ctrl *preorder_ctrl = pcontext;
+       struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)data;
        struct adapter *padapter = preorder_ctrl->padapter;
        struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
 
@@ -1957,7 +1960,8 @@ void rtw_reordering_ctrl_timeout_handler(void *pcontext)
        spin_lock_bh(&ppending_recvframe_queue->lock);
 
        if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true)
-               _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME);
+               mod_timer(&preorder_ctrl->reordering_ctrl_timer,
+                         jiffies + msecs_to_jiffies(REORDER_WAIT_TIME));
 
        spin_unlock_bh(&ppending_recvframe_queue->lock);
 }
@@ -2130,9 +2134,9 @@ _recv_entry_drop:
        return ret;
 }
 
-void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS)
+void rtw_signal_stat_timer_hdl(unsigned long data)
 {
-       struct adapter *adapter = (struct adapter *)FunctionContext;
+       struct adapter *adapter = (struct adapter *)data;
        struct recv_priv *recvpriv = &adapter->recvpriv;
 
        u32 tmp_s, tmp_q;
@@ -2159,7 +2163,7 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS)
 
                /* update value of signal_strength, rssi, signal_qual */
                if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == false) {
-                       tmp_s = (avg_signal_strength+(_alpha-1)*recvpriv->signal_strength);
+                       tmp_s = avg_signal_strength+(_alpha-1)*recvpriv->signal_strength;
                        if (tmp_s % _alpha)
                                tmp_s = tmp_s/_alpha + 1;
                        else
@@ -2167,7 +2171,7 @@ void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS)
                        if (tmp_s > 100)
                                tmp_s = 100;
 
-                       tmp_q = (avg_signal_qual+(_alpha-1)*recvpriv->signal_qual);
+                       tmp_q = avg_signal_qual+(_alpha-1)*recvpriv->signal_qual;
                        if (tmp_q % _alpha)
                                tmp_q = tmp_q/_alpha + 1;
                        else
index bd8d60a230e9b0fdad18e7c16cd9af17b02c5b5c..d870a5ce858533a4fa2e16e3e12000fe00e24e8d 100644 (file)
@@ -854,7 +854,7 @@ static void mix_column(u8 *in, u8 *out)
        u8 add1b[4];
        u8 add1bf7[4];
        u8 rotl[4];
-       u8 swap_halfs[4];
+       u8 swap_halves[4];
        u8 andf7[4];
        u8 rotr[4];
        u8 temp[4];
@@ -866,10 +866,10 @@ static void mix_column(u8 *in, u8 *out)
                        add1b[i] = 0x00;
        }
 
-       swap_halfs[0] = in[2];    /* Swap halves */
-       swap_halfs[1] = in[3];
-       swap_halfs[2] = in[0];
-       swap_halfs[3] = in[1];
+       swap_halves[0] = in[2];    /* Swap halves */
+       swap_halves[1] = in[3];
+       swap_halves[2] = in[0];
+       swap_halves[3] = in[1];
 
        rotl[0] = in[3];        /* Rotate left 8 bits */
        rotl[1] = in[0];
@@ -900,7 +900,7 @@ static void mix_column(u8 *in, u8 *out)
        rotr[3] = temp[0];
 
        xor_32(add1bf7, rotr, temp);
-       xor_32(swap_halfs, rotl, tempb);
+       xor_32(swap_halves, rotl, tempb);
        xor_32(temp, tempb, out);
 }
 
@@ -1079,7 +1079,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
        uint    frtype  = GetFrameType(pframe);
        uint    frsubtype  = GetFrameSubType(pframe);
 
-       frsubtype = frsubtype>>4;
+       frsubtype >>= 4;
 
        memset((void *)mic_iv, 0, 16);
        memset((void *)mic_header1, 0, 16);
@@ -1122,7 +1122,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
        num_blocks = plen / 16;
 
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
 
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
@@ -1277,7 +1277,7 @@ static int aes_decipher(u8 *key, uint     hdrlen,
 /*     uint    offset = 0; */
        uint    frtype  = GetFrameType(pframe);
        uint    frsubtype  = GetFrameSubType(pframe);
-       frsubtype = frsubtype>>4;
+       frsubtype >>= 4;
 
        memset((void *)mic_iv, 0, 16);
        memset((void *)mic_header1, 0, 16);
@@ -1366,7 +1366,7 @@ static int aes_decipher(u8 *key, uint     hdrlen,
        num_blocks = (plen-8) / 16;
 
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
 
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
index cd4e344e6ffd0c93c94bc6d74c1539cc089910f4..e725a4708775cf7af72119680d09bf551406ae81 100644 (file)
@@ -47,7 +47,7 @@ u8 sreset_get_wifi_status(struct adapter *padapter)
 
        if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) {
                DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status);
-               status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL)));
+               status = psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL));
        }
        DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status);
 
index a3ffc691be9a24396e9967750916e0af5ee03a2b..2b371757cbfe03dc81e5ccba52326e578b5d0faf 100644 (file)
@@ -88,35 +88,25 @@ int cckratesonly_included(unsigned char *rate, int ratelen)
 
 unsigned char networktype_to_raid(unsigned char network_type)
 {
-       unsigned char raid;
-
        switch (network_type) {
        case WIRELESS_11B:
-               raid = RATR_INX_WIRELESS_B;
-               break;
+               return RATR_INX_WIRELESS_B;
        case WIRELESS_11A:
        case WIRELESS_11G:
-               raid = RATR_INX_WIRELESS_G;
-               break;
+               return RATR_INX_WIRELESS_G;
        case WIRELESS_11BG:
-               raid = RATR_INX_WIRELESS_GB;
-               break;
+               return RATR_INX_WIRELESS_GB;
        case WIRELESS_11_24N:
        case WIRELESS_11_5N:
-               raid = RATR_INX_WIRELESS_N;
-               break;
+               return RATR_INX_WIRELESS_N;
        case WIRELESS_11A_5N:
        case WIRELESS_11G_24N:
-               raid = RATR_INX_WIRELESS_NG;
-               break;
+               return  RATR_INX_WIRELESS_NG;
        case WIRELESS_11BG_24N:
-               raid = RATR_INX_WIRELESS_NGB;
-               break;
+               return RATR_INX_WIRELESS_NGB;
        default:
-               raid = RATR_INX_WIRELESS_GB;
-               break;
+               return RATR_INX_WIRELESS_GB;
        }
-       return raid;
 }
 
 u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen)
@@ -146,47 +136,34 @@ u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen
 
 static unsigned char ratetbl_val_2wifirate(unsigned char rate)
 {
-       unsigned char val = 0;
-
        switch (rate & 0x7f) {
        case 0:
-               val = IEEE80211_CCK_RATE_1MB;
-               break;
+               return IEEE80211_CCK_RATE_1MB;
        case 1:
-               val = IEEE80211_CCK_RATE_2MB;
-               break;
+               return IEEE80211_CCK_RATE_2MB;
        case 2:
-               val = IEEE80211_CCK_RATE_5MB;
-               break;
+               return IEEE80211_CCK_RATE_5MB;
        case 3:
-               val = IEEE80211_CCK_RATE_11MB;
-               break;
+               return IEEE80211_CCK_RATE_11MB;
        case 4:
-               val = IEEE80211_OFDM_RATE_6MB;
-               break;
+               return IEEE80211_OFDM_RATE_6MB;
        case 5:
-               val = IEEE80211_OFDM_RATE_9MB;
-               break;
+               return IEEE80211_OFDM_RATE_9MB;
        case 6:
-               val = IEEE80211_OFDM_RATE_12MB;
-               break;
+               return IEEE80211_OFDM_RATE_12MB;
        case 7:
-               val = IEEE80211_OFDM_RATE_18MB;
-               break;
+               return IEEE80211_OFDM_RATE_18MB;
        case 8:
-               val = IEEE80211_OFDM_RATE_24MB;
-               break;
+               return IEEE80211_OFDM_RATE_24MB;
        case 9:
-               val = IEEE80211_OFDM_RATE_36MB;
-               break;
+               return IEEE80211_OFDM_RATE_36MB;
        case 10:
-               val = IEEE80211_OFDM_RATE_48MB;
-               break;
+               return IEEE80211_OFDM_RATE_48MB;
        case 11:
-               val = IEEE80211_OFDM_RATE_54MB;
-               break;
+               return IEEE80211_OFDM_RATE_54MB;
+       default:
+               return 0;
        }
-       return val;
 }
 
 static int is_basicrate(struct adapter *padapter, unsigned char rate)
@@ -485,14 +462,14 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key)
        for (j = 5; j >= 0; j--) {
                switch (j) {
                case 0:
-                       val = (ctrl | (mac[0] << 16) | (mac[1] << 24));
+                       val = ctrl | (mac[0] << 16) | (mac[1] << 24);
                        break;
                case 1:
-                       val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24));
+                       val = mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24);
                        break;
                default:
                        i = (j - 2) << 2;
-                       val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24));
+                       val = key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24);
                        break;
                }
 
@@ -587,7 +564,7 @@ void WMMOnAssocRsp(struct adapter *padapter)
                /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */
                AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime;
 
-               ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f);
+               ECWMin = pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f;
                ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4;
                TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit);
 
@@ -659,8 +636,6 @@ void WMMOnAssocRsp(struct adapter *padapter)
                pxmitpriv->wmm_para_seq[i] = inx[i];
                DBG_88E("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]);
        }
-
-       return;
 }
 
 static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
@@ -766,14 +741,14 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
                } else {
                        /* modify from  fw by Thomas 2010/11/17 */
                        if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3))
-                               max_AMPDU_len = (pIE->data[i] & 0x3);
+                               max_AMPDU_len = pIE->data[i] & 0x3;
                        else
-                               max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3);
+                               max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3;
 
                        if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c))
-                               min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c);
+                               min_MPDU_spacing = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c;
                        else
-                               min_MPDU_spacing = (pIE->data[i] & 0x1c);
+                               min_MPDU_spacing = pIE->data[i] & 0x1c;
 
                        pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing;
                }
@@ -788,7 +763,6 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
                else
                        pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i];
        }
-       return;
 }
 
 void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
@@ -809,7 +783,6 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE)
 
        pmlmeinfo->HT_info_enable = 1;
        memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length);
-       return;
 }
 
 void HTOnAssocRsp(struct adapter *padapter)
@@ -1221,48 +1194,36 @@ unsigned int is_ap_in_wep(struct adapter *padapter)
 
 static int wifirate2_ratetbl_inx(unsigned char rate)
 {
-       int     inx = 0;
        rate = rate & 0x7f;
 
        switch (rate) {
        case 54*2:
-               inx = 11;
-               break;
+               return 11;
        case 48*2:
-               inx = 10;
-               break;
+               return 10;
        case 36*2:
-               inx = 9;
-               break;
+               return 9;
        case 24*2:
-               inx = 8;
-               break;
+               return 8;
        case 18*2:
-               inx = 7;
-               break;
+               return 7;
        case 12*2:
-               inx = 6;
-               break;
+               return 6;
        case 9*2:
-               inx = 5;
-               break;
+               return 5;
        case 6*2:
-               inx = 4;
-               break;
+               return 4;
        case 11*2:
-               inx = 3;
-               break;
+               return 3;
        case 11:
-               inx = 2;
-               break;
+               return 2;
        case 2*2:
-               inx = 1;
-               break;
+               return 1;
        case 1*2:
-               inx = 0;
-               break;
+               return 0;
+       default:
+               return 0;
        }
-       return inx;
 }
 
 unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz)
@@ -1295,7 +1256,7 @@ unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps)
 {
        unsigned int mask = 0;
 
-       mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20));
+       mask = (pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20);
 
        return mask;
 }
@@ -1309,7 +1270,7 @@ int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps)
        if (!(pmlmeinfo->HT_enable))
                return _FAIL;
 
-       if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK))
+       if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)
                return _FAIL;
 
        bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5;
index 7a71df167464ea0ce622936806e13498c9d965b8..7ed60abf4d49e8f776c1fe58fb3bf9d5904c3588 100644 (file)
@@ -1634,7 +1634,8 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
 
        pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
 
-       pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);
+       pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry,
+                                    sizeof(struct hw_xmit), GFP_KERNEL);
 
        hwxmits = pxmitpriv->hwxmits;
 
index 3c651d5c6824e19799f656a2add99b73a1dca9d7..353ff3761a2aee3a20dcf63b14fb33481e4122f2 100644 (file)
@@ -487,7 +487,7 @@ static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo)
                        break;
        }
 
-       j = j >> 1;
+       j >>= 1;
        temp_stage = (pRaInfo->PTStage + 1) >> 1;
        if (temp_stage > j)
                stage_id = temp_stage-j;
@@ -538,6 +538,7 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid)
        struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid];
        u8 WirelessMode = 0xFF; /* invalid value */
        u8 max_rate_idx = 0x13; /* MCS7 */
+
        if (dm_odm->pWirelessMode != NULL)
                WirelessMode = *(dm_odm->pWirelessMode);
 
@@ -618,7 +619,7 @@ u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid)
 
        if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM))
                return 0;
-       DecisionRate = (dm_odm->RAInfo[macid].DecisionRate);
+       DecisionRate = dm_odm->RAInfo[macid].DecisionRate;
        ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
                (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate));
        return DecisionRate;
@@ -630,7 +631,7 @@ u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid)
 
        if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM))
                return 0;
-       PTStage = (dm_odm->RAInfo[macid].PTStage);
+       PTStage = dm_odm->RAInfo[macid].PTStage;
        ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
                     ("macid =%d PTStage = 0x%x\n", macid, PTStage));
        return PTStage;
index 1e963bf9e48bc928347ff156d7be1adbd960fbec..2d3d012d3736a925138a15732b6c696f879d2e02 100644 (file)
@@ -511,62 +511,71 @@ static u32 array_phy_reg_pg_8188e[] = {
 static void store_pwrindex_offset(struct adapter *Adapter, u32 regaddr, u32 bitmask, u32 data)
 {
        struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter);
+        u8 pwrGrpCnt = hal_data->pwrGroupCnt;
 
        if (regaddr == rTxAGC_A_Rate18_06)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][0] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][0] = data;
        if (regaddr == rTxAGC_A_Rate54_24)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][1] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][1] = data;
        if (regaddr == rTxAGC_A_CCK1_Mcs32)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][6] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][6] = data;
        if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][7] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][7] = data;
        if (regaddr == rTxAGC_A_Mcs03_Mcs00)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][2] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][2] = data;
        if (regaddr == rTxAGC_A_Mcs07_Mcs04)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][3] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][3] = data;
        if (regaddr == rTxAGC_A_Mcs11_Mcs08)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][4] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][4] = data;
        if (regaddr == rTxAGC_A_Mcs15_Mcs12) {
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][5] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][5] = data;
                if (hal_data->rf_type == RF_1T1R)
                        hal_data->pwrGroupCnt++;
        }
        if (regaddr == rTxAGC_B_Rate18_06)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][8] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][8] = data;
        if (regaddr == rTxAGC_B_Rate54_24)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][9] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][9] = data;
        if (regaddr == rTxAGC_B_CCK1_55_Mcs32)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][14] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][14] = data;
        if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][15] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][15] = data;
        if (regaddr == rTxAGC_B_Mcs03_Mcs00)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][10] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][10] = data;
        if (regaddr == rTxAGC_B_Mcs07_Mcs04)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][11] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][11] = data;
        if (regaddr == rTxAGC_B_Mcs11_Mcs08)
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][12] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][12] = data;
        if (regaddr == rTxAGC_B_Mcs15_Mcs12) {
-               hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt][13] = data;
+               hal_data->MCSTxPowerLevelOriginalOffset[pwrGrpCnt][13] = data;
                if (hal_data->rf_type != RF_1T1R)
                        hal_data->pwrGroupCnt++;
        }
 }
 
-static void rtl_addr_delay(struct adapter *adapt, u32 addr, u32 bit_mask, u32 data)
+static void rtl_addr_delay(struct adapter *adapt,
+                       u32 addr, u32 bit_mask, u32 data)
 {
-       if (addr == 0xfe) {
+       switch (addr) {
+       case 0xfe:
                msleep(50);
-       } else if (addr == 0xfd) {
+               break;
+       case 0xfd:
                mdelay(5);
-       } else if (addr == 0xfc) {
+               break;
+       case 0xfc:
                mdelay(1);
-       } else if (addr == 0xfb) {
+               break;
+       case 0xfb:
                udelay(50);
-       } else if (addr == 0xfa) {
+               break;
+       case 0xfa:
                udelay(5);
-       } else if (addr == 0xf9) {
+               break;
+       case 0xf9:
                udelay(1);
-       } else{
+               break;
+       default:
                store_pwrindex_offset(adapt, addr, bit_mask, data);
        }
 }
index 3b2875481fc5bb7e6819e8fd0e5be105a72dba5b..a71c54295508b05e245b5de1a7dce1105ba0be69 100644 (file)
@@ -154,9 +154,8 @@ static int _rtl88e_fw_free_to_go(struct adapter *adapt)
                        break;
        } while (counter++ < POLLING_READY_TIMEOUT_COUNT);
 
-       if (counter >= POLLING_READY_TIMEOUT_COUNT) {
+       if (counter >= POLLING_READY_TIMEOUT_COUNT)
                goto exit;
-       }
 
        value32 = usb_read32(adapt, REG_MCUFWDL);
        value32 |= MCUFWDL_RDY;
index 06477e8346535cd60a50ebba8e08c74406e62cef..28b5e7bd4fc0223beddd07102ce3d116bf0b116b 100644 (file)
@@ -741,13 +741,13 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm)
 
        ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
        FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16);
+       FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0xffff0000)>>16;
        ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
        FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16);
+       FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0xffff0000)>>16;
        ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
        FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16);
+       FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0xffff0000)>>16;
        ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
        FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff);
 
@@ -757,7 +757,7 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm)
 
        ret_value = phy_query_bb_reg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord);
        FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16);
+       FalseAlmCnt->Cnt_BW_USC = (ret_value & 0xffff0000)>>16;
 
        /* hold cck counter */
        phy_set_bb_reg(adapter, ODM_REG_CCK_FA_RST_11N, BIT12, 1);
index 29f87dffbad374857a9ea755afc76e9b5f61abfb..36afe45d1c9a6dc11102cbbb3ee13cf1df4572c6 100644 (file)
@@ -123,8 +123,8 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm,
                /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */
                /* The RSSI formula should be modified according to the gain table */
                /* In 88E, cck_highpwr is always set to 1 */
-               LNA_idx = ((cck_agc_rpt & 0xE0) >> 5);
-               VGA_idx = (cck_agc_rpt & 0x1F);
+               LNA_idx = (cck_agc_rpt & 0xE0) >> 5;
+               VGA_idx = cck_agc_rpt & 0x1F;
                switch (LNA_idx) {
                case 7:
                        if (VGA_idx <= 27)
index 3f663fe151ba9125c7e1c8754c8ce4d139d42870..6e4c3ee0399a42b579cb421b381ad8dc7444c346 100644 (file)
@@ -60,7 +60,7 @@ void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data)
        if (bitmask != bMaskDWord) { /* if not "double word" write */
                original_value = usb_read32(adapt, regaddr);
                bit_shift = cal_bit_shift(bitmask);
-               data = ((original_value & (~bitmask)) | (data << bit_shift));
+               data = (original_value & (~bitmask)) | (data << bit_shift);
        }
 
        usb_write32(adapt, regaddr, data);
@@ -72,12 +72,10 @@ static u32 rf_serial_read(struct adapter *adapt,
        u32 ret = 0;
        struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
        struct bb_reg_def *phyreg = &hal_data->PHYRegDef[rfpath];
-       u32 newoffset;
        u32 tmplong, tmplong2;
        u8 rfpi_enable = 0;
 
        offset &= 0xff;
-       newoffset = offset;
 
        tmplong = phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord);
        if (rfpath == RF_PATH_A)
@@ -87,7 +85,7 @@ static u32 rf_serial_read(struct adapter *adapt,
                                            bMaskDWord);
 
        tmplong2 = (tmplong2 & (~bLSSIReadAddress)) |
-                  (newoffset<<23) | bLSSIReadEdge;
+                  (offset<<23) | bLSSIReadEdge;
 
        phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord,
                       tmplong&(~bLSSIReadEdge));
@@ -119,10 +117,9 @@ static void rf_serial_write(struct adapter *adapt,
        u32 data_and_addr = 0;
        struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
        struct bb_reg_def *phyreg = &hal_data->PHYRegDef[rfpath];
-       u32 newoffset;
 
-       newoffset = offset & 0xff;
-       data_and_addr = ((newoffset<<20) | (data&0x000fffff)) & 0x0fffffff;
+       offset &= 0xff;
+       data_and_addr = ((offset<<20) | (data&0x000fffff)) & 0x0fffffff;
        phy_set_bb_reg(adapt, phyreg->rf3wireOffset, bMaskDWord, data_and_addr);
 }
 
@@ -146,7 +143,7 @@ void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path,
        if (bit_mask != bRFRegOffsetMask) {
                original_value = rf_serial_read(adapt, rf_path, reg_addr);
                bit_shift =  cal_bit_shift(bit_mask);
-               data = ((original_value & (~bit_mask)) | (data << bit_shift));
+               data = (original_value & (~bit_mask)) | (data << bit_shift);
        }
 
        rf_serial_write(adapt, rf_path, reg_addr, data);
@@ -304,21 +301,8 @@ static void phy_set_bw_mode_callback(struct adapter *adapt)
        }
 
        /* Set RF related register */
-       switch (hal_data->rf_chip) {
-       case RF_8225:
-               break;
-       case RF_8256:
-               break;
-       case RF_8258:
-               break;
-       case RF_PSEUDO_11N:
-               break;
-       case RF_6052:
+       if (hal_data->rf_chip == RF_6052)
                rtl88eu_phy_rf6052_set_bandwidth(adapt, hal_data->CurrentChannelBW);
-               break;
-       default:
-               break;
-       }
 }
 
 void phy_set_bw_mode(struct adapter *adapt, enum ht_channel_width bandwidth,
@@ -361,7 +345,6 @@ void phy_sw_chnl(struct adapter *adapt, u8 channel)
 {
        struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
        u8 tmpchannel = hal_data->CurrentChannel;
-       bool  result = true;
 
        if (hal_data->rf_chip == RF_PSEUDO_11N)
                return;
@@ -371,34 +354,28 @@ void phy_sw_chnl(struct adapter *adapt, u8 channel)
 
        hal_data->CurrentChannel = channel;
 
-       if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved)) {
+       if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved))
                phy_sw_chnl_callback(adapt, channel);
-
-               if (!result)
-                       hal_data->CurrentChannel = tmpchannel;
-
-       } else {
+       else
                hal_data->CurrentChannel = tmpchannel;
-       }
 }
 
 #define ODM_TXPWRTRACK_MAX_IDX_88E  6
 
 static u8 get_right_chnl_for_iqk(u8 chnl)
 {
+       u8 place;
        u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = {
-               1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64,
                100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122,
                124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153,
                155, 157, 159, 161, 163, 165
        };
-       u8 place = chnl;
 
        if (chnl > 14) {
-               for (place = 14; place < sizeof(channel_all); place++) {
+               for (place = 0; place < sizeof(channel_all); place++) {
                        if (channel_all[place] == chnl)
-                               return place-13;
+                               return ++place;
                }
        }
        return 0;
@@ -416,12 +393,12 @@ void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, u8 type,
 
                if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) {
                        *direction = 1;
-                       pwr_value = (dm_odm->BbSwingIdxOfdmBase -
-                                    dm_odm->BbSwingIdxOfdm);
+                       pwr_value = dm_odm->BbSwingIdxOfdmBase -
+                                    dm_odm->BbSwingIdxOfdm;
                } else {
                        *direction = 2;
-                       pwr_value = (dm_odm->BbSwingIdxOfdm -
-                                    dm_odm->BbSwingIdxOfdmBase);
+                       pwr_value = dm_odm->BbSwingIdxOfdm -
+                                    dm_odm->BbSwingIdxOfdmBase;
                }
 
        } else if (type == 1) { /* For CCK adjust. */
@@ -431,12 +408,12 @@ void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, u8 type,
 
                if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) {
                        *direction = 1;
-                       pwr_value = (dm_odm->BbSwingIdxCckBase -
-                                    dm_odm->BbSwingIdxCck);
+                       pwr_value = dm_odm->BbSwingIdxCckBase -
+                                    dm_odm->BbSwingIdxCck;
                } else {
                        *direction = 2;
-                       pwr_value = (dm_odm->BbSwingIdxCck -
-                                    dm_odm->BbSwingIdxCckBase);
+                       pwr_value = dm_odm->BbSwingIdxCck -
+                                    dm_odm->BbSwingIdxCckBase;
                }
 
        }
@@ -465,15 +442,13 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
        u8 thermal_val = 0, delta, delta_lck, delta_iqk, offset;
        u8 thermal_avg_count = 0;
        u32 thermal_avg = 0;
-       s32 ele_a = 0, ele_d, temp_cck, x, value32;
-       s32 y, ele_c = 0;
+       s32 ele_d, temp_cck;
        s8 ofdm_index[2], cck_index = 0;
        s8 ofdm_index_old[2] = {0, 0}, cck_index_old = 0;
        u32 i = 0, j = 0;
        bool is2t = false;
 
        u8 ofdm_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB */
-       u8 indexforchannel = 0;
        s8 ofdm_index_mapping[2][index_mapping_NUM_88E] = {
                /* 2.4G, decrease power */
                {0, 0, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11},
@@ -529,18 +504,12 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                temp_cck = dm_odm->RFCalibrateInfo.RegA24;
 
                for (i = 0; i < CCK_TABLE_SIZE; i++) {
-                       if (dm_odm->RFCalibrateInfo.bCCKinCH14) {
-                               if (memcmp(&temp_cck, &CCKSwingTable_Ch14[i][2], 4)) {
-                                       cck_index_old = (u8)i;
-                                       dm_odm->BbSwingIdxCckBase = (u8)i;
-                                       break;
-                               }
-                       } else {
-                               if (memcmp(&temp_cck, &CCKSwingTable_Ch1_Ch13[i][2], 4)) {
+                       if ((dm_odm->RFCalibrateInfo.bCCKinCH14 &&
+                               memcmp(&temp_cck, &CCKSwingTable_Ch14[i][2], 4)) ||
+                               memcmp(&temp_cck, &CCKSwingTable_Ch1_Ch13[i][2], 4)) {
                                        cck_index_old = (u8)i;
                                        dm_odm->BbSwingIdxCckBase = (u8)i;
                                        break;
-                               }
                        }
                }
 
@@ -570,27 +539,19 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                if (thermal_avg_count)
                        thermal_val = (u8)(thermal_avg / thermal_avg_count);
 
-               if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) {
-                       delta = thermal_val > hal_data->EEPROMThermalMeter ?
-                               (thermal_val - hal_data->EEPROMThermalMeter) :
-                               (hal_data->EEPROMThermalMeter - thermal_val);
-                       dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false;
-                       dm_odm->RFCalibrateInfo.bDoneTxpower = false;
-               } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) {
-                       delta = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue) ?
-                               (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue) :
-                               (dm_odm->RFCalibrateInfo.ThermalValue - thermal_val);
-               } else {
-                       delta = thermal_val > hal_data->EEPROMThermalMeter ?
-                               (thermal_val - hal_data->EEPROMThermalMeter) :
-                               (hal_data->EEPROMThermalMeter - thermal_val);
+               if (dm_odm->RFCalibrateInfo.bDoneTxpower &&
+                       !dm_odm->RFCalibrateInfo.bReloadtxpowerindex)
+                       delta = abs(thermal_val - dm_odm->RFCalibrateInfo.ThermalValue);
+               else {
+                       delta = abs(thermal_val - hal_data->EEPROMThermalMeter);
+                       if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) {
+                               dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false;
+                               dm_odm->RFCalibrateInfo.bDoneTxpower = false;
+                       }
                }
-               delta_lck = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ?
-                           (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue_LCK) :
-                           (dm_odm->RFCalibrateInfo.ThermalValue_LCK - thermal_val);
-               delta_iqk = (thermal_val > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ?
-                           (thermal_val - dm_odm->RFCalibrateInfo.ThermalValue_IQK) :
-                           (dm_odm->RFCalibrateInfo.ThermalValue_IQK - thermal_val);
+
+               delta_lck = abs(dm_odm->RFCalibrateInfo.ThermalValue_LCK - thermal_val);
+               delta_iqk = abs(dm_odm->RFCalibrateInfo.ThermalValue_IQK - thermal_val);
 
                /* Delta temperature is equal to or larger than 20 centigrade.*/
                if ((delta_lck >= 8)) {
@@ -599,9 +560,8 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                }
 
                if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) {
-                       delta = thermal_val > hal_data->EEPROMThermalMeter ?
-                               (thermal_val - hal_data->EEPROMThermalMeter) :
-                               (hal_data->EEPROMThermalMeter - thermal_val);
+                       delta = abs(hal_data->EEPROMThermalMeter - thermal_val);
+
                        /* calculate new OFDM / CCK offset */
                        if (thermal_val > hal_data->EEPROMThermalMeter)
                                j = 1;
@@ -616,17 +576,17 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                        }
                        if (offset >= index_mapping_NUM_88E)
                                offset = index_mapping_NUM_88E-1;
-                       for (i = 0; i < rf; i++)
-                               ofdm_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + ofdm_index_mapping[j][offset];
-                       cck_index = dm_odm->RFCalibrateInfo.CCK_index + ofdm_index_mapping[j][offset];
 
+                       /* Updating ofdm_index values with new OFDM / CCK offset */
                        for (i = 0; i < rf; i++) {
+                               ofdm_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + ofdm_index_mapping[j][offset];
                                if (ofdm_index[i] > OFDM_TABLE_SIZE_92D-1)
                                        ofdm_index[i] = OFDM_TABLE_SIZE_92D-1;
                                else if (ofdm_index[i] < ofdm_min_index)
                                        ofdm_index[i] = ofdm_min_index;
                        }
 
+                       cck_index = dm_odm->RFCalibrateInfo.CCK_index + ofdm_index_mapping[j][offset];
                        if (cck_index > CCK_TABLE_SIZE-1)
                                cck_index = CCK_TABLE_SIZE-1;
                        else if (cck_index < 0)
@@ -637,11 +597,6 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                        if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) {
                                dm_odm->RFCalibrateInfo.bDoneTxpower = true;
 
-                               /* Adujst OFDM Ant_A according to IQK result */
-                               ele_d = (OFDMSwingTable[(u8)ofdm_index[0]] & 0xFFC00000)>>22;
-                               x = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][0];
-                               y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][1];
-
                                /*  Revse TX power table. */
                                dm_odm->BbSwingIdxOfdm = (u8)ofdm_index[0];
                                dm_odm->BbSwingIdxCck = (u8)cck_index;
@@ -655,53 +610,6 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt)
                                        dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck;
                                        dm_odm->BbSwingFlagCck = true;
                                }
-
-                               if (x != 0) {
-                                       if ((x & 0x00000200) != 0)
-                                               x = x | 0xFFFFFC00;
-                                       ele_a = ((x * ele_d)>>8)&0x000003FF;
-
-                                       /* new element C = element D x Y */
-                                       if ((y & 0x00000200) != 0)
-                                               y = y | 0xFFFFFC00;
-                                       ele_c = ((y * ele_d)>>8)&0x000003FF;
-
-                               }
-
-                               if (is2t) {
-                                       ele_d = (OFDMSwingTable[(u8)ofdm_index[1]] & 0xFFC00000)>>22;
-
-                                       /* new element A = element D x X */
-                                       x = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][4];
-                                       y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[indexforchannel].Value[0][5];
-
-                                       if ((x != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) {
-                                               if ((x & 0x00000200) != 0)      /* consider minus */
-                                                       x = x | 0xFFFFFC00;
-                                               ele_a = ((x * ele_d)>>8)&0x000003FF;
-
-                                               /* new element C = element D x Y */
-                                               if ((y & 0x00000200) != 0)
-                                                       y = y | 0xFFFFFC00;
-                                               ele_c = ((y * ele_d)>>8)&0x00003FF;
-
-                                               /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */
-                                               value32 = (ele_d<<22) | ((ele_c&0x3F)<<16) | ele_a;
-                                               phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord, value32);
-
-                                               value32 = (ele_c&0x000003C0)>>6;
-                                               phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, bMaskH4Bits, value32);
-
-                                               value32 = ((x * ele_d)>>7)&0x01;
-                                               phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT28, value32);
-                                       } else {
-                                               phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)ofdm_index[1]]);
-                                               phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00);
-                                               phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT28, 0x00);
-                                       }
-
-                               }
-
                        }
                }
 
@@ -1033,11 +941,11 @@ static void path_adda_on(struct adapter *adapt, u32 *adda_reg,
        u32 path_on;
        u32 i;
 
-       path_on = is_path_a_on ? 0x04db25a4 : 0x0b1b25a4;
        if (!is2t) {
                path_on = 0x0bdb25a0;
                phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, 0x0b1b25a0);
        } else {
+               path_on = is_path_a_on ? 0x04db25a4 : 0x0b1b25a4;
                phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, path_on);
        }
 
@@ -1077,27 +985,19 @@ static void pi_mode_switch(struct adapter *adapt, bool pi_mode)
 static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
                               u8 c1, u8 c2)
 {
-       u32 i, j, diff, sim_bitmap, bound = 0;
+       u32 i, j, diff, sim_bitmap = 0, bound;
        struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
        struct odm_dm_struct *dm_odm = &hal_data->odmpriv;
        u8 final_candidate[2] = {0xFF, 0xFF};   /* for path A and path B */
        bool result = true;
-       bool is2t;
        s32 tmp1 = 0, tmp2 = 0;
 
        if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) ||
            (dm_odm->RFType == ODM_2T4R))
-               is2t = true;
-       else
-               is2t = false;
-
-       if (is2t)
                bound = 8;
        else
                bound = 4;
 
-       sim_bitmap = 0;
-
        for (i = 0; i < bound; i++) {
                if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
                        if ((resulta[c1][i] & 0x00000200) != 0)
index be0663e93f611d9ea1d0f756153483fe60c80ea6..73e1f8b36b37d255e6c6e08b8f22b505ebcce5ff 100644 (file)
@@ -109,7 +109,6 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers,
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
                                         ("rtl88eu_pwrseqcmdparsing: PWR_CMD_END\n"));
                                return true;
-                               break;
                        default:
                                RT_TRACE(_module_hal_init_c_, _drv_err_,
                                         ("rtl88eu_pwrseqcmdparsing: Unknown CMD!!\n"));
index eea4c8a6022b6643d6164a09102ceb6ed07bc8d1..097092772a860d4b66845394ab0ca46e3b005b09 100644 (file)
@@ -201,7 +201,7 @@ static void get_rx_power_val_by_reg(struct adapter *adapt, u8 channel,
                        break;
                case 2: /*  Better regulatory */
                                /*  don't increase any power diff */
-                       write_val = ((index < 2) ? powerbase0[rf] : powerbase1[rf]);
+                       write_val = (index < 2) ? powerbase0[rf] : powerbase1[rf];
                        break;
                case 3: /*  Customer defined power diff. */
                                /*  increase power diff defined by customer. */
index 5dc11cae2ef992e6e541161ac67423ba9bc629e5..455ecdc8d9fa7c8a0d78c5d11a4049a9142f4d11 100644 (file)
@@ -38,12 +38,12 @@ static bool check_condition(struct adapter *adapt, const u32  condition)
                return false;
 
        cond = condition & 0x0000FF00;
-       cond = cond >> 8;
+       cond >>= 8;
        if ((_interface & cond) == 0 && cond != 0x07)
                return false;
 
        cond = condition & 0x00FF0000;
-       cond = cond >> 16;
+       cond >>= 16;
        if ((_platform & cond) == 0 && cond != 0x0F)
                return false;
        return true;
index 3222d8d08b5b2d306ebf1e94ef5d8436c00e6e67..7904d2260f2cfd6b0f0e2eafeb1727ddab5683e7 100644 (file)
@@ -596,7 +596,8 @@ void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoL
        struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter);
 
        if (!AutoLoadFail)
-               pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E]&0xE0)>>5);
+               pHalData->BoardType = (hwinfo[EEPROM_RF_BOARD_OPTION_88E]
+                                       & 0xE0) >> 5;
        else
                pHalData->BoardType = 0;
        DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType);
index bc275b2a7d37f66431268ee0629e73dca34046b6..06d1e654483e2c4426a4c9c25dd0b830275aed2a 100644 (file)
@@ -42,7 +42,7 @@ int   rtl8188eu_init_recv_priv(struct adapter *padapter)
        _rtw_init_queue(&precvpriv->free_recv_buf_queue);
 
        precvpriv->pallocated_recv_buf =
-               kzalloc(NR_RECVBUFF * sizeof(struct recv_buf), GFP_KERNEL);
+               kcalloc(NR_RECVBUFF, sizeof(struct recv_buf), GFP_KERNEL);
        if (precvpriv->pallocated_recv_buf == NULL) {
                res = _FAIL;
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
index 14650e91c78a55f4765e520a9c3c58b9275b4a4c..7b01d5aa6b23e023f61c6f9fe74de93a4690405c 100644 (file)
@@ -1096,10 +1096,8 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool
                memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN);
        }
        RT_TRACE(_module_hci_hal_init_c_, _drv_notice_,
-                ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
-                eeprom->mac_addr[0], eeprom->mac_addr[1],
-                eeprom->mac_addr[2], eeprom->mac_addr[3],
-                eeprom->mac_addr[4], eeprom->mac_addr[5]));
+                ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %pM\n",
+                eeprom->mac_addr));
 }
 
 static void
@@ -1352,7 +1350,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val)
 
                        /*  Set RTS initial rate */
                        while (BrateCfg > 0x1) {
-                               BrateCfg = (BrateCfg >> 1);
+                               BrateCfg >>= 1;
                                RateIndex++;
                        }
                        /*  Ziv - Check */
index 3299571e339f891b781cc04071ec50a8919bcbf2..8fd35dcdbb94b28fb387c260ea4df4f6f090938e 100644 (file)
@@ -122,7 +122,6 @@ enum {
 
 #define WPA_SELECTOR_LEN 4
 extern u8 RTW_WPA_OUI_TYPE[];
-extern u16 RTW_WPA_VERSION;
 extern u8 WPA_AUTH_KEY_MGMT_NONE[];
 extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[];
 extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[];
index 3a274770364b01023303e6236c9419f956df84ff..515e949629e27886376fdb3ee9c6eb21bd86e3c4 100644 (file)
@@ -76,25 +76,6 @@ static inline int _enter_critical_mutex(struct mutex *pmutex,
        return ret;
 }
 
-static inline void _init_timer(struct timer_list *ptimer,
-                              struct  net_device *nic_hdl,
-                              void *pfunc, void *cntx)
-{
-       ptimer->function = pfunc;
-       ptimer->data = (unsigned long)cntx;
-       init_timer(ptimer);
-}
-
-static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
-{
-       mod_timer(ptimer , (jiffies+msecs_to_jiffies(delay_time)));
-}
-
-#define RTW_TIMER_HDL_ARGS void *FunctionContext
-#define RTW_TIMER_HDL_NAME(name) rtw_##name##_timer_hdl
-#define RTW_DECLARE_TIMER_HDL(name) \
-       void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS)
-
 static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
 {
        return  netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
index 23f0cfe312f365963ba397bb7e593634b247290f..7a5303d50d4978daaf2a55f713a851be29fc7792 100644 (file)
@@ -103,7 +103,7 @@ struct led_priv {
                        (adapt)->ledpriv.LedControlHandler((adapt), (action)); \
        } while (0)
 
-void BlinkTimerCallback(void *data);
+void BlinkTimerCallback(unsigned long data);
 void BlinkWorkItemCallback(struct work_struct *work);
 
 void ResetLedStatus(struct LED_871x *pLed);
index 8d83f7ceda760207c352b5323eec8522ff74b5b2..3f7d1e631ef9636173d8de3270ead75ebb50096c 100644 (file)
@@ -551,10 +551,10 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter);
 
 void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter);
 
-void _rtw_join_timeout_handler(void *function_context);
-void rtw_scan_timeout_handler(void *function_context);
+void _rtw_join_timeout_handler(unsigned long data);
+void rtw_scan_timeout_handler(unsigned long data);
 
-void rtw_dynamic_check_timer_handlder(void *function_context);
+void rtw_dynamic_check_timer_handlder(unsigned long data);
 #define rtw_is_scan_deny(adapter) false
 #define rtw_clear_scan_deny(adapter) do {} while (0)
 #define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0)
index 4f05aee93c9cb5edbb1968c3474fb182230ac9c5..2bebf46b053af68a34ed97952786cfe8512d6336 100644 (file)
@@ -645,19 +645,17 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter,
 
 void linked_status_chk(struct adapter *padapter);
 
-void survey_timer_hdl(void *function_context);
-void link_timer_hdl(void *funtion_context);
-void addba_timer_hdl(void *function_context);
+void survey_timer_hdl(unsigned long data);
+void link_timer_hdl(unsigned long data);
+void addba_timer_hdl(unsigned long data);
 
 #define set_survey_timer(mlmeext, ms) \
-       do { \
-               _set_timer(&(mlmeext)->survey_timer, (ms)); \
-       } while (0)
+       mod_timer(&mlmeext->survey_timer, jiffies +     \
+                 msecs_to_jiffies(ms))
 
 #define set_link_timer(mlmeext, ms) \
-       do { \
-               _set_timer(&(mlmeext)->link_timer, (ms)); \
-       } while (0)
+       mod_timer(&mlmeext->link_timer, jiffies +       \
+                 msecs_to_jiffies(ms))
 
 int cckrates_included(unsigned char *rate, int ratelen);
 int cckratesonly_included(unsigned char *rate, int ratelen);
index 54dfbf07564bc1b7938402aa36eeb3a6efeca027..aa1fd87c47fba84c561b386f42117176d833ccc0 100644 (file)
@@ -233,9 +233,8 @@ struct pwrctrl_priv {
 #define RTW_PWR_STATE_CHK_INTERVAL 2000
 
 #define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \
-       do { \
-               _set_timer(&(pwrctrlpriv)->pwr_state_check_timer, (ms)); \
-       } while (0)
+       mod_timer(&pwrctrlpriv->pwr_state_check_timer,  \
+                 jiffies + msecs_to_jiffies(ms))
 
 #define rtw_set_pwr_state_check_timer(pwrctrl)                 \
        _rtw_set_pwr_state_check_timer((pwrctrl),               \
index f0c26ef8f66a08afd06d6fbb0d5f7ffc16044813..eb1ac3d03123f952da9db9008f72e24a17b3e086 100644 (file)
@@ -216,8 +216,8 @@ struct recv_priv {
 };
 
 #define rtw_set_signal_stat_timer(recvpriv)                    \
-       _set_timer(&(recvpriv)->signal_stat_timer,              \
-                  (recvpriv)->signal_stat_sampling_interval)
+       mod_timer(&(recvpriv)->signal_stat_timer, jiffies +     \
+                 msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval))
 
 struct sta_recv_priv {
        spinlock_t lock;
@@ -278,7 +278,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,
                              struct __queue *pfree_recv_queue);
 u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter);
 
-void rtw_reordering_ctrl_timeout_handler(void *pcontext);
+void rtw_reordering_ctrl_timeout_handler(unsigned long data);
 
 static inline u8 *get_rxmem(struct recv_frame *precvframe)
 {
index 66d60aaf4ae8545727b9918adfe209374a5eb29c..e9723a72af5e5269de655e2188e2c1484444d473 100644 (file)
@@ -245,10 +245,6 @@ struct mic_data {
 };
 
 extern const u32 Te0[256];
-extern const u32 Te1[256];
-extern const u32 Te2[256];
-extern const u32 Te3[256];
-extern const u32 Te4[256];
 extern const u32 Td0[256];
 extern const u32 Td1[256];
 extern const u32 Td2[256];
@@ -269,28 +265,6 @@ static inline u32 rotr(u32 val, int bits)
 #define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8)
 #define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16)
 #define TE3(i) rotr(Te0[(i) & 0xff], 24)
-#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000)
-#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000)
-#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00)
-#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff)
-#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000)
-#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000)
-#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00)
-#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff)
-#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff)
-
-#define TD0(i) Td0[((i) >> 24) & 0xff]
-#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8)
-#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16)
-#define TD3(i) rotr(Td0[(i) & 0xff], 24)
-#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24)
-#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16)
-#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8)
-#define TD44(i) (Td4s[(i) & 0xff])
-#define TD0_(i) Td0[(i) & 0xff]
-#define TD1_(i) rotr(Td0[(i) & 0xff], 8)
-#define TD2_(i) rotr(Td0[(i) & 0xff], 16)
-#define TD3_(i) rotr(Td0[(i) & 0xff], 24)
 
 #define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \
                        ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))
index 8dbdfafd52b55e3a86db5632c00511d9891a1a34..a89275e0e0e054053707b9277efd4a7fa98dab6c 100644 (file)
@@ -301,22 +301,12 @@ enum WIFI_REG_DOMAIN {
 #define GetPrivacy(pbuf)                                       \
        (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
 
-#define ClearPrivacy(pbuf)     \
-       *(__le16 *)(pbuf) &= (~cpu_to_le16(_PRIVACY_))
-
-
 #define GetOrder(pbuf)                                 \
        (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0)
 
 #define GetFrameType(pbuf)                             \
        (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
 
-#define SetFrameType(pbuf, type)       \
-       do {    \
-               *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \
-               *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
-       } while (0)
-
 #define GetFrameSubType(pbuf)  (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\
         BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2)))
 
@@ -333,17 +323,6 @@ enum WIFI_REG_DOMAIN {
 #define GetFragNum(pbuf)                       \
        (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f)
 
-#define GetTupleCache(pbuf)                    \
-       (cpu_to_le16(*(unsigned short *)((size_t)(pbuf) + 22)))
-
-#define SetFragNum(pbuf, num) \
-       do {    \
-               *(unsigned short *)((size_t)(pbuf) + 22) = \
-                       ((*(unsigned short *)((size_t)(pbuf) + 22)) &   \
-                       le16_to_cpu(~(0x000f))) | \
-                       cpu_to_le16(0x0f & (num));     \
-       } while (0)
-
 #define SetSeqNum(pbuf, num) \
        do {    \
                *(__le16 *)((size_t)(pbuf) + 22) = \
@@ -370,15 +349,8 @@ enum WIFI_REG_DOMAIN {
 
 #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
 
-#define SetAMsdu(pbuf, amsdu)  \
-       *(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7)
-
 #define GetAid(pbuf)   (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
 
-#define GetTid(pbuf)   (le16_to_cpu(*(__le16 *)((size_t)(pbuf) +       \
-                       (((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ?    \
-                       30 : 24))) & 0x000f)
-
 #define GetAddr1Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 4))
 
 #define GetAddr2Ptr(pbuf)      ((unsigned char *)((size_t)(pbuf) + 10))
@@ -916,7 +888,7 @@ enum ht_cap_ampdu_factor {
 #define        P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION           0x0A
 #define        P2P_STATUS_FAIL_USER_REJECT                     0x0B
 
-/*     Value of Inviation Flags Attribute */
+/*     Value of Invitation Flags Attribute */
 #define        P2P_INVITATION_FLAGS_PERSISTENT                 BIT(0)
 
 #define        DMP_P2P_DEVCAP_SUPPORT  (P2P_DEVCAP_SERVICE_DISCOVERY | \
@@ -970,7 +942,7 @@ enum ht_cap_ampdu_factor {
 
 #define        P2P_WILDCARD_SSID_LEN                   7
 
-/* default value, used when: (1)p2p disabed or (2)p2p enabled
+/* default value, used when: (1)p2p disabled or (2)p2p enabled
  * but only do 1 scan phase */
 #define        P2P_FINDPHASE_EX_NONE           0
 /*  used when p2p enabled and want to do 1 scan phase and
@@ -1035,13 +1007,13 @@ enum P2P_STATE {
        P2P_STATE_TX_PROVISION_DIS_REQ = 6,
        P2P_STATE_RX_PROVISION_DIS_RSP = 7,
        P2P_STATE_RX_PROVISION_DIS_REQ = 8,
-       /* Doing the group owner negoitation handshake */
+       /* Doing the group owner negotiation handshake */
        P2P_STATE_GONEGO_ING = 9,
-       /* finish the group negoitation handshake with success */
+       /* finish the group negotiation handshake with success */
        P2P_STATE_GONEGO_OK = 10,
-       /* finish the group negoitation handshake with failure */
+       /* finish the group negotiation handshake with failure */
        P2P_STATE_GONEGO_FAIL = 11,
-       /* receiving the P2P Inviation request and match with the profile. */
+       /* receiving the P2P Invitation request and match with the profile. */
        P2P_STATE_RECV_INVITE_REQ_MATCH = 12,
        /* Doing the P2P WPS */
        P2P_STATE_PROVISIONING_ING = 13,
@@ -1051,17 +1023,17 @@ enum P2P_STATE {
        P2P_STATE_TX_INVITE_REQ = 15,
        /* Receiving the P2P Invitation response */
        P2P_STATE_RX_INVITE_RESP_OK = 16,
-       /* receiving the P2P Inviation request and dismatch with the profile. */
+       /* receiving the P2P Invitation request and dismatch with the profile. */
        P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,
-       /* receiving the P2P Inviation request and this wifi is GO. */
+       /* receiving the P2P Invitation request and this wifi is GO. */
        P2P_STATE_RECV_INVITE_REQ_GO = 18,
-       /* receiving the P2P Inviation request to join an existing P2P Group. */
+       /* receiving the P2P Invitation request to join an existing P2P Group. */
        P2P_STATE_RECV_INVITE_REQ_JOIN = 19,
-       /* recveing the P2P Inviation response with failure */
+       /* receiving the P2P Invitation response with failure */
        P2P_STATE_RX_INVITE_RESP_FAIL = 20,
-       /* receiving p2p negoitation response with information is not available */
+       /* receiving p2p negotiation response with information is not available */
        P2P_STATE_RX_INFOR_NOREADY = 21,
-       /* sending p2p negoitation response with information is not available */
+       /* sending p2p negotiation response with information is not available */
        P2P_STATE_TX_INFOR_NOREADY = 22,
 };
 
index 53b1bd8e99468068c78bec93f386aaa999d63e81..85b99da49a2d66c64862f2af0e002e9d00f5439a 100644 (file)
@@ -156,16 +156,6 @@ enum ndis_802_11_reload_def {
        Ndis802_11ReloadWEPKeys
 };
 
-/*  Key mapping keys require a BSSID */
-struct ndis_802_11_key {
-       u32           Length;             /*  Length of this structure */
-       u32           KeyIndex;
-       u32           KeyLength;          /*  length of key in bytes */
-       unsigned char BSSID[ETH_ALEN];
-       unsigned long long KeyRSC;
-       u8           KeyMaterial[32];  /* var len depending on above field */
-};
-
 struct ndis_802_11_remove_key {
        u32                   Length;        /*  Length */
        u32                   KeyIndex;
index 24a8f5ac96e56b103b527fd2813ec54026b85542..96c1c2d4a112c2b741ae63c35aa0d83ae8e6d79f 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <rtw_iol.h>
 #include <linux/vmalloc.h>
+#include <linux/etherdevice.h>
+
 #include "osdep_intf.h"
 
 #define RTL_IOCTL_WPA_SUPPLICANT       (SIOCIWFIRSTPRIV + 30)
@@ -92,7 +94,7 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter)
        memset(&wrqu, 0, sizeof(union iwreq_data));
 
        wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-       memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       eth_zero_addr(wrqu.ap_addr.sa_data);
 
        DBG_88E_LEVEL(_drv_always_, "indicate disassoc\n");
        wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
@@ -827,7 +829,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev,
                for (j = 0; j < NUM_PMKID_CACHE; j++) {
                        if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) {
                                /*  BSSID is matched, the same AP => Remove this PMKID information and reset it. */
-                               memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN);
+                               eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
                                psecuritypriv->PMKIDList[j].bUsed = false;
                                break;
                        }
@@ -1028,7 +1030,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
 
        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
 
-       memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+       eth_zero_addr(wrqu->ap_addr.sa_data);
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n"));
 
@@ -1037,7 +1039,7 @@ static int rtw_wx_get_wap(struct net_device *dev,
            ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true))
                memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
        else
-               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+               eth_zero_addr(wrqu->ap_addr.sa_data);
        return 0;
 }
 
@@ -1796,11 +1798,9 @@ static int rtw_wx_set_gen_ie(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       int ret;
        struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
 
-       ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
-       return ret;
+       return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
 }
 
 static int rtw_wx_set_auth(struct net_device *dev,
index 1b892c424cb8be54c9cf70c94acca67530462697..baff1e2661d55b60ac88b5664f705dc87d4de835 100644 (file)
@@ -29,9 +29,12 @@ void rtw_init_mlme_timer(struct adapter *padapter)
 {
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, _rtw_join_timeout_handler, padapter);
-       _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, rtw_scan_timeout_handler, padapter);
-       _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, rtw_dynamic_check_timer_handlder, padapter);
+       setup_timer(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->dynamic_chk_timer,
+                   rtw_dynamic_check_timer_handlder, (unsigned long)padapter);
 }
 
 void rtw_os_indicate_connect(struct adapter *adapter)
@@ -60,7 +63,6 @@ void rtw_reset_securitypriv(struct adapter *adapter)
                /*  We have to backup the PMK information for WiFi PMK Caching test item. */
                /*  Backup the btkip_countermeasure information. */
                /*  When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
-               memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
                backup_index = adapter->securitypriv.PMKIDIndex;
                backup_counter = adapter->securitypriv.btkip_countermeasure;
@@ -131,15 +133,18 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
 
 void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
 {
-       _init_timer(&psta->addba_retry_timer, padapter->pnetdev, addba_timer_hdl, psta);
+       setup_timer(&psta->addba_retry_timer, addba_timer_hdl,
+                   (unsigned long)psta);
 }
 
 void init_mlme_ext_timer(struct adapter *padapter)
 {
        struct  mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-       _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, survey_timer_hdl, padapter);
-       _init_timer(&pmlmeext->link_timer, padapter->pnetdev, link_timer_hdl, padapter);
+       setup_timer(&pmlmeext->survey_timer, survey_timer_hdl,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmeext->link_timer, link_timer_hdl,
+                   (unsigned long)padapter);
 }
 
 #ifdef CONFIG_88EU_AP_MODE
index 88a909c9e4577c26548e3e254a8f227305827941..750c87b46365bd317201280beb8b7a6c703579f5 100644 (file)
@@ -38,7 +38,7 @@ MODULE_VERSION(DRIVERVERSION);
 #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */
 
 /* module param defaults */
-static int rtw_chip_version = 0x00;
+static int rtw_chip_version;
 static int rtw_rfintfs = HWPI;
 static int rtw_lbkmode;/* RTL8712_AIR_TRX; */
 static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */
@@ -998,7 +998,8 @@ int _netdev_open(struct net_device *pnetdev)
        }
        padapter->net_closed = false;
 
-       _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000);
+       mod_timer(&padapter->mlmepriv.dynamic_chk_timer,
+                 jiffies + msecs_to_jiffies(2000));
 
        padapter->pwrctrlpriv.bips_processing = false;
        rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
@@ -1052,7 +1053,8 @@ static int  ips_netdrv_open(struct adapter *padapter)
                padapter->intf_start(padapter);
 
        rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
-       _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000);
+       mod_timer(&padapter->mlmepriv.dynamic_chk_timer,
+                 jiffies + msecs_to_jiffies(5000));
 
         return _SUCCESS;
 
index 05427c489b3f7d6010c79660b3de8803976565eb..05701328dce408bf63d9827b42f39d998f49095b 100644 (file)
@@ -193,7 +193,8 @@ _recv_indicatepkt_drop:
 
 void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
 {
-       struct adapter *padapter = preorder_ctrl->padapter;
 
-       _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, rtw_reordering_ctrl_timeout_handler, preorder_ctrl);
+       setup_timer(&preorder_ctrl->reordering_ctrl_timer,
+                   rtw_reordering_ctrl_timeout_handler,
+                   (unsigned long)preorder_ctrl);
 }
index bee39c2278f18115935601ad4c985d031c235ce0..ef3c73e38172589147749a67ba3ca4c8e7fe799e 100644 (file)
@@ -179,7 +179,7 @@ static void usb_intf_stop(struct adapter *padapter)
 {
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n"));
 
-       /* disabel_hw_interrupt */
+       /* disable_hw_interrupt */
        if (!padapter->bSurpriseRemoved) {
                /* device still exists, so driver can do i/o operation */
                /* TODO: */
index 80e7ef96d807e4f7d5fae5439102fd413b9d3042..7e599bc5b2d3c9f515bb2c3bb94eb1e702a8cd12 100644 (file)
@@ -530,6 +530,7 @@ void usb_read_port_cancel(struct adapter *padapter)
 {
        int i;
        struct recv_buf *precvbuf;
+
        precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
 
        DBG_88E("%s\n", __func__);
@@ -552,7 +553,6 @@ int usb_write8(struct adapter *adapter, u32 addr, u8 val)
        u16 index;
        u16 len;
        u8 data;
-       int ret;
 
        request = 0x05;
        requesttype = 0x00;/* write_out */
@@ -560,8 +560,8 @@ int usb_write8(struct adapter *adapter, u32 addr, u8 val)
        wvalue = (u16)(addr&0x0000ffff);
        len = 1;
        data = val;
-       ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
-       return ret;
+       return usbctrl_vendorreq(adapter, request, wvalue,
+                                index, &data, len, requesttype);
 }
 
 int usb_write16(struct adapter *adapter, u32 addr, u16 val)
@@ -572,7 +572,6 @@ int usb_write16(struct adapter *adapter, u32 addr, u16 val)
        u16 index;
        u16 len;
        __le32 data;
-       int ret;
 
 
        request = 0x05;
@@ -584,10 +583,10 @@ int usb_write16(struct adapter *adapter, u32 addr, u16 val)
 
        data = cpu_to_le32(val & 0x0000ffff);
 
-       ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
+       return usbctrl_vendorreq(adapter, request, wvalue,
+                                index, &data, len, requesttype);
 
 
-       return ret;
 }
 
 int usb_write32(struct adapter *adapter, u32 addr, u32 val)
@@ -598,7 +597,6 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val)
        u16 index;
        u16 len;
        __le32 data;
-       int ret;
 
 
        request = 0x05;
@@ -609,10 +607,10 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val)
        len = 4;
        data = cpu_to_le32(val);
 
-       ret = usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype);
+       return usbctrl_vendorreq(adapter, request, wvalue,
+                                index, &data, len, requesttype);
 
 
-       return ret;
 }
 
 static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs)
index eeea50260f1d08368ade615e22420945b97c6581..aad3394392fee282d2680d1ac0f78f244c38ff0a 100644 (file)
@@ -74,16 +74,11 @@ static inline void cpMacAddr(unsigned char *des, unsigned char *src)
        (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
 
 #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa)            \
-        eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
+        ether_addr_equal_unaligned(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, \
+       __pTa)
 #define UPDATE_CIE_SRC(__pIeeeDev, __pTa)              \
        cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
 
-#define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
-       (((__Ie).Length == 0 || (__Ie).Length !=        \
-       GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ?    \
-       false : (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf,     \
-       (__Ie).Octet, (__Ie).Length)))
-
 #define CIE_WATCHDOG_TH 1
 #define GET_CIE_WATCHDOG(__pIeeeDev)                           \
         (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog)
index 0e6bdd222e75350f45f7ad305dd0ce9572c14190..01d2201afc94da23a5ebc7db3204ea320fce1ab3 100644 (file)
@@ -47,8 +47,8 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
                                                0x0e, bMask12Bits, 0x021);
 
                        } else {
-                               RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): "
-                                        "unknown hardware version\n");
+                               RT_TRACE(COMP_ERR,
+                                        "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
                        }
 
                        break;
@@ -66,15 +66,16 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
                                                 0x0e, bMask12Bits, 0x0e1);
 
                        } else {
-                               RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): "
-                                        "unknown hardware version\n");
+                               RT_TRACE(COMP_ERR,
+                                        "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
                        }
 
 
                        break;
                default:
-                       RT_TRACE(COMP_ERR, "PHY_SetRF8256Bandwidth(): unknown "
-                                "Bandwidth: %#X\n", Bandwidth);
+                       RT_TRACE(COMP_ERR,
+                                "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",
+                                Bandwidth);
                        break;
 
                }
@@ -138,8 +139,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF,
                                                (enum rf90_radio_path)eRFPath);
                if (!rtStatus) {
-                       RT_TRACE(COMP_ERR, "PHY_RF8256_Config():Check "
-                                "Radio[%d] Fail!!\n", eRFPath);
+                       RT_TRACE(COMP_ERR,
+                                "PHY_RF8256_Config():Check Radio[%d] Fail!!\n",
+                                eRFPath);
                        goto phy_RF8256_Config_ParaFile_Fail;
                }
 
@@ -155,9 +157,10 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                                                 (enum rf90_radio_path)eRFPath,
                                                 RegOffSetToBeCheck,
                                                 bMask12Bits);
-                               RT_TRACE(COMP_RF, "RF %d %d register final "
-                                        "value: %x\n", eRFPath,
-                                        RegOffSetToBeCheck, RF3_Final_Value);
+                               RT_TRACE(COMP_RF,
+                                        "RF %d %d register final value: %x\n",
+                                        eRFPath, RegOffSetToBeCheck,
+                                        RF3_Final_Value);
                                RetryTimes--;
                        }
                        break;
@@ -170,9 +173,10 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                                                 (enum rf90_radio_path)eRFPath,
                                                 RegOffSetToBeCheck,
                                                 bMask12Bits);
-                               RT_TRACE(COMP_RF, "RF %d %d register final "
-                                        "value: %x\n", eRFPath,
-                                         RegOffSetToBeCheck, RF3_Final_Value);
+                               RT_TRACE(COMP_RF,
+                                        "RF %d %d register final value: %x\n",
+                                        eRFPath, RegOffSetToBeCheck,
+                                        RF3_Final_Value);
                                RetryTimes--;
                        }
                        break;
@@ -185,9 +189,10 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                                                (enum rf90_radio_path)eRFPath,
                                                RegOffSetToBeCheck,
                                                bMask12Bits);
-                               RT_TRACE(COMP_RF, "RF %d %d register final "
-                                        "value: %x\n", eRFPath,
-                                        RegOffSetToBeCheck, RF3_Final_Value);
+                               RT_TRACE(COMP_RF,
+                                        "RF %d %d register final value: %x\n",
+                                        eRFPath, RegOffSetToBeCheck,
+                                        RF3_Final_Value);
                                RetryTimes--;
                        }
                        break;
@@ -199,9 +204,10 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                                RF3_Final_Value = rtl8192_phy_QueryRFReg(dev,
                                               (enum rf90_radio_path)eRFPath,
                                               RegOffSetToBeCheck, bMask12Bits);
-                               RT_TRACE(COMP_RF, "RF %d %d register final "
-                                        "value: %x\n", eRFPath,
-                                         RegOffSetToBeCheck, RF3_Final_Value);
+                               RT_TRACE(COMP_RF,
+                                        "RF %d %d register final value: %x\n",
+                                        eRFPath, RegOffSetToBeCheck,
+                                        RF3_Final_Value);
                                RetryTimes--;
                        }
                        break;
@@ -221,8 +227,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
                }
 
                if (ret) {
-                       RT_TRACE(COMP_ERR, "phy_RF8256_Config_ParaFile():"
-                                "Radio[%d] Fail!!", eRFPath);
+                       RT_TRACE(COMP_ERR,
+                                "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!",
+                                eRFPath);
                        goto phy_RF8256_Config_ParaFile_Fail;
                }
 
index 2b1430d66adb211d04540ce32dc414db9ff67de8..e2ef0a3fcb839a460f5f34d42a2a28409ce4650b 100644 (file)
@@ -46,7 +46,7 @@ bool cmpk_message_handle_tx(
 
        do {
                if ((buffer_len - frag_offset) > frag_threshold) {
-                       frag_length = frag_threshold ;
+                       frag_length = frag_threshold;
                        bLastIniPkt = 0;
 
                } else {
@@ -332,44 +332,44 @@ u32 cmpk_message_handle_rx(struct net_device *dev,
 
                switch (element_id) {
                case RX_TX_FEEDBACK:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "RX_TX_FEEDBACK\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():RX_TX_FEEDBACK\n");
                        cmpk_handle_tx_feedback(dev, pcmd_buff);
                        cmd_length = CMPK_RX_TX_FB_SIZE;
                        break;
                case RX_INTERRUPT_STATUS:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "RX_INTERRUPT_STATUS\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():RX_INTERRUPT_STATUS\n");
                        cmpk_handle_interrupt_status(dev, pcmd_buff);
                        cmd_length = sizeof(struct cmpk_intr_sta);
                        break;
                case BOTH_QUERY_CONFIG:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "BOTH_QUERY_CONFIG\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():BOTH_QUERY_CONFIG\n");
                        cmpk_handle_query_config_rx(dev, pcmd_buff);
                        cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE;
                        break;
                case RX_TX_STATUS:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "RX_TX_STATUS\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():RX_TX_STATUS\n");
                        cmpk_handle_tx_status(dev, pcmd_buff);
                        cmd_length = CMPK_RX_TX_STS_SIZE;
                        break;
                case RX_TX_PER_PKT_FEEDBACK:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "RX_TX_PER_PKT_FEEDBACK\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():RX_TX_PER_PKT_FEEDBACK\n");
                        cmd_length = CMPK_RX_TX_FB_SIZE;
                        break;
                case RX_TX_RATE_HISTORY:
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "RX_TX_HISTORY\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():RX_TX_HISTORY\n");
                        cmpk_handle_tx_rate_history(dev, pcmd_buff);
                        cmd_length = CMPK_TX_RAHIS_SIZE;
                        break;
                default:
 
-                       RT_TRACE(COMP_CMDPKT, "---->cmpk_message_handle_rx():"
-                                "unknown CMD Element\n");
+                       RT_TRACE(COMP_CMDPKT,
+                                "---->cmpk_message_handle_rx():unknown CMD Element\n");
                        return 1;
                }
 
index 552d943b1761c459a86dd25a6b6c33a6ee1abfa8..170ff12c450a22e194d7cf1ff2f9533c51f976a0 100644 (file)
@@ -224,8 +224,8 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val)
                        break;
 
                default:
-                       printk(KERN_INFO "SetHwReg8185(): invalid ACI: %d !\n",
-                              eACI);
+                       netdev_info(dev, "SetHwReg8185(): invalid ACI: %d !\n",
+                                   eACI);
                        break;
                }
                priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACM_CTRL,
@@ -263,9 +263,9 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val)
                                break;
 
                        default:
-                               RT_TRACE(COMP_QOS, "SetHwReg8185(): [HW_VAR_"
-                                        "ACM_CTRL] acm set failed: eACI is "
-                                        "%d\n", eACI);
+                               RT_TRACE(COMP_QOS,
+                                        "SetHwReg8185(): [HW_VAR_ACM_CTRL] acm set failed: eACI is %d\n",
+                                        eACI);
                                break;
                        }
                } else {
@@ -287,8 +287,9 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val)
                        }
                }
 
-               RT_TRACE(COMP_QOS, "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write"
-                        " 0x%X\n", AcmCtrl);
+               RT_TRACE(COMP_QOS,
+                        "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
+                        AcmCtrl);
                write_nic_byte(dev, AcmHwCtrl, AcmCtrl);
                break;
        }
@@ -334,17 +335,17 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
        }
 
        if (!priv->AutoloadFailFlag) {
-               priv->eeprom_vid = eprom_read(dev, (EEPROM_VID >> 1));
-               priv->eeprom_did = eprom_read(dev, (EEPROM_DID >> 1));
+               priv->eeprom_vid = eprom_read(dev, EEPROM_VID >> 1);
+               priv->eeprom_did = eprom_read(dev, EEPROM_DID >> 1);
 
                usValue = eprom_read(dev, (u16)(EEPROM_Customer_ID>>1)) >> 8;
                priv->eeprom_CustomerID = (u8)(usValue & 0xff);
-               usValue = eprom_read(dev, (EEPROM_ICVersion_ChannelPlan>>1));
+               usValue = eprom_read(dev, EEPROM_ICVersion_ChannelPlan>>1);
                priv->eeprom_ChannelPlan = usValue&0xff;
-               IC_Version = ((usValue&0xff00)>>8);
+               IC_Version = (usValue & 0xff00)>>8;
 
                ICVer8192 = (IC_Version&0xf);
-               ICVer8256 = ((IC_Version&0xf0)>>4);
+               ICVer8256 = (IC_Version & 0xf0)>>4;
                RT_TRACE(COMP_INIT, "\nICVer8192 = 0x%x\n", ICVer8192);
                RT_TRACE(COMP_INIT, "\nICVer8256 = 0x%x\n", ICVer8256);
                if (ICVer8192 == 0x2) {
@@ -424,7 +425,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                if (priv->epromtype == EEPROM_93C46) {
                        if (!priv->AutoloadFailFlag) {
                                usValue = eprom_read(dev,
-                                         (EEPROM_TxPwDiff_CrystalCap >> 1));
+                                         EEPROM_TxPwDiff_CrystalCap >> 1);
                                priv->EEPROMAntPwDiff = (usValue&0x0fff);
                                priv->EEPROMCrystalCap = (u8)((usValue & 0xf000)
                                                         >> 12);
@@ -448,12 +449,12 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                                        usValue = EEPROM_Default_TxPower;
                                *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) =
                                                                 usValue;
-                               RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index"
-                                        " %d = 0x%02x\n", i,
-                                        priv->EEPROMTxPowerLevelCCK[i]);
-                               RT_TRACE(COMP_INIT, "CCK Tx Power Level, Index"
-                                        " %d = 0x%02x\n", i+1,
-                                        priv->EEPROMTxPowerLevelCCK[i+1]);
+                               RT_TRACE(COMP_INIT,
+                                        "CCK Tx Power Level, Index %d = 0x%02x\n",
+                                        i, priv->EEPROMTxPowerLevelCCK[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "CCK Tx Power Level, Index %d = 0x%02x\n",
+                                        i+1, priv->EEPROMTxPowerLevelCCK[i+1]);
                        }
                        for (i = 0; i < 14; i += 2) {
                                if (!priv->AutoloadFailFlag)
@@ -464,11 +465,12 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                                        usValue = EEPROM_Default_TxPower;
                                *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i]))
                                                         = usValue;
-                               RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level,"
-                                        " Index %d = 0x%02x\n", i,
-                                        priv->EEPROMTxPowerLevelOFDM24G[i]);
-                               RT_TRACE(COMP_INIT, "OFDM 2.4G Tx Power Level,"
-                                        " Index %d = 0x%02x\n", i + 1,
+                               RT_TRACE(COMP_INIT,
+                                        "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+                                        i, priv->EEPROMTxPowerLevelOFDM24G[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n",
+                                        i + 1,
                                         priv->EEPROMTxPowerLevelOFDM24G[i+1]);
                        }
                }
@@ -483,15 +485,15 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                                         priv->EEPROMLegacyHTTxPowerDiff;
                        priv->AntennaTxPwDiff[0] = (priv->EEPROMAntPwDiff &
                                                    0xf);
-                       priv->AntennaTxPwDiff[1] = ((priv->EEPROMAntPwDiff &
-                                                   0xf0)>>4);
-                       priv->AntennaTxPwDiff[2] = ((priv->EEPROMAntPwDiff &
-                                                   0xf00)>>8);
+                       priv->AntennaTxPwDiff[1] = (priv->EEPROMAntPwDiff &
+                                                       0xf0) >> 4;
+                       priv->AntennaTxPwDiff[2] = (priv->EEPROMAntPwDiff &
+                                                       0xf00) >> 8;
                        priv->CrystalCap = priv->EEPROMCrystalCap;
                        priv->ThermalMeter[0] = (priv->EEPROMThermalMeter &
                                                 0xf);
-                       priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter &
-                                                0xf0)>>4);
+                       priv->ThermalMeter[1] = (priv->EEPROMThermalMeter &
+                                                    0xf0) >> 4;
                } else if (priv->epromtype == EEPROM_93C56) {
 
                        for (i = 0; i < 3; i++) {
@@ -525,21 +527,21 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                                         priv->EEPROMRfCOfdmChnlTxPwLevel[2];
                        }
                        for (i = 0; i < 14; i++)
-                               RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_A"
-                                        "[%d] = 0x%x\n", i,
-                                        priv->TxPowerLevelCCK_A[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "priv->TxPowerLevelCCK_A[%d] = 0x%x\n",
+                                        i, priv->TxPowerLevelCCK_A[i]);
                        for (i = 0; i < 14; i++)
-                               RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM"
-                                        "24G_A[%d] = 0x%x\n", i,
-                                        priv->TxPowerLevelOFDM24G_A[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "priv->TxPowerLevelOFDM24G_A[%d] = 0x%x\n",
+                                        i, priv->TxPowerLevelOFDM24G_A[i]);
                        for (i = 0; i < 14; i++)
-                               RT_TRACE(COMP_INIT, "priv->TxPowerLevelCCK_C"
-                                        "[%d] = 0x%x\n", i,
-                                        priv->TxPowerLevelCCK_C[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "priv->TxPowerLevelCCK_C[%d] = 0x%x\n",
+                                        i, priv->TxPowerLevelCCK_C[i]);
                        for (i = 0; i < 14; i++)
-                               RT_TRACE(COMP_INIT, "priv->TxPowerLevelOFDM"
-                                        "24G_C[%d] = 0x%x\n", i,
-                                        priv->TxPowerLevelOFDM24G_C[i]);
+                               RT_TRACE(COMP_INIT,
+                                        "priv->TxPowerLevelOFDM24G_C[%d] = 0x%x\n",
+                                        i, priv->TxPowerLevelOFDM24G_C[i]);
                        priv->LegacyHTTxPowerDiff =
                                 priv->EEPROMLegacyHTTxPowerDiff;
                        priv->AntennaTxPwDiff[0] = 0;
@@ -548,8 +550,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                        priv->CrystalCap = priv->EEPROMCrystalCap;
                        priv->ThermalMeter[0] = (priv->EEPROMThermalMeter &
                                                 0xf);
-                       priv->ThermalMeter[1] = ((priv->EEPROMThermalMeter &
-                                                0xf0)>>4);
+                       priv->ThermalMeter[1] = (priv->EEPROMThermalMeter &
+                                                    0xf0) >> 4;
                }
        }
 
@@ -735,8 +737,9 @@ start:
        else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
                ulRegRead |= CPU_GEN_FIRMWARE_RESET;
        else
-               RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)"
-                        "\n", __func__,   priv->pFirmware->firmware_status);
+               RT_TRACE(COMP_ERR,
+                        "ERROR in %s(): undefined firmware state(%d)\n",
+                        __func__,   priv->pFirmware->firmware_status);
 
        write_nic_dword(dev, CPU_GEN, ulRegRead);
 
@@ -766,8 +769,8 @@ start:
                else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK)
                        ulRegRead |= CPU_CCK_LOOPBACK;
                else
-                       RT_TRACE(COMP_ERR, "Serious error: wrong loopback"
-                                " mode setting\n");
+                       RT_TRACE(COMP_ERR,
+                                "Serious error: wrong loopback mode setting\n");
 
                write_nic_dword(dev, CPU_GEN, ulRegRead);
 
@@ -883,15 +886,15 @@ start:
                          __func__);
                MgntActSet_RF_State(dev, eRfOff, RF_CHANGE_BY_SW, true);
        } else if (priv->rtllib->RfOffReason > RF_CHANGE_BY_PS) {
-               RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for"
-                        " RfOffReason(%d) ----------\n", __func__,
-                        priv->rtllib->RfOffReason);
+               RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER),
+                        "%s(): Turn off RF for RfOffReason(%d) ----------\n",
+                        __func__, priv->rtllib->RfOffReason);
                MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,
                                    true);
        } else if (priv->rtllib->RfOffReason >= RF_CHANGE_BY_IPS) {
-               RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER), "%s(): Turn off RF for"
-                        " RfOffReason(%d) ----------\n", __func__,
-                        priv->rtllib->RfOffReason);
+               RT_TRACE((COMP_INIT|COMP_RF|COMP_POWER),
+                        "%s(): Turn off RF for RfOffReason(%d) ----------\n",
+                        __func__, priv->rtllib->RfOffReason);
                MgntActSet_RF_State(dev, eRfOff, priv->rtllib->RfOffReason,
                                    true);
        } else {
@@ -939,17 +942,17 @@ start:
                        priv->CCKPresentAttentuation_difference = 0;
                        priv->CCKPresentAttentuation =
                                  priv->CCKPresentAttentuation_20Mdefault;
-                       RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower"
-                                "trackingindex_initial = %d\n",
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->rfa_txpowertrackingindex_initial = %d\n",
                                 priv->rfa_txpowertrackingindex);
-                       RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpower"
-                                "trackingindex_real__initial = %d\n",
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->rfa_txpowertrackingindex_real__initial = %d\n",
                                 priv->rfa_txpowertrackingindex_real);
-                       RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent"
-                                "Attentuation_difference_initial = %d\n",
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->CCKPresentAttentuation_difference_initial = %d\n",
                                  priv->CCKPresentAttentuation_difference);
-                       RT_TRACE(COMP_POWER_TRACKING, "priv->CCKPresent"
-                                "Attentuation_initial = %d\n",
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->CCKPresentAttentuation_initial = %d\n",
                                 priv->CCKPresentAttentuation);
                        priv->btxpower_tracking = false;
                }
@@ -1169,8 +1172,9 @@ static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority)
                QueueSelect = QSLT_HIGH;
                break;
        default:
-               RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection:"
-                        " %d\n", QueueID);
+               RT_TRACE(COMP_ERR,
+                        "TransmitTCB(): Impossible Queue Selection: %d\n",
+                        QueueID);
                break;
        }
        return QueueSelect;
@@ -1361,9 +1365,10 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
                        break;
 
                default:
-                       RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported"
-                                "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
-                                                 break;
+                       RT_TRACE(COMP_RECV,
+                                "HwRateToMRate90(): Non supportedRate [%x], bIsHT = %d!!!\n",
+                                rate, bIsHT);
+                       break;
                }
 
        } else {
@@ -1421,8 +1426,9 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
                        break;
 
                default:
-                       RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported "
-                                "Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
+                       RT_TRACE(COMP_RECV,
+                                "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",
+                                rate, bIsHT);
                        break;
                }
        }
@@ -1527,7 +1533,7 @@ static void rtl8192_query_rxphystatus(
                priv->stats.numqry_phystatusCCK++;
                if (!reg824_bit9) {
                        report = pcck_buf->cck_agc_rpt & 0xc0;
-                       report = report>>6;
+                       report >>= 6;
                        switch (report) {
                        case 0x3:
                                rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt &
@@ -1547,7 +1553,7 @@ static void rtl8192_query_rxphystatus(
                        }
                } else {
                        report = pcck_buf->cck_agc_rpt & 0x60;
-                       report = report>>5;
+                       report >>= 5;
                        switch (report) {
                        case 0x3:
                                rx_pwr_all = -35 -
@@ -1737,8 +1743,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
                        if (!rtl8192_phy_CheckIsLegalRFPath(priv->rtllib->dev,
                            rfpath))
                                continue;
-                       RT_TRACE(COMP_DBG, "Jacken -> pPreviousstats->RxMIMO"
-                                "SignalStrength[rfpath]  = %d\n",
+                       RT_TRACE(COMP_DBG,
+                                "Jacken -> pPreviousstats->RxMIMOSignalStrength[rfpath]  = %d\n",
                                 prev_st->RxMIMOSignalStrength[rfpath]);
                        if (priv->stats.rx_rssi_percentage[rfpath] == 0) {
                                priv->stats.rx_rssi_percentage[rfpath] =
@@ -1761,8 +1767,8 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
                                   (prev_st->RxMIMOSignalStrength[rfpath])) /
                                   (RX_SMOOTH);
                        }
-                       RT_TRACE(COMP_DBG, "Jacken -> priv->RxStats.RxRSSI"
-                                "Percentage[rfPath]  = %d\n",
+                       RT_TRACE(COMP_DBG,
+                                "Jacken -> priv->RxStats.RxRSSIPercentage[rfPath]  = %d\n",
                                 priv->stats.rx_rssi_percentage[rfpath]);
                }
        }
@@ -2073,8 +2079,8 @@ bool rtl8192_rx_query_status_desc(struct net_device *dev,
                                               pDrvInfo);
 
                if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1)
-                       RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d,"
-                                " pDrvInfo->PartAggr = %d\n",
+                       RT_TRACE(COMP_RXDESC,
+                                "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n",
                                 pDrvInfo->FirstAGGR, pDrvInfo->PartAggr);
                skb_trim(skb, skb->len - 4/*sCrcLng*/);
 
index 2e28744b9aab630ec5120512cbfa4d0ecad79ebb..1f7077d3966ca1fec4a30534d976f41cd35ac01a 100644 (file)
@@ -36,7 +36,6 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
                             u32 buffer_len)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
-       bool                rt_status = true;
        u16                 frag_threshold;
        u16                 frag_length, frag_offset = 0;
        int                 i;
@@ -51,7 +50,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
        frag_threshold = pfirmware->cmdpacket_frag_thresold;
        do {
                if ((buffer_len - frag_offset) > frag_threshold) {
-                       frag_length = frag_threshold ;
+                       frag_length = frag_threshold;
                        bLastIniPkt = 0;
 
                } else {
@@ -84,8 +83,8 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
                if (!priv->rtllib->check_nic_enough_desc(dev, tcb_desc->queue_index) ||
                    (!skb_queue_empty(&priv->rtllib->skb_waitQ[tcb_desc->queue_index])) ||
                    (priv->rtllib->queue_stop)) {
-                       RT_TRACE(COMP_FIRMWARE, "===================> tx "
-                                "full!\n");
+                       RT_TRACE(COMP_FIRMWARE,
+                                "===================> tx full!\n");
                        skb_queue_tail(&priv->rtllib->skb_waitQ
                                        [tcb_desc->queue_index], skb);
                } else {
@@ -99,7 +98,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
 
        write_nic_byte(dev, TPPoll, TPPoll_CQ);
 
-       return rt_status;
+       return true;
 }
 
 static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
@@ -108,7 +107,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
        u32             CPU_status = 0;
        unsigned long   timeout;
 
-       timeout = jiffies + MSECS(200);
+       timeout = jiffies + msecs_to_jiffies(200);
        while (time_before(jiffies, timeout)) {
                CPU_status = read_nic_dword(dev, CPU_GEN);
                if (CPU_status & CPU_GEN_PUT_CODE_OK)
@@ -128,7 +127,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
                       (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff));
        mdelay(1);
 
-       timeout = jiffies + MSECS(200);
+       timeout = jiffies + msecs_to_jiffies(200);
        while (time_before(jiffies, timeout)) {
                CPU_status = read_nic_dword(dev, CPU_GEN);
                if (CPU_status&CPU_GEN_BOOT_RDY)
@@ -156,7 +155,7 @@ static bool CPUcheck_firmware_ready(struct net_device *dev)
        u32     CPU_status = 0;
        unsigned long timeout;
 
-       timeout = jiffies + MSECS(20);
+       timeout = jiffies + msecs_to_jiffies(20);
        while (time_before(jiffies, timeout)) {
                CPU_status = read_nic_dword(dev, CPU_GEN);
                if (CPU_status&CPU_GEN_FIRM_RDY)
@@ -197,8 +196,8 @@ static bool firmware_check_ready(struct net_device *dev,
                if (rt_status)
                        pfirmware->firmware_status = FW_STATUS_3_TURNON_CPU;
                else
-                       RT_TRACE(COMP_FIRMWARE, "CPUcheck_maincodeok_turnon"
-                                "CPU fail!\n");
+                       RT_TRACE(COMP_FIRMWARE,
+                                "CPUcheck_maincodeok_turnonCPU fail!\n");
 
                break;
 
@@ -210,8 +209,9 @@ static bool firmware_check_ready(struct net_device *dev,
                if (rt_status)
                        pfirmware->firmware_status = FW_STATUS_5_READY;
                else
-                       RT_TRACE(COMP_FIRMWARE, "CPUcheck_firmware_ready fail"
-                                "(%d)!\n", rt_status);
+                       RT_TRACE(COMP_FIRMWARE,
+                                "CPUcheck_firmware_ready fail(%d)!\n",
+                                rt_status);
 
                break;
        default:
@@ -246,8 +246,8 @@ bool init_firmware(struct net_device *dev)
                rst_opt = OPT_FIRMWARE_RESET;
                starting_state = FW_INIT_STEP2_DATA;
        } else {
-               RT_TRACE(COMP_FIRMWARE, "PlatformInitFirmware: undefined"
-                        " firmware state\n");
+               RT_TRACE(COMP_FIRMWARE,
+                        "PlatformInitFirmware: undefined firmware state\n");
        }
 
        for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA;
@@ -266,14 +266,14 @@ bool init_firmware(struct net_device *dev)
                                                      fw_name[init_step],
                                                      &priv->pdev->dev);
                                if (rc < 0) {
-                                       RT_TRACE(COMP_FIRMWARE, "request firmware fail!\n");
+                                       RT_TRACE(COMP_FIRMWARE,
+                                                "request firmware fail!\n");
                                        goto download_firmware_fail;
                                }
                                if (fw_entry->size >
                                    sizeof(pfirmware->firmware_buf[init_step])) {
-                                       RT_TRACE(COMP_FIRMWARE, "img file size "
-                                                "exceed the container struct "
-                                                "buffer fail!\n");
+                                       RT_TRACE(COMP_FIRMWARE,
+                                                "img file size exceed the container struct buffer fail!\n");
                                        goto download_firmware_fail;
                                }
 
index 019836bb36c24d626af6ea42a75a40eac94dfce8..d804876dd92f82e795f296eabc4bdb325ed9bea8 100644 (file)
@@ -34,18 +34,18 @@ extern u32 Rtl8192PciEPHY_REGArray[PHY_REGArrayLengthPciE];
 #define PHY_REG_1T2RArrayLengthPciE 296
 extern u32 Rtl8192PciEPHY_REG_1T2RArray[PHY_REG_1T2RArrayLengthPciE];
 #define RadioA_ArrayLengthPciE 246
-extern u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE] ;
+extern u32 Rtl8192PciERadioA_Array[RadioA_ArrayLengthPciE];
 #define RadioB_ArrayLengthPciE 78
-extern u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE] ;
+extern u32 Rtl8192PciERadioB_Array[RadioB_ArrayLengthPciE];
 #define RadioC_ArrayLengthPciE 2
-extern u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE] ;
+extern u32 Rtl8192PciERadioC_Array[RadioC_ArrayLengthPciE];
 #define RadioD_ArrayLengthPciE 2
-extern u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE] ;
+extern u32 Rtl8192PciERadioD_Array[RadioD_ArrayLengthPciE];
 #define MACPHY_ArrayLengthPciE 18
-extern u32 Rtl8192PciEMACPHY_Array[MACPHY_ArrayLengthPciE] ;
+extern u32 Rtl8192PciEMACPHY_Array[MACPHY_ArrayLengthPciE];
 #define MACPHY_Array_PGLengthPciE 30
-extern u32 Rtl8192PciEMACPHY_Array_PG[MACPHY_Array_PGLengthPciE] ;
+extern u32 Rtl8192PciEMACPHY_Array_PG[MACPHY_Array_PGLengthPciE];
 #define AGCTAB_ArrayLengthPciE 384
-extern u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE] ;
+extern u32 Rtl8192PciEAGCTAB_Array[AGCTAB_ArrayLengthPciE];
 
 #endif
index 8c08ef6a40a4443da823e577a7817b40bbf62958..1d9b7a17cbdea682a035fd056788f746e6825357 100644 (file)
@@ -136,8 +136,8 @@ static u32 rtl8192_phy_RFSerialRead(struct net_device *dev,
                } else
                        NewOffset = Offset;
        } else {
-               RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need"
-                        " to be 8256\n");
+               RT_TRACE((COMP_PHY|COMP_ERR),
+                        "check RF type here, need to be 8256\n");
                NewOffset = Offset;
        }
        rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadAddress,
@@ -192,8 +192,8 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev,
                } else
                        NewOffset = Offset;
        } else {
-               RT_TRACE((COMP_PHY|COMP_ERR), "check RF type here, need to be"
-                        " 8256\n");
+               RT_TRACE((COMP_PHY|COMP_ERR),
+                        "check RF type here, need to be 8256\n");
                NewOffset = Offset;
        }
 
@@ -348,8 +348,8 @@ void rtl8192_phy_configmac(struct net_device *dev)
                pdwArray = Rtl819XMACPHY_Array;
        }
        for (i = 0; i < dwArrayLen; i += 3) {
-               RT_TRACE(COMP_DBG, "The Rtl8190MACPHY_Array[0] is %x Rtl8190MAC"
-                        "PHY_Array[1] is %x Rtl8190MACPHY_Array[2] is %x\n",
+               RT_TRACE(COMP_DBG,
+                        "The Rtl8190MACPHY_Array[0] is %x Rtl8190MACPHY_Array[1] is %x Rtl8190MACPHY_Array[2] is %x\n",
                         pdwArray[i], pdwArray[i+1], pdwArray[i+2]);
                if (pdwArray[i] == 0x318)
                        pdwArray[i+2] = 0x00000800;
@@ -383,8 +383,8 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
                        rtl8192_setBBreg(dev, Rtl819XPHY_REGArray_Table[i],
                                         bMaskDWord,
                                         Rtl819XPHY_REGArray_Table[i+1]);
-                       RT_TRACE(COMP_DBG, "i: %x, The Rtl819xUsbPHY_REGArray"
-                                "[0] is %x Rtl819xUsbPHY_REGArray[1] is %x\n",
+                       RT_TRACE(COMP_DBG,
+                                "i: %x, The Rtl819xUsbPHY_REGArray[0] is %x Rtl819xUsbPHY_REGArray[1] is %x\n",
                                 i, Rtl819XPHY_REGArray_Table[i],
                                 Rtl819XPHY_REGArray_Table[i+1]);
                }
@@ -393,9 +393,9 @@ void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType)
                        rtl8192_setBBreg(dev, Rtl819XAGCTAB_Array_Table[i],
                                         bMaskDWord,
                                         Rtl819XAGCTAB_Array_Table[i+1]);
-                       RT_TRACE(COMP_DBG, "i:%x, The rtl819XAGCTAB_Array[0] "
-                                "is %x rtl819XAGCTAB_Array[1] is %x\n", i,
-                                Rtl819XAGCTAB_Array_Table[i],
+                       RT_TRACE(COMP_DBG,
+                                "i:%x, The rtl819XAGCTAB_Array[0] is %x rtl819XAGCTAB_Array[1] is %x\n",
+                                i, Rtl819XAGCTAB_Array_Table[i],
                                 Rtl819XAGCTAB_Array_Table[i+1]);
                }
        }
@@ -511,8 +511,8 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
        for (i = 0; i < CheckTimes; i++) {
                switch (CheckBlock) {
                case HW90_BLOCK_MAC:
-                       RT_TRACE(COMP_ERR, "PHY_CheckBBRFOK(): Never Write "
-                                "0x100 here!");
+                       RT_TRACE(COMP_ERR,
+                                "PHY_CheckBBRFOK(): Never Write 0x100 here!");
                        break;
 
                case HW90_BLOCK_PHY0:
@@ -541,8 +541,9 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
 
 
                if (dwRegRead != WriteData[i]) {
-                       RT_TRACE(COMP_ERR, "====>error=====dwRegRead: %x, "
-                                "WriteData: %x\n", dwRegRead, WriteData[i]);
+                       RT_TRACE(COMP_ERR,
+                                "====>error=====dwRegRead: %x, WriteData: %x\n",
+                                dwRegRead, WriteData[i]);
                        ret = false;
                        break;
                }
@@ -570,8 +571,9 @@ static bool rtl8192_BB_Config_ParaFile(struct net_device *dev)
                                         (enum hw90_block)eCheckItem,
                                         (enum rf90_radio_path)0);
                if (!rtStatus) {
-                       RT_TRACE((COMP_ERR | COMP_PHY), "PHY_RF8256_Config():"
-                                "Check PHY%d Fail!!\n", eCheckItem-1);
+                       RT_TRACE((COMP_ERR | COMP_PHY),
+                                "PHY_RF8256_Config():Check PHY%d Fail!!\n",
+                                eCheckItem-1);
                        return rtStatus;
                }
        }
@@ -628,8 +630,8 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
        priv->DefaultInitialGain[1] = read_nic_byte(dev, rOFDM0_XBAGCCore1);
        priv->DefaultInitialGain[2] = read_nic_byte(dev, rOFDM0_XCAGCCore1);
        priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1);
-       RT_TRACE(COMP_INIT, "Default initial gain (c50=0x%x, c58=0x%x, "
-               "c60=0x%x, c68=0x%x)\n",
+       RT_TRACE(COMP_INIT,
+                "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n",
                priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
                priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
 
@@ -807,8 +809,8 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
        case RF_8258:
                break;
        default:
-               RT_TRACE(COMP_ERR, "unknown rf chip ID in rtl8192_SetTxPower"
-                        "Level()\n");
+               RT_TRACE(COMP_ERR,
+                        "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n");
                break;
        }
        return;
@@ -822,15 +824,14 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable,
        struct sw_chnl_cmd *pCmd;
 
        if (CmdTable == NULL) {
-               RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): CmdTable cannot "
-                        "be NULL.\n");
+               RT_TRACE(COMP_ERR,
+                        "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n");
                return false;
        }
        if (CmdTableIdx >= CmdTableSz) {
-               RT_TRACE(COMP_ERR, "phy_SetSwChnlCmdArray(): Access invalid"
-                        " index, please check size of the table, CmdTableIdx:"
-                        "%d, CmdTableSz:%d\n",
-                               CmdTableIdx, CmdTableSz);
+               RT_TRACE(COMP_ERR,
+                        "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n",
+                        CmdTableIdx, CmdTableSz);
                return false;
        }
 
@@ -883,8 +884,9 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
                switch (priv->rf_chip) {
                case RF_8225:
                        if (!(channel >= 1 && channel <= 14)) {
-                               RT_TRACE(COMP_ERR, "illegal channel for Zebra "
-                                        "8225: %d\n", channel);
+                               RT_TRACE(COMP_ERR,
+                                        "illegal channel for Zebra 8225: %d\n",
+                                        channel);
                                return false;
                        }
                        rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
@@ -898,8 +900,9 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
 
                case RF_8256:
                        if (!(channel >= 1 && channel <= 14)) {
-                               RT_TRACE(COMP_ERR, "illegal channel for Zebra"
-                                        " 8256: %d\n", channel);
+                               RT_TRACE(COMP_ERR,
+                                        "illegal channel for Zebra 8256: %d\n",
+                                        channel);
                                return false;
                        }
                        rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
@@ -920,7 +923,6 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
                        RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n",
                                 priv->rf_chip);
                        return false;
-                       break;
                }
 
 
@@ -996,7 +998,7 @@ static void rtl8192_phy_FinishSwChnlNow(struct net_device *dev, u8 channel)
              &priv->SwChnlStep, &delay)) {
                if (delay > 0)
                        msleep(delay);
-               if (IS_NIC_DOWN(priv))
+               if (!priv->up)
                        break;
        }
 }
@@ -1020,7 +1022,7 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
        struct r8192_priv *priv = rtllib_priv(dev);
 
        RT_TRACE(COMP_PHY, "=====>%s()\n", __func__);
-       if (IS_NIC_DOWN(priv)) {
+       if (!priv->up) {
                RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__);
                return false;
        }
@@ -1060,7 +1062,7 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
        priv->SwChnlStage = 0;
        priv->SwChnlStep = 0;
 
-       if (!IS_NIC_DOWN(priv))
+       if (priv->up)
                rtl8192_SwChnl_WorkItem(dev);
        priv->SwChnlInProgress = false;
        return true;
@@ -1083,8 +1085,8 @@ static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev)
                if (priv->CCKPresentAttentuation < 0)
                        priv->CCKPresentAttentuation = 0;
 
-               RT_TRACE(COMP_POWER_TRACKING, "20M, priv->CCKPresent"
-                        "Attentuation = %d\n",
+               RT_TRACE(COMP_POWER_TRACKING,
+                        "20M, priv->CCKPresentAttentuation = %d\n",
                         priv->CCKPresentAttentuation);
 
                if (priv->rtllib->current_network.channel == 14 &&
@@ -1105,8 +1107,8 @@ static void CCK_Tx_Power_Track_BW_Switch_TSSI(struct net_device *dev)
                        priv->CCKPresentAttentuation_40Mdefault +
                        priv->CCKPresentAttentuation_difference;
 
-               RT_TRACE(COMP_POWER_TRACKING, "40M, priv->CCKPresent"
-                        "Attentuation = %d\n",
+               RT_TRACE(COMP_POWER_TRACKING,
+                        "40M, priv->CCKPresentAttentuation = %d\n",
                         priv->CCKPresentAttentuation);
                if (priv->CCKPresentAttentuation >
                    (CCKTxBBGainTableLength - 1))
@@ -1146,15 +1148,15 @@ static void CCK_Tx_Power_Track_BW_Switch_ThermalMeter(struct net_device *dev)
                if (priv->Record_CCK_20Mindex == 0)
                        priv->Record_CCK_20Mindex = 6;
                priv->CCK_index = priv->Record_CCK_20Mindex;
-               RT_TRACE(COMP_POWER_TRACKING, "20MHz, CCK_Tx_Power_Track_BW_"
-                        "Switch_ThermalMeter(),CCK_index = %d\n",
+               RT_TRACE(COMP_POWER_TRACKING,
+                        "20MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(),CCK_index = %d\n",
                         priv->CCK_index);
        break;
 
        case HT_CHANNEL_WIDTH_20_40:
                priv->CCK_index = priv->Record_CCK_40Mindex;
-               RT_TRACE(COMP_POWER_TRACKING, "40MHz, CCK_Tx_Power_Track_BW_"
-                        "Switch_ThermalMeter(), CCK_index = %d\n",
+               RT_TRACE(COMP_POWER_TRACKING,
+                        "40MHz, CCK_Tx_Power_Track_BW_Switch_ThermalMeter(), CCK_index = %d\n",
                         priv->CCK_index);
        break;
        }
@@ -1177,16 +1179,17 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 regBwOpMode;
 
-       RT_TRACE(COMP_SWBW, "==>rtl8192_SetBWModeWorkItem()  Switch to %s "
-                "bandwidth\n", priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ?
-                "20MHz" : "40MHz");
+       RT_TRACE(COMP_SWBW,
+                "==>rtl8192_SetBWModeWorkItem()  Switch to %s bandwidth\n",
+                priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ?
+                        "20MHz" : "40MHz");
 
 
        if (priv->rf_chip == RF_PSEUDO_11N) {
                priv->SetBWModeInProgress = false;
                return;
        }
-       if (IS_NIC_DOWN(priv)) {
+       if (!priv->up) {
                RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__);
                return;
        }
@@ -1204,8 +1207,9 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
                break;
 
        default:
-               RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown "
-                        "Bandwidth: %#X\n", priv->CurrentChannelBW);
+               RT_TRACE(COMP_ERR,
+                        "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",
+                        priv->CurrentChannelBW);
                break;
        }
 
@@ -1245,8 +1249,9 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
                rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0);
                break;
        default:
-               RT_TRACE(COMP_ERR, "SetChannelBandwidth819xUsb(): unknown "
-                        "Bandwidth: %#X\n", priv->CurrentChannelBW);
+               RT_TRACE(COMP_ERR,
+                        "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",
+                        priv->CurrentChannelBW);
                break;
 
        }
@@ -1309,11 +1314,11 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation)
        u32 BitMask;
        u8 initial_gain;
 
-       if (!IS_NIC_DOWN(priv)) {
+       if (priv->up) {
                switch (Operation) {
                case IG_Backup:
-                       RT_TRACE(COMP_SCAN, "IG_Backup, backup the initial"
-                                " gain.\n");
+                       RT_TRACE(COMP_SCAN,
+                                "IG_Backup, backup the initial gain.\n");
                        initial_gain = SCAN_RX_INITIAL_GAIN;
                        BitMask = bMaskByte0;
                        if (dm_digtable.dig_algorithm ==
@@ -1335,16 +1340,21 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation)
                        priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev,
                                                    rCCK0_CCA, BitMask);
 
-                       RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc50 is"
-                                " %x\n", priv->initgain_backup.xaagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc58 is"
-                                " %x\n", priv->initgain_backup.xbagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc60 is"
-                                " %x\n", priv->initgain_backup.xcagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xc68 is"
-                                " %x\n", priv->initgain_backup.xdagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is"
-                                " %x\n", priv->initgain_backup.cca);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan InitialGainBackup 0xc50 is %x\n",
+                                priv->initgain_backup.xaagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan InitialGainBackup 0xc58 is %x\n",
+                                priv->initgain_backup.xbagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan InitialGainBackup 0xc60 is %x\n",
+                                priv->initgain_backup.xcagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan InitialGainBackup 0xc68 is %x\n",
+                                priv->initgain_backup.xdagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan InitialGainBackup 0xa0a is %x\n",
+                                priv->initgain_backup.cca);
 
                        RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n",
                                 initial_gain);
@@ -1357,8 +1367,8 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation)
                        write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH);
                        break;
                case IG_Restore:
-                       RT_TRACE(COMP_SCAN, "IG_Restore, restore the initial "
-                                "gain.\n");
+                       RT_TRACE(COMP_SCAN,
+                                "IG_Restore, restore the initial gain.\n");
                        BitMask = 0x7f;
                        if (dm_digtable.dig_algorithm ==
                            DIG_ALGO_BY_FALSE_ALARM)
@@ -1376,16 +1386,21 @@ void InitialGain819xPci(struct net_device *dev, u8 Operation)
                        rtl8192_setBBreg(dev, rCCK0_CCA, BitMask,
                                         (u32)priv->initgain_backup.cca);
 
-                       RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc50"
-                                " is %x\n", priv->initgain_backup.xaagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc58"
-                                " is %x\n", priv->initgain_backup.xbagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc60"
-                                " is %x\n", priv->initgain_backup.xcagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xc68"
-                                " is %x\n", priv->initgain_backup.xdagccore1);
-                       RT_TRACE(COMP_SCAN, "Scan BBInitialGainRestore 0xa0a"
-                                " is %x\n", priv->initgain_backup.cca);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan BBInitialGainRestore 0xc50 is %x\n",
+                                priv->initgain_backup.xaagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan BBInitialGainRestore 0xc58 is %x\n",
+                                priv->initgain_backup.xbagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan BBInitialGainRestore 0xc60 is %x\n",
+                                priv->initgain_backup.xcagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan BBInitialGainRestore 0xc68 is %x\n",
+                                priv->initgain_backup.xdagccore1);
+                       RT_TRACE(COMP_SCAN,
+                                "Scan BBInitialGainRestore 0xa0a is %x\n",
+                                priv->initgain_backup.cca);
 
                        rtl8192_phy_setTxPower(dev,
                                         priv->rtllib->current_network.channel);
@@ -1447,8 +1462,8 @@ static bool SetRFPowerState8190(struct net_device *dev,
                                } while (!rtstatus && (InitilizeCount > 0));
 
                                if (!rtstatus) {
-                                       RT_TRACE(COMP_ERR, "%s():Initialize Ada"
-                                                "pter fail,return\n",
+                                       RT_TRACE(COMP_ERR,
+                                                "%s():Initialize Adapter fail,return\n",
                                                 __func__);
                                        priv->SetRFPowerStateInProgress = false;
                                        return false;
@@ -1492,19 +1507,16 @@ static bool SetRFPowerState8190(struct net_device *dev,
                                        QueueID++;
                                        continue;
                                } else {
-                                       RT_TRACE((COMP_POWER|COMP_RF), "eRf Off"
-                                                "/Sleep: %d times TcbBusyQueue"
-                                                "[%d] !=0 before doze!\n",
+                                       RT_TRACE((COMP_POWER|COMP_RF),
+                                                "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n",
                                                 (i+1), QueueID);
                                        udelay(10);
                                        i++;
                                }
 
                                if (i >= MAX_DOZE_WAITING_TIMES_9x) {
-                                       RT_TRACE(COMP_POWER, "\n\n\n TimeOut!! "
-                                                "SetRFPowerState8190(): eRfOff"
-                                                ": %d times TcbBusyQueue[%d] "
-                                                "!= 0 !!!\n",
+                                       RT_TRACE(COMP_POWER,
+                                                "\n\n\n TimeOut!! SetRFPowerState8190(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n",
                                                 MAX_DOZE_WAITING_TIMES_9x,
                                                 QueueID);
                                        break;
@@ -1514,8 +1526,8 @@ static bool SetRFPowerState8190(struct net_device *dev,
                        break;
 
                case eRfOff:
-                       RT_TRACE(COMP_PS, "SetRFPowerState8190() eRfOff/"
-                                "Sleep !\n");
+                       RT_TRACE(COMP_PS,
+                                "SetRFPowerState8190() eRfOff/Sleep !\n");
 
                        for (QueueID = 0, i = 0; QueueID < MAX_TX_QUEUE; ) {
                                ring = &priv->tx_ring[QueueID];
@@ -1524,19 +1536,16 @@ static bool SetRFPowerState8190(struct net_device *dev,
                                        QueueID++;
                                        continue;
                                } else {
-                                       RT_TRACE(COMP_POWER, "eRf Off/Sleep: %d"
-                                                " times TcbBusyQueue[%d] !=0 b"
-                                                "efore doze!\n", (i+1),
-                                                QueueID);
+                                       RT_TRACE(COMP_POWER,
+                                                "eRf Off/Sleep: %d times TcbBusyQueue[%d] !=0 before doze!\n",
+                                                (i+1), QueueID);
                                        udelay(10);
                                        i++;
                                }
 
                                if (i >= MAX_DOZE_WAITING_TIMES_9x) {
-                                       RT_TRACE(COMP_POWER, "\n\n\n SetZebra: "
-                                                "RFPowerState8185B(): eRfOff:"
-                                                " %d times TcbBusyQueue[%d] "
-                                                "!= 0 !!!\n",
+                                       RT_TRACE(COMP_POWER,
+                                                "\n\n\n SetZebra: RFPowerState8185B(): eRfOff: %d times TcbBusyQueue[%d] != 0 !!!\n",
                                                 MAX_DOZE_WAITING_TIMES_9x,
                                                 QueueID);
                                        break;
@@ -1556,8 +1565,9 @@ static bool SetRFPowerState8190(struct net_device *dev,
 
                default:
                        bResult = false;
-                       RT_TRACE(COMP_ERR, "SetRFPowerState8190(): unknown state"
-                                " to set: 0x%X!!!\n", eRFPowerState);
+                       RT_TRACE(COMP_ERR,
+                                "SetRFPowerState8190(): unknown state to set: 0x%X!!!\n",
+                                eRFPowerState);
                        break;
                }
 
@@ -1576,8 +1586,8 @@ static bool SetRFPowerState8190(struct net_device *dev,
                        break;
 
                default:
-                       RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown "
-                                "RF type\n");
+                       RT_TRACE(COMP_ERR,
+                                "SetRFPowerState8190(): Unknown RF type\n");
                        break;
                }
        }
@@ -1599,8 +1609,8 @@ bool SetRFPowerState(struct net_device *dev,
                 eRFPowerState);
        if (eRFPowerState == priv->rtllib->eRFPowerState &&
            priv->bHwRfOffAction == 0) {
-               RT_TRACE(COMP_PS, "<--------- SetRFPowerState(): discard the "
-                        "request for eRFPowerState(%d) is the same.\n",
+               RT_TRACE(COMP_PS,
+                        "<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n",
                         eRFPowerState);
                return bResult;
        }
index 89ea70b0d3aadd1e23ac130ff7fc7e80c85622f2..8b5f6085697e7ec904767d17fef5654b8028b79b 100644 (file)
@@ -86,9 +86,9 @@ void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
 
-       RT_TRACE(COMP_DBG, "===========>%s():EntryNo is %d,KeyIndex is "
-                "%d,KeyType is %d,is_mesh is %d\n", __func__, EntryNo,
-                KeyIndex, KeyType, is_mesh);
+       RT_TRACE(COMP_DBG,
+                "===========>%s():EntryNo is %d,KeyIndex is %d,KeyType is %d,is_mesh is %d\n",
+                __func__, EntryNo, KeyIndex, KeyType, is_mesh);
        if (!is_mesh) {
                ieee->swcamtable[EntryNo].bused = true;
                ieee->swcamtable[EntryNo].key_index = KeyIndex;
@@ -115,7 +115,7 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
                        if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) {
                                RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
                                        __func__);
-                               return ;
+                               return;
                        } else {
                                down(&priv->rtllib->ips_sem);
                                IPSLeave(dev);
@@ -127,9 +127,9 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
        if (EntryNo >= TOTAL_CAM_ENTRY)
                RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
 
-       RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d,"
-                "KeyType:%d, MacAddr %pM\n", dev, EntryNo, KeyIndex,
-                KeyType, MacAddr);
+       RT_TRACE(COMP_SEC,
+                "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d,KeyType:%d, MacAddr %pM\n",
+                dev, EntryNo, KeyIndex, KeyType, MacAddr);
 
        if (DefaultKey)
                usConfig |= BIT15 | (KeyType<<2);
@@ -192,7 +192,7 @@ void CamRestoreAllEntry(struct net_device *dev)
                for (EntryId = 0; EntryId < 4; EntryId++) {
                        MacAddr = CAM_CONST_ADDR[EntryId];
                        if (priv->rtllib->swcamtable[EntryId].bused) {
-                               setKey(dev, EntryId , EntryId,
+                               setKey(dev, EntryId, EntryId,
                                       priv->rtllib->pairwise_key_type, MacAddr,
                                       0, (u32 *)(&priv->rtllib->swcamtable
                                      [EntryId].key_buf[0]));
@@ -244,8 +244,8 @@ void CamRestoreAllEntry(struct net_device *dev)
                                       (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])
                                     );
                        } else {
-                               RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC TKIP "
-                                        ",but 0 entry is have no data\n",
+                               RT_TRACE(COMP_ERR,
+                                        "===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",
                                         __func__);
                                return;
                        }
@@ -254,7 +254,7 @@ void CamRestoreAllEntry(struct net_device *dev)
                MacAddr = CAM_CONST_BROAD;
                for (EntryId = 1; EntryId < 4; EntryId++) {
                        if (priv->rtllib->swcamtable[EntryId].bused) {
-                               setKey(dev, EntryId , EntryId,
+                               setKey(dev, EntryId, EntryId,
                                       priv->rtllib->group_key_type,
                                       MacAddr, 0,
                                       (u32 *)(&priv->rtllib->swcamtable[EntryId].key_buf[0]));
@@ -263,13 +263,13 @@ void CamRestoreAllEntry(struct net_device *dev)
 
                if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
                        if (priv->rtllib->swcamtable[0].bused) {
-                               setKey(dev, 0 , 0,
+                               setKey(dev, 0, 0,
                                        priv->rtllib->group_key_type,
                                        CAM_CONST_ADDR[0], 0,
                                        (u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]));
                        } else {
-                               RT_TRACE(COMP_ERR, "===>%s():ERR!! ADHOC CCMP ,"
-                                        "but 0 entry is have no data\n",
+                               RT_TRACE(COMP_ERR,
+                                        "===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n",
                                         __func__);
                                return;
                        }
index 5615c80f614cab0c4860196117ab4d1f250e631a..bcf7a9d822e2554c3ae29c16363651ef051bddb4 100644 (file)
@@ -131,7 +131,7 @@ static bool PlatformIOCheckPageLegalAndGetRegMask(u32 u4bPage, u8 *pu1bPageMask)
 
 void write_nic_io_byte(struct net_device *dev, int x, u8 y)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
 
@@ -154,7 +154,7 @@ void write_nic_io_byte(struct net_device *dev, int x, u8 y)
 
 void write_nic_io_word(struct net_device *dev, int x, u16 y)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
 
@@ -177,7 +177,7 @@ void write_nic_io_word(struct net_device *dev, int x, u16 y)
 
 void write_nic_io_dword(struct net_device *dev, int x, u32 y)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
 
@@ -199,7 +199,7 @@ void write_nic_io_dword(struct net_device *dev, int x, u32 y)
 
 u8 read_nic_io_byte(struct net_device *dev, int x)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
        u8      Data = 0;
@@ -224,7 +224,7 @@ u8 read_nic_io_byte(struct net_device *dev, int x)
 
 u16 read_nic_io_word(struct net_device *dev, int x)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
        u16     Data = 0;
@@ -250,7 +250,7 @@ u16 read_nic_io_word(struct net_device *dev, int x)
 
 u32 read_nic_io_dword(struct net_device *dev, int x)
 {
-       u32 u4bPage = (x >> 8);
+       u32 u4bPage = x >> 8;
        u8 u1PageMask = 0;
        bool    bIsLegalPage = false;
        u32     Data = 0;
@@ -326,8 +326,8 @@ bool MgntActSet_RF_State(struct net_device *dev,
        u16                     RFWaitCounter = 0;
        unsigned long flag;
 
-       RT_TRACE((COMP_PS | COMP_RF), "===>MgntActSet_RF_State(): "
-                "StateToSet(%d)\n", StateToSet);
+       RT_TRACE((COMP_PS | COMP_RF),
+                "===>MgntActSet_RF_State(): StateToSet(%d)\n", StateToSet);
 
        ProtectOrNot = false;
 
@@ -338,22 +338,19 @@ bool MgntActSet_RF_State(struct net_device *dev,
                        if (priv->RFChangeInProgress) {
                                spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
                                RT_TRACE((COMP_PS | COMP_RF),
-                                        "MgntActSet_RF_State(): RF Change in "
-                                        "progress! Wait to set..StateToSet"
-                                        "(%d).\n", StateToSet);
+                                        "MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n",
+                                        StateToSet);
 
                                while (priv->RFChangeInProgress) {
                                        RFWaitCounter++;
                                        RT_TRACE((COMP_PS | COMP_RF),
-                                                "MgntActSet_RF_State(): Wait 1"
-                                                " ms (%d times)...\n",
+                                                "MgntActSet_RF_State(): Wait 1 ms (%d times)...\n",
                                                 RFWaitCounter);
                                        mdelay(1);
 
                                        if (RFWaitCounter > 100) {
-                                               RT_TRACE(COMP_ERR, "MgntActSet_"
-                                                        "RF_State(): Wait too "
-                                                        "logn to set RF\n");
+                                               RT_TRACE(COMP_ERR,
+                                                        "MgntActSet_RF_State(): Wait too logn to set RF\n");
                                                return false;
                                        }
                                }
@@ -383,9 +380,8 @@ bool MgntActSet_RF_State(struct net_device *dev,
                            ChangeSource >= RF_CHANGE_BY_HW)
                                bConnectBySSID = true;
                } else {
-                       RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State - "
-                                "eRfon reject pMgntInfo->RfOffReason= 0x%x,"
-                                " ChangeSource=0x%X\n",
+                       RT_TRACE((COMP_PS | COMP_RF),
+                                "MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n",
                                  priv->rtllib->RfOffReason, ChangeSource);
        }
 
@@ -421,8 +417,8 @@ bool MgntActSet_RF_State(struct net_device *dev,
        }
 
        if (bActionAllowed) {
-               RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): Action is"
-                        " allowed.... StateToSet(%d), RfOffReason(%#X)\n",
+               RT_TRACE((COMP_PS | COMP_RF),
+                        "MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n",
                         StateToSet, priv->rtllib->RfOffReason);
                PHY_SetRFPowerState(dev, StateToSet);
                if (StateToSet == eRfOn) {
@@ -434,10 +430,9 @@ bool MgntActSet_RF_State(struct net_device *dev,
                        }
                }
        } else {
-               RT_TRACE((COMP_PS | COMP_RF), "MgntActSet_RF_State(): "
-                        "Action is rejected.... StateToSet(%d), ChangeSource"
-                        "(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource,
-                        priv->rtllib->RfOffReason);
+               RT_TRACE((COMP_PS | COMP_RF),
+                        "MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n",
+                        StateToSet, ChangeSource, priv->rtllib->RfOffReason);
        }
 
        if (!ProtectOrNot) {
@@ -460,9 +455,9 @@ static short rtl8192_get_nic_desc_num(struct net_device *dev, int prio)
        * between the tail and the head
        */
        if ((prio == MGNT_QUEUE) && (skb_queue_len(&ring->queue) > 10))
-               RT_TRACE(COMP_DBG, "-----[%d]---------ring->idx=%d "
-                        "queue_len=%d---------\n", prio, ring->idx,
-                        skb_queue_len(&ring->queue));
+               RT_TRACE(COMP_DBG,
+                        "-----[%d]---------ring->idx=%d queue_len=%d---------\n",
+                        prio, ring->idx, skb_queue_len(&ring->queue));
        return skb_queue_len(&ring->queue);
 }
 
@@ -481,7 +476,7 @@ void rtl8192_tx_timeout(struct net_device *dev)
        struct r8192_priv *priv = rtllib_priv(dev);
 
        schedule_work(&priv->reset_wq);
-       printk(KERN_INFO "TXTIMEOUT");
+       netdev_info(dev, "TXTIMEOUT");
 }
 
 void rtl8192_irq_enable(struct net_device *dev)
@@ -526,8 +521,9 @@ void rtl8192_update_cap(struct net_device *dev, u16 cap)
                if (priv->dot11CurrentPreambleMode != PREAMBLE_SHORT) {
                        ShortPreamble = true;
                        priv->dot11CurrentPreambleMode = PREAMBLE_SHORT;
-                       RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_SHORT_"
-                                "PREAMBLE\n", __func__);
+                       RT_TRACE(COMP_DBG,
+                                "%s(): WLAN_CAPABILITY_SHORT_PREAMBLE\n",
+                                __func__);
                        priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE,
                                        (unsigned char *)&ShortPreamble);
                }
@@ -535,8 +531,9 @@ void rtl8192_update_cap(struct net_device *dev, u16 cap)
                if (priv->dot11CurrentPreambleMode != PREAMBLE_LONG) {
                        ShortPreamble = false;
                        priv->dot11CurrentPreambleMode = PREAMBLE_LONG;
-                       RT_TRACE(COMP_DBG, "%s(): WLAN_CAPABILITY_LONG_"
-                                "PREAMBLE\n", __func__);
+                       RT_TRACE(COMP_DBG,
+                                "%s(): WLAN_CAPABILITY_LONG_PREAMBLE\n",
+                                __func__);
                        priv->rtllib->SetHwRegHandler(dev, HW_VAR_ACK_PREAMBLE,
                                              (unsigned char *)&ShortPreamble);
                }
@@ -597,8 +594,8 @@ static void rtl8192_qos_activate(void *data)
        mutex_lock(&priv->mutex);
        if (priv->rtllib->state != RTLLIB_LINKED)
                goto success;
-       RT_TRACE(COMP_QOS, "qos active process with associate response "
-                "received\n");
+       RT_TRACE(COMP_QOS,
+                "qos active process with associate response received\n");
 
        for (i = 0; i <  QOS_QUEUE_NUM; i++)
                priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&i));
@@ -634,8 +631,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
                                network->qos_data.param_count;
        priv->rtllib->wmm_acm = network->qos_data.wmm_acm;
                        queue_work_rsl(priv->priv_wq, &priv->qos_activate);
-                       RT_TRACE(COMP_QOS, "QoS parameters change call "
-                                       "qos_activate\n");
+                       RT_TRACE(COMP_QOS,
+                                "QoS parameters change call qos_activate\n");
                }
        } else {
                memcpy(&priv->rtllib->current_network.qos_data.parameters,
@@ -643,8 +640,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
 
                if ((network->qos_data.active == 1) && (active_network == 1)) {
                        queue_work_rsl(priv->priv_wq, &priv->qos_activate);
-                       RT_TRACE(COMP_QOS, "QoS was disabled call qos_"
-                                "activate\n");
+                       RT_TRACE(COMP_QOS,
+                                "QoS was disabled call qos_activate\n");
                }
                network->qos_data.active = 0;
                network->qos_data.supported = 0;
@@ -909,8 +906,9 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
                } else if ((bSupportMode & WIRELESS_MODE_B)) {
                        wireless_mode = WIRELESS_MODE_B;
                } else {
-                       RT_TRACE(COMP_ERR, "%s(), No valid wireless mode "
-                                "supported (%x)!!!\n", __func__, bSupportMode);
+                       RT_TRACE(COMP_ERR,
+                                "%s(), No valid wireless mode supported (%x)!!!\n",
+                                __func__, bSupportMode);
                        wireless_mode = WIRELESS_MODE_B;
                }
        }
@@ -1025,8 +1023,9 @@ static int rtl8192_sta_down(struct net_device *dev, bool shutdownrf)
                        spin_lock_irqsave(&priv->rf_ps_lock, flags);
                        break;
                }
-               RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait "
-                        "until rf change is done.\n", __func__);
+               RT_TRACE(COMP_DBG,
+                        "===>%s():RF is in progress, need to wait until rf change is done.\n",
+                        __func__);
                mdelay(1);
                RFInProgressTimeOut++;
                spin_lock_irqsave(&priv->rf_ps_lock, flags);
@@ -1212,8 +1211,8 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
        priv->AcmControl = 0;
        priv->pFirmware = vzalloc(sizeof(struct rt_firmware));
        if (!priv->pFirmware)
-               printk(KERN_ERR "rtl8192e: Unable to allocate space "
-                      "for firmware\n");
+               netdev_err(dev,
+                          "rtl8192e: Unable to allocate space for firmware\n");
 
        skb_queue_head_init(&priv->rx_queue);
        skb_queue_head_init(&priv->skb_queue);
@@ -1278,14 +1277,15 @@ static short rtl8192_get_channel_map(struct net_device *dev)
 
        if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256)
                        && (priv->rf_chip != RF_6052)) {
-               RT_TRACE(COMP_ERR, "%s: unknown rf chip, can't set channel "
-                        "map\n", __func__);
+               RT_TRACE(COMP_ERR,
+                        "%s: unknown rf chip, can't set channel map\n",
+                        __func__);
                return -1;
        }
 
        if (priv->ChannelPlan >= COUNTRY_CODE_MAX) {
-               printk(KERN_INFO "rtl819x_init:Error channel plan! Set to "
-                      "default.\n");
+               netdev_info(dev,
+                           "rtl819x_init:Error channel plan! Set to default.\n");
                priv->ChannelPlan = COUNTRY_CODE_FCC;
        }
        RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan);
@@ -1329,7 +1329,7 @@ static short rtl8192_init(struct net_device *dev)
        rtl8192_irq_disable(dev);
        if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED,
            dev->name, dev)) {
-               printk(KERN_ERR "Error allocating IRQ %d", dev->irq);
+               netdev_err(dev, "Error allocating IRQ %d", dev->irq);
                return -1;
        } else {
                priv->irq = dev->irq;
@@ -1337,7 +1337,7 @@ static short rtl8192_init(struct net_device *dev)
        }
 
        if (rtl8192_pci_initdescring(dev) != 0) {
-               printk(KERN_ERR "Endopoints initialization failed");
+               netdev_err(dev, "Endopoints initialization failed");
                free_irq(dev->irq, dev);
                return -1;
        }
@@ -1357,7 +1357,7 @@ short rtl8192_is_tx_queue_empty(struct net_device *dev)
                if ((i == TXCMD_QUEUE) || (i == HCCA_QUEUE))
                        continue;
                if (skb_queue_len(&(&priv->tx_ring[i])->queue) > 0) {
-                       printk(KERN_INFO "===>tx queue is not empty:%d, %d\n",
+                       netdev_info(dev, "===>tx queue is not empty:%d, %d\n",
                               i, skb_queue_len(&(&priv->tx_ring[i])->queue));
                        return 0;
                }
@@ -1406,17 +1406,18 @@ static enum reset_type rtl819x_TxCheckStuck(struct net_device *dev)
                        tcb_desc->nStuckCount++;
                        bCheckFwTxCnt = true;
                        if (tcb_desc->nStuckCount > 1)
-                               printk(KERN_INFO "%s: QueueID=%d tcb_desc->n"
-                                      "StuckCount=%d\n", __func__, QueueID,
-                                      tcb_desc->nStuckCount);
+                               netdev_info(dev,
+                                           "%s: QueueID=%d tcb_desc->nStuckCount=%d\n",
+                                           __func__, QueueID,
+                                           tcb_desc->nStuckCount);
                }
        }
        spin_unlock_irqrestore(&priv->irq_th_lock, flags);
 
        if (bCheckFwTxCnt) {
                if (priv->ops->TxCheckStuckHandler(dev)) {
-                       RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no"
-                                " Tx condition!\n");
+                       RT_TRACE(COMP_RESET,
+                                "TxCheckStuck(): Fw indicates no Tx condition!\n");
                        return RESET_TYPE_SILENT;
                }
        }
@@ -1455,13 +1456,13 @@ static enum reset_type rtl819x_ifcheck_resetornot(struct net_device *dev)
 
        if (TxResetType == RESET_TYPE_NORMAL ||
            RxResetType == RESET_TYPE_NORMAL) {
-               printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n",
-                      __func__, TxResetType, RxResetType);
+               netdev_info(dev, "%s(): TxResetType is %d, RxResetType is %d\n",
+                           __func__, TxResetType, RxResetType);
                return RESET_TYPE_NORMAL;
        } else if (TxResetType == RESET_TYPE_SILENT ||
                   RxResetType == RESET_TYPE_SILENT) {
-               printk(KERN_INFO "%s(): TxResetType is %d, RxResetType is %d\n",
-                      __func__, TxResetType, RxResetType);
+               netdev_info(dev, "%s(): TxResetType is %d, RxResetType is %d\n",
+                           __func__, TxResetType, RxResetType);
                return RESET_TYPE_SILENT;
        } else {
                return RESET_TYPE_NORESET;
@@ -1506,9 +1507,10 @@ RESET_START:
                if (priv->rtllib->state == RTLLIB_LINKED)
                        LeisurePSLeave(dev);
 
-               if (IS_NIC_DOWN(priv)) {
-                       RT_TRACE(COMP_ERR, "%s():the driver is not up! "
-                                "return\n", __func__);
+               if (priv->up) {
+                       RT_TRACE(COMP_ERR,
+                                "%s():the driver is not up! return\n",
+                                __func__);
                        up(&priv->wx_sem);
                        return;
                }
@@ -1517,8 +1519,9 @@ RESET_START:
                RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n",
                          __func__);
                mdelay(1000);
-               RT_TRACE(COMP_RESET, "%s():111111111111111111111111======>start"
-                        " to down the driver\n", __func__);
+               RT_TRACE(COMP_RESET,
+                        "%s():111111111111111111111111======>start to down the driver\n",
+                        __func__);
 
                if (!netif_queue_stopped(dev))
                        netif_stop_queue(dev);
@@ -1531,7 +1534,7 @@ RESET_START:
 
                if (ieee->state == RTLLIB_LINKED) {
                        SEM_DOWN_IEEE_WX(&ieee->wx_sem);
-                       printk(KERN_INFO "ieee->state is RTLLIB_LINKED\n");
+                       netdev_info(dev, "ieee->state is RTLLIB_LINKED\n");
                        rtllib_stop_send_beacons(priv->rtllib);
                        del_timer_sync(&ieee->associate_timer);
                        cancel_delayed_work(&ieee->associate_retry_wq);
@@ -1539,29 +1542,31 @@ RESET_START:
                        netif_carrier_off(dev);
                        SEM_UP_IEEE_WX(&ieee->wx_sem);
                } else {
-                       printk(KERN_INFO "ieee->state is NOT LINKED\n");
+                       netdev_info(dev, "ieee->state is NOT LINKED\n");
                        rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
                }
 
                dm_backup_dynamic_mechanism_state(dev);
 
                up(&priv->wx_sem);
-               RT_TRACE(COMP_RESET, "%s():<==========down process is "
-                        "finished\n", __func__);
+               RT_TRACE(COMP_RESET,
+                        "%s():<==========down process is finished\n",
+                        __func__);
 
                RT_TRACE(COMP_RESET, "%s():<===========up process start\n",
                         __func__);
                reset_status = _rtl8192_up(dev, true);
 
-               RT_TRACE(COMP_RESET, "%s():<===========up process is "
-                        "finished\n", __func__);
+               RT_TRACE(COMP_RESET,
+                        "%s():<===========up process is finished\n", __func__);
                if (reset_status == -1) {
                        if (reset_times < 3) {
                                reset_times++;
                                goto RESET_START;
                        } else {
-                               RT_TRACE(COMP_ERR, " ERR!!! %s():  Reset "
-                                        "Failed!!\n", __func__);
+                               RT_TRACE(COMP_ERR,
+                                        " ERR!!! %s():  Reset Failed!!\n",
+                                        __func__);
                        }
                }
 
@@ -1650,7 +1655,7 @@ void      rtl819x_watchdog_wqcallback(void *data)
        bool    bHigherBusyRxTraffic = false;
        bool bEnterPS = false;
 
-       if (IS_NIC_DOWN(priv) || priv->bHwRadioOff)
+       if (!priv->up || priv->bHwRadioOff)
                return;
 
        if (priv->rtllib->state >= RTLLIB_LINKED) {
@@ -1670,8 +1675,8 @@ void      rtl819x_watchdog_wqcallback(void *data)
                        if ((ieee->PowerSaveControl.ReturnPoint ==
                             IPS_CALLBACK_NONE) &&
                             (!ieee->bNetPromiscuousMode)) {
-                               RT_TRACE(COMP_PS, "====================>haha: "
-                                        "IPSEnter()\n");
+                               RT_TRACE(COMP_PS,
+                                        "====================>haha: IPSEnter()\n");
                                IPSEnter(dev);
                        }
                }
@@ -1736,8 +1741,9 @@ void      rtl819x_watchdog_wqcallback(void *data)
                        if (ieee->eRFPowerState == eRfOff)
                                RT_TRACE(COMP_ERR, "========>%s()\n", __func__);
 
-                       printk(KERN_INFO "===>%s(): AP is power off, chan:%d,"
-                              " connect another one\n", __func__, priv->chan);
+                       netdev_info(dev,
+                                   "===>%s(): AP is power off, chan:%d, connect another one\n",
+                                   __func__, priv->chan);
 
                        ieee->state = RTLLIB_ASSOCIATING;
 
@@ -1793,7 +1799,7 @@ void watch_dog_timer_callback(unsigned long data)
 
        queue_delayed_work_rsl(priv->priv_wq, &priv->watch_dog_wq, 0);
        mod_timer(&priv->watch_dog_timer, jiffies +
-                 MSECS(RTLLIB_WATCH_DOG_TIME));
+                 msecs_to_jiffies(RTLLIB_WATCH_DOG_TIME));
 }
 
 /****************************************************************************
@@ -1882,7 +1888,7 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
                                    MAX_DEV_ADDR_SIZE);
        u8 queue_index = tcb_desc->queue_index;
 
-       if ((priv->rtllib->eRFPowerState == eRfOff) || IS_NIC_DOWN(priv) ||
+       if ((priv->rtllib->eRFPowerState == eRfOff) || !priv->up ||
             priv->bResetInProgress) {
                kfree_skb(skb);
                return;
@@ -1916,7 +1922,7 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (queue_index != TXCMD_QUEUE) {
                if ((priv->rtllib->eRFPowerState == eRfOff) ||
-                    IS_NIC_DOWN(priv) || priv->bResetInProgress) {
+                    !priv->up || priv->bResetInProgress) {
                        kfree_skb(skb);
                        return 0;
                }
@@ -2007,9 +2013,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
        u32 fwinfo_size = 0;
 
        if (priv->bdisable_nic) {
-               RT_TRACE(COMP_ERR, "%s: ERR!! Nic is disabled! Can't tx packet"
-                        " len=%d qidx=%d!!!\n", __func__, skb->len,
-                        tcb_desc->queue_index);
+               RT_TRACE(COMP_ERR,
+                        "%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n",
+                        __func__, skb->len, tcb_desc->queue_index);
                return skb->len;
        }
 
@@ -2046,8 +2052,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
 
        pdesc = &ring->desc[idx];
        if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) {
-               RT_TRACE(COMP_ERR, "No more TX desc@%d, ring->idx = %d, idx = "
-                        "%d, skblen = 0x%x queuelen=%d",
+               RT_TRACE(COMP_ERR,
+                        "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d",
                         tcb_desc->queue_index, ring->idx, idx, skb->len,
                         skb_queue_len(&ring->queue));
                spin_unlock_irqrestore(&priv->irq_th_lock, flags);
@@ -2567,7 +2573,7 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac)
 
        down(&priv->wx_sem);
 
-       memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
+       ether_addr_copy(dev->dev_addr, addr->sa_data);
 
        schedule_work(&priv->reset_wq);
        up(&priv->wx_sem);
@@ -2869,7 +2875,8 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
 
        if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
-                       printk(KERN_INFO "Unable to obtain 32bit DMA for consistent allocations\n");
+                       dev_info(&pdev->dev,
+                                "Unable to obtain 32bit DMA for consistent allocations\n");
                        goto err_pci_disable;
                }
        }
@@ -2902,7 +2909,8 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
                goto err_rel_rtllib;
        }
 
-       printk(KERN_INFO "Memory mapped space start: 0x%08lx\n", pmem_start);
+       dev_info(&pdev->dev, "Memory mapped space start: 0x%08lx\n",
+                pmem_start);
        if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) {
                RT_TRACE(COMP_ERR, "request_mem_region failed!");
                goto err_rel_rtllib;
@@ -2940,8 +2948,8 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
        dev->watchdog_timeo = HZ * 3;
 
        if (dev_alloc_name(dev, ifname) < 0) {
-               RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying "
-                        "wlan%%d...\n");
+               RT_TRACE(COMP_INIT,
+                        "Oops: devname already taken! Trying wlan%%d...\n");
                        dev_alloc_name(dev, ifname);
        }
 
@@ -2981,7 +2989,7 @@ err_pci_disable:
 static void rtl8192_pci_disconnect(struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata(pdev);
-       struct r8192_priv *priv ;
+       struct r8192_priv *priv;
        u32 i;
 
        if (dev) {
@@ -3004,7 +3012,7 @@ static void rtl8192_pci_disconnect(struct pci_dev *pdev)
                        rtl8192_free_tx_ring(dev, i);
 
                if (priv->irq) {
-                       printk(KERN_INFO "Freeing irq %d\n", dev->irq);
+                       dev_info(&pdev->dev, "Freeing irq %d\n", dev->irq);
                        free_irq(dev->irq, dev);
                        priv->irq = 0;
                }
@@ -3032,7 +3040,7 @@ bool NicIFEnableNIC(struct net_device *dev)
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
                                        (&(priv->rtllib->PowerSaveControl));
 
-       if (IS_NIC_DOWN(priv)) {
+       if (!priv->up) {
                RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",
                         __func__);
                priv->bdisable_nic = false;
@@ -3059,7 +3067,6 @@ bool NicIFEnableNIC(struct net_device *dev)
 }
 bool NicIFDisableNIC(struct net_device *dev)
 {
-       bool    status = true;
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 tmp_state = 0;
 
@@ -3074,13 +3081,13 @@ bool NicIFDisableNIC(struct net_device *dev)
        priv->ops->stop_adapter(dev, false);
        RT_TRACE(COMP_PS, "<=========%s()\n", __func__);
 
-       return status;
+       return true;
 }
 
 static int __init rtl8192_pci_module_init(void)
 {
-       printk(KERN_INFO "\nLinux kernel driver for RTL8192E WLAN cards\n");
-       printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan Driver\n");
+       pr_info("\nLinux kernel driver for RTL8192E WLAN cards\n");
+       pr_info("Copyright (c) 2007-2008, Realsil Wlan Driver\n");
 
        if (0 != pci_register_driver(&rtl8192_pci_driver)) {
                DMESG("No device found");
@@ -3106,7 +3113,7 @@ void check_rfctrl_gpio_timer(unsigned long data)
        queue_delayed_work_rsl(priv->priv_wq, &priv->gpio_change_rf_wq, 0);
 
        mod_timer(&priv->gpio_polling_timer, jiffies +
-                 MSECS(RTLLIB_WATCH_DOG_TIME));
+                 msecs_to_jiffies(RTLLIB_WATCH_DOG_TIME));
 }
 
 /***************************************************************************
index d1438c2f8980e35b92351c7e0126886d3718075c..d365af6ebdc7b56bb71729d4e3e332e15eb9fbca 100644 (file)
 #define BIT(_i)                                (1<<(_i))
 #endif
 
-#define IS_NIC_DOWN(priv)      (!(priv)->up)
-
 #define IS_ADAPTER_SENDS_BEACON(dev) 0
 
-#define IS_UNDER_11N_AES_MODE(_rtllib)         \
-       ((_rtllib->pHTInfo->bCurrentHTSupport == true) && \
-       (_rtllib->pairwise_key_type == KEY_TYPE_CCMP))
-
 #define HAL_MEMORY_MAPPED_IO_RANGE_8190PCI     0x1000
 #define HAL_HW_PCI_REVISION_ID_8190PCI                 0x00
 #define HAL_MEMORY_MAPPED_IO_RANGE_8192PCIE    0x4000
@@ -1004,14 +998,14 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb);
 
 u8 read_nic_io_byte(struct net_device *dev, int x);
 u32 read_nic_io_dword(struct net_device *dev, int x);
-u16 read_nic_io_word(struct net_device *dev, int x) ;
+u16 read_nic_io_word(struct net_device *dev, int x);
 void write_nic_io_byte(struct net_device *dev, int x, u8 y);
 void write_nic_io_word(struct net_device *dev, int x, u16 y);
 void write_nic_io_dword(struct net_device *dev, int x, u32 y);
 
 u8 read_nic_byte(struct net_device *dev, int x);
 u32 read_nic_dword(struct net_device *dev, int x);
-u16 read_nic_word(struct net_device *dev, int x) ;
+u16 read_nic_word(struct net_device *dev, int x);
 void write_nic_byte(struct net_device *dev, int x, u8 y);
 void write_nic_word(struct net_device *dev, int x, u16 y);
 void write_nic_dword(struct net_device *dev, int x, u32 y);
index b8891c62af3e3d116b7891ee7d89fa66c74a3159..aa95e88a693118e7cd3395f65acc98af77209353 100644 (file)
@@ -267,7 +267,7 @@ static void dm_check_rate_adaptive(struct net_device *dev)
        bool bshort_gi_enabled = false;
        static u8 ping_rssi_state;
 
-       if (IS_NIC_DOWN(priv)) {
+       if (!priv->up) {
                RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
                return;
        }
@@ -757,8 +757,8 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
                for (i = 0; i < CCK_Table_length; i++) {
                        if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) {
                                priv->CCK_index = (u8) i;
-                               RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x"
-                                        " = 0x%x, CCK_index = 0x%x\n",
+                               RT_TRACE(COMP_POWER_TRACKING,
+                                        "Initial reg0x%x = 0x%x, CCK_index = 0x%x\n",
                                         rCCK0_TxFilter1, TempCCk,
                                         priv->CCK_index);
                                break;
@@ -803,8 +803,8 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
 
        priv->Record_CCK_20Mindex = tmpCCK20Mindex;
        priv->Record_CCK_40Mindex = tmpCCK40Mindex;
-       RT_TRACE(COMP_POWER_TRACKING, "Record_CCK_20Mindex / Record_CCK_40"
-                "Mindex = %d / %d.\n",
+       RT_TRACE(COMP_POWER_TRACKING,
+                "Record_CCK_20Mindex / Record_CCK_40Mindex = %d / %d.\n",
                 priv->Record_CCK_20Mindex, priv->Record_CCK_40Mindex);
 
        if (priv->rtllib->current_network.channel == 14 &&
@@ -1420,7 +1420,8 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
                TM_Trigger = 1;
                return;
        } else {
-           printk(KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n");
+               netdev_info(dev,
+                           "===============>Schedule TxPowerTrackingWorkItem\n");
 
                queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0);
                TM_Trigger = 0;
@@ -1446,7 +1447,7 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
        TempVal = 0;
        if (!bInCH14) {
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
-                         (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
+                         (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8));
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
@@ -1455,12 +1456,12 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
                          (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
-                         (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
+                         (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8));
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
        } else {
                TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
-                         (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8)) ;
+                         (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8));
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
@@ -1469,7 +1470,7 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool  bInCH14)
                          (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
                rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
                TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
-                         (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8)) ;
+                         (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8));
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
        }
@@ -1485,7 +1486,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
        TempVal = 0;
        if (!bInCH14) {
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
-                                       (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8) ;
+                                       (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);
@@ -1497,14 +1498,14 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,    bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
                TempVal =       CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
-                                       (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8) ;
+                                       (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8);
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_DebugPort, TempVal);
        } else {
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][0] +
-                                       (CCKSwingTable_Ch14[priv->CCK_index][1]<<8) ;
+                                       (CCKSwingTable_Ch14[priv->CCK_index][1]<<8);
 
                rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
@@ -1517,7 +1518,7 @@ static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,      bool  bInCH
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
                        rCCK0_TxFilter2, TempVal);
                TempVal =       CCKSwingTable_Ch14[priv->CCK_index][6] +
-                                       (CCKSwingTable_Ch14[priv->CCK_index][7]<<8) ;
+                                       (CCKSwingTable_Ch14[priv->CCK_index][7]<<8);
 
                rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
                RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
@@ -1569,7 +1570,7 @@ void dm_restore_dynamic_mechanism_state(struct net_device *dev)
        u32     reg_ratr = priv->rate_adaptive.last_ratr;
        u32 ratr_value;
 
-       if (IS_NIC_DOWN(priv)) {
+       if (!priv->up) {
                RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
                return;
        }
@@ -2131,10 +2132,10 @@ static void dm_check_edca_turbo(struct net_device *dev)
                static int wb_tmp;
 
                if (wb_tmp == 0) {
-                       printk(KERN_INFO "%s():iot peer is %s, bssid:"
-                              " %pM\n", __func__,
-                              peername[pHTInfo->IOTPeer],
-                              priv->rtllib->current_network.bssid);
+                       netdev_info(dev,
+                                   "%s():iot peer is %s, bssid: %pM\n",
+                                   __func__, peername[pHTInfo->IOTPeer],
+                                   priv->rtllib->current_network.bssid);
                        wb_tmp = 1;
                }
        }
@@ -2638,9 +2639,10 @@ void dm_fsync_timer_callback(unsigned long data)
                }
                priv->rate_record = rate_count;
                priv->rateCountDiffRecord = rate_count_diff;
-               RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rate"
-                        "Countdiff %d bSwitchFsync %d\n", priv->rate_record,
-                        rate_count, rate_count_diff, priv->bswitch_fsync);
+               RT_TRACE(COMP_HALDM,
+                        "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n",
+                        priv->rate_record, rate_count, rate_count_diff,
+                        priv->bswitch_fsync);
                if (priv->undecorated_smoothed_pwdb >
                    priv->rtllib->fsync_rssi_threshold &&
                    bSwitchFromCountDiff) {
@@ -2665,14 +2667,14 @@ void dm_fsync_timer_callback(unsigned long data)
                        if (timer_pending(&priv->fsync_timer))
                                del_timer_sync(&priv->fsync_timer);
                        priv->fsync_timer.expires = jiffies +
-                                MSECS(priv->rtllib->fsync_time_interval *
+                                msecs_to_jiffies(priv->rtllib->fsync_time_interval *
                                 priv->rtllib->fsync_multiple_timeinterval);
                        add_timer(&priv->fsync_timer);
                } else {
                        if (timer_pending(&priv->fsync_timer))
                                del_timer_sync(&priv->fsync_timer);
                        priv->fsync_timer.expires = jiffies +
-                                MSECS(priv->rtllib->fsync_time_interval);
+                                msecs_to_jiffies(priv->rtllib->fsync_time_interval);
                        add_timer(&priv->fsync_timer);
                }
        } else {
@@ -2685,9 +2687,10 @@ void dm_fsync_timer_callback(unsigned long data)
                write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
        }
        RT_TRACE(COMP_HALDM, "ContinueDiffCount %d\n", priv->ContinueDiffCount);
-       RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d "
-                "bSwitchFsync %d\n", priv->rate_record, rate_count,
-                rate_count_diff, priv->bswitch_fsync);
+       RT_TRACE(COMP_HALDM,
+                "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n",
+                priv->rate_record, rate_count, rate_count_diff,
+                priv->bswitch_fsync);
 }
 
 static void dm_StartHWFsync(struct net_device *dev)
@@ -2762,7 +2765,7 @@ static void dm_StartSWFsync(struct net_device *dev)
        if (timer_pending(&priv->fsync_timer))
                del_timer_sync(&priv->fsync_timer);
        priv->fsync_timer.expires = jiffies +
-                                   MSECS(priv->rtllib->fsync_time_interval);
+                                   msecs_to_jiffies(priv->rtllib->fsync_time_interval);
        add_timer(&priv->fsync_timer);
 
        write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
@@ -2778,12 +2781,14 @@ void dm_check_fsync(struct net_device *dev)
        static u8 reg_c38_State = RegC38_Default;
        static u32 reset_cnt;
 
-       RT_TRACE(COMP_HALDM, "RSSI %d TimeInterval %d MultipleTimeInterval "
-                "%d\n", priv->rtllib->fsync_rssi_threshold,
+       RT_TRACE(COMP_HALDM,
+                "RSSI %d TimeInterval %d MultipleTimeInterval %d\n",
+                priv->rtllib->fsync_rssi_threshold,
                 priv->rtllib->fsync_time_interval,
                 priv->rtllib->fsync_multiple_timeinterval);
-       RT_TRACE(COMP_HALDM, "RateBitmap 0x%x FirstDiffRateThreshold %d Second"
-                "DiffRateThreshold %d\n", priv->rtllib->fsync_rate_bitmap,
+       RT_TRACE(COMP_HALDM,
+                "RateBitmap 0x%x FirstDiffRateThreshold %d SecondDiffRateThreshold %d\n",
+                priv->rtllib->fsync_rate_bitmap,
                 priv->rtllib->fsync_firstdiff_ratethreshold,
                 priv->rtllib->fsync_seconddiff_ratethreshold);
 
index ab44a9a6927c7e5755814a6d1260f059d13e3b8a..3f02e11cfc57ec9d8599d797f5098871f909ded5 100644 (file)
@@ -255,14 +255,6 @@ extern     u8                      test_flag;
 /*------------------------Export global variable----------------------------*/
 
 
-/*------------------------Export Marco Definition---------------------------*/
-#define DM_APInitGainChangeNotify(Event)               \
-       {                                               \
-               dm_digtable.CurAPConnectState = Event;  \
-       }
-/*------------------------Export Marco Definition---------------------------*/
-
-
 /*--------------------------Exported Function prototype---------------------*/
 /*--------------------------Exported Function prototype---------------------*/
 extern  void    init_hal_dm(struct net_device *dev);
index 2ad92eee50c27dc47aa2be0922f70a740811f814..51f53be2de17f01e0b0090ce28ed3b90a142c2f7 100644 (file)
@@ -65,27 +65,32 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev)
        if (DeviceID == 0x8172) {
                switch (RevisionID) {
                case HAL_HW_PCI_REVISION_ID_8192PCIE:
-                       printk(KERN_INFO "Adapter(8192 PCI-E) is found - "
-                              "DeviceID=%x\n", DeviceID);
+                       dev_info(&pdev->dev,
+                                "Adapter(8192 PCI-E) is found - DeviceID=%x\n",
+                                DeviceID);
                        priv->card_8192 = NIC_8192E;
                        break;
                case HAL_HW_PCI_REVISION_ID_8192SE:
-                       printk(KERN_INFO "Adapter(8192SE) is found - "
-                              "DeviceID=%x\n", DeviceID);
+                       dev_info(&pdev->dev,
+                                "Adapter(8192SE) is found - DeviceID=%x\n",
+                                DeviceID);
                        priv->card_8192 = NIC_8192SE;
                        break;
                default:
-                       printk(KERN_INFO "UNKNOWN nic type(%4x:%4x)\n",
-                              pdev->vendor, pdev->device);
+                       dev_info(&pdev->dev,
+                                "UNKNOWN nic type(%4x:%4x)\n",
+                                pdev->vendor, pdev->device);
                        priv->card_8192 = NIC_UNKNOWN;
                        return false;
                }
        }
 
        if (priv->ops->nic_type != priv->card_8192) {
-               printk(KERN_INFO "Detect info(%x) and hardware info(%x) not match!\n",
-                               priv->ops->nic_type, priv->card_8192);
-               printk(KERN_INFO "Please select proper driver before install!!!!\n");
+               dev_info(&pdev->dev,
+                        "Detect info(%x) and hardware info(%x) not match!\n",
+                        priv->ops->nic_type, priv->card_8192);
+               dev_info(&pdev->dev,
+                        "Please select proper driver before install!!!!\n");
                return false;
        }
 
index 0b4f76481bf4322f7d764a5e33754628db618ece..ca6ecfc8299e88b75a5b0b9357afd51707c5494a 100644 (file)
@@ -29,14 +29,14 @@ int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state)
        struct r8192_priv *priv = rtllib_priv(dev);
        u32     ulRegRead;
 
-       printk(KERN_INFO "============> r8192E suspend call.\n");
+       netdev_info(dev, "============> r8192E suspend call.\n");
        del_timer_sync(&priv->gpio_polling_timer);
        cancel_delayed_work(&priv->gpio_change_rf_wq);
        priv->polling_timer_on = 0;
 
        if (!netif_running(dev)) {
-               printk(KERN_INFO "RTL819XE:UI is open out of suspend "
-                      "function\n");
+               netdev_info(dev,
+                           "RTL819XE:UI is open out of suspend function\n");
                goto out_pci_suspend;
        }
 
@@ -57,10 +57,10 @@ int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state)
                write_nic_byte(dev, MacBlkCtrl, 0xa);
        }
 out_pci_suspend:
-       printk("r8192E support WOL call??????????????????????\n");
+       netdev_info(dev, "r8192E support WOL call??????????????????????\n");
        if (priv->rtllib->bSupportRemoteWakeUp)
-               RT_TRACE(COMP_POWER, "r8192E support WOL call!!!!!!!"
-                        "!!!!!!!!!!!.\n");
+               RT_TRACE(COMP_POWER,
+                        "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n");
        pci_save_state(pdev);
        pci_disable_device(pdev);
        pci_enable_wake(pdev, pci_choose_state(pdev, state),
@@ -79,14 +79,13 @@ int rtl8192E_resume(struct pci_dev *pdev)
        int err;
        u32 val;
 
-       printk(KERN_INFO "================>r8192E resume call.\n");
+       netdev_info(dev, "================>r8192E resume call.\n");
 
        pci_set_power_state(pdev, PCI_D0);
 
        err = pci_enable_device(pdev);
        if (err) {
-               printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
-                      dev->name);
+               netdev_err(dev, "pci_enable_device failed on resume\n");
                return err;
        }
        pci_restore_state(pdev);
@@ -101,8 +100,8 @@ int rtl8192E_resume(struct pci_dev *pdev)
                check_rfctrl_gpio_timer((unsigned long)dev);
 
        if (!netif_running(dev)) {
-               printk(KERN_INFO "RTL819XE:UI is open out of resume "
-                      "function\n");
+               netdev_info(dev,
+                           "RTL819XE:UI is open out of resume function\n");
                goto out;
        }
 
index 4856b76292f9a3507340c2f89139cf99b3856f07..40c3be9a5e54d630230f711af88534e32d05dcfc 100644 (file)
@@ -37,8 +37,8 @@ static void rtl8192_hw_sleep_down(struct net_device *dev)
        spin_lock_irqsave(&priv->rf_ps_lock, flags);
        if (priv->RFChangeInProgress) {
                spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
-               RT_TRACE(COMP_DBG, "rtl8192_hw_sleep_down(): RF Change in "
-                        "progress!\n");
+               RT_TRACE(COMP_DBG,
+                        "rtl8192_hw_sleep_down(): RF Change in progress!\n");
                return;
        }
        spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
@@ -64,10 +64,11 @@ void rtl8192_hw_wakeup(struct net_device *dev)
        spin_lock_irqsave(&priv->rf_ps_lock, flags);
        if (priv->RFChangeInProgress) {
                spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
-               RT_TRACE(COMP_DBG, "rtl8192_hw_wakeup(): RF Change in "
-                        "progress!\n");
+               RT_TRACE(COMP_DBG,
+                        "rtl8192_hw_wakeup(): RF Change in progress!\n");
                queue_delayed_work_rsl(priv->rtllib->wq,
-                                      &priv->rtllib->hw_wakeup_wq, MSECS(10));
+                                      &priv->rtllib->hw_wakeup_wq,
+                                      msecs_to_jiffies(10));
                return;
        }
        spin_unlock_irqrestore(&priv->rf_ps_lock, flags);
@@ -95,18 +96,18 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time)
 
        spin_lock_irqsave(&priv->ps_lock, flags);
 
-       time -= MSECS(8+16+7);
+       time -= msecs_to_jiffies(8 + 16 + 7);
 
-       if ((time - jiffies) <= MSECS(MIN_SLEEP_TIME)) {
+       if ((time - jiffies) <= msecs_to_jiffies(MIN_SLEEP_TIME)) {
                spin_unlock_irqrestore(&priv->ps_lock, flags);
-               printk(KERN_INFO "too short to sleep::%lld < %ld\n",
-                      time - jiffies, MSECS(MIN_SLEEP_TIME));
+               netdev_info(dev, "too short to sleep::%lld < %ld\n",
+                           time - jiffies, msecs_to_jiffies(MIN_SLEEP_TIME));
                return;
        }
 
-       if ((time - jiffies) > MSECS(MAX_SLEEP_TIME)) {
-               printk(KERN_INFO "========>too long to sleep:%lld > %ld\n",
-                      time - jiffies,  MSECS(MAX_SLEEP_TIME));
+       if ((time - jiffies) > msecs_to_jiffies(MAX_SLEEP_TIME)) {
+               netdev_info(dev, "========>too long to sleep:%lld > %ld\n",
+                           time - jiffies, msecs_to_jiffies(MAX_SLEEP_TIME));
                spin_unlock_irqrestore(&priv->ps_lock, flags);
                return;
        }
@@ -202,8 +203,8 @@ void rtllib_ips_leave_wq(struct net_device *dev)
                                         __func__);
                                return;
                        } else {
-                               printk(KERN_INFO "=========>%s(): IPSLeave\n",
-                                      __func__);
+                               netdev_info(dev, "=========>%s(): IPSLeave\n",
+                                           __func__);
                                queue_work_rsl(priv->rtllib->wq,
                                               &priv->rtllib->ips_leave_wq);
                        }
@@ -239,8 +240,8 @@ static bool MgntActSet_802_11_PowerSaveMode(struct net_device *dev,
                priv->rtllib->sta_sleep = LPS_IS_WAKE;
 
                spin_lock_irqsave(&(priv->rtllib->mgmt_tx_lock), flags);
-               RT_TRACE(COMP_DBG, "LPS leave: notify AP we are awaked"
-                        " ++++++++++ SendNullFunctionData\n");
+               RT_TRACE(COMP_DBG,
+                        "LPS leave: notify AP we are awaked ++++++++++ SendNullFunctionData\n");
                rtllib_sta_ps_send_null_frame(priv->rtllib, 0);
                spin_unlock_irqrestore(&(priv->rtllib->mgmt_tx_lock), flags);
        }
@@ -255,8 +256,8 @@ void LeisurePSEnter(struct net_device *dev)
                                        &(priv->rtllib->PowerSaveControl);
 
        RT_TRACE(COMP_PS, "LeisurePSEnter()...\n");
-       RT_TRACE(COMP_PS, "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdle"
-                "Count is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n",
+       RT_TRACE(COMP_PS,
+                "pPSC->bLeisurePs = %d, ieee->ps = %d,pPSC->LpsIdleCount is %d,RT_CHECK_FOR_HANG_PERIOD is %d\n",
                 pPSC->bLeisurePs, priv->rtllib->ps, pPSC->LpsIdleCount,
                 RT_CHECK_FOR_HANG_PERIOD);
 
@@ -271,8 +272,8 @@ void LeisurePSEnter(struct net_device *dev)
 
                        if (priv->rtllib->ps == RTLLIB_PS_DISABLED) {
 
-                               RT_TRACE(COMP_LPS, "LeisurePSEnter(): Enter "
-                                        "802.11 power save mode...\n");
+                               RT_TRACE(COMP_LPS,
+                                        "LeisurePSEnter(): Enter 802.11 power save mode...\n");
 
                                if (!pPSC->bFwCtrlLPS) {
                                        if (priv->rtllib->SetFwCmdHandler)
@@ -301,8 +302,8 @@ void LeisurePSLeave(struct net_device *dev)
 
        if (pPSC->bLeisurePs) {
                if (priv->rtllib->ps != RTLLIB_PS_DISABLED) {
-                       RT_TRACE(COMP_LPS, "LeisurePSLeave(): Busy Traffic , "
-                                "Leave 802.11 power save..\n");
+                       RT_TRACE(COMP_LPS,
+                                "LeisurePSLeave(): Busy Traffic , Leave 802.11 power save..\n");
                        MgntActSet_802_11_PowerSaveMode(dev,
                                         RTLLIB_PS_DISABLED);
 
index df0323f00f69c1e808a9a1e790d49740bfba281c..d074f974fe110c5ad8a232b3207710f633d620ff 100644 (file)
@@ -67,7 +67,7 @@ static int r8192_wx_set_rate(struct net_device *dev,
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -87,7 +87,7 @@ static int r8192_wx_set_rts(struct net_device *dev,
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -115,9 +115,10 @@ static int r8192_wx_set_power(struct net_device *dev,
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true) {
-               RT_TRACE(COMP_ERR, "%s():Hw is Radio Off, we can't set "
-                        "Power,return\n", __func__);
+       if (priv->bHwRadioOff) {
+               RT_TRACE(COMP_ERR,
+                        "%s():Hw is Radio Off, we can't set Power,return\n",
+                        __func__);
                return 0;
        }
        down(&priv->wx_sem);
@@ -145,7 +146,7 @@ static int r8192_wx_set_rawtx(struct net_device *dev,
        struct r8192_priv *priv = rtllib_priv(dev);
        int ret;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -254,10 +255,11 @@ static int r8192se_wx_set_radio(struct net_device *dev,
 
        down(&priv->wx_sem);
 
-       printk(KERN_INFO "%s(): set radio ! extra is %d\n", __func__, *extra);
+       netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra);
        if ((*extra != 0) && (*extra != 1)) {
-               RT_TRACE(COMP_ERR, "%s(): set radio an err value,must 0(radio "
-                        "off) or 1(radio on)\n", __func__);
+               RT_TRACE(COMP_ERR,
+                        "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",
+                        __func__);
                up(&priv->wx_sem);
                return -1;
        }
@@ -277,8 +279,8 @@ static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
 
        down(&priv->wx_sem);
 
-       printk(KERN_INFO "%s(): set lps awake interval ! extra is %d\n",
-              __func__, *extra);
+       netdev_info(dev, "%s(): set lps awake interval ! extra is %d\n",
+                   __func__, *extra);
 
        pPSC->RegMaxLPSAwakeIntvl = *extra;
        up(&priv->wx_sem);
@@ -293,8 +295,9 @@ static int r8192se_wx_set_force_lps(struct net_device *dev,
 
        down(&priv->wx_sem);
 
-       printk(KERN_INFO "%s(): force LPS ! extra is %d (1 is open 0 is "
-              "close)\n", __func__, *extra);
+       netdev_info(dev,
+                   "%s(): force LPS ! extra is %d (1 is open 0 is close)\n",
+                   __func__, *extra);
        priv->force_lps = *extra;
        up(&priv->wx_sem);
        return 0;
@@ -308,11 +311,11 @@ static int r8192_wx_set_debugflag(struct net_device *dev,
        struct r8192_priv *priv = rtllib_priv(dev);
        u8 c = *extra;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
-       printk(KERN_INFO "=====>%s(), *extra:%x, debugflag:%x\n", __func__,
-              *extra, rt_global_debug_component);
+       netdev_info(dev, "=====>%s(), *extra:%x, debugflag:%x\n", __func__,
+                   *extra, rt_global_debug_component);
        if (c > 0)
                rt_global_debug_component |= (1<<c);
        else
@@ -329,7 +332,7 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
        enum rt_rf_power_state rtState;
        int ret;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
        rtState = priv->rtllib->eRFPowerState;
        down(&priv->wx_sem);
@@ -344,8 +347,9 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
                                        up(&priv->wx_sem);
                                        return -1;
                                } else {
-                                       printk(KERN_INFO "=========>%s(): "
-                                              "IPSLeave\n", __func__);
+                                       netdev_info(dev,
+                                                   "=========>%s(): IPSLeave\n",
+                                                   __func__);
                                        down(&priv->rtllib->ips_sem);
                                        IPSLeave(dev);
                                        up(&priv->rtllib->ips_sem);
@@ -470,9 +474,9 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                        return 0;
        }
 
-       if (priv->bHwRadioOff == true) {
-               printk(KERN_INFO "================>%s(): hwradio off\n",
-                      __func__);
+       if (priv->bHwRadioOff) {
+               netdev_info(dev, "================>%s(): hwradio off\n",
+                           __func__);
                return 0;
        }
        rtState = priv->rtllib->eRFPowerState;
@@ -500,13 +504,15 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
                        if (rtState == eRfOff) {
                                if (priv->rtllib->RfOffReason >
                                    RF_CHANGE_BY_IPS) {
-                                       RT_TRACE(COMP_ERR, "%s(): RF is "
-                                                "OFF.\n", __func__);
+                                       RT_TRACE(COMP_ERR,
+                                                "%s(): RF is OFF.\n",
+                                                __func__);
                                        up(&priv->wx_sem);
                                        return -1;
                                } else {
-                                       RT_TRACE(COMP_PS, "=========>%s(): "
-                                                "IPSLeave\n", __func__);
+                                       RT_TRACE(COMP_PS,
+                                                "=========>%s(): IPSLeave\n",
+                                                __func__);
                                        down(&priv->rtllib->ips_sem);
                                        IPSLeave(dev);
                                        up(&priv->rtllib->ips_sem);
@@ -552,7 +558,7 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
        if (!priv->up)
                return -ENETDOWN;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
 
@@ -572,13 +578,10 @@ static int r8192_wx_set_essid(struct net_device *dev,
        struct r8192_priv *priv = rtllib_priv(dev);
        int ret;
 
-       if ((rtllib_act_scanning(priv->rtllib, false)) &&
-           !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
-               ;       /* TODO - get rid of if */
-       }
-       if (priv->bHwRadioOff == true) {
-               printk(KERN_INFO "=========>%s():hw radio off,or Rf state is "
-                      "eRfOff, return\n", __func__);
+       if (priv->bHwRadioOff) {
+               netdev_info(dev,
+                           "=========>%s():hw radio off,or Rf state is eRfOff, return\n",
+                           __func__);
                return 0;
        }
        down(&priv->wx_sem);
@@ -642,7 +645,7 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a,
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -669,7 +672,7 @@ static int r8192_wx_set_frag(struct net_device *dev,
 {
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        if (wrqu->frag.disabled)
@@ -708,12 +711,7 @@ static int r8192_wx_set_wap(struct net_device *dev,
        int ret;
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if ((rtllib_act_scanning(priv->rtllib, false)) &&
-           !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN)) {
-               ;       /* TODO - get rid of if */
-       }
-
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -763,10 +761,7 @@ static int r8192_wx_set_enc(struct net_device *dev,
                             {0x00, 0x00, 0x00, 0x00, 0x00, 0x03} };
        int i;
 
-       if ((rtllib_act_scanning(priv->rtllib, false)) &&
-          !(priv->rtllib->softmac_features & IEEE_SOFTMAC_SCAN))
-               ;       /* TODO - get rid of if */
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        if (!priv->up)
@@ -838,7 +833,8 @@ static int r8192_wx_set_enc(struct net_device *dev,
                        set_swcam(dev, key_idx, key_idx, KEY_TYPE_WEP104,
                                  zero_addr[key_idx], 0, hwkey, 0);
                } else {
-                        printk(KERN_INFO "wrong type in WEP, not WEP40 and WEP104\n");
+                       netdev_info(dev,
+                                   "wrong type in WEP, not WEP40 and WEP104\n");
                }
        }
 
@@ -855,7 +851,7 @@ static int r8192_wx_set_scan_type(struct net_device *dev,
        int *parms = (int *)p;
        int mode = parms[0];
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        priv->rtllib->active_scan = mode;
@@ -873,7 +869,7 @@ static int r8192_wx_set_retry(struct net_device *dev,
        struct r8192_priv *priv = rtllib_priv(dev);
        int err = 0;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -956,7 +952,7 @@ static int r8192_wx_set_sens(struct net_device *dev,
 
        short err = 0;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -983,7 +979,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
        struct r8192_priv *priv = rtllib_priv(dev);
        struct rtllib_device *ieee = priv->rtllib;
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -1064,7 +1060,7 @@ static int r8192_wx_set_auth(struct net_device *dev,
 
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -1082,7 +1078,7 @@ static int r8192_wx_set_mlme(struct net_device *dev,
 
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -1099,7 +1095,7 @@ static int r8192_wx_set_gen_ie(struct net_device *dev,
 
        struct r8192_priv *priv = rtllib_priv(dev);
 
-       if (priv->bHwRadioOff == true)
+       if (priv->bHwRadioOff)
                return 0;
 
        down(&priv->wx_sem);
@@ -1160,8 +1156,10 @@ static int r8192_wx_set_PromiscuousMode(struct net_device *dev,
                        (rtllib_EnableIntelPromiscuousMode(dev, false)) :
                        (rtllib_DisableIntelPromiscuousMode(dev, false));
 
-               printk(KERN_INFO "=======>%s(), on = %d, filter src sta = %d\n",
-                      __func__, bPromiscuousOn, bFilterSourceStationFrame);
+               netdev_info(dev,
+                           "=======>%s(), on = %d, filter src sta = %d\n",
+                           __func__, bPromiscuousOn,
+                           bFilterSourceStationFrame);
        } else {
                return -1;
        }
index 0415e02b4eff4d23287d7e874fb1ee3d09cbee55..26258ea8de4aa540ca945e33cefdb87bc542f97c 100644 (file)
@@ -26,7 +26,7 @@ static void ActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA,
 {
        pBA->bValid = true;
        if (Time != 0)
-               mod_timer(&pBA->Timer, jiffies + MSECS(Time));
+               mod_timer(&pBA->Timer, jiffies + msecs_to_jiffies(Time));
 }
 
 static void DeActivateBAEntry(struct rtllib_device *ieee, struct ba_record *pBA)
@@ -83,9 +83,9 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
        u8 *tag = NULL;
        u16 len = ieee->tx_headroom + 9;
 
-       RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "========>%s(), frame(%d)"
-                    " sentd to: %pM, ieee->dev:%p\n", __func__,
-                    type, Dst, ieee->dev);
+       RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
+                    "========>%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n",
+                    __func__, type, Dst, ieee->dev);
        if (pBA == NULL) {
                RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n");
                return NULL;
@@ -148,9 +148,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
 
        if (net_ratelimit())
                RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
-                            "========>%s(), Reason"
-                            "Code(%d) sentd to: %pM\n", __func__,
-                            ReasonCode, dst);
+                            "========>%s(), ReasonCode(%d) sentd to: %pM\n",
+                            __func__, ReasonCode, dst);
 
        memset(&DelbaParamSet, 0, 2);
 
@@ -203,8 +202,8 @@ static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst,
                RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n");
                softmac_mgmt_xmit(skb, ieee);
        } else {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function"
-                            " %s()\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "alloc skb error in function %s()\n", __func__);
        }
 }
 
@@ -217,8 +216,8 @@ static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst,
        if (skb)
                softmac_mgmt_xmit(skb, ieee);
        else
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function"
-                            " %s()\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "alloc skb error in function %s()\n", __func__);
 }
 
 static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
@@ -231,8 +230,8 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
        if (skb)
                softmac_mgmt_xmit(skb, ieee);
        else
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "alloc skb error in function"
-                            " %s()\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "alloc skb error in function %s()\n", __func__);
 }
 
 int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
@@ -247,8 +246,9 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
        struct rx_ts_record *pTS = NULL;
 
        if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BAREQ(%d / "
-                            "%d)\n", (int)skb->len,
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            " Invalid skb len in BAREQ(%d / %d)\n",
+                            (int)skb->len,
                             (int)(sizeof(struct rtllib_hdr_3addr) + 9));
                return -1;
        }
@@ -269,8 +269,8 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
            (ieee->pHTInfo->bCurrentHTSupport == false) ||
            (ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
                rc = ADDBA_STATUS_REFUSED;
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "Failed to reply on ADDBA_REQ as "
-                            "some capability is not ready(%d, %d)\n",
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n",
                             ieee->current_network.qos_data.active,
                             ieee->pHTInfo->bCurrentHTSupport);
                goto OnADDBAReq_Fail;
@@ -285,8 +285,8 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
 
        if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
                rc = ADDBA_STATUS_INVALID_PARAM;
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "BA Policy is not correct in "
-                            "%s()\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "BA Policy is not correct in %s()\n", __func__);
                goto OnADDBAReq_Fail;
        }
 
@@ -333,8 +333,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
        u16                     ReasonCode;
 
        if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in BARSP(%d / "
-                            "%d)\n", (int)skb->len,
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "Invalid skb len in BARSP(%d / %d)\n",
+                            (int)skb->len,
                             (int)(sizeof(struct rtllib_hdr_3addr) + 9));
                return -1;
        }
@@ -351,8 +352,8 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
        if (ieee->current_network.qos_data.active == 0  ||
            ieee->pHTInfo->bCurrentHTSupport == false ||
            ieee->pHTInfo->bCurrentAMPDUEnable == false) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "reject to ADDBA_RSP as some capab"
-                            "ility is not ready(%d, %d, %d)\n",
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",
                             ieee->current_network.qos_data.active,
                             ieee->pHTInfo->bCurrentHTSupport,
                             ieee->pHTInfo->bCurrentAMPDUEnable);
@@ -374,18 +375,19 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
 
 
        if (pAdmittedBA->bValid == true) {
-               RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp."
-                            " Drop because already admit it!\n");
+               RTLLIB_DEBUG(RTLLIB_DL_BA,
+                            "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it!\n");
                return -1;
        } else if ((pPendingBA->bValid == false) ||
                   (*pDialogToken != pPendingBA->DialogToken)) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR,  "OnADDBARsp(): Recv ADDBA Rsp. "
-                            "BA invalid, DELBA!\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA!\n");
                ReasonCode = DELBA_REASON_UNKNOWN_BA;
                goto OnADDBARsp_Reject;
        } else {
-               RTLLIB_DEBUG(RTLLIB_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. BA "
-                            "is admitted! Status code:%X\n", *pStatusCode);
+               RTLLIB_DEBUG(RTLLIB_DL_BA,
+                            "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n",
+                            *pStatusCode);
                DeActivateBAEntry(ieee, pPendingBA);
        }
 
@@ -432,16 +434,17 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
        u8 *dst = NULL;
 
        if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, " Invalid skb len in DELBA(%d /"
-                            " %d)\n", (int)skb->len,
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "Invalid skb len in DELBA(%d / %d)\n",
+                            (int)skb->len,
                             (int)(sizeof(struct rtllib_hdr_3addr) + 6));
                return -1;
        }
 
        if (ieee->current_network.qos_data.active == 0  ||
                ieee->pHTInfo->bCurrentHTSupport == false) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "received DELBA while QOS or HT "
-                            "is not supported(%d, %d)\n",
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "received DELBA while QOS or HT is not supported(%d, %d)\n",
                             ieee->current_network. qos_data.active,
                             ieee->pHTInfo->bCurrentHTSupport);
                return -1;
@@ -459,8 +462,9 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
 
                if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst,
                    (u8)pDelBaParamSet->field.TID, RX_DIR, false)) {
-                       RTLLIB_DEBUG(RTLLIB_DL_ERR,  "can't get TS for RXTS in "
-                                    "%s().dst: %pM TID:%d\n", __func__, dst,
+                       RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                                    "can't get TS for RXTS in %s().dst: %pM TID:%d\n",
+                                    __func__, dst,
                                     (u8)pDelBaParamSet->field.TID);
                        return -1;
                }
@@ -471,8 +475,9 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
 
                if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst,
                           (u8)pDelBaParamSet->field.TID, TX_DIR, false)) {
-                       RTLLIB_DEBUG(RTLLIB_DL_ERR,  "can't get TS for TXTS in "
-                                    "%s()\n", __func__);
+                       RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                                    "can't get TS for TXTS in %s()\n",
+                                    __func__);
                        return -1;
                }
 
index 13f41057461a19938b0e36b9e8f3bf59fa10ca10..f7076d7ddc5357e71b04113dc90232a5e0e44787 100644 (file)
@@ -77,43 +77,6 @@ enum chnl_op {
        CHNLOP_SWCHNL = 3,
 };
 
-#define CHHLOP_IN_PROGRESS(_pHTInfo)   \
-               ((_pHTInfo)->ChnlOp > CHNLOP_NONE) ? true : false
-
-/*
-union ht_capability {
-       u16     ShortData;
-       u8      CharData[2];
-       struct
-       {
-               u16     AdvCoding:1;
-               u16     ChlWidth:1;
-               u16     MimoPwrSave:2;
-               u16     GreenField:1;
-               u16     ShortGI20Mhz:1;
-               u16     ShortGI40Mhz:1;
-               u16     STBC:1;
-               u16     BeamForm:1;
-               u16     DelayBA:1;
-               u16     MaxAMSDUSize:1;
-               u16     DssCCk:1;
-               u16     PSMP:1;
-               u16     Rsvd:3;
-       }Field;
-};
-
-union ht_capability_macpara {
-       u8      ShortData;
-       u8      CharData[1];
-       struct
-       {
-               u8      MaxRxAMPDU:2;
-               u8      MPDUDensity:2;
-               u8      Rsvd:4;
-       }Field;
-};
-*/
-
 enum ht_action {
        ACT_RECOMMAND_WIDTH             = 0,
        ACT_MIMO_PWR_SAVE               = 1,
@@ -380,16 +343,6 @@ struct false_alarm_stats {
 extern u8 MCS_FILTER_ALL[16];
 extern u8 MCS_FILTER_1SS[16];
 
-#define PICK_RATE(_nLegacyRate, _nMcsRate)     \
-               ((_nMcsRate == 0) ? (_nLegacyRate&0x7f) : (_nMcsRate))
-#define        LEGACY_WIRELESS_MODE    IEEE_MODE_MASK
-
-#define CURRENT_RATE(WirelessMode, LegacyRate, HTRate) \
-                       ((WirelessMode & (LEGACY_WIRELESS_MODE)) != 0) ? \
-                       (LegacyRate) : (PICK_RATE(LegacyRate, HTRate))
-
-
-
 #define        RATE_ADPT_1SS_MASK              0xFF
 #define        RATE_ADPT_2SS_MASK              0xF0
 #define        RATE_ADPT_MCS32_MASK            0x01
index 1ea426b7b7acd5401c172986811b5b5d689c02c5..9820dd2df5f3721ccd8f3a8ad9574b81da3dae85 100644 (file)
@@ -117,160 +117,6 @@ void HTUpdateDefaultSetting(struct rtllib_device *ieee)
        pHTInfo->RxReorderPendingTime = 30;
 }
 
-void HTDebugHTCapability(u8 *CapIE, u8 *TitleString)
-{
-
-       static u8       EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33};
-       struct ht_capab_ele *pCapELE;
-
-       if (!memcmp(CapIE, EWC11NHTCap, sizeof(EWC11NHTCap))) {
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__);
-               pCapELE = (struct ht_capab_ele *)(&CapIE[4]);
-       } else
-               pCapELE = (struct ht_capab_ele *)(&CapIE[0]);
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "<Log HT Capability>. Called by %s\n",
-                    TitleString);
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tSupported Channel Width = %s\n",
-                    (pCapELE->ChlWidth) ? "20MHz" : "20/40MHz");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tSupport Short GI for 20M = %s\n",
-                    (pCapELE->ShortGI20Mhz) ? "YES" : "NO");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tSupport Short GI for 40M = %s\n",
-                    (pCapELE->ShortGI40Mhz) ? "YES" : "NO");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tSupport TX STBC = %s\n",
-                    (pCapELE->TxSTBC) ? "YES" : "NO");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tMax AMSDU Size = %s\n",
-                    (pCapELE->MaxAMSDUSize) ? "3839" : "7935");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tSupport CCK in 20/40 mode = %s\n",
-                    (pCapELE->DssCCk) ? "YES" : "NO");
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tMax AMPDU Factor = %d\n",
-                    pCapELE->MaxRxAMPDUFactor);
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tMPDU Density = %d\n",
-                    pCapELE->MPDUDensity);
-       RTLLIB_DEBUG(RTLLIB_DL_HT,  "\tMCS Rate Set = [%x][%x][%x][%x][%x]\n",
-                    pCapELE->MCS[0], pCapELE->MCS[1], pCapELE->MCS[2],
-                    pCapELE->MCS[3], pCapELE->MCS[4]);
-       return;
-
-}
-
-void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString)
-{
-
-       static u8       EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
-       struct ht_info_ele *pHTInfoEle;
-
-       if (!memcmp(InfoIE, EWC11NHTInfo, sizeof(EWC11NHTInfo))) {
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "EWC IE in %s()\n", __func__);
-               pHTInfoEle = (struct ht_info_ele *)(&InfoIE[4]);
-       } else
-               pHTInfoEle = (struct ht_info_ele *)(&InfoIE[0]);
-
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "<Log HT Information Element>. "
-                    "Called by %s\n", TitleString);
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "\tPrimary channel = %d\n",
-                    pHTInfoEle->ControlChl);
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "\tSenondary channel =");
-       switch (pHTInfoEle->ExtChlOffset) {
-       case 0:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "Not Present\n");
-               break;
-       case 1:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "Upper channel\n");
-               break;
-       case 2:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "Reserved. Eooro!!!\n");
-               break;
-       case 3:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "Lower Channel\n");
-               break;
-       }
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "\tRecommended channel width = %s\n",
-                    (pHTInfoEle->RecommemdedTxWidth) ? "20Mhz" : "40Mhz");
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "\tOperation mode for protection = ");
-       switch (pHTInfoEle->OptMode) {
-       case 0:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "No Protection\n");
-               break;
-       case 1:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "HT non-member protection mode\n");
-               break;
-       case 2:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "Suggest to open protection\n");
-               break;
-       case 3:
-               RTLLIB_DEBUG(RTLLIB_DL_HT, "HT mixed mode\n");
-               break;
-       }
-
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "\tBasic MCS Rate Set = [%x][%x][%x][%x]"
-                    "[%x]\n", pHTInfoEle->BasicMSC[0], pHTInfoEle->BasicMSC[1],
-                    pHTInfoEle->BasicMSC[2], pHTInfoEle->BasicMSC[3],
-                    pHTInfoEle->BasicMSC[4]);
-}
-
-static bool IsHTHalfNmode40Bandwidth(struct rtllib_device *ieee)
-{
-       bool                    retValue = false;
-       struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
-
-       if (pHTInfo->bCurrentHTSupport == false)
-               retValue = false;
-       else if (pHTInfo->bRegBW40MHz == false)
-               retValue = false;
-       else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
-               retValue = false;
-       else if (((struct ht_capab_ele *)(pHTInfo->PeerHTCapBuf))->ChlWidth)
-               retValue = true;
-       else
-               retValue = false;
-
-       return retValue;
-}
-
-static bool IsHTHalfNmodeSGI(struct rtllib_device *ieee, bool is40MHz)
-{
-       bool                    retValue = false;
-       struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
-
-       if (pHTInfo->bCurrentHTSupport == false)
-               retValue = false;
-       else if (!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
-               retValue = false;
-       else if (is40MHz) {
-               if (((struct ht_capab_ele *)
-                   (pHTInfo->PeerHTCapBuf))->ShortGI40Mhz)
-                       retValue = true;
-               else
-                       retValue = false;
-       } else {
-               if (((struct ht_capab_ele *)
-                  (pHTInfo->PeerHTCapBuf))->ShortGI20Mhz)
-                       retValue = true;
-               else
-                       retValue = false;
-       }
-
-       return retValue;
-}
-
-u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
-{
-
-       u8      is40MHz;
-       u8      isShortGI;
-
-       is40MHz  =  (IsHTHalfNmode40Bandwidth(ieee)) ? 1 : 0;
-       isShortGI = (IsHTHalfNmodeSGI(ieee, is40MHz)) ? 1 : 0;
-
-       return MCS_DATA_RATE[is40MHz][isShortGI][(nMcsRate & 0x7f)];
-}
-
-
 u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate)
 {
        struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
@@ -386,9 +232,7 @@ static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr)
 
 static bool HTIOTActIsDisableMCS15(struct rtllib_device *ieee)
 {
-       bool retValue = false;
-
-       return retValue;
+       return false;
 }
 
 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee)
@@ -450,8 +294,8 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
        struct ht_capab_ele *pCapELE = NULL;
 
        if ((posHTCap == NULL) || (pHT == NULL)) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTCap or pHTInfo can't be "
-                            "null in HTConstructCapabilityElement()\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
                return;
        }
        memset(posHTCap, 0, *len);
@@ -487,9 +331,9 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
        pCapELE->LSigTxopProtect = 0;
 
 
-       RTLLIB_DEBUG(RTLLIB_DL_HT, "TX HT cap/info ele BW=%d MaxAMSDUSize:%d "
-                    "DssCCk:%d\n", pCapELE->ChlWidth, pCapELE->MaxAMSDUSize,
-                    pCapELE->DssCCk);
+       RTLLIB_DEBUG(RTLLIB_DL_HT,
+                    "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
+                    pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
 
        if (IsEncrypt) {
                pCapELE->MPDUDensity    = 7;
@@ -532,8 +376,8 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo,
        struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo;
 
        if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "posHTInfo or pHTInfoEle can't be "
-                            "null in HTConstructInfoElement()\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
                return;
        }
 
@@ -572,8 +416,8 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg,
                                u8 *len)
 {
        if (posRT2RTAgg == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "posRT2RTAgg can't be null in "
-                            "HTConstructRT2RTAggElement()\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
                return;
        }
        memset(posRT2RTAgg, 0, *len);
@@ -596,8 +440,8 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS)
        u8 i;
 
        if (pOperateMCS == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "pOperateMCS can't be null"
-                            " in HT_PickMCSRate()\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "pOperateMCS can't be null in HT_PickMCSRate()\n");
                return false;
        }
 
@@ -631,8 +475,8 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
        u8              availableMcsRate[16];
 
        if (pMCSRateSet == NULL || pMCSFilter == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "pMCSRateSet or pMCSFilter can't "
-                            "be null in HTGetHighestMCSRate()\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
                return false;
        }
        for (i = 0; i < 16; i++)
@@ -654,7 +498,7 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
                                            HTMcsToDataRate(ieee, mcsRate))
                                                mcsRate = (8*i+j);
                                }
-                               bitMap = bitMap>>1;
+                               bitMap >>= 1;
                        }
                }
        }
@@ -697,8 +541,8 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
        static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
 
        if (pHTInfo->bCurrentHTSupport == false) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "<=== HTOnAssocRsp(): "
-                            "HT_DISABLE\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "<=== HTOnAssocRsp(): HT_DISABLE\n");
                return;
        }
        RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
@@ -999,8 +843,8 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame)
 {
        if (ieee->pHTInfo->bCurrentHTSupport) {
                if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
-                       RTLLIB_DEBUG(RTLLIB_DL_HT, "HT CONTROL FILED "
-                                    "EXIST!!\n");
+                       RTLLIB_DEBUG(RTLLIB_DL_HT,
+                                    "HT CONTROL FILED EXIST!!\n");
                        return true;
                }
        }
index 973342b8a06da3dbe62e5f906af9b7dfc9e742f8..55ef7ec33f650f448e465e98971cd1a58d90c639 100644 (file)
@@ -19,8 +19,6 @@
 #ifndef __INC_QOS_TYPE_H
 #define __INC_QOS_TYPE_H
 
-#include "rtllib_endianfree.h"
-
 #define BIT0               0x00000001
 #define BIT1               0x00000002
 #define BIT2               0x00000004
@@ -340,18 +338,6 @@ struct sta_qos {
 };
 
 #define QBSS_LOAD_SIZE                         5
-#define GET_QBSS_LOAD_STA_COUNT(__pStart)      \
-               ReadEF2Byte(__pStart)
-#define SET_QBSS_LOAD_STA_COUNT(__pStart, __Value)     \
-               WriteEF2Byte(__pStart, __Value)
-#define GET_QBSS_LOAD_CHNL_UTILIZATION(__pStart)       \
-               ReadEF1Byte((u8 *)(__pStart) + 2)
-#define SET_QBSS_LOAD_CHNL_UTILIZATION(__pStart, __Value)      \
-               WriteEF1Byte((u8 *)(__pStart) + 2, __Value)
-#define GET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart)     \
-               ReadEF2Byte((u8 *)(__pStart) + 3)
-#define SET_QBSS_LOAD_AVAILABLE_CAPACITY(__pStart, __Value) \
-               WriteEF2Byte((u8 *)(__pStart) + 3, __Value)
 
 struct bss_qos {
        QOS_MODE bdQoSMode;
@@ -367,10 +353,6 @@ struct bss_qos {
        bool bQBssLoadValid;
 };
 
-#define sQoSCtlLng     2
-#define QOS_CTRL_LEN(_QosMode) ((_QosMode > QOS_DISABLE) ? sQoSCtlLng : 0)
-
-
 #define IsACValid(ac)          ((ac >= 0 && ac <= 7) ? true : false)
 
 
index 294847d1a90347a4eb524e706acdc7cc07e9ed07..735ae60e574014131125f0675889fbcb0ef5317d 100644 (file)
@@ -58,9 +58,9 @@ static void RxPktPendingTimeout(unsigned long data)
                                        pRxTs->RxIndicateSeq =
                                              (pRxTs->RxIndicateSeq + 1) % 4096;
 
-                               RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate"
-                                            " SeqNum: %d\n", __func__,
-                                            pReorderEntry->SeqNum);
+                               RTLLIB_DEBUG(RTLLIB_DL_REORDER,
+                                            "%s(): Indicate SeqNum: %d\n",
+                                            __func__, pReorderEntry->SeqNum);
                                ieee->stats_IndicateArray[index] =
                                                         pReorderEntry->prxb;
                                index++;
@@ -78,8 +78,8 @@ static void RxPktPendingTimeout(unsigned long data)
                pRxTs->RxTimeoutIndicateSeq = 0xffff;
 
                if (index > REORDER_WIN_SIZE) {
-                       RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket():"
-                                    " Rx Reorder struct buffer full!!\n");
+                       RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                                    "RxReorderIndicatePacket(): Rx Reorder struct buffer full!!\n");
                        spin_unlock_irqrestore(&(ieee->reorder_spinlock),
                                               flags);
                        return;
@@ -91,7 +91,7 @@ static void RxPktPendingTimeout(unsigned long data)
        if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) {
                pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
                mod_timer(&pRxTs->RxPktPendingTimer,  jiffies +
-                         MSECS(ieee->pHTInfo->RxReorderPendingTime));
+                         msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime));
        }
        spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
 }
@@ -104,8 +104,8 @@ static void TsAddBaProcess(unsigned long data)
                                     TxTsRecord[num]);
 
        TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
-       RTLLIB_DEBUG(RTLLIB_DL_BA, "TsAddBaProcess(): ADDBA Req is "
-                    "started!!\n");
+       RTLLIB_DEBUG(RTLLIB_DL_BA,
+                    "TsAddBaProcess(): ADDBA Req is started!!\n");
 }
 
 static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo)
@@ -223,7 +223,7 @@ static void AdmitTS(struct rtllib_device *ieee,
 
        if (InactTime != 0)
                mod_timer(&pTsCommonInfo->InactTimer, jiffies +
-                         MSECS(InactTime));
+                         msecs_to_jiffies(InactTime));
 }
 
 static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee,
@@ -313,16 +313,17 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
        u8      UP = 0;
 
        if (is_multicast_ether_addr(Addr)) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or "
-                            "Multicast\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "ERR! get TS for Broadcast or Multicast\n");
                return false;
        }
        if (ieee->current_network.qos_data.supported == 0) {
                UP = 0;
        } else {
                if (!IsACValid(TID)) {
-                       RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! in %s(), TID(%d) is "
-                                    "not valid\n", __func__, TID);
+                       RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                                    "ERR! in %s(), TID(%d) is not valid\n",
+                                    __func__, TID);
                        return false;
                }
 
@@ -351,8 +352,8 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
                return true;
        } else {
                if (!bAddNewTs) {
-                       RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed"
-                                    "(tid:%d)\n", UP);
+                       RTLLIB_DEBUG(RTLLIB_DL_TS,
+                                    "add new TS failed(tid:%d)\n", UP);
                        return false;
                } else {
                        union tspec_body TSpec;
@@ -390,10 +391,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
                                        ResetRxTsEntry(tmp);
                                }
 
-                               RTLLIB_DEBUG(RTLLIB_DL_TS, "to init current TS"
-                                            ", UP:%d, Dir:%d, addr: %pM"
-                                            " ppTs=%p\n", UP, Dir,
-                                             Addr, *ppTS);
+                               RTLLIB_DEBUG(RTLLIB_DL_TS,
+                                            "to init current TS, UP:%d, Dir:%d, addr: %pM ppTs=%p\n",
+                                            UP, Dir, Addr, *ppTS);
                                pTSInfo->field.ucTrafficType = 0;
                                pTSInfo->field.ucTSID = UP;
                                pTSInfo->field.ucDirection = Dir;
@@ -410,10 +410,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
 
                                return true;
                        } else {
-                               RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!in function "
-                                            "%s() There is not enough dir=%d"
-                                            "(0=up down=1) TS record to be "
-                                            "used!!", __func__, Dir);
+                               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                                            "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!",
+                                            __func__, Dir);
                                return false;
                        }
                }
@@ -438,8 +437,8 @@ static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs
                        pRxReorderEntry = (struct rx_reorder_entry *)
                                        list_entry(pRxTS->RxPendingPktList.prev,
                                        struct rx_reorder_entry, List);
-                       RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Delete SeqNum "
-                                    "%d!\n", __func__,
+                       RTLLIB_DEBUG(RTLLIB_DL_REORDER,
+                                    "%s(): Delete SeqNum %d!\n", __func__,
                                     pRxReorderEntry->SeqNum);
                        list_del_init(&pRxReorderEntry->List);
                        {
@@ -467,7 +466,7 @@ void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr)
 {
        struct ts_common_info *pTS, *pTmpTS;
 
-       printk(KERN_INFO "===========>RemovePeerTS, %pM\n", Addr);
+       netdev_info(ieee->dev, "===========>RemovePeerTS, %pM\n", Addr);
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, List) {
                if (memcmp(pTS->Addr, Addr, 6) == 0) {
@@ -479,7 +478,8 @@ void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr)
 
        list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Admit_List, List) {
                if (memcmp(pTS->Addr, Addr, 6) == 0) {
-                       printk(KERN_INFO "====>remove Tx_TS_admin_list\n");
+                       netdev_info(ieee->dev,
+                                   "====>remove Tx_TS_admin_list\n");
                        RemoveTsEntry(ieee, pTS, TX_DIR);
                        list_del_init(&pTS->List);
                        list_add_tail(&pTS->List, &ieee->Tx_TS_Unused_List);
@@ -539,13 +539,13 @@ void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS)
                pTxTS->bAddBaReqInProgress = true;
 
                if (pTxTS->bAddBaReqDelayed) {
-                       RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): "
-                                    "Delayed Start ADDBA after 60 sec!!\n");
+                       RTLLIB_DEBUG(RTLLIB_DL_BA,
+                                    "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
                        mod_timer(&pTxTS->TsAddBaTimer, jiffies +
-                                 MSECS(TS_ADDBA_DELAY));
+                                 msecs_to_jiffies(TS_ADDBA_DELAY));
                } else {
-                       RTLLIB_DEBUG(RTLLIB_DL_BA, "TsStartAddBaProcess(): "
-                                    "Immediately Start ADDBA now!!\n");
+                       RTLLIB_DEBUG(RTLLIB_DL_BA,
+                                    "TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
                        mod_timer(&pTxTS->TsAddBaTimer, jiffies+10);
                }
        } else
index cef2dc27103f30223dd08cf4ddc770d5d158b8fd..dc9f675150e737a350905fda6ff8e3f131b63ad0 100644 (file)
 #define IW_CUSTOM_MAX  256     /* In bytes */
 #endif
 
-#ifndef container_of
-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr:       the pointer to the member.
- * @type:       the type of the container struct this is embedded in.
- * @member:     the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({                   \
-       const typeof(((type *)0)->member)*__mptr = (ptr);    \
-       (type *)((char *)__mptr - offsetof(type, member)); })
-#endif
-
 #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
 
 #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
@@ -482,9 +468,6 @@ enum rt_op_mode {
 #define        IEEE_CRYPT_ALG_NAME_LEN                 16
 
 #define MAX_IE_LEN  0xff
-#define RT_ASSERT_RET(_Exp) do {} while (0)
-#define RT_ASSERT_RET_VALUE(_Exp, Ret)         \
-       do {} while (0)
 
 struct ieee_param {
        u32 cmd;
@@ -525,7 +508,6 @@ struct ieee_param {
 #define IW_QUAL_NOISE_UPDATED  0x4
 #endif
 
-#define MSECS(t) msecs_to_jiffies(t)
 #define msleep_interruptible_rsl  msleep_interruptible
 
 #define RTLLIB_DATA_LEN                2304
@@ -769,8 +751,8 @@ do {                                                                \
 #define RTLLIB_DL_TRACE           (1<<29)
 #define RTLLIB_DL_DATA    (1<<30)
 #define RTLLIB_DL_ERR     (1<<31)
-#define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
-#define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
+#define RTLLIB_ERROR(f, a...) pr_err("rtllib: " f, ## a)
+#define RTLLIB_WARNING(f, a...) pr_warn("rtllib: " f, ## a)
 #define RTLLIB_DEBUG_INFO(f, a...)   RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
 
 #define RTLLIB_DEBUG_WX(f, a...)     RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
@@ -784,26 +766,6 @@ do {                                                               \
 #define RTLLIB_DEBUG_RX(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
 #define RTLLIB_DEBUG_QOS(f, a...)  RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
 
-/* Added by Annie, 2005-11-22. */
-#define MAX_STR_LEN     64
-/* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
-#define PRINTABLE(_ch)  (_ch > '!' && _ch < '~')
-#define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len)              \
-       if ((_Comp) & level) {                                         \
-               int          __i;                                   \
-               u8  struct buffer[MAX_STR_LEN];                         \
-               int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\
-               memset(struct buffer, 0, MAX_STR_LEN);          \
-               memcpy(struct buffer, (u8 *)_Ptr, length);              \
-               for (__i = 0; __i < MAX_STR_LEN; __i++) {               \
-                       if (!PRINTABLE(struct buffer[__i]))             \
-                               struct buffer[__i] = '?';               \
-               }                                                       \
-               struct buffer[length] = '\0';                           \
-               printk(KERN_INFO "Rtl819x: ");                          \
-               printk(_TitleString);                                   \
-               printk(": %d, <%s>\n", _Len, struct buffer);            \
-       }
 #ifndef ETH_P_PAE
 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
 #define ETH_P_IP       0x0800          /* Internet Protocol packet     */
@@ -1670,7 +1632,6 @@ struct rtllib_network {
        struct list_head list;
 };
 
-#if 1
 enum rtllib_state {
 
        /* the card is not linked at all */
@@ -1708,17 +1669,6 @@ enum rtllib_state {
         */
        RTLLIB_LINKED_SCANNING,
 };
-#else
-enum rtllib_state {
-       RTLLIB_UNINITIALIZED = 0,
-       RTLLIB_INITIALIZED,
-       RTLLIB_ASSOCIATING,
-       RTLLIB_ASSOCIATED,
-       RTLLIB_AUTHENTICATING,
-       RTLLIB_AUTHENTICATED,
-       RTLLIB_SHUTDOWN
-};
-#endif
 
 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
 #define DEFAULT_FTS 2346
@@ -1736,11 +1686,6 @@ enum rtllib_state {
 #define RTLLIB_52GHZ_MAX_CHANNEL 165
 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
                                  RTLLIB_52GHZ_MIN_CHANNEL + 1)
-#ifndef eqMacAddr
-#define eqMacAddr(a, b)                                        \
-       (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] &&   \
-       (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
-#endif
 struct tx_pending {
        int frag;
        struct rtllib_txb *txb;
@@ -2276,7 +2221,7 @@ struct rtllib_device {
        short raw_tx;
        /* used if IEEE_SOFTMAC_TX_QUEUE is set */
        short queue_stop;
-       short scanning_continue ;
+       short scanning_continue;
        short proto_started;
        short proto_stoppping;
 
@@ -2882,8 +2827,6 @@ extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra);
 #define MAX_RECEIVE_BUFFER_SIZE 9100
-extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
-extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
 
 void HTSetConnectBwMode(struct rtllib_device *ieee,
                        enum ht_channel_width Bandwidth,
@@ -2906,11 +2849,10 @@ extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
 extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
                              u8 *pMCSFilter);
 extern u8 MCS_FILTER_ALL[];
-extern u16 MCS_DATA_RATE[2][2][77] ;
+extern u16 MCS_DATA_RATE[2][2][77];
 extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
 extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
 extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
-extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
 extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
 extern u16  TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
 extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
index 60c0cedefb86d94382f846c60ad91df173be326c..807ba1b92447c5f8be6a535ccf4dc8b6580397e2 100644 (file)
@@ -62,8 +62,9 @@ void rtllib_crypt_deinit_handler(unsigned long data)
        spin_lock_irqsave(info->lock, flags);
        rtllib_crypt_deinit_entries(info, 0);
        if (!list_empty(&info->crypt_deinit_list)) {
-               printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
-                      "deletion list\n", info->name);
+               printk(KERN_DEBUG
+                      "%s: entries remaining in delayed crypt deletion list\n",
+                      info->name);
                info->crypt_deinit_timer.expires = jiffies + HZ;
                add_timer(&info->crypt_deinit_timer);
        }
@@ -145,8 +146,8 @@ int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
        spin_unlock_irqrestore(&hcrypt->lock, flags);
 
        if (del_alg) {
-               printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm "
-                      "'%s'\n", ops->name);
+               printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm '%s'\n",
+                      ops->name);
                kfree(del_alg);
        }
 
@@ -237,8 +238,9 @@ void __exit rtllib_crypto_deinit(void)
                struct rtllib_crypto_alg *alg =
                        (struct rtllib_crypto_alg *) ptr;
                list_del(ptr);
-               printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm "
-                      "'%s' (deinit)\n", alg->ops->name);
+               printk(KERN_DEBUG
+                      "rtllib_crypt: unregistered algorithm '%s' (deinit)\n",
+                      alg->ops->name);
                kfree(alg);
        }
 
index 01f85db98e0d2091702c8af3d6a0a38be4f1d3bc..c0b8bb289e7de5413277509135ad46800f1222b5 100644 (file)
@@ -69,8 +69,7 @@ static void *rtllib_ccmp_init(int key_idx)
 
        priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->tfm)) {
-               pr_debug("rtllib_crypt_ccmp: could not allocate "
-                      "crypto API aes\n");
+               pr_debug("rtllib_crypt_ccmp: could not allocate crypto API aes\n");
                priv->tfm = NULL;
                goto fail;
        }
@@ -278,23 +277,22 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        keyidx = pos[3];
        if (!(keyidx & (1 << 5))) {
                if (net_ratelimit()) {
-                       pr_debug("CCMP: received packet without ExtIV"
-                              " flag from %pM\n", hdr->addr2);
+                       pr_debug("CCMP: received packet without ExtIV flag from %pM\n",
+                                hdr->addr2);
                }
                key->dot11RSNAStatsCCMPFormatErrors++;
                return -2;
        }
        keyidx >>= 6;
        if (key->key_idx != keyidx) {
-               pr_debug("CCMP: RX tkey->key_idx=%d frame "
-                      "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
+               pr_debug("CCMP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+                        key->key_idx, keyidx, priv);
                return -6;
        }
        if (!key->key_set) {
                if (net_ratelimit()) {
-                       pr_debug("CCMP: received packet from %pM"
-                              " with keyid=%d that does not have a configured"
-                              " key\n", hdr->addr2, keyidx);
+                       pr_debug("CCMP: received packet from %pM with keyid=%d that does not have a configured key\n",
+                                hdr->addr2, keyidx);
                }
                return -3;
        }
@@ -341,8 +339,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
                if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
                        if (net_ratelimit()) {
-                               pr_debug("CCMP: decrypt failed: STA="
-                               " %pM\n", hdr->addr2);
+                               pr_debug("CCMP: decrypt failed: STA= %pM\n",
+                                        hdr->addr2);
                        }
                        key->dot11RSNAStatsCCMPDecryptErrors++;
                        return -5;
@@ -419,9 +417,7 @@ static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
        struct rtllib_ccmp_data *ccmp = priv;
 
        seq_printf(m,
-                  "key[%d] alg=CCMP key_set=%d "
-                  "tx_pn=%pM rx_pn=%pM "
-                  "format_errors=%d replays=%d decrypt_errors=%d\n",
+                  "key[%d] alg=CCMP key_set=%d tx_pn=%pM rx_pn=%pM format_errors=%d replays=%d decrypt_errors=%d\n",
                   ccmp->key_idx, ccmp->key_set,
                   ccmp->tx_pn, ccmp->rx_pn,
                   ccmp->dot11RSNAStatsCCMPFormatErrors,
index 78db2b6826f77c7cb62d850fbfc0cc858f58910a..ccf85309b4b6beadcae993060fa45477a40fadb7 100644 (file)
@@ -66,8 +66,8 @@ static void *rtllib_tkip_init(int key_idx)
        priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
                        CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->tx_tfm_arc4)) {
-               printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate "
-                               "crypto API arc4\n");
+               printk(KERN_DEBUG
+                      "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
                priv->tx_tfm_arc4 = NULL;
                goto fail;
        }
@@ -75,8 +75,8 @@ static void *rtllib_tkip_init(int key_idx)
        priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
                        CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->tx_tfm_michael)) {
-               printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate "
-                               "crypto API michael_mic\n");
+               printk(KERN_DEBUG
+                      "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
                priv->tx_tfm_michael = NULL;
                goto fail;
        }
@@ -84,8 +84,8 @@ static void *rtllib_tkip_init(int key_idx)
        priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
                        CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->rx_tfm_arc4)) {
-               printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate "
-                               "crypto API arc4\n");
+               printk(KERN_DEBUG
+                      "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
                priv->rx_tfm_arc4 = NULL;
                goto fail;
        }
@@ -93,8 +93,8 @@ static void *rtllib_tkip_init(int key_idx)
        priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
                        CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->rx_tfm_michael)) {
-               printk(KERN_DEBUG "rtllib_crypt_tkip: could not allocate "
-                               "crypto API michael_mic\n");
+               printk(KERN_DEBUG
+                      "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
                priv->rx_tfm_michael = NULL;
                goto fail;
        }
@@ -399,22 +399,24 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        keyidx = pos[3];
        if (!(keyidx & (1 << 5))) {
                if (net_ratelimit()) {
-                       printk(KERN_DEBUG "TKIP: received packet without ExtIV"
-                              " flag from %pM\n", hdr->addr2);
+                       printk(KERN_DEBUG
+                              "TKIP: received packet without ExtIV flag from %pM\n",
+                              hdr->addr2);
                }
                return -2;
        }
        keyidx >>= 6;
        if (tkey->key_idx != keyidx) {
-               printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "
-                      "keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);
+               printk(KERN_DEBUG
+                      "TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+                      tkey->key_idx, keyidx, priv);
                return -6;
        }
        if (!tkey->key_set) {
                if (net_ratelimit()) {
-                       printk(KERN_DEBUG "TKIP: received packet from %pM"
-                              " with keyid=%d that does not have a configured"
-                              " key\n", hdr->addr2, keyidx);
+                       printk(KERN_DEBUG
+                              "TKIP: received packet from %pM with keyid=%d that does not have a configured key\n",
+                              hdr->addr2, keyidx);
                }
                return -3;
        }
@@ -427,10 +429,10 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) &&
                    tkey->initialized) {
                        if (net_ratelimit()) {
-                               printk(KERN_DEBUG "TKIP: replay detected: STA="
-                                      " %pM previous TSC %08x%04x received "
-                                     "TSC %08x%04x\n", hdr->addr2,
-                                     tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
+                               printk(KERN_DEBUG
+                                      "TKIP: replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n",
+                                      hdr->addr2, tkey->rx_iv32, tkey->rx_iv16,
+                                      iv32, iv16);
                        }
                        tkey->dot11RSNAStatsTKIPReplays++;
                        return -4;
@@ -451,8 +453,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
                if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
                        if (net_ratelimit()) {
-                               printk(KERN_DEBUG ": TKIP: failed to decrypt "
-                                      "received packet from %pM\n",
+                               printk(KERN_DEBUG
+                                      ": TKIP: failed to decrypt received packet from %pM\n",
                                       hdr->addr2);
                        }
                        return -7;
@@ -472,8 +474,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                                tkey->rx_phase1_done = 0;
                        }
                        if (net_ratelimit()) {
-                               printk(KERN_DEBUG "TKIP: ICV error detected: STA="
-                               " %pM\n", hdr->addr2);
+                               printk(KERN_DEBUG
+                                      "TKIP: ICV error detected: STA= %pM\n",
+                                      hdr->addr2);
                        }
                        tkey->dot11RSNAStatsTKIPICVErrors++;
                        return -5;
@@ -502,7 +505,7 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
        struct scatterlist sg[2];
 
        if (tfm_michael == NULL) {
-               printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
+               pr_warn("michael_mic: tfm_michael == NULL\n");
                return -1;
        }
        sg_init_table(sg, 2);
@@ -557,8 +560,8 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
        hdr = (struct rtllib_hdr_4addr *) skb->data;
 
        if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
-               printk(KERN_DEBUG "Invalid packet for Michael MIC add "
-                      "(tailroom=%d hdr_len=%d skb->len=%d)\n",
+               printk(KERN_DEBUG
+                      "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n",
                       skb_tailroom(skb), hdr_len, skb->len);
                return -1;
        }
@@ -621,14 +624,14 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
                struct rtllib_hdr_4addr *hdr;
 
                hdr = (struct rtllib_hdr_4addr *) skb->data;
-               printk(KERN_DEBUG "%s: Michael MIC verification failed for "
-                      "MSDU from %pM keyidx=%d\n",
+               printk(KERN_DEBUG
+                      "%s: Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
                       skb->dev ? skb->dev->name : "N/A", hdr->addr2,
                       keyidx);
                printk(KERN_DEBUG "%d\n",
                       memcmp(mic, skb->data + skb->len - 8, 8) != 0);
                if (skb->dev) {
-                       printk(KERN_INFO "skb->dev != NULL\n");
+                       pr_info("skb->dev != NULL\n");
                        rtllib_michael_mic_failure(skb->dev, hdr, keyidx);
                }
                tkey->dot11RSNAStatsTKIPLocalMICFailures++;
@@ -717,10 +720,7 @@ static void rtllib_tkip_print_stats(struct seq_file *m, void *priv)
        struct rtllib_tkip_data *tkip = priv;
 
        seq_printf(m,
-                  "key[%d] alg=TKIP key_set=%d "
-                  "tx_pn=%02x%02x%02x%02x%02x%02x "
-                  "rx_pn=%02x%02x%02x%02x%02x%02x "
-                  "replays=%d icv_errors=%d local_mic_failures=%d\n",
+                  "key[%d] alg=TKIP key_set=%d tx_pn=%02x%02x%02x%02x%02x%02x rx_pn=%02x%02x%02x%02x%02x%02x replays=%d icv_errors=%d local_mic_failures=%d\n",
                   tkip->key_idx, tkip->key_set,
                   (tkip->tx_iv32 >> 24) & 0xff,
                   (tkip->tx_iv32 >> 16) & 0xff,
index 75e7b02a144abd3058f7545264be3f071a08ffb3..06c79fabdcd30c23fde81ee7066eda0b7ac41dcf 100644 (file)
@@ -44,15 +44,13 @@ static void *prism2_wep_init(int keyidx)
 
        priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->tx_tfm)) {
-               pr_debug("rtllib_crypt_wep: could not allocate "
-                      "crypto API arc4\n");
+               pr_debug("rtllib_crypt_wep: could not allocate crypto API arc4\n");
                priv->tx_tfm = NULL;
                goto fail;
        }
        priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->rx_tfm)) {
-               pr_debug("rtllib_crypt_wep: could not allocate "
-                      "crypto API arc4\n");
+               pr_debug("rtllib_crypt_wep: could not allocate crypto API arc4\n");
                priv->rx_tfm = NULL;
                goto fail;
        }
@@ -108,9 +106,8 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
        if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
            skb->len < hdr_len){
-               printk(KERN_ERR "Error!!! headroom=%d tailroom=%d skblen=%d"
-                      " hdr_len=%d\n", skb_headroom(skb), skb_tailroom(skb),
-                      skb->len, hdr_len);
+               pr_err("Error!!! headroom=%d tailroom=%d skblen=%d hdr_len=%d\n",
+                      skb_headroom(skb), skb_tailroom(skb), skb->len, hdr_len);
                return -1;
        }
        len = skb->len - hdr_len;
index 7537dae89a75ac3096970b0d506dcb35aa1e6797..90cffab4287eccdba832a2e29695acab3503a8f7 100644 (file)
@@ -80,7 +80,7 @@ do {                  \
 #define assert(expr) \
 do {   \
        if (!(expr)) {                            \
-               printk(KERN_INFO "Assertion failed! %s,%s,%s,line=%d\n", \
+               pr_info("Assertion failed! %s,%s,%s,line=%d\n", \
                #expr, __FILE__, __func__, __LINE__);     \
        }       \
 } while (0);
diff --git a/drivers/staging/rtl8192e/rtllib_endianfree.h b/drivers/staging/rtl8192e/rtllib_endianfree.h
deleted file mode 100644 (file)
index b189fa5..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-#ifndef __INC_ENDIANFREE_H
-#define __INC_ENDIANFREE_H
-
-/*
- *     Call endian free function when
- *             1. Read/write packet content.
- *             2. Before write integer to IO.
- *             3. After read integer from IO.
- */
-
-#define __MACHINE_LITTLE_ENDIAN 1234    /* LSB first: i386, vax */
-#define __MACHINE_BIG_ENDIAN    4321    /* MSB first: 68000, ibm, net, ppc */
-
-#define BYTE_ORDER __MACHINE_LITTLE_ENDIAN
-
-#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
-#define EF1Byte(_val)                  ((u8)(_val))
-#define EF2Byte(_val)                  ((u16)(_val))
-#define EF4Byte(_val)                  ((u32)(_val))
-
-#else
-#define EF1Byte(_val)                  ((u8)(_val))
-#define EF2Byte(_val)                  \
-       (((((u16)(_val))&0x00ff)<<8)|((((u16)(_val))&0xff00)>>8))
-#define EF4Byte(_val)                  \
-       (((((u32)(_val))&0x000000ff)<<24)|\
-       ((((u32)(_val))&0x0000ff00)<<8)|\
-       ((((u32)(_val))&0x00ff0000)>>8)|\
-       ((((u32)(_val))&0xff000000)>>24))
-#endif
-
-#define ReadEF1Byte(_ptr)              EF1Byte(*((u8 *)(_ptr)))
-#define ReadEF2Byte(_ptr)              EF2Byte(*((u16 *)(_ptr)))
-#define ReadEF4Byte(_ptr)              EF4Byte(*((u32 *)(_ptr)))
-
-#define WriteEF1Byte(_ptr, _val)       ((*((u8 *)(_ptr))) = EF1Byte(_val))
-#define WriteEF2Byte(_ptr, _val)       ((*((u16 *)(_ptr))) = EF2Byte(_val))
-#define WriteEF4Byte(_ptr, _val)       ((*((u32 *)(_ptr))) = EF4Byte(_val))
-#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
-#define H2N1BYTE(_val) ((u8)(_val))
-#define H2N2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
-                       ((((u16)(_val))&0xff00)>>8))
-#define H2N4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
-                       ((((u32)(_val))&0x0000ff00)<<8) |\
-                       ((((u32)(_val))&0x00ff0000)>>8) |\
-                       ((((u32)(_val))&0xff000000)>>24))
-#else
-#define H2N1BYTE(_val)                 ((u8)(_val))
-#define H2N2BYTE(_val)                 ((u16)(_val))
-#define H2N4BYTE(_val)                 ((u32)(_val))
-#endif
-
-#if BYTE_ORDER == __MACHINE_LITTLE_ENDIAN
-#define N2H1BYTE(_val) ((u8)(_val))
-#define N2H2BYTE(_val) (((((u16)(_val))&0x00ff)<<8)|\
-                       ((((u16)(_val))&0xff00)>>8))
-#define N2H4BYTE(_val) (((((u32)(_val))&0x000000ff)<<24)|\
-                       ((((u32)(_val))&0x0000ff00)<<8) |\
-                       ((((u32)(_val))&0x00ff0000)>>8) |\
-                       ((((u32)(_val))&0xff000000)>>24))
-#else
-#define N2H1BYTE(_val)                 ((u8)(_val))
-#define N2H2BYTE(_val)                 ((u16)(_val))
-#define N2H4BYTE(_val)                 ((u32)(_val))
-#endif
-
-#define BIT_LEN_MASK_32(__BitLen) (0xFFFFFFFF >> (32 - (__BitLen)))
-#define BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen)                  \
-       (BIT_LEN_MASK_32(__BitLen) << (__BitOffset))
-
-#define LE_P4BYTE_TO_HOST_4BYTE(__pStart) (EF4Byte(*((u32 *)(__pStart))))
-
-#define LE_BITS_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
-       ( \
-         (LE_P4BYTE_TO_HOST_4BYTE(__pStart) >> (__BitOffset)) \
-         & \
-         BIT_LEN_MASK_32(__BitLen) \
-       )
-
-#define LE_BITS_CLEARED_TO_4BYTE(__pStart, __BitOffset, __BitLen) \
-       ( \
-         LE_P4BYTE_TO_HOST_4BYTE(__pStart) \
-         & \
-         (~BIT_OFFSET_LEN_MASK_32(__BitOffset, __BitLen)) \
-       )
-
-#define BIT_LEN_MASK_16(__BitLen) \
-       (0xFFFF >> (16 - (__BitLen)))
-
-#define BIT_OFFSET_LEN_MASK_16(__BitOffset, __BitLen) \
-       (BIT_LEN_MASK_16(__BitLen) << (__BitOffset))
-
-#define LE_P2BYTE_TO_HOST_2BYTE(__pStart) \
-       (EF2Byte(*((u16 *)(__pStart))))
-
-#define LE_BITS_TO_2BYTE(__pStart, __BitOffset, __BitLen) \
-       ( \
-         (LE_P2BYTE_TO_HOST_2BYTE(__pStart) >> (__BitOffset)) \
-         & \
-         BIT_LEN_MASK_16(__BitLen) \
-       )
-
-#define BIT_LEN_MASK_8(__BitLen) \
-       (0xFF >> (8 - (__BitLen)))
-
-#define BIT_OFFSET_LEN_MASK_8(__BitOffset, __BitLen) \
-       (BIT_LEN_MASK_8(__BitLen) << (__BitOffset))
-
-#define LE_P1BYTE_TO_HOST_1BYTE(__pStart) \
-       (EF1Byte(*((u8 *)(__pStart))))
-
-#define LE_BITS_TO_1BYTE(__pStart, __BitOffset, __BitLen) \
-       ( \
-         (LE_P1BYTE_TO_HOST_1BYTE(__pStart) >> (__BitOffset)) \
-         & \
-         BIT_LEN_MASK_8(__BitLen) \
-       )
-
-#define        N_BYTE_ALIGMENT(__Value, __Aligment)                    \
-        ((__Aligment == 1) ? (__Value) : (((__Value + __Aligment - 1) / \
-       __Aligment) * __Aligment))
-#endif
index 0cf38091f8c51cd17123d1fe8d9e99c6608edaf1..32cc8df9d3a76a9efae7fac3491082fbf4c83e3d 100644 (file)
@@ -72,11 +72,8 @@ static inline int rtllib_networks_allocate(struct rtllib_device *ieee)
        ieee->networks = kzalloc(
                MAX_NETWORK_COUNT * sizeof(struct rtllib_network),
                GFP_KERNEL);
-       if (!ieee->networks) {
-               printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
-                      ieee->dev->name);
+       if (!ieee->networks)
                return -ENOMEM;
-       }
 
        return 0;
 }
@@ -161,10 +158,9 @@ struct net_device *alloc_rtllib(int sizeof_priv)
        rtllib_softmac_init(ieee);
 
        ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
-       if (ieee->pHTInfo == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for HTInfo\n");
+       if (ieee->pHTInfo == NULL)
                return NULL;
-       }
+
        HTUpdateDefaultSetting(ieee);
        HTInitializeHTInfo(ieee);
        TSInitialize(ieee);
@@ -207,7 +203,9 @@ static struct proc_dir_entry *rtllib_proc;
 
 static int show_debug_level(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "0x%08X\n", rtllib_debug_level);
+       seq_printf(m, "0x%08X\n", rtllib_debug_level);
+
+       return 0;
 }
 
 static ssize_t write_debug_level(struct file *file, const char __user *buffer,
index 1664040efdab916ae6fd60cd347183c4bf6d3b5d..9fc635395ca55ff92f4a28c41ac55968d4a0a221 100644 (file)
@@ -394,10 +394,9 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
                }
                if (p == &ieee->ibss_mac_hash[index]) {
                        entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
-                       if (!entry) {
-                               printk(KERN_WARNING "Cannot malloc new mac entry\n");
+                       if (!entry)
                                return 0;
-                       }
+
                        memcpy(entry->mac, mac, ETH_ALEN);
                        entry->seq_num[tid] = seq;
                        entry->frag_num[tid] = frag;
@@ -524,7 +523,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,        struct rx_ts_record
        del_timer_sync(&pTS->RxPktPendingTimer);
        while (!list_empty(&pTS->RxPendingPktList)) {
                if (RfdCnt >= REORDER_WIN_SIZE) {
-                       printk(KERN_INFO "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n", __func__);
+                       netdev_info(ieee->dev,
+                                   "-------------->%s() error! RfdCnt >= REORDER_WIN_SIZE\n",
+                                   __func__);
                        break;
                }
 
@@ -718,7 +719,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                             __func__);
                pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
                mod_timer(&pTS->RxPktPendingTimer, jiffies +
-                         MSECS(pHTInfo->RxReorderPendingTime));
+                         msecs_to_jiffies(pHTInfo->RxReorderPendingTime));
        }
        spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
 }
@@ -793,13 +794,18 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
                                           (nSubframe_Length << 8);
 
                        if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
-                               printk(KERN_INFO "%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
-                                      __func__, rxb->nr_subframes);
-                               printk(KERN_INFO "%s: A-MSDU parse error!! Subframe Length: %d\n", __func__,
-                                      nSubframe_Length);
-                               printk(KERN_INFO "nRemain_Length is %d and nSubframe_Length is : %d\n", skb->len,
-                                      nSubframe_Length);
-                               printk(KERN_INFO "The Packet SeqNum is %d\n", SeqNum);
+                               netdev_info(ieee->dev,
+                                           "%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",
+                                           __func__, rxb->nr_subframes);
+                               netdev_info(ieee->dev,
+                                           "%s: A-MSDU parse error!! Subframe Length: %d\n",
+                                           __func__, nSubframe_Length);
+                               netdev_info(ieee->dev,
+                                           "nRemain_Length is %d and nSubframe_Length is : %d\n",
+                                           skb->len, nSubframe_Length);
+                               netdev_info(ieee->dev,
+                                           "The Packet SeqNum is %d\n",
+                                           SeqNum);
                                return 0;
                        }
 
@@ -859,7 +865,8 @@ static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee,
        hdrlen = rtllib_get_hdrlen(fc);
        if (HTCCheck(ieee, skb->data)) {
                if (net_ratelimit())
-                       printk(KERN_INFO "%s: find HTCControl!\n", __func__);
+                       netdev_info(ieee->dev, "%s: find HTCControl!\n",
+                                   __func__);
                hdrlen += 4;
                rx_stats->bContainHTC = true;
        }
@@ -1049,7 +1056,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
 
        keyidx = rtllib_rx_frame_decrypt(ieee, skb, crypt);
        if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) && (keyidx < 0)) {
-               printk(KERN_INFO "%s: decrypt frame error\n", __func__);
+               netdev_info(ieee->dev, "%s: decrypt frame error\n", __func__);
                return -1;
        }
 
@@ -1072,8 +1079,9 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
                        flen -= hdrlen;
 
                if (frag_skb->tail + flen > frag_skb->end) {
-                       printk(KERN_WARNING "%s: host decrypted and reassembled frame did not fit skb\n",
-                              __func__);
+                       netdev_warn(ieee->dev,
+                                   "%s: host decrypted and reassembled frame did not fit skb\n",
+                                   __func__);
                        rtllib_frag_cache_invalidate(ieee, hdr);
                        return -1;
                }
@@ -1109,7 +1117,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
         * encrypted/authenticated */
        if (ieee->host_decrypt && (fc & RTLLIB_FCTL_WEP) &&
                rtllib_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt)) {
-               printk(KERN_INFO "%s: ==>decrypt msdu error\n", __func__);
+               netdev_info(ieee->dev, "%s: ==>decrypt msdu error\n", __func__);
                return -1;
        }
 
@@ -1149,7 +1157,7 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
        }
 
        if (rtllib_is_eapol_frame(ieee, skb, hdrlen))
-               printk(KERN_WARNING "RX: IEEE802.1X EAPOL frame!\n");
+               netdev_warn(ieee->dev, "RX: IEEE802.1X EAPOL frame!\n");
 
        return 0;
 }
@@ -1181,8 +1189,8 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
        int i = 0;
 
        if (rxb == NULL) {
-               printk(KERN_INFO "%s: rxb is NULL!!\n", __func__);
-               return ;
+               netdev_info(dev, "%s: rxb is NULL!!\n", __func__);
+               return;
        }
 
        for (i = 0; i < rxb->nr_subframes; i++) {
@@ -1226,7 +1234,6 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
                }
        }
        kfree(rxb);
-       rxb = NULL;
 }
 
 static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
@@ -1263,7 +1270,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        /*Filter pkt has too small length */
        hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats);
        if (skb->len < hdrlen) {
-               printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__);
+               netdev_info(dev, "%s():ERR!!! skb->len is smaller than hdrlen\n",
+                           __func__);
                goto rx_dropped;
        }
 
@@ -1345,11 +1353,9 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        /* skb: hdr + (possible reassembled) full plaintext payload */
        payload = skb->data + hdrlen;
        rxb = kmalloc(sizeof(struct rtllib_rxb), GFP_ATOMIC);
-       if (rxb == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR,
-                            "%s(): kmalloc rxb error\n", __func__);
+       if (rxb == NULL)
                goto rx_dropped;
-       }
+
        /* to parse amsdu packets */
        /* qos data packets & reserved bit is 1 */
        if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
@@ -1408,13 +1414,16 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
        size_t hdrlen = rtllib_get_hdrlen(fc);
 
        if (skb->len < hdrlen) {
-               printk(KERN_INFO "%s():ERR!!! skb->len is smaller than hdrlen\n", __func__);
+               netdev_info(ieee->dev,
+                           "%s():ERR!!! skb->len is smaller than hdrlen\n",
+                           __func__);
                return 0;
        }
 
        if (HTCCheck(ieee, skb->data)) {
                if (net_ratelimit())
-                       printk(KERN_INFO "%s: Find HTCControl!\n", __func__);
+                       netdev_info(ieee->dev, "%s: Find HTCControl!\n",
+                                   __func__);
                hdrlen += 4;
        }
 
@@ -1440,11 +1449,11 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
        int ret = 0;
 
        if ((NULL == ieee) || (NULL == skb) || (NULL == rx_stats)) {
-               printk(KERN_INFO "%s: Input parameters NULL!\n", __func__);
+               pr_info("%s: Input parameters NULL!\n", __func__);
                goto rx_dropped;
        }
        if (skb->len < 10) {
-               printk(KERN_INFO "%s: SKB length < 10\n", __func__);
+               netdev_info(ieee->dev, "%s: SKB length < 10\n", __func__);
                goto rx_dropped;
        }
 
@@ -1464,7 +1473,7 @@ int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
                ret = rtllib_rx_Mesh(ieee, skb, rx_stats);
                break;
        default:
-               printk(KERN_INFO"%s: ERR iw mode!!!\n", __func__);
+               netdev_info(ieee->dev, "%s: ERR iw mode!!!\n", __func__);
                break;
        }
 
@@ -1705,7 +1714,9 @@ static inline void rtllib_extract_country_ie(
 
                        if (!IS_COUNTRY_IE_VALID(ieee)) {
                                if (rtllib_act_scanning(ieee, false) && ieee->FirstIe_InScan)
-                                       printk(KERN_INFO "Received beacon ContryIE, SSID: <%s>\n", network->ssid);
+                                       netdev_info(ieee->dev,
+                                                   "Received beacon ContryIE, SSID: <%s>\n",
+                                                   network->ssid);
                                Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
                        }
                }
@@ -1908,7 +1919,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                                   info_element->data[2] == 0x4c &&
                                   info_element->data[3] == 0x033) {
 
-                                               tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN);
+                                               tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
                                                if (tmp_htcap_len != 0) {
                                                        network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
                                                        network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
@@ -1932,7 +1943,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                                    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);
+                                       tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
                                        if (tmp_htinfo_len != 0) {
                                                network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
                                                if (tmp_htinfo_len) {
@@ -1953,7 +1964,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                                            info_element->data[1] == 0xe0 &&
                                            info_element->data[2] == 0x4c &&
                                            info_element->data[3] == 0x02) {
-                                               ht_realtek_agg_len = min(info_element->len, (u8)MAX_IE_LEN);
+                                               ht_realtek_agg_len = min_t(u8, info_element->len, MAX_IE_LEN);
                                                memcpy(ht_realtek_agg_buf, info_element->data, info_element->len);
                                        }
                                        if (ht_realtek_agg_len >= 5) {
@@ -2083,7 +2094,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                case MFIE_TYPE_HT_CAP:
                        RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
                                             info_element->len);
-                       tmp_htcap_len = min(info_element->len, (u8)MAX_IE_LEN);
+                       tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
                        if (tmp_htcap_len != 0) {
                                network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
                                network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
@@ -2110,7 +2121,7 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                case MFIE_TYPE_HT_INFO:
                        RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
                                             info_element->len);
-                       tmp_htinfo_len = min(info_element->len, (u8)MAX_IE_LEN);
+                       tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
                        if (tmp_htinfo_len) {
                                network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
                                network->bssht.bdHTInfoLen = tmp_htinfo_len >
@@ -2142,8 +2153,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                        }
                        break;
                case MFIE_TYPE_QOS_PARAMETER:
-                       printk(KERN_ERR
-                              "QoS Error need to parse QOS_PARAMETER IE\n");
+                       netdev_err(ieee->dev,
+                                  "QoS Error need to parse QOS_PARAMETER IE\n");
                        break;
 
                case MFIE_TYPE_COUNTRY:
@@ -2422,7 +2433,7 @@ static inline int is_beacon(__le16 fc)
 static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
 {
        if (MAX_CHANNEL_NUMBER < channel) {
-               printk(KERN_INFO "%s(): Invalid Channel\n", __func__);
+               netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
                return 0;
        }
 
@@ -2435,7 +2446,7 @@ static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
 int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel)
 {
        if (MAX_CHANNEL_NUMBER < channel) {
-               printk(KERN_INFO "%s(): Invalid Channel\n", __func__);
+               netdev_info(rtllib->dev, "%s(): Invalid Channel\n", __func__);
                return 0;
        }
        if (rtllib->active_channel_map[channel] > 0)
@@ -2501,8 +2512,9 @@ static inline void rtllib_process_probe_response(
        if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) ==
            RTLLIB_STYPE_PROBE_RESP) {
                if (IsPassiveChannel(ieee, network->channel)) {
-                       printk(KERN_INFO "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
-                              network->channel);
+                       netdev_info(ieee->dev,
+                                   "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
+                                   network->channel);
                        goto free_network;
                }
        }
index d992a754e72db17ec15061cec212e902349845d6..f1f19fc2305c6c249d2de2344aae5600acf66622 100644 (file)
@@ -124,7 +124,7 @@ void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p)
        *tag++ = 0x00;
 
        *tag_p = tag;
-       printk(KERN_ALERT "This is enable turbo mode IE process\n");
+       netdev_alert(ieee->dev, "This is enable turbo mode IE process\n");
 }
 
 static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb)
@@ -188,7 +188,7 @@ MgntQuery_TxRateExcludeCCKRates(struct rtllib_device *ieee)
 
        if (QueryRate == 0) {
                QueryRate = 12;
-               printk(KERN_INFO "No BasicRate found!!\n");
+               netdev_info(ieee->dev, "No BasicRate found!!\n");
        }
        return QueryRate;
 }
@@ -277,8 +277,9 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
                        /* as for the completion function, it does not need
                         * to check it any more.
                         * */
-                       printk(KERN_INFO "%s():insert to waitqueue, queue_index"
-                              ":%d!\n", __func__, tcb_desc->queue_index);
+                       netdev_info(ieee->dev,
+                              "%s():insert to waitqueue, queue_index:%d!\n",
+                              __func__, tcb_desc->queue_index);
                        skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index],
                                       skb);
                } else {
@@ -401,7 +402,7 @@ static void rtllib_send_beacon(struct rtllib_device *ieee)
 
        if (ieee->beacon_txing && ieee->ieee_up)
                mod_timer(&ieee->beacon_timer, jiffies +
-                         (MSECS(ieee->current_network.beacon_interval - 5)));
+                         (msecs_to_jiffies(ieee->current_network.beacon_interval - 5)));
 }
 
 
@@ -425,7 +426,7 @@ void rtllib_EnableNetMonitorMode(struct net_device *dev,
 {
        struct rtllib_device *ieee = netdev_priv_rsl(dev);
 
-       printk(KERN_INFO "========>Enter Monitor Mode\n");
+       netdev_info(dev, "========>Enter Monitor Mode\n");
 
        ieee->AllowAllDestAddrHandler(dev, true, !bInitState);
 }
@@ -441,7 +442,7 @@ void rtllib_DisableNetMonitorMode(struct net_device *dev,
 {
        struct rtllib_device *ieee = netdev_priv_rsl(dev);
 
-       printk(KERN_INFO "========>Exit Monitor Mode\n");
+       netdev_info(dev, "========>Exit Monitor Mode\n");
 
        ieee->AllowAllDestAddrHandler(dev, false, !bInitState);
 }
@@ -462,7 +463,7 @@ void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
 
        struct rtllib_device *ieee = netdev_priv_rsl(dev);
 
-       printk(KERN_INFO "========>Enter Intel Promiscuous Mode\n");
+       netdev_info(dev, "========>Enter Intel Promiscuous Mode\n");
 
        ieee->AllowAllDestAddrHandler(dev, true, !bInitState);
        ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID,
@@ -485,7 +486,7 @@ void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
 
        struct rtllib_device *ieee = netdev_priv_rsl(dev);
 
-       printk(KERN_INFO "========>Exit Intel Promiscuous Mode\n");
+       netdev_info(dev, "========>Exit Intel Promiscuous Mode\n");
 
        ieee->AllowAllDestAddrHandler(dev, false, !bInitState);
        ieee->SetHwRegHandler(dev, HW_VAR_CECHK_BSSID,
@@ -569,7 +570,8 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
                if (ieee->state == RTLLIB_LINKED)
                        goto out;
                if (ieee->sync_scan_hurryup) {
-                       printk(KERN_INFO "============>sync_scan_hurryup out\n");
+                       netdev_info(ieee->dev,
+                                   "============>sync_scan_hurryup out\n");
                        goto out;
                }
 
@@ -614,8 +616,9 @@ static void rtllib_softmac_scan_wq(void *data)
        down(&ieee->scan_sem);
 
        if (ieee->eRFPowerState == eRfOff) {
-               printk(KERN_INFO "======>%s():rf state is eRfOff, return\n",
-                      __func__);
+               netdev_info(ieee->dev,
+                           "======>%s():rf state is eRfOff, return\n",
+                           __func__);
                goto out1;
        }
 
@@ -639,7 +642,7 @@ static void rtllib_softmac_scan_wq(void *data)
                rtllib_send_probe_requests(ieee, 0);
 
        queue_delayed_work_rsl(ieee->wq, &ieee->softmac_scan_wq,
-                              MSECS(RTLLIB_SOFTMAC_SCAN_TIME));
+                              msecs_to_jiffies(RTLLIB_SOFTMAC_SCAN_TIME));
 
        up(&ieee->scan_sem);
        return;
@@ -1238,8 +1241,8 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
        PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid);
        if (PMKCacheIdx >= 0) {
                wpa_ie_len += 18;
-               printk(KERN_INFO "[PMK cache]: WPA2 IE length: %x\n",
-                      wpa_ie_len);
+               netdev_info(ieee->dev, "[PMK cache]: WPA2 IE length: %x\n",
+                           wpa_ie_len);
        }
        len = sizeof(struct rtllib_assoc_request_frame) + 2
                + beacon->ssid_len
@@ -1418,8 +1421,9 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
        if (ieee->assocreq_ies)
                memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len);
        else {
-               printk(KERN_INFO "%s()Warning: can't alloc memory for assocreq"
-                      "_ies\n", __func__);
+               netdev_info(ieee->dev,
+                           "%s()Warning: can't alloc memory for assocreq_ies\n",
+                           __func__);
                ieee->assocreq_ies_len = 0;
        }
        return skb;
@@ -1474,7 +1478,7 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
        if (!skb)
                rtllib_associate_abort(ieee);
        else {
-               ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING ;
+               ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING;
                RTLLIB_DEBUG_MGMT("Sending authentication request\n");
                softmac_mgmt_xmit(skb, ieee);
                if (!timer_pending(&ieee->associate_timer)) {
@@ -1503,8 +1507,7 @@ static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int
                *(c++) = chlen;
                memcpy(c, challenge, chlen);
 
-               RTLLIB_DEBUG_MGMT("Sending authentication challenge "
-                                 "response\n");
+               RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n");
 
                rtllib_encrypt_fragment(ieee, skb,
                                        sizeof(struct rtllib_hdr_3addr));
@@ -1543,9 +1546,9 @@ static void rtllib_associate_complete_wq(void *data)
                                     associate_complete_wq);
        struct rt_pwr_save_ctrl *pPSC = (struct rt_pwr_save_ctrl *)
                                        (&(ieee->PowerSaveControl));
-       printk(KERN_INFO "Associated successfully\n");
+       netdev_info(ieee->dev, "Associated successfully\n");
        if (!ieee->is_silent_reset) {
-               printk(KERN_INFO "normal associate\n");
+               netdev_info(ieee->dev, "normal associate\n");
                notify_wx_assoc_event(ieee);
        }
 
@@ -1554,20 +1557,20 @@ static void rtllib_associate_complete_wq(void *data)
        if (rtllib_is_54g(&ieee->current_network) &&
           (ieee->modulation & RTLLIB_OFDM_MODULATION)) {
                ieee->rate = 108;
-               printk(KERN_INFO"Using G rates:%d\n", ieee->rate);
+               netdev_info(ieee->dev, "Using G rates:%d\n", ieee->rate);
        } else {
                ieee->rate = 22;
                ieee->SetWirelessMode(ieee->dev, IEEE_B);
-               printk(KERN_INFO"Using B rates:%d\n", ieee->rate);
+               netdev_info(ieee->dev, "Using B rates:%d\n", ieee->rate);
        }
        if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
-               printk(KERN_INFO "Successfully associated, ht enabled\n");
+               netdev_info(ieee->dev, "Successfully associated, ht enabled\n");
                HTOnAssocRsp(ieee);
        } else {
-               printk(KERN_INFO "Successfully associated, ht not "
-                      "enabled(%d, %d)\n",
-                      ieee->pHTInfo->bCurrentHTSupport,
-                      ieee->pHTInfo->bEnableHT);
+               netdev_info(ieee->dev,
+                           "Successfully associated, ht not enabled(%d, %d)\n",
+                           ieee->pHTInfo->bCurrentHTSupport,
+                           ieee->pHTInfo->bEnableHT);
                memset(ieee->dot11HTOperationalRateSet, 0, 16);
        }
        ieee->LinkDetectInfo.SlotNum = 2 * (1 +
@@ -1582,7 +1585,7 @@ static void rtllib_associate_complete_wq(void *data)
        ieee->link_change(ieee->dev);
 
        if (ieee->is_silent_reset) {
-               printk(KERN_INFO "silent reset associate\n");
+               netdev_info(ieee->dev, "silent reset associate\n");
                ieee->is_silent_reset = false;
        }
 
@@ -1623,8 +1626,9 @@ static void rtllib_associate_procedure_wq(void *data)
                 ieee->current_network.channel);
        HTSetConnectBwMode(ieee, HT_CHANNEL_WIDTH_20, HT_EXTCHNL_OFFSET_NO_EXT);
        if (ieee->eRFPowerState == eRfOff) {
-               RT_TRACE(COMP_DBG, "=============>%s():Rf state is eRfOff,"
-                        " schedule ipsleave wq again,return\n", __func__);
+               RT_TRACE(COMP_DBG,
+                        "=============>%s():Rf state is eRfOff, schedule ipsleave wq again,return\n",
+                        __func__);
                if (ieee->rtllib_ips_leave_wq != NULL)
                        ieee->rtllib_ips_leave_wq(ieee->dev);
                up(&ieee->wx_sem);
@@ -1719,15 +1723,15 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
                                        IW_ESSID_MAX_SIZE);
                                ieee->current_network.ssid_len = tmp_ssid_len;
                        }
-                       printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, "
-                              "myHT:%d, networkHT:%d, mode:%x cur_net.flags"
-                              ":0x%x\n", ieee->current_network.ssid,
-                              ieee->current_network.channel,
-                              ieee->current_network.qos_data.supported,
-                              ieee->pHTInfo->bEnableHT,
-                              ieee->current_network.bssht.bdSupportHT,
-                              ieee->current_network.mode,
-                              ieee->current_network.flags);
+                       netdev_info(ieee->dev,
+                                   "Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d, mode:%x cur_net.flags:0x%x\n",
+                                   ieee->current_network.ssid,
+                                   ieee->current_network.channel,
+                                   ieee->current_network.qos_data.supported,
+                                   ieee->pHTInfo->bEnableHT,
+                                   ieee->current_network.bssht.bdSupportHT,
+                                   ieee->current_network.mode,
+                                   ieee->current_network.flags);
 
                        if ((rtllib_act_scanning(ieee, false)) &&
                           !(ieee->softmac_features & IEEE_SOFTMAC_SCAN))
@@ -1758,11 +1762,11 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
                                        (ieee->modulation & RTLLIB_OFDM_MODULATION)) {
                                        ieee->rate = 108;
                                        ieee->SetWirelessMode(ieee->dev, IEEE_G);
-                                       printk(KERN_INFO"Using G rates\n");
+                                       netdev_info(ieee->dev, "Using G rates\n");
                                } else {
                                        ieee->rate = 22;
                                        ieee->SetWirelessMode(ieee->dev, IEEE_B);
-                                       printk(KERN_INFO"Using B rates\n");
+                                       netdev_info(ieee->dev, "Using B rates\n");
                                }
                                memset(ieee->dot11HTOperationalRateSet, 0, 16);
                                ieee->state = RTLLIB_LINKED;
@@ -1965,7 +1969,7 @@ static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee,
        if (assoc_rq_parse(skb, dest) != -1)
                rtllib_resp_to_assoc_rq(ieee, dest);
 
-       printk(KERN_INFO"New client associated: %pM\n", dest);
+       netdev_info(ieee->dev, "New client associated: %pM\n", dest);
 }
 
 void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee, short pwr)
@@ -2008,9 +2012,11 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
        if (dtim & (RTLLIB_DTIM_UCAST & ieee->ps))
                return 2;
 
-       if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
+       if (!time_after(jiffies,
+                       ieee->dev->trans_start + msecs_to_jiffies(timeout)))
                return 0;
-       if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
+       if (!time_after(jiffies,
+                       ieee->last_rx_ps_time + msecs_to_jiffies(timeout)))
                return 0;
        if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) &&
            (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
@@ -2060,7 +2066,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
                        }
 
                *time = ieee->current_network.last_dtim_sta_time
-                       + MSECS(ieee->current_network.beacon_interval *
+                       + msecs_to_jiffies(ieee->current_network.beacon_interval *
                        LPSAwakeIntvl_tmp);
        }
        }
@@ -2081,10 +2087,9 @@ static inline void rtllib_sta_ps(struct rtllib_device *ieee)
        if ((ieee->ps == RTLLIB_PS_DISABLED ||
             ieee->iw_mode != IW_MODE_INFRA ||
             ieee->state != RTLLIB_LINKED)) {
-               RT_TRACE(COMP_DBG, "=====>%s(): no need to ps,wake up!! "
-                        "ieee->ps is %d, ieee->iw_mode is %d, ieee->state"
-                        " is %d\n", __func__, ieee->ps, ieee->iw_mode,
-                         ieee->state);
+               RT_TRACE(COMP_DBG,
+                        "=====>%s(): no need to ps,wake up!! ieee->ps is %d, ieee->iw_mode is %d, ieee->state is %d\n",
+                        __func__, ieee->ps, ieee->iw_mode, ieee->state);
                spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
                rtllib_sta_wakeup(ieee, 1);
 
@@ -2199,8 +2204,8 @@ static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *sk
        u8 category = 0;
 
        if (act == NULL) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "error to get payload of "
-                            "action frame\n");
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "error to get payload of action frame\n");
                return;
        }
 
@@ -2285,16 +2290,18 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
                                memcpy(ieee->assocresp_ies, ies,
                                       ieee->assocresp_ies_len);
                        else {
-                               printk(KERN_INFO "%s()Warning: can't alloc "
-                                      "memory for assocresp_ies\n", __func__);
+                               netdev_info(ieee->dev,
+                                           "%s()Warning: can't alloc memory for assocresp_ies\n",
+                                           __func__);
                                ieee->assocresp_ies_len = 0;
                        }
                        rtllib_associate_complete(ieee);
                } else {
                        /* aid could not been allocated */
                        ieee->softmac_stats.rx_ass_err++;
-                       printk(KERN_INFO "Association response status code 0x%x\n",
-                               errcode);
+                       netdev_info(ieee->dev,
+                                   "Association response status code 0x%x\n",
+                                   errcode);
                        RTLLIB_DEBUG_MGMT(
                                "Association response status code 0x%x\n",
                                errcode);
@@ -2351,8 +2358,8 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
 
                                        if (ieee->current_network.mode ==
                                            IEEE_N_24G && bHalfSupportNmode) {
-                                               printk(KERN_INFO "======>enter "
-                                                      "half N mode\n");
+                                               netdev_info(ieee->dev,
+                                                           "======>enter half N mode\n");
                                                ieee->bHalfWirelessN24GMode =
                                                                         true;
                                        } else
@@ -2366,11 +2373,12 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
                                }
                        } else {
                                ieee->softmac_stats.rx_auth_rs_err++;
-                               RTLLIB_DEBUG_MGMT("Authentication respose"
-                                                 " status code 0x%x", errcode);
+                               RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",
+                                                 errcode);
 
-                               printk(KERN_INFO "Authentication respose "
-                                      "status code 0x%x", errcode);
+                               netdev_info(ieee->dev,
+                                           "Authentication respose status code 0x%x",
+                                           errcode);
                                rtllib_associate_abort(ieee);
                        }
 
@@ -2394,10 +2402,10 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb)
        if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
            ieee->state == RTLLIB_LINKED &&
            (ieee->iw_mode == IW_MODE_INFRA)) {
-               printk(KERN_INFO "==========>received disassoc/deauth(%x) "
-                      "frame, reason code:%x\n",
-                      WLAN_FC_GET_STYPE(header->frame_ctl),
-                      ((struct rtllib_disassoc *)skb->data)->reason);
+               netdev_info(ieee->dev,
+                           "==========>received disassoc/deauth(%x) frame, reason code:%x\n",
+                           WLAN_FC_GET_STYPE(header->frame_ctl),
+                           ((struct rtllib_disassoc *)skb->data)->reason);
                ieee->state = RTLLIB_ASSOCIATING;
                ieee->softmac_stats.reassoc++;
                ieee->is_roaming = true;
@@ -2450,7 +2458,6 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
                break;
        default:
                return -1;
-               break;
        }
        return 0;
 }
@@ -2688,7 +2695,7 @@ static void rtllib_start_ibss_wq(void *data)
         * on the semaphore
         */
        if (!ieee->proto_started) {
-               printk(KERN_INFO "==========oh driver down return\n");
+               netdev_info(ieee->dev, "==========oh driver down return\n");
                return;
        }
        down(&ieee->wx_sem);
@@ -2724,7 +2731,7 @@ static void rtllib_start_ibss_wq(void *data)
 
        /* the network definitively is not here.. create a new cell */
        if (ieee->state == RTLLIB_NOLINK) {
-               printk(KERN_INFO "creating new IBSS cell\n");
+               netdev_info(ieee->dev, "creating new IBSS cell\n");
                ieee->current_network.channel = ieee->IbssStartChnl;
                if (!ieee->wap_set)
                        rtllib_randomize_cell(ieee);
@@ -2778,7 +2785,7 @@ static void rtllib_start_ibss_wq(void *data)
                ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
        }
 
-       printk(KERN_INFO "%s(): ieee->mode = %d\n", __func__, ieee->mode);
+       netdev_info(ieee->dev, "%s(): ieee->mode = %d\n", __func__, ieee->mode);
        if ((ieee->mode == IEEE_N_24G) || (ieee->mode == IEEE_N_5G))
                HTUseDefaultSetting(ieee);
        else
@@ -2808,7 +2815,8 @@ static void rtllib_start_ibss_wq(void *data)
 
 inline void rtllib_start_ibss(struct rtllib_device *ieee)
 {
-       queue_delayed_work_rsl(ieee->wq, &ieee->start_ibss_wq, MSECS(150));
+       queue_delayed_work_rsl(ieee->wq, &ieee->start_ibss_wq,
+                              msecs_to_jiffies(150));
 }
 
 /* this is called only in user context, with wx_sem held */
@@ -3181,7 +3189,7 @@ static int rtllib_wpa_enable(struct rtllib_device *ieee, int value)
 {
        /* This is called when wpa_supplicant loads and closes the driver
         * interface. */
-       printk(KERN_INFO "%s WPA\n", value ? "enabling" : "disabling");
+       netdev_info(ieee->dev, "%s WPA\n", value ? "enabling" : "disabling");
        ieee->wpa_enabled = value;
        memset(ieee->ap_mac_addr, 0, 6);
        return 0;
@@ -3212,7 +3220,7 @@ static int rtllib_wpa_mlme(struct rtllib_device *ieee, int command, int reason)
                break;
 
        default:
-               printk(KERN_INFO "Unknown MLME request: %d\n", command);
+               netdev_info(ieee->dev, "Unknown MLME request: %d\n", command);
                ret = -EOPNOTSUPP;
        }
 
@@ -3343,7 +3351,7 @@ static int rtllib_wpa_set_param(struct rtllib_device *ieee, u8 name, u32 value)
                break;
 
        default:
-               printk(KERN_INFO "Unknown WPA param: %d\n", name);
+               netdev_info(ieee->dev, "Unknown WPA param: %d\n", name);
                ret = -EOPNOTSUPP;
        }
 
@@ -3369,8 +3377,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
        if (param_len !=
            (int) ((char *) param->u.crypt.key - (char *) param) +
            param->u.crypt.key_len) {
-               printk(KERN_INFO "Len mismatch %d, %d\n", param_len,
-                              param->u.crypt.key_len);
+               netdev_info(ieee->dev, "Len mismatch %d, %d\n", param_len,
+                           param->u.crypt.key_len);
                return -EINVAL;
        }
        if (is_broadcast_ether_addr(param->sta_addr)) {
@@ -3410,8 +3418,8 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
                ops = lib80211_get_crypto_ops(param->u.crypt.alg);
        }
        if (ops == NULL) {
-               printk(KERN_INFO "unknown crypto alg '%s'\n",
-                      param->u.crypt.alg);
+               netdev_info(ieee->dev, "unknown crypto alg '%s'\n",
+                           param->u.crypt.alg);
                param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
                ret = -EINVAL;
                goto done;
@@ -3421,12 +3429,11 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
 
                lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
 
-               new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL);
+               new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct lib80211_crypt_data));
                new_crypt->ops = ops;
                if (new_crypt->ops)
                        new_crypt->priv =
@@ -3446,7 +3453,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
            (*crypt)->ops->set_key(param->u.crypt.key,
            param->u.crypt.key_len, param->u.crypt.seq,
            (*crypt)->priv) < 0) {
-               printk(KERN_INFO "key setting failed\n");
+               netdev_info(ieee->dev, "key setting failed\n");
                param->u.crypt.err = IEEE_CRYPT_ERR_KEY_SET_FAILED;
                ret = -EINVAL;
                goto done;
@@ -3491,7 +3498,7 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
            ieee->iw_mode != IW_MODE_INFRA &&
            ieee->reset_port &&
            ieee->reset_port(ieee->dev)) {
-               printk(KERN_INFO "reset_port failed\n");
+               netdev_info(ieee->dev, "reset_port failed\n");
                param->u.crypt.err = IEEE_CRYPT_ERR_CARD_CONF_FAILED;
                return -EINVAL;
        }
@@ -3634,8 +3641,8 @@ int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee, struct iw_point *p,
                break;
 
        default:
-               printk(KERN_INFO "Unknown WPA supplicant request: %d\n",
-                      param->cmd);
+               netdev_info(ieee->dev, "Unknown WPA supplicant request: %d\n",
+                           param->cmd);
                ret = -EOPNOTSUPP;
                break;
        }
@@ -3749,9 +3756,9 @@ void notify_wx_assoc_event(struct rtllib_device *ieee)
                       ETH_ALEN);
        else {
 
-               printk(KERN_INFO "%s(): Tell user space disconnected\n",
-                      __func__);
-               memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+               netdev_info(ieee->dev, "%s(): Tell user space disconnected\n",
+                           __func__);
+               eth_zero_addr(wrqu.ap_addr.sa_data);
        }
        wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
 }
index 835f3d78a16f44589719bddb7e962bae60baa359..9715a793fd3735615a9aca267fd5d120576c4fcc 100644 (file)
@@ -120,7 +120,7 @@ int rtllib_wx_get_wap(struct rtllib_device *ieee,
                ieee->state != RTLLIB_LINKED_SCANNING &&
                ieee->wap_set == 0)
 
-               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+               eth_zero_addr(wrqu->ap_addr.sa_data);
        else
                memcpy(wrqu->ap_addr.sa_data,
                       ieee->current_network.bssid, ETH_ALEN);
@@ -527,8 +527,8 @@ int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
        else
                ieee->raw_tx = 0;
 
-       printk(KERN_INFO"raw TX is %s\n",
-             ieee->raw_tx ? "enabled" : "disabled");
+       netdev_info(ieee->dev, "raw TX is %s\n",
+                   ieee->raw_tx ? "enabled" : "disabled");
 
        if (ieee->iw_mode == IW_MODE_MONITOR) {
                if (prev == 0 && ieee->raw_tx) {
@@ -575,8 +575,9 @@ int rtllib_wx_set_power(struct rtllib_device *ieee,
        if ((!ieee->sta_wake_up) ||
            (!ieee->enter_sleep_state) ||
            (!ieee->ps_is_queue_empty)) {
-               RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tried to be use "
-                            "but driver missed a callback\n\n", __func__);
+               RTLLIB_DEBUG(RTLLIB_DL_ERR,
+                            "%s(): PS mode is tried to be use but driver missed a callback\n\n",
+                            __func__);
                return -1;
        }
 
index 4f68ffe41475660f293299a613d19f8affff0771..f6d0257e4c9bda25733cf23aa473fc83961eae06 100644 (file)
@@ -185,7 +185,8 @@ int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag,
        crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
 
        if (!(crypt && crypt->ops)) {
-               printk(KERN_INFO "=========>%s(), crypt is null\n", __func__);
+               netdev_info(ieee->dev, "=========>%s(), crypt is null\n",
+                           __func__);
                return -1;
        }
        /* To encrypt, frame format is:
@@ -202,8 +203,8 @@ int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag,
 
        atomic_dec(&crypt->refcnt);
        if (res < 0) {
-               printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
-                      ieee->dev->name, frag->len);
+               netdev_info(ieee->dev, "%s: Encryption failed: len=%d.\n",
+                           ieee->dev->name, frag->len);
                ieee->ieee_stats.tx_discards++;
                return -1;
        }
@@ -311,7 +312,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
        if (pHTInfo->bCurrentAMPDUEnable) {
                if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1,
                    skb->priority, TX_DIR, true)) {
-                       printk(KERN_INFO "%s: can't get TS\n", __func__);
+                       netdev_info(ieee->dev, "%s: can't get TS\n", __func__);
                        return;
                }
                if (pTxTs->TxAdmittedBARecord.bValid == false) {
@@ -549,6 +550,17 @@ static int wme_downgrade_ac(struct sk_buff *skb)
        }
 }
 
+static u8 rtllib_current_rate(struct rtllib_device *ieee)
+{
+       if (ieee->mode & IEEE_MODE_MASK)
+               return ieee->rate;
+
+       if (ieee->HTCurrentOperaRate)
+               return ieee->HTCurrentOperaRate;
+       else
+               return ieee->rate & 0x7F;
+}
+
 int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 {
        struct rtllib_device *ieee = (struct rtllib_device *)
@@ -582,16 +594,15 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
           IEEE_SOFTMAC_TX_QUEUE)) ||
           ((!ieee->softmac_data_hard_start_xmit &&
           (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) {
-               printk(KERN_WARNING "%s: No xmit handler.\n",
-                      ieee->dev->name);
+               netdev_warn(ieee->dev, "No xmit handler.\n");
                goto success;
        }
 
 
        if (likely(ieee->raw_tx == 0)) {
                if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
-                       printk(KERN_WARNING "%s: skb too small (%d).\n",
-                       ieee->dev->name, skb->len);
+                       netdev_warn(ieee->dev, "skb too small (%d).\n",
+                                   skb->len);
                        goto success;
                }
                /* Save source and destination addresses */
@@ -604,9 +615,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                if (ieee->iw_mode == IW_MODE_MONITOR) {
                        txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC);
                        if (unlikely(!txb)) {
-                               printk(KERN_WARNING "%s: Could not allocate "
-                                      "TXB\n",
-                               ieee->dev->name);
+                               netdev_warn(ieee->dev,
+                                           "Could not allocate TXB\n");
                                goto failed;
                        }
 
@@ -636,8 +646,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                                        }
                                }
                        } else if (ETH_P_ARP == ether_type) {
-                               printk(KERN_INFO "=================>DHCP "
-                                      "Protocol start tx ARP pkt!!\n");
+                               netdev_info(ieee->dev,
+                                           "=================>DHCP Protocol start tx ARP pkt!!\n");
                                bdhcp = true;
                                ieee->LPSDelayCnt =
                                         ieee->current_network.tim.tim_count;
@@ -717,10 +727,11 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 
                /* in case we are a client verify acm is not set for this ac */
                while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) {
-                       printk(KERN_INFO "skb->priority = %x\n", skb->priority);
+                       netdev_info(ieee->dev, "skb->priority = %x\n",
+                                   skb->priority);
                        if (wme_downgrade_ac(skb))
                                break;
-                       printk(KERN_INFO "converted skb->priority = %x\n",
+                       netdev_info(ieee->dev, "converted skb->priority = %x\n",
                               skb->priority);
                 }
                        qos_ctl |= skb->priority;
@@ -760,8 +771,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                txb = rtllib_alloc_txb(nr_frags, frag_size +
                                       ieee->tx_headroom, GFP_ATOMIC);
                if (unlikely(!txb)) {
-                       printk(KERN_WARNING "%s: Could not allocate TXB\n",
-                       ieee->dev->name);
+                       netdev_warn(ieee->dev, "Could not allocate TXB\n");
                        goto failed;
                }
                txb->encrypted = encrypt;
@@ -858,15 +868,14 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                }
        } else {
                if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) {
-                       printk(KERN_WARNING "%s: skb too small (%d).\n",
-                       ieee->dev->name, skb->len);
+                       netdev_warn(ieee->dev, "skb too small (%d).\n",
+                                   skb->len);
                        goto success;
                }
 
                txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC);
                if (!txb) {
-                       printk(KERN_WARNING "%s: Could not allocate TXB\n",
-                       ieee->dev->name);
+                       netdev_warn(ieee->dev, "Could not allocate TXB\n");
                        goto failed;
                }
 
@@ -906,8 +915,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                        if (tcb_desc->bMulticast ||  tcb_desc->bBroadcast)
                                tcb_desc->data_rate = ieee->basic_rate;
                        else
-                               tcb_desc->data_rate = CURRENT_RATE(ieee->mode,
-                                       ieee->rate, ieee->HTCurrentOperaRate);
+                               tcb_desc->data_rate = rtllib_current_rate(ieee);
 
                        if (bdhcp) {
                                if (ieee->pHTInfo->IOTAction &
index 9e0f975c152f13eaf19a9094067e370f3670c5b6..a1cae3748ae6adc763ecaf73e3415922f10ebae3 100644 (file)
@@ -32,7 +32,7 @@
 #include <linux/wireless.h>
 #include <linux/kmod.h>
 #include <linux/module.h>
-
+#include <linux/etherdevice.h>
 #include "rtllib.h"
 struct modes_unit {
        char *mode_string;
@@ -65,7 +65,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
        /* First entry *MUST* be the AP MAC address */
        iwe.cmd = SIOCGIWAP;
        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-       memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
+       ether_addr_copy(iwe.u.ap_addr.sa_data, network->bssid);
        start = iwe_stream_add_event_rsl(info, start, stop,
                                         &iwe, IW_EV_ADDR_LEN);
        /* Remaining entries will be displayed in the order we provide them */
@@ -74,7 +74,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
        iwe.cmd = SIOCGIWESSID;
        iwe.u.data.flags = 1;
        if (network->ssid_len > 0) {
-               iwe.u.data.length = min(network->ssid_len, (u8)32);
+               iwe.u.data.length = min_t(u8, network->ssid_len, 32);
                start = iwe_stream_add_point_rsl(info, start, stop, &iwe,
                                                 network->ssid);
        } else if (network->hidden_ssid_len == 0) {
@@ -82,7 +82,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
                start = iwe_stream_add_point_rsl(info, start, stop,
                                                 &iwe, "<hidden>");
        } else {
-               iwe.u.data.length = min(network->hidden_ssid_len, (u8)32);
+               iwe.u.data.length = min_t(u8, network->hidden_ssid_len, 32);
                start = iwe_stream_add_point_rsl(info, start, stop, &iwe,
                                                 network->hidden_ssid);
        }
@@ -282,8 +282,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
                        ev = rtl819x_translate_scan(ieee, ev, stop, network,
                                                    info);
                else
-                       RTLLIB_DEBUG_SCAN("Not showing network '%s ("
-                               " %pM)' due to age (%lums).\n",
+                       RTLLIB_DEBUG_SCAN("Not showing network '%s ( %pM)' due to age (%lums).\n",
                                escape_essid(network->ssid,
                                             network->ssid_len),
                                network->bssid,
@@ -344,7 +343,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                                if (key_provided)
                                        break;
                                lib80211_crypt_delayed_deinit(&ieee->crypt_info,
-                                                           &ieee->crypt_info.crypt[i]);
+                                                   &ieee->crypt_info.crypt[i]);
                        }
                }
 
@@ -390,9 +389,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                        kfree(new_crypt);
                        new_crypt = NULL;
 
-                       printk(KERN_WARNING "%s: could not initialize WEP: "
-                              "load module rtllib_crypt_wep\n",
-                              dev->name);
+                       netdev_warn(dev,
+                                   "%s: could not initialize WEP: load module rtllib_crypt_wep\n",
+                                   dev->name);
                        return -EOPNOTSUPP;
                }
                *crypt = new_crypt;
@@ -423,11 +422,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                                             NULL, (*crypt)->priv);
                if (len == 0) {
                        /* Set a default key of all 0 */
-                       printk(KERN_INFO "Setting key %d to all zero.\n",
+                       netdev_info(ieee->dev, "Setting key %d to all zero.\n",
                                           key);
 
-                       RTLLIB_DEBUG_WX("Setting key %d to all zero.\n",
-                                          key);
                        memset(sec.keys[key], 0, 13);
                        (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
                                               (*crypt)->priv);
@@ -437,8 +434,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
 
                /* No key data - just set the default TX key index */
                if (key_provided) {
-                       RTLLIB_DEBUG_WX(
-                               "Setting key %d to default Tx key.\n", key);
+                       RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n",
+                                       key);
                        ieee->crypt_info.tx_keyidx = key;
                        sec.active_key = key;
                        sec.flags |= SEC_ACTIVE_KEY;
@@ -469,7 +466,7 @@ int rtllib_wx_set_encode(struct rtllib_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(dev, "%s: reset_port failed\n", dev->name);
                return -EINVAL;
        }
        return 0;
@@ -596,7 +593,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
                ret = -EINVAL;
                goto done;
        }
-       printk(KERN_INFO "alg name:%s\n", alg);
+       netdev_info(dev, "alg name:%s\n", alg);
 
        ops = lib80211_get_crypto_ops(alg);
        if (ops == NULL) {
@@ -608,9 +605,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
                ops = lib80211_get_crypto_ops(alg);
        }
        if (ops == NULL) {
-               RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n",
-                                  dev->name, ext->alg);
-               printk(KERN_INFO "========>unknown crypto alg %d\n", ext->alg);
+               netdev_info(dev, "========>unknown crypto alg %d\n", ext->alg);
                ret = -EINVAL;
                goto done;
        }
@@ -641,8 +636,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
        if (ext->key_len > 0 && (*crypt)->ops->set_key &&
            (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
                                   (*crypt)->priv) < 0) {
-               RTLLIB_DEBUG_WX("%s: key setting failed\n", dev->name);
-               printk(KERN_INFO "key setting failed\n");
+               netdev_info(dev, "key setting failed\n");
                ret = -EINVAL;
                goto done;
        }
@@ -759,9 +753,9 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
 
        case IW_MLME_DISASSOC:
                if (deauth)
-                       printk(KERN_INFO "disauth packet !\n");
+                       netdev_info(ieee->dev, "disauth packet !\n");
                else
-                       printk(KERN_INFO "dis associate packet!\n");
+                       netdev_info(ieee->dev, "dis associate packet!\n");
 
                ieee->cannot_notify = true;
 
index 90ace791f2d77a9368143bf416188c0106184605..82d60380bb404a6c5c332c3b35ca5d423d538ca9 100644 (file)
@@ -6,7 +6,7 @@ void Dot11d_Init(struct ieee80211_device *ieee)
 {
        PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
 
-       pDot11dInfo->bEnabled = 0;
+       pDot11dInfo->bEnabled = false;
 
        pDot11dInfo->State = DOT11D_STATE_NONE;
        pDot11dInfo->CountryIeLen = 0;
index bd75e29adc2c41bfccb211e40130c64ae65185a4..8ae673b217d89e32c752451f63e03e41e1136900 100644 (file)
@@ -53,7 +53,7 @@ typedef struct _RT_DOT11D_INFO {
 
 #define CIE_WATCHDOG_TH 1
 #define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog)
-#define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
+#define RESET_CIE_WATCHDOG(__pIeeeDev) (GET_CIE_WATCHDOG(__pIeeeDev) = 0)
 #define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev))
 
 #define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
index b44aa17d30a764f429fad303d9c562d97975b8d4..0f53c6a97578504d0f4a31eb42a98d846e6c3ba3 100644 (file)
@@ -606,33 +606,6 @@ do { if (ieee80211_debug_level & (level)) \
 #define IEEE80211_DEBUG_RX(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
 #define IEEE80211_DEBUG_QOS(f, a...)  IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a)
 
-#ifdef CONFIG_IEEE80211_DEBUG
-/* Added by Annie, 2005-11-22. */
-#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)                                                     \
-                       {                                                                       \
-                               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 );                            \
-                               for( __i=0; __i<MAX_STR_LEN; __i++ )                            \
-                               {                                                               \
-                                    if( !PRINTABLE(buffer[__i]) )   buffer[__i] = '?';         \
-                               }                                                               \
-                               buffer[length] = '\0';                                          \
-                               printk("Rtl819x: ");                                            \
-                               printk(_TitleString);                                         \
-                               printk(": %d, <%s>\n", _Len, buffer);                         \
-                       }
-#else
-#define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len)  do {} while (0)
-#endif
-
-#include <linux/netdevice.h>
 #include <linux/if_arp.h> /* ARPHRD_ETHER */
 
 #ifndef WIRELESS_SPY
@@ -661,7 +634,7 @@ struct ieee80211_snap_hdr {
        u8    ctrl;   /* always 0x03 */
        u8    oui[P80211_OUI_LEN];    /* organizational universal id */
 
-} __attribute__ ((packed));
+} __packed;
 
 #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
 
@@ -996,7 +969,7 @@ struct ieee80211_security {
        u8 keys[WEP_KEYS][SCM_KEY_LEN];
        u8 level;
        u16 flags;
-} __attribute__ ((packed));
+} __packed;
 
 
 /*
@@ -1051,14 +1024,14 @@ struct ieee80211_hdr {
        __le16 frame_ctl;
        __le16 duration_id;
        u8 payload[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_1addr {
        __le16 frame_ctl;
        __le16 duration_id;
        u8 addr1[ETH_ALEN];
        u8 payload[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_2addr {
        __le16 frame_ctl;
@@ -1066,7 +1039,7 @@ struct ieee80211_hdr_2addr {
        u8 addr1[ETH_ALEN];
        u8 addr2[ETH_ALEN];
        u8 payload[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_3addr {
        __le16 frame_ctl;
@@ -1076,7 +1049,7 @@ struct ieee80211_hdr_3addr {
        u8 addr3[ETH_ALEN];
        __le16 seq_ctl;
        u8 payload[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_4addr {
        __le16 frame_ctl;
@@ -1087,7 +1060,7 @@ struct ieee80211_hdr_4addr {
        __le16 seq_ctl;
        u8 addr4[ETH_ALEN];
        u8 payload[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_3addrqos {
        __le16 frame_ctl;
@@ -1098,7 +1071,7 @@ struct ieee80211_hdr_3addrqos {
        __le16 seq_ctl;
        u8 payload[0];
        __le16 qos_ctl;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_hdr_4addrqos {
        __le16 frame_ctl;
@@ -1110,13 +1083,13 @@ struct ieee80211_hdr_4addrqos {
        u8 addr4[ETH_ALEN];
        u8 payload[0];
        __le16 qos_ctl;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_info_element {
        u8 id;
        u8 len;
        u8 data[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_authentication {
        struct ieee80211_hdr_3addr header;
@@ -1125,18 +1098,18 @@ struct ieee80211_authentication {
        __le16 status;
        /*challenge*/
        struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_disassoc {
        struct ieee80211_hdr_3addr header;
        __le16 reason;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_probe_request {
        struct ieee80211_hdr_3addr header;
        /* SSID, supported rates */
        struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_probe_response {
        struct ieee80211_hdr_3addr header;
@@ -1146,7 +1119,7 @@ struct ieee80211_probe_response {
        /* SSID, supported rates, FH params, DS params,
         * CF params, IBSS params, TIM (if beacon), RSN */
        struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
+} __packed;
 
 /* Alias beacon for probe_response */
 #define ieee80211_beacon ieee80211_probe_response
@@ -1157,7 +1130,7 @@ struct ieee80211_assoc_request_frame {
        __le16 listen_interval;
        /* SSID, supported rates, RSN */
        struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_reassoc_request_frame {
        struct ieee80211_hdr_3addr header;
@@ -1166,7 +1139,7 @@ struct ieee80211_reassoc_request_frame {
        u8 current_ap[ETH_ALEN];
        /* SSID, supported rates, RSN */
        struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_assoc_response_frame {
        struct ieee80211_hdr_3addr header;
@@ -1174,7 +1147,7 @@ struct ieee80211_assoc_response_frame {
        __le16 status;
        __le16 aid;
        struct ieee80211_info_element info_element[0]; /* supported rates */
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_txb {
        u8 nr_frags;
@@ -1191,7 +1164,7 @@ struct ieee80211_txb {
 struct ieee80211_drv_agg_txb {
        u8 nr_drv_agg_frames;
        struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT];
-}__attribute__((packed));
+} __packed;
 
 #define MAX_SUBFRAME_COUNT               64
 struct ieee80211_rxb {
@@ -1199,7 +1172,7 @@ struct ieee80211_rxb {
        struct sk_buff *subframes[MAX_SUBFRAME_COUNT];
        u8 dst[ETH_ALEN];
        u8 src[ETH_ALEN];
-}__attribute__((packed));
+} __packed;
 
 typedef union _frameqos {
        u16 shortdata;
@@ -1267,19 +1240,19 @@ struct ieee80211_qos_information_element {
        u8 qui_subtype;
        u8 version;
        u8 ac_info;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_qos_ac_parameter {
        u8 aci_aifsn;
        u8 ecw_min_max;
        __le16 tx_op_limit;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_qos_parameter_info {
        struct ieee80211_qos_information_element info_element;
        u8 reserved;
        struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_qos_parameters {
        __le16 cw_min[QOS_QUEUE_NUM];
@@ -1287,7 +1260,7 @@ struct ieee80211_qos_parameters {
        u8 aifs[QOS_QUEUE_NUM];
        u8 flag[QOS_QUEUE_NUM];
        __le16 tx_op_limit[QOS_QUEUE_NUM];
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_qos_data {
        struct ieee80211_qos_parameters parameters;
@@ -1300,7 +1273,7 @@ struct ieee80211_qos_data {
 struct ieee80211_tim_parameters {
        u8 tim_count;
        u8 tim_period;
-} __attribute__ ((packed));
+} __packed;
 
 //#else
 struct ieee80211_wmm_ac_param {
@@ -1313,7 +1286,7 @@ struct ieee80211_wmm_ts_info {
        u8 ac_dir_tid;
        u8 ac_up_psb;
        u8 reserved;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_wmm_tspec_elem {
        struct ieee80211_wmm_ts_info ts_info;
@@ -1332,7 +1305,7 @@ struct ieee80211_wmm_tspec_elem {
        u32 min_phy_rate;
        u16 surp_band_allow;
        u16 medium_time;
-}__attribute__((packed));
+} __packed;
 enum eap_type {
        EAP_PACKET = 0,
        EAPOL_START,
@@ -1371,7 +1344,7 @@ struct eapol {
        u8 version;
        u8 type;
        u16 length;
-} __attribute__ ((packed));
+} __packed;
 
 struct ieee80211_softmac_stats{
        unsigned int rx_ass_ok;
@@ -1401,7 +1374,7 @@ struct ieee80211_softmac_stats{
 struct ieee80211_info_element_hdr {
        u8 id;
        u8 len;
-} __attribute__ ((packed));
+} __packed;
 
 /*
  * These are the data types that can make up management packets
@@ -1414,7 +1387,7 @@ struct ieee80211_info_element_hdr {
        u16 listen_interval;
        struct {
                u16 association_id:14, reserved:2;
-       } __attribute__ ((packed));
+       } __packed;
        u32 time_stamp[2];
        u16 reason;
        u16 status;
@@ -1475,7 +1448,7 @@ struct    ether_header {
        u8 ether_dhost[ETHER_ADDR_LEN];
        u8 ether_shost[ETHER_ADDR_LEN];
        u16 ether_type;
-} __attribute__((packed));
+} __packed;
 
 #ifndef ETHERTYPE_PAE
 #define        ETHERTYPE_PAE   0x888e          /* EAPOL PAE/802.1x */
@@ -1484,24 +1457,6 @@ struct   ether_header {
 #define        ETHERTYPE_IP    0x0800          /* IP protocol */
 #endif
 
-typedef struct _bss_ht{
-
-       bool                            support_ht;
-
-       // HT related elements
-       u8                                      ht_cap_buf[32];
-       u16                                     ht_cap_len;
-       u8                                      ht_info_buf[32];
-       u16                                     ht_info_len;
-
-       HT_SPEC_VER                     ht_spec_ver;
-       //HT_CAPABILITY_ELE                     bdHTCapEle;
-       //HT_INFORMATION_ELE            bdHTInfoEle;
-
-       bool                            aggregation;
-       bool                            long_slot_time;
-}bss_ht, *pbss_ht;
-
 typedef enum _erp_t{
        ERP_NonERPpresent       = 0x01,
        ERP_UseProtection       = 0x02,
index 55332217c29fb211fceca01a7c08a4a8be453bca..3995620b3442deb0d8d73ed6e03a6b9e28ecbde5 100644 (file)
  *
  */
 
-//#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <asm/string.h>
-#include <asm/errno.h>
+#include <linux/string.h>
+#include <linux/errno.h>
 
 #include "ieee80211.h"
 
@@ -66,8 +65,8 @@ void ieee80211_crypt_deinit_handler(unsigned long data)
        spin_lock_irqsave(&ieee->lock, flags);
        ieee80211_crypt_deinit_entries(ieee, 0);
        if (!list_empty(&ieee->crypt_deinit_list)) {
-               printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
-                      "deletion list\n", ieee->dev->name);
+               netdev_dbg(ieee->dev, "%s: entries remaining in delayed crypt deletion list\n",
+                               ieee->dev->name);
                ieee->crypt_deinit_timer.expires = jiffies + HZ;
                add_timer(&ieee->crypt_deinit_timer);
        }
@@ -118,7 +117,7 @@ int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
        list_add(&alg->list, &hcrypt->algs);
        spin_unlock_irqrestore(&hcrypt->lock, flags);
 
-       printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n",
+       pr_debug("ieee80211_crypt: registered algorithm '%s'\n",
               ops->name);
 
        return 0;
@@ -146,8 +145,8 @@ int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
        spin_unlock_irqrestore(&hcrypt->lock, flags);
 
        if (del_alg) {
-               printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
-                      "'%s'\n", ops->name);
+               pr_debug("ieee80211_crypt: unregistered algorithm '%s'\n",
+                               ops->name);
                kfree(del_alg);
        }
 
@@ -232,8 +231,8 @@ void __exit ieee80211_crypto_deinit(void)
                struct ieee80211_crypto_alg *alg =
                        (struct ieee80211_crypto_alg *) ptr;
                list_del(ptr);
-               printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
-                      "'%s' (deinit)\n", alg->ops->name);
+               pr_debug("ieee80211_crypt: unregistered algorithm '%s' (deinit)\n",
+                               alg->ops->name);
                kfree(alg);
        }
 
index 143b682477e59f16954f6ab9a26cbac10021fb37..788704b800c4002405f1408dc575976dddd55d44 100644 (file)
@@ -9,7 +9,6 @@
  * more details.
  */
 
-//#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -18,7 +17,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_ether.h>
 #include <linux/if_arp.h>
-#include <asm/string.h>
+#include <linux/string.h>
 #include <linux/wireless.h>
 
 #include "ieee80211.h"
@@ -130,9 +129,9 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
        qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
                       (WLAN_FC_GET_STYPE(fc) & 0x08));
        */
-       // fixed by David :2006.9.6
-       qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
-                      (WLAN_FC_GET_STYPE(fc) & 0x80));
+       /* fixed by David :2006.9.6 */
+       qc_included = (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
+                      (WLAN_FC_GET_STYPE(fc) & 0x80);
        aad_len = 22;
        if (a4_included)
                aad_len += 6;
@@ -209,7 +208,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        pos = skb_push(skb, CCMP_HDR_LEN);
        memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
        pos += hdr_len;
-//     mic = skb_put(skb, CCMP_MIC_LEN);
+       /* mic = skb_put(skb, CCMP_MIC_LEN); */
 
        i = CCMP_PN_LEN - 1;
        while (i >= 0) {
@@ -239,7 +238,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
                u8 *e = key->tx_e;
                u8 *s0 = key->tx_s0;
 
-               //mic is moved to here by john
+               /* mic is moved to here by john */
                mic = skb_put(skb, CCMP_MIC_LEN);
 
                ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
@@ -444,7 +443,7 @@ static char *ieee80211_ccmp_print_stats(char *p, void *priv)
 
 void ieee80211_ccmp_null(void)
 {
-//    printk("============>%s()\n", __func__);
+       /* printk("============>%s()\n", __func__); */
        return;
 }
 
index fcc90a5700d66784555d507b5e8a9192b7307046..e815c81b45dc59551341c981685794c721939a5e 100644 (file)
@@ -9,7 +9,6 @@
  * more details.
  */
 
-//#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
@@ -18,7 +17,7 @@
 #include <linux/netdevice.h>
 #include <linux/if_ether.h>
 #include <linux/if_arp.h>
-#include <asm/string.h>
+#include <linux/string.h>
 
 #include "ieee80211.h"
 
index 8c1bf1f56883fb3d5dad053f0af747e0389ea2de..0a17f84bb809124ffe050eccff359b9cf927aa6c 100644 (file)
@@ -9,13 +9,12 @@
  * more details.
  */
 
-//#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/skbuff.h>
-#include <asm/string.h>
+#include <linux/string.h>
 
 #include "ieee80211.h"
 
@@ -49,14 +48,14 @@ static void *prism2_wep_init(int keyidx)
 
        priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->tx_tfm)) {
-               printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+               pr_debug("ieee80211_crypt_wep: could not allocate "
                       "crypto API arc4\n");
                priv->tx_tfm = NULL;
                goto fail;
        }
        priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(priv->rx_tfm)) {
-               printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
+               pr_debug("ieee80211_crypt_wep: could not allocate "
                       "crypto API arc4\n");
                priv->rx_tfm = NULL;
                goto fail;
@@ -110,6 +109,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
        u32 crc;
        u8 *icv;
        struct scatterlist sg;
+
        if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
            skb->len < hdr_len)
                return -1;
@@ -128,6 +128,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
         * can be used to speedup attacks, so avoid using them. */
        if ((wep->iv & 0xff00) == 0xff00) {
                u8 B = (wep->iv >> 16) & 0xff;
+
                if (B >= 3 && B < klen)
                        wep->iv += 0x0100;
        }
@@ -180,6 +181,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        u32 crc;
        u8 icv[4];
        struct scatterlist sg;
+
        if (skb->len < hdr_len + 8)
                return -1;
 
@@ -256,6 +258,7 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
 static char *prism2_wep_print_stats(char *p, void *priv)
 {
        struct prism2_wep_data *wep = priv;
+
        p += sprintf(p, "key[%d] alg=WEP len=%d\n",
                     wep->key_idx, wep->key_len);
        return p;
index afbd09d7300a0e10c40631359ee9c646bf4ec982..31233d895ee9414c2206697d0d7e1dc3b1ae8613 100644 (file)
@@ -31,7 +31,7 @@
 *******************************************************************************/
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
+/* #include <linux/config.h> */
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
@@ -133,15 +133,14 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
        ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
 
        INIT_LIST_HEAD(&ieee->crypt_deinit_list);
-       init_timer(&ieee->crypt_deinit_timer);
-       ieee->crypt_deinit_timer.data = (unsigned long)ieee;
-       ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
+       setup_timer(&ieee->crypt_deinit_timer,
+                   ieee80211_crypt_deinit_handler, (unsigned long)ieee);
 
        spin_lock_init(&ieee->lock);
        spin_lock_init(&ieee->wpax_suitlist_lock);
        spin_lock_init(&ieee->bw_spinlock);
        spin_lock_init(&ieee->reorder_spinlock);
-       //added by WB
+       /* added by WB */
        atomic_set(&(ieee->atm_chnlop), 0);
        atomic_set(&(ieee->atm_swbw), 0);
 
@@ -153,7 +152,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
        ieee->ieee802_1x = 1;
        ieee->raw_tx = 0;
        //ieee->hwsec_support = 1; //defalt support hw security. //use module_param instead.
-       ieee->hwsec_active = 0; //disable hwsec, switch it on when necessary.
+       ieee->hwsec_active = 0; /* disable hwsec, switch it on when necessary. */
 
        ieee80211_softmac_init(ieee);
 
@@ -164,7 +163,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
                goto failed;
        }
        HTUpdateDefaultSetting(ieee);
-       HTInitializeHTInfo(ieee); //may move to other place.
+       HTInitializeHTInfo(ieee); /* may move to other place. */
        TSInitialize(ieee);
 
        for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
@@ -176,7 +175,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
          ieee->last_packet_time[i] = 0;
        }
 
-//These function were added to load crypte module autoly
+/* These function were added to load crypte module autoly */
        ieee80211_tkip_null();
        ieee80211_wep_null();
        ieee80211_ccmp_null();
@@ -195,7 +194,7 @@ void free_ieee80211(struct net_device *dev)
 {
        struct ieee80211_device *ieee = netdev_priv(dev);
        int i;
-       //struct list_head *p, *q;
+       /* struct list_head *p, *q; */
 //     del_timer_sync(&ieee->SwBwTimer);
        kfree(ieee->pHTInfo);
        ieee->pHTInfo = NULL;
@@ -239,13 +238,15 @@ static int debug = \
        //                  IEEE80211_DL_REORDER|
 //                         IEEE80211_DL_TRACE  |
                            //IEEE80211_DL_DATA |
-                           IEEE80211_DL_ERR      //awayls open this flags to show error out
+                           IEEE80211_DL_ERR      /* awayls open this flags to show error out */
                            ;
 static struct proc_dir_entry *ieee80211_proc;
 
 static int show_debug_level(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "0x%08X\n", ieee80211_debug_level);
+       seq_printf(m, "0x%08X\n", ieee80211_debug_level);
+
+       return 0;
 }
 
 static ssize_t write_debug_level(struct file *file, const char __user *buffer,
@@ -284,7 +285,7 @@ int __init ieee80211_debug_init(void)
                                " proc directory\n");
                return -EIO;
        }
-       e = proc_create("debug_level", S_IRUGO | S_IWUSR, 
+       e = proc_create("debug_level", S_IRUGO | S_IWUSR,
                              ieee80211_proc, &fops);
        if (!e) {
                remove_proc_entry(DRV_NAME, init_net.proc_net);
@@ -303,7 +304,6 @@ void __exit ieee80211_debug_exit(void)
        }
 }
 
-#include <linux/moduleparam.h>
 module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
 #endif
index d401dbf4c7c608767d7c7b011d49e7f460799b2a..0a90450a295d455e0c156cfe623f84d9fb850a93 100644 (file)
@@ -22,7 +22,6 @@
 
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
@@ -39,7 +38,7 @@
 #include <linux/types.h>
 #include <linux/wireless.h>
 #include <linux/etherdevice.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/ctype.h>
 
 #include "ieee80211.h"
@@ -56,7 +55,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
 
        skb_pull(skb, ieee80211_get_hdrlen(fc));
        skb->pkt_type = PACKET_OTHERHOST;
-       skb->protocol = __constant_htons(ETH_P_80211_RAW);
+       skb->protocol = htons(ETH_P_80211_RAW);
        memset(skb->cb, 0, sizeof(skb->cb));
        netif_rx(skb);
 }
@@ -222,8 +221,8 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
 
        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
+       /* 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;
@@ -944,7 +943,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                if(net_ratelimit())
                printk("find HTCControl\n");
                hdrlen += 4;
-               rx_stats->bContainHTC = 1;
+               rx_stats->bContainHTC = true;
        }
 
        //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
index d1471877e19d6e0b8ee127d7317f41124921ad7a..66b1587148228f14bd31d52c6da0584c179ef9b9 100644 (file)
@@ -877,7 +877,7 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee,
                crypt = ieee->crypt[ieee->tx_keyidx];
        else crypt = NULL;
 
-       encrypt = (crypt && crypt->ops);
+       encrypt = crypt && crypt->ops;
 
        if (encrypt)
                assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
@@ -1371,7 +1371,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work)
        else if(ieee->is_silent_reset == 1)
        {
                printk("==================>silent reset associate\n");
-               ieee->is_silent_reset = 0;
+               ieee->is_silent_reset = false;
        }
 
        if (ieee->data_hard_resume)
@@ -1920,6 +1920,66 @@ static void ieee80211_process_action(struct ieee80211_device *ieee,
        return;
 
 }
+
+void ieee80211_check_auth_response(struct ieee80211_device *ieee,
+                                  struct sk_buff *skb)
+{
+       /* default support N mode, disable halfNmode */
+       bool bSupportNmode = true, bHalfSupportNmode = false;
+       u16 errcode;
+       u8 *challenge;
+       int chlen = 0;
+       u32 iotAction;
+
+       errcode = auth_parse(skb, &challenge, &chlen);
+       if (!errcode) {
+               if (ieee->open_wep || !challenge) {
+                       ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
+                       ieee->softmac_stats.rx_auth_rs_ok++;
+                       iotAction = ieee->pHTInfo->IOTAction;
+                       if (!(iotAction & HT_IOT_ACT_PURE_N_MODE)) {
+                               if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
+                                       /* WEP or TKIP encryption */
+                                       if (IsHTHalfNmodeAPs(ieee)) {
+                                               bSupportNmode = true;
+                                               bHalfSupportNmode = true;
+                                       } else {
+                                               bSupportNmode = false;
+                                               bHalfSupportNmode = false;
+                                       }
+                                       netdev_dbg(ieee->dev, "SEC(%d, %d)\n",
+                                                       bSupportNmode,
+                                                       bHalfSupportNmode);
+                               }
+                       }
+                       /* Dummy wirless mode setting- 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) {
+                               netdev_dbg(ieee->dev, "enter half N mode\n");
+                               ieee->bHalfWirelessN24GMode = true;
+                       } else
+                               ieee->bHalfWirelessN24GMode = false;
+
+                       ieee80211_associate_step2(ieee);
+               } else {
+                       ieee80211_auth_challenge(ieee, challenge, chlen);
+               }
+       } else {
+               ieee->softmac_stats.rx_auth_rs_err++;
+               IEEE80211_DEBUG_MGMT("Auth response status code 0x%x", errcode);
+               ieee80211_associate_abort(ieee);
+       }
+}
+
 inline int
 ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats, u16 type,
@@ -1927,12 +1987,9 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
 {
        struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data;
        u16 errcode;
-       u8 *challenge;
-       int chlen=0;
        int aid;
        struct ieee80211_assoc_response_frame *assoc_resp;
 //     struct ieee80211_info_element *info_element;
-       bool bSupportNmode = true, bHalfSupportNmode = false; //default support N mode, disable halfNmode
 
        if(!ieee->proto_started)
                return 0;
@@ -2014,67 +2071,15 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
        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->state == IEEE80211_ASSOCIATING_AUTHENTICATING
+                               && ieee->iw_mode == IW_MODE_INFRA) {
 
-                                       IEEE80211_DEBUG_MGMT("Received authentication response");
-
-                                       errcode = auth_parse(skb, &challenge, &chlen);
-                                       if (!errcode) {
-                                               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))
-                                                               {
-                                                                                       // 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);
-                                                               }
-                                                       }
-                                                       /* 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);
-                                               }else{
-                                                       ieee80211_auth_challenge(ieee, challenge, chlen);
-                                               }
-                                       }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);
-                               }
+                               IEEE80211_DEBUG_MGMT("Received auth response");
+                               ieee80211_check_auth_response(ieee, skb);
+                       } else if (ieee->iw_mode == IW_MODE_MASTER) {
+                               ieee80211_rx_auth_rq(ieee, skb);
                        }
+               }
                break;
 
        case IEEE80211_STYPE_PROBE_REQ:
@@ -2110,27 +2115,26 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
                break;
        default:
                return -1;
-               break;
        }
 
        //dev_kfree_skb_any(skb);
        return 0;
 }
 
-/* following are for a simpler TX queue management.
- * Instead of using netif_[stop/wake]_queue the driver
- * will uses these two function (plus a reset one), that
- * will internally uses the kernel netif_* and takes
- * care of the ieee802.11 fragmentation.
- * So the driver receives a fragment per time and might
- * call the stop function when it want without take care
- * to have enought room to TX an entire packet.
- * This might be useful if each fragment need it's own
- * descriptor, thus just keep a total free memory > than
- * the max fragmentation treshold is not enought.. If the
- * ieee802.11 stack passed a TXB struct then you needed
+/* The following are for a simpler TX queue management.
+ * Instead of using netif_[stop/wake]_queue, the driver
+ * will use these two functions (plus a reset one) that
+ * will internally call the kernel netif_* and take care
+ * of the ieee802.11 fragmentation.
+ * So, the driver receives a fragment at a time and might
+ * call the stop function when it wants, without taking
+ * care to have enough room to TX an entire packet.
+ * This might be useful if each fragment needs its own
+ * descriptor. Thus, just keeping a total free memory > than
+ * the max fragmentation threshold is not enough. If the
+ * ieee802.11 stack passed a TXB struct, then you would need
  * to keep N free descriptors where
- * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
+ * N = MAX_PACKET_SIZE / MIN_FRAG_THRESHOLD.
  * In this way you need just one and the 802.11 stack
  * will take care of buffering fragments and pass them to
  * to the driver later, when it wakes the queue.
@@ -2719,16 +2723,14 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee)
        ieee->sta_edca_param[2] = 0x005E4342;
        ieee->sta_edca_param[3] = 0x002F3262;
        ieee->aggregation = true;
-       ieee->enable_rx_imm_BA = 1;
+       ieee->enable_rx_imm_BA = true;
        ieee->tx_pending.txb = NULL;
 
-       init_timer(&ieee->associate_timer);
-       ieee->associate_timer.data = (unsigned long)ieee;
-       ieee->associate_timer.function = ieee80211_associate_abort_cb;
+       setup_timer(&ieee->associate_timer, ieee80211_associate_abort_cb,
+                   (unsigned long)ieee);
 
-       init_timer(&ieee->beacon_timer);
-       ieee->beacon_timer.data = (unsigned long) ieee;
-       ieee->beacon_timer.function = ieee80211_send_beacon_cb;
+       setup_timer(&ieee->beacon_timer, ieee80211_send_beacon_cb,
+                   (unsigned long)ieee);
 
        ieee->wq = create_workqueue(DRV_NAME);
 
@@ -3027,12 +3029,11 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
 
                ieee80211_crypt_delayed_deinit(ieee, crypt);
 
-               new_crypt = kmalloc(sizeof(*new_crypt), GFP_KERNEL);
+               new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
                new_crypt->ops = ops;
                if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
                        new_crypt->priv =
@@ -3210,7 +3211,7 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
        if (ieee->state == IEEE80211_LINKED)
                memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid, ETH_ALEN);
        else
-               memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+               eth_zero_addr(wrqu.ap_addr.sa_data);
        wireless_send_event(ieee->dev, SIOCGIWAP, &wrqu, NULL);
 }
 EXPORT_SYMBOL(notify_wx_assoc_event);
index 644368df634223c06e248d3aa50bc78b061b930d..dcfa5abea12777b10dda07a33c6a9be67d08602a 100644 (file)
@@ -121,7 +121,7 @@ int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
                ieee->state != IEEE80211_LINKED_SCANNING &&
                ieee->wap_set == 0)
 
-               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+               eth_zero_addr(wrqu->ap_addr.sa_data);
        else
                memcpy(wrqu->ap_addr.sa_data,
                       ieee->current_network.bssid, ETH_ALEN);
index fca73c7c9fbe911c1f6d7dc3cf8824b1939e98d0..9f68c652fb2bf8b0807880a917135f1b338e0f26 100644 (file)
@@ -32,7 +32,6 @@
 ******************************************************************************/
 
 #include <linux/compiler.h>
-//#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
@@ -554,16 +553,16 @@ static void ieee80211_txrate_selectmode(struct ieee80211_device *ieee,
 #ifdef TO_DO_LIST
        if(!IsDataFrame(pFrame))
        {
-               pTcb->bTxDisableRateFallBack = TRUE;
-               pTcb->bTxUseDriverAssingedRate = TRUE;
+               pTcb->bTxDisableRateFallBack = true;
+               pTcb->bTxUseDriverAssingedRate = true;
                pTcb->RATRIndex = 7;
                return;
        }
 
        if(pMgntInfo->ForcedDataRate!= 0)
        {
-               pTcb->bTxDisableRateFallBack = TRUE;
-               pTcb->bTxUseDriverAssingedRate = TRUE;
+               pTcb->bTxDisableRateFallBack = true;
+               pTcb->bTxUseDriverAssingedRate = true;
                return;
        }
 #endif
index e60d926a3973f42445ccb4437f75a336aacdce11..69b0e30541861c2a2a5150270f3bf13dcb06a3d4 100644 (file)
@@ -471,12 +471,10 @@ static bool HTIOTActIsDisableMCS15(struct ieee80211_device *ieee)
 static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee,
                                                 u8 *PeerMacAddr)
 {
-       bool retValue = false;
-
 #ifdef TODO
        // Apply for 819u only
 #endif
-       return retValue;
+       return false;
 }
 
 /********************************************************************************************************************
@@ -488,11 +486,8 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct ieee80211_device *ieee,
   * *****************************************************************************************************************/
 static 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.
-
-       return retValue;
+{      /* default enable EDCA Turbo mode. */
+       return false;
 }
 
 /********************************************************************************************************************
@@ -889,7 +884,7 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF
                                        if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
                                                mcsRate = (8*i+j);
                                }
-                               bitMap = bitMap>>1;
+                               bitMap >>= 1;
                        }
                }
        }
index 7ed7243b1fb07e69b5edfe7e559e955d1c01a880..873969c9f226f74d8826d5f810c0614ea1d987ff 100644 (file)
@@ -1,14 +1,14 @@
 #ifndef _TSTYPE_H_
 #define _TSTYPE_H_
 #include "rtl819x_Qos.h"
-#define TS_SETUP_TIMEOUT       60  // In millisecond
+#define TS_SETUP_TIMEOUT       60  /*  In millisecond */
 #define TS_INACT_TIMEOUT       60
 #define TS_ADDBA_DELAY         60
 
 #define TOTAL_TS_NUM           16
 #define TCLAS_NUM              4
 
-// This define the Tx/Rx directions
+/*  This define the Tx/Rx directions */
 typedef enum _TR_SELECT {
        TX_DIR = 0,
        RX_DIR = 1,
@@ -28,9 +28,9 @@ typedef struct _TS_COMMON_INFO{
 typedef struct _TX_TS_RECORD{
        TS_COMMON_INFO          TsCommonInfo;
        u16                             TxCurSeq;
-       BA_RECORD                       TxPendingBARecord;      // For BA Originator
-       BA_RECORD                       TxAdmittedBARecord;     // For BA Originator
-//     QOS_DL_RECORD           DLRecord;
+       BA_RECORD                       TxPendingBARecord;      /*  For BA Originator */
+       BA_RECORD                       TxAdmittedBARecord;     /*  For BA Originator */
+/*     QOS_DL_RECORD           DLRecord; */
        u8                              bAddBaReqInProgress;
        u8                              bAddBaReqDelayed;
        u8                              bUsingBa;
@@ -44,11 +44,11 @@ typedef struct _RX_TS_RECORD {
        u16                             RxTimeoutIndicateSeq;
        struct list_head                RxPendingPktList;
        struct timer_list               RxPktPendingTimer;
-       BA_RECORD                       RxAdmittedBARecord;      // For BA Recipient
+       BA_RECORD                       RxAdmittedBARecord;      /*  For BA Recipient */
        u16                             RxLastSeqNum;
        u8                              RxLastFragNum;
        u8                              num;
-//     QOS_DL_RECORD           DLRecord;
+/*     QOS_DL_RECORD           DLRecord; */
 } RX_TS_RECORD, *PRX_TS_RECORD;
 
 
index acaa723817e709dd574ffeedd89bb980d0f27a2f..ea92fdebe5a748a9f762f482f97ad706d428271e 100644 (file)
@@ -156,26 +156,16 @@ void TSInitialize(struct ieee80211_device *ieee)
                pTxTS->num = count;
                // The timers for the operation of Traffic Stream and Block Ack.
                // DLS related timer will be add here in the future!!
-               init_timer(&pTxTS->TsCommonInfo.SetupTimer);
-               pTxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
-               init_timer(&pTxTS->TsCommonInfo.InactTimer);
-               pTxTS->TsCommonInfo.InactTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
-               init_timer(&pTxTS->TsAddBaTimer);
-               pTxTS->TsAddBaTimer.data = (unsigned long)pTxTS;
-               pTxTS->TsAddBaTimer.function = TsAddBaProcess;
-
-               init_timer(&pTxTS->TxPendingBARecord.Timer);
-               pTxTS->TxPendingBARecord.Timer.data = (unsigned long)pTxTS;
-               pTxTS->TxPendingBARecord.Timer.function = BaSetupTimeOut;
-
-               init_timer(&pTxTS->TxAdmittedBARecord.Timer);
-               pTxTS->TxAdmittedBARecord.Timer.data = (unsigned long)pTxTS;
-               pTxTS->TxAdmittedBARecord.Timer.function = TxBaInactTimeout;
-
+               setup_timer(&pTxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TsCommonInfo.InactTimer, TsInactTimeout,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TsAddBaTimer, TsAddBaProcess,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TxPendingBARecord.Timer, BaSetupTimeOut,
+                           (unsigned long)pTxTS);
+               setup_timer(&pTxTS->TxAdmittedBARecord.Timer,
+                           TxBaInactTimeout, (unsigned long)pTxTS);
                ResetTxTsEntry(pTxTS);
                list_add_tail(&pTxTS->TsCommonInfo.List, &ieee->Tx_TS_Unused_List);
                pTxTS++;
@@ -189,23 +179,14 @@ void TSInitialize(struct ieee80211_device *ieee)
        {
                pRxTS->num = count;
                INIT_LIST_HEAD(&pRxTS->RxPendingPktList);
-
-               init_timer(&pRxTS->TsCommonInfo.SetupTimer);
-               pRxTS->TsCommonInfo.SetupTimer.data = (unsigned long)pRxTS;
-               pRxTS->TsCommonInfo.SetupTimer.function = TsSetupTimeOut;
-
-               init_timer(&pRxTS->TsCommonInfo.InactTimer);
-               pRxTS->TsCommonInfo.InactTimer.data = (unsigned long)pRxTS;
-               pRxTS->TsCommonInfo.InactTimer.function = TsInactTimeout;
-
-               init_timer(&pRxTS->RxAdmittedBARecord.Timer);
-               pRxTS->RxAdmittedBARecord.Timer.data = (unsigned long)pRxTS;
-               pRxTS->RxAdmittedBARecord.Timer.function = RxBaInactTimeout;
-
-               init_timer(&pRxTS->RxPktPendingTimer);
-               pRxTS->RxPktPendingTimer.data = (unsigned long)pRxTS;
-               pRxTS->RxPktPendingTimer.function = RxPktPendingTimeout;
-
+               setup_timer(&pRxTS->TsCommonInfo.SetupTimer, TsSetupTimeOut,
+                           (unsigned long)pRxTS);
+               setup_timer(&pRxTS->TsCommonInfo.InactTimer, TsInactTimeout,
+                           (unsigned long)pRxTS);
+               setup_timer(&pRxTS->RxAdmittedBARecord.Timer,
+                           RxBaInactTimeout, (unsigned long)pRxTS);
+               setup_timer(&pRxTS->RxPktPendingTimer, RxPktPendingTimeout,
+                           (unsigned long)pRxTS);
                ResetRxTsEntry(pRxTS);
                list_add_tail(&pRxTS->TsCommonInfo.List, &ieee->Rx_TS_Unused_List);
                pRxTS++;
@@ -288,7 +269,7 @@ static PTS_COMMON_INFO SearchAdmitTRStream(struct ieee80211_device *ieee,
        //for(dir = DIR_UP; dir <= DIR_BI_DIR; dir++)
        for(dir = 0; dir <= DIR_BI_DIR; dir++)
        {
-               if(search_dir[dir] ==false )
+               if (!search_dir[dir])
                        continue;
                list_for_each_entry(pRet, psearch_list, List){
        //              IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.field.ucTSID, pRet->TSpec.f.TSInfo.field.ucDirection);
@@ -400,8 +381,7 @@ bool GetTs(
        }
        else
        {
-               if(bAddNewTs == false)
-               {
+               if (!bAddNewTs) {
                        IEEE80211_DEBUG(IEEE80211_DL_TS, "add new TS failed(tid:%d)\n", UP);
                        return false;
                }
index 1868352d3789ea784770e21ee3292bebf2fdcb7e..e00032947e0fc5aa893cb395bcbeacf1cda73512 100644 (file)
@@ -225,7 +225,7 @@ void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel)
        struct r8192_priv *priv = ieee80211_priv(dev);
        TxAGC = powerlevel;
 
-       if (priv->bDynamicTxLowPower == TRUE) {
+       if (priv->bDynamicTxLowPower) {
                if (priv->CustomerID == RT_CID_819x_Netcore)
                        TxAGC = 0x22;
                else
@@ -275,7 +275,7 @@ void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel)
                        priv->Pwr_Track = writeVal_tmp;
                }
 
-               if (priv->bDynamicTxHighPower == TRUE) {
+               if (priv->bDynamicTxHighPower) {
                        /*Add by Jacken 2008/03/06
                         *Emily, 20080613. Set low tx power for both MCS and legacy OFDM
                         */
index fa6dd37d85e6680d76aaa5909f9f9040d7930d7a..6e5662f7951c9ffd96c875173522eaec7e17e1ca 100644 (file)
@@ -13,8 +13,9 @@
 #ifndef RTL8225H
 #define RTL8225H
 
-#define RTL819X_TOTAL_RF_PATH 2 //for 8192U
-extern void PHY_SetRF8256Bandwidth(struct net_device *dev , HT_CHANNEL_WIDTH Bandwidth);
+#define RTL819X_TOTAL_RF_PATH 2 /* for 8192U */
+extern void PHY_SetRF8256Bandwidth(struct net_device *dev,
+                                  HT_CHANNEL_WIDTH Bandwidth);
 extern void PHY_RF8256_Config(struct net_device *dev);
 extern void phy_RF8256_Config_ParaFile(struct net_device *dev);
 extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel);
index c9d8c102cca39d085143572ed8b69a2a883abdec..6c2e438c9af498fbcc63e9d251d1903d7e8452ee 100644 (file)
@@ -40,8 +40,6 @@
 #define RTL8192U
 #define RTL819xU_MODULE_NAME "rtl819xU"
 /* HW security */
-#define FALSE 0
-#define TRUE 1
 #define MAX_KEY_LEN     61
 #define KEY_BUF_SIZE    5
 
index e031a253e2ae3dd5d40550b5f2f80e53afff1ca2..f6096568ffeaab142d41e5d7db8382bc6fba011c 100644 (file)
@@ -827,7 +827,6 @@ void rtl8192_rtx_disable(struct net_device *dev)
                netdev_warn(dev, "skb_queue not empty\n");
 
        skb_queue_purge(&priv->skb_queue);
-       return;
 }
 
 inline u16 ieeerate2rtlrate(int rate)
@@ -966,8 +965,6 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
        ret = rtl8192_tx(dev, skb);
 
        spin_unlock_irqrestore(&priv->tx_lock, flags);
-
-       return;
 }
 
 /* This is a rough attempt to TX a frame
@@ -2067,7 +2064,6 @@ static void rtl8192_refresh_supportrate(struct r8192_priv *priv)
                memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
        else
                memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
-       return;
 }
 
 static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev)
@@ -2078,10 +2074,10 @@ static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev)
        case RF_8225:
        case RF_8256:
        case RF_PSEUDO_11N:
-               ret = (WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B);
+               ret = WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B;
                break;
        case RF_8258:
-               ret = (WIRELESS_MODE_A|WIRELESS_MODE_N_5G);
+               ret = WIRELESS_MODE_A|WIRELESS_MODE_N_5G;
                break;
        default:
                ret = WIRELESS_MODE_B;
@@ -2143,7 +2139,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
        //for silent reset
        priv->IrpPendingCount = 1;
        priv->ResetProgress = RESET_TYPE_NORESET;
-       priv->bForcedSilentReset = 0;
+       priv->bForcedSilentReset = false;
        priv->bDisableNormalResetCheck = false;
        priv->force_reset = false;
 
@@ -2310,11 +2306,11 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
        }
 
        if (bLoad_From_EEPOM) {
-               tmpValue = eprom_read(dev, (EEPROM_VID>>1));
+               tmpValue = eprom_read(dev, EEPROM_VID>>1);
                priv->eeprom_vid = endian_swap(&tmpValue);
-               priv->eeprom_pid = eprom_read(dev, (EEPROM_PID>>1));
-               tmpValue = eprom_read(dev, (EEPROM_ChannelPlan>>1));
-               priv->eeprom_ChannelPlan = ((tmpValue&0xff00)>>8);
+               priv->eeprom_pid = eprom_read(dev, EEPROM_PID>>1);
+               tmpValue = eprom_read(dev, EEPROM_ChannelPlan>>1);
+               priv->eeprom_ChannelPlan = (tmpValue & 0xff00)>>8;
                priv->btxpowerdata_readfromEEPORM = true;
                priv->eeprom_CustomerID = eprom_read(dev, (EEPROM_Customer_ID>>1)) >>8;
        } else {
@@ -2397,7 +2393,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                        }
                } else if (priv->EEPROM_Def_Ver == 1) {
                        if (bLoad_From_EEPOM) {
-                               tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1>>1));
+                               tmpValue = eprom_read(dev,
+                                               EEPROM_TxPwIndex_CCK_V1 >> 1);
                                tmpValue = (tmpValue & 0xff00) >> 8;
                        } else {
                                tmpValue = 0x10;
@@ -2410,7 +2407,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                                tmpValue = 0x1010;
                        *((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue;
                        if (bLoad_From_EEPOM)
-                               tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1>>1));
+                               tmpValue = eprom_read(dev,
+                                       EEPROM_TxPwIndex_OFDM_24G_V1 >> 1);
                        else
                                tmpValue = 0x1010;
                        *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) = tmpValue;
@@ -2453,7 +2451,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
                // Antenna B gain offset to antenna A, bit0~3
                priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);
                // Antenna C gain offset to antenna A, bit4~7
-               priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);
+               priv->AntennaTxPwDiff[1] = (priv->EEPROMTxPowerDiff & 0xf0)>>4;
                // CrystalCap, bit12~15
                priv->CrystalCap = priv->EEPROMCrystalCap;
                // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
@@ -2505,7 +2503,6 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
        //we need init DIG RATR table here again.
 
        RT_TRACE(COMP_EPROM, "<===========%s()\n", __func__);
-       return;
 }
 
 static short rtl8192_get_channel_map(struct net_device *dev)
@@ -2547,9 +2544,8 @@ static short rtl8192_init(struct net_device *dev)
        rtl8192_read_eeprom_info(dev);
        rtl8192_get_channel_map(dev);
        init_hal_dm(dev);
-       init_timer(&priv->watch_dog_timer);
-       priv->watch_dog_timer.data = (unsigned long)dev;
-       priv->watch_dog_timer.function = watch_dog_timer_callback;
+       setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback,
+                   (unsigned long)dev);
        if (rtl8192_usb_initendpoints(dev) != 0) {
                DMESG("Endopoints initialization failed");
                return -ENOMEM;
@@ -2686,7 +2682,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
 
        read_nic_dword(dev, CPU_GEN, &dwRegRead);
        if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK)
-               dwRegRead = ((dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET);
+               dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET;
        else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK)
                dwRegRead |= CPU_CCK_LOOPBACK;
        else
@@ -2767,7 +2763,7 @@ static bool rtl8192_adapter_start(struct net_device *dev)
        //
 #ifdef TO_DO_LIST
        if (Adapter->ResetProgress == RESET_TYPE_NORESET) {
-               if (pMgntInfo->RegRfOff == TRUE) { /* User disable RF via registry. */
+               if (pMgntInfo->RegRfOff == true) { /* User disable RF via registry. */
                        RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
                        MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
                        // Those actions will be discard in MgntActSet_RF_State because of the same state
@@ -2814,15 +2810,15 @@ static bool rtl8192_adapter_start(struct net_device *dev)
                u8 tmpvalue;
                read_nic_byte(dev, 0x301, &tmpvalue);
                if (tmpvalue == 0x03) {
-                       priv->bDcut = TRUE;
+                       priv->bDcut = true;
                        RT_TRACE(COMP_POWER_TRACKING, "D-cut\n");
                } else {
-                       priv->bDcut = FALSE;
+                       priv->bDcut = false;
                        RT_TRACE(COMP_POWER_TRACKING, "C-cut\n");
                }
                dm_initialize_txpower_tracking(dev);
 
-               if (priv->bDcut == TRUE) {
+               if (priv->bDcut) {
                        u32 i, TempCCk;
                        u32 tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
                        for (i = 0; i < TxBBGainTableLength; i++) {
@@ -2874,11 +2870,11 @@ static bool HalTxCheckStuck819xUsb(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        u16             RegTxCounter;
-       bool            bStuck = FALSE;
+       bool            bStuck = false;
        read_nic_word(dev, 0x128, &RegTxCounter);
        RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, RegTxCounter, priv->TxCounter);
        if (priv->TxCounter == RegTxCounter)
-               bStuck = TRUE;
+               bStuck = true;
 
        priv->TxCounter = RegTxCounter;
 
@@ -2920,7 +2916,7 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 {
        u16     RegRxCounter;
        struct r8192_priv *priv = ieee80211_priv(dev);
-       bool bStuck = FALSE;
+       bool bStuck = false;
        static u8       rx_chk_cnt;
        read_nic_word(dev, 0x130, &RegRxCounter);
        RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, RegRxCounter, priv->RxCounter);
@@ -2951,7 +2947,7 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
        }
 
        if (priv->RxCounter == RegRxCounter)
-               bStuck = TRUE;
+               bStuck = true;
 
        priv->RxCounter = RegRxCounter;
 
@@ -2961,10 +2957,10 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
 static RESET_TYPE RxCheckStuck(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       bool        bRxCheck = FALSE;
+       bool        bRxCheck = false;
 
        if (priv->IrpPendingCount > 1)
-               bRxCheck = TRUE;
+               bRxCheck = true;
 
        if (bRxCheck) {
                if (HalRxCheckStuck819xUsb(dev)) {
@@ -3642,7 +3638,7 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate)
                                ret_rate = MGN_MCS15;
                                break;
                        case DESC90_RATEMCS32:
-                               ret_rate = (0x80|0x20);
+                               ret_rate = 0x80|0x20;
                                break;
 
                        default:
@@ -4038,7 +4034,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
 
                if (!priv->bCckHighPower) {
                        report = pcck_buf->cck_agc_rpt & 0xc0;
-                       report = report>>6;
+                       report >>= 6;
                        switch (report) {
                                //Fixed by Jacken from Bryant 2008-03-20
                                //Original value is -38 , -26 , -14 , -2
@@ -4058,7 +4054,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv,
                        }
                } else {
                        report = pcck_buf->cck_agc_rpt & 0x60;
-                       report = report>>5;
+                       report >>= 5;
                        switch (report) {
                        case 0x3:
                                rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1);
@@ -4208,7 +4204,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
        struct net_device *dev = info->dev;
        struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
        bool bpacket_match_bssid, bpacket_toself;
-       bool bPacketBeacon = FALSE, bToSelfBA = FALSE;
+       bool bPacketBeacon = false, bToSelfBA = false;
        static struct ieee80211_rx_stats  previous_stats;
        struct ieee80211_hdr_3addr *hdr;//by amy
        u16 fc, type;
@@ -4227,9 +4223,9 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
        praddr = hdr->addr1;
 
        /* Check if the received packet is acceptable. */
-       bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) &&
+       bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) &&
                               (eqMacAddr(priv->ieee80211->current_network.bssid,  (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3))
-                              && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV));
+                              && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV);
        bpacket_toself =  bpacket_match_bssid & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr));
 
        if (WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BEACON)
@@ -4474,13 +4470,10 @@ static void query_rxdesc_status(struct sk_buff *skb,
                skb_pull(skb, stats->RxBufShift + stats->RxDrvInfoSize);
        }
 
-       /* for debug 2008.5.29 */
-
-       //added by vivi, for MP, 20080108
-       stats->RxIs40MHzPacket = driver_info->BW;
-       if (stats->RxDrvInfoSize != 0)
+       if (driver_info) {
+               stats->RxIs40MHzPacket = driver_info->BW;
                TranslateRxSignalStuff819xUsb(skb, stats, driver_info);
-
+       }
 }
 
 static void rtl8192_rx_nomal(struct sk_buff *skb)
index ee6b936efef2e32702baf1e5bdeafb3b38283789..12dd19e1159bd4d9c1e7d0be971d6affebedef31 100644 (file)
@@ -36,11 +36,12 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
 
 /*------------------------Define global variable-----------------------------*/
 /* Debug variable ? */
-dig_t  dm_digtable;
+struct dig dm_digtable;
 /* Store current software write register content for MAC PHY. */
 u8             dm_shadow[16][256] = { {0} };
 /* For Dynamic Rx Path Selection by Signal Strength */
-DRxPathSel     DM_RxPathSelTable;
+struct dynamic_rx_path_sel DM_RxPathSelTable;
+
 /*------------------------Define global variable-----------------------------*/
 
 
@@ -502,7 +503,7 @@ static u8   CCKSwingTable_Ch14[CCK_Table_length][8] = {
 static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
-       bool                                            bHighpowerstate, viviflag = FALSE;
+       bool                                            bHighpowerstate, viviflag = false;
        DCMD_TXCMD_T                    tx_cmd;
        u8                                              powerlevelOFDM24G;
        int                                             i = 0, j = 0, k = 0;
@@ -558,13 +559,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                        /* check if the report value is right */
                        for (k = 0; k < 5; k++) {
                                if (tmp_report[k] <= 20) {
-                                       viviflag = TRUE;
+                                       viviflag = true;
                                        break;
                                }
                        }
-                       if (viviflag == TRUE) {
+                       if (viviflag == true) {
                                write_nic_byte(dev, 0x1ba, 0);
-                               viviflag = FALSE;
+                               viviflag = false;
                                RT_TRACE(COMP_POWER_TRACKING, "we filtered the data\n");
                                for (k = 0; k < 5; k++)
                                        tmp_report[k] = 0;
@@ -587,7 +588,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                                delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver;
 
                        if (delta <= E_FOR_TX_POWER_TRACK) {
-                               priv->ieee80211->bdynamic_txpower_enable = TRUE;
+                               priv->ieee80211->bdynamic_txpower_enable = true;
                                write_nic_byte(dev, 0x1ba, 0);
                                RT_TRACE(COMP_POWER_TRACKING, "tx power track is done\n");
                                RT_TRACE(COMP_POWER_TRACKING, "priv->rfa_txpowertrackingindex = %d\n", priv->rfa_txpowertrackingindex);
@@ -624,10 +625,10 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
 
                        if (priv->cck_present_attentuation > -1 && priv->cck_present_attentuation < 23) {
                                if (priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) {
-                                       priv->bcck_in_ch14 = TRUE;
+                                       priv->bcck_in_ch14 = true;
                                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
                                } else if (priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) {
-                                       priv->bcck_in_ch14 = FALSE;
+                                       priv->bcck_in_ch14 = false;
                                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
                                } else
                                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
@@ -638,7 +639,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                        RT_TRACE(COMP_POWER_TRACKING, "priv->cck_present_attentuation = %d\n", priv->cck_present_attentuation);
 
                        if (priv->cck_present_attentuation_difference <= -12 || priv->cck_present_attentuation_difference >= 24) {
-                               priv->ieee80211->bdynamic_txpower_enable = TRUE;
+                               priv->ieee80211->bdynamic_txpower_enable = true;
                                write_nic_byte(dev, 0x1ba, 0);
                                RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
                                return;
@@ -651,7 +652,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                        break;
                }
        }
-       priv->ieee80211->bdynamic_txpower_enable = TRUE;
+       priv->ieee80211->bdynamic_txpower_enable = true;
        write_nic_byte(dev, 0x1ba, 0);
 }
 
@@ -684,7 +685,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
                                break;
                        }
                }
-               priv->btxpower_trackingInit = TRUE;
+               priv->btxpower_trackingInit = true;
                /*pHalData->TXPowercount = 0;*/
                return;
        }
@@ -717,7 +718,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
                if (tmpCCK40Mindex >= CCK_Table_length)
                        tmpCCK40Mindex = CCK_Table_length-1;
        } else {
-               tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]);
+               tmpval = (u8)tmpRegA - priv->ThermalMeter[0];
 
                if (tmpval >= 6) /* higher temperature */
                        tmpOFDMindex = tmpCCK20Mindex = 0; /* max to +6dB */
@@ -734,10 +735,10 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
                tmpCCKindex = tmpCCK20Mindex;
 
        if (priv->ieee80211->current_network.channel == 14 && !priv->bcck_in_ch14) {
-               priv->bcck_in_ch14 = TRUE;
+               priv->bcck_in_ch14 = true;
                CCKSwingNeedUpdate = 1;
        } else if (priv->ieee80211->current_network.channel != 14 && priv->bcck_in_ch14) {
-               priv->bcck_in_ch14 = FALSE;
+               priv->bcck_in_ch14 = false;
                CCKSwingNeedUpdate = 1;
        }
 
@@ -765,7 +766,7 @@ void dm_txpower_trackingcallback(struct work_struct *work)
        struct r8192_priv *priv = container_of(dwork, struct r8192_priv, txpower_tracking_wq);
        struct net_device *dev = priv->ieee80211->dev;
 
-       if (priv->bDcut == TRUE)
+       if (priv->bDcut == true)
                dm_TXPowerTrackingCallback_TSSI(dev);
        else
                dm_TXPowerTrackingCallback_ThermalMeter(dev);
@@ -1273,9 +1274,9 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00;
        priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00;
 
-       priv->btxpower_tracking = TRUE;
+       priv->btxpower_tracking = true;
        priv->txpower_count       = 0;
-       priv->btxpower_trackingInit = FALSE;
+       priv->btxpower_trackingInit = false;
 
 }
 
@@ -1289,18 +1290,18 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev)
         * 3-wire by driver causes RF to go into a wrong state.
         */
        if (priv->ieee80211->FwRWRF)
-               priv->btxpower_tracking = TRUE;
+               priv->btxpower_tracking = true;
        else
-               priv->btxpower_tracking = FALSE;
+               priv->btxpower_tracking = false;
        priv->txpower_count       = 0;
-       priv->btxpower_trackingInit = FALSE;
+       priv->btxpower_trackingInit = false;
 }
 
 void dm_initialize_txpower_tracking(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 
-       if (priv->bDcut == TRUE)
+       if (priv->bDcut == true)
                dm_InitializeTXPowerTracking_TSSI(dev);
        else
                dm_InitializeTXPowerTracking_ThermalMeter(dev);
@@ -1356,7 +1357,7 @@ static void dm_check_txpower_tracking(struct net_device *dev)
 #ifdef RTL8190P
        dm_CheckTXPowerTracking_TSSI(dev);
 #else
-       if (priv->bDcut == TRUE)
+       if (priv->bDcut == true)
                dm_CheckTXPowerTracking_TSSI(dev);
        else
                dm_CheckTXPowerTracking_ThermalMeter(dev);
@@ -1466,7 +1467,7 @@ void dm_cck_txpower_adjust(struct net_device *dev, bool binch14)
 {      /*  dm_CCKTxPowerAdjust */
        struct r8192_priv *priv = ieee80211_priv(dev);
 
-       if (priv->bDcut == TRUE)
+       if (priv->bDcut == true)
                dm_CCKTxPowerAdjust_TSSI(dev, binch14);
        else
                dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14);
@@ -1628,8 +1629,8 @@ void dm_change_dynamic_initgain_thresh(struct net_device *dev, u32 dm_type,
                dm_digtable.rssi_low_thresh = dm_value;
        } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) {
                dm_digtable.rssi_high_power_highthresh = dm_value;
-       } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH) {
-               dm_digtable.rssi_high_power_highthresh = dm_value;
+       } else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_LOW) {
+               dm_digtable.rssi_high_power_lowthresh = dm_value;
        } else if (dm_type == DIG_TYPE_ENABLE) {
                dm_digtable.dig_state           = DM_STA_DIG_MAX;
                dm_digtable.dig_enable_flag     = true;
@@ -2270,10 +2271,10 @@ static void dm_check_edca_turbo(
                                /*  For Each time updating EDCA parameter, reset EDCA turbo mode status. */
                                dm_init_edca_turbo(dev);
                                u1bAIFS = qos_parameters->aifs[0] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime;
-                               u4bAcParam = ((((u32)(qos_parameters->tx_op_limit[0])) << AC_PARAM_TXOP_LIMIT_OFFSET)|
+                               u4bAcParam = (((u32)(qos_parameters->tx_op_limit[0])) << AC_PARAM_TXOP_LIMIT_OFFSET)|
                                        (((u32)(qos_parameters->cw_max[0])) << AC_PARAM_ECW_MAX_OFFSET)|
                                        (((u32)(qos_parameters->cw_min[0])) << AC_PARAM_ECW_MIN_OFFSET)|
-                                       ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET));
+                                       ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET);
                                /*write_nic_dword(dev, WDCAPARA_ADD[i], u4bAcParam);*/
                                write_nic_dword(dev, EDCAPARA_BE,  u4bAcParam);
 
@@ -2314,7 +2315,7 @@ static void dm_init_ctstoself(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv((struct net_device *)dev);
 
-       priv->ieee80211->bCTSToSelfEnable = TRUE;
+       priv->ieee80211->bCTSToSelfEnable = true;
        priv->ieee80211->CTSToSelfTH = CTSToSelfTHVal;
 }
 
@@ -2327,7 +2328,7 @@ static void dm_ctstoself(struct net_device *dev)
        unsigned long                                           curTxOkCnt = 0;
        unsigned long                                           curRxOkCnt = 0;
 
-       if (priv->ieee80211->bCTSToSelfEnable != TRUE) {
+       if (priv->ieee80211->bCTSToSelfEnable != true) {
                pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF;
                return;
        }
@@ -2419,9 +2420,9 @@ void dm_rf_pathcheck_workitemcallback(struct work_struct *work)
        /* Check Bit 0-3, it means if RF A-D is enabled. */
        for (i = 0; i < RF90_PATH_MAX; i++) {
                if (rfpath & (0x01<<i))
-                       priv->brfpath_rxenable[i] = 1;
+                       priv->brfpath_rxenable[i] = true;
                else
-                       priv->brfpath_rxenable[i] = 0;
+                       priv->brfpath_rxenable[i] = false;
        }
        if (!DM_RxPathSelTable.Enable)
                return;
@@ -2681,10 +2682,8 @@ static void dm_init_fsync(struct net_device *dev)
        priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
        priv->ieee80211->fsync_state = Default_Fsync;
        priv->framesyncMonitor = 1;     /* current default 0xc38 monitor on */
-
-       init_timer(&priv->fsync_timer);
-       priv->fsync_timer.data = (unsigned long)dev;
-       priv->fsync_timer.function = dm_fsync_timer_callback;
+       setup_timer(&priv->fsync_timer, dm_fsync_timer_callback,
+                   (unsigned long)dev);
 }
 
 static void dm_deInit_fsync(struct net_device *dev)
index 3008f91ad4cf11d352fc8e8b685c42a78e40550a..6cd32eb440852e513b1cc2bc60b128447fb4612d 100644 (file)
@@ -67,7 +67,7 @@
 
 /*------------------------------Define structure----------------------------*/
 /* 2007/10/04 MH Define upper and lower threshold of DIG enable or disable. */
-typedef struct _dynamic_initial_gain_threshold_ {
+struct dig {
        u8              dig_enable_flag;
        u8              dig_algorithm;
        u8              dbg_mode;
@@ -98,7 +98,7 @@ typedef struct _dynamic_initial_gain_threshold_ {
        bool            initialgain_lowerbound_state;
 
        long            rssi_val;
-} dig_t;
+};
 
 typedef enum tag_dynamic_init_gain_state_definition {
        DM_STA_DIG_OFF = 0,
@@ -163,7 +163,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_ {
+struct dynamic_rx_path_sel {
        u8              Enable;
        u8              DbgMode;
        u8              cck_method;
@@ -177,7 +177,7 @@ typedef struct _Dynamic_Rx_Path_Selection_ {
        u8              rf_rssi[4];
        u8              rf_enable_rssi_th[4];
        long            cck_pwdb_sta[4];
-} DRxPathSel;
+};
 
 typedef enum tag_CCK_Rx_Path_Method_Definition {
        CCK_Rx_Version_1 = 0,
@@ -200,9 +200,9 @@ typedef struct tag_Tx_Config_Cmd_Format {
 
 
 /*------------------------Export global variable----------------------------*/
-extern dig_t dm_digtable;
+extern struct dig dm_digtable;
 extern u8 dm_shadow[16][256];
-extern DRxPathSel DM_RxPathSelTable;
+extern struct dynamic_rx_path_sel DM_RxPathSelTable;
 /*------------------------Export global variable----------------------------*/
 
 
index 361d2d0c3df167284d168d8b22ff040f08061b4e..83597051a4485b5f541052cc80abea7981805b79 100644 (file)
@@ -139,7 +139,7 @@ static int r8192_wx_force_reset(struct net_device *dev,
 
        down(&priv->wx_sem);
 
-       printk("%s(): force reset ! extra is %d\n", __func__, *extra);
+       netdev_dbg(dev, "%s(): force reset ! extra is %d\n", __func__, *extra);
        priv->force_reset = *extra;
        up(&priv->wx_sem);
        return 0;
@@ -335,7 +335,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
        if (!priv->up)
                return -ENETDOWN;
 
-       if (priv->ieee80211->LinkDetectInfo.bBusyTraffic == true)
+       if (priv->ieee80211->LinkDetectInfo.bBusyTraffic)
                return -EAGAIN;
        if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                struct iw_scan_req *req = (struct iw_scan_req *)b;
index ae7a617740a31ccc412924cc793d076dceb980a4..d6a2d975653166b8c07d0d7c5aa53abc6393054f 100644 (file)
@@ -1,20 +1,21 @@
 /*
-       This is part of rtl8180 OpenSource driver - v 0.3
-       Copyright (C) Andrea Merello 2004  <andrea.merello@gmail.com>
-       Released under the terms of GPL (General Public Licence)
+ * This is part of rtl8180 OpenSource driver - v 0.3
+ * Copyright (C) Andrea Merello 2004  <andrea.merello@gmail.com>
+ * Released under the terms of GPL (General Public Licence)
+ *
+ * Parts of this driver are based on the GPL part of the official realtek driver
+ * Parts of this driver are based on the rtl8180 driver skeleton from Patric
+ * Schenke & Andres Salomon
+ * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
+ *
+ * We want to thank the Authors of such projects and the Ndiswrapper project
+ * Authors.
+ */
 
-       Parts of this driver are based on the GPL part of the official realtek driver
-       Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
-       Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
-
-       We want to thank the Authors of such projects and the Ndiswrapper project Authors.
-*/
-
-/* this file (will) contains wireless extension handlers*/
+/* this file (will) contains wireless extension handlers */
 
 #ifndef R8180_WX_H
 #define R8180_WX_H
-//#include <linux/wireless.h>
 
 extern struct iw_handler_def r8192_wx_handlers_def;
 /* Enable  the rtl819x_core.c to share this function, david 2008.9.22 */
index c230be290ab61a9f4e19f452cc4004e90a99b355..d27b1e24ca4a1829141179bf7f2e617fa2eba79f 100644 (file)
@@ -37,7 +37,6 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
        bool                rt_status = true;
        u16                 frag_threshold;
        u16                 frag_length, frag_offset = 0;
-       //u16               total_size;
        int                 i;
 
        rt_firmware         *pfirmware = priv->pFirmware;
@@ -48,7 +47,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
        u8                  index;
 
        firmware_init_param(dev);
-       //Fragmentation might be required
+       /* Fragmentation might be required */
        frag_threshold = pfirmware->cmdpacket_frag_thresold;
        do {
                if ((buffer_len - frag_offset) > frag_threshold) {
@@ -107,19 +106,20 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
 
 }
 
-//-----------------------------------------------------------------------------
-// Procedure:    Check whether main code is download OK. If OK, turn on CPU
-//
-// Description:   CPU register locates in different page against general register.
-//                         Switch to CPU register in the begin and switch back before return
-//
-//
-// Arguments:   The pointer of the adapter
-//
-// Returns:
-//        NDIS_STATUS_FAILURE - the following initialization process should be terminated
-//        NDIS_STATUS_SUCCESS - if firmware initialization process success
-//-----------------------------------------------------------------------------
+/*
+ * Procedure:  Check whether main code is download OK. If OK, turn on CPU
+ *
+ * Description:        CPU register locates in different page against general register.
+ *         Switch to CPU register in the begin and switch back before return
+ *
+ *
+ * Arguments:   The pointer of the adapter
+ *
+ * Returns:
+ *        NDIS_STATUS_FAILURE - the following initialization process should
+ *                             be terminated
+ *        NDIS_STATUS_SUCCESS - if firmware initialization process success
+ */
 static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
 {
        bool            rt_status = true;
@@ -164,7 +164,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
 
 CPUCheckMainCodeOKAndTurnOnCPU_Fail:
        RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
-       rt_status = FALSE;
+       rt_status = false;
        return rt_status;
 }
 
@@ -201,7 +201,7 @@ CPUCheckFirmwareReady_Fail:
 bool init_firmware(struct net_device *dev)
 {
        struct r8192_priv       *priv = ieee80211_priv(dev);
-       bool                    rt_status = TRUE;
+       bool                    rt_status = true;
 
        u32                     file_length = 0;
        u8                      *mapped_file = NULL;
@@ -222,7 +222,7 @@ bool init_firmware(struct net_device *dev)
                /* it is called by reset */
                rst_opt = OPT_SYSTEM_RESET;
                starting_state = FW_INIT_STEP0_BOOT;
-               // TODO: system reset
+               /* TODO: system reset */
 
        } else if (pfirmware->firmware_status == FW_STATUS_5_READY) {
                /* it is called by Initialize */
@@ -281,7 +281,7 @@ bool init_firmware(struct net_device *dev)
                if (rst_opt == OPT_SYSTEM_RESET)
                        release_firmware(fw_entry);
 
-               if (rt_status != TRUE)
+               if (!rt_status)
                        goto download_firmware_fail;
 
                switch (init_step) {
@@ -291,7 +291,7 @@ bool init_firmware(struct net_device *dev)
                         * will set polling bit when firmware code is also configured
                         */
                        pfirmware->firmware_status = FW_STATUS_1_MOVE_BOOT_CODE;
-                       //mdelay(1000);
+                       /* mdelay(1000); */
                        /*
                         * To initialize IMEM, CPU move code  from 0x80000080,
                         * hence, we send 0x80 byte packet
@@ -304,7 +304,7 @@ bool init_firmware(struct net_device *dev)
 
                        /* Check Put Code OK and Turn On CPU */
                        rt_status = CPUcheck_maincodeok_turnonCPU(dev);
-                       if (rt_status != TRUE) {
+                       if (!rt_status) {
                                RT_TRACE(COMP_ERR, "CPUcheck_maincodeok_turnonCPU fail!\n");
                                goto download_firmware_fail;
                        }
@@ -318,7 +318,7 @@ bool init_firmware(struct net_device *dev)
                        mdelay(1);
 
                        rt_status = CPUcheck_firmware_ready(dev);
-                       if (rt_status != TRUE) {
+                       if (!rt_status) {
                                RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status);
                                goto download_firmware_fail;
                        }
@@ -330,13 +330,11 @@ bool init_firmware(struct net_device *dev)
        }
 
        RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n");
-       //assert(pfirmware->firmware_status == FW_STATUS_5_READY, ("Firmware Download Fail\n"));
-
        return rt_status;
 
 download_firmware_fail:
        RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
-       rt_status = FALSE;
+       rt_status = false;
        return rt_status;
 
 }
index 058960251bacdd72a69b55df6a15a78de4d6c738..e5dbaca9e518e9cd8ca5ede123cbaa294bfb6e6e 100644 (file)
@@ -106,10 +106,10 @@ void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, u32 bitmask,
 /******************************************************************************
  * function:  This function reads specific bits from BB register
  * input:     net_device       *dev
- *            u32              reg_addr   //target addr to be readback
- *            u32              bitmask    //taget bit pos to be readback
+ *            u32              reg_addr   //target addr to be readback
+ *            u32              bitmask    //taget bit pos to be readback
  * output:    none
- * return:    u32              data       //the readback register value
+ * return:    u32              data       //the readback register value
  * notice:
  ******************************************************************************/
 u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask)
@@ -352,16 +352,14 @@ u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath,
                return 0;
        if (priv->Rf_Mode == RF_OP_By_FW) {
                reg = phy_FwRFSerialRead(dev, eRFPath, reg_addr);
-               bitshift =  rtl8192_CalculateBitShift(bitmask);
-               reg = (reg & bitmask) >> bitshift;
                udelay(200);
-               return reg;
        } else {
                reg = rtl8192_phy_RFSerialRead(dev, eRFPath, reg_addr);
-               bitshift =  rtl8192_CalculateBitShift(bitmask);
-               reg = (reg & bitmask) >> bitshift;
-               return reg;
        }
+       bitshift =  rtl8192_CalculateBitShift(bitmask);
+       reg = (reg & bitmask) >> bitshift;
+       return reg;
+
 }
 
 /******************************************************************************
@@ -478,7 +476,7 @@ static void phy_FwRFSerialWrite(struct net_device *dev,
 /******************************************************************************
  * function:  This function reads BB parameters from header file we generate,
  *            and do register read/write
- * input:     net_device       *dev
+ * input:     net_device       *dev
  * output:    none
  * return:    none
  * notice:    BB parameters may change all the time, so please make
@@ -825,8 +823,8 @@ static void rtl8192_BB_Config_ParaFile(struct net_device *dev)
        write_nic_byte_E(dev, 0x5e, 0x00);
        if (priv->card_8192_version == (u8)VERSION_819xU_A) {
                /* Antenna gain offset from B/C/D to A */
-               reg_u32 = (priv->AntennaTxPwDiff[1]<<4 |
-                          priv->AntennaTxPwDiff[0]);
+               reg_u32 = priv->AntennaTxPwDiff[1]<<4 |
+                          priv->AntennaTxPwDiff[0];
                rtl8192_setBBreg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC),
                                 reg_u32);
 
@@ -900,7 +898,7 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
        read_nic_byte(dev, rOFDM0_RxDetector3, &priv->framesync);
        read_nic_byte(dev, rOFDM0_RxDetector2, &tmp);
        priv->framesyncC34 = tmp;
-       RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x \n",
+       RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n",
                rOFDM0_RxDetector3, priv->framesync);
 
        /* Read SIFS (save the value read fome MACPHY_REG.txt) */
@@ -1101,7 +1099,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev,
        if (eRFPowerState == priv->ieee80211->eRFPowerState)
                return false;
 
-       if (priv->SetRFPowerStateInProgress == true)
+       if (priv->SetRFPowerStateInProgress)
                return false;
 
        priv->SetRFPowerStateInProgress = true;
@@ -1187,7 +1185,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev,
                                /* Turn on RF we are still linked, which might
                                   happen when we quickly turn off and on HW RF.
                                 */
-                               if (pMgntInfo->bMediaConnect == TRUE)
+                               if (pMgntInfo->bMediaConnect)
                                        Adapter->HalFunc.LedControlHandler(Adapter, LED_CTL_LINK);
                                else
                                        /* Turn off LED if RF is not ON. */
@@ -1344,7 +1342,6 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
        default:
                RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip);
                return true;
-               break;
        }
 
 
@@ -1365,11 +1362,10 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
                        if ((*stage) == 2) {
                                (*delay) = CurrentCmd->msDelay;
                                return true;
-                       } else {
-                               (*stage)++;
-                               (*step) = 0;
-                               continue;
                        }
+                       (*stage)++;
+                       (*step) = 0;
+                       continue;
                }
 
                switch (CurrentCmd->CmdID) {
@@ -1579,10 +1575,10 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
                         priv->cck_present_attentuation);
 
                if (priv->chan == 14 && !priv->bcck_in_ch14) {
-                       priv->bcck_in_ch14 = TRUE;
+                       priv->bcck_in_ch14 = true;
                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
                } else if (priv->chan != 14 && priv->bcck_in_ch14) {
-                       priv->bcck_in_ch14 = FALSE;
+                       priv->bcck_in_ch14 = false;
                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
                } else {
                        dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
@@ -1746,13 +1742,13 @@ void InitialGainOperateWorkItemCallBack(struct work_struct *work)
                RT_TRACE(COMP_SCAN, "Scan InitialGainBackup 0xa0a is %x\n",
                         priv->initgain_backup.cca);
 
-               RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x \n",
+               RT_TRACE(COMP_SCAN, "Write scan initial gain = 0x%x\n",
                         initial_gain);
                write_nic_byte(dev, rOFDM0_XAAGCCore1, initial_gain);
                write_nic_byte(dev, rOFDM0_XBAGCCore1, initial_gain);
                write_nic_byte(dev, rOFDM0_XCAGCCore1, initial_gain);
                write_nic_byte(dev, rOFDM0_XDAGCCore1, initial_gain);
-               RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x \n",
+               RT_TRACE(COMP_SCAN, "Write scan 0xa0a = 0x%x\n",
                         POWER_DETECTION_TH);
                write_nic_byte(dev, 0xa0a, POWER_DETECTION_TH);
                break;
@@ -1793,7 +1789,7 @@ void InitialGainOperateWorkItemCallBack(struct work_struct *work)
                        rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);
                break;
        default:
-               RT_TRACE(COMP_SCAN, "Unknown IG Operation. \n");
+               RT_TRACE(COMP_SCAN, "Unknown IG Operation.\n");
                break;
        }
 }
index 324da34383eaac6a6a5b38a7d83206d9556559a8..0a1c6313e78156b708e570591fca431b0981f33e 100644 (file)
@@ -92,7 +92,7 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw)
 
 static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv)
 {
-       struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
+       struct dvobj_priv *pdvobj = &padapter->dvobjpriv;
        struct registry_priv *pregpriv = &padapter->registrypriv;
 
        memset(pfwpriv, 0, sizeof(struct fw_priv));
index 354bd03e700f7b8d2ce3c979b165e1296e76b0f2..8c5a475f05e7a546598071a84be324182af273c2 100644 (file)
 #include "drv_types.h"
 #include "mlme_osdep.h"
 
-static void sitesurvey_ctrl_handler(void *FunctionContext)
+static void sitesurvey_ctrl_handler(unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_sitesurvey_ctrl_handler(adapter);
-       _set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
-                  3000);
+       mod_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
+                 jiffies + msecs_to_jiffies(3000));
 }
 
-static void join_timeout_handler (void *FunctionContext)
+static void join_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_join_timeout_handler(adapter);
 }
 
-static void _scan_timeout_handler (void *FunctionContext)
+static void _scan_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        r8712_scan_timeout_handler(adapter);
 }
 
-static void dhcp_timeout_handler (void *FunctionContext)
+static void dhcp_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_dhcp_timeout_handler(adapter);
 }
 
-static void wdg_timeout_handler (void *FunctionContext)
+static void wdg_timeout_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _r8712_wdg_timeout_handler(adapter);
 
-       _set_timer(&adapter->mlmepriv.wdg_timer, 2000);
+       mod_timer(&adapter->mlmepriv.wdg_timer,
+                 jiffies + msecs_to_jiffies(2000));
 }
 
 void r8712_init_mlme_timer(struct _adapter *padapter)
 {
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
-                   join_timeout_handler, (pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
-                   padapter->pnetdev, sitesurvey_ctrl_handler,
-                   (u8 *)(pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
-                   _scan_timeout_handler, (pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
-                   dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
-       _init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
-                   wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
+       setup_timer(&pmlmepriv->assoc_timer, join_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer,
+                   sitesurvey_ctrl_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->scan_to_timer, _scan_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->dhcp_timer, dhcp_timeout_handler,
+                   (unsigned long)padapter);
+       setup_timer(&pmlmepriv->wdg_timer, wdg_timeout_handler,
+                   (unsigned long)padapter);
 }
 
 void r8712_os_indicate_connect(struct _adapter *adapter)
@@ -117,9 +118,9 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter)
                                           btkip_countermeasure;
                memset((unsigned char *)&adapter->securitypriv, 0,
                         sizeof(struct security_priv));
-               _init_timer(&(adapter->securitypriv.tkip_timer),
-                           adapter->pnetdev, r8712_use_tkipkey_handler,
-                           adapter);
+               setup_timer(&adapter->securitypriv.tkip_timer,
+                           r8712_use_tkipkey_handler,
+                           (unsigned long)adapter);
                /* Restore the PMK information to securitypriv structure
                 * for the following connection. */
                memcpy(&adapter->securitypriv.PMKIDList[0],
index 13debb59ad97ac2f721b768c446fd732b1ab7790..78815b6170c784fe26dcc947cc3871b1c17b9520 100644 (file)
@@ -255,20 +255,20 @@ void r8712_stop_drv_threads(struct _adapter *padapter)
 
 static void start_drv_timers(struct _adapter *padapter)
 {
-       _set_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
-                  5000);
-       _set_timer(&padapter->mlmepriv.wdg_timer, 2000);
+       mod_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
+                 jiffies + msecs_to_jiffies(5000));
+       mod_timer(&padapter->mlmepriv.wdg_timer,
+                 jiffies + msecs_to_jiffies(2000));
 }
 
 void r8712_stop_drv_timers(struct _adapter *padapter)
 {
-       _cancel_timer_ex(&padapter->mlmepriv.assoc_timer);
-       _cancel_timer_ex(&padapter->securitypriv.tkip_timer);
-       _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer);
-       _cancel_timer_ex(&padapter->mlmepriv.dhcp_timer);
-       _cancel_timer_ex(&padapter->mlmepriv.wdg_timer);
-       _cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl.
-                        sitesurvey_ctrl_timer);
+       del_timer_sync(&padapter->mlmepriv.assoc_timer);
+       del_timer_sync(&padapter->securitypriv.tkip_timer);
+       del_timer_sync(&padapter->mlmepriv.scan_to_timer);
+       del_timer_sync(&padapter->mlmepriv.dhcp_timer);
+       del_timer_sync(&padapter->mlmepriv.wdg_timer);
+       del_timer_sync(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer);
 }
 
 static u8 init_default_value(struct _adapter *padapter)
@@ -322,8 +322,8 @@ u8 r8712_init_drv_sw(struct _adapter *padapter)
        _r8712_init_recv_priv(&padapter->recvpriv, padapter);
        memset((unsigned char *)&padapter->securitypriv, 0,
               sizeof(struct security_priv));
-       _init_timer(&(padapter->securitypriv.tkip_timer), padapter->pnetdev,
-                   r8712_use_tkipkey_handler, padapter);
+       setup_timer(&padapter->securitypriv.tkip_timer,
+                   r8712_use_tkipkey_handler, (unsigned long)padapter);
        _r8712_init_sta_priv(&padapter->stapriv);
        padapter->stapriv.padapter = padapter;
        r8712_init_bcmc_stainfo(padapter);
index 36348d900d34b935ee0c789db0ad9f9d376e5589..0a7f58c59df521aab10911520a39810be8ff38b2 100644 (file)
@@ -60,26 +60,6 @@ struct       __queue {
 #define LIST_CONTAINOR(ptr, type, member) \
        ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
 
-static inline void _init_timer(struct timer_list *ptimer,
-                              struct  net_device *padapter,
-                              void *pfunc, void *cntx)
-{
-       ptimer->function = pfunc;
-       ptimer->data = (addr_t)cntx;
-       init_timer(ptimer);
-}
-
-static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
-{
-       mod_timer(ptimer, (jiffies+msecs_to_jiffies(delay_time)));
-}
-
-static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
-{
-       del_timer(ptimer);
-       *bcancelled = true; /*true ==1; false==0*/
-}
-
 #ifndef BIT
        #define BIT(x)  (1 << (x))
 #endif
@@ -106,11 +86,6 @@ static inline void sleep_schedulable(int ms)
        schedule_timeout(delta);
 }
 
-static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
-{
-       return del_timer(ptimer);
-}
-
 static inline void flush_signals_thread(void)
 {
        if (signal_pending(current))
index 409c8c897256ad4dd16494f0cb9bfac3f3c4ab91..799a0f9a5b2d27a089bfc5a87f3d0bbb99229ddd 100644 (file)
@@ -96,7 +96,7 @@ void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
        else
                ev.flags |= IW_MICFAILURE_PAIRWISE;
        ev.src_addr.sa_family = ARPHRD_ETHER;
-       memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
+       ether_addr_copy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0]);
        memset(&wrqu, 0x00, sizeof(wrqu));
        wrqu.data.length = sizeof(ev);
        wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
@@ -137,18 +137,17 @@ _recv_indicatepkt_drop:
         precvpriv->rx_drop++;
 }
 
-static void _r8712_reordering_ctrl_timeout_handler (void *FunctionContext)
+static void _r8712_reordering_ctrl_timeout_handler (unsigned long data)
 {
        struct recv_reorder_ctrl *preorder_ctrl =
-                        (struct recv_reorder_ctrl *)FunctionContext;
+                        (struct recv_reorder_ctrl *)data;
 
        r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
 }
 
 void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
 {
-       struct _adapter *padapter = preorder_ctrl->padapter;
-
-       _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev,
-                   _r8712_reordering_ctrl_timeout_handler, preorder_ctrl);
+       setup_timer(&preorder_ctrl->reordering_ctrl_timer,
+                    _r8712_reordering_ctrl_timeout_handler,
+                    (unsigned long)preorder_ctrl);
 }
index 62e53cc1d8b9406ed1ffe4f103d88d92e51ae2b8..007f0a3ab13d5729739d17048e78ffc4b1ed3fdb 100644 (file)
@@ -95,7 +95,7 @@ static void query_fw_rx_phy_status(struct _adapter *padapter)
                        val32 = r8712_read32(padapter, IOCMD_DATA_REG);
                else /* time out */
                        val32 = 0;
-               val32 = val32 >> 4;
+               val32 >>= 4;
                padapter->recvpriv.fw_rssi =
                         (u8)r8712_signal_scale_mapping(val32);
        }
index 56e8add30a2061545106f68e71aadffa420f38dd..f1d47a0676c3e3ba29ea974754c77e8a32a3f950 100644 (file)
@@ -97,7 +97,8 @@ static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed,
        pLed->bLedBlinkInProgress = false;
        pLed->BlinkTimes = 0;
        pLed->BlinkingLedState = LED_UNKNOWN;
-       _init_timer(&(pLed->BlinkTimer), nic, BlinkTimerCallback, pLed);
+       setup_timer(&pLed->BlinkTimer, BlinkTimerCallback,
+                   (unsigned long)pLed);
        INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback);
 }
 
@@ -107,7 +108,7 @@ static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed,
  */
 static void DeInitLed871x(struct LED_871x *pLed)
 {
-       _cancel_timer_ex(&(pLed->BlinkTimer));
+       del_timer_sync(&pLed->BlinkTimer);
        /* We should reset bLedBlinkInProgress if we cancel
         * the LedControlTimer, */
        pLed->bLedBlinkInProgress = false;
@@ -258,21 +259,21 @@ static void SwLedBlink(struct LED_871x *pLed)
                /* Schedule a timer to toggle LED state. */
                switch (pLed->CurrLedState) {
                case LED_BLINK_NORMAL:
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NORMAL_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                        break;
                case LED_BLINK_SLOWLY:
                case LED_BLINK_StartToBlink:
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SLOWLY_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                        break;
                case LED_BLINK_WPS:
-                       _set_timer(&(pLed->BlinkTimer),
-                                       LED_BLINK_LONG_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LONG_INTERVAL));
                        break;
                default:
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SLOWLY_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                        break;
                }
        }
@@ -315,16 +316,16 @@ static void SwLedBlink1(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_BLINK_NORMAL:
                if (pLed->bLedOn)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                break;
        case LED_SCAN_BLINK:
                pLed->BlinkTimes--;
@@ -338,8 +339,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = LED_OFF;
                                else
                                        pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                        } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                                pLed->bLedNoLinkBlinkInProgress = true;
                                pLed->CurrLedState = LED_BLINK_SLOWLY;
@@ -347,8 +348,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = LED_OFF;
                                else
                                        pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                        }
                        pLed->bLedScanBlinkInProgress = false;
                } else {
@@ -356,8 +357,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_TXRX_BLINK:
@@ -372,8 +373,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = LED_OFF;
                                else
                                        pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                        } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                                pLed->bLedNoLinkBlinkInProgress = true;
                                pLed->CurrLedState = LED_BLINK_SLOWLY;
@@ -381,8 +382,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                        pLed->BlinkingLedState = LED_OFF;
                                else
                                        pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                        }
                        pLed->BlinkTimes = 0;
                        pLed->bLedBlinkInProgress = false;
@@ -391,8 +392,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_WPS:
@@ -400,14 +401,14 @@ static void SwLedBlink1(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_SCAN_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
        case LED_BLINK_WPS_STOP:        /* WPS success */
                if (pLed->BlinkingLedState == LED_ON) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
                        bStopBlinking = false;
                } else
                        bStopBlinking = true;
@@ -418,8 +419,8 @@ static void SwLedBlink1(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                }
                pLed->bLedWPSBlinkInProgress = false;
                break;
@@ -460,8 +461,8 @@ static void SwLedBlink2(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_TXRX_BLINK:
@@ -484,8 +485,8 @@ static void SwLedBlink2(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        default:
@@ -528,8 +529,8 @@ static void SwLedBlink3(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_TXRX_BLINK:
@@ -554,8 +555,8 @@ static void SwLedBlink3(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_WPS:
@@ -563,14 +564,14 @@ static void SwLedBlink3(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_SCAN_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
        case LED_BLINK_WPS_STOP:        /*WPS success*/
                if (pLed->BlinkingLedState == LED_ON) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
                        bStopBlinking = false;
                } else
                        bStopBlinking = true;
@@ -610,18 +611,18 @@ static void SwLedBlink4(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_BLINK_StartToBlink:
                if (pLed->bLedOn) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SLOWLY_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                } else {
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NORMAL_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                }
                break;
        case LED_SCAN_BLINK:
@@ -635,16 +636,16 @@ static void SwLedBlink4(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                        pLed->bLedScanBlinkInProgress = false;
                } else {
                        if (pLed->bLedOn)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_TXRX_BLINK:
@@ -658,27 +659,27 @@ static void SwLedBlink4(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                        pLed->bLedBlinkInProgress = false;
                } else {
                         if (pLed->bLedOn)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_WPS:
                if (pLed->bLedOn) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SLOWLY_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                } else {
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NORMAL_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                }
                break;
        case LED_BLINK_WPS_STOP:        /*WPS authentication fail*/
@@ -686,7 +687,8 @@ static void SwLedBlink4(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                break;
        case LED_BLINK_WPS_STOP_OVERLAP:        /*WPS session overlap */
                pLed->BlinkTimes--;
@@ -699,15 +701,15 @@ static void SwLedBlink4(struct LED_871x *pLed)
                if (bStopBlinking) {
                        pLed->BlinkTimes = 10;
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                } else {
                        if (pLed->bLedOn)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NORMAL_INTERVAL);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                }
                break;
        default:
@@ -734,16 +736,16 @@ static void SwLedBlink5(struct LED_871x *pLed)
                        pLed->CurrLedState = LED_ON;
                        pLed->BlinkingLedState = LED_ON;
                        if (!pLed->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_FASTER_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                        pLed->bLedScanBlinkInProgress = false;
                } else {
                        if (pLed->bLedOn)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_TXRX_BLINK:
@@ -754,16 +756,16 @@ static void SwLedBlink5(struct LED_871x *pLed)
                        pLed->CurrLedState = LED_ON;
                        pLed->BlinkingLedState = LED_ON;
                        if (!pLed->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_FASTER_INTERVAL_ALPHA);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                        pLed->bLedBlinkInProgress = false;
                } else {
                         if (pLed->bLedOn)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        default:
@@ -797,8 +799,8 @@ static void SwLedBlink6(struct LED_871x *pLed)
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_BLINK_WPS:
@@ -806,7 +808,8 @@ static void SwLedBlink6(struct LED_871x *pLed)
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                break;
 
        default:
@@ -895,11 +898,11 @@ static void SwLedControlMode1(struct _adapter *padapter,
                          IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedNoLinkBlinkInProgress = true;
@@ -908,8 +911,8 @@ static void SwLedControlMode1(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_LINK:
@@ -918,11 +921,11 @@ static void SwLedControlMode1(struct _adapter *padapter,
                            IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedLinkBlinkInProgress = true;
@@ -931,8 +934,8 @@ static void SwLedControlMode1(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_SITE_SURVEY:
@@ -943,15 +946,15 @@ static void SwLedControlMode1(struct _adapter *padapter,
                        if (IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                 pLed->bLedLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedScanBlinkInProgress = true;
@@ -961,8 +964,8 @@ static void SwLedControlMode1(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                 }
                break;
        case LED_CTL_TX:
@@ -972,11 +975,11 @@ static void SwLedControlMode1(struct _adapter *padapter,
                            IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedLinkBlinkInProgress = false;
                        }
                        pLed->bLedBlinkInProgress = true;
@@ -986,8 +989,8 @@ static void SwLedControlMode1(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
 
@@ -995,19 +998,19 @@ static void SwLedControlMode1(struct _adapter *padapter,
        case LED_CTL_START_WPS_BOTTON:
                 if (pLed->bLedWPSBlinkInProgress == false) {
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                 pLed->bLedLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        if (pLed->bLedScanBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedScanBlinkInProgress = false;
                        }
                        pLed->bLedWPSBlinkInProgress = true;
@@ -1016,44 +1019,45 @@ static void SwLedControlMode1(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_STOP_WPS:
                if (pLed->bLedNoLinkBlinkInProgress == true) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedNoLinkBlinkInProgress = false;
                }
                if (pLed->bLedLinkBlinkInProgress == true) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                         pLed->bLedLinkBlinkInProgress = false;
                }
                if (pLed->bLedBlinkInProgress == true) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress == true) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                else
                        pLed->bLedWPSBlinkInProgress = true;
                pLed->CurrLedState = LED_BLINK_WPS_STOP;
                if (pLed->bLedOn) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
                } else {
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                }
                break;
        case LED_CTL_STOP_WPS_FAIL:
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->bLedNoLinkBlinkInProgress = true;
@@ -1062,33 +1066,34 @@ static void SwLedControlMode1(struct _adapter *padapter,
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedNoLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedNoLinkBlinkInProgress = false;
                }
                if (pLed->bLedLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedLinkBlinkInProgress = false;
                }
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        default:
                break;
@@ -1111,7 +1116,7 @@ static void SwLedControlMode2(struct _adapter *padapter,
                                return;
 
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedScanBlinkInProgress = true;
@@ -1121,8 +1126,8 @@ static void SwLedControlMode2(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                 }
                break;
 
@@ -1140,8 +1145,8 @@ static void SwLedControlMode2(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
 
@@ -1149,32 +1154,34 @@ static void SwLedControlMode2(struct _adapter *padapter,
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
 
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
 
        case LED_CTL_START_WPS: /*wait until xinpin finish*/
        case LED_CTL_START_WPS_BOTTON:
                if (pLed->bLedWPSBlinkInProgress == false) {
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        if (pLed->bLedScanBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedScanBlinkInProgress = false;
                        }
                        pLed->bLedWPSBlinkInProgress = true;
                        pLed->CurrLedState = LED_ON;
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                 }
                break;
 
@@ -1182,14 +1189,16 @@ static void SwLedControlMode2(struct _adapter *padapter,
                pLed->bLedWPSBlinkInProgress = false;
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
 
        case LED_CTL_STOP_WPS_FAIL:
                pLed->bLedWPSBlinkInProgress = false;
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
 
        case LED_CTL_START_TO_LINK:
@@ -1197,25 +1206,27 @@ static void SwLedControlMode2(struct _adapter *padapter,
                if (!IS_LED_BLINKING(pLed)) {
                        pLed->CurrLedState = LED_OFF;
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                }
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        default:
                break;
@@ -1237,7 +1248,7 @@ static void SwLedControlMode3(struct _adapter *padapter,
                        if (IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedScanBlinkInProgress = true;
@@ -1247,8 +1258,8 @@ static void SwLedControlMode3(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_TX:
@@ -1265,8 +1276,8 @@ static void SwLedControlMode3(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_LINK:
@@ -1275,24 +1286,25 @@ static void SwLedControlMode3(struct _adapter *padapter,
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        case LED_CTL_START_WPS: /* wait until xinpin finish */
        case LED_CTL_START_WPS_BOTTON:
                if (pLed->bLedWPSBlinkInProgress == false) {
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        if (pLed->bLedScanBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedScanBlinkInProgress = false;
                        }
                        pLed->bLedWPSBlinkInProgress = true;
@@ -1301,59 +1313,63 @@ static void SwLedControlMode3(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_STOP_WPS:
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&(pLed->BlinkTimer));
                        pLed->bLedWPSBlinkInProgress = false;
                } else
                        pLed->bLedWPSBlinkInProgress = true;
                pLed->CurrLedState = LED_BLINK_WPS_STOP;
                if (pLed->bLedOn) {
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA));
                } else {
                        pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                }
                break;
        case LED_CTL_STOP_WPS_FAIL:
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        case LED_CTL_START_TO_LINK:
        case LED_CTL_NO_LINK:
                if (!IS_LED_BLINKING(pLed)) {
                        pLed->CurrLedState = LED_OFF;
                        pLed->BlinkingLedState = LED_OFF;
-                       _set_timer(&(pLed->BlinkTimer), 0);
+                       mod_timer(&pLed->BlinkTimer,
+                                 jiffies + msecs_to_jiffies(0));
                }
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        default:
                break;
@@ -1372,34 +1388,35 @@ static void SwLedControlMode4(struct _adapter *padapter,
        case LED_CTL_START_TO_LINK:
                if (pLed1->bLedWPSBlinkInProgress) {
                        pLed1->bLedWPSBlinkInProgress = false;
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
+                       del_timer_sync(&pLed1->BlinkTimer);
                        pLed1->BlinkingLedState = LED_OFF;
                        pLed1->CurrLedState = LED_OFF;
                        if (pLed1->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer), 0);
+                               mod_timer(&pLed->BlinkTimer,
+                                         jiffies + msecs_to_jiffies(0));
                }
                if (pLed->bLedStartToLinkBlinkInProgress == false) {
                        if (pLed->CurrLedState == LED_SCAN_BLINK ||
                            IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        pLed->bLedStartToLinkBlinkInProgress = true;
                        pLed->CurrLedState = LED_BLINK_StartToBlink;
                        if (pLed->bLedOn) {
                                pLed->BlinkingLedState = LED_OFF;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_SLOWLY_INTERVAL);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                        } else {
                                pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_NORMAL_INTERVAL);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                        }
                }
                break;
@@ -1409,11 +1426,12 @@ static void SwLedControlMode4(struct _adapter *padapter,
                if (LedAction == LED_CTL_LINK) {
                        if (pLed1->bLedWPSBlinkInProgress) {
                                pLed1->bLedWPSBlinkInProgress = false;
-                               _cancel_timer_ex(&(pLed1->BlinkTimer));
+                               del_timer_sync(&pLed1->BlinkTimer);
                                pLed1->BlinkingLedState = LED_OFF;
                                pLed1->CurrLedState = LED_OFF;
                                if (pLed1->bLedOn)
-                                       _set_timer(&(pLed->BlinkTimer), 0);
+                                       mod_timer(&pLed->BlinkTimer,
+                                                 jiffies + msecs_to_jiffies(0));
                        }
                }
                if (pLed->bLedNoLinkBlinkInProgress == false) {
@@ -1421,7 +1439,7 @@ static void SwLedControlMode4(struct _adapter *padapter,
                            IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedNoLinkBlinkInProgress = true;
@@ -1430,8 +1448,8 @@ static void SwLedControlMode4(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_SITE_SURVEY:
@@ -1442,11 +1460,11 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        if (IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedScanBlinkInProgress = true;
@@ -1456,8 +1474,8 @@ static void SwLedControlMode4(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_TX:
@@ -1467,7 +1485,7 @@ static void SwLedControlMode4(struct _adapter *padapter,
                            IS_LED_WPS_BLINKING(pLed))
                                return;
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        pLed->bLedBlinkInProgress = true;
@@ -1477,49 +1495,50 @@ static void SwLedControlMode4(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_START_WPS: /*wait until xinpin finish*/
        case LED_CTL_START_WPS_BOTTON:
                if (pLed1->bLedWPSBlinkInProgress) {
                        pLed1->bLedWPSBlinkInProgress = false;
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
+                       del_timer_sync(&(pLed1->BlinkTimer));
                        pLed1->BlinkingLedState = LED_OFF;
                        pLed1->CurrLedState = LED_OFF;
                        if (pLed1->bLedOn)
-                               _set_timer(&(pLed->BlinkTimer), 0);
+                               mod_timer(&pLed->BlinkTimer,
+                                         jiffies + msecs_to_jiffies(0));
                }
                if (pLed->bLedWPSBlinkInProgress == false) {
                        if (pLed->bLedNoLinkBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedNoLinkBlinkInProgress = false;
                        }
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        if (pLed->bLedScanBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedScanBlinkInProgress = false;
                        }
                        pLed->bLedWPSBlinkInProgress = true;
                        pLed->CurrLedState = LED_BLINK_WPS;
                        if (pLed->bLedOn) {
                                pLed->BlinkingLedState = LED_OFF;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_SLOWLY_INTERVAL);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_SLOWLY_INTERVAL));
                        } else {
                                pLed->BlinkingLedState = LED_ON;
-                               _set_timer(&(pLed->BlinkTimer),
-                                          LED_BLINK_NORMAL_INTERVAL);
+                               mod_timer(&pLed->BlinkTimer, jiffies +
+                                         msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                        }
                }
                break;
        case LED_CTL_STOP_WPS:  /*WPS connect success*/
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->bLedNoLinkBlinkInProgress = true;
@@ -1528,12 +1547,12 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                break;
        case LED_CTL_STOP_WPS_FAIL:     /*WPS authentication fail*/
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->bLedNoLinkBlinkInProgress = true;
@@ -1542,11 +1561,11 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                /*LED1 settings*/
                if (pLed1->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
+                       del_timer_sync(&pLed1->BlinkTimer);
                else
                        pLed1->bLedWPSBlinkInProgress = true;
                pLed1->CurrLedState = LED_BLINK_WPS_STOP;
@@ -1554,11 +1573,12 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        pLed1->BlinkingLedState = LED_OFF;
                else
                        pLed1->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                break;
        case LED_CTL_STOP_WPS_FAIL_OVERLAP:     /*WPS session overlap*/
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->bLedNoLinkBlinkInProgress = true;
@@ -1567,11 +1587,11 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        pLed->BlinkingLedState = LED_OFF;
                else
                        pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer),
-                          LED_BLINK_NO_LINK_INTERVAL_ALPHA);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA));
                /*LED1 settings*/
                if (pLed1->bLedWPSBlinkInProgress)
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
+                       del_timer_sync(&pLed1->BlinkTimer);
                else
                        pLed1->bLedWPSBlinkInProgress = true;
                pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP;
@@ -1580,37 +1600,38 @@ static void SwLedControlMode4(struct _adapter *padapter,
                        pLed1->BlinkingLedState = LED_OFF;
                else
                        pLed1->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL);
+               mod_timer(&pLed->BlinkTimer, jiffies +
+                         msecs_to_jiffies(LED_BLINK_NORMAL_INTERVAL));
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedNoLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedNoLinkBlinkInProgress = false;
                }
                if (pLed->bLedLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedLinkBlinkInProgress = false;
                }
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                if (pLed->bLedScanBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedScanBlinkInProgress = false;
                }
                if (pLed->bLedStartToLinkBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedStartToLinkBlinkInProgress = false;
                }
                if (pLed1->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed1->BlinkTimer));
+                       del_timer_sync(&pLed1->BlinkTimer);
                        pLed1->bLedWPSBlinkInProgress = false;
                }
                pLed1->BlinkingLedState = LED_UNKNOWN;
@@ -1641,7 +1662,8 @@ static void SwLedControlMode5(struct _adapter *padapter,
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
                pLed->bLedBlinkInProgress = false;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        case LED_CTL_SITE_SURVEY:
                if ((pmlmepriv->sitesurveyctrl.traffic_busy) &&
@@ -1649,7 +1671,7 @@ static void SwLedControlMode5(struct _adapter *padapter,
                        ; /* dummy branch */
                else if (pLed->bLedScanBlinkInProgress == false) {
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedScanBlinkInProgress = true;
@@ -1659,8 +1681,8 @@ static void SwLedControlMode5(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_TX:
@@ -1675,15 +1697,15 @@ static void SwLedControlMode5(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                SwLedOff(padapter, pLed);
@@ -1711,7 +1733,7 @@ static void SwLedControlMode6(struct _adapter *padapter,
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
                pLed->bLedBlinkInProgress = false;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&(pLed->BlinkTimer), jiffies + msecs_to_jiffies(0));
                break;
        case LED_CTL_TX:
        case LED_CTL_RX:
@@ -1726,15 +1748,15 @@ static void SwLedControlMode6(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_FASTER_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_START_WPS: /*wait until xinpin finish*/
        case LED_CTL_START_WPS_BOTTON:
                if (pLed->bLedWPSBlinkInProgress == false) {
                        if (pLed->bLedBlinkInProgress == true) {
-                               _cancel_timer_ex(&(pLed->BlinkTimer));
+                               del_timer_sync(&pLed->BlinkTimer);
                                pLed->bLedBlinkInProgress = false;
                        }
                        pLed->bLedWPSBlinkInProgress = true;
@@ -1743,29 +1765,30 @@ static void SwLedControlMode6(struct _adapter *padapter,
                                pLed->BlinkingLedState = LED_OFF;
                        else
                                pLed->BlinkingLedState = LED_ON;
-                       _set_timer(&(pLed->BlinkTimer),
-                                  LED_BLINK_SCAN_INTERVAL_ALPHA);
+                       mod_timer(&pLed->BlinkTimer, jiffies +
+                                 msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA));
                }
                break;
        case LED_CTL_STOP_WPS_FAIL:
        case LED_CTL_STOP_WPS:
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                pLed->CurrLedState = LED_ON;
                pLed->BlinkingLedState = LED_ON;
-               _set_timer(&(pLed->BlinkTimer), 0);
+               mod_timer(&pLed->BlinkTimer,
+                         jiffies + msecs_to_jiffies(0));
                break;
        case LED_CTL_POWER_OFF:
                pLed->CurrLedState = LED_OFF;
                pLed->BlinkingLedState = LED_OFF;
                if (pLed->bLedBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedBlinkInProgress = false;
                }
                if (pLed->bLedWPSBlinkInProgress) {
-                       _cancel_timer_ex(&(pLed->BlinkTimer));
+                       del_timer_sync(&pLed->BlinkTimer);
                        pLed->bLedWPSBlinkInProgress = false;
                }
                SwLedOff(padapter, pLed);
index cd8b444b255b48161b087807ed9656e3d532a186..50227b598e0c3cecb0f7c07208fb04fe7f0aaa57 100644 (file)
@@ -161,12 +161,12 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
        u16 drvinfo_sz = 0;
 
        drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16;
-       drvinfo_sz = drvinfo_sz<<3;
+       drvinfo_sz <<= 3;
        /*TODO:
         * Offset 0 */
        pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27)
                                 ? 0 : 1;
-       pattrib->crc_err = ((le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14);
+       pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14;
        /*Offset 4*/
        /*Offset 8*/
        /*Offset 12*/
@@ -435,8 +435,8 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
        poffset = (u8 *)prxcmdbuf;
        voffset = *(uint *)poffset;
        prxstat = (struct recv_stat *)prxcmdbuf;
-       drvinfo_sz = ((le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16);
-       drvinfo_sz = drvinfo_sz << 3;
+       drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16;
+       drvinfo_sz <<= 3;
        poffset += RXDESC_SIZE + drvinfo_sz;
        do {
                voffset  = *(uint *)poffset;
@@ -604,12 +604,12 @@ static int recv_indicatepkt_reorder(struct _adapter *padapter,
         */
        if (r8712_recv_indicatepkts_in_order(padapter, preorder_ctrl, false) ==
            true) {
-               _set_timer(&preorder_ctrl->reordering_ctrl_timer,
-                          REORDER_WAIT_TIME);
+               mod_timer(&preorder_ctrl->reordering_ctrl_timer,
+                         jiffies + msecs_to_jiffies(REORDER_WAIT_TIME));
                spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
        } else {
                spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql);
-               _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
+               del_timer(&preorder_ctrl->reordering_ctrl_timer);
        }
        return _SUCCESS;
 _err_exit:
@@ -749,7 +749,7 @@ static void query_rx_phy_status(struct _adapter *padapter,
                 */
                if (!cck_highpwr) {
                        report = pcck_buf->cck_agc_rpt & 0xc0;
-                       report = report >> 6;
+                       report >>= 6;
                        switch (report) {
                        /* Modify the RF RNA gain value to -40, -20,
                         * -2, 14 by Jenyu's suggestion
@@ -775,7 +775,7 @@ static void query_rx_phy_status(struct _adapter *padapter,
                } else {
                        report = ((u8)(le32_to_cpu(pphy_stat->phydw1) >> 8)) &
                                 0x60;
-                       report = report >> 5;
+                       report >>= 5;
                        switch (report) {
                        case 0x3:
                                rx_pwr_all = -40 - ((pcck_buf->cck_agc_rpt &
@@ -1039,7 +1039,7 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb)
                frag = (le32_to_cpu(prxstat->rxdw2) >> 12) & 0xf;
                /* uint 2^3 = 8 bytes */
                drvinfo_sz = (le32_to_cpu(prxstat->rxdw0) & 0x000f0000) >> 16;
-               drvinfo_sz = drvinfo_sz<<3;
+               drvinfo_sz <<= 3;
                if (pkt_len <= 0)
                        goto  _exit_recvbuf2recvframe;
                /* Qos data, wireless lan header length is 26 */
index fe5e315319f7c7afb70494af935916df4b64c072..1a1c38f885d6b191d5a62b5fb1aae26713dd6cb3 100644 (file)
@@ -247,7 +247,8 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
        }
        set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
        r8712_enqueue_cmd(pcmdpriv, ph2c);
-       _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
+       mod_timer(&pmlmepriv->scan_to_timer,
+                 jiffies + msecs_to_jiffies(SCANNING_TIMEOUT));
        padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY);
        padapter->blnEnableRxFF0Filter = 0;
        return _SUCCESS;
@@ -530,8 +531,8 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
         * the driver just has the bssid information for PMKIDList searching.
         */
        if (pmlmepriv->assoc_by_bssid == false)
-               memcpy(&pmlmepriv->assoc_bssid[0],
-                       &pnetwork->network.MacAddress[0], ETH_ALEN);
+               ether_addr_copy(&pmlmepriv->assoc_bssid[0],
+                               &pnetwork->network.MacAddress[0]);
        psecnetwork->IELength = r8712_restruct_sec_ie(padapter,
                                                &pnetwork->network.IEs[0],
                                                &psecnetwork->IEs[0],
@@ -682,7 +683,7 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key)
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
        ph2c->rsp = (u8 *) psetstakey_rsp;
        ph2c->rspsz = sizeof(struct set_stakey_rsp);
-       memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
+       ether_addr_copy(psetstakey_para->addr, sta->hwaddr);
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                psetstakey_para->algorithm = (unsigned char)
                                            psecuritypriv->PrivacyAlgrthm;
@@ -784,7 +785,7 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr)
        }
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para,
                                   _SetMacAddress_CMD_);
-       memcpy(psetMacAddr_para->MacAddr, mac_addr, ETH_ALEN);
+       ether_addr_copy(psetMacAddr_para->MacAddr, mac_addr);
        r8712_enqueue_cmd(pcmdpriv, ph2c);
        return _SUCCESS;
 }
@@ -813,7 +814,7 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr)
        init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_);
        ph2c->rsp = (u8 *) psetassocsta_rsp;
        ph2c->rspsz = sizeof(struct set_assocsta_rsp);
-       memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN);
+       ether_addr_copy(psetassocsta_para->addr, mac_addr);
        r8712_enqueue_cmd(pcmdpriv, ph2c);
        return _SUCCESS;
 }
@@ -890,7 +891,8 @@ void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if (pcmd->res != H2C_SUCCESS)
-               _set_timer(&pmlmepriv->assoc_timer, 1);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
        r8712_free_cmd_obj(pcmd);
 }
 
@@ -898,7 +900,6 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
                                  struct cmd_obj *pcmd)
 {
        unsigned long irqL;
-       u8 timer_cancelled;
        struct sta_info *psta = NULL;
        struct wlan_network *pwlan = NULL;
        struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -907,8 +908,9 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
        struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
 
        if (pcmd->res != H2C_SUCCESS)
-               _set_timer(&pmlmepriv->assoc_timer, 1);
-       _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
+               mod_timer(&pmlmepriv->assoc_timer,
+                         jiffies + msecs_to_jiffies(1));
+       del_timer_sync(&pmlmepriv->assoc_timer);
 #ifdef __BIG_ENDIAN
        /* endian_convert */
        pnetwork->Length = le32_to_cpu(pnetwork->Length);
index 2f145d63fcecbf6b16898e35803c367033fce360..50339e67da071015a0e4c00a4693693fab08efcb 100644 (file)
@@ -64,7 +64,7 @@ static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count)
                udelay(CLOCK_RATE);
                up_clk(padapter, &x);
                down_clk(padapter, &x);
-               mask = mask >> 1;
+               mask >>= 1;
        } while (mask);
        if (padapter->bSurpriseRemoved == true)
                goto out;
@@ -83,7 +83,7 @@ static u16 shift_in_bits(struct _adapter *padapter)
        x &= ~(_EEDO | _EEDI);
        d = 0;
        for (i = 0; i < 16; i++) {
-               d = d << 1;
+               d <<= 1;
                up_clk(padapter, &x);
                if (padapter->bSurpriseRemoved == true)
                        goto out;
index 9bb364f04fd49b59152fd0e792e33f161b937ee3..81f39c31594775be5e83097a9a4a939c9d498e94 100644 (file)
@@ -46,6 +46,8 @@
 #include <linux/semaphore.h>
 #include <net/iw_handler.h>
 #include <linux/if_arp.h>
+#include <linux/etherdevice.h>
+
 
 #define RTL_IOCTL_WPA_SUPPLICANT       (SIOCIWFIRSTPRIV + 0x1E)
 
@@ -112,7 +114,7 @@ void r8712_indicate_wx_disassoc_event(struct _adapter *padapter)
        union iwreq_data wrqu;
 
        wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-       memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+       eth_zero_addr(wrqu.ap_addr.sa_data);
        wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL);
 }
 
@@ -129,7 +131,8 @@ static inline void handle_pairwise_key(struct sta_info *psta,
                memcpy(psta->tkiprxmickey. skey, &(param->u.crypt.
                        key[24]), 8);
                padapter->securitypriv. busetkipkey = false;
-               _set_timer(&padapter->securitypriv.tkip_timer, 50);
+               mod_timer(&padapter->securitypriv.tkip_timer,
+                         jiffies + msecs_to_jiffies(50));
        }
        r8712_setstakey_cmd(padapter, (unsigned char *)psta, true);
 }
@@ -153,8 +156,8 @@ static inline void handle_group_key(struct ieee_param *param,
                if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE) {
                        if (padapter->registrypriv.power_mgnt != padapter->
                            pwrctrlpriv.pwr_mode)
-                               _set_timer(&(padapter->mlmepriv.dhcp_timer),
-                                          60000);
+                               mod_timer(&padapter->mlmepriv.dhcp_timer,
+                                         jiffies + msecs_to_jiffies(60000));
                }
        }
 }
@@ -182,7 +185,7 @@ static inline char *translate_scan(struct _adapter *padapter,
        /* AP MAC address */
        iwe.cmd = SIOCGIWAP;
        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-       memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN);
+       ether_addr_copy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress);
        start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
        /* Add the ESSID */
        iwe.cmd = SIOCGIWESSID;
@@ -851,8 +854,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                            strIssueBssid, ETH_ALEN)) {
                                /* BSSID is matched, the same AP => Remove
                                 * this PMKID information and reset it. */
-                               memset(psecuritypriv->PMKIDList[j].Bssid,
-                                       0x00, ETH_ALEN);
+                               eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
                                psecuritypriv->PMKIDList[j].bUsed = false;
                                break;
                        }
@@ -1115,9 +1117,9 @@ static int r8711_wx_get_wap(struct net_device *dev,
        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
        if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
                                     WIFI_AP_STATE))
-               memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
+               ether_addr_copy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress);
        else
-               memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+               eth_zero_addr(wrqu->ap_addr.sa_data);
        return 0;
 }
 
index 6318a0e65e6e6c9831f07ccde9f90b3c25967707..bd1d1b773c4818278e12460200fd08f2dbcd36c7 100644 (file)
@@ -85,7 +85,8 @@ static u8 do_join(struct _adapter *padapter)
 
                ret = r8712_select_and_join_from_scan(pmlmepriv);
                if (ret == _SUCCESS)
-                       _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
+                       mod_timer(&pmlmepriv->assoc_timer,
+                                 jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                else {
                        if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
                                /* submit r8712_createbss_cmd to change to an
index 977a83358056a3ac7fe7b07661426bb935bdd48d..fb2b195b90af0d1690552dfccb6ec93b13960fdf 100644 (file)
@@ -582,9 +582,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
        spin_lock_irqsave(&pmlmepriv->lock, irqL);
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) {
-               u8 timer_cancelled;
-
-               _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled);
+               del_timer_sync(&pmlmepriv->scan_to_timer);
 
                _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
        }
@@ -596,8 +594,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
 
                                if (r8712_select_and_join_from_scan(pmlmepriv)
                                    == _SUCCESS)
-                                       _set_timer(&pmlmepriv->assoc_timer,
-                                                  MAX_JOIN_TIMEOUT);
+                                       mod_timer(&pmlmepriv->assoc_timer, jiffies +
+                                                 msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                                else {
                                        struct wlan_bssid_ex *pdev_network =
                                          &(adapter->registrypriv.dev_network);
@@ -622,8 +620,8 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf)
                        set_fwstate(pmlmepriv, _FW_UNDER_LINKING);
                        if (r8712_select_and_join_from_scan(pmlmepriv) ==
                            _SUCCESS)
-                               _set_timer(&pmlmepriv->assoc_timer,
-                                          MAX_JOIN_TIMEOUT);
+                               mod_timer(&pmlmepriv->assoc_timer, jiffies +
+                                         msecs_to_jiffies(MAX_JOIN_TIMEOUT));
                        else
                                _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                }
@@ -679,7 +677,8 @@ void r8712_indicate_connect(struct _adapter *padapter)
        padapter->ledpriv.LedControlHandler(padapter, LED_CTL_LINK);
        r8712_os_indicate_connect(padapter);
        if (padapter->registrypriv.power_mgnt > PS_MODE_ACTIVE)
-               _set_timer(&pmlmepriv->dhcp_timer, 60000);
+               mod_timer(&pmlmepriv->dhcp_timer,
+                         jiffies + msecs_to_jiffies(60000));
 }
 
 
@@ -697,7 +696,7 @@ void r8712_ind_disconnect(struct _adapter *padapter)
        }
        if (padapter->pwrctrlpriv.pwr_mode !=
            padapter->registrypriv.power_mgnt) {
-               _cancel_timer_ex(&pmlmepriv->dhcp_timer);
+               del_timer_sync(&pmlmepriv->dhcp_timer);
                r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt,
                                  padapter->registrypriv.smart_ps);
        }
@@ -716,7 +715,6 @@ void r8712_ind_disconnect(struct _adapter *padapter)
 void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
 {
        unsigned long irqL = 0, irqL2;
-       u8 timer_cancelled;
        struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL;
        struct sta_priv *pstapriv = &adapter->stapriv;
        struct mlme_priv        *pmlmepriv = &adapter->mlmepriv;
@@ -727,6 +725,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
 
        if (sizeof(struct list_head) == 4 * sizeof(u32)) {
                pnetwork = kmalloc(sizeof(struct wlan_network), GFP_ATOMIC);
+               if (!pnetwork)
+                       return;
                memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8,
                        sizeof(struct wlan_network) - 16);
        } else
@@ -910,13 +910,13 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf)
                        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)
                                == true)
                                r8712_indicate_connect(adapter);
-                       _cancel_timer(&pmlmepriv->assoc_timer,
-                                     &timer_cancelled);
+                       del_timer_sync(&pmlmepriv->assoc_timer);
                } else
                        goto ignore_joinbss_callback;
        } else {
                if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) {
-                       _set_timer(&pmlmepriv->assoc_timer, 1);
+                       mod_timer(&pmlmepriv->assoc_timer,
+                                 jiffies + msecs_to_jiffies(1));
                        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                }
        }
@@ -1599,17 +1599,15 @@ sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
        iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid);
        if (iEntry < 0)
                return ielength;
-       else {
-               if (authmode == _WPA2_IE_ID_) {
-                       out_ie[ielength] = 1;
-                       ielength++;
-                       out_ie[ielength] = 0;   /*PMKID count = 0x0100*/
-                       ielength++;
-                       memcpy(&out_ie[ielength],
-                               &psecuritypriv->PMKIDList[iEntry].PMKID, 16);
-                       ielength += 16;
-                       out_ie[13] += 18;/*PMKID length = 2+16*/
-               }
+       if (authmode == _WPA2_IE_ID_) {
+               out_ie[ielength] = 1;
+               ielength++;
+               out_ie[ielength] = 0;   /*PMKID count = 0x0100*/
+               ielength++;
+               memcpy(&out_ie[ielength],
+                       &psecuritypriv->PMKIDList[iEntry].PMKID, 16);
+               ielength += 16;
+               out_ie[13] += 18;/*PMKID length = 2+16*/
        }
        return ielength;
 }
index 3d913b9701bba873179b156aeca303861f01b0dd..26201ea3cca6594e6a2405821a0337426927d2a3 100644 (file)
@@ -327,8 +327,8 @@ void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset)
        u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D, tmpAGC;
 
        TxAGCOffset_B = (ulTxAGCOffset&0x000000ff);
-       TxAGCOffset_C = ((ulTxAGCOffset&0x0000ff00)>>8);
-       TxAGCOffset_D = ((ulTxAGCOffset&0x00ff0000)>>16);
+       TxAGCOffset_C = (ulTxAGCOffset & 0x0000ff00)>>8;
+       TxAGCOffset_D = (ulTxAGCOffset & 0x00ff0000)>>16;
        tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B);
        set_bb_reg(pAdapter, rFPGA0_TxGainStage,
                        (bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC);
index ed2844d2b02abcf3345bfba74e72dc98865d1410..aaa584435c87d25d3efb3bbbe794da6cf2096c24 100644 (file)
@@ -103,7 +103,7 @@ void r8712_cpwm_int_hdl(struct _adapter *padapter,
 
        if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80))
                return;
-       _cancel_timer_ex(&padapter->pwrctrlpriv. rpwm_check_timer);
+       del_timer_sync(&padapter->pwrctrlpriv.rpwm_check_timer);
        _enter_pwrlock(&pwrpriv->lock);
        pwrpriv->cpwm = (preportpwrstate->state) & 0xf;
        if (pwrpriv->cpwm >= PS_STATE_S2) {
@@ -165,9 +165,9 @@ static void rpwm_workitem_callback(struct work_struct *work)
        }
 }
 
-static void rpwm_check_handler (void *FunctionContext)
+static void rpwm_check_handler (unsigned long data)
 {
-       struct _adapter *adapter = (struct _adapter *)FunctionContext;
+       struct _adapter *adapter = (struct _adapter *)data;
 
        _rpwm_check_handler(adapter);
 }
@@ -186,8 +186,8 @@ void r8712_init_pwrctrl_priv(struct _adapter *padapter)
        r8712_write8(padapter, 0x1025FE58, 0);
        INIT_WORK(&pwrctrlpriv->SetPSModeWorkItem, SetPSModeWorkItemCallback);
        INIT_WORK(&pwrctrlpriv->rpwm_workitem, rpwm_workitem_callback);
-       _init_timer(&(pwrctrlpriv->rpwm_check_timer),
-                   padapter->pnetdev, rpwm_check_handler, (u8 *)padapter);
+       setup_timer(&pwrctrlpriv->rpwm_check_timer, rpwm_check_handler,
+                   (unsigned long)padapter);
 }
 
 /*
index 06f15f81c4d86062c53f00e33617945e6688ace7..046a46c4cd7ff1e2f392f827ab6272569b5bff90 100644 (file)
@@ -517,8 +517,7 @@ static sint validate_recv_data_frame(struct _adapter *adapter,
                return _FAIL;
        if (psta == NULL)
                return _FAIL;
-       else
-               precv_frame->u.hdr.psta = psta;
+       precv_frame->u.hdr.psta = psta;
        pattrib->amsdu = 0;
        /* parsing QC field */
        if (pattrib->qos == 1) {
index c653ad6854b4d3776c978730b924e6ee02535704..a178c232b44a447be77fd2d061df306730286336 100644 (file)
@@ -1045,7 +1045,7 @@ static sint aes_cipher(u8 *key, uint      hdrlen,
        uint    frtype  = GetFrameType(pframe);
        uint    frsubtype  = GetFrameSubType(pframe);
 
-       frsubtype = frsubtype >> 4;
+       frsubtype >>= 4;
        memset((void *)mic_iv, 0, 16);
        memset((void *)mic_header1, 0, 16);
        memset((void *)mic_header2, 0, 16);
@@ -1086,7 +1086,7 @@ static sint aes_cipher(u8 *key, uint      hdrlen,
        payload_remainder = plen % 16;
        num_blocks = plen / 16;
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
        bitwise_xor(aes_out, mic_header1, chain_buffer);
@@ -1216,7 +1216,7 @@ static sint aes_decipher(u8 *key, uint    hdrlen,
        uint frtype  = GetFrameType(pframe);
        uint frsubtype  = GetFrameSubType(pframe);
 
-       frsubtype = frsubtype >> 4;
+       frsubtype >>= 4;
        memset((void *)mic_iv, 0, 16);
        memset((void *)mic_header1, 0, 16);
        memset((void *)mic_header2, 0, 16);
@@ -1292,7 +1292,7 @@ static sint aes_decipher(u8 *key, uint    hdrlen,
        payload_remainder = (plen - 8) % 16;
        num_blocks = (plen - 8) / 16;
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
        bitwise_xor(aes_out, mic_header1, chain_buffer);
@@ -1392,9 +1392,9 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe)
        return _SUCCESS;
 }
 
-void r8712_use_tkipkey_handler(void *FunctionContext)
+void r8712_use_tkipkey_handler(unsigned long data)
 {
-       struct _adapter *padapter = (struct _adapter *)FunctionContext;
+       struct _adapter *padapter = (struct _adapter *)data;
 
        padapter->securitypriv.busetkipkey = true;
 }
index c732aeab8d2c67049900abce4fb48c150bb5605a..2295f0e64dc2c7d0ef867903324caf6cf379db65 100644 (file)
@@ -216,7 +216,7 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8  *pxmitframe);
 u32 r8712_aes_decrypt(struct _adapter *padapter, u8  *precvframe);
 u32 r8712_tkip_decrypt(struct _adapter *padapter, u8  *precvframe);
 void r8712_wep_decrypt(struct _adapter *padapter, u8  *precvframe);
-void r8712_use_tkipkey_handler(void *FunctionContext);
+void r8712_use_tkipkey_handler(unsigned long data);
 
 #endif /*__RTL871X_SECURITY_H_ */
 
index 1752121ff494d5274325a2aacb6e2d4945e87fe1..7bb96c47f1883dad0c62e8618b2e98ac773fca27 100644 (file)
@@ -198,7 +198,7 @@ void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta)
         * cancel reordering_ctrl_timer */
        for (i = 0; i < 16; i++) {
                preorder_ctrl = &psta->recvreorder_ctrl[i];
-               _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
+               del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
        }
        spin_lock(&(pfree_sta_queue->lock));
        /* insert into free_sta_queue; 20061114 */
index a28af03c9d8adb4e4b51e5c708cd3456b7e344c3..2e4fa88951ad88f4a622fe9a81e9641ca69ba7ea 100644 (file)
@@ -203,13 +203,12 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
        pattrib->ether_type = ntohs(etherhdr.h_proto);
 
 {
-       u8 bool;
        /*If driver xmit ARP packet, driver can set ps mode to initial
         * setting. It stands for getting DHCP or fix IP.*/
        if (pattrib->ether_type == 0x0806) {
                if (padapter->pwrctrlpriv.pwr_mode !=
                    padapter->registrypriv.power_mgnt) {
-                       _cancel_timer(&(pmlmepriv->dhcp_timer), &bool);
+                       del_timer_sync(&pmlmepriv->dhcp_timer);
                        r8712_set_ps_mode(padapter, padapter->registrypriv.
                                power_mgnt, padapter->registrypriv.smart_ps);
                }
index 73d7cd28060750e5114b9df332a8b3dea40c46bb..17f513122f48b79ec71ed03df80893af4a94b533 100644 (file)
@@ -235,11 +235,6 @@ enum WIFI_REG_DOMAIN {
 #define GetPrivacy(pbuf)       (((*(unsigned short *)(pbuf)) & \
                                le16_to_cpu(_PRIVACY_)) != 0)
 
-#define ClearPrivacy(pbuf) ({ \
-       *(unsigned short *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)); \
-})
-
-
 #define GetOrder(pbuf) (((*(unsigned short *)(pbuf)) & \
                        le16_to_cpu(_ORDER_)) != 0)
 
@@ -248,9 +243,9 @@ enum WIFI_REG_DOMAIN {
 
 #define SetFrameType(pbuf, type)       \
        do {    \
-               *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | \
+               *(unsigned short *)(pbuf) &= cpu_to_le16(~(BIT(3) | \
                BIT(2))); \
-               *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \
+               *(unsigned short *)(pbuf) |= cpu_to_le16(type); \
        } while (0)
 
 #define GetFrameSubType(pbuf)  (cpu_to_le16(*(unsigned short *)(pbuf)) & \
@@ -270,16 +265,6 @@ enum WIFI_REG_DOMAIN {
 #define GetFragNum(pbuf)       (cpu_to_le16(*(unsigned short *)((addr_t)\
                                (pbuf) + 22)) & 0x0f)
 
-#define GetTupleCache(pbuf)    (cpu_to_le16(*(unsigned short *)\
-                               ((addr_t)(pbuf) + 22)))
-
-#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)) & \
@@ -306,17 +291,9 @@ enum WIFI_REG_DOMAIN {
 
 #define GetAMsdu(pbuf) (((le16_to_cpu(*(unsigned short *)pbuf)) >> 7) & 0x1)
 
-#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)
 
-#define GetTid(pbuf)   (cpu_to_le16(*(unsigned short *)((addr_t)(pbuf) + \
-                       (((GetToDs(pbuf) << 1)|GetFrDs(pbuf)) == 3 ? \
-                       30 : 24))) & 0x000f)
-
 #define GetAddr1Ptr(pbuf)      ((unsigned char *)((addr_t)(pbuf) + 4))
 
 #define GetAddr2Ptr(pbuf)      ((unsigned char *)((addr_t)(pbuf) + 10))
index c6327c07291837396861062d23f3e0c1e40e3457..bed13db03da2fef8c48c47f80010393178b6e813 100644 (file)
@@ -20,6 +20,7 @@
 #include <wifi.h>
 #include <rtl8723a_cmd.h>
 #include <rtl8723a_hal.h>
+#include <asm/unaligned.h>
 
 extern unsigned char WMM_OUI23A[];
 extern unsigned char WPS_OUI23A[];
@@ -72,11 +73,8 @@ static void update_BCNTIM(struct rtw_adapter *padapter)
        struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network;
        unsigned char *pie = pnetwork_mlmeext->IEs;
        u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL;
-       __le16 tim_bitmap_le;
        uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
 
-       tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap);
-
        p = rtw_get_ie23a(pie, WLAN_EID_TIM, &tim_ielen,
                          pnetwork_mlmeext->IELength);
        if (p != NULL && tim_ielen > 0) {
@@ -143,9 +141,9 @@ static void update_BCNTIM(struct rtw_adapter *padapter)
                *dst_ie++ = 0;
 
        if (tim_ielen == 4) {
-               *dst_ie++ = *(u8 *)&tim_bitmap_le;
+               *dst_ie++ = pstapriv->tim_bitmap & 0xff;
        } else if (tim_ielen == 5) {
-               memcpy(dst_ie, &tim_bitmap_le, 2);
+               put_unaligned_le16(pstapriv->tim_bitmap, dst_ie);
                dst_ie += 2;
        }
 
@@ -785,6 +783,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter,
        struct wlan_bssid_ex *pbss_network = &pmlmepriv->cur_network.network;
        u8 *ie = pbss_network->IEs;
        u8 *pbuf = mgmt->u.beacon.variable;
+
        len -= offsetof(struct ieee80211_mgmt, u.beacon.variable);
        /* SSID */
        /* Supported rates */
@@ -1477,8 +1476,8 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
        if (psta->flags & WLAN_STA_HT) {
                u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info);
 
-               DBG_8723A("HT: STA " MAC_FMT " HT Capabilities "
-                          "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab);
+               DBG_8723A("HT: STA " MAC_FMT " HT Capabilities Info: 0x%04x\n",
+                               MAC_ARG(psta->hwaddr), ht_capab);
 
                if (psta->no_ht_set) {
                        psta->no_ht_set = 0;
index 2447a56df8381c48eddac40fe3d7fcd1c05c6f6f..f6b99d8e1878df371d8823b45d6e268ac3db7ed5 100644 (file)
@@ -1368,7 +1368,7 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter,
                                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
                                         ("\nCan't alloc sta_info when "
                                          "createbss_cmd_callback\n"));
-                               goto createbss_cmd_fail ;
+                               goto createbss_cmd_fail;
                        }
                }
 
index a6deddc02291392017e02ffc8c47fde8d27872cb..29fc25b367e55e2e027d84d9b28dbb572c580049 100644 (file)
@@ -304,8 +304,7 @@ EFUSE_Read1Byte23a(struct rtw_adapter *Adapter, u16 Address)
                }
                data = rtl8723au_read8(Adapter, EFUSE_CTRL);
                return data;
-       }
-       else
+       } else
                return 0xFF;
 }/* EFUSE_Read1Byte23a */
 
index 0e0f73c86e53c5738dc5d728f2df0361d99c004e..d01ca1d75254d38c330ad26aab7ed6868f9e13a4 100644 (file)
@@ -3842,7 +3842,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter,
                                IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK;
                } else {
                        /* immediate ack & 64 buffer size */
-                       BA_para_set = (0x1002 | ((status & 0xf) << 2));
+                       BA_para_set = 0x1002 | ((status & 0xf) << 2);
                }
 
                put_unaligned_le16(BA_para_set,
@@ -4745,7 +4745,7 @@ void report_survey_event23a(struct rtw_adapter *padapter,
        if (!pcmd_obj)
                return;
 
-       cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct survey_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (!pevtcmd) {
                kfree(pcmd_obj);
@@ -4796,7 +4796,7 @@ void report_surveydone_event23a(struct rtw_adapter *padapter)
        if (!pcmd_obj)
                return;
 
-       cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (!pevtcmd) {
                kfree(pcmd_obj);
@@ -4840,7 +4840,7 @@ void report_join_res23a(struct rtw_adapter *padapter, int res)
        if (!pcmd_obj)
                return;
 
-       cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (!pevtcmd) {
                kfree(pcmd_obj);
@@ -4890,7 +4890,7 @@ void report_del_sta_event23a(struct rtw_adapter *padapter,
        if (!pcmd_obj)
                return;
 
-       cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (!pevtcmd) {
                kfree(pcmd_obj);
@@ -4918,7 +4918,7 @@ void report_del_sta_event23a(struct rtw_adapter *padapter,
        if (psta)
                mac_id = (int)psta->mac_id;
        else
-               mac_id = (-1);
+               mac_id = -1;
 
        pdel_sta_evt->mac_id = mac_id;
 
@@ -4944,7 +4944,7 @@ void report_add_sta_event23a(struct rtw_adapter *padapter,
        if (!pcmd_obj)
                return;
 
-       cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header));
+       cmdsz = sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header);
        pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
        if (!pevtcmd) {
                kfree(pcmd_obj);
@@ -5951,7 +5951,7 @@ int set_stakey_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
 
                        /* 0~3 for default key, cmd_id = macid + 3,
                           macid = aid+1; */
-                       cam_id = (psta->mac_id + 3);
+                       cam_id = psta->mac_id + 3;
 
                        DBG_8723A("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, "
                                  "cam_entry =%d\n", pparm->addr[0],
index 559dddee26485df3ced453913850eb1b2e513e49..9c783002caf2c4878aa95fe758cbf16ebdd50bf6 100644 (file)
@@ -2334,8 +2334,8 @@ void rtw_signal_stat_timer_hdl23a(unsigned long data)
 
        /* update value of signal_strength, rssi, signal_qual */
        if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) {
-               tmp_s = (avg_signal_strength + (_alpha - 1) *
-                        recvpriv->signal_strength);
+               tmp_s = avg_signal_strength + (_alpha - 1) *
+                        recvpriv->signal_strength;
                if (tmp_s %_alpha)
                        tmp_s = tmp_s / _alpha + 1;
                else
index 715a47414bdd587ec58355edab079ebf3da52a86..045a24c81b1256098498d7c91794b37d1c584693 100644 (file)
@@ -87,7 +87,7 @@ static void arcfour_encrypt(  struct arc4context      *parc4ctx,
 
 }
 
-static int bcrc32initialized = 0;
+static int bcrc32initialized;
 static u32 crc32_table[256];
 
 static u8 crc32_reverseBit(u8 data)
@@ -1193,7 +1193,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
        num_blocks = plen / 16;
 
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
 
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
@@ -1466,7 +1466,7 @@ static int aes_decipher(u8 *key, uint     hdrlen,
        num_blocks = (plen-8) / 16;
 
        /* Find start of payload */
-       payload_index = (hdrlen + 8);
+       payload_index = hdrlen + 8;
 
        /* Calculate MIC */
        aes128k128d(key, mic_iv, aes_out);
index 179a1ba03029690bd4ca66d54c49b028e6e3fb46..3f9ec9e00e1681fec049ece1c10782631f9a13c2 100644 (file)
@@ -23,9 +23,8 @@
 #define                DPK_DELTA_MAPPING_NUM   13
 #define                index_mapping_HP_NUM    15
 /* 091212 chiyokolin */
-static void
-odm_TXPowerTrackingCallback_ThermalMeter_92C(
-       struct rtw_adapter *Adapter)
+static void
+odm_TXPowerTrackingCallback_ThermalMeter_92C(struct rtw_adapter *Adapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
@@ -35,7 +34,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
        s8 OFDM_index[2], CCK_index = 0, OFDM_index_old[2] = {0};
        s8 CCK_index_old = 0;
        int i = 0;
-       bool is2T = IS_92C_SERIAL(pHalData->VersionID);
        u8 OFDM_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB*/
        u8 ThermalValue_HP_count = 0;
        u32 ThermalValue_HP = 0;
@@ -60,15 +58,15 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
        rtl8723a_phy_ap_calibrate(Adapter, (ThermalValue -
                                  pHalData->EEPROMThermalMeter));
 
-       if (is2T)
+       if (pHalData->rf_type == RF_2T2R)
                rf = 2;
        else
                rf = 1;
 
        if (ThermalValue) {
                /* Query OFDM path A default setting     */
-               ele_D = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance,
-                                      bMaskDWord)&bMaskOFDM_D;
+               ele_D = rtl8723au_read32(Adapter, rOFDM0_XATxIQImbalance) &
+                       bMaskOFDM_D;
                for (i = 0; i < OFDM_TABLE_SIZE_92C; i++) {
                        /* find the index */
                        if (ele_D == (OFDMSwingTable23A[i]&bMaskOFDM_D)) {
@@ -78,9 +76,10 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                }
 
                /* Query OFDM path B default setting  */
-               if (is2T) {
-                       ele_D = PHY_QueryBBReg(Adapter, rOFDM0_XBTxIQImbalance,
-                                              bMaskDWord)&bMaskOFDM_D;
+               if (pHalData->rf_type == RF_2T2R) {
+                       ele_D = rtl8723au_read32(Adapter,
+                                                rOFDM0_XBTxIQImbalance);
+                       ele_D &= bMaskOFDM_D;
                        for (i = 0; i < OFDM_TABLE_SIZE_92C; i++) {     /* find the index  */
                                if (ele_D == (OFDMSwingTable23A[i]&bMaskOFDM_D)) {
                                        OFDM_index_old[1] = (u8)i;
@@ -90,8 +89,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                }
 
                /* Query CCK default setting From 0xa24 */
-               TempCCk = PHY_QueryBBReg(Adapter, rCCK0_TxFilter2,
-                                        bMaskDWord)&bMaskCCK;
+               TempCCk = rtl8723au_read32(Adapter, rCCK0_TxFilter2) & bMaskCCK;
                for (i = 0 ; i < CCK_TABLE_SIZE ; i++) {
                        if (pdmpriv->bCCKinCH14) {
                                if (!memcmp(&TempCCk,
@@ -224,12 +222,13 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                        }
 
                        if (CCK_index > (CCK_TABLE_SIZE-1))
-                               CCK_index = (CCK_TABLE_SIZE-1);
+                               CCK_index = CCK_TABLE_SIZE-1;
                        else if (CCK_index < 0)
                                CCK_index = 0;
                }
 
-               if (pdmpriv->TxPowerTrackControl && (delta != 0 || delta_HP != 0)) {
+               if (pdmpriv->TxPowerTrackControl &&
+                   (delta != 0 || delta_HP != 0)) {
                        /* Adujst OFDM Ant_A according to IQK result */
                        ele_D = (OFDMSwingTable23A[OFDM_index[0]] & 0xFFC00000)>>22;
                        X = pdmpriv->RegE94;
@@ -247,7 +246,9 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
 
                                /* write new elements A, C, D to regC80 and regC94, element B is always 0 */
                                value32 = (ele_D<<22)|((ele_C&0x3F)<<16)|ele_A;
-                               PHY_SetBBReg(Adapter, rOFDM0_XATxIQImbalance, bMaskDWord, value32);
+                               rtl8723au_write32(Adapter,
+                                                 rOFDM0_XATxIQImbalance,
+                                                 value32);
 
                                value32 = (ele_C&0x000003C0)>>6;
                                PHY_SetBBReg(Adapter, rOFDM0_XCTxAFE, bMaskH4Bits, value32);
@@ -260,9 +261,9 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                                PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold,
                                             BIT(29), value32);
                        } else {
-                               PHY_SetBBReg(Adapter, rOFDM0_XATxIQImbalance,
-                                            bMaskDWord,
-                                            OFDMSwingTable23A[OFDM_index[0]]);
+                               rtl8723au_write32(Adapter,
+                                                 rOFDM0_XATxIQImbalance,
+                                                 OFDMSwingTable23A[OFDM_index[0]]);
                                PHY_SetBBReg(Adapter, rOFDM0_XCTxAFE,
                                             bMaskH4Bits, 0x00);
                                PHY_SetBBReg(Adapter, rOFDM0_ECCAThreshold,
@@ -290,7 +291,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                                rtl8723au_write8(Adapter, 0xa29, CCKSwingTable_Ch1423A[CCK_index][7]);
                        }
 
-                       if (is2T) {
+                       if (pHalData->rf_type == RF_2T2R) {
                                ele_D = (OFDMSwingTable23A[(u8)OFDM_index[1]] & 0xFFC00000)>>22;
 
                                /* new element A = element D x X */
@@ -309,7 +310,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
 
                                        /* write new elements A, C, D to regC88 and regC9C, element B is always 0 */
                                        value32 = (ele_D<<22)|((ele_C&0x3F)<<16) | ele_A;
-                                       PHY_SetBBReg(Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord, value32);
+                                       rtl8723au_write32(Adapter, rOFDM0_XBTxIQImbalance, value32);
 
                                        value32 = (ele_C&0x000003C0)>>6;
                                        PHY_SetBBReg(Adapter, rOFDM0_XDTxAFE, bMaskH4Bits, value32);
@@ -324,10 +325,9 @@ odm_TXPowerTrackingCallback_ThermalMeter_92C(
                                                     rOFDM0_ECCAThreshold,
                                                     BIT(25), value32);
                                } else {
-                                       PHY_SetBBReg(Adapter,
-                                                    rOFDM0_XBTxIQImbalance,
-                                                    bMaskDWord,
-                                                    OFDMSwingTable23A[OFDM_index[1]]);
+                                       rtl8723au_write32(Adapter,
+                                                         rOFDM0_XBTxIQImbalance,
+                                                         OFDMSwingTable23A[OFDM_index[1]]);
                                        PHY_SetBBReg(Adapter,
                                                     rOFDM0_XDTxAFE,
                                                     bMaskH4Bits, 0x00);
@@ -361,14 +361,10 @@ static void ODM_TXPowerTracking92CDirectCall(struct rtw_adapter *Adapter)
        odm_TXPowerTrackingCallback_ThermalMeter_92C(Adapter);
 }
 
-static void odm_CheckTXPowerTracking_ThermalMeter(struct rtw_adapter *Adapter)
+void rtl8723a_odm_check_tx_power_tracking(struct rtw_adapter *Adapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       struct dm_odm_t *podmpriv = &pHalData->odmpriv;
-
-       if (!(podmpriv->SupportAbility & ODM_RF_TX_PWR_TRACK))
-               return;
 
        if (!pdmpriv->TM_Trigger) {             /* at least delay 1 sec */
                PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60);
@@ -381,11 +377,6 @@ static void odm_CheckTXPowerTracking_ThermalMeter(struct rtw_adapter *Adapter)
        }
 }
 
-void rtl8723a_odm_check_tx_power_tracking(struct rtw_adapter *Adapter)
-{
-       odm_CheckTXPowerTracking_ThermalMeter(Adapter);
-}
-
 /*     IQK */
 #define MAX_TOLERANCE          5
 #define IQK_DELAY_TIME         1       /* ms */
@@ -397,36 +388,37 @@ static u8 _PHY_PathA_IQK(struct rtw_adapter *pAdapter, bool configPathB)
        struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter);
 
        /* path-A IQK setting */
-       PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1f);
-       PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f);
-       PHY_SetBBReg(pAdapter, rTx_IQK_PI_A, bMaskDWord, 0x82140102);
+       rtl8723au_write32(pAdapter, rTx_IQK_Tone_A, 0x10008c1f);
+       rtl8723au_write32(pAdapter, rRx_IQK_Tone_A, 0x10008c1f);
+       rtl8723au_write32(pAdapter, rTx_IQK_PI_A, 0x82140102);
 
-       PHY_SetBBReg(pAdapter, rRx_IQK_PI_A, bMaskDWord, configPathB ? 0x28160202 :
+       rtl8723au_write32(pAdapter, rRx_IQK_PI_A, configPathB ? 0x28160202 :
                IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)?0x28160202:0x28160502);
 
        /* path-B IQK setting */
        if (configPathB) {
-               PHY_SetBBReg(pAdapter, rTx_IQK_Tone_B, bMaskDWord, 0x10008c22);
-               PHY_SetBBReg(pAdapter, rRx_IQK_Tone_B, bMaskDWord, 0x10008c22);
-               PHY_SetBBReg(pAdapter, rTx_IQK_PI_B, bMaskDWord, 0x82140102);
-               PHY_SetBBReg(pAdapter, rRx_IQK_PI_B, bMaskDWord, 0x28160202);
+               rtl8723au_write32(pAdapter, rTx_IQK_Tone_B, 0x10008c22);
+               rtl8723au_write32(pAdapter, rRx_IQK_Tone_B, 0x10008c22);
+               rtl8723au_write32(pAdapter, rTx_IQK_PI_B, 0x82140102);
+               rtl8723au_write32(pAdapter, rRx_IQK_PI_B, 0x28160202);
        }
 
        /* LO calibration setting */
-       PHY_SetBBReg(pAdapter, rIQK_AGC_Rsp, bMaskDWord, 0x001028d1);
+       rtl8723au_write32(pAdapter, rIQK_AGC_Rsp, 0x001028d1);
 
        /* One shot, path A LOK & IQK */
-       PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf9000000);
-       PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
+       rtl8723au_write32(pAdapter, rIQK_AGC_Pts, 0xf9000000);
+       rtl8723au_write32(pAdapter, rIQK_AGC_Pts, 0xf8000000);
 
        /*  delay x ms */
-       udelay(IQK_DELAY_TIME*1000);/* PlatformStallExecution(IQK_DELAY_TIME*1000); */
+       /* PlatformStallExecution(IQK_DELAY_TIME*1000); */
+       udelay(IQK_DELAY_TIME*1000);
 
        /*  Check failed */
-       regEAC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord);
-       regE94 = PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord);
-       regE9C = PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord);
-       regEA4 = PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord);
+       regEAC = rtl8723au_read32(pAdapter, rRx_Power_After_IQK_A_2);
+       regE94 = rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_A);
+       regE9C = rtl8723au_read32(pAdapter, rTx_Power_After_IQK_A);
+       regEA4 = rtl8723au_read32(pAdapter, rRx_Power_Before_IQK_A_2);
 
        if (!(regEAC & BIT(28)) &&
            (((regE94 & 0x03FF0000)>>16) != 0x142) &&
@@ -435,7 +427,7 @@ static u8 _PHY_PathA_IQK(struct rtw_adapter *pAdapter, bool configPathB)
        else                    /* if Tx not OK, ignore Rx */
                return result;
 
-       if (!(regEAC & BIT(27)) &&              /* if Tx is OK, check whether Rx is OK */
+       if (!(regEAC & BIT(27)) && /* if Tx is OK, check whether Rx is OK */
            (((regEA4 & 0x03FF0000)>>16) != 0x132) &&
            (((regEAC & 0x03FF0000)>>16) != 0x36))
                result |= 0x02;
@@ -450,18 +442,18 @@ static u8 _PHY_PathB_IQK(struct rtw_adapter *pAdapter)
        u8 result = 0x00;
 
        /* One shot, path B LOK & IQK */
-       PHY_SetBBReg(pAdapter, rIQK_AGC_Cont, bMaskDWord, 0x00000002);
-       PHY_SetBBReg(pAdapter, rIQK_AGC_Cont, bMaskDWord, 0x00000000);
+       rtl8723au_write32(pAdapter, rIQK_AGC_Cont, 0x00000002);
+       rtl8723au_write32(pAdapter, rIQK_AGC_Cont, 0x00000000);
 
        /*  delay x ms */
        udelay(IQK_DELAY_TIME*1000);
 
        /*  Check failed */
-       regEAC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord);
-       regEB4 = PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord);
-       regEBC = PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord);
-       regEC4 = PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_B_2, bMaskDWord);
-       regECC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_B_2, bMaskDWord);
+       regEAC = rtl8723au_read32(pAdapter, rRx_Power_After_IQK_A_2);
+       regEB4 = rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_B);
+       regEBC = rtl8723au_read32(pAdapter, rTx_Power_After_IQK_B);
+       regEC4 = rtl8723au_read32(pAdapter, rRx_Power_Before_IQK_B_2);
+       regECC = rtl8723au_read32(pAdapter, rRx_Power_After_IQK_B_2);
 
        if (!(regEAC & BIT(31)) &&
            (((regEB4 & 0x03FF0000)>>16) != 0x142) &&
@@ -494,22 +486,27 @@ static void _PHY_PathAFillIQKMatrix(struct rtw_adapter *pAdapter,
        if (final_candidate == 0xFF) {
                return;
        } else if (bIQKOK) {
-               Oldval_0 = (PHY_QueryBBReg(pAdapter, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF;
+               Oldval_0 = rtl8723au_read32(pAdapter, rOFDM0_XATxIQImbalance);
+               Oldval_0 = (Oldval_0 >> 22) & 0x3FF;
 
                X = result[final_candidate][0];
                if ((X & 0x00000200) != 0)
                        X = X | 0xFFFFFC00;
                TX0_A = (X * Oldval_0) >> 8;
                PHY_SetBBReg(pAdapter, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A);
-               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1));
+               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(31),
+                            ((X * Oldval_0>>7) & 0x1));
 
                Y = result[final_candidate][1];
                if ((Y & 0x00000200) != 0)
                        Y = Y | 0xFFFFFC00;
                TX0_C = (Y * Oldval_0) >> 8;
-               PHY_SetBBReg(pAdapter, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6));
-               PHY_SetBBReg(pAdapter, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F));
-               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1));
+               PHY_SetBBReg(pAdapter, rOFDM0_XCTxAFE, 0xF0000000,
+                            ((TX0_C&0x3C0)>>6));
+               PHY_SetBBReg(pAdapter, rOFDM0_XATxIQImbalance, 0x003F0000,
+                            (TX0_C&0x3F));
+               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(29),
+                            ((Y * Oldval_0>>7) & 0x1));
 
                if (bTxOnly) {
                        DBG_8723A("_PHY_PathAFillIQKMatrix only Tx OK\n");
@@ -537,22 +534,27 @@ static void _PHY_PathBFillIQKMatrix(struct rtw_adapter *pAdapter, bool bIQKOK, i
        if (final_candidate == 0xFF) {
                return;
        } else if (bIQKOK) {
-               Oldval_1 = (PHY_QueryBBReg(pAdapter, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF;
+               Oldval_1 = rtl8723au_read32(pAdapter, rOFDM0_XBTxIQImbalance);
+               Oldval_1 = (Oldval_1 >> 22) & 0x3FF;
 
                X = result[final_candidate][4];
                if ((X & 0x00000200) != 0)
                        X = X | 0xFFFFFC00;
                TX1_A = (X * Oldval_1) >> 8;
                PHY_SetBBReg(pAdapter, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A);
-               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1));
+               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(27),
+                            ((X * Oldval_1 >> 7) & 0x1));
 
                Y = result[final_candidate][5];
                if ((Y & 0x00000200) != 0)
                        Y = Y | 0xFFFFFC00;
                TX1_C = (Y * Oldval_1) >> 8;
-               PHY_SetBBReg(pAdapter, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6));
-               PHY_SetBBReg(pAdapter, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F));
-               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1));
+               PHY_SetBBReg(pAdapter, rOFDM0_XDTxAFE, 0xF0000000,
+                            ((TX1_C & 0x3C0) >> 6));
+               PHY_SetBBReg(pAdapter, rOFDM0_XBTxIQImbalance, 0x003F0000,
+                            (TX1_C & 0x3F));
+               PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(25),
+                            ((Y * Oldval_1 >> 7) & 0x1));
 
                if (bTxOnly)
                        return;
@@ -573,11 +575,12 @@ static void _PHY_SaveADDARegisters(struct rtw_adapter *pAdapter, u32 *ADDAReg, u
        u32 i;
 
        for (i = 0 ; i < RegisterNum ; i++) {
-               ADDABackup[i] = PHY_QueryBBReg(pAdapter, ADDAReg[i], bMaskDWord);
+               ADDABackup[i] = rtl8723au_read32(pAdapter, ADDAReg[i]);
        }
 }
 
-static void _PHY_SaveMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u32 *MACBackup)
+static void _PHY_SaveMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg,
+                                 u32 *MACBackup)
 {
        u32 i;
 
@@ -587,16 +590,19 @@ static void _PHY_SaveMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u32
        MACBackup[i] = rtl8723au_read32(pAdapter, MACReg[i]);
 }
 
-static void _PHY_ReloadADDARegisters(struct rtw_adapter *pAdapter, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum)
+static void _PHY_ReloadADDARegisters(struct rtw_adapter *pAdapter,
+                                    u32 *ADDAReg, u32 *ADDABackup,
+                                    u32 RegiesterNum)
 {
        u32 i;
 
        for (i = 0 ; i < RegiesterNum ; i++) {
-               PHY_SetBBReg(pAdapter, ADDAReg[i], bMaskDWord, ADDABackup[i]);
+               rtl8723au_write32(pAdapter, ADDAReg[i], ADDABackup[i]);
        }
 }
 
-static void _PHY_ReloadMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u32 *MACBackup)
+static void _PHY_ReloadMACRegisters(struct rtw_adapter *pAdapter,
+                                   u32 *MACReg, u32 *MACBackup)
 {
        u32 i;
 
@@ -606,7 +612,8 @@ static void _PHY_ReloadMACRegisters(struct rtw_adapter *pAdapter, u32 *MACReg, u
        rtl8723au_write32(pAdapter, MACReg[i], MACBackup[i]);
 }
 
-static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg, bool isPathAOn, bool is2T)
+static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg,
+                           bool isPathAOn, bool is2T)
 {
        u32 pathOn;
        u32 i;
@@ -614,16 +621,17 @@ static void _PHY_PathADDAOn(struct rtw_adapter *pAdapter, u32 *ADDAReg, bool isP
        pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4;
        if (!is2T) {
                pathOn = 0x0bdb25a0;
-               PHY_SetBBReg(pAdapter, ADDAReg[0], bMaskDWord, 0x0b1b25a0);
+               rtl8723au_write32(pAdapter, ADDAReg[0], 0x0b1b25a0);
        } else {
-               PHY_SetBBReg(pAdapter, ADDAReg[0], bMaskDWord, pathOn);
+               rtl8723au_write32(pAdapter, ADDAReg[0], pathOn);
        }
 
        for (i = 1 ; i < IQK_ADDA_REG_NUM ; i++)
-               PHY_SetBBReg(pAdapter, ADDAReg[i], bMaskDWord, pathOn);
+               rtl8723au_write32(pAdapter, ADDAReg[i], pathOn);
 }
 
-static void _PHY_MACSettingCalibration(struct rtw_adapter *pAdapter, u32 *MACReg, u32 *MACBackup)
+static void _PHY_MACSettingCalibration(struct rtw_adapter *pAdapter,
+                                      u32 *MACReg, u32 *MACBackup)
 {
        u32 i = 0;
 
@@ -638,9 +646,9 @@ static void _PHY_MACSettingCalibration(struct rtw_adapter *pAdapter, u32 *MACReg
 
 static void _PHY_PathAStandBy(struct rtw_adapter *pAdapter)
 {
-       PHY_SetBBReg(pAdapter, rFPGA0_IQK, bMaskDWord, 0x0);
-       PHY_SetBBReg(pAdapter, 0x840, bMaskDWord, 0x00010000);
-       PHY_SetBBReg(pAdapter, rFPGA0_IQK, bMaskDWord, 0x80800000);
+       rtl8723au_write32(pAdapter, rFPGA0_IQK, 0x0);
+       rtl8723au_write32(pAdapter, 0x840, 0x00010000);
+       rtl8723au_write32(pAdapter, rFPGA0_IQK, 0x80800000);
 }
 
 static void _PHY_PIModeSwitch(struct rtw_adapter *pAdapter, bool PIMode)
@@ -648,8 +656,8 @@ static void _PHY_PIModeSwitch(struct rtw_adapter *pAdapter, bool PIMode)
        u32 mode;
 
        mode = PIMode ? 0x01000100 : 0x01000000;
-       PHY_SetBBReg(pAdapter, 0x820, bMaskDWord, mode);
-       PHY_SetBBReg(pAdapter, 0x828, bMaskDWord, mode);
+       rtl8723au_write32(pAdapter, 0x820, mode);
+       rtl8723au_write32(pAdapter, 0x828, mode);
 }
 
 /*
@@ -660,9 +668,9 @@ static bool _PHY_SimularityCompare(struct rtw_adapter *pAdapter, int result[][8]
        u32 i, j, diff, SimularityBitMap, bound = 0;
        struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter);
        u8 final_candidate[2] = {0xFF, 0xFF};   /* for path A and path B */
-       bool bResult = true, is2T = IS_92C_SERIAL(pHalData->VersionID);
+       bool bResult = true;
 
-       if (is2T)
+       if (pHalData->rf_type == RF_2T2R)
                bound = 8;
        else
                bound = 4;
@@ -699,7 +707,7 @@ static bool _PHY_SimularityCompare(struct rtw_adapter *pAdapter, int result[][8]
                for (i = 0; i < 4; i++)
                        result[3][i] = result[c1][i];
                return false;
-       } else if (!(SimularityBitMap & 0xF0) && is2T) {
+       } else if (!(SimularityBitMap & 0xF0) && pHalData->rf_type == RF_2T2R) {
                /* path B OK */
                for (i = 4; i < 8; i++)
                        result[3][i] = result[c1][i];
@@ -746,7 +754,7 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t
        u32 bbvalue;
 
        if (t == 0) {
-               bbvalue = PHY_QueryBBReg(pAdapter, rFPGA0_RFMOD, bMaskDWord);
+               bbvalue = rtl8723au_read32(pAdapter, rFPGA0_RFMOD);
 
                /*  Save ADDA parameters, turn Path A ADDA on */
                _PHY_SaveADDARegisters(pAdapter, ADDA_REG, pdmpriv->ADDA_backup, IQK_ADDA_REG_NUM);
@@ -766,48 +774,50 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t
        }
 
        PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, BIT(24), 0x00);
-       PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600);
-       PHY_SetBBReg(pAdapter, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4);
-       PHY_SetBBReg(pAdapter, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000);
+       rtl8723au_write32(pAdapter, rOFDM0_TRxPathEnable, 0x03a05600);
+       rtl8723au_write32(pAdapter, rOFDM0_TRMuxPar, 0x000800e4);
+       rtl8723au_write32(pAdapter, rFPGA0_XCD_RFInterfaceSW, 0x22204000);
        PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0x01);
        PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0x01);
        PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00);
        PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00);
 
        if (is2T) {
-               PHY_SetBBReg(pAdapter, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000);
-               PHY_SetBBReg(pAdapter, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00010000);
+               rtl8723au_write32(pAdapter,
+                                 rFPGA0_XA_LSSIParameter, 0x00010000);
+               rtl8723au_write32(pAdapter,
+                                 rFPGA0_XB_LSSIParameter, 0x00010000);
        }
 
        /* MAC settings */
        _PHY_MACSettingCalibration(pAdapter, IQK_MAC_REG, pdmpriv->IQK_MAC_backup);
 
        /* Page B init */
-       PHY_SetBBReg(pAdapter, rConfig_AntA, bMaskDWord, 0x00080000);
+       rtl8723au_write32(pAdapter, rConfig_AntA, 0x00080000);
 
        if (is2T)
-               PHY_SetBBReg(pAdapter, rConfig_AntB, bMaskDWord, 0x00080000);
+               rtl8723au_write32(pAdapter, rConfig_AntB, 0x00080000);
 
        /*  IQ calibration setting */
-       PHY_SetBBReg(pAdapter, rFPGA0_IQK, bMaskDWord, 0x80800000);
-       PHY_SetBBReg(pAdapter, rTx_IQK, bMaskDWord, 0x01007c00);
-       PHY_SetBBReg(pAdapter, rRx_IQK, bMaskDWord, 0x01004800);
+       rtl8723au_write32(pAdapter, rFPGA0_IQK, 0x80800000);
+       rtl8723au_write32(pAdapter, rTx_IQK, 0x01007c00);
+       rtl8723au_write32(pAdapter, rRx_IQK, 0x01004800);
 
        for (i = 0 ; i < retryCount ; i++) {
                PathAOK = _PHY_PathA_IQK(pAdapter, is2T);
                if (PathAOK == 0x03) {
                                DBG_8723A("Path A IQK Success!!\n");
-                               result[t][0] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][1] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][2] = (PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][3] = (PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16;
+                               result[t][0] = (rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_A)&0x3FF0000)>>16;
+                               result[t][1] = (rtl8723au_read32(pAdapter, rTx_Power_After_IQK_A)&0x3FF0000)>>16;
+                               result[t][2] = (rtl8723au_read32(pAdapter, rRx_Power_Before_IQK_A_2)&0x3FF0000)>>16;
+                               result[t][3] = (rtl8723au_read32(pAdapter, rRx_Power_After_IQK_A_2)&0x3FF0000)>>16;
                        break;
                } else if (i == (retryCount-1) && PathAOK == 0x01) {
                        /* Tx IQK OK */
                        DBG_8723A("Path A IQK Only  Tx Success!!\n");
 
-                       result[t][0] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16;
-                       result[t][1] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16;
+                       result[t][0] = (rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_A)&0x3FF0000)>>16;
+                       result[t][1] = (rtl8723au_read32(pAdapter, rTx_Power_After_IQK_A)&0x3FF0000)>>16;
                }
        }
 
@@ -825,16 +835,16 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t
                        PathBOK = _PHY_PathB_IQK(pAdapter);
                        if (PathBOK == 0x03) {
                                DBG_8723A("Path B IQK Success!!\n");
-                               result[t][4] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][5] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][6] = (PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][7] = (PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16;
+                               result[t][4] = (rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_B)&0x3FF0000)>>16;
+                               result[t][5] = (rtl8723au_read32(pAdapter, rTx_Power_After_IQK_B)&0x3FF0000)>>16;
+                               result[t][6] = (rtl8723au_read32(pAdapter, rRx_Power_Before_IQK_B_2)&0x3FF0000)>>16;
+                               result[t][7] = (rtl8723au_read32(pAdapter, rRx_Power_After_IQK_B_2)&0x3FF0000)>>16;
                                break;
                        } else if (i == (retryCount - 1) && PathBOK == 0x01) {
                                /* Tx IQK OK */
                                DBG_8723A("Path B Only Tx IQK Success!!\n");
-                               result[t][4] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16;
-                               result[t][5] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16;
+                               result[t][4] = (rtl8723au_read32(pAdapter, rTx_Power_Before_IQK_B)&0x3FF0000)>>16;
+                               result[t][5] = (rtl8723au_read32(pAdapter, rTx_Power_After_IQK_B)&0x3FF0000)>>16;
                        }
                }
 
@@ -844,7 +854,7 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t
        }
 
        /* Back to BB mode, load original value */
-       PHY_SetBBReg(pAdapter, rFPGA0_IQK, bMaskDWord, 0);
+       rtl8723au_write32(pAdapter, rFPGA0_IQK, 0);
 
        if (t != 0) {
                if (!pdmpriv->bRfPiEnable) {
@@ -862,14 +872,16 @@ static void _PHY_IQCalibrate(struct rtw_adapter *pAdapter, int result[][8], u8 t
                _PHY_ReloadADDARegisters(pAdapter, IQK_BB_REG_92C, pdmpriv->IQK_BB_backup, IQK_BB_REG_NUM);
 
                /*  Restore RX initial gain */
-               PHY_SetBBReg(pAdapter, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3);
+               rtl8723au_write32(pAdapter,
+                                 rFPGA0_XA_LSSIParameter, 0x00032ed3);
                if (is2T) {
-                       PHY_SetBBReg(pAdapter, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00032ed3);
+                       rtl8723au_write32(pAdapter,
+                                         rFPGA0_XB_LSSIParameter, 0x00032ed3);
                }
 
                /* load 0xe30 IQC default value */
-               PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00);
-               PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00);
+               rtl8723au_write32(pAdapter, rTx_IQK_Tone_A, 0x01008c00);
+               rtl8723au_write32(pAdapter, rRx_IQK_Tone_A, 0x01008c00);
 
        }
 }
@@ -980,12 +992,10 @@ void rtl8723a_phy_iq_calibrate(struct rtw_adapter *pAdapter, bool bReCovery)
        is13simular = false;
 
        for (i = 0; i < 3; i++) {
-               if (IS_92C_SERIAL(pHalData->VersionID)) {
-                        _PHY_IQCalibrate(pAdapter, result, i, true);
-               } else {
-                       /*  For 88C 1T1R */
+               if (pHalData->rf_type == RF_2T2R)
+                       _PHY_IQCalibrate(pAdapter, result, i, true);
+               else /*  For 88C 1T1R */
                        _PHY_IQCalibrate(pAdapter, result, i, false);
-               }
 
                if (i == 1) {
                        is12simular = _PHY_SimularityCompare(pAdapter, result, 0, 1);
@@ -1053,9 +1063,10 @@ void rtl8723a_phy_iq_calibrate(struct rtw_adapter *pAdapter, bool bReCovery)
        if ((RegE94 != 0)/*&&(RegEA4 != 0)*/)
                _PHY_PathAFillIQKMatrix(pAdapter, bPathAOK, result, final_candidate, (RegEA4 == 0));
 
-       if (IS_92C_SERIAL(pHalData->VersionID)) {
+       if (pHalData->rf_type == RF_2T2R) {
                if ((RegEB4 != 0)/*&&(RegEC4 != 0)*/)
-               _PHY_PathBFillIQKMatrix(pAdapter, bPathBOK, result, final_candidate, (RegEC4 == 0));
+                       _PHY_PathBFillIQKMatrix(pAdapter, bPathBOK, result,
+                                               final_candidate, (RegEC4 == 0));
        }
 
        _PHY_SaveADDARegisters(pAdapter, IQK_BB_REG_92C, pdmpriv->IQK_BB_backup_recover, 9);
@@ -1074,12 +1085,10 @@ void rtl8723a_phy_lc_calibrate(struct rtw_adapter *pAdapter)
        if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS)
                return;
 
-       if (IS_92C_SERIAL(pHalData->VersionID)) {
+       if (pHalData->rf_type == RF_2T2R)
                _PHY_LCCalibrate(pAdapter, true);
-       } else {
-               /*  For 88C 1T1R */
+       else    /*  For 88C 1T1R */
                _PHY_LCCalibrate(pAdapter, false);
-       }
 }
 
 void
index 9d4f6bed4269d1566a53e97933006a82e5e48ce8..e8cab9e97385735cf730181f8f642a7603fd332e 100644 (file)
@@ -30,12 +30,12 @@ static bool CheckCondition(const u32  Condition, const u32  Hex)
                return false;
 
        cond = Condition & 0x0000FF00;
-       cond = cond >> 8;
+       cond >>= 8;
        if ((_interface & cond) == 0 && cond != 0x07)
                return false;
 
        cond = Condition & 0x00FF0000;
-       cond = cond >> 16;
+       cond >>= 16;
        if ((_platform & cond) == 0 && cond != 0x0F)
                return false;
        return true;
@@ -215,17 +215,15 @@ static u32 Array_AGC_TAB_1T_8723A[] = {
 
 void ODM_ReadAndConfig_AGC_TAB_1T_8723A(struct dm_odm_t *pDM_Odm)
 {
-
        u32 hex;
        u32 i;
        u8 platform = 0x04;
-       u8 interfaceValue   = pDM_Odm->SupportInterface;
        u8 board = pDM_Odm->BoardType;
        u32 ArrayLen = sizeof(Array_AGC_TAB_1T_8723A)/sizeof(u32);
        u32 *Array = Array_AGC_TAB_1T_8723A;
 
        hex = board;
-       hex += interfaceValue << 8;
+       hex += ODM_ITRF_USB << 8;
        hex += platform << 16;
        hex += 0xFF000000;
        for (i = 0; i < ArrayLen; i += 2) {
@@ -234,11 +232,11 @@ void ODM_ReadAndConfig_AGC_TAB_1T_8723A(struct dm_odm_t *pDM_Odm)
 
                /*  This (offset, data) pair meets the condition. */
                if (v1 < 0xCDCDCDCD) {
-                       odm_ConfigBB_AGC_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                       odm_ConfigBB_AGC_8723A(pDM_Odm, v1, v2);
                        continue;
                } else {
                        if (!CheckCondition(Array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
+                               /* Discard the following (offset, data) pairs */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
@@ -246,12 +244,13 @@ void ODM_ReadAndConfig_AGC_TAB_1T_8723A(struct dm_odm_t *pDM_Odm)
                                        READ_NEXT_PAIR(v1, v2, i);
                                i -= 2; /*  prevent from for-loop += 2 */
                        } else {
-                               /*  Configure matched pairs and skip to end of if-else. */
+                               /*  Configure matched pairs and skip to
+                                   end of if-else. */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
                                       v2 != 0xCDCD && i < ArrayLen - 2) {
-                                       odm_ConfigBB_AGC_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                                       odm_ConfigBB_AGC_8723A(pDM_Odm, v1, v2);
                                        READ_NEXT_PAIR(v1, v2, i);
                                }
                                while (v2 != 0xDEAD && i < ArrayLen - 2)
@@ -467,13 +466,12 @@ void ODM_ReadAndConfig_PHY_REG_1T_8723A(struct dm_odm_t *pDM_Odm)
        u32 hex = 0;
        u32 i = 0;
        u8  platform = 0x04;
-       u8  interfaceValue = pDM_Odm->SupportInterface;
        u8  board = pDM_Odm->BoardType;
        u32 ArrayLen = sizeof(Array_PHY_REG_1T_8723A)/sizeof(u32);
        u32 *Array = Array_PHY_REG_1T_8723A;
 
        hex += board;
-       hex += interfaceValue << 8;
+       hex += ODM_ITRF_USB << 8;
        hex += platform << 16;
        hex += 0xFF000000;
        for (i = 0; i < ArrayLen; i += 2) {
@@ -482,11 +480,11 @@ void ODM_ReadAndConfig_PHY_REG_1T_8723A(struct dm_odm_t *pDM_Odm)
 
                /*  This (offset, data) pair meets the condition. */
                if (v1 < 0xCDCDCDCD) {
-                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, v2);
                        continue;
                } else {
                        if (!CheckCondition(Array[i], hex)) {
-                               /*  Discard the following (offset, data) pairs. */
+                               /* Discard the following (offset, data) pairs */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
@@ -494,12 +492,13 @@ void ODM_ReadAndConfig_PHY_REG_1T_8723A(struct dm_odm_t *pDM_Odm)
                                        READ_NEXT_PAIR(v1, v2, i);
                                i -= 2; /*  prevent from for-loop += 2 */
                        } else {
-                               /*  Configure matched pairs and skip to end of if-else. */
+                               /*  Configure matched pairs and skip to
+                                   end of if-else. */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
                                       v2 != 0xCDCD && i < ArrayLen - 2) {
-                                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, v2);
                                        READ_NEXT_PAIR(v1, v2, i);
                                }
                                while (v2 != 0xDEAD && i < ArrayLen - 2)
@@ -520,16 +519,15 @@ static u32 Array_PHY_REG_MP_8723A[] = {
 
 void ODM_ReadAndConfig_PHY_REG_MP_8723A(struct dm_odm_t *pDM_Odm)
 {
-       u32     hex         = 0;
-       u32     i           = 0;
-       u8     platform    = 0x04;
-       u8     interfaceValue   = pDM_Odm->SupportInterface;
-       u8     board       = pDM_Odm->BoardType;
-       u32     ArrayLen    = sizeof(Array_PHY_REG_MP_8723A)/sizeof(u32);
-       u32 *Array       = Array_PHY_REG_MP_8723A;
+       u32 hex = 0;
+       u32 i;
+       u8 platform = 0x04;
+       u8 board = pDM_Odm->BoardType;
+       u32 ArrayLen = sizeof(Array_PHY_REG_MP_8723A)/sizeof(u32);
+       u32 *Array = Array_PHY_REG_MP_8723A;
 
        hex += board;
-       hex += interfaceValue << 8;
+       hex += ODM_ITRF_USB << 8;
        hex += platform << 16;
        hex += 0xFF000000;
        for (i = 0; i < ArrayLen; i += 2) {
@@ -538,11 +536,11 @@ void ODM_ReadAndConfig_PHY_REG_MP_8723A(struct dm_odm_t *pDM_Odm)
 
                /*  This (offset, data) pair meets the condition. */
                if (v1 < 0xCDCDCDCD) {
-                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, v2);
                        continue;
                } else {
                        if (!CheckCondition(Array[i], hex)) {
-                               /* Discard the following (offset, data) pairs. */
+                               /* Discard the following (offset, data) pairs */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
@@ -550,12 +548,13 @@ void ODM_ReadAndConfig_PHY_REG_MP_8723A(struct dm_odm_t *pDM_Odm)
                                        READ_NEXT_PAIR(v1, v2, i);
                                i -= 2; /*  prevent from for-loop += 2 */
                        } else {
-                               /* Configure matched pairs and skip to end of if-else. */
+                               /* Configure matched pairs and skip to
+                                  end of if-else. */
                                READ_NEXT_PAIR(v1, v2, i);
                                while (v2 != 0xDEAD &&
                                       v2 != 0xCDEF &&
                                       v2 != 0xCDCD && i < ArrayLen - 2) {
-                                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
+                                       odm_ConfigBB_PHY_8723A(pDM_Odm, v1, v2);
                                        READ_NEXT_PAIR(v1, v2, i);
                                }
                                while (v2 != 0xDEAD && i < ArrayLen - 2)
index 12071453be97228d7761699f829310a532aa8e6b..93b2d183d6942e9295ff9c9ba65df03815de6075 100644 (file)
@@ -30,12 +30,12 @@ static bool CheckCondition(const u32  Condition, const u32  Hex)
                return false;
 
        cond = Condition & 0x0000FF00;
-       cond = cond >> 8;
+       cond >>= 8;
        if ((_interface & cond) == 0 && cond != 0x07)
                return false;
 
        cond = Condition & 0x00FF0000;
-       cond = cond >> 16;
+       cond >>= 16;
        if ((_platform & cond) == 0 && cond != 0x0F)
                return false;
        return true;
@@ -144,13 +144,12 @@ void ODM_ReadAndConfig_MAC_REG_8723A(struct dm_odm_t *pDM_Odm)
        u32     hex         = 0;
        u32     i           = 0;
        u8     platform    = 0x04;
-       u8     interfaceValue   = pDM_Odm->SupportInterface;
        u8     board       = pDM_Odm->BoardType;
        u32     ArrayLen    = sizeof(Array_MAC_REG_8723A)/sizeof(u32);
        u32 *Array       = Array_MAC_REG_8723A;
 
        hex += board;
-       hex += interfaceValue << 8;
+       hex += ODM_ITRF_USB << 8;
        hex += platform << 16;
        hex += 0xFF000000;
        for (i = 0; i < ArrayLen; i += 2) {
index 00480f5fcdab251ca353cd3864c6696dc1e3a9d9..dbf571e8b908599d2cb138ccc6879e4d2610019f 100644 (file)
@@ -30,12 +30,12 @@ static bool CheckCondition(const u32  Condition, const u32  Hex)
                return false;
 
        cond = Condition & 0x0000FF00;
-       cond = cond >> 8;
+       cond >>= 8;
        if ((_interface & cond) == 0 && cond != 0x07)
                return false;
 
        cond = Condition & 0x00FF0000;
-       cond = cond >> 16;
+       cond >>= 16;
        if ((_platform & cond) == 0 && cond != 0x0F)
                return false;
        return true;
@@ -214,13 +214,12 @@ void ODM_ReadAndConfig_RadioA_1T_8723A(struct dm_odm_t *pDM_Odm)
        u32     hex         = 0;
        u32     i           = 0;
        u8     platform    = 0x04;
-       u8     interfaceValue   = pDM_Odm->SupportInterface;
        u8     board       = pDM_Odm->BoardType;
        u32     ArrayLen    = sizeof(Array_RadioA_1T_8723A)/sizeof(u32);
        u32 *Array = Array_RadioA_1T_8723A;
 
        hex += board;
-       hex += interfaceValue << 8;
+       hex += ODM_ITRF_USB << 8;
        hex += platform << 16;
        hex += 0xFF000000;
 
index 33777d2852f49c02c1d11cd71f213d7d9751a42b..2dc18560a3817c5b63eb3154bbcd7766c4fe16e7 100644 (file)
@@ -148,7 +148,6 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
                                         ("HalPwrSeqCmdParsing23a: "
                                          "PWR_CMD_END\n"));
                                return true;
-                               break;
 
                        default:
                                RT_TRACE(_module_hal_init_c_, _drv_err_,
index bf4cae20bd1273cb6673818f47af586dea685774..db7d57e2816543fd547f7c3925f1324403e98145 100644 (file)
 
 #define _HAL_INIT_C_
 
-void dump_chip_info23a(struct hal_version ChipVersion)
-{
-       int cnt = 0;
-       u8 buf[128];
-
-       cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8723A_");
-
-       cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(ChipVersion) ?
-                      "Normal_Chip" : "Test_Chip");
-       cnt += sprintf((buf + cnt), "%s_",
-                      IS_CHIP_VENDOR_TSMC(ChipVersion) ? "TSMC" : "UMC");
-       if (IS_A_CUT(ChipVersion))
-               cnt += sprintf((buf + cnt), "A_CUT_");
-       else if (IS_B_CUT(ChipVersion))
-               cnt += sprintf((buf + cnt), "B_CUT_");
-       else if (IS_C_CUT(ChipVersion))
-               cnt += sprintf((buf + cnt), "C_CUT_");
-       else if (IS_D_CUT(ChipVersion))
-               cnt += sprintf((buf + cnt), "D_CUT_");
-       else if (IS_E_CUT(ChipVersion))
-               cnt += sprintf((buf + cnt), "E_CUT_");
-       else
-               cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_",
-                              ChipVersion.CUTVersion);
-
-       if (IS_1T1R(ChipVersion))
-               cnt += sprintf((buf + cnt), "1T1R_");
-       else if (IS_1T2R(ChipVersion))
-               cnt += sprintf((buf + cnt), "1T2R_");
-       else if (IS_2T2R(ChipVersion))
-               cnt += sprintf((buf + cnt), "2T2R_");
-       else
-               cnt += sprintf((buf + cnt), "UNKNOWN_RFTYPE(%d)_",
-                              ChipVersion.RFType);
-
-       cnt += sprintf((buf + cnt), "RomVer(%d)\n", ChipVersion.ROMVer);
-
-       DBG_8723A("%s", buf);
-}
-
 #define        EEPROM_CHANNEL_PLAN_BY_HW_MASK  0x80
 
 /* return the final channel plan decision */
@@ -231,13 +191,11 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS)
        rate_index = 0;
        /*  Set RTS initial rate */
        while (brate_cfg > 0x1) {
-               brate_cfg = (brate_cfg >> 1);
+               brate_cfg >>= 1;
                rate_index++;
        }
                /*  Ziv - Check */
        rtl8723au_write8(padapter, REG_INIRTS_RATE_SEL, rate_index);
-
-       return;
 }
 
 static void _OneOutPipeMapping(struct rtw_adapter *pAdapter)
index 5269b46445f4c236ad4e04d6ea4b0dfc6a7a40f5..428b2b308f27386141c288549291212dac3865f7 100644 (file)
@@ -189,25 +189,16 @@ void odm_DynamicBBPowerSaving23a(struct dm_odm_t *pDM_Odm);
 
 /* END---------BB POWER SAVE----------------------- */
 
-void odm_RefreshRateAdaptiveMask23aCE23a(struct dm_odm_t *pDM_Odm);
-
 void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm);
 
-void odm_RSSIMonitorCheck23aCE(struct dm_odm_t *pDM_Odm);
-void odm_RSSIMonitorCheck23a(struct dm_odm_t *pDM_Odm);
+static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm);
 void odm_DynamicTxPower23a(struct dm_odm_t *pDM_Odm);
 
-void odm_RefreshRateAdaptiveMask23a(struct dm_odm_t *pDM_Odm);
-
-void ODM_TXPowerTrackingCheck23a(struct dm_odm_t *pDM_Odm);
+static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm);
 
 void odm_RateAdaptiveMaskInit23a(struct dm_odm_t *pDM_Odm);
 
-void odm_TXPowerTrackingThermalMeterInit23a(struct dm_odm_t *pDM_Odm);
-
-void odm_TXPowerTrackingInit23a(struct dm_odm_t *pDM_Odm);
-
-void odm_TXPowerTrackingCheckCE23a(struct dm_odm_t *pDM_Odm);
+static void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm);
 
 static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm);
 static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm);
@@ -216,16 +207,16 @@ static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm);
 #define        RxDefaultAnt2           0x569a
 
 bool odm_StaDefAntSel(struct dm_odm_t *pDM_Odm,
- u32 OFDM_Ant1_Cnt,
- u32 OFDM_Ant2_Cnt,
- u32 CCK_Ant1_Cnt,
- u32 CCK_Ant2_Cnt,
- u8 *pDefAnt
      u32 OFDM_Ant1_Cnt,
      u32 OFDM_Ant2_Cnt,
      u32 CCK_Ant1_Cnt,
      u32 CCK_Ant2_Cnt,
      u8 *pDefAnt
        );
 
 void odm_SetRxIdleAnt(struct dm_odm_t *pDM_Odm,
        u8 Ant,
-   bool   bDualPath
+       bool   bDualPath
 );
 
 /* 3 Export Interface */
@@ -241,7 +232,7 @@ void ODM23a_DMInit(struct dm_odm_t *pDM_Odm)
 
        odm23a_DynBBPSInit(pDM_Odm);
        odm_DynamicTxPower23aInit(pDM_Odm);
-       odm_TXPowerTrackingInit23a(pDM_Odm);
+       odm_TXPowerTrackingInit(pDM_Odm);
        ODM_EdcaTurboInit23a(pDM_Odm);
 }
 
@@ -258,7 +249,7 @@ void ODM_DMWatchdog23a(struct rtw_adapter *adapter)
        odm_CmnInfoUpdate_Debug23a(pDM_Odm);
        odm_CommonInfoSelfUpdate(pHalData);
        odm_FalseAlarmCounterStatistics23a(pDM_Odm);
-       odm_RSSIMonitorCheck23a(pDM_Odm);
+       odm_RSSIMonitorCheck(pDM_Odm);
 
        /* 8723A or 8189ES platform */
        /* NeilChen--2012--08--24-- */
@@ -277,14 +268,11 @@ void ODM_DMWatchdog23a(struct rtw_adapter *adapter)
        if (pwrctrlpriv->bpower_saving)
                return;
 
-       odm_RefreshRateAdaptiveMask23a(pDM_Odm);
+       odm_RefreshRateAdaptiveMask(pDM_Odm);
 
        odm_DynamicBBPowerSaving23a(pDM_Odm);
 
-       ODM_TXPowerTrackingCheck23a(pDM_Odm);
        odm_EdcaTurboCheck23a(pDM_Odm);
-
-       odm_dtc(pDM_Odm);
 }
 
 /*  */
@@ -302,11 +290,6 @@ void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm,
        /*  */
        switch  (CmnInfo) {
        /*  Fixed ODM value. */
-       case    ODM_CMNINFO_PLATFORM:
-               break;
-       case    ODM_CMNINFO_INTERFACE:
-               pDM_Odm->SupportInterface = (u8)Value;
-               break;
        case    ODM_CMNINFO_MP_TEST_CHIP:
                pDM_Odm->bIsMPChip = (u8)Value;
                break;
@@ -319,9 +302,6 @@ void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm,
        case    ODM_CMNINFO_FAB_VER:
                pDM_Odm->FabVersion = (u8)Value;
                break;
-       case    ODM_CMNINFO_RF_TYPE:
-               pDM_Odm->RFType = (u8)Value;
-               break;
        case    ODM_CMNINFO_BOARD_TYPE:
                pDM_Odm->BoardType = (u8)Value;
                break;
@@ -334,9 +314,6 @@ void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm,
        case    ODM_CMNINFO_EXT_TRSW:
                pDM_Odm->ExtTRSW = (u8)Value;
                break;
-       case    ODM_CMNINFO_PATCH_ID:
-               pDM_Odm->PatchID = (u8)Value;
-               break;
        case    ODM_CMNINFO_BINHCT_TEST:
                pDM_Odm->bInHctTest = (bool)Value;
                break;
@@ -351,15 +328,6 @@ void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm,
                /* do nothing */
                break;
        }
-
-       /*  */
-       /*  Tx power tracking BB swing table. */
-       /*  The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */
-       /*  */
-       pDM_Odm->BbSwingIdxOfdm                 = 12; /*  Set defalut value as index 12. */
-       pDM_Odm->BbSwingIdxOfdmCurrent  = 12;
-       pDM_Odm->BbSwingFlagOfdm                = false;
-
 }
 
 void ODM_CmnInfoPtrArrayHook23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo CmnInfo,
@@ -383,9 +351,6 @@ void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value)
 {
        /*  This init variable may be changed in run time. */
        switch  (CmnInfo) {
-       case    ODM_CMNINFO_RF_TYPE:
-               pDM_Odm->RFType = (u8)Value;
-               break;
        case    ODM_CMNINFO_WIFI_DIRECT:
                pDM_Odm->bWIFI_Direct = (bool)Value;
                break;
@@ -414,13 +379,18 @@ void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value)
 
 }
 
-void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm
-       )
+void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm)
 {
-       pDM_Odm->bCckHighPower =
-               (bool) ODM_GetBBReg(pDM_Odm, rFPGA0_XA_HSSIParameter2, BIT(9));
+       u32 val32;
+
+       val32 = rtl8723au_read32(pDM_Odm->Adapter, rFPGA0_XA_HSSIParameter2);
+       if (val32 & BIT(9))
+               pDM_Odm->bCckHighPower = true;
+       else
+               pDM_Odm->bCckHighPower = false;
+               
        pDM_Odm->RFPathRxEnable =
-               (u8) ODM_GetBBReg(pDM_Odm, rOFDM0_TRxPathEnable, 0x0F);
+               rtl8723au_read32(pDM_Odm->Adapter, rOFDM0_TRxPathEnable) & 0x0F;
 
        ODM_InitDebugSetting23a(pDM_Odm);
 }
@@ -432,15 +402,6 @@ static void odm_CommonInfoSelfUpdate(struct hal_data_8723a *pHalData)
        u8 EntryCnt = 0;
        u8 i;
 
-       if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) {
-               if (pHalData->nCur40MhzPrimeSC == 1)
-                       pDM_Odm->ControlChannel = pHalData->CurrentChannel - 2;
-               else if (pHalData->nCur40MhzPrimeSC == 2)
-                       pDM_Odm->ControlChannel = pHalData->CurrentChannel + 2;
-       } else {
-               pDM_Odm->ControlChannel = pHalData->CurrentChannel;
-       }
-
        for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
                pEntry = pDM_Odm->pODM_StaInfo[i];
                if (pEntry)
@@ -456,16 +417,13 @@ void odm_CmnInfoInit_Debug23a(struct dm_odm_t *pDM_Odm)
 {
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug23a ==>\n"));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility = 0x%x\n", pDM_Odm->SupportAbility));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface =%d\n", pDM_Odm->SupportInterface));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType = 0x%x\n", pDM_Odm->SupportICType));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion =%d\n", pDM_Odm->CutVersion));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion =%d\n", pDM_Odm->FabVersion));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType =%d\n", pDM_Odm->RFType));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType =%d\n", pDM_Odm->BoardType));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA =%d\n", pDM_Odm->ExtLNA));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA =%d\n", pDM_Odm->ExtPA));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW =%d\n", pDM_Odm->ExtTRSW));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID =%d\n", pDM_Odm->PatchID));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest =%d\n", pDM_Odm->bInHctTest));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest =%d\n", pDM_Odm->bWIFITest));
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent =%d\n", pDM_Odm->bDualMacSmartConcurrent));
@@ -481,18 +439,19 @@ void odm_CmnInfoUpdate_Debug23a(struct dm_odm_t *pDM_Odm)
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min =%d\n", pDM_Odm->RSSI_Min));
 }
 
-void ODM_Write_DIG23a(struct dm_odm_t *pDM_Odm,
-       u8 CurrentIGI
-       )
+void ODM_Write_DIG23a(struct dm_odm_t *pDM_Odm,        u8 CurrentIGI)
 {
+       struct rtw_adapter *adapter = pDM_Odm->Adapter;
        struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
-
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_REG(IGI_A, pDM_Odm) = 0x%x, ODM_BIT(IGI, pDM_Odm) = 0x%x \n",
-               ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)));
+       u32 val32;
 
        if (pDM_DigTable->CurIGValue != CurrentIGI) {
-               ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI);
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x). \n", CurrentIGI));
+               val32 = rtl8723au_read32(adapter, ODM_REG_IGI_A_11N);
+               val32 &= ~ODM_BIT_IGI_11N;
+               val32 |= CurrentIGI;
+               rtl8723au_write32(adapter, ODM_REG_IGI_A_11N, val32);
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
+                            ("CurrentIGI(0x%02x). \n", CurrentIGI));
                pDM_DigTable->CurIGValue = CurrentIGI;
        }
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
@@ -515,11 +474,10 @@ void odm_DIG23abyRSSI_LPS(struct dm_odm_t *pDM_Odm)
        CurrentIGI = CurrentIGI+RSSI_OFFSET_DIG;
        bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode;
 
-       /* ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG_LPS, ODM_DBG_LOUD, ("odm_DIG23a() ==>\n")); */
-
        /*  Using FW PS mode to make IGI */
        if (bFwCurrentInPSMode) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG23a is in LPS mode\n"));
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
+                            ("---Neil---odm_DIG23a is in LPS mode\n"));
                /* Adjust by  FA in LPS MODE */
                if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS)
                        CurrentIGI = CurrentIGI+2;
@@ -545,15 +503,17 @@ void odm_DIG23abyRSSI_LPS(struct dm_odm_t *pDM_Odm)
         else if (CurrentIGI < RSSI_Lower)
                CurrentIGI = RSSI_Lower;
 
-       ODM_Write_DIG23a(pDM_Odm, CurrentIGI);/* ODM_Write_DIG23a(pDM_Odm, pDM_DigTable->CurIGValue); */
-
+       ODM_Write_DIG23a(pDM_Odm, CurrentIGI);
 }
 
 void odm_DIG23aInit(struct dm_odm_t *pDM_Odm)
 {
        struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
+       u32 val32;
+
+       val32 = rtl8723au_read32(pDM_Odm->Adapter, ODM_REG_IGI_A_11N);
+       pDM_DigTable->CurIGValue = val32 & ODM_BIT_IGI_11N;
 
-       pDM_DigTable->CurIGValue = (u8) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm));
        pDM_DigTable->RssiLowThresh     = DM_DIG_THRESH_LOW;
        pDM_DigTable->RssiHighThresh    = DM_DIG_THRESH_HIGH;
        pDM_DigTable->FALowThresh       = DM_FALSEALARM_THRESH_LOW;
@@ -591,26 +551,22 @@ void odm_DIG23a(struct rtw_adapter *adapter)
        u8 dm_dig_max, dm_dig_min;
        u8 CurrentIGI = pDM_DigTable->CurIGValue;
 
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a() ==>\n"));
-       /* if (!(pDM_Odm->SupportAbility & (ODM_BB_DIG|ODM_BB_FA_CNT))) */
-       if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
-                            ("odm_DIG23a() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n"));
-               return;
-       }
-
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
+                    ("odm_DIG23a() ==>\n"));
        if (adapter->mlmepriv.bScanInProcess) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a() Return: In Scan Progress \n"));
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD,
+                            ("odm_DIG23a() Return: In Scan Progress \n"));
                return;
        }
 
        DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
        FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0);
-       FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0);
+       FirstDisConnect = (!pDM_Odm->bLinked) &&
+               (pDM_DigTable->bMediaConnect_0);
 
        /* 1 Boundary Decision */
        if ((pDM_Odm->SupportICType & ODM_RTL8723A) &&
-           ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) {
+           (pDM_Odm->BoardType == ODM_BOARD_HIGHPWR || pDM_Odm->ExtLNA)) {
                dm_dig_max = DM_DIG_MAX_NIC_HP;
                dm_dig_min = DM_DIG_MIN_NIC_HP;
                DIG_MaxOfMin = DM_DIG_MAX_AP_HP;
@@ -764,31 +720,29 @@ void odm_DIG23a(struct rtw_adapter *adapter)
 
 void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm)
 {
-       u32 ret_value;
+       struct rtw_adapter *adapter = pDM_Odm->Adapter;
        struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
-
-       if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))
-               return;
+       u32 ret_value, val32;
 
        /* hold ofdm counter */
-        /* hold page C counter */
-       ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1);
+       /* hold page C counter */
+       val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_HOLDC_11N);
+       val32 |= BIT(31);
+       rtl8723au_write32(adapter, ODM_REG_OFDM_FA_HOLDC_11N, val32);
        /* hold page D counter */
-       ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1);
-       ret_value =
-               ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
+       val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N);
+       val32 |= BIT(31);
+       rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32);
+       ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE1_11N);
        FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16);
-       ret_value =
-               ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
+       FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0xffff0000)>>16;
+       ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE2_11N);
        FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16);
-       ret_value =
-               ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
+       FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0xffff0000)>>16;
+       ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE3_11N);
        FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff);
-       FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16);
-       ret_value =
-               ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
+       FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0xffff0000)>>16;
+       ret_value = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_TYPE4_11N);
        FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff);
 
        FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail +
@@ -798,15 +752,16 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm)
                FalseAlmCnt->Cnt_Fast_Fsync +
                FalseAlmCnt->Cnt_SB_Search_fail;
        /* hold cck counter */
-       ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(12), 1);
-       ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(14), 1);
+       val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N);
+       val32 |= (BIT(12) | BIT(14));
+       rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32);
 
-       ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0);
+       ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_FA_LSB_11N) & 0xff;
        FalseAlmCnt->Cnt_Cck_fail = ret_value;
-       ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3);
-       FalseAlmCnt->Cnt_Cck_fail +=  (ret_value & 0xff) << 8;
+       ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_FA_MSB_11N) >> 16;
+       FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff00);
 
-       ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord);
+       ret_value = rtl8723au_read32(adapter, ODM_REG_CCK_CCA_CNT_11N);
        FalseAlmCnt->Cnt_CCK_CCA =
                ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8);
 
@@ -823,26 +778,39 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm)
 
        if (pDM_Odm->SupportICType >= ODM_RTL8723A) {
                /* reset false alarm counter registers */
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 1);
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 0);
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 1);
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 0);
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTC_11N);
+               val32 |= BIT(31);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTC_11N, val32);
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTC_11N);
+               val32 &= ~BIT(31);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTC_11N, val32);
+       
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N);
+               val32 |= BIT(27);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32);
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N);
+               val32 &= ~BIT(27);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32);
+
                /* update ofdm counter */
                 /* update page C counter */
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0);
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_HOLDC_11N);
+               val32 &= ~BIT(31);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_HOLDC_11N, val32);
+
                 /* update page D counter */
-               ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0);
+               val32 = rtl8723au_read32(adapter, ODM_REG_OFDM_FA_RSTD_11N);
+               val32 &= ~BIT(31);
+               rtl8723au_write32(adapter, ODM_REG_OFDM_FA_RSTD_11N, val32);
 
                /* reset CCK CCA counter */
-               ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N,
-                            BIT(13) | BIT(12), 0);
-               ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N,
-                            BIT(13) | BIT(12), 2);
-               /* reset CCK FA counter */
-               ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N,
-                            BIT(15) | BIT(14), 0);
-               ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N,
-                            BIT(15) | BIT(14), 2);
+               val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N);
+               val32 &= ~(BIT(12) | BIT(13) | BIT(14) | BIT(15));
+               rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32);
+
+               val32 = rtl8723au_read32(adapter, ODM_REG_CCK_FA_RST_11N);
+               val32 |= (BIT(13) | BIT(15));
+               rtl8723au_write32(adapter, ODM_REG_CCK_FA_RST_11N, val32);
        }
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
@@ -859,9 +827,12 @@ void odm_FalseAlarmCounterStatistics23a(struct dm_odm_t *pDM_Odm)
                     ("Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n",
                      FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail));
 
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+                    ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+                    ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+                    ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all));
 }
 
 /* 3 ============================================================ */
@@ -873,16 +844,13 @@ void odm_CCKPacketDetectionThresh23a(struct dm_odm_t *pDM_Odm)
        struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt;
        u8 CurCCK_CCAThres;
 
-       if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT)))
-               return;
-
        if (pDM_Odm->ExtLNA)
                return;
 
        if (pDM_Odm->bLinked) {
                if (pDM_Odm->RSSI_Min > 25) {
                        CurCCK_CCAThres = 0xcd;
-               } else if ((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10)) {
+               } else if (pDM_Odm->RSSI_Min <= 25 && pDM_Odm->RSSI_Min > 10) {
                        CurCCK_CCAThres = 0x83;
                } else {
                        if (FalseAlmCnt->Cnt_Cck_fail > 1000)
@@ -905,10 +873,10 @@ void ODM_Write_CCK_CCA_Thres23a(struct dm_odm_t *pDM_Odm, u8 CurCCK_CCAThres)
        struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 
        if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres)
-               ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres);
+               rtl8723au_write8(pDM_Odm->Adapter, ODM_REG(CCK_CCA, pDM_Odm),
+                                CurCCK_CCAThres);
        pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres;
        pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres;
-
 }
 
 /* 3 ============================================================ */
@@ -934,20 +902,19 @@ void odm_DynamicBBPowerSaving23a(struct dm_odm_t *pDM_Odm)
 void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal)
 {
        struct dynamic_pwr_sav *pDM_PSTable = &pDM_Odm->DM_PSTable;
+       struct rtw_adapter *adapter = pDM_Odm->Adapter;
+       u32 val32;
        u8 Rssi_Up_bound = 30;
        u8 Rssi_Low_bound = 25;
-       if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */
-               Rssi_Up_bound = 50;
-               Rssi_Low_bound = 45;
-       }
        if (pDM_PSTable->initialize == 0) {
 
-               pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14;
+               pDM_PSTable->Reg874 =
+                       rtl8723au_read32(adapter, 0x874) & 0x1CC000;
                pDM_PSTable->RegC70 =
-                       (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord) & BIT(3)) >>3;
-               pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24;
-               pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12;
-               /* Reg818 = PHY_QueryBBReg(pAdapter, 0x818, bMaskDWord); */
+                       rtl8723au_read32(adapter, 0xc70) & BIT(3);
+               pDM_PSTable->Reg85C =
+                       rtl8723au_read32(adapter, 0x85c) & 0xFF000000;
+               pDM_PSTable->RegA74 = rtl8723au_read32(adapter, 0xa74) & 0xF000;
                pDM_PSTable->initialize = 1;
        }
 
@@ -973,26 +940,74 @@ void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal)
 
        if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) {
                if (pDM_PSTable->CurRFState == RF_Save) {
-                       /*  <tynli_note> 8723 RSSI report will be wrong. Set 0x874[5]= 1 when enter BB power saving mode. */
+                       /*  <tynli_note> 8723 RSSI report will be wrong.
+                        * Set 0x874[5]= 1 when enter BB power saving mode. */
                        /*  Suggested by SD3 Yu-Nan. 2011.01.20. */
-                       if (pDM_Odm->SupportICType == ODM_RTL8723A)
-                               ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x1); /* Reg874[5]= 1b'1 */
-                       ODM_SetBBReg(pDM_Odm, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]= 3'b010 */
-                       ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), 0); /* RegC70[3]= 1'b0 */
-                       ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]= 0x63 */
-                       ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]= 2'b10 */
-                       ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]= 0x3 */
-                       ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); /* Reg818[28]= 1'b0 */
-                       ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x1); /* Reg818[28]= 1'b1 */
+                       /* Reg874[5]= 1b'1 */
+                       if (pDM_Odm->SupportICType == ODM_RTL8723A) {
+                               val32 = rtl8723au_read32(adapter, 0x874);
+                               val32 |= BIT(5);
+                               rtl8723au_write32(adapter, 0x874, val32);
+                       }
+                       /* Reg874[20:18]= 3'b010 */
+                       val32 = rtl8723au_read32(adapter, 0x874);
+                       val32 &= ~(BIT(18) | BIT(20));
+                       val32 |= BIT(19);
+                       rtl8723au_write32(adapter, 0x874, val32);
+                       /* RegC70[3]= 1'b0 */
+                       val32 = rtl8723au_read32(adapter, 0xc70);
+                       val32 &= ~BIT(3);
+                       rtl8723au_write32(adapter, 0xc70, val32);
+                       /* Reg85C[31:24]= 0x63 */
+                       val32 = rtl8723au_read32(adapter, 0x85c);
+                       val32 &= 0x00ffffff;
+                       val32 |= 0x63000000;
+                       rtl8723au_write32(adapter, 0x85c, val32);
+                       /* Reg874[15:14]= 2'b10 */
+                       val32 = rtl8723au_read32(adapter, 0x874);
+                       val32 &= ~BIT(14);
+                       val32 |= BIT(15);
+                       rtl8723au_write32(adapter, 0x874, val32);
+                       /* RegA75[7:4]= 0x3 */
+                       val32 = rtl8723au_read32(adapter, 0xa74);
+                       val32 &= ~(BIT(14) | BIT(15));
+                       val32 |= (BIT(12) | BIT(13));
+                       rtl8723au_write32(adapter, 0xa74, val32);
+                       /* Reg818[28]= 1'b0 */
+                       val32 = rtl8723au_read32(adapter, 0x818);
+                       val32 &= ~BIT(28);
+                       rtl8723au_write32(adapter, 0x818, val32);
+                       /* Reg818[28]= 1'b1 */
+                       val32 = rtl8723au_read32(adapter, 0x818);
+                       val32 |= BIT(28);
+                       rtl8723au_write32(adapter, 0x818, val32);
                } else {
-                       ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->Reg874);
-                       ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), pDM_PSTable->RegC70);
-                       ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C);
-                       ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74);
-                       ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0);
-
-                       if (pDM_Odm->SupportICType == ODM_RTL8723A)
-                               ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x0); /* Reg874[5]= 1b'0 */
+                       val32 = rtl8723au_read32(adapter, 0x874);
+                       val32 |= pDM_PSTable->Reg874;
+                       rtl8723au_write32(adapter, 0x874, val32);
+               
+                       val32 = rtl8723au_read32(adapter, 0xc70);
+                       val32 |= pDM_PSTable->RegC70;
+                       rtl8723au_write32(adapter, 0xc70, val32);
+
+                       val32 = rtl8723au_read32(adapter, 0x85c);
+                       val32 |= pDM_PSTable->Reg85C;
+                       rtl8723au_write32(adapter, 0x85c, val32);
+
+                       val32 = rtl8723au_read32(adapter, 0xa74);
+                       val32 |= pDM_PSTable->RegA74;
+                       rtl8723au_write32(adapter, 0xa74, val32);
+
+                       val32 = rtl8723au_read32(adapter, 0x818);
+                       val32 &= ~BIT(28);
+                       rtl8723au_write32(adapter, 0x818, val32);
+
+                       /* Reg874[5]= 1b'0 */
+                       if (pDM_Odm->SupportICType == ODM_RTL8723A) {
+                               val32 = rtl8723au_read32(adapter, 0x874);
+                               val32 &= ~BIT(5);
+                               rtl8723au_write32(adapter, 0x874, val32);
+                       }
                }
                pDM_PSTable->PreRFState = pDM_PSTable->CurRFState;
        }
@@ -1010,10 +1025,6 @@ void odm_RateAdaptiveMaskInit23a(struct dm_odm_t *pDM_Odm)
        struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive;
 
        pOdmRA->Type = DM_Type_ByDriver;
-       if (pOdmRA->Type == DM_Type_ByDriver)
-               pDM_Odm->bUseRAMask = true;
-       else
-               pDM_Odm->bUseRAMask = false;
 
        pOdmRA->RATRState = DM_RATR_STA_INIT;
        pOdmRA->HighRSSIThresh = 50;
@@ -1057,7 +1068,8 @@ u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid,
                break;
        case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
        case (ODM_WM_A|ODM_WM_B|ODM_WM_G|ODM_WM_N24G):
-               if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) {
+               if (pHalData->rf_type == RF_1T2R ||
+                   pHalData->rf_type == RF_1T1R) {
                        if (rssi_level == DM_RATR_STA_HIGH) {
                                rate_bitmap = 0x000f0000;
                        } else if (rssi_level == DM_RATR_STA_MIDDLE) {
@@ -1086,22 +1098,22 @@ u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid,
        default:
                /* case WIRELESS_11_24N: */
                /* case WIRELESS_11_5N: */
-               if (pDM_Odm->RFType == RF_1T2R)
+               if (pHalData->rf_type == RF_1T2R)
                        rate_bitmap = 0x000fffff;
                else
                        rate_bitmap = 0x0fffffff;
                break;
        }
 
-       /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", __func__, rssi_level, WirelessMode, rate_bitmap); */
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n", rssi_level, WirelessMode, rate_bitmap));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD,
+       (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n",
+        rssi_level, WirelessMode, rate_bitmap));
 
        return rate_bitmap;
-
 }
 
 /*-----------------------------------------------------------------------------
- * Function:   odm_RefreshRateAdaptiveMask23a()
+ * Function:   odm_RefreshRateAdaptiveMask()
  *
  * Overview:   Update rate table mask according to rssi
  *
@@ -1116,51 +1128,35 @@ u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid,
  *05/27/2009   hpfan   Create Version 0.
  *
  *---------------------------------------------------------------------------*/
-void odm_RefreshRateAdaptiveMask23a(struct dm_odm_t *pDM_Odm)
-{
-       if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK))
-               return;
-       /*  */
-       /*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
-       /*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
-       /*  HW dynamic mechanism. */
-       /*  */
-       odm_RefreshRateAdaptiveMask23aCE23a(pDM_Odm);
-}
-
-void odm_RefreshRateAdaptiveMask23aCE23a(struct dm_odm_t *pDM_Odm)
+static void odm_RefreshRateAdaptiveMask(struct dm_odm_t *pDM_Odm)
 {
+       struct rtw_adapter *pAdapter = pDM_Odm->Adapter;
+       u32 smoothed;
        u8 i;
-       struct rtw_adapter *pAdapter     =  pDM_Odm->Adapter;
 
        if (pAdapter->bDriverStopped) {
                ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE,
-                            ("<---- odm_RefreshRateAdaptiveMask23a(): driver is going to unload\n"));
+                            ("<---- %s: driver is going to unload\n",
+                             __func__));
                return;
        }
 
-       if (!pDM_Odm->bUseRAMask) {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD,
-                            ("<---- odm_RefreshRateAdaptiveMask23a(): driver does not control rate adaptive mask\n"));
-               return;
-       }
-
-       /* printk("==> %s \n", __func__); */
-
        for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
                struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i];
                if (pstat) {
-                       if (ODM_RAStateCheck23a(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD,
+                       smoothed = pstat->rssi_stat.UndecoratedSmoothedPWDB;
+                       if (ODM_RAStateCheck23a(pDM_Odm, smoothed, false,
+                                               &pstat->rssi_level)) {
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK,
+                                            ODM_DBG_LOUD,
                                             ("RSSI:%d, RSSI_LEVEL:%d\n",
-                                            pstat->rssi_stat.UndecoratedSmoothedPWDB,
-                                            pstat->rssi_level));
-                               rtw_hal_update_ra_mask23a(pstat, pstat->rssi_level);
+                                             smoothed,
+                                             pstat->rssi_level));
+                               rtw_hal_update_ra_mask23a(pstat,
+                                                         pstat->rssi_level);
                        }
-
                }
        }
-
 }
 
 /*  Return Value: bool */
@@ -1189,7 +1185,8 @@ bool ODM_RAStateCheck23a(struct dm_odm_t *pDM_Odm, s32 RSSI, bool bForceUpdate,
                LowRSSIThreshForRA += GoUpGap;
                break;
        default:
-               ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState));
+               ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !",
+                                              *pRATRState));
                break;
        }
 
@@ -1227,24 +1224,8 @@ void odm_DynamicTxPower23aInit(struct dm_odm_t *pDM_Odm)
        pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
 }
 
-void odm_RSSIMonitorCheck23a(struct dm_odm_t *pDM_Odm)
-{
-       /*  For AP/ADSL use struct rtl8723a_priv * */
-       /*  For CE/NIC use struct rtw_adapter * */
-
-       if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
-               return;
-
-       /*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
-       /*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
-       /*  HW dynamic mechanism. */
-       odm_RSSIMonitorCheck23aCE(pDM_Odm);
-}      /*  odm_RSSIMonitorCheck23a */
-
 static void
-FindMinimumRSSI(
-       struct rtw_adapter *pAdapter
-       )
+FindMinimumRSSI(struct rtw_adapter *pAdapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter);
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
@@ -1252,21 +1233,22 @@ FindMinimumRSSI(
 
        /* 1 1.Determine the minimum RSSI */
 
-       if ((!pDM_Odm->bLinked) &&
-           (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0))
+       if (!pDM_Odm->bLinked && !pdmpriv->EntryMinUndecoratedSmoothedPWDB)
                pdmpriv->MinUndecoratedPWDBForDM = 0;
        else
-               pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
+               pdmpriv->MinUndecoratedPWDBForDM =
+                       pdmpriv->EntryMinUndecoratedSmoothedPWDB;
 }
 
-void odm_RSSIMonitorCheck23aCE(struct dm_odm_t *pDM_Odm)
+static void odm_RSSIMonitorCheck(struct dm_odm_t *pDM_Odm)
 {
        struct rtw_adapter *Adapter = pDM_Odm->Adapter;
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
        struct dm_priv *pdmpriv = &pHalData->dmpriv;
-       int     i;
-       int     tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff;
+       int i;
+       int MaxDB = 0, MinDB = 0xff;
        u8 sta_cnt = 0;
+       u32 tmpdb;
        u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */
        struct sta_info *psta;
 
@@ -1276,37 +1258,36 @@ void odm_RSSIMonitorCheck23aCE(struct dm_odm_t *pDM_Odm)
        for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
                psta = pDM_Odm->pODM_StaInfo[i];
                if (psta) {
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
-                               tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+                       if (psta->rssi_stat.UndecoratedSmoothedPWDB < MinDB)
+                               MinDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
 
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
-                               tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
+                       if (psta->rssi_stat.UndecoratedSmoothedPWDB > MaxDB)
+                               MaxDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
 
-                       if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1))
-                               PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16));
+                       if (psta->rssi_stat.UndecoratedSmoothedPWDB != -1) {
+                               tmpdb = psta->rssi_stat.UndecoratedSmoothedPWDB;
+                               PWDB_rssi[sta_cnt++] = psta->mac_id |
+                                       (tmpdb << 16);
+                       }
                }
        }
 
        for (i = 0; i < sta_cnt; i++) {
-               if (PWDB_rssi[i] != (0)) {
-                       if (pHalData->fw_ractrl) /*  Report every sta's RSSI to FW */
-                               rtl8723a_set_rssi_cmd(Adapter, (u8 *)&PWDB_rssi[i]);
-               }
+               if (PWDB_rssi[i] != (0))
+                       rtl8723a_set_rssi_cmd(Adapter, (u8 *)&PWDB_rssi[i]);
        }
 
-       if (tmpEntryMaxPWDB != 0)       /*  If associated entry is found */
-               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
-       else
-               pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
+       pdmpriv->EntryMaxUndecoratedSmoothedPWDB = MaxDB;
 
-       if (tmpEntryMinPWDB != 0xff) /*  If associated entry is found */
-               pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
+       if (MinDB != 0xff) /*  If associated entry is found */
+               pdmpriv->EntryMinUndecoratedSmoothedPWDB = MinDB;
        else
                pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
 
        FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */
 
-       ODM_CmnInfoUpdate23a(&pHalData->odmpriv, ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM);
+       ODM_CmnInfoUpdate23a(&pHalData->odmpriv, ODM_CMNINFO_RSSI_MIN,
+                            pdmpriv->MinUndecoratedPWDBForDM);
 }
 
 /* endif */
@@ -1314,12 +1295,7 @@ void odm_RSSIMonitorCheck23aCE(struct dm_odm_t *pDM_Odm)
 /* 3 Tx Power Tracking */
 /* 3 ============================================================ */
 
-void odm_TXPowerTrackingInit23a(struct dm_odm_t *pDM_Odm)
-{
-       odm_TXPowerTrackingThermalMeterInit23a(pDM_Odm);
-}
-
-void odm_TXPowerTrackingThermalMeterInit23a(struct dm_odm_t *pDM_Odm)
+static void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm)
 {
        struct rtw_adapter *Adapter = pDM_Odm->Adapter;
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
@@ -1329,42 +1305,33 @@ void odm_TXPowerTrackingThermalMeterInit23a(struct dm_odm_t *pDM_Odm)
        pdmpriv->TXPowercount = 0;
        pdmpriv->bTXPowerTrackingInit = false;
        pdmpriv->TxPowerTrackControl = true;
-       MSG_8723A("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl);
+       MSG_8723A("pdmpriv->TxPowerTrackControl = %d\n",
+                 pdmpriv->TxPowerTrackControl);
 
        pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true;
 }
 
-void ODM_TXPowerTrackingCheck23a(struct dm_odm_t *pDM_Odm)
-{
-       /*  For AP/ADSL use struct rtl8723a_priv * */
-       /*  For CE/NIC use struct rtw_adapter * */
-
-       /*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
-       /*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
-       /*  HW dynamic mechanism. */
-       odm_TXPowerTrackingCheckCE23a(pDM_Odm);
-}
-
-void odm_TXPowerTrackingCheckCE23a(struct dm_odm_t *pDM_Odm)
-{
-}
-
 /* EDCA Turbo */
 static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm)
 {
-
        struct rtw_adapter *Adapter = pDM_Odm->Adapter;
 
        pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false;
-       pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false;
        Adapter->recvpriv.bIsAnyNonBEPkts = false;
 
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM)));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM)));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM)));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM)));
-
-}      /*  ODM_InitEdcaTurbo */
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
+                    ("Orginial VO PARAM: 0x%x\n",
+                     rtl8723au_read32(Adapter, ODM_EDCA_VO_PARAM)));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
+                    ("Orginial VI PARAM: 0x%x\n",
+                     rtl8723au_read32(Adapter, ODM_EDCA_VI_PARAM)));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
+                    ("Orginial BE PARAM: 0x%x\n",
+                     rtl8723au_read32(Adapter, ODM_EDCA_BE_PARAM)));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD,
+                    ("Orginial BK PARAM: 0x%x\n",
+                     rtl8723au_read32(Adapter, ODM_EDCA_BK_PARAM)));
+}
 
 static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm)
 {
@@ -1377,19 +1344,18 @@ static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        u32 trafficIndex;
        u32 edca_param;
-       u64 cur_tx_bytes = 0;
-       u64 cur_rx_bytes = 0;
-       u8 bbtchange = false;
+       u64 cur_tx_bytes;
+       u64 cur_rx_bytes;
 
        /*  For AP/ADSL use struct rtl8723a_priv * */
        /*  For CE/NIC use struct rtw_adapter * */
 
-       /*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
-       /*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
-       /*  HW dynamic mechanism. */
-
-       if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO))
-               return;
+       /*
+        * 2011/09/29 MH In HW integration first stage, we provide 4
+        * different handle to operate at the same time. In the stage2/3,
+        * we need to prive universal interface and merge all HW dynamic
+        * mechanism.
+        */
 
        if ((pregpriv->wifi_spec == 1))/*  (pmlmeinfo->HT_enable == 0)) */
                goto dm_CheckEdcaTurbo_EXIT;
@@ -1401,7 +1367,7 @@ static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm)
                goto dm_CheckEdcaTurbo_EXIT;
 
        /*  Check if the status needs to be changed. */
-       if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) {
+       if (!precvpriv->bIsAnyNonBEPkts) {
                cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes;
                cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes;
 
@@ -1454,29 +1420,37 @@ dm_CheckEdcaTurbo_EXIT:
        precvpriv->last_rx_bytes = precvpriv->rx_bytes;
 }
 
-u32 GetPSDData(struct dm_odm_t *pDM_Odm, unsigned int point, u8 initial_gain_psd)
+u32 GetPSDData(struct dm_odm_t *pDM_Odm, unsigned int point,
+              u8 initial_gain_psd)
 {
-       u32 psd_report;
+       struct rtw_adapter *adapter = pDM_Odm->Adapter;
+       u32 psd_report, val32;
 
        /* Set DCO frequency index, offset = (40MHz/SamplePts)*point */
-       ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point);
+       val32 = rtl8723au_read32(adapter, 0x808);
+       val32 &= ~0x3ff;
+       val32 |= (point & 0x3ff);
+       rtl8723au_write32(adapter, 0x808, val32);
 
        /* Start PSD calculation, Reg808[22]= 0->1 */
-       ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 1);
+       val32 = rtl8723au_read32(adapter, 0x808);
+       val32 |= BIT(22);
+       rtl8723au_write32(adapter, 0x808, val32);
        /* Need to wait for HW PSD report */
        udelay(30);
-       ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 0);
+       val32 = rtl8723au_read32(adapter, 0x808);
+       val32 &= ~BIT(22);
+       rtl8723au_write32(adapter, 0x808, val32);
        /* Read PSD report, Reg8B4[15:0] */
-       psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF;
+       psd_report = rtl8723au_read32(adapter, 0x8B4) & 0x0000FFFF;
 
-       psd_report = (u32)(ConvertTo_dB23a(psd_report))+(u32)(initial_gain_psd-0x1c);
+       psd_report = (u32)(ConvertTo_dB23a(psd_report)) +
+               (u32)(initial_gain_psd-0x1c);
 
        return psd_report;
 }
 
-u32
-ConvertTo_dB23a(
-       u32 Value)
+u32 ConvertTo_dB23a(u32 Value)
 {
        u8 i;
        u8 j;
@@ -1504,7 +1478,8 @@ ConvertTo_dB23a(
 
 /*  */
 /*  Description: */
-/*Set Single/Dual Antenna default setting for products that do not do detection in advance. */
+/* Set Single/Dual Antenna default setting for products that do not
+ * do detection in advance. */
 /*  */
 /*  Added by Joseph, 2012.03.22 */
 /*  */
@@ -1518,18 +1493,13 @@ void ODM_SingleDualAntennaDefaultSetting(struct dm_odm_t *pDM_Odm)
 
 /* 2 8723A ANT DETECT */
 
-static void odm_PHY_SaveAFERegisters(
-       struct dm_odm_t *pDM_Odm,
-       u32 *AFEReg,
-       u32 *AFEBackup,
-       u32 RegisterNum
-       )
+static void odm_PHY_SaveAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg,
+                                    u32 *AFEBackup, u32 RegisterNum)
 {
        u32 i;
 
-       /* RTPRINT(FINIT, INIT_IQK, ("Save ADDA parameters.\n")); */
        for (i = 0 ; i < RegisterNum ; i++)
-               AFEBackup[i] = ODM_GetBBReg(pDM_Odm, AFEReg[i], bMaskDWord);
+               AFEBackup[i] = rtl8723au_read32(pDM_Odm->Adapter, AFEReg[i]);
 }
 
 static void odm_PHY_ReloadAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg,
@@ -1538,7 +1508,7 @@ static void odm_PHY_ReloadAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg,
        u32 i;
 
        for (i = 0 ; i < RegiesterNum; i++)
-               ODM_SetBBReg(pDM_Odm, AFEReg[i], bMaskDWord, AFEBackup[i]);
+               rtl8723au_write32(pDM_Odm->Adapter, AFEReg[i], AFEBackup[i]);
 }
 
 /* 2 8723A ANT DETECT */
@@ -1548,9 +1518,10 @@ static void odm_PHY_ReloadAFERegisters(struct dm_odm_t *pDM_Odm, u32 *AFEReg,
 bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
 {
        struct sw_ant_sw *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
+       struct rtw_adapter *adapter = pDM_Odm->Adapter;
        u32 CurrentChannel, RfLoopReg;
        u8 n;
-       u32 Reg88c, Regc08, Reg874, Regc50;
+       u32 Reg88c, Regc08, Reg874, Regc50, val32;
        u8 initial_gain = 0x5a;
        u32 PSD_report_tmp;
        u32 AntA_report = 0x0, AntB_report = 0x0, AntO_report = 0x0;
@@ -1573,72 +1544,80 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
                return bResult;
        /* 1 Backup Current RF/BB Settings */
 
-       CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask);
+       CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL,
+                                     bRFRegOffsetMask);
        RfLoopReg = ODM_GetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask);
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, ODM_DPDT, Antenna_A);  /*  change to Antenna A */
+       /*  change to Antenna A */
+       val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE);
+       val32 &= ~0x300;
+       val32 |= 0x100;         /* Enable antenna A */
+       rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32);
+
        /*  Step 1: USE IQK to transmitter single tone */
 
        udelay(10);
 
        /* Store A Path Register 88c, c08, 874, c50 */
-       Reg88c = ODM_GetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord);
-       Regc08 = ODM_GetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord);
-       Reg874 = ODM_GetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord);
-       Regc50 = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord);
+       Reg88c = rtl8723au_read32(adapter, rFPGA0_AnalogParameter4);
+       Regc08 = rtl8723au_read32(adapter, rOFDM0_TRMuxPar);
+       Reg874 = rtl8723au_read32(adapter, rFPGA0_XCD_RFInterfaceSW);
+       Regc50 = rtl8723au_read32(adapter, rOFDM0_XAAGCCore1);
 
        /*  Store AFE Registers */
        odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16);
 
        /* Set PSD 128 pts */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT(14) | BIT(15), 0x0);
+       val32 = rtl8723au_read32(adapter, rFPGA0_PSDFunction);
+       val32 &= ~(BIT(14) | BIT(15));
+       rtl8723au_write32(adapter, rFPGA0_PSDFunction, val32);
 
        /*  To SET CH1 to do */
-       ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01);     /* Channel 1 */
+       ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01);
 
        /*  AFE all on step */
-       ODM_SetBBReg(pDM_Odm, rRx_Wait_CCA, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_CCK_RFON, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_CCK_BBON, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_OFDM_RFON, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_OFDM_BBON, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_To_Rx, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rTx_To_Tx, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rRx_CCK, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rRx_OFDM, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rRx_Wait_RIFS, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rRx_TO_Rx, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rStandby, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rSleep, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rPMPD_ANAEN, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_SwitchControl, bMaskDWord, 0x6FDB25A4);
-       ODM_SetBBReg(pDM_Odm, rBlue_Tooth, bMaskDWord, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rRx_Wait_CCA, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_CCK_RFON, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_CCK_BBON, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_OFDM_RFON, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_OFDM_BBON, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_To_Rx, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rTx_To_Tx, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rRx_CCK, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rRx_OFDM, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rRx_Wait_RIFS, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rRx_TO_Rx, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rStandby, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rSleep, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rPMPD_ANAEN, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rFPGA0_XCD_SwitchControl, 0x6FDB25A4);
+       rtl8723au_write32(adapter, rBlue_Tooth, 0x6FDB25A4);
 
        /*  3 wire Disable */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, 0xCCF000C0);
+       rtl8723au_write32(adapter, rFPGA0_AnalogParameter4, 0xCCF000C0);
 
        /* BB IQK Setting */
-       ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800E4);
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22208000);
+       rtl8723au_write32(adapter, rOFDM0_TRMuxPar, 0x000800E4);
+       rtl8723au_write32(adapter, rFPGA0_XCD_RFInterfaceSW, 0x22208000);
 
        /* IQK setting tone@ 4.34Mhz */
-       ODM_SetBBReg(pDM_Odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008C1C);
-       ODM_SetBBReg(pDM_Odm, rTx_IQK, bMaskDWord, 0x01007c00);
+       rtl8723au_write32(adapter, rTx_IQK_Tone_A, 0x10008C1C);
+       rtl8723au_write32(adapter, rTx_IQK, 0x01007c00);
 
        /* Page B init */
-       ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x00080000);
-       ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x0f600000);
-       ODM_SetBBReg(pDM_Odm, rRx_IQK, bMaskDWord, 0x01004800);
-       ODM_SetBBReg(pDM_Odm, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f);
-       ODM_SetBBReg(pDM_Odm, rTx_IQK_PI_A, bMaskDWord, 0x82150008);
-       ODM_SetBBReg(pDM_Odm, rRx_IQK_PI_A, bMaskDWord, 0x28150008);
-       ODM_SetBBReg(pDM_Odm, rIQK_AGC_Rsp, bMaskDWord, 0x001028d0);
+       rtl8723au_write32(adapter, rConfig_AntA, 0x00080000);
+       rtl8723au_write32(adapter, rConfig_AntA, 0x0f600000);
+       rtl8723au_write32(adapter, rRx_IQK, 0x01004800);
+       rtl8723au_write32(adapter, rRx_IQK_Tone_A, 0x10008c1f);
+       rtl8723au_write32(adapter, rTx_IQK_PI_A, 0x82150008);
+       rtl8723au_write32(adapter, rRx_IQK_PI_A, 0x28150008);
+       rtl8723au_write32(adapter, rIQK_AGC_Rsp, 0x001028d0);
 
        /* RF loop Setting */
        ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x0, 0xFFFFF, 0x50008);
 
        /* IQK Single tone start */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x80800000);
-       ODM_SetBBReg(pDM_Odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
+       rtl8723au_write32(adapter, rFPGA0_IQK, 0x80800000);
+       rtl8723au_write32(adapter, rIQK_AGC_Pts, 0xf8000000);
        udelay(1000);
        PSD_report_tmp = 0x0;
 
@@ -1650,7 +1629,10 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
 
        PSD_report_tmp = 0x0;
 
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B);  /*  change to Antenna B */
+       val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE);
+       val32 &= ~0x300;
+       val32 |= 0x200;         /* Enable antenna B */
+       rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32);
        udelay(10);
 
        for (n = 0; n < 2; n++) {
@@ -1660,7 +1642,10 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
        }
 
        /*  change to open case */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, 0);  /*  change to Ant A and B all open case */
+       /*  change to Ant A and B all open case */
+       val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE);
+       val32 &= ~0x300;
+       rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32);
        udelay(10);
 
        for (n = 0; n < 2; n++) {
@@ -1670,25 +1655,36 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
        }
 
        /* Close IQK Single Tone function */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x00000000);
+       rtl8723au_write32(adapter, rFPGA0_IQK, 0x00000000);
        PSD_report_tmp = 0x0;
 
        /* 1 Return to antanna A */
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A);
-       ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, Reg88c);
-       ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, Regc08);
-       ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, Reg874);
-       ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, 0x7F, 0x40);
-       ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord, Regc50);
-       ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel);
+       val32 = rtl8723au_read32(adapter, rFPGA0_XA_RFInterfaceOE);
+       val32 &= ~0x300;
+       val32 |= 0x100;         /* Enable antenna A */
+       rtl8723au_write32(adapter, rFPGA0_XA_RFInterfaceOE, val32);
+       rtl8723au_write32(adapter, rFPGA0_AnalogParameter4, Reg88c);
+       rtl8723au_write32(adapter, rOFDM0_TRMuxPar, Regc08);
+       rtl8723au_write32(adapter, rFPGA0_XCD_RFInterfaceSW, Reg874);
+       val32 = rtl8723au_read32(adapter, rOFDM0_XAAGCCore1);
+       val32 &= ~0x7f;
+       val32 |= 0x40;
+       rtl8723au_write32(adapter, rOFDM0_XAAGCCore1, val32);
+
+       rtl8723au_write32(adapter, rOFDM0_XAAGCCore1, Regc50);
+       ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask,
+                    CurrentChannel);
        ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask, RfLoopReg);
 
        /* Reload AFE Registers */
        odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16);
 
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d \n", 2416, AntA_report));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d \n", 2416, AntB_report));
-       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d \n", 2416, AntO_report));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
+                    ("psd_report_A[%d]= %d \n", 2416, AntA_report));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
+                    ("psd_report_B[%d]= %d \n", 2416, AntB_report));
+       ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
+                    ("psd_report_O[%d]= %d \n", 2416, AntO_report));
 
        /* 2 Test Ant B based on Ant A is ON */
        if (mode == ANTTESTB) {
@@ -1710,30 +1706,33 @@ bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode)
                if ((AntO_report >= 100) & (AntO_report < 118)) {
                        if (AntA_report > (AntO_report+1)) {
                                pDM_SWAT_Table->ANTA_ON = false;
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is OFF"));
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,
+                                            ODM_DBG_LOUD, ("Ant A is OFF"));
                        } else {
                                pDM_SWAT_Table->ANTA_ON = true;
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is ON"));
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,
+                                            ODM_DBG_LOUD, ("Ant A is ON"));
                        }
 
                        if (AntB_report > (AntO_report+2)) {
                                pDM_SWAT_Table->ANTB_ON = false;
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is OFF"));
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,
+                                            ODM_DBG_LOUD, ("Ant B is OFF"));
                        } else {
                                pDM_SWAT_Table->ANTB_ON = true;
-                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is ON"));
+                               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,
+                                            ODM_DBG_LOUD, ("Ant B is ON"));
                        }
                }
        } else {
-               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n"));
-               pDM_SWAT_Table->ANTA_ON = true; /*  Set Antenna A on as default */
-               pDM_SWAT_Table->ANTB_ON = false; /*  Set Antenna B off as default */
+               ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
+               ("ODM_SingleDualAntennaDetection(): Need to check again\n"));
+               /*  Set Antenna A on as default */
+               pDM_SWAT_Table->ANTA_ON = true;
+               /*  Set Antenna B off as default */
+               pDM_SWAT_Table->ANTB_ON = false;
                bResult = false;
        }
-       return bResult;
-}
 
-/* Justin: According to the current RRSI to adjust Response Frame TX power, 2012/11/05 */
-void odm_dtc(struct dm_odm_t *pDM_Odm)
-{
+       return bResult;
 }
index 33aafa01f900bfc7ab6ab9f24ab8ea8b8adc872a..7b9799e3dbdae06f501636b705736009c8e9a67d 100644 (file)
@@ -33,24 +33,23 @@ static s32 odm_SignalScaleMapping_92CSeries(struct dm_odm_t *pDM_Odm, s32 CurrSi
 {
        s32 RetSig = 0;
 
-       if ((pDM_Odm->SupportInterface  == ODM_ITRF_USB) || (pDM_Odm->SupportInterface  == ODM_ITRF_SDIO)) {
-               if (CurrSig >= 51 && CurrSig <= 100)
-                       RetSig = 100;
-               else if (CurrSig >= 41 && CurrSig <= 50)
-                       RetSig = 80 + ((CurrSig - 40)*2);
-               else if (CurrSig >= 31 && CurrSig <= 40)
-                       RetSig = 66 + (CurrSig - 30);
-               else if (CurrSig >= 21 && CurrSig <= 30)
-                       RetSig = 54 + (CurrSig - 20);
-               else if (CurrSig >= 10 && CurrSig <= 20)
-                       RetSig = 42 + (((CurrSig - 10) * 2) / 3);
-               else if (CurrSig >= 5 && CurrSig <= 9)
-                       RetSig = 22 + (((CurrSig - 5) * 3) / 2);
-               else if (CurrSig >= 1 && CurrSig <= 4)
-                       RetSig = 6 + (((CurrSig - 1) * 3) / 2);
-               else
-                       RetSig = CurrSig;
-       }
+       if (CurrSig >= 51 && CurrSig <= 100)
+               RetSig = 100;
+       else if (CurrSig >= 41 && CurrSig <= 50)
+               RetSig = 80 + ((CurrSig - 40)*2);
+       else if (CurrSig >= 31 && CurrSig <= 40)
+               RetSig = 66 + (CurrSig - 30);
+       else if (CurrSig >= 21 && CurrSig <= 30)
+               RetSig = 54 + (CurrSig - 20);
+       else if (CurrSig >= 10 && CurrSig <= 20)
+               RetSig = 42 + (((CurrSig - 10) * 2) / 3);
+       else if (CurrSig >= 5 && CurrSig <= 9)
+               RetSig = 22 + (((CurrSig - 5) * 3) / 2);
+       else if (CurrSig >= 1 && CurrSig <= 4)
+               RetSig = 6 + (((CurrSig - 1) * 3) / 2);
+       else
+               RetSig = CurrSig;
+
        return RetSig;
 }
 
index 88e0126e855aa6826d3e4a4fda4a2acbea7791fe..342dec3e939f325eae79d2b31766047c0802cdca 100644 (file)
@@ -14,6 +14,7 @@
  ******************************************************************************/
 
 #include "odm_precomp.h"
+#include "usb_ops_linux.h"
 
 void
 odm_ConfigRFReg_8723A(
@@ -43,62 +44,45 @@ odm_ConfigRFReg_8723A(
        }
 }
 
-void odm_ConfigMAC_8723A(struct dm_odm_t *pDM_Odm,
-       u32             Addr,
-       u8              Data
-       )
+void odm_ConfigMAC_8723A(struct dm_odm_t *pDM_Odm, u32 addr, u8        data)
 {
-       ODM_Write1Byte(pDM_Odm, Addr, Data);
+       rtl8723au_write8(pDM_Odm->Adapter, addr, data);
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
-                    ("===> ODM_ConfigMACWithHeaderFile23a: [MAC_REG] %08X %08X\n",
-                    Addr, Data));
+                    ("===> %s: [MAC_REG] %08X %08X\n", __func__, addr, data));
 }
 
-void
-odm_ConfigBB_AGC_8723A(
-       struct dm_odm_t *pDM_Odm,
-       u32             Addr,
-       u32             Bitmask,
-       u32             Data
-  )
+void odm_ConfigBB_AGC_8723A(struct dm_odm_t *pDM_Odm, u32 addr, u32 data)
 {
-       ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data);
+       rtl8723au_write32(pDM_Odm->Adapter, addr, data);
        /*  Add 1us delay between BB/RF register setting. */
        udelay(1);
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
-                    ("===> ODM_ConfigBBWithHeaderFile23a: [AGC_TAB] %08X %08X\n",
-                    Addr, Data));
+                    ("===> %s: [AGC_TAB] %08X %08X\n", __func__, addr, data));
 }
 
 void
-odm_ConfigBB_PHY_8723A(
-       struct dm_odm_t *pDM_Odm,
-       u32             Addr,
-       u32             Bitmask,
-       u32             Data
-  )
+odm_ConfigBB_PHY_8723A(struct dm_odm_t *pDM_Odm, u32 addr, u32 data)
 {
-       if (Addr == 0xfe)
+       if (addr == 0xfe)
                msleep(50);
-       else if (Addr == 0xfd)
+       else if (addr == 0xfd)
                mdelay(5);
-       else if (Addr == 0xfc)
+       else if (addr == 0xfc)
                mdelay(1);
-       else if (Addr == 0xfb)
+       else if (addr == 0xfb)
                udelay(50);
-       else if (Addr == 0xfa)
+       else if (addr == 0xfa)
                udelay(5);
-       else if (Addr == 0xf9)
+       else if (addr == 0xf9)
                udelay(1);
-       else if (Addr == 0xa24)
-               pDM_Odm->RFCalibrateInfo.RegA24 = Data;
-       ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data);
+       else if (addr == 0xa24)
+               pDM_Odm->RFCalibrateInfo.RegA24 = data;
+       rtl8723au_write32(pDM_Odm->Adapter, addr, data);
 
        /*  Add 1us delay between BB/RF register setting. */
        udelay(1);
 
        ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
-                    ("===> ODM_ConfigBBWithHeaderFile23a: [PHY_REG] %08X %08X\n",
-                    Addr, Data));
+                    ("===> %s: [PHY_REG] %08X %08X\n", __func__, addr, data));
 }
index f03f6d4a38889240646356ec6687db0b55f771bb..d8f67902708e70955957f9a26da38c9c11de31dc 100644 (file)
 /*  */
 #include <usb_ops_linux.h>
 
-u8 ODM_Read1Byte(struct dm_odm_t *pDM_Odm,
-       u32                     RegAddr
-       )
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       return rtl8723au_read8(Adapter, RegAddr);
-}
-
-u16 ODM_Read2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr)
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       return rtl8723au_read16(Adapter, RegAddr);
-}
-
-u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr)
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       return rtl8723au_read32(Adapter, RegAddr);
-}
-
-void ODM_Write1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u8 Data)
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       rtl8723au_write8(Adapter, RegAddr, Data);
-}
-
-void ODM_Write2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u16 Data)
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       rtl8723au_write16(Adapter, RegAddr, Data);
-}
-
-void ODM_Write4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 Data)
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       rtl8723au_write32(Adapter, RegAddr, Data);
-}
-
-void ODM_SetMACReg(
-       struct dm_odm_t *pDM_Odm,
-       u32             RegAddr,
-       u32             BitMask,
-       u32             Data
-       )
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       PHY_SetBBReg(Adapter, RegAddr, BitMask, Data);
-}
-
-u32 ODM_GetMACReg(
-       struct dm_odm_t *pDM_Odm,
-       u32             RegAddr,
-       u32             BitMask
-       )
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       return PHY_QueryBBReg(Adapter, RegAddr, BitMask);
-}
-
-void ODM_SetBBReg(
-       struct dm_odm_t *pDM_Odm,
-       u32             RegAddr,
-       u32             BitMask,
-       u32             Data
-       )
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       PHY_SetBBReg(Adapter, RegAddr, BitMask, Data);
-}
-
-u32 ODM_GetBBReg(
-       struct dm_odm_t *pDM_Odm,
-       u32             RegAddr,
-       u32             BitMask
-       )
-{
-       struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-       return PHY_QueryBBReg(Adapter, RegAddr, BitMask);
-}
-
 void ODM_SetRFReg(
        struct dm_odm_t *pDM_Odm,
        enum RF_RADIO_PATH      eRFPath,
index 73cfddd6df9aef6277db821b3c66d31a7425540a..7f091da0273f998b45c82b9230dcc103330373bb 100644 (file)
@@ -3208,7 +3208,7 @@ bthci_CmdDisconnectPhysicalLink(struct rtw_adapter *padapter,
        pBtDbg->dbgHciInfo.hciCmdCntDisconnectPhyLink++;
 
        PLH = *((u8 *)pHciCmd->Data);
-       PhysLinkDisconnectReason = (*((u8 *)pHciCmd->Data+1));
+       PhysLinkDisconnectReason = *((u8 *)pHciCmd->Data+1);
        RTPRINT(FIOCTL, IOCTL_BT_HCICMD, ("HCI_DISCONNECT_PHYSICAL_LINK  PhyHandle = 0x%x, Reason = 0x%x\n",
                PLH, PhysLinkDisconnectReason));
 
@@ -5796,7 +5796,7 @@ static void
 btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter)
 {
        u8 init_rate = 0;
-       u8 raid;
+       u8 raid, arg;
        u32 mask;
        u8 shortGIrate = false;
        int supportRateNum = 0;
@@ -5860,26 +5860,16 @@ btdm_1AntUpdateHalRAMask(struct rtw_adapter *padapter, u32 mac_id, u32 filter)
        mask &= ~filter;
        init_rate = get_highest_rate_idx23a(mask)&0x3f;
 
-       if (pHalData->fw_ractrl) {
-               u8 arg = 0;
+       arg = mac_id&0x1f;/* MACID */
+       arg |= BIT(7);
+       if (true == shortGIrate)
+               arg |= BIT(5);
 
-               arg = mac_id&0x1f;/* MACID */
-               arg |= BIT(7);
-               if (true == shortGIrate)
-                       arg |= BIT(5);
-
-               RTPRINT(FBT, BT_TRACE,
-                       ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, "
-                        "arg = 0x%02x\n", mask, arg));
-
-               rtl8723a_set_raid_cmd(padapter, mask, arg);
-       } else {
-               if (shortGIrate)
-                       init_rate |= BIT(6);
+       RTPRINT(FBT, BT_TRACE,
+               ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, "
+                "arg = 0x%02x\n", mask, arg));
 
-               rtl8723au_write8(padapter, REG_INIDATA_RATE_SEL + mac_id,
-                                init_rate);
-       }
+       rtl8723a_set_raid_cmd(padapter, mask, arg);
 
        psta->init_rate = init_rate;
        pdmpriv->INIDATA_RATE[mac_id] = init_rate;
index 7b56411cc3c8130c5cf70d816a57459ac4b8a5fc..11e1108d0c56f17a37de922b7b969df2ea842c9b 100644 (file)
@@ -142,32 +142,18 @@ int rtl8723a_set_raid_cmd(struct rtw_adapter *padapter, u32 mask, u8 arg)
 /* arg[5] = Short GI */
 void rtl8723a_add_rateatid(struct rtw_adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level)
 {
-       struct hal_data_8723a   *pHalData = GET_HAL_DATA(pAdapter);
-       u8 macid = arg&0x1f;
-       u8 raid = (bitmap>>28) & 0x0f;
+       struct hal_data_8723a *pHalData = GET_HAL_DATA(pAdapter);
+       u8 macid = arg & 0x1f;
+       u32 raid = bitmap & 0xf0000000;
 
        bitmap &= 0x0fffffff;
        if (rssi_level != DM_RATR_STA_INIT)
                bitmap = ODM_Get_Rate_Bitmap23a(pHalData, macid, bitmap,
                                                rssi_level);
 
-       bitmap |= ((raid<<28)&0xf0000000);
+       bitmap |= raid;
 
-       if (pHalData->fw_ractrl == true) {
-               rtl8723a_set_raid_cmd(pAdapter, bitmap, arg);
-       } else {
-               u8 init_rate, shortGIrate = false;
-
-               init_rate = get_highest_rate_idx23a(bitmap&0x0fffffff)&0x3f;
-
-               shortGIrate = (arg&BIT(5)) ? true:false;
-
-               if (shortGIrate == true)
-                       init_rate |= BIT(6);
-
-               rtl8723au_write8(pAdapter, REG_INIDATA_RATE_SEL + macid,
-                                init_rate);
-       }
+       rtl8723a_set_raid_cmd(pAdapter, bitmap, arg);
 }
 
 void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode)
@@ -183,10 +169,8 @@ void rtl8723a_set_FwPwrMode_cmd(struct rtw_adapter *padapter, u8 Mode)
            prevent conficting setting in Fw power */
        /*  saving sequence. 2010.06.07. Added by tynli.
            Suggested by SD3 yschang. */
-       if ((Mode != PS_MODE_ACTIVE) &&
-           (!IS_92C_SERIAL(pHalData->VersionID))) {
+       if (Mode != PS_MODE_ACTIVE && pHalData->rf_type != RF_2T2R)
                ODM_RF_Saving23a(&pHalData->odmpriv, true);
-       }
 
        H2CSetPwrMode.Mode = Mode;
        H2CSetPwrMode.SmartPS = pwrpriv->smart_ps;
index fa826b068d11ea8a91247a0b3b6a708e78d6efe5..1e831f2d1cafaf695dca988ee3444403f240dadc 100644 (file)
@@ -94,8 +94,6 @@ void rtl8723a_init_dm_priv(struct rtw_adapter *Adapter)
        memset(pDM_Odm, 0, sizeof(*pDM_Odm));
 
        pDM_Odm->Adapter = Adapter;
-       ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_PLATFORM, 0x04);
-       ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_INTERFACE, RTW_USB);/* RTL871X_HCI_TYPE */
 
        ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8723A);
 
@@ -119,15 +117,7 @@ void rtl8723a_init_dm_priv(struct rtw_adapter *Adapter)
                ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_EXT_LNA, true);
                ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_EXT_PA, true);
        }
-       ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_PATCH_ID, pHalData->CustomerID);
        ODM_CmnInfoInit23a(pDM_Odm, ODM_CMNINFO_BWIFI_TEST, Adapter->registrypriv.wifi_spec);
-
-       if (pHalData->rf_type == RF_1T1R)
-               ODM_CmnInfoUpdate23a(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R);
-       else if (pHalData->rf_type == RF_2T2R)
-               ODM_CmnInfoUpdate23a(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R);
-       else if (pHalData->rf_type == RF_1T2R)
-               ODM_CmnInfoUpdate23a(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R);
 }
 
 static void Update_ODM_ComInfo_8723a(struct rtw_adapter *Adapter)
@@ -136,16 +126,7 @@ static void Update_ODM_ComInfo_8723a(struct rtw_adapter *Adapter)
        struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
        struct dm_priv  *pdmpriv = &pHalData->dmpriv;
        int i;
-       pdmpriv->InitODMFlag =  ODM_BB_DIG              |
-                               ODM_BB_RA_MASK          |
-                               ODM_BB_DYNAMIC_TXPWR    |
-                               ODM_BB_FA_CNT           |
-                               ODM_BB_RSSI_MONITOR     |
-                               ODM_BB_CCK_PD           |
-                               ODM_BB_PWR_SAVE         |
-                               ODM_MAC_EDCA_TURBO      |
-                               ODM_RF_TX_PWR_TRACK     |
-                               ODM_RF_CALIBRATION;
+       pdmpriv->InitODMFlag = 0;
        /*  Pointer reference */
        rtl8723a_odm_support_ability_set(Adapter, DYNAMIC_ALL_FUNC_ENABLE);
 
index a5eadd4e2580023553dcfede4b77928fcfbff008..d3dc24b0cc46fcec33e31d6132b038df9e456767 100644 (file)
@@ -424,15 +424,14 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter,
                        offset = GET_HDR_OFFSET_2_0(efuseHeader);
 
                        ReadEFuseByte23a(padapter, eFuse_Addr++, &efuseExtHdr);
-                       if (ALL_WORDS_DISABLED(efuseExtHdr)) {
+                       if (ALL_WORDS_DISABLED(efuseExtHdr))
                                continue;
-                       }
 
                        offset |= ((efuseExtHdr & 0xF0) >> 1);
-                       wden = (efuseExtHdr & 0x0F);
+                       wden = efuseExtHdr & 0x0F;
                } else {
-                       offset = ((efuseHeader >> 4) & 0x0f);
-                       wden = (efuseHeader & 0x0f);
+                       offset = (efuseHeader >> 4) & 0x0f;
+                       wden = efuseHeader & 0x0f;
                }
 
                if (offset < EFUSE_MAX_SECTION_8723A) {
@@ -524,15 +523,14 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter,
 
                                ReadEFuseByte23a(padapter, eFuse_Addr++,
                                              &efuseExtHdr);
-                               if (ALL_WORDS_DISABLED(efuseExtHdr)) {
+                               if (ALL_WORDS_DISABLED(efuseExtHdr))
                                        continue;
-                               }
 
                                offset |= ((efuseExtHdr & 0xF0) >> 1);
-                               wden = (efuseExtHdr & 0x0F);
+                               wden = efuseExtHdr & 0x0F;
                        } else {
-                               offset = ((efuseHeader >> 4) & 0x0f);
-                               wden = (efuseHeader & 0x0f);
+                               offset = (efuseHeader >> 4) & 0x0f;
+                               wden = efuseHeader & 0x0f;
                        }
 
                        if (offset < EFUSE_BT_MAX_SECTION) {
@@ -630,9 +628,8 @@ u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter)
                        hoffset = GET_HDR_OFFSET_2_0(efuse_data);
                        efuse_addr++;
                        efuse_OneByteRead23a(padapter, efuse_addr, &efuse_data);
-                       if (ALL_WORDS_DISABLED(efuse_data)) {
+                       if (ALL_WORDS_DISABLED(efuse_data))
                                continue;
-                       }
 
                        hoffset |= ((efuse_data & 0xF0) >> 1);
                        hworden = efuse_data & 0x0F;
@@ -721,9 +718,8 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
                }
 
                /*  Check if we need to check next bank efuse */
-               if (efuse_addr < retU2) {
+               if (efuse_addr < retU2)
                        break;  /*  don't need to check next bank. */
-               }
        }
 
        retU2 = ((bank - 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN) + efuse_addr;
@@ -744,7 +740,7 @@ void rtl8723a_read_chip_version(struct rtw_adapter *padapter)
        value32 = rtl8723au_read32(padapter, REG_SYS_CFG);
        ChipVersion.ICType = CHIP_8723A;
        ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP);
-       ChipVersion.RFType = RF_TYPE_1T1R;
+       pHalData->rf_type = RF_1T1R;
        ChipVersion.VendorType =
                ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC);
        ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT;   /*  IC version (CUT) */
@@ -755,7 +751,7 @@ void rtl8723a_read_chip_version(struct rtw_adapter *padapter)
 
        value32 = rtl8723au_read32(padapter, REG_GPIO_OUTSTS);
        /*  ROM code version. */
-       ChipVersion.ROMVer = ((value32 & RF_RL_ID) >> 20);
+       ChipVersion.ROMVer = (value32 & RF_RL_ID) >> 20;
 
        /*  For multi-function consideration. Added by Roger, 2010.10.06. */
        pHalData->MultiFunc = RT_MULTI_FUNC_NONE;
@@ -768,16 +764,8 @@ void rtl8723a_read_chip_version(struct rtw_adapter *padapter)
        pHalData->PolarityCtl =
                ((value32 & WL_HWPDN_SL) ? RT_POLARITY_HIGH_ACT :
                 RT_POLARITY_LOW_ACT);
-       dump_chip_info23a(ChipVersion);
        pHalData->VersionID = ChipVersion;
 
-       if (IS_1T2R(ChipVersion))
-               pHalData->rf_type = RF_1T2R;
-       else if (IS_2T2R(ChipVersion))
-               pHalData->rf_type = RF_2T2R;
-       else
-               pHalData->rf_type = RF_1T1R;
-
        MSG_8723A("RF_Type is %x!!\n", pHalData->rf_type);
 }
 
@@ -1095,7 +1083,6 @@ void rtl8723a_init_default_value(struct rtw_adapter *padapter)
        pdmpriv = &pHalData->dmpriv;
 
        /*  init default value */
-       pHalData->fw_ractrl = false;
        pHalData->bIQKInitialized = false;
        if (!padapter->pwrctrlpriv.bkeepfwalive)
                pHalData->LastHMEBoxNum = 0;
@@ -1149,9 +1136,8 @@ static int _LLTWrite(struct rtw_adapter *padapter, u32 address, u32 data)
        /* polling */
        do {
                value = rtl8723au_read32(padapter, LLTReg);
-               if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) {
+               if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
                        break;
-               }
 
                if (count > POLLING_LLT_THRESHOLD) {
                        RT_TRACE(_module_hal_init_c_, _drv_err_,
@@ -1174,16 +1160,14 @@ int InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary)
 
        for (i = 0; i < (txpktbuf_bndy - 1); i++) {
                status = _LLTWrite(padapter, i, i + 1);
-               if (status != _SUCCESS) {
+               if (status != _SUCCESS)
                        return status;
-               }
        }
 
        /*  end of list */
        status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF);
-       if (status != _SUCCESS) {
+       if (status != _SUCCESS)
                return status;
-       }
 
        /*  Make the other pages as ring buffer */
        /*  This ring buffer is used as beacon buffer if we config this
@@ -1191,16 +1175,14 @@ int InitLLTTable23a(struct rtw_adapter *padapter, u32 boundary)
        /*  Otherwise used as local loopback buffer. */
        for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) {
                status = _LLTWrite(padapter, i, (i + 1));
-               if (_SUCCESS != status) {
+               if (_SUCCESS != status)
                        return status;
-               }
        }
 
        /*  Let last entry point to the start entry of ring buffer */
        status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy);
-       if (status != _SUCCESS) {
+       if (status != _SUCCESS)
                return status;
-       }
 
        return status;
 }
@@ -1435,9 +1417,9 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM)
 /*  HW Auto state machine */
 int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
 {
-       if (padapter->bSurpriseRemoved) {
+       if (padapter->bSurpriseRemoved)
                return _SUCCESS;
-       }
+
        /*  RF Off Sequence ==== */
        _DisableRFAFEAndResetBB8192C(padapter);
 
@@ -1459,9 +1441,8 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
 /*  without HW Auto state machine */
 int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
 {
-       if (padapter->bSurpriseRemoved) {
+       if (padapter->bSurpriseRemoved)
                return _SUCCESS;
-       }
 
        /*  RF Off Sequence ==== */
        _DisableRFAFEAndResetBB8192C(padapter);
@@ -1747,8 +1728,8 @@ Hal_EfuseParseBTCoexistInfo_8723A(struct rtw_adapter *padapter,
                /*  eeprom spec */
                tempval = hwinfo[RF_OPTION4_8723A];
                pHalData->EEPROMBluetoothAntNum = (tempval & 0x1);
-               pHalData->EEPROMBluetoothAntIsolation = ((tempval & 0x10) >> 4);
-               pHalData->EEPROMBluetoothRadioShared = ((tempval & 0x20) >> 5);
+               pHalData->EEPROMBluetoothAntIsolation = (tempval & 0x10) >> 4;
+               pHalData->EEPROMBluetoothRadioShared = (tempval & 0x20) >> 5;
        } else {
                pHalData->EEPROMBluetoothCoexist = 0;
                pHalData->EEPROMBluetoothType = BT_RTL8723A;
@@ -1875,9 +1856,8 @@ static void rtl8723a_cal_txdesc_chksum(struct tx_desc *ptxdesc)
        /*  Clear first */
        ptxdesc->txdw7 &= cpu_to_le32(0xffff0000);
 
-       for (index = 0; index < count; index++) {
+       for (index = 0; index < count; index++)
                checksum ^= le16_to_cpu(*(usPtr + index));
-       }
 
        ptxdesc->txdw7 |= cpu_to_le32(checksum & 0x0000ffff);
 }
@@ -1925,9 +1905,8 @@ void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc,
                ptxdesc->txdw3 |= cpu_to_le32((8 << 28));
        }
 
-       if (true == IsBTQosNull) {
+       if (true == IsBTQosNull)
                ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /*  BT NULL */
-       }
 
        /* offset 16 */
        ptxdesc->txdw4 |= cpu_to_le32(BIT(8));  /* driver uses rate */
index 19dc5e3b2e2ec94f41b0fc83f116e615613fc8d5..38f8c3de302932674b40272f974aa3a24843be59 100644 (file)
@@ -126,7 +126,7 @@ PHY_SetBBReg(struct rtw_adapter *Adapter, u32 RegAddr, u32 BitMask, u32     Data)
        if (BitMask != bMaskDWord) {/* if not "double word" write */
                OriginalValue = rtl8723au_read32(Adapter, RegAddr);
                BitShift = phy_CalculateBitShift(BitMask);
-               Data = ((OriginalValue & (~BitMask)) | (Data << BitShift));
+               Data = (OriginalValue & (~BitMask)) | (Data << BitShift);
        }
 
        rtl8723au_write32(Adapter, RegAddr, Data);
@@ -190,25 +190,24 @@ phy_RFSerialRead(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath,
        /*  For 92S LSSI Read RFLSSIRead */
        /*  For RF A/B write 0x824/82c(does not work in the future) */
        /*  We must use 0x824 for RF A and B to execute read trigger */
-       tmplong = PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord);
+       tmplong = rtl8723au_read32(Adapter, rFPGA0_XA_HSSIParameter2);
        if (eRFPath == RF_PATH_A)
                tmplong2 = tmplong;
        else
-               tmplong2 = PHY_QueryBBReg(Adapter, pPhyReg->rfHSSIPara2,
-                                         bMaskDWord);
+               tmplong2 = rtl8723au_read32(Adapter, pPhyReg->rfHSSIPara2);
 
        tmplong2 = (tmplong2 & ~bLSSIReadAddress) |
                (NewOffset << 23) | bLSSIReadEdge;      /* T65 RF */
 
-       PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2,
-                    bMaskDWord, tmplong & (~bLSSIReadEdge));
+       rtl8723au_write32(Adapter, rFPGA0_XA_HSSIParameter2,
+                         tmplong & (~bLSSIReadEdge));
        udelay(10);/*  PlatformStallExecution(10); */
 
-       PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2);
+       rtl8723au_write32(Adapter, pPhyReg->rfHSSIPara2, tmplong2);
        udelay(100);/* PlatformStallExecution(100); */
 
-       PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord,
-                    tmplong | bLSSIReadEdge);
+       rtl8723au_write32(Adapter, rFPGA0_XA_HSSIParameter2,
+                         tmplong | bLSSIReadEdge);
        udelay(10);/* PlatformStallExecution(10); */
 
        if (eRFPath == RF_PATH_A)
@@ -319,9 +318,7 @@ phy_RFSerialWrite(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath,
        /*  */
        /*  Write Operation */
        /*  */
-       PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr);
-       /* RTPRINT(FPHY, PHY_RFW, ("RFW-%d Addr[0x%lx]= 0x%lx\n", eRFPath, pPhyReg->rf3wireOffset, DataAndAddr)); */
-
+       rtl8723au_write32(Adapter, pPhyReg->rf3wireOffset, DataAndAddr);
 }
 
 /**
@@ -392,7 +389,7 @@ PHY_SetRFReg(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath,
        if (BitMask != bRFRegOffsetMask) {
                Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr);
                BitShift =  phy_CalculateBitShift(BitMask);
-               Data = ((Original_Value & (~BitMask)) | (Data << BitShift));
+               Data = (Original_Value & (~BitMask)) | (Data << BitShift);
        }
 
        phy_RFSerialWrite(Adapter, eRFPath, RegAddr, Data);
@@ -419,7 +416,6 @@ PHY_SetRFReg(struct rtw_adapter *Adapter, enum RF_RADIO_PATH eRFPath,
 int PHY_MACConfig8723A(struct rtw_adapter *Adapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-       bool is92C = IS_92C_SERIAL(pHalData->VersionID);
 
        /*  */
        /*  Config MAC */
@@ -427,9 +423,9 @@ int PHY_MACConfig8723A(struct rtw_adapter *Adapter)
        ODM_ReadAndConfig_MAC_REG_8723A(&pHalData->odmpriv);
 
        /*  2010.07.13 AMPDU aggregation number 9 */
-       /* rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); */
        rtl8723au_write8(Adapter, REG_MAX_AGGR_NUM, 0x0A);
-       if (is92C && (BOARD_USB_DONGLE == pHalData->BoardType))
+       if (pHalData->rf_type == RF_2T2R &&
+           BOARD_USB_DONGLE == pHalData->BoardType)
                rtl8723au_write8(Adapter, 0x40, 0x04);
 
        return _SUCCESS;
@@ -831,7 +827,7 @@ PHY_BBConfig8723A(struct rtw_adapter *Adapter)
                             (CrystalCap | (CrystalCap << 6)));
        }
 
-       PHY_SetBBReg(Adapter, REG_LDOA15_CTRL, bMaskDWord, 0x01572505);
+       rtl8723au_write32(Adapter, REG_LDOA15_CTRL, 0x01572505);
        return rtStatus;
 }
 
@@ -920,10 +916,6 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter)
        u8 regBwOpMode;
        u8 regRRSR_RSC;
 
-       /*  There is no 40MHz mode in RF_8225. */
-       if (pHalData->rf_chip == RF_8225)
-               return;
-
        if (Adapter->bDriverStopped)
                return;
 
@@ -997,35 +989,7 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter)
        /* RT_TRACE(COMP_SCAN, DBG_LOUD, ("SetBWMode23aCallback8190Pci: time
           of SetBWMode23a = %I64d us!\n", (EndTime - BeginTime))); */
 
-       /* 3<3>Set RF related register */
-       switch (pHalData->rf_chip) {
-       case RF_8225:
-               /* PHY_SetRF8225Bandwidth(Adapter,
-                  pHalData->CurrentChannelBW); */
-               break;
-
-       case RF_8256:
-               /*  Please implement this function in Hal8190PciPhy8256.c */
-               /* PHY_SetRF8256Bandwidth(Adapter,
-                  pHalData->CurrentChannelBW); */
-               break;
-
-       case RF_8258:
-               /*  Please implement this function in Hal8190PciPhy8258.c */
-               /*  PHY_SetRF8258Bandwidth(); */
-               break;
-
-       case RF_6052:
-               rtl8723a_phy_rf6052set_bw(Adapter, pHalData->CurrentChannelBW);
-               break;
-
-       default:
-               /* RT_ASSERT(false, ("Unknown RFChipID: %d\n",
-                  pHalData->RFChipID)); */
-               break;
-       }
-
-       /* pHalData->SetBWMode23aInProgress = false; */
+       rtl8723a_phy_rf6052set_bw(Adapter, pHalData->CurrentChannelBW);
 
        /* RT_TRACE(COMP_SCAN, DBG_LOUD,
           ("<== PHY_SetBWMode23aCallback8192C() \n")); */
index 1aad4384471cfdc5befb5a1d70183a65e1e14dc3..3e3f18634ffef53cb6e971b0b03f2b4b5b76f92f 100644 (file)
@@ -267,8 +267,8 @@ getTxPowerWriteValByRegulatory(struct rtw_adapter *Adapter, u8 Channel,
                        break;
                case 2: /*  Better regulatory */
                        /*  don't increase any power diff */
-                       writeVal = ((index < 2) ? powerBase0[rf] :
-                                   powerBase1[rf]);
+                       writeVal = (index < 2) ? powerBase0[rf] :
+                                   powerBase1[rf];
                        break;
                case 3: /*  Customer defined power diff. */
                        chnlGroup = 0;
@@ -353,7 +353,7 @@ static void writeOFDMPowerReg(struct rtw_adapter *Adapter, u8 index,
                else
                        RegOffset = RegOffset_B[index];
 
-               PHY_SetBBReg(Adapter, RegOffset, bMaskDWord, writeVal);
+               rtl8723au_write32(Adapter, RegOffset, writeVal);
 
                /*  201005115 Joseph: Set Tx Power diff for Tx power
                    training mechanism. */
index 6075b6dc1beead980e4737aa51bfcfcaca2dad3e..aae433f0e8af456c702131e78026679066d2f331 100644 (file)
@@ -194,8 +194,8 @@ void update_recvframe_phyinfo(struct recv_frame *precvframe,
        bool matchbssid = false;
        u8 *bssid;
 
-       matchbssid = (!ieee80211_is_ctl(hdr->frame_control) &&
-                     !pattrib->icv_err && !pattrib->crc_err);
+       matchbssid = !ieee80211_is_ctl(hdr->frame_control) &&
+                     !pattrib->icv_err && !pattrib->crc_err;
 
        if (matchbssid) {
                switch (hdr->frame_control &
index adbf1c2dd383ac9fd921e422b143bc40cb84e99c..0d08863d72bd16d5be8fa265b5a0a91834e1f21d 100644 (file)
@@ -447,22 +447,8 @@ static void _InitRetryFunction(struct rtw_adapter *Adapter)
 static void _InitRFType(struct rtw_adapter *Adapter)
 {
        struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-       bool is92CU = IS_92C_SERIAL(pHalData->VersionID);
 
-       pHalData->rf_chip = RF_6052;
-
-       if (!is92CU) {
-               pHalData->rf_type = RF_1T1R;
-               DBG_8723A("Set RF Chip ID to RF_6052 and RF type to 1T1R.\n");
-               return;
-       }
-
-       /*  TODO: Consider that EEPROM set 92CU to 1T1R later. */
-       /*  Force to overwrite setting according to chip version. Ignore
-           EEPROM setting. */
-       /* pHalData->RF_Type = is92CU ? RF_2T2R : RF_1T1R; */
-       MSG_8723A("Set RF Chip ID to RF_6052 and RF type to %d.\n",
-                 pHalData->rf_type);
+       pHalData->rf_type = RF_1T1R;
 }
 
 /*  Set CCK and OFDM Block "ON" */
@@ -572,12 +558,10 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
        status = rtl8723a_FirmwareDownload(Adapter);
        if (status != _SUCCESS) {
                Adapter->bFWReady = false;
-               pHalData->fw_ractrl = false;
                DBG_8723A("fw download fail!\n");
                goto exit;
        } else {
                Adapter->bFWReady = true;
-               pHalData->fw_ractrl = true;
                DBG_8723A("fw download ok!\n");
        }
 
@@ -625,17 +609,22 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
        }
 
        /* reducing 80M spur */
-       PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, bMaskDWord, 0x0381808d);
-       PHY_SetBBReg(Adapter, REG_AFE_PLL_CTRL, bMaskDWord, 0xf0ffff83);
-       PHY_SetBBReg(Adapter, REG_AFE_PLL_CTRL, bMaskDWord, 0xf0ffff82);
-       PHY_SetBBReg(Adapter, REG_AFE_PLL_CTRL, bMaskDWord, 0xf0ffff83);
+       rtl8723au_write32(Adapter, REG_AFE_XTAL_CTRL, 0x0381808d);
+       rtl8723au_write32(Adapter, REG_AFE_PLL_CTRL, 0xf0ffff83);
+       rtl8723au_write32(Adapter, REG_AFE_PLL_CTRL, 0xf0ffff82);
+       rtl8723au_write32(Adapter, REG_AFE_PLL_CTRL, 0xf0ffff83);
 
        /* RFSW Control */
-       PHY_SetBBReg(Adapter, rFPGA0_TxInfo, bMaskDWord, 0x00000003);   /* 0x804[14]= 0 */
-       PHY_SetBBReg(Adapter, rFPGA0_XAB_RFInterfaceSW, bMaskDWord, 0x07000760);        /* 0x870[6:5]= b'11 */
-       PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, 0x66F60210); /* 0x860[6:5]= b'00 */
+       /* 0x804[14]= 0 */
+       rtl8723au_write32(Adapter, rFPGA0_TxInfo, 0x00000003);
+       /* 0x870[6:5]= b'11 */
+       rtl8723au_write32(Adapter, rFPGA0_XAB_RFInterfaceSW, 0x07000760);
+       /* 0x860[6:5]= b'00 */
+       rtl8723au_write32(Adapter, rFPGA0_XA_RFInterfaceOE, 0x66F60210);
 
-       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("%s: 0x870 = value 0x%x\n", __func__, PHY_QueryBBReg(Adapter, 0x870, bMaskDWord)));
+       RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
+                ("%s: 0x870 = value 0x%x\n", __func__,
+                 rtl8723au_read32(Adapter, 0x870)));
 
        /*  */
        /*  Joseph Note: Keep RfRegChnlVal for later use. */
@@ -747,8 +736,8 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 
        rtl8723a_InitHalDm(Adapter);
 
-       val8 = ((WiFiNavUpperUs + HAL_8723A_NAV_UPPER_UNIT - 1) /
-               HAL_8723A_NAV_UPPER_UNIT);
+       val8 = (WiFiNavUpperUs + HAL_8723A_NAV_UPPER_UNIT - 1) /
+               HAL_8723A_NAV_UPPER_UNIT;
        rtl8723au_write8(Adapter, REG_NAV_UPPER, val8);
 
        /*  2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */
@@ -806,19 +795,18 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter,
 
                /* AFE */
                if (pHalData->rf_type ==  RF_2T2R)
-                       PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord,
-                                    0x63DB25A0);
+                       rtl8723au_write32(Adapter, rRx_Wait_CCA, 0x63DB25A0);
                else if (pHalData->rf_type ==  RF_1T1R)
-                       PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord,
-                                    0x631B25A0);
+                       rtl8723au_write32(Adapter, rRx_Wait_CCA, 0x631B25A0);
 
                /*  4. issue 3-wire command that RF set to Rx idle
                    mode. This is used to re-write the RX idle mode. */
                /*  We can only prvide a usual value instead and then
                    HW will modify the value by itself. */
-               PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0x32D95);
+               PHY_SetRFReg(Adapter, RF_PATH_A, RF_AC,
+                            bRFRegOffsetMask, 0x32D95);
                if (pHalData->rf_type ==  RF_2T2R) {
-                       PHY_SetRFReg(Adapter, RF_PATH_B, 0,
+                       PHY_SetRFReg(Adapter, RF_PATH_B, RF_AC,
                                     bRFRegOffsetMask, 0x32D95);
                }
                break;
@@ -840,13 +828,11 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter,
                                                for packet detection */
                /*      (4) Reg800[1] = 1       enable preamble power saving */
                Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF0] =
-                       PHY_QueryBBReg(Adapter, rFPGA0_XAB_RFParameter,
-                                      bMaskDWord);
+                       rtl8723au_read32(Adapter, rFPGA0_XAB_RFParameter);
                Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF1] =
-                       PHY_QueryBBReg(Adapter, rOFDM0_TRxPathEnable,
-                                      bMaskDWord);
+                       rtl8723au_read32(Adapter, rOFDM0_TRxPathEnable);
                Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_RF2] =
-                       PHY_QueryBBReg(Adapter, rFPGA0_RFMOD, bMaskDWord);
+                       rtl8723au_read32(Adapter, rFPGA0_RFMOD);
                if (pHalData->rf_type ==  RF_2T2R) {
                        PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter,
                                     0x380038, 0);
@@ -858,18 +844,16 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter,
 
                /*  2 .AFE control register to power down. bit[30:22] */
                Adapter->pwrctrlpriv.PS_BBRegBackup[PSBBREG_AFE0] =
-                       PHY_QueryBBReg(Adapter, rRx_Wait_CCA, bMaskDWord);
+                       rtl8723au_read32(Adapter, rRx_Wait_CCA);
                if (pHalData->rf_type ==  RF_2T2R)
-                       PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord,
-                                    0x00DB25A0);
+                       rtl8723au_write32(Adapter, rRx_Wait_CCA, 0x00DB25A0);
                else if (pHalData->rf_type ==  RF_1T1R)
-                       PHY_SetBBReg(Adapter, rRx_Wait_CCA, bMaskDWord,
-                                    0x001B25A0);
+                       rtl8723au_write32(Adapter, rRx_Wait_CCA, 0x001B25A0);
 
                /*  3. issue 3-wire command that RF set to power down.*/
-               PHY_SetRFReg(Adapter, RF_PATH_A, 0, bRFRegOffsetMask, 0);
+               PHY_SetRFReg(Adapter, RF_PATH_A, RF_AC, bRFRegOffsetMask, 0);
                if (pHalData->rf_type ==  RF_2T2R)
-                       PHY_SetRFReg(Adapter, RF_PATH_B, 0,
+                       PHY_SetRFReg(Adapter, RF_PATH_B, RF_AC,
                                     bRFRegOffsetMask, 0);
 
                /*  4. Force PFM , disable SPS18_LDO_Marco_Block */
@@ -1102,13 +1086,6 @@ static void _ReadPROMContent(struct rtw_adapter *Adapter)
        readAdapterInfo(Adapter);
 }
 
-static void _ReadRFType(struct rtw_adapter *Adapter)
-{
-       struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-
-       pHalData->rf_chip = RF_6052;
-}
-
 /*  */
 /*     Description: */
 /*             We should set Efuse cell selection to WiFi cell in default. */
@@ -1138,12 +1115,8 @@ void rtl8723a_read_adapter_info(struct rtw_adapter *Adapter)
 
        hal_EfuseCellSel(Adapter);
 
-       _ReadRFType(Adapter);/* rf_chip -> _InitRFType() */
        _ReadPROMContent(Adapter);
 
-       /* MSG_8723A("%s()(done), rf_chip = 0x%x, rf_type = 0x%x\n",
-          __func__, pHalData->rf_chip, pHalData->rf_type); */
-
        MSG_8723A("<==== _ReadAdapterInfo8723AU in %d ms\n",
                  jiffies_to_msecs(jiffies - start));
 }
@@ -1211,7 +1184,7 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter,
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        struct wlan_bssid_ex *cur_network = &pmlmeinfo->network;
-       u8 init_rate, networkType, raid;
+       u8 init_rate, networkType, raid, arg;
        u32 mask, rate_bitmap;
        u8 shortGIrate = false;
        int supportRateNum;
@@ -1283,27 +1256,15 @@ void rtl8723a_update_ramask(struct rtw_adapter *padapter,
 
        init_rate = get_highest_rate_idx23a(mask) & 0x3f;
 
-       if (pHalData->fw_ractrl == true) {
-               u8 arg = 0;
-
-               arg = mac_id & 0x1f;/* MACID */
+       arg = mac_id & 0x1f;/* MACID */
+       arg |= BIT(7);
 
-               arg |= BIT(7);
+       if (shortGIrate == true)
+               arg |= BIT(5);
 
-               if (shortGIrate == true)
-                       arg |= BIT(5);
+       DBG_8723A("update raid entry, mask = 0x%x, arg = 0x%x\n", mask, arg);
 
-               DBG_8723A("update raid entry, mask = 0x%x, arg = 0x%x\n",
-                         mask, arg);
-
-               rtl8723a_set_raid_cmd(padapter, mask, arg);
-       } else {
-               if (shortGIrate == true)
-                       init_rate |= BIT(6);
-
-               rtl8723au_write8(padapter, (REG_INIDATA_RATE_SEL + mac_id),
-                                init_rate);
-       }
+       rtl8723a_set_raid_cmd(padapter, mask, arg);
 
        /* set ra_id */
        psta->raid = raid;
index 2247d98747194c23ef76f09eaaccf1a8455d8347..bcf36579f43aea293b36d54068c4aff0a48ff8b5 100644 (file)
@@ -16,9 +16,6 @@
 #ifndef __INC_HAL8723PHYCFG_H__
 #define __INC_HAL8723PHYCFG_H__
 
-/*--------------------------Define Parameters-------------------------------*/
-#define MAX_AGGR_NUM   0x0909
-
 /*------------------------------Define structure----------------------------*/
 enum RF_RADIO_PATH {
        RF_PATH_A = 0,                  /* Radio Path A */
@@ -39,15 +36,6 @@ enum WIRELESS_MODE {
        WIRELESS_MODE_AC        = BIT(6)
 };
 
-/* BB/RF related */
-enum rf_type_8190p {
-       RF_TYPE_MIN,            /*  0 */
-       RF_8225 = 1,            /*  1 11b/g RF for verification only */
-       RF_8256 = 2,            /*  2 11b/g/n */
-       RF_8258 = 3,            /*  3 11a/b/g/n RF */
-       RF_6052 = 4,            /*  4 11b/g/n RF */
-};
-
 struct bb_reg_define {
        u32 rfintfs;            /*  set software control: */
                                /*              0x870~0x877[8 bytes] */
index 607b71f6e1e4ca754c59afdffbc19cdae8d0cfef..2a0e4ea7afadc66b30874eb3fb7d426e932f7cf0 100644 (file)
@@ -51,30 +51,17 @@ enum hal_vendor {
        CHIP_VENDOR_UMC         =       1,
 };
 
-enum hal_rf_type {
-       RF_TYPE_1T1R    =       0,
-       RF_TYPE_1T2R    =       1,
-       RF_TYPE_2T2R    =       2,
-       RF_TYPE_2T3R    =       3,
-       RF_TYPE_2T4R    =       4,
-       RF_TYPE_3T3R    =       5,
-       RF_TYPE_3T4R    =       6,
-       RF_TYPE_4T4R    =       7,
-};
-
 struct hal_version {
        enum hal_ic_type        ICType;
        enum hal_chip_type      ChipType;
        enum hal_cut_version    CUTVersion;
        enum hal_vendor         VendorType;
-       enum hal_rf_type        RFType;
        u8                      ROMVer;
 };
 
 /*  Get element */
 #define GET_CVID_IC_TYPE(version)      ((version).ICType)
 #define GET_CVID_CHIP_TYPE(version)    ((version).ChipType)
-#define GET_CVID_RF_TYPE(version)      ((version).RFType)
 #define GET_CVID_MANUFACTUER(version)  ((version).VendorType)
 #define GET_CVID_CUT_VERSION(version)  ((version).CUTVersion)
 #define GET_CVID_ROM_VERSION(version)  (((version).ROMVer) & ROM_VERSION_MASK)
@@ -108,17 +95,8 @@ struct hal_version {
 #define IS_CHIP_VENDOR_UMC(version)            \
        ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false)
 
-#define IS_1T1R(version)                       \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false)
-#define IS_1T2R(version)                       \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false)
-#define IS_2T2R(version)                       \
-       ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false)
-
 /* Chip version Macro. -- */
 
-#define IS_92C_SERIAL(version)                                 \
-       ((IS_81XXC(version) && IS_2T2R(version)) ? true : false)
 #define IS_81xxC_VENDOR_UMC_A_CUT(version)                     \
        (IS_81XXC(version)?(IS_CHIP_VENDOR_UMC(version) ?       \
        (IS_A_CUT(version) ? true : false) : false) : false)
index 7c31865e9865a08c96c8fb7f95c935fd5e5a113d..9c50320b2100008299b69c3501dd87d54a33df2d 100644 (file)
 #define RATE_36M                               BIT(9)
 #define RATE_48M                               BIT(10)
 #define RATE_54M                               BIT(11)
-/* MCS 1 Spatial Stream */
-#define RATE_MCS0                              BIT(12)
-#define RATE_MCS1                              BIT(13)
-#define RATE_MCS2                              BIT(14)
-#define RATE_MCS3                              BIT(15)
-#define RATE_MCS4                              BIT(16)
-#define RATE_MCS5                              BIT(17)
-#define RATE_MCS6                              BIT(18)
-#define RATE_MCS7                              BIT(19)
-/* MCS 2 Spatial Stream */
-#define RATE_MCS8                              BIT(20)
-#define RATE_MCS9                              BIT(21)
-#define RATE_MCS10                             BIT(22)
-#define RATE_MCS11                             BIT(23)
-#define RATE_MCS12                             BIT(24)
-#define RATE_MCS13                             BIT(25)
-#define RATE_MCS14                             BIT(26)
-#define RATE_MCS15                             BIT(27)
-
-/*  ALL CCK Rate */
-#define        RATE_ALL_CCK    (RATR_1M | RATR_2M | RATR_55M | RATR_11M)
-#define        RATE_ALL_OFDM_AG                                \
-       (RATR_6M | RATR_9M | RATR_12M | RATR_18M | RATR_24M| \
-        RATR_36M|RATR_48M|RATR_54M)
-#define        RATE_ALL_OFDM_1SS                               \
-       (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | RATR_MCS3 |        \
-        RATR_MCS4 | RATR_MCS5 | RATR_MCS6 | RATR_MCS7)
-#define        RATE_ALL_OFDM_2SS                               \
-       (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | RATR_MCS11|       \
-        RATR_MCS12 | RATR_MCS13 | RATR_MCS14 | RATR_MCS15)
 
 /*------------------------------ Tx Desc definition Macro ------------------------*/
 /* pragma mark -- Tx Desc related definition. -- */
 #define REG_NOA_DESC_COUNT                     0x05EC
 
 #include "HalVerDef.h"
-void dump_chip_info23a(struct hal_version      ChipVersion);
 
 
 u8     /* return the final channel plan decision */
index 404acb52352daa0ef57eb23c19c47975845ad214..b924d47fcfbc570da848780f870c60c16bcfb44b 100644 (file)
 #include <osdep_service.h>
 #include <drv_types.h>
 
-enum RTL871X_HCI_TYPE {
-       RTW_PCIE        = BIT(0),
-       RTW_USB         = BIT(1),
-       RTW_SDIO        = BIT(2),
-       RTW_GSPI        = BIT(3),
-};
-
 enum _CHIP_TYPE {
        NULL_CHIP_TYPE,
        RTL8712_8188S_8191S_8192S,
index cb23cd0349b4ae9e13e23345193641535a19086e..3caf4f502ad8052da6598c284833be5ffc60a888 100644 (file)
@@ -171,20 +171,6 @@ struct ieee80211_snap_hdr {
 #define WLAN_REASON_JOIN_WRONG_CHANNEL       65534
 #define WLAN_REASON_EXPIRATION_CHK 65535
 
-
-#define IEEE80211_STATMASK_SIGNAL (1<<0)
-#define IEEE80211_STATMASK_RSSI (1<<1)
-#define IEEE80211_STATMASK_NOISE (1<<2)
-#define IEEE80211_STATMASK_RATE (1<<3)
-#define IEEE80211_STATMASK_WEMASK 0x7
-
-
-#define IEEE80211_CCK_MODULATION    (1<<0)
-#define IEEE80211_OFDM_MODULATION   (1<<1)
-
-#define IEEE80211_24GHZ_BAND     (1<<0)
-#define IEEE80211_52GHZ_BAND     (1<<1)
-
 #define IEEE80211_CCK_RATE_LEN                 4
 #define IEEE80211_NUM_OFDM_RATESLEN    8
 
index 5a0561e092ac63bd4bf6ceab81ce360c537ad711..24f2f28c473f4bc832f90deb016252a3062e866f 100644 (file)
@@ -158,27 +158,6 @@ struct false_alarm_stats {
        u32     Cnt_BW_LSC;     /* Gary */
 };
 
-struct pri_cca {
-       u8              PriCCA_flag;
-       u8              intf_flag;
-       u8              intf_type;
-       u8              DupRTS_flag;
-       u8              Monitor_flag;
-};
-
-struct rx_hp {
-       u8              RXHP_flag;
-       u8              PSD_func_trigger;
-       u8              PSD_bitmap_RXHP[80];
-       u8              Pre_IGI;
-       u8              Cur_IGI;
-       u8              Pre_pw_th;
-       u8              Cur_pw_th;
-       bool            First_time_enter;
-       bool            RXHP_enable;
-       u8              TP_Mode;
-};
-
 #define ASSOCIATE_ENTRY_NUM                                    32 /*  Max size of AsocEntry[]. */
 #define        ODM_ASSOCIATE_ENTRY_NUM                         ASSOCIATE_ENTRY_NUM
 
@@ -227,7 +206,6 @@ struct sw_ant_sw {
 
 struct edca_turbo {
        bool bCurrentTurboEDCA;
-       bool bIsCurRDLState;
        u32     prv_traffic_idx; /*  edca turbo */
 };
 
@@ -298,18 +276,14 @@ enum odm_cmninfo {
        /*  Fixed value: */
        /*  */
 
-       ODM_CMNINFO_PLATFORM = 0,
-       ODM_CMNINFO_INTERFACE,                          /*  enum odm_interface_def */
-       ODM_CMNINFO_MP_TEST_CHIP,
-       ODM_CMNINFO_IC_TYPE,                                    /*  enum odm_ic_type_def */
-       ODM_CMNINFO_CUT_VER,                                    /*  enum odm_cut_version */
-       ODM_CMNINFO_FAB_VER,                                    /*  enum odm_fab_version */
-       ODM_CMNINFO_RF_TYPE,                                    /*  enum rf_path_def or enum odm_rf_type? */
-       ODM_CMNINFO_BOARD_TYPE,                         /*  enum odm_board_type */
-       ODM_CMNINFO_EXT_LNA,                                    /*  true */
+       ODM_CMNINFO_MP_TEST_CHIP = 2,
+       ODM_CMNINFO_IC_TYPE,                    /*  enum odm_ic_type_def */
+       ODM_CMNINFO_CUT_VER,                    /*  enum odm_cut_version */
+       ODM_CMNINFO_FAB_VER,                    /*  enum odm_fab_version */
+       ODM_CMNINFO_BOARD_TYPE,                 /*  enum odm_board_type */
+       ODM_CMNINFO_EXT_LNA,                    /*  true */
        ODM_CMNINFO_EXT_PA,
        ODM_CMNINFO_EXT_TRSW,
-       ODM_CMNINFO_PATCH_ID,                           /* CUSTOMER ID */
        ODM_CMNINFO_BINHCT_TEST,
        ODM_CMNINFO_BWIFI_TEST,
        ODM_CMNINFO_SMART_CONCURRENT,
@@ -348,29 +322,7 @@ enum odm_cmninfo {
 /*  Define ODM support ability.  ODM_CMNINFO_ABILITY */
 enum {
        /*  BB ODM section BIT 0-15 */
-       ODM_BB_DIG                              = BIT(0),
-       ODM_BB_RA_MASK                          = BIT(1),
-       ODM_BB_DYNAMIC_TXPWR                    = BIT(2),
-       ODM_BB_FA_CNT                           = BIT(3),
-       ODM_BB_RSSI_MONITOR                     = BIT(4),
-       ODM_BB_CCK_PD                           = BIT(5),
        ODM_BB_ANT_DIV                          = BIT(6),
-       ODM_BB_PWR_SAVE                         = BIT(7),
-       ODM_BB_PWR_TRAIN                        = BIT(8),
-       ODM_BB_RATE_ADAPTIVE                    = BIT(9),
-       ODM_BB_PATH_DIV                         = BIT(10),
-       ODM_BB_PSD                              = BIT(11),
-       ODM_BB_RXHP                             = BIT(12),
-
-       /*  MAC DM section BIT 16-23 */
-       ODM_MAC_EDCA_TURBO                      = BIT(16),
-       ODM_MAC_EARLY_MODE                      = BIT(17),
-
-       /*  RF ODM section BIT 24-31 */
-       ODM_RF_TX_PWR_TRACK                     = BIT(24),
-       ODM_RF_RX_GAIN_TRACK                    = BIT(25),
-       ODM_RF_CALIBRATION                      = BIT(26),
-
 };
 
 /*     ODM_CMNINFO_INTERFACE */
@@ -409,7 +361,6 @@ enum odm_fab_version {
        ODM_UMC         =       1,
 };
 
-/*  ODM_CMNINFO_RF_TYPE */
 /*  For example 1T2R (A+AB = BIT0|BIT4|BIT5) */
 enum rf_path_def {
        ODM_RF_TX_A     =       BIT(0),
@@ -422,18 +373,6 @@ enum rf_path_def {
        ODM_RF_RX_D     =       BIT(7),
 };
 
-
-enum odm_rf_type {
-       ODM_1T1R        =       0,
-       ODM_1T2R        =       1,
-       ODM_2T2R        =       2,
-       ODM_2T3R        =       3,
-       ODM_2T4R        =       4,
-       ODM_3T3R        =       5,
-       ODM_3T4R        =       6,
-       ODM_4T4R        =       7,
-};
-
 /*  ODM Dynamic common info value definition */
 
 enum odm_mac_phy_mode {
@@ -587,33 +526,6 @@ struct odm_rf_cal_t {
        u8      bDPPathBOK;
 };
 
-/*  ODM Dynamic common info value definition */
-struct odm_fat_t {
-       u8      Bssid[6];
-       u8      antsel_rx_keep_0;
-       u8      antsel_rx_keep_1;
-       u8      antsel_rx_keep_2;
-       u32     antSumRSSI[7];
-       u32     antRSSIcnt[7];
-       u32     antAveRSSI[7];
-       u8      FAT_State;
-       u32     TrainIdx;
-       u8      antsel_a[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      antsel_b[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      antsel_c[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     MainAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     AuxAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     MainAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-       u32     AuxAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM];
-       u8      RxIdleAnt;
-       bool    bBecomeLinked;
-};
-
-enum fat_state {
-       FAT_NORMAL_STATE                = 0,
-       FAT_TRAINING_STATE              = 1,
-};
-
 enum ant_dif_type {
        NO_ANTDIV                       = 0xFF,
        CG_TRX_HW_ANTDIV                = 0x01,
@@ -636,7 +548,6 @@ struct dm_odm_t {
 /*  ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */
        bool                    bCckHighPower;
        u8                      RFPathRxEnable;         /*  ODM_CMNINFO_RFPATH_ENABLE */
-       u8                      ControlChannel;
 /*  ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */
 
 /* 1  COMMON INFORMATION */
@@ -645,16 +556,12 @@ struct dm_odm_t {
 /* HOOK BEFORE REG INIT----------- */
        /*  ODM Support Ability DIG/RATR/TX_PWR_TRACK/ Â¡K¡K = 1/2/3/¡K */
        u32                     SupportAbility;
-       /*  ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */
-       u8                      SupportInterface;
        /*  ODM composite or independent. Bit oriented/ 92C+92D+ .... or any other type = 1/2/3/... */
        u32                     SupportICType;
        /*  Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */
        u8                      CutVersion;
        /*  Fab Version TSMC/UMC = 0/1 */
        u8                      FabVersion;
-       /*  RF Type 4T4R/3T3R/2T2R/1T2R/1T1R/... */
-       u8                      RFType;
        /*  Board Type Normal/HighPower/MiniCard/SLIM/Combo/... = 0/1/2/3/4/... */
        u8                      BoardType;
        /*  with external LNA  NO/Yes = 0/1 */
@@ -663,7 +570,6 @@ struct dm_odm_t {
        u8                      ExtPA;
        /*  with external TRSW  NO/Yes = 0/1 */
        u8                      ExtTRSW;
-       u8                      PatchID; /* Customer ID */
        bool                    bInHctTest;
        bool                    bWIFITest;
 
@@ -703,14 +609,6 @@ struct dm_odm_t {
        /*  2012/01/12 MH For MP, we need to reduce one array pointer for default port.?? */
        struct sta_info *               pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM];
 
-       /*  */
-       /*  2012/02/14 MH Add to share 88E ra with other SW team. */
-       /*  We need to colelct all support abilit to a proper area. */
-       /*  */
-       bool                            RaSupport88E;
-
-       /*  Define ........... */
-
        /*  Latest packet phy info (ODM write) */
        struct odm_phy_dbg_info  PhyDbgInfo;
        /* PHY_INFO_88E         PhyInfo; */
@@ -728,11 +626,8 @@ struct dm_odm_t {
        /*  */
        /* ODM Structure */
        /*  */
-       struct odm_fat_t                DM_FatTable;
        struct dig_t    DM_DigTable;
        struct dynamic_pwr_sav          DM_PSTable;
-       struct pri_cca  DM_PriCCA;
-       struct rx_hp            DM_RXHP_Table;
        struct false_alarm_stats        FalseAlmCnt;
        struct false_alarm_stats        FlaseAlmCntBuddyAdapter;
        struct sw_ant_sw                DM_SWAT_Table;
@@ -745,32 +640,11 @@ struct dm_odm_t {
        /*  */
 
        /* PSD */
-       bool                    bUserAssignLevel;
-       u8                      RSSI_BT;                        /* come from BT */
-       bool                    bPSDinProcess;
-
-       /* for rate adaptive, in fact,  88c/92c fw will handle this */
-       u8                      bUseRAMask;
-
+       u8                      RSSI_BT;                /* come from BT */
        struct odm_rate_adapt   RateAdaptive;
 
 
        struct odm_rf_cal_t     RFCalibrateInfo;
-
-       /*  */
-       /*  TX power tracking */
-       /*  */
-       u8                      BbSwingIdxOfdm;
-       u8                      BbSwingIdxOfdmCurrent;
-       u8                      BbSwingIdxOfdmBase;
-       bool                    BbSwingFlagOfdm;
-       u8                      BbSwingIdxCck;
-       u8                      BbSwingIdxCckCurrent;
-       u8                      BbSwingIdxCckBase;
-       bool                    BbSwingFlagCck;
-       /*  */
-       /*  ODM system resource. */
-       /*  */
 };     /*  DM_Dynamic_Mechanism_Structure */
 
 enum odm_rf_content {
@@ -983,6 +857,4 @@ void ODM_SingleDualAntennaDefaultSetting(struct dm_odm_t *pDM_Odm);
 
 bool ODM_SingleDualAntennaDetection(struct dm_odm_t *pDM_Odm, u8 mode);
 
-void odm_dtc(struct dm_odm_t *pDM_Odm);
-
 #endif
index a6cfb6df4cf7353670d28091272be01dcb581157..f2a54d829ed56925a488005591550a6aed5d3237 100644 (file)
@@ -20,9 +20,8 @@ void odm_ConfigRFReg_8723A(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data,
 
 void odm_ConfigMAC_8723A(struct dm_odm_t *pDM_Odm, u32 Addr, u8 Data);
 
-void odm_ConfigBB_AGC_8723A(struct dm_odm_t *pDM_Odm, u32 Addr,
-                           u32 Bitmask, u32 Data);
+void odm_ConfigBB_AGC_8723A(struct dm_odm_t *pDM_Odm, u32 addr, u32 data);
 
-void odm_ConfigBB_PHY_8723A(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data);
+void odm_ConfigBB_PHY_8723A(struct dm_odm_t *pDM_Odm, u32 addr, u32 data);
 
 #endif /*  end of SUPPORT */
index ea35070b744f97c1fe089d70c55e128caef1e498..1d3bf03b59ea7a40a4a100a8587702c4ebfebc3a 100644 (file)
@@ -54,17 +54,6 @@ typedef void (*RT_WORKITEM_CALL_BACK)(struct work_struct *pContext);
 /*  =========== EXtern Function Prototype */
 /*  */
 
-
-u8 ODM_Read1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr);
-u16 ODM_Read2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr);
-u32 ODM_Read4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr);
-void ODM_Write1Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u8 Data);
-void ODM_Write2Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u16 Data);
-void ODM_Write4Byte(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 Data);
-void ODM_SetMACReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data);
-u32 ODM_GetMACReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask);
-void ODM_SetBBReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data);
-u32 ODM_GetBBReg(struct dm_odm_t *pDM_Odm, u32 RegAddr, u32 BitMask);
 void ODM_SetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath,
                  u32 RegAddr, u32 BitMask, u32 Data);
 u32 ODM_GetRFReg(struct dm_odm_t *pDM_Odm, enum RF_RADIO_PATH eRFPath,
index e14633678b52d1d63d32efad4036a52465ad12bd..ad3a442bc000cba7b2f6f8616973b1f953572ff4 100644 (file)
@@ -270,7 +270,6 @@ struct hal_data_8723a {
        u16     BasicRateSet;
 
        /* rf_ctrl */
-       u8      rf_chip;
        u8      rf_type;
        u8      NumTotalRFPath;
 
@@ -348,7 +347,6 @@ struct hal_data_8723a {
        /* for host message to fw */
        u8      LastHMEBoxNum;
 
-       u8      fw_ractrl;
        u8      RegTxPause;
        /*  Beacon function related global variable. */
        u8      RegFwHwTxQCtrl;
index 1b23eb13222b76baafb92d974a9308fabd836203..db6a15971a211530a4854617420bd48b7914573e 100644 (file)
@@ -34,7 +34,7 @@ MODULE_FIRMWARE("rtlwifi/rtl8723aufw_B.bin");
 MODULE_FIRMWARE("rtlwifi/rtl8723aufw_B_NoBT.bin");
 
 /* module param defaults */
-static int rtw_chip_version = 0x00;
+static int rtw_chip_version;
 static int rtw_rfintfs = HWPI;
 static int rtw_debug = 1;
 
index 05755b870a5fbeaeda0de95d1a7dc1e7c9980e09..bab06995078b80ed9ab7f40e4c49c6d84176e883 100644 (file)
@@ -237,6 +237,7 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter)
 static void rtw_dev_unload(struct rtw_adapter *padapter)
 {
        struct submit_ctx *pack_tx_ops = &padapter->xmitpriv.ack_tx_ops;
+
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n"));
 
        if (padapter->bup) {
@@ -599,8 +600,6 @@ static void rtw_disconnect(struct usb_interface *pusb_intf)
 
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n"));
        DBG_8723A("-r871xu_dev_remove, done\n");
-
-       return;
 }
 
 static int __init rtw_drv_entry(void)
index a47a19135d49ff27fd8d4edd164f389f1bd6bb80..4c38ff9d9a765ec22c6ecab81ec2aae3da7949fd 100644 (file)
@@ -107,7 +107,7 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode,
 }
 
 static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode,
-                       u8 tpc, u16 sec_cnt, u8 cfg, int mode_2k,
+                       u8 tpc, u16 sec_cnt, u8 cfg, bool mode_2k,
                        int use_sg, void *buf, int buf_len)
 {
        int retval;
@@ -1560,7 +1560,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
                u16 log_blk, u8 start_page, u8 end_page)
 {
        struct ms_info *ms_card = &(chip->ms_card);
-       int retval, rty_cnt, uncorrect_flag = 0;
+       bool uncorrect_flag = false;
+       int retval, rty_cnt;
        u8 extra[MS_EXTRA_SIZE], val, i, j, data[16];
 
        dev_dbg(rtsx_dev(chip), "Copy page from 0x%x to 0x%x, logical block is 0x%x\n",
@@ -1642,10 +1643,10 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
                        if (val & INT_REG_ERR) {
                                retval = ms_read_status_reg(chip);
                                if (retval != STATUS_SUCCESS) {
-                                       uncorrect_flag = 1;
+                                       uncorrect_flag = true;
                                        dev_dbg(rtsx_dev(chip), "Uncorrectable error\n");
                                } else {
-                                       uncorrect_flag = 0;
+                                       uncorrect_flag = false;
                                }
 
                                retval = ms_transfer_tpc(chip,
@@ -2029,6 +2030,8 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip)
 
        reg_addr = PPBUF_BASE2;
        for (i = 0; i < (((ms_card->total_block >> 9) * 10) + 1); i++) {
+               int block_no;
+
                retval = rtsx_read_register(chip, reg_addr++, &val1);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, INIT_FAIL);
@@ -2042,7 +2045,9 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip)
                        break;
 
                seg_no = defect_block / 512;
-               ms_card->segment[seg_no].defect_list[ms_card->segment[seg_no].disable_count++] = defect_block;
+
+               block_no = ms_card->segment[seg_no].disable_count++;
+               ms_card->segment[seg_no].defect_list[block_no] = defect_block;
        }
 
        for (i = 0; i < ms_card->segment_cnt; i++) {
@@ -2187,8 +2192,9 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 {
        struct ms_info *ms_card = &(chip->ms_card);
        struct zone_entry *segment;
-       int retval, table_size, disable_cnt, defect_flag, i;
-       u16 start, end, phy_blk, log_blk, tmp_blk;
+       bool defect_flag;
+       int retval, table_size, disable_cnt, i;
+       u16 start, end, phy_blk, log_blk, tmp_blk, idx;
        u8 extra[MS_EXTRA_SIZE], us1, us2;
 
        dev_dbg(rtsx_dev(chip), "ms_build_l2p_tbl: %d\n", seg_no);
@@ -2236,10 +2242,10 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 
        for (phy_blk = start; phy_blk < end; phy_blk++) {
                if (disable_cnt) {
-                       defect_flag = 0;
+                       defect_flag = false;
                        for (i = 0; i < segment->disable_count; i++) {
                                if (phy_blk == segment->defect_list[i]) {
-                                       defect_flag = 1;
+                                       defect_flag = true;
                                        break;
                                }
                        }
@@ -2299,13 +2305,15 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
                        continue;
                }
 
-               if (segment->l2p_table[log_blk - ms_start_idx[seg_no]] == 0xFFFF) {
-                       segment->l2p_table[log_blk - ms_start_idx[seg_no]] = phy_blk;
+               idx = log_blk - ms_start_idx[seg_no];
+
+               if (segment->l2p_table[idx] == 0xFFFF) {
+                       segment->l2p_table[idx] = phy_blk;
                        continue;
                }
 
                us1 = extra[0] & 0x10;
-               tmp_blk = segment->l2p_table[log_blk - ms_start_idx[seg_no]];
+               tmp_blk = segment->l2p_table[idx];
                retval = ms_read_extra_data(chip, tmp_blk, 0,
                                        extra, MS_EXTRA_SIZE);
                if (retval != STATUS_SUCCESS)
@@ -2336,7 +2344,8 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 
        for (log_blk = ms_start_idx[seg_no];
             log_blk < ms_start_idx[seg_no + 1]; log_blk++) {
-               if (segment->l2p_table[log_blk-ms_start_idx[seg_no]] == 0xFFFF) {
+               idx = log_blk - ms_start_idx[seg_no];
+               if (segment->l2p_table[idx] == 0xFFFF) {
                        phy_blk = ms_get_unused_block(chip, seg_no);
                        if (phy_blk == 0xFFFF) {
                                chip->card_wp |= MS_CARD;
@@ -2346,7 +2355,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
                        if (retval != STATUS_SUCCESS)
                                TRACE_GOTO(chip, BUILD_FAIL);
 
-                       segment->l2p_table[log_blk-ms_start_idx[seg_no]] = phy_blk;
+                       segment->l2p_table[idx] = phy_blk;
                        if (seg_no == ms_card->segment_cnt - 1) {
                                if (segment->unused_blk_cnt < 2) {
                                        chip->card_wp |= MS_CARD;
@@ -2522,7 +2531,8 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                                u16 sector_cnt)
 {
        struct ms_info *ms_card = &(chip->ms_card);
-       int retval, mode_2k = 0;
+       bool mode_2k = false;
+       int retval;
        u16 count;
        u8 val, trans_mode, rw_tpc, rw_cmd;
 
@@ -2547,7 +2557,7 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                                rw_tpc = PRO_WRITE_QUAD_DATA;
                                rw_cmd = PRO_WRITE_2K_DATA;
                        }
-                       mode_2k = 1;
+                       mode_2k = true;
                }
        } else {
                if (srb->sc_data_direction == DMA_FROM_DEVICE) {
@@ -2780,7 +2790,7 @@ void mspro_polling_format_status(struct rtsx_chip *chip)
 }
 
 int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
-               int short_data_len, int quick_format)
+               int short_data_len, bool quick_format)
 {
        struct ms_info *ms_card = &(chip->ms_card);
        int retval, i;
index 26c5b03d535e7805bc5d29f169226affc55fefed..d919170f2720ee485d6a6a9bf80a8f2b322e5950 100644 (file)
@@ -205,7 +205,7 @@ int reset_ms_card(struct rtsx_chip *chip);
 int ms_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
        u32 start_sector, u16 sector_cnt);
 int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
-               int short_data_len, int quick_format);
+               int short_data_len, bool quick_format);
 void ms_free_l2p_tbl(struct rtsx_chip *chip);
 void ms_cleanup_work(struct rtsx_chip *chip);
 int ms_power_off_card3v3(struct rtsx_chip *chip);
index c74f1b8108f601aa44558e7abe1ee6e813d77092..c482a6ac26ba6b1c00e35c294651b46d5b7d7ff0 100644 (file)
@@ -137,8 +137,8 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
 
        /* check for state-transition errors */
        if (chip->srb != NULL) {
-               dev_err(&dev->pci->dev, "Error in %s: chip->srb = %p\n",
-                       __func__, chip->srb);
+               dev_err(&dev->pci->dev, "Error: chip->srb = %p\n",
+                       chip->srb);
                return SCSI_MLQUEUE_HOST_BUSY;
        }
 
@@ -1036,7 +1036,7 @@ static const struct pci_device_id rtsx_ids[] = {
 MODULE_DEVICE_TABLE(pci, rtsx_ids);
 
 /* pci_driver definition */
-static struct pci_driver driver = {
+static struct pci_driver rtsx_driver = {
        .name = CR_DRIVER_NAME,
        .id_table = rtsx_ids,
        .probe = rtsx_probe,
@@ -1048,21 +1048,4 @@ static struct pci_driver driver = {
        .shutdown = rtsx_shutdown,
 };
 
-static int __init rtsx_init(void)
-{
-       pr_info("Initializing Realtek PCIE storage driver...\n");
-
-       return pci_register_driver(&driver);
-}
-
-static void __exit rtsx_exit(void)
-{
-       pr_info("rtsx_exit() called\n");
-
-       pci_unregister_driver(&driver);
-
-       pr_info("%s module exit\n", CR_DRIVER_NAME);
-}
-
-module_init(rtsx_init)
-module_exit(rtsx_exit)
+module_pci_driver(rtsx_driver);
index 9593d8132938ee334ad3ec4dc5d9704c07ae4863..35fa19d8b7a225c0b6eea094ffbfa9a524be6021 100644 (file)
@@ -153,22 +153,22 @@ static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip)
 static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
 {
        u8 tmp;
-       int sw_bypass_sd = 0;
+       bool sw_bypass_sd = false;
        int retval;
 
        if (chip->driver_first_load) {
                if (CHECK_PID(chip, 0x5288)) {
                        RTSX_READ_REG(chip, 0xFE5A, &tmp);
                        if (tmp & 0x08)
-                               sw_bypass_sd = 1;
+                               sw_bypass_sd = true;
                } else if (CHECK_PID(chip, 0x5208)) {
                        RTSX_READ_REG(chip, 0xFE70, &tmp);
                        if (tmp & 0x80)
-                               sw_bypass_sd = 1;
+                               sw_bypass_sd = true;
                }
        } else {
                if (chip->sdio_in_charge)
-                       sw_bypass_sd = 1;
+                       sw_bypass_sd = true;
        }
        dev_dbg(rtsx_dev(chip), "chip->sdio_in_charge = %d\n",
                chip->sdio_in_charge);
@@ -501,13 +501,14 @@ nextcard:
 
 static inline int check_sd_speed_prior(u32 sd_speed_prior)
 {
-       int i, fake_para = 0;
+       bool fake_para = false;
+       int i;
 
        for (i = 0; i < 4; i++) {
                u8 tmp = (u8)(sd_speed_prior >> (i*8));
 
                if ((tmp < 0x01) || (tmp > 0x04)) {
-                       fake_para = 1;
+                       fake_para = true;
                        break;
                }
        }
@@ -517,13 +518,14 @@ static inline int check_sd_speed_prior(u32 sd_speed_prior)
 
 static inline int check_sd_current_prior(u32 sd_current_prior)
 {
-       int i, fake_para = 0;
+       bool fake_para = false;
+       int i;
 
        for (i = 0; i < 4; i++) {
                u8 tmp = (u8)(sd_current_prior >> (i*8));
 
                if (tmp > 0x03) {
-                       fake_para = 1;
+                       fake_para = true;
                        break;
                }
        }
@@ -784,31 +786,31 @@ static inline void rtsx_blink_led(struct rtsx_chip *chip)
 
 static void rtsx_monitor_aspm_config(struct rtsx_chip *chip)
 {
-       int maybe_support_aspm, reg_changed;
+       bool reg_changed, maybe_support_aspm;
        u32 tmp = 0;
        u8 reg0 = 0, reg1 = 0;
 
-       maybe_support_aspm = 0;
-       reg_changed = 0;
+       maybe_support_aspm = false;
+       reg_changed = false;
        rtsx_read_config_byte(chip, LCTLR, &reg0);
        if (chip->aspm_level[0] != reg0) {
-               reg_changed = 1;
+               reg_changed = true;
                chip->aspm_level[0] = reg0;
        }
        if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) {
                rtsx_read_cfg_dw(chip, 1, 0xC0, &tmp);
                reg1 = (u8)tmp;
                if (chip->aspm_level[1] != reg1) {
-                       reg_changed = 1;
+                       reg_changed = true;
                        chip->aspm_level[1] = reg1;
                }
 
                if ((reg0 & 0x03) && (reg1 & 0x03))
-                       maybe_support_aspm = 1;
+                       maybe_support_aspm = true;
 
        } else {
                if (reg0 & 0x03)
-                       maybe_support_aspm = 1;
+                       maybe_support_aspm = true;
        }
 
        if (reg_changed) {
@@ -835,7 +837,7 @@ void rtsx_polling_func(struct rtsx_chip *chip)
 #ifdef SUPPORT_SD_LOCK
        struct sd_info *sd_card = &chip->sd_card;
 #endif
-       int ss_allowed;
+       bool ss_allowed;
 
        if (rtsx_chk_stat(chip, RTSX_STAT_SUSPEND))
                return;
@@ -887,21 +889,21 @@ void rtsx_polling_func(struct rtsx_chip *chip)
        rtsx_init_cards(chip);
 
        if (chip->ss_en) {
-               ss_allowed = 1;
+               ss_allowed = true;
 
                if (CHECK_PID(chip, 0x5288)) {
-                       ss_allowed = 0;
+                       ss_allowed = false;
                } else {
                        if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip)) {
                                u32 val;
 
                                rtsx_read_cfg_dw(chip, 1, 0x04, &val);
                                if (val & 0x07)
-                                       ss_allowed = 0;
+                                       ss_allowed = false;
                        }
                }
        } else {
-               ss_allowed = 0;
+               ss_allowed = false;
        }
 
        if (ss_allowed && !chip->sd_io) {
@@ -1358,7 +1360,8 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 
 int rtsx_write_phy_register(struct rtsx_chip *chip, u8 addr, u16 val)
 {
-       int i, finished = 0;
+       bool finished = false;
+       int i;
        u8 tmp;
 
        RTSX_WRITE_REG(chip, PHYDATA0, 0xFF, (u8)val);
@@ -1369,7 +1372,7 @@ int rtsx_write_phy_register(struct rtsx_chip *chip, u8 addr, u16 val)
        for (i = 0; i < 100000; i++) {
                RTSX_READ_REG(chip, PHYRWCTL, &tmp);
                if (!(tmp & 0x80)) {
-                       finished = 1;
+                       finished = true;
                        break;
                }
        }
@@ -1382,7 +1385,8 @@ int rtsx_write_phy_register(struct rtsx_chip *chip, u8 addr, u16 val)
 
 int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val)
 {
-       int i, finished = 0;
+       bool finished = false;
+       int i;
        u16 data = 0;
        u8 tmp;
 
@@ -1392,7 +1396,7 @@ int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val)
        for (i = 0; i < 100000; i++) {
                RTSX_READ_REG(chip, PHYRWCTL, &tmp);
                if (!(tmp & 0x80)) {
-                       finished = 1;
+                       finished = true;
                        break;
                }
        }
@@ -1615,7 +1619,7 @@ void rtsx_exit_ss(struct rtsx_chip *chip)
 int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
 {
        u32 status, int_enable;
-       int exit_ss = 0;
+       bool exit_ss = false;
 #ifdef SUPPORT_OCP
        u32 ocp_int = 0;
 
@@ -1625,7 +1629,7 @@ int rtsx_pre_handle_interrupt(struct rtsx_chip *chip)
        if (chip->ss_en) {
                chip->ss_counter = 0;
                if (rtsx_get_stat(chip) == RTSX_STAT_SS) {
-                       exit_ss = 1;
+                       exit_ss = true;
                        rtsx_exit_L1(chip);
                        rtsx_set_stat(chip, RTSX_STAT_RUN);
                }
index 11610826acf19111934a5fc0252f8a371c5810d9..98f102b78e6d6831740d6a8056432a0f1f09309a 100644 (file)
@@ -39,7 +39,8 @@ void scsi_show_command(struct rtsx_chip *chip)
 {
        struct scsi_cmnd *srb = chip->srb;
        char *what = NULL;
-       int unknown_cmd = 0, len;
+       bool unknown_cmd = false;
+       int len;
 
        switch (srb->cmnd[0]) {
        case TEST_UNIT_READY:
@@ -310,7 +311,8 @@ void scsi_show_command(struct rtsx_chip *chip)
                what = "Realtek's vendor command";
                break;
        default:
-               what = "(unknown command)"; unknown_cmd = 1;
+               what = "(unknown command)";
+               unknown_cmd = true;
                break;
        }
 
@@ -485,7 +487,7 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        unsigned char sendbytes;
        unsigned char *buf;
        u8 card = get_lun_card(chip, lun);
-       int pro_formatter_flag = 0;
+       bool pro_formatter_flag = false;
        unsigned char inquiry_buf[] = {
                QULIFIRE|DRCT_ACCESS_DEV,
                RMB_DISC|0x0D,
@@ -519,10 +521,8 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 #else
        if (chip->mspro_formatter_enable)
 #endif
-       {
                if (!card || (card == MS_CARD))
-                       pro_formatter_flag = 1;
-       }
+                       pro_formatter_flag = true;
 
        if (pro_formatter_flag) {
                if (scsi_bufflen(srb) < 56)
@@ -665,7 +665,7 @@ static void ms_mode_sense(struct rtsx_chip *chip, u8 cmd,
        struct ms_info *ms_card = &(chip->ms_card);
        int sys_info_offset;
        int data_size = buf_len;
-       int support_format = 0;
+       bool support_format = false;
        int i = 0;
 
        if (cmd == MODE_SENSE) {
@@ -686,10 +686,10 @@ static void ms_mode_sense(struct rtsx_chip *chip, u8 cmd,
        /* Medium Type Code */
        if (check_card_ready(chip, lun)) {
                if (CHK_MSXC(ms_card)) {
-                       support_format = 1;
+                       support_format = true;
                        buf[i++] = 0x40;
                } else if (CHK_MSPRO(ms_card)) {
-                       support_format = 1;
+                       support_format = true;
                        buf[i++] = 0x20;
                } else {
                        buf[i++] = 0x10;
@@ -757,7 +757,7 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        unsigned int lun = SCSI_LUN(srb);
        unsigned int dataSize;
        int status;
-       int pro_formatter_flag;
+       bool pro_formatter_flag;
        unsigned char pageCode, *buf;
        u8 card = get_lun_card(chip, lun);
 
@@ -769,20 +769,20 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 #endif
 
-       pro_formatter_flag = 0;
+       pro_formatter_flag = false;
        dataSize = 8;
 #ifdef SUPPORT_MAGIC_GATE
        if ((chip->lun2card[lun] & MS_CARD)) {
                if (!card || (card == MS_CARD)) {
                        dataSize = 108;
                        if (chip->mspro_formatter_enable)
-                               pro_formatter_flag = 1;
+                               pro_formatter_flag = true;
                }
        }
 #else
        if (card == MS_CARD) {
                if (chip->mspro_formatter_enable) {
-                       pro_formatter_flag = 1;
+                       pro_formatter_flag = true;
                        dataSize = 108;
                }
        }
@@ -2297,7 +2297,8 @@ Exit:
 static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 {
        int retval;
-       u8 func, func_max;
+       bool func_max;
+       u8 func;
        u16 addr, len;
        u8 *buf;
 
@@ -2317,9 +2318,9 @@ static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                __func__, func, addr, len);
 
        if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip))
-               func_max = 1;
+               func_max = true;
        else
-               func_max = 0;
+               func_max = false;
 
        if (func > func_max) {
                set_sense_type(chip, SCSI_LUN(srb),
@@ -2351,7 +2352,8 @@ static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 {
        int retval;
-       u8 func, func_max;
+       bool func_max;
+       u8 func;
        u16 addr, len;
        u8 *buf;
 
@@ -2371,9 +2373,9 @@ static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                __func__, func, addr);
 
        if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip))
-               func_max = 1;
+               func_max = true;
        else
-               func_max = 0;
+               func_max = false;
 
        if (func > func_max) {
                set_sense_type(chip, SCSI_LUN(srb),
@@ -2797,7 +2799,8 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 {
        struct ms_info *ms_card = &(chip->ms_card);
        unsigned int lun = SCSI_LUN(srb);
-       int retval, quick_format;
+       bool quick_format;
+       int retval;
 
        if (get_lun_card(chip, lun) != MS_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
@@ -2826,9 +2829,9 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        rtsx_set_stat(chip, RTSX_STAT_RUN);
 
        if (srb->cmnd[8] & 0x01)
-               quick_format = 0;
+               quick_format = false;
        else
-               quick_format = 1;
+               quick_format = true;
 
        if (!(chip->card_ready & MS_CARD)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
index dab1995d1a6a5f9276edaaecf876fad2e166de77..03caa9b3771ff1ff1fa9bf0b304f2d9cf69e0c28 100644 (file)
@@ -642,7 +642,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,
        dma_addr_t addr;
        u8 dir;
        int err = 0;
-       u32 val = (1 << 31);
+       u32 val = 1 << 31;
        long timeleft;
 
        if ((buf == NULL) || (len <= 0))
index c28a92773f05de2e32985240238dbe4d25ed3ece..a03cbe93722ad5397ca183d89d8582ad4bf81e46 100644 (file)
@@ -791,7 +791,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
        u16 SD_VP_CTL, SD_DCMPS_CTL;
        u8 val;
        int retval;
-       int ddr_rx = 0;
+       bool ddr_rx = false;
 
        dev_dbg(rtsx_dev(chip), "sd_change_phase (sample_point = %d, tune_dir = %d)\n",
                sample_point, tune_dir);
@@ -800,7 +800,7 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
                SD_VP_CTL = SD_VPRX_CTL;
                SD_DCMPS_CTL = SD_DCMPS_RX_CTL;
                if (CHK_SD_DDR50(sd_card))
-                       ddr_rx = 1;
+                       ddr_rx = true;
        } else {
                SD_VP_CTL = SD_VPTX_CTL;
                SD_DCMPS_CTL = SD_DCMPS_TX_CTL;
@@ -1121,7 +1121,7 @@ static int sd_check_switch(struct rtsx_chip *chip,
 {
        int retval;
        int i;
-       int switch_good = 0;
+       bool switch_good = false;
 
        for (i = 0; i < 3; i++) {
                if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
@@ -1137,7 +1137,7 @@ static int sd_check_switch(struct rtsx_chip *chip,
                        retval = sd_check_switch_mode(chip, SD_SWITCH_MODE,
                                        func_group, func_to_switch, bus_width);
                        if (retval == STATUS_SUCCESS) {
-                               switch_good = 1;
+                               switch_good = true;
                                break;
                        }
 
@@ -1524,7 +1524,8 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map,
        struct sd_info *sd_card = &(chip->sd_card);
        struct timing_phase_path path[MAX_PHASE + 1];
        int i, j, cont_path_cnt;
-       int new_block, max_len, final_path_idx;
+       bool new_block;
+       int max_len, final_path_idx;
        u8 final_phase = 0xFF;
 
        if (phase_map == 0xFFFFFFFF) {
@@ -1537,12 +1538,12 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map,
        }
 
        cont_path_cnt = 0;
-       new_block = 1;
+       new_block = true;
        j = 0;
        for (i = 0; i < MAX_PHASE + 1; i++) {
                if (phase_map & (1 << i)) {
                        if (new_block) {
-                               new_block = 0;
+                               new_block = false;
                                j = cont_path_cnt++;
                                path[j].start = i;
                                path[j].end = i;
@@ -1550,7 +1551,7 @@ static u8 sd_search_final_phase(struct rtsx_chip *chip, u32 phase_map,
                                path[j].end = i;
                        }
                } else {
-                       new_block = 1;
+                       new_block = true;
                        if (cont_path_cnt) {
                                int idx = cont_path_cnt - 1;
 
@@ -2141,14 +2142,15 @@ static int sd_check_wp_state(struct rtsx_chip *chip)
 static int reset_sd(struct rtsx_chip *chip)
 {
        struct sd_info *sd_card = &(chip->sd_card);
-       int retval, i = 0, j = 0, k = 0, hi_cap_flow = 0;
-       int sd_dont_switch = 0;
-       int support_1v8 = 0;
-       int try_sdio = 1;
+       bool hi_cap_flow = false;
+       int retval, i = 0, j = 0, k = 0;
+       bool sd_dont_switch = false;
+       bool support_1v8 = false;
+       bool try_sdio = true;
        u8 rsp[16];
        u8 switch_bus_width;
        u32 voltage = 0;
-       int sd20_mode = 0;
+       bool sd20_mode = false;
 
        SET_SD(sd_card);
 
@@ -2157,7 +2159,7 @@ Switch_Fail:
        i = 0;
        j = 0;
        k = 0;
-       hi_cap_flow = 0;
+       hi_cap_flow = false;
 
 #ifdef SUPPORT_SD_LOCK
        if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON)
@@ -2217,7 +2219,7 @@ RTY_SD_RST:
                                SD_RSP_TYPE_R7, rsp, 5);
        if (retval == STATUS_SUCCESS) {
                if ((rsp[4] == 0xAA) && ((rsp[3] & 0x0f) == 0x01)) {
-                       hi_cap_flow = 1;
+                       hi_cap_flow = true;
                        voltage = SUPPORT_VOLTAGE | 0x40000000;
                }
        }
@@ -2272,10 +2274,10 @@ RTY_SD_RST:
                else
                        CLR_SD_HCXC(sd_card);
 
-               support_1v8 = 0;
+               support_1v8 = false;
        } else {
                CLR_SD_HCXC(sd_card);
-               support_1v8 = 0;
+               support_1v8 = false;
        }
        dev_dbg(rtsx_dev(chip), "support_1v8 = %d\n", support_1v8);
 
@@ -2361,7 +2363,7 @@ SD_UNLOCK_ENTRY:
                TRACE_RET(chip, STATUS_FAIL);
 
        if (!(sd_card->raw_csd[4] & 0x40))
-               sd_dont_switch = 1;
+               sd_dont_switch = true;
 
        if (!sd_dont_switch) {
                if (sd20_mode) {
@@ -2378,16 +2380,16 @@ SD_UNLOCK_ENTRY:
                        retval = sd_switch_function(chip, switch_bus_width);
                        if (retval != STATUS_SUCCESS) {
                                sd_init_power(chip);
-                               sd_dont_switch = 1;
-                               try_sdio = 0;
+                               sd_dont_switch = true;
+                               try_sdio = false;
 
                                goto Switch_Fail;
                        }
                } else {
                        if (support_1v8) {
                                sd_init_power(chip);
-                               sd_dont_switch = 1;
-                               try_sdio = 0;
+                               sd_dont_switch = true;
+                               try_sdio = false;
 
                                goto Switch_Fail;
                        }
@@ -2433,8 +2435,8 @@ SD_UNLOCK_ENTRY:
                                if (retval != STATUS_SUCCESS)
                                        TRACE_RET(chip, STATUS_FAIL);
 
-                               try_sdio = 0;
-                               sd20_mode = 1;
+                               try_sdio = false;
+                               sd20_mode = true;
                                goto Switch_Fail;
                        }
                }
@@ -2458,8 +2460,8 @@ SD_UNLOCK_ENTRY:
                                        if (retval != STATUS_SUCCESS)
                                                TRACE_RET(chip, STATUS_FAIL);
 
-                                       try_sdio = 0;
-                                       sd20_mode = 1;
+                                       try_sdio = false;
+                                       sd20_mode = true;
                                        goto Switch_Fail;
                                }
                        }
@@ -2604,7 +2606,7 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)
 }
 
 
-static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)
+static int mmc_switch_timing_bus(struct rtsx_chip *chip, bool switch_ddr)
 {
        struct sd_info *sd_card = &(chip->sd_card);
        int retval;
@@ -2727,7 +2729,7 @@ static int reset_mmc(struct rtsx_chip *chip)
 {
        struct sd_info *sd_card = &(chip->sd_card);
        int retval, i = 0, j = 0, k = 0;
-       int switch_ddr = 1;
+       bool switch_ddr = true;
        u8 rsp[16];
        u8 spec_ver = 0;
        u32 temp;
@@ -2858,7 +2860,7 @@ MMC_UNLOCK_ENTRY:
                                if (retval != STATUS_SUCCESS)
                                        TRACE_RET(chip, STATUS_FAIL);
 
-                               switch_ddr = 0;
+                               switch_ddr = false;
                                TRACE_GOTO(chip, Switch_Fail);
                        }
 
@@ -2870,7 +2872,7 @@ MMC_UNLOCK_ENTRY:
                                        if (retval != STATUS_SUCCESS)
                                                TRACE_RET(chip, STATUS_FAIL);
 
-                                       switch_ddr = 0;
+                                       switch_ddr = false;
                                        TRACE_GOTO(chip, Switch_Fail);
                                }
                        }
@@ -3417,7 +3419,7 @@ int soft_reset_sd_card(struct rtsx_chip *chip)
 }
 
 int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx,
-               u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, int special_check)
+               u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, bool special_check)
 {
        int retval;
        int timeout = 100;
@@ -3511,7 +3513,7 @@ RTY_SEND_CMD:
 
        if ((cmd_idx == SELECT_CARD) || (cmd_idx == APP_CMD) ||
                (cmd_idx == SEND_STATUS) || (cmd_idx == STOP_TRANSMISSION)) {
-               if ((cmd_idx != STOP_TRANSMISSION) && (special_check == 0)) {
+               if ((cmd_idx != STOP_TRANSMISSION) && !special_check) {
                        if (ptr[1] & 0x80)
                                TRACE_RET(chip, STATUS_FAIL);
                }
@@ -3702,7 +3704,7 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        unsigned int lun = SCSI_LUN(srb);
        int retval, rsp_len;
        u8 cmd_idx, rsp_type;
-       u8 standby = 0, acmd = 0;
+       bool standby = false, acmd = false;
        u32 arg;
 
        if (!sd_card->sd_pass_thru_en) {
@@ -3722,10 +3724,10 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        cmd_idx = srb->cmnd[2] & 0x3F;
        if (srb->cmnd[1] & 0x02)
-               standby = 1;
+               standby = true;
 
        if (srb->cmnd[1] & 0x01)
-               acmd = 1;
+               acmd = true;
 
        arg = ((u32)srb->cmnd[3] << 24) | ((u32)srb->cmnd[4] << 16) |
                ((u32)srb->cmnd[5] << 8) | srb->cmnd[6];
@@ -3771,13 +3773,13 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
        }
 
        retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type,
-                       sd_card->rsp, rsp_len, 0);
+                       sd_card->rsp, rsp_len, false);
        if (retval != STATUS_SUCCESS)
                TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
 
@@ -3812,9 +3814,9 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        struct sd_info *sd_card = &(chip->sd_card);
        unsigned int lun = SCSI_LUN(srb);
        int retval, rsp_len, i;
-       int cmd13_checkbit = 0, read_err = 0;
+       bool read_err = false, cmd13_checkbit = false;
        u8 cmd_idx, rsp_type, bus_width;
-       u8 send_cmd12 = 0, standby = 0, acmd = 0;
+       bool standby = false, send_cmd12 = false, acmd = false;
        u32 data_len;
 
        if (!sd_card->sd_pass_thru_en) {
@@ -3834,13 +3836,13 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        cmd_idx = srb->cmnd[2] & 0x3F;
        if (srb->cmnd[1] & 0x04)
-               send_cmd12 = 1;
+               send_cmd12 = true;
 
        if (srb->cmnd[1] & 0x02)
-               standby = 1;
+               standby = true;
 
        if (srb->cmnd[1] & 0x01)
-               acmd = 1;
+               acmd = true;
 
        data_len = ((u32)srb->cmnd[7] << 16) | ((u32)srb->cmnd[8]
                                                << 8) | srb->cmnd[9];
@@ -3874,7 +3876,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (data_len < 512) {
                retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len,
-                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
        }
@@ -3888,7 +3890,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
        }
@@ -3915,7 +3917,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                retval = sd_read_data(chip, SD_TM_NORMAL_READ, cmd, 5, byte_cnt,
                                       blk_cnt, bus_width, buf, data_len, 2000);
                if (retval != STATUS_SUCCESS) {
-                       read_err = 1;
+                       read_err = true;
                        kfree(buf);
                        rtsx_clear_sd_error(chip);
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
@@ -3964,7 +3966,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                        scsi_bufflen(srb), scsi_sg_count(srb),
                                        DMA_FROM_DEVICE, 10000);
                if (retval < 0) {
-                       read_err = 1;
+                       read_err = true;
                        rtsx_clear_sd_error(chip);
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
                }
@@ -3985,14 +3987,14 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (send_cmd12) {
                retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION,
-                               0, SD_RSP_TYPE_R1b, NULL, 0, 0);
+                               0, SD_RSP_TYPE_R1b, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
        }
 
        if (data_len < 512) {
                retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200,
-                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
 
@@ -4006,7 +4008,7 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        if ((srb->cmnd[1] & 0x02) || (srb->cmnd[1] & 0x04))
-               cmd13_checkbit = 1;
+               cmd13_checkbit = true;
 
        for (i = 0; i < 3; i++) {
                retval = ext_sd_send_cmd_get_rsp(chip, SEND_STATUS,
@@ -4041,9 +4043,9 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        struct sd_info *sd_card = &(chip->sd_card);
        unsigned int lun = SCSI_LUN(srb);
        int retval, rsp_len, i;
-       int cmd13_checkbit = 0, write_err = 0;
+       bool write_err = false, cmd13_checkbit = false;
        u8 cmd_idx, rsp_type;
-       u8 send_cmd12 = 0, standby = 0, acmd = 0;
+       bool standby = false, send_cmd12 = false, acmd = false;
        u32 data_len, arg;
 #ifdef SUPPORT_SD_LOCK
        int lock_cmd_fail = 0;
@@ -4068,13 +4070,13 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        cmd_idx = srb->cmnd[2] & 0x3F;
        if (srb->cmnd[1] & 0x04)
-               send_cmd12 = 1;
+               send_cmd12 = true;
 
        if (srb->cmnd[1] & 0x02)
-               standby = 1;
+               standby = true;
 
        if (srb->cmnd[1] & 0x01)
-               acmd = 1;
+               acmd = true;
 
        data_len = ((u32)srb->cmnd[7] << 16) | ((u32)srb->cmnd[8]
                                                << 8) | srb->cmnd[9];
@@ -4122,7 +4124,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (data_len < 512) {
                retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len,
-                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
        }
@@ -4136,13 +4138,13 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
        }
 
        retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type,
-                       sd_card->rsp, rsp_len, 0);
+                       sd_card->rsp, rsp_len, false);
        if (retval != STATUS_SUCCESS)
                TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
 
@@ -4247,7 +4249,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        if (retval < 0) {
-               write_err = 1;
+               write_err = true;
                rtsx_clear_sd_error(chip);
                TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
        }
@@ -4281,14 +4283,14 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (send_cmd12) {
                retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION,
-                               0, SD_RSP_TYPE_R1b, NULL, 0, 0);
+                               0, SD_RSP_TYPE_R1b, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
        }
 
        if (data_len < 512) {
                retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200,
-                               SD_RSP_TYPE_R1, NULL, 0, 0);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
                if (retval != STATUS_SUCCESS)
                        TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
 
@@ -4302,7 +4304,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        if ((srb->cmnd[1] & 0x02) || (srb->cmnd[1] & 0x04))
-               cmd13_checkbit = 1;
+               cmd13_checkbit = true;
 
        for (i = 0; i < 3; i++) {
                retval = ext_sd_send_cmd_get_rsp(chip, SEND_STATUS,
index 735b2d0f5a7897d99744ad30f0460023a0338174..60b79280fb5f909114e2477725cbd130219f3511 100644 (file)
@@ -287,7 +287,7 @@ int release_sd_card(struct rtsx_chip *chip);
 #ifdef SUPPORT_CPRM
 int soft_reset_sd_card(struct rtsx_chip *chip);
 int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx,
-               u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, int special_check);
+               u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, bool special_check);
 int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type);
 
 int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip);
index 9bd69ce3be0014b373c328aeb0ac6ca50c9c8eec..b0cd9357348fcc8a53e5ac8da5792867ab66f356 100644 (file)
@@ -68,9 +68,7 @@ do {                                         \
 
 #if SKEIN_UNROLL_256 == 0
 #define R256(p0, p1, p2, p3, ROT, r_num) /* fully unrolled */ \
-do {                                                          \
-       ROUND256(p0, p1, p2, p3, ROT, r_num);                 \
-} while (0)
+       ROUND256(p0, p1, p2, p3, ROT, r_num)
 
 #define I256(R)                                                           \
 do {                                                                      \
@@ -152,9 +150,7 @@ do {                                                         \
 
 #if SKEIN_UNROLL_512 == 0
 #define R512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num) /* unrolled */ \
-do {                                                                    \
-       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num);           \
-} while (0)
+       ROUND512(p0, p1, p2, p3, p4, p5, p6, p7, ROT, r_num)
 
 #define I512(R)                                                           \
 do {                                                                      \
index 42d62ef56cb8661c9cce4e85e5ee4a5bcce99a52..3104cb0d0589635c83ed8800d15f54fe170e0322 100644 (file)
@@ -84,7 +84,6 @@
 #include <linux/seq_file.h>
 #include <linux/kthread.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 
 #include <linux/firmware.h>
 #include <linux/types.h>
@@ -99,8 +98,7 @@
 #include "slic.h"
 
 static uint slic_first_init = 1;
-static char *slic_banner = "Alacritech SLIC Technology(tm) Server "
-               "and Storage Accelerator (Non-Accelerated)";
+static char *slic_banner = "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)";
 
 static char *slic_proc_version = "2.0.351  2006/07/14 12:26:00";
 
@@ -166,7 +164,7 @@ static void slic_mcast_set_bit(struct adapter *adapter, char *address)
        /* Get the CRC polynomial for the mac address */
        /* we use bits 1-8 (lsb), bitwise reversed,
         * msb (= lsb bit 0 before bitrev) is automatically discarded */
-       crcpoly = (ether_crc(ETH_ALEN, address)>>23);
+       crcpoly = ether_crc(ETH_ALEN, address)>>23;
 
        /* We only have space on the SLIC for 64 entries.  Lop
         * off the top two bits. (2^6 = 64)
@@ -1852,7 +1850,7 @@ static void slic_xmit_build_request(struct adapter *adapter,
 
        ihcmd = &hcmd->cmd64;
 
-       ihcmd->flags = (adapter->port << IHFLG_IFSHFT);
+       ihcmd->flags = adapter->port << IHFLG_IFSHFT;
        ihcmd->command = IHCMD_XMT_REQ;
        ihcmd->u.slic_buffers.totlen = skb->len;
        phys_addr = pci_map_single(adapter->pcidev, skb->data, skb->len,
@@ -1864,8 +1862,8 @@ static void slic_xmit_build_request(struct adapter *adapter,
        hcmd->cmdsize = (u32) ((((u64)&ihcmd->u.slic_buffers.bufs[1] -
                                     (u64) hcmd) + 31) >> 5);
 #else
-       hcmd->cmdsize = ((((u32) &ihcmd->u.slic_buffers.bufs[1] -
-                          (u32) hcmd) + 31) >> 5);
+       hcmd->cmdsize = (((u32)&ihcmd->u.slic_buffers.bufs[1] -
+                                      (u32)hcmd) + 31) >> 5;
 #endif
 }
 
@@ -2315,9 +2313,8 @@ static int slic_if_init(struct adapter *adapter)
        }
        rc = slic_adapter_allocresources(adapter);
        if (rc) {
-               dev_err(&dev->dev,
-                       "%s: slic_adapter_allocresources FAILED %x\n",
-                       __func__, rc);
+               dev_err(&dev->dev, "slic_adapter_allocresources FAILED %x\n",
+                       rc);
                slic_adapter_freeresources(adapter);
                goto err;
        }
@@ -2362,22 +2359,19 @@ static int slic_if_init(struct adapter *adapter)
 
        adapter->state = ADAPT_UP;
        if (!card->loadtimerset) {
-               init_timer(&card->loadtimer);
+               setup_timer(&card->loadtimer, &slic_timer_load_check,
+                           (ulong)card);
                card->loadtimer.expires =
                    jiffies + (SLIC_LOADTIMER_PERIOD * HZ);
-               card->loadtimer.data = (ulong) card;
-               card->loadtimer.function = &slic_timer_load_check;
                add_timer(&card->loadtimer);
 
                card->loadtimerset = 1;
        }
 
        if (!adapter->pingtimerset) {
-               init_timer(&adapter->pingtimer);
+               setup_timer(&adapter->pingtimer, &slic_timer_ping, (ulong)dev);
                adapter->pingtimer.expires =
                    jiffies + (PING_TIMER_INTERVAL * HZ);
-               adapter->pingtimer.data = (ulong) dev;
-               adapter->pingtimer.function = &slic_timer_ping;
                add_timer(&adapter->pingtimer);
                adapter->pingtimerset = 1;
                adapter->card->pingstatus = ISR_PINGMASK;
@@ -2554,8 +2548,8 @@ static int slic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                if (copy_from_user(data, rq->ifr_data, 28))
                        return -EFAULT;
                intagg = data[0];
-               dev_err(&dev->dev, "%s: set interrupt aggregation to %d\n",
-                       __func__, intagg);
+               dev_err(&dev->dev, "set interrupt aggregation to %d\n",
+                       intagg);
                slic_intagg_set(adapter, intagg);
                return 0;
 
diff --git a/drivers/staging/sm750fb/Kconfig b/drivers/staging/sm750fb/Kconfig
new file mode 100644 (file)
index 0000000..c40d088
--- /dev/null
@@ -0,0 +1,10 @@
+config FB_SM750
+       tristate "Silicon Motion SM750 framebuffer support"
+       depends on FB && PCI
+       help
+         Frame buffer driver for the Silicon Motion SM750 chip
+         with 2D accelearion and dual head support.
+
+         This driver is also available as a module. The module will be
+         called sm750fb. If you want to compile it as a module, say M
+         here and read <file:Documentation/kbuild/modules.txt>.
diff --git a/drivers/staging/sm750fb/Makefile b/drivers/staging/sm750fb/Makefile
new file mode 100644 (file)
index 0000000..dcce3f4
--- /dev/null
@@ -0,0 +1,4 @@
+obj-$(CONFIG_FB_SM750) += sm750fb.o
+
+sm750fb-objs           := sm750.o sm750_hw.o sm750_accel.o sm750_cursor.o ddk750_chip.o ddk750_power.o ddk750_mode.o
+sm750fb-objs           += ddk750_display.o ddk750_help.o ddk750_swi2c.o ddk750_sii164.o ddk750_dvi.o ddk750_hwi2c.o
diff --git a/drivers/staging/sm750fb/TODO b/drivers/staging/sm750fb/TODO
new file mode 100644 (file)
index 0000000..bc16172
--- /dev/null
@@ -0,0 +1,15 @@
+TODO:
+- lots of clechpatch cleanup
+- use kernel coding style
+- refine the code and remove unused code
+- check on hardware effects of removal of USE_HW_I2C and USE_DVICHIP (these two
+       are supposed to be sample code which is given here if someone wants to
+       use those functionalities)
+- move it to drivers/video/fbdev
+- modify the code for drm framework
+
+Please send any patches to
+       Greg Kroah-Hartman <greg@kroah.com>
+       Sudip Mukherjee <sudipm.mukherjee@gmail.com>
+       Teddy Wang <teddy.wang@siliconmotion.com>
+       Sudip Mukherjee <sudip@vectorindia.org>
diff --git a/drivers/staging/sm750fb/ddk750.h b/drivers/staging/sm750fb/ddk750.h
new file mode 100644 (file)
index 0000000..2c10a08
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef DDK750_H__
+#define DDK750_H__
+/*******************************************************************
+*
+*         Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
+*
+*  All rights are reserved. Reproduction or in part is prohibited
+*  without the written consent of the copyright owner.
+*
+*  RegSC.h --- SM718 SDK
+*  This file contains the definitions for the System Configuration registers.
+*
+*******************************************************************/
+#include "ddk750_reg.h"
+#include "ddk750_mode.h"
+#include "ddk750_chip.h"
+#include "ddk750_display.h"
+#include "ddk750_power.h"
+#include "ddk750_help.h"
+#ifdef USE_HW_I2C
+#include "ddk750_hwi2c.h"
+#endif
+#include "ddk750_swi2c.h"
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
new file mode 100644 (file)
index 0000000..02f9326
--- /dev/null
@@ -0,0 +1,639 @@
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_chip.h"
+#include "ddk750_power.h"
+typedef struct _pllcalparam{
+       unsigned char power;/* d : 0~ 6*/
+       unsigned char pod;
+       unsigned char od;
+       unsigned char value;/* value of  2 power d (2^d) */
+}
+pllcalparam;
+
+
+logical_chip_type_t getChipType(void)
+{
+       unsigned short physicalID;
+       char physicalRev;
+       logical_chip_type_t chip;
+
+       physicalID = devId750;//either 0x718 or 0x750
+       physicalRev = revId750;
+
+       if (physicalID == 0x718)
+       {
+               chip = SM718;
+       }
+       else if (physicalID == 0x750)
+       {
+               chip = SM750;
+               /* SM750 and SM750LE are different in their revision ID only. */
+               if (physicalRev == SM750LE_REVISION_ID){
+                       chip = SM750LE;
+               }
+       }
+       else
+       {
+               chip = SM_UNKNOWN;
+       }
+
+       return chip;
+}
+
+
+inline unsigned int twoToPowerOfx(unsigned long x)
+{
+       unsigned long i;
+       unsigned long result = 1;
+
+       for (i=1; i<=x; i++)
+               result *= 2;
+       return result;
+}
+
+inline unsigned int calcPLL(pll_value_t *pPLL)
+{
+       return (pPLL->inputFreq * pPLL->M / pPLL->N / twoToPowerOfx(pPLL->OD) / twoToPowerOfx(pPLL->POD));
+}
+
+unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL)
+{
+       unsigned int ulPllReg = 0;
+
+       pPLL->inputFreq = DEFAULT_INPUT_CLOCK;
+       pPLL->clockType = clockType;
+
+       switch (clockType)
+       {
+       case MXCLK_PLL:
+               ulPllReg = PEEK32(MXCLK_PLL_CTRL);
+               break;
+       case PRIMARY_PLL:
+               ulPllReg = PEEK32(PANEL_PLL_CTRL);
+               break;
+       case SECONDARY_PLL:
+               ulPllReg = PEEK32(CRT_PLL_CTRL);
+               break;
+       case VGA0_PLL:
+               ulPllReg = PEEK32(VGA_PLL0_CTRL);
+               break;
+       case VGA1_PLL:
+               ulPllReg = PEEK32(VGA_PLL1_CTRL);
+               break;
+       }
+
+       pPLL->M = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, M);
+       pPLL->N = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, N);
+       pPLL->OD = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, OD);
+       pPLL->POD = FIELD_GET(ulPllReg, PANEL_PLL_CTRL, POD);
+
+       return calcPLL(pPLL);
+}
+
+
+unsigned int getChipClock(void)
+{
+       pll_value_t pll;
+#if 1
+       if(getChipType() == SM750LE)
+               return MHz(130);
+#endif
+
+       return getPllValue(MXCLK_PLL, &pll);
+}
+
+
+/*
+ * This function set up the main chip clock.
+ *
+ * Input: Frequency to be set.
+ */
+void setChipClock(unsigned int frequency)
+{
+       pll_value_t pll;
+       unsigned int ulActualMxClk;
+#if 1
+       /* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */
+       if (getChipType() == SM750LE)
+               return;
+#endif
+
+       if (frequency != 0)
+       {
+               /*
+               * Set up PLL, a structure to hold the value to be set in clocks.
+               */
+               pll.inputFreq = DEFAULT_INPUT_CLOCK; /* Defined in CLOCK.H */
+               pll.clockType = MXCLK_PLL;
+
+               /*
+               * Call calcPllValue() to fill up the other fields for PLL structure.
+               * Sometime, the chip cannot set up the exact clock required by User.
+               * Return value from calcPllValue() gives the actual possible clock.
+               */
+               ulActualMxClk = calcPllValue(frequency, &pll);
+
+               /* Master Clock Control: MXCLK_PLL */
+               POKE32(MXCLK_PLL_CTRL, formatPllReg(&pll));
+       }
+}
+
+
+
+void setMemoryClock(unsigned int frequency)
+{
+       unsigned int ulReg, divisor;
+ #if 1
+       /* Cheok_0509: For SM750LE, the memory clock is fixed. Nothing to set. */
+       if (getChipType() == SM750LE)
+               return;
+#endif
+       if (frequency != 0)
+       {
+               /* Set the frequency to the maximum frequency that the DDR Memory can take
+               which is 336MHz. */
+               if (frequency > MHz(336))
+                       frequency = MHz(336);
+
+               /* Calculate the divisor */
+               divisor = (unsigned int) roundedDiv(getChipClock(), frequency);
+
+               /* Set the corresponding divisor in the register. */
+               ulReg = PEEK32(CURRENT_GATE);
+               switch(divisor)
+               {
+               default:
+               case 1:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, M2XCLK, DIV_1);
+                       break;
+               case 2:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, M2XCLK, DIV_2);
+                       break;
+               case 3:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, M2XCLK, DIV_3);
+                       break;
+               case 4:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, M2XCLK, DIV_4);
+                       break;
+               }
+
+               setCurrentGate(ulReg);
+       }
+}
+
+
+/*
+ * This function set up the master clock (MCLK).
+ *
+ * Input: Frequency to be set.
+ *
+ * NOTE:
+ *      The maximum frequency the engine can run is 168MHz.
+ */
+void setMasterClock(unsigned int frequency)
+{
+       unsigned int ulReg, divisor;
+#if 1
+       /* Cheok_0509: For SM750LE, the memory clock is fixed. Nothing to set. */
+       if (getChipType() == SM750LE)
+               return;
+#endif
+       if (frequency != 0)
+       {
+               /* Set the frequency to the maximum frequency that the SM750 engine can
+               run, which is about 190 MHz. */
+               if (frequency > MHz(190))
+                       frequency = MHz(190);
+
+               /* Calculate the divisor */
+               divisor = (unsigned int) roundedDiv(getChipClock(), frequency);
+
+               /* Set the corresponding divisor in the register. */
+               ulReg = PEEK32(CURRENT_GATE);
+               switch(divisor)
+               {
+               default:
+               case 3:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_3);
+                       break;
+               case 4:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_4);
+                       break;
+               case 6:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_6);
+                       break;
+               case 8:
+                       ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_8);
+                       break;
+               }
+
+               setCurrentGate(ulReg);
+               }
+}
+
+
+unsigned int ddk750_getVMSize(void)
+{
+       unsigned int reg;
+       unsigned int data;
+
+       /* sm750le only use 64 mb memory*/
+       if(getChipType() == SM750LE)
+               return MB(64);
+
+       /* for 750,always use power mode0*/
+       reg = PEEK32(MODE0_GATE);
+       reg = FIELD_SET(reg,MODE0_GATE,GPIO,ON);
+       POKE32(MODE0_GATE,reg);
+
+       /* get frame buffer size from GPIO */
+       reg = FIELD_GET(PEEK32(MISC_CTRL),MISC_CTRL,LOCALMEM_SIZE);
+       switch(reg){
+       case MISC_CTRL_LOCALMEM_SIZE_8M:  data = MB(8);  break; /* 8  Mega byte */
+       case MISC_CTRL_LOCALMEM_SIZE_16M: data = MB(16); break; /* 16 Mega byte */
+       case MISC_CTRL_LOCALMEM_SIZE_32M: data = MB(32); break; /* 32 Mega byte */
+       case MISC_CTRL_LOCALMEM_SIZE_64M: data = MB(64); break; /* 64 Mega byte */
+       default: data = 0;break;
+       }
+       return data;
+
+}
+
+int ddk750_initHw(initchip_param_t * pInitParam)
+{
+
+       unsigned int ulReg;
+#if 0
+       //move the code to map regiter function.
+       if(getChipType() == SM718){
+               /* turn on big endian bit*/
+               ulReg = PEEK32(0x74);
+               /* now consider register definition in a big endian pattern*/
+               POKE32(0x74,ulReg|0x80000000);
+       }
+
+#endif
+
+
+       if (pInitParam->powerMode != 0 )
+               pInitParam->powerMode = 0;
+       setPowerMode(pInitParam->powerMode);
+
+       /* Enable display power gate & LOCALMEM power gate*/
+       ulReg = PEEK32(CURRENT_GATE);
+       ulReg = FIELD_SET(ulReg, CURRENT_GATE, DISPLAY, ON);
+       ulReg = FIELD_SET(ulReg,CURRENT_GATE,LOCALMEM,ON);
+       setCurrentGate(ulReg);
+
+       if(getChipType() != SM750LE){
+               /*      set panel pll and graphic mode via mmio_88 */
+               ulReg = PEEK32(VGA_CONFIGURATION);
+               ulReg = FIELD_SET(ulReg,VGA_CONFIGURATION,PLL,PANEL);
+               ulReg = FIELD_SET(ulReg,VGA_CONFIGURATION,MODE,GRAPHIC);
+               POKE32(VGA_CONFIGURATION,ulReg);
+       }else{
+#if defined(__i386__) || defined( __x86_64__)
+               /* set graphic mode via IO method */
+               outb_p(0x88,0x3d4);
+               outb_p(0x06,0x3d5);
+#endif
+       }
+
+       /* Set the Main Chip Clock */
+       setChipClock(MHz((unsigned int)pInitParam->chipClock));
+
+       /* Set up memory clock. */
+       setMemoryClock(MHz(pInitParam->memClock));
+
+       /* Set up master clock */
+       setMasterClock(MHz(pInitParam->masterClock));
+
+
+       /* Reset the memory controller. If the memory controller is not reset in SM750,
+          the system might hang when sw accesses the memory.
+          The memory should be resetted after changing the MXCLK.
+        */
+       if (pInitParam->resetMemory == 1)
+       {
+               ulReg = PEEK32(MISC_CTRL);
+               ulReg = FIELD_SET(ulReg, MISC_CTRL, LOCALMEM_RESET, RESET);
+               POKE32(MISC_CTRL, ulReg);
+
+               ulReg = FIELD_SET(ulReg, MISC_CTRL, LOCALMEM_RESET, NORMAL);
+               POKE32(MISC_CTRL, ulReg);
+       }
+
+       if (pInitParam->setAllEngOff == 1)
+       {
+               enable2DEngine(0);
+
+               /* Disable Overlay, if a former application left it on */
+               ulReg = PEEK32(VIDEO_DISPLAY_CTRL);
+               ulReg = FIELD_SET(ulReg, VIDEO_DISPLAY_CTRL, PLANE, DISABLE);
+               POKE32(VIDEO_DISPLAY_CTRL, ulReg);
+
+               /* Disable video alpha, if a former application left it on */
+               ulReg = PEEK32(VIDEO_ALPHA_DISPLAY_CTRL);
+               ulReg = FIELD_SET(ulReg, VIDEO_ALPHA_DISPLAY_CTRL, PLANE, DISABLE);
+               POKE32(VIDEO_ALPHA_DISPLAY_CTRL, ulReg);
+
+               /* Disable alpha plane, if a former application left it on */
+               ulReg = PEEK32(ALPHA_DISPLAY_CTRL);
+               ulReg = FIELD_SET(ulReg, ALPHA_DISPLAY_CTRL, PLANE, DISABLE);
+               POKE32(ALPHA_DISPLAY_CTRL, ulReg);
+
+#if 0
+               /* Disable LCD hardware cursor, if a former application left it on */
+               ulReg = PEEK32(PANEL_HWC_ADDRESS);
+               ulReg = FIELD_SET(ulReg, PANEL_HWC_ADDRESS, ENABLE, DISABLE);
+               POKE32(PANEL_HWC_ADDRESS, ulReg);
+
+               /* Disable CRT hardware cursor, if a former application left it on */
+               ulReg = PEEK32(CRT_HWC_ADDRESS);
+               ulReg = FIELD_SET(ulReg, CRT_HWC_ADDRESS, ENABLE, DISABLE);
+               POKE32(CRT_HWC_ADDRESS, ulReg);
+
+               /* Disable ZV Port 0, if a former application left it on */
+               ulReg = PEEK32(ZV0_CAPTURE_CTRL);
+               ulReg = FIELD_SET(ulReg, ZV0_CAPTURE_CTRL, CAP, DISABLE);
+               POKE32(ZV0_CAPTURE_CTRL, ulReg);
+
+               /* Disable ZV Port 1, if a former application left it on */
+               ulReg = PEEK32(ZV1_CAPTURE_CTRL);
+               ulReg = FIELD_SET(ulReg, ZV1_CAPTURE_CTRL, CAP, DISABLE);
+               POKE32(ZV1_CAPTURE_CTRL, ulReg);
+
+               /* Disable ZV Port Power, if a former application left it on */
+               enableZVPort(0);
+               /* Disable DMA Channel, if a former application left it on */
+               ulReg = PEEK32(DMA_ABORT_INTERRUPT);
+               ulReg = FIELD_SET(ulReg, DMA_ABORT_INTERRUPT, ABORT_1, ABORT);
+               POKE32(DMA_ABORT_INTERRUPT, ulReg);
+
+               /* Disable i2c */
+               enableI2C(0);
+#endif
+               /* Disable DMA Channel, if a former application left it on */
+               ulReg = PEEK32(DMA_ABORT_INTERRUPT);
+               ulReg = FIELD_SET(ulReg, DMA_ABORT_INTERRUPT, ABORT_1, ABORT);
+               POKE32(DMA_ABORT_INTERRUPT, ulReg);
+
+               /* Disable DMA Power, if a former application left it on */
+               enableDMA(0);
+       }
+
+       /* We can add more initialization as needed. */
+
+       return 0;
+}
+
+#if 0
+
+unsigned int absDiff(unsigned int a, unsigned int b)
+{
+       if ( a > b )
+               return(a - b);
+       else
+               return(b - a);
+}
+
+#endif
+/*
+       monk liu @ 4/6/2011:
+                  re-write the calculatePLL function of ddk750.
+                  the original version function does not use some mathematics tricks and shortcut
+                  when it doing the calculation of the best N,M,D combination
+                  I think this version gives a little upgrade in speed
+
+       750 pll clock formular:
+       Request Clock = (Input Clock * M )/(N * X)
+
+       Input Clock = 14318181 hz
+       X = 2 power D
+       D ={0,1,2,3,4,5,6}
+       M = {1,...,255}
+       N = {2,...,15}
+*/
+unsigned int calcPllValue(unsigned int request_orig,pll_value_t *pll)
+{
+       /* used for primary and secondary channel pixel clock pll */
+       static pllcalparam xparm_PIXEL[] = {
+               /* 2^0 = 1*/                    {0,0,0,1},
+               /* 2^ 1 =2*/                    {1,0,1,2},
+               /* 2^ 2  = 4*/          {2,0,2,4},
+                                                       {3,0,3,8},
+                                                       {4,1,3,16},
+                                                       {5,2,3,32},
+               /* 2^6 = 64  */         {6,3,3,64},
+                                                       };
+
+       /* used for MXCLK (chip clock) */
+       static pllcalparam xparm_MXCLK[] = {
+               /* 2^0 = 1*/                    {0,0,0,1},
+               /* 2^ 1 =2*/                    {1,0,1,2},
+               /* 2^ 2  = 4*/          {2,0,2,4},
+                                                       {3,0,3,8},
+                                                       };
+
+       /* as sm750 register definition, N located in 2,15 and M located in 1,255       */
+       int N,M,X,d;
+       int xcnt;
+       int miniDiff;
+       unsigned int RN,quo,rem,fl_quo;
+       unsigned int input,request;
+       unsigned int tmpClock,ret;
+       pllcalparam * xparm;
+
+#if 1
+       if (getChipType() == SM750LE)
+       {
+               /* SM750LE don't have prgrammable PLL and M/N values to work on.
+               Just return the requested clock. */
+               return request_orig;
+       }
+#endif
+
+       ret = 0;
+       miniDiff = ~0;
+       request = request_orig / 1000;
+       input = pll->inputFreq / 1000;
+
+       /* for MXCLK register , no POD provided, so need be treated differently */
+
+       if(pll->clockType != MXCLK_PLL){
+               xparm = &xparm_PIXEL[0];
+               xcnt = sizeof(xparm_PIXEL)/sizeof(xparm_PIXEL[0]);
+       }else{
+               xparm = &xparm_MXCLK[0];
+               xcnt = sizeof(xparm_MXCLK)/sizeof(xparm_MXCLK[0]);
+       }
+
+
+       for(N = 15;N>1;N--)
+       {
+               /* RN will not exceed maximum long if @request <= 285 MHZ (for 32bit cpu) */
+               RN = N * request;
+               quo = RN / input;
+               rem = RN % input;/* rem always small than 14318181 */
+               fl_quo = (rem * 10000 /input);
+
+               for(d = xcnt - 1;d >= 0;d--){
+                       X = xparm[d].value;
+                       M = quo*X;
+                       M += fl_quo * X / 10000;
+                       /* round step */
+                       M += (fl_quo*X % 10000)>5000?1:0;
+                       if(M < 256 && M > 0)
+                       {
+                               unsigned int diff;
+                               tmpClock = pll->inputFreq *M / N / X;
+                               diff = absDiff(tmpClock,request_orig);
+                               if(diff < miniDiff)
+                               {
+                                       pll->M = M;
+                                       pll->N = N;
+                                       pll->OD = xparm[d].od;
+                                       pll->POD = xparm[d].pod;
+                                       miniDiff = diff;
+                                       ret = tmpClock;
+                               }
+                       }
+               }
+       }
+
+       //printk("Finally:  pll->n[%lu],m[%lu],od[%lu],pod[%lu]\n",pll->N,pll->M,pll->OD,pll->POD);
+       return ret;
+}
+
+unsigned int calcPllValue2(
+unsigned int ulRequestClk, /* Required pixel clock in Hz unit */
+pll_value_t *pPLL           /* Structure to hold the value to be set in PLL */
+)
+{
+       unsigned int M, N, OD, POD = 0, diff, pllClk, odPower, podPower;
+       unsigned int bestDiff = 0xffffffff; /* biggest 32 bit unsigned number */
+       unsigned int ret;
+    /* Init PLL structure to know states */
+       pPLL->M = 0;
+       pPLL->N = 0;
+       pPLL->OD = 0;
+       pPLL->POD = 0;
+
+    /* Sanity check: None at the moment */
+
+    /* Convert everything in Khz range in order to avoid calculation overflow */
+       pPLL->inputFreq /= 1000;
+       ulRequestClk /= 1000;
+
+#ifndef VALIDATION_CHIP
+    /* The maximum of post divider is 8. */
+       for (POD=0; POD<=3; POD++)
+#endif
+               {
+
+#ifndef VALIDATION_CHIP
+       /* MXCLK_PLL does not have post divider. */
+       if ((POD > 0) && (pPLL->clockType == MXCLK_PLL))
+               break;
+#endif
+
+       /* Work out 2 to the power of POD */
+       podPower = twoToPowerOfx(POD);
+
+       /* OD has only 2 bits [15:14] and its value must between 0 to 3 */
+       for (OD=0; OD<=3; OD++)
+       {
+               /* Work out 2 to the power of OD */
+               odPower = twoToPowerOfx(OD);
+
+#ifdef VALIDATION_CHIP
+       if (odPower > 4)
+               podPower = 4;
+       else
+               podPower = odPower;
+#endif
+
+               /* N has 4 bits [11:8] and its value must between 2 and 15.
+               The N == 1 will behave differently --> Result is not correct. */
+       for (N=2; N<=15; N++)
+       {
+               /* The formula for PLL is ulRequestClk = inputFreq * M / N / (2^OD)
+               In the following steps, we try to work out a best M value given the others are known.
+               To avoid decimal calculation, we use 1000 as multiplier for up to 3 decimal places of accuracy.
+               */
+               M = ulRequestClk * N * odPower * 1000 / pPLL->inputFreq;
+               M = roundedDiv(M, 1000);
+
+               /* M field has only 8 bits, reject value bigger than 8 bits */
+               if (M < 256)
+               {
+                       /* Calculate the actual clock for a given M & N */
+                       pllClk = pPLL->inputFreq * M / N / odPower / podPower;
+
+                       /* How much are we different from the requirement */
+                       diff = absDiff(pllClk, ulRequestClk);
+
+                       if (diff < bestDiff)
+                       {
+                               bestDiff = diff;
+
+                               /* Store M and N values */
+                               pPLL->M  = M;
+                               pPLL->N  = N;
+                               pPLL->OD = OD;
+
+#ifdef VALIDATION_CHIP
+                       if (OD > 2)
+                               POD = 2;
+                       else
+                               POD = OD;
+#endif
+
+                       pPLL->POD = POD;
+                       }
+               }
+       }
+       }
+       }
+
+    /* Restore input frequency from Khz to hz unit */
+//    pPLL->inputFreq *= 1000;
+       ulRequestClk *= 1000;
+       pPLL->inputFreq = DEFAULT_INPUT_CLOCK; /* Default reference clock */
+
+    /* Output debug information */
+       //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Requested Frequency = %d\n", ulRequestClk));
+       //DDKDEBUGPRINT((DISPLAY_LEVEL, "calcPllValue: Input CLK = %dHz, M=%d, N=%d, OD=%d, POD=%d\n", pPLL->inputFreq, pPLL->M, pPLL->N, pPLL->OD, pPLL->POD));
+
+    /* Return actual frequency that the PLL can set */
+       ret = calcPLL(pPLL);
+       return ret;
+}
+
+
+
+
+
+unsigned int formatPllReg(pll_value_t *pPLL)
+{
+       unsigned int ulPllReg = 0;
+
+    /* Note that all PLL's have the same format. Here, we just use Panel PLL parameter
+       to work out the bit fields in the register.
+       On returning a 32 bit number, the value can be applied to any PLL in the calling function.
+    */
+       ulPllReg =
+       FIELD_SET(  0, PANEL_PLL_CTRL, BYPASS, OFF)
+       | FIELD_SET(  0, PANEL_PLL_CTRL, POWER,  ON)
+       | FIELD_SET(  0, PANEL_PLL_CTRL, INPUT,  OSC)
+#ifndef VALIDATION_CHIP
+       | FIELD_VALUE(0, PANEL_PLL_CTRL, POD,    pPLL->POD)
+#endif
+       | FIELD_VALUE(0, PANEL_PLL_CTRL, OD,     pPLL->OD)
+       | FIELD_VALUE(0, PANEL_PLL_CTRL, N,      pPLL->N)
+       | FIELD_VALUE(0, PANEL_PLL_CTRL, M,      pPLL->M);
+
+    return ulPllReg;
+}
+
+
diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
new file mode 100644 (file)
index 0000000..04cb0d5
--- /dev/null
@@ -0,0 +1,87 @@
+#ifndef DDK750_CHIP_H__
+#define DDK750_CHIP_H__
+#define DEFAULT_INPUT_CLOCK 14318181 /* Default reference clock */
+#ifndef SM750LE_REVISION_ID
+#define SM750LE_REVISION_ID ((unsigned char)0xfe)
+#endif
+
+#include <linux/io.h>
+
+/* This is all the chips recognized by this library */
+typedef enum _logical_chip_type_t
+{
+    SM_UNKNOWN,
+    SM718,
+    SM750,
+    SM750LE,
+}
+logical_chip_type_t;
+
+
+typedef enum _clock_type_t
+{
+       MXCLK_PLL,
+       PRIMARY_PLL,
+       SECONDARY_PLL,
+       VGA0_PLL,
+       VGA1_PLL,
+}
+clock_type_t;
+
+typedef struct _pll_value_t
+{
+    clock_type_t clockType;
+    unsigned long inputFreq; /* Input clock frequency to the PLL */
+
+    /* Use this when clockType = PANEL_PLL */
+    unsigned long M;
+    unsigned long N;
+    unsigned long OD;
+    unsigned long POD;
+}
+pll_value_t;
+
+/* input struct to initChipParam() function */
+typedef struct _initchip_param_t
+{
+    unsigned short powerMode;    /* Use power mode 0 or 1 */
+    unsigned short chipClock;    /* Speed of main chip clock in MHz unit
+                                    0 = keep the current clock setting
+                                    Others = the new main chip clock
+                                  */
+    unsigned short memClock;     /* Speed of memory clock in MHz unit
+                                    0 = keep the current clock setting
+                                    Others = the new memory clock
+                                  */
+    unsigned short masterClock;  /* Speed of master clock in MHz unit
+                                    0 = keep the current clock setting
+                                    Others = the new master clock
+                                  */
+    unsigned short setAllEngOff; /* 0 = leave all engine state untouched.
+                                    1 = make sure they are off: 2D, Overlay,
+                                    video alpha, alpha, hardware cursors
+                                 */
+    unsigned char resetMemory;   /* 0 = Do not reset the memory controller
+                                    1 = Reset the memory controller
+                                  */
+
+    /* More initialization parameter can be added if needed */
+}
+initchip_param_t;
+
+
+logical_chip_type_t getChipType(void);
+unsigned int calcPllValue(unsigned int request,pll_value_t *pll);
+unsigned int calcPllValue2(unsigned int,pll_value_t *);
+unsigned int formatPllReg(pll_value_t *pPLL);
+void ddk750_set_mmio(void __iomem *,unsigned short,char);
+unsigned int ddk750_getVMSize(void);
+int ddk750_initHw(initchip_param_t *);
+unsigned int getPllValue(clock_type_t clockType, pll_value_t *pPLL);
+unsigned int getChipClock(void);
+void setChipClock(unsigned int);
+void setMemoryClock(unsigned int frequency);
+void setMasterClock(unsigned int frequency);
+
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_display.c b/drivers/staging/sm750fb/ddk750_display.c
new file mode 100644 (file)
index 0000000..c84196a
--- /dev/null
@@ -0,0 +1,307 @@
+#include "ddk750_reg.h"
+#include "ddk750_help.h"
+#include "ddk750_display.h"
+#include "ddk750_power.h"
+#include "ddk750_dvi.h"
+
+#define primaryWaitVerticalSync(delay) waitNextVerticalSync(0,delay)
+
+static void setDisplayControl(int ctrl,int dispState)
+{
+       /* state != 0 means turn on both timing & plane en_bit */
+       unsigned long ulDisplayCtrlReg, ulReservedBits;
+       int cnt;
+
+       cnt = 0;
+
+       /* Set the primary display control */
+       if (!ctrl)
+       {
+               ulDisplayCtrlReg = PEEK32(PANEL_DISPLAY_CTRL);
+               /* Turn on/off the Panel display control */
+               if (dispState)
+               {
+                       /* Timing should be enabled first before enabling the plane
+                        * because changing at the same time does not guarantee that
+                        * the plane will also enabled or disabled.
+            */
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               PANEL_DISPLAY_CTRL, TIMING, ENABLE);
+                       POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
+
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               PANEL_DISPLAY_CTRL, PLANE, ENABLE);
+
+                       /* Added some masks to mask out the reserved bits.
+                        * Sometimes, the reserved bits are set/reset randomly when
+                        * writing to the PRIMARY_DISPLAY_CTRL, therefore, the register
+                        * reserved bits are needed to be masked out.
+                        */
+                       ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) |
+                               FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) |
+                               FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE);
+
+                       /* Somehow the register value on the plane is not set
+                        * until a few delay. Need to write
+                        * and read it a couple times
+                        */
+                       do
+                       {
+                               cnt++;
+                               POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
+                       } while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) !=
+                                       (ulDisplayCtrlReg & ~ulReservedBits));
+                       printk("Set Panel Plane enbit:after tried %d times\n",cnt);
+               }
+               else
+               {
+                       /* When turning off, there is no rule on the programming
+                        * sequence since whenever the clock is off, then it does not
+                        * matter whether the plane is enabled or disabled.
+                        * Note: Modifying the plane bit will take effect on the
+                        * next vertical sync. Need to find out if it is necessary to
+                        * wait for 1 vsync before modifying the timing enable bit.
+                        * */
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               PANEL_DISPLAY_CTRL, PLANE, DISABLE);
+                       POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
+
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               PANEL_DISPLAY_CTRL, TIMING, DISABLE);
+                       POKE32(PANEL_DISPLAY_CTRL, ulDisplayCtrlReg);
+               }
+
+       }
+       /* Set the secondary display control */
+       else
+       {
+               ulDisplayCtrlReg = PEEK32(CRT_DISPLAY_CTRL);
+
+               if (dispState)
+               {
+                       /* Timing should be enabled first before enabling the plane because changing at the
+                          same time does not guarantee that the plane will also enabled or disabled.
+                          */
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               CRT_DISPLAY_CTRL, TIMING, ENABLE);
+                       POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg);
+
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               CRT_DISPLAY_CTRL, PLANE, ENABLE);
+
+                       /* Added some masks to mask out the reserved bits.
+                        * Sometimes, the reserved bits are set/reset randomly when
+                        * writing to the PRIMARY_DISPLAY_CTRL, therefore, the register
+                        * reserved bits are needed to be masked out.
+                        */
+
+                       ulReservedBits = FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) |
+                               FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) |
+                               FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE) |
+                               FIELD_SET(0, CRT_DISPLAY_CTRL, RESERVED_4_MASK, ENABLE);
+
+                       do
+                       {
+                               cnt++;
+                               POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg);
+                       } while((PEEK32(CRT_DISPLAY_CTRL) & ~ulReservedBits) !=
+                                       (ulDisplayCtrlReg & ~ulReservedBits));
+                               printk("Set Crt Plane enbit:after tried %d times\n",cnt);
+               }
+               else
+               {
+                       /* When turning off, there is no rule on the programming
+                        * sequence since whenever the clock is off, then it does not
+                        * matter whether the plane is enabled or disabled.
+                        * Note: Modifying the plane bit will take effect on the next
+                        * vertical sync. Need to find out if it is necessary to
+                        * wait for 1 vsync before modifying the timing enable bit.
+                        */
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               CRT_DISPLAY_CTRL, PLANE, DISABLE);
+                       POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg);
+
+                       ulDisplayCtrlReg = FIELD_SET(ulDisplayCtrlReg,
+                                                               CRT_DISPLAY_CTRL, TIMING, DISABLE);
+                       POKE32(CRT_DISPLAY_CTRL, ulDisplayCtrlReg);
+               }
+       }
+}
+
+
+static void waitNextVerticalSync(int ctrl,int delay)
+{
+       unsigned int status;
+       if(!ctrl){
+               /* primary controller */
+
+        /* Do not wait when the Primary PLL is off or display control is already off.
+                  This will prevent the software to wait forever. */
+               if ((FIELD_GET(PEEK32(PANEL_PLL_CTRL), PANEL_PLL_CTRL, POWER) ==
+                        PANEL_PLL_CTRL_POWER_OFF) ||
+                       (FIELD_GET(PEEK32(PANEL_DISPLAY_CTRL), PANEL_DISPLAY_CTRL, TIMING) ==
+                        PANEL_DISPLAY_CTRL_TIMING_DISABLE))
+               {
+                       return;
+               }
+
+        while (delay-- > 0)
+        {
+            /* Wait for end of vsync. */
+            do
+            {
+                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                   SYSTEM_CTRL,
+                                   PANEL_VSYNC);
+            }
+            while (status == SYSTEM_CTRL_PANEL_VSYNC_ACTIVE);
+
+            /* Wait for start of vsync. */
+            do
+            {
+                status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                   SYSTEM_CTRL,
+                                   PANEL_VSYNC);
+            }
+            while (status == SYSTEM_CTRL_PANEL_VSYNC_INACTIVE);
+        }
+
+       }else{
+
+               /* Do not wait when the Primary PLL is off or display control is already off.
+                          This will prevent the software to wait forever. */
+               if ((FIELD_GET(PEEK32(CRT_PLL_CTRL), CRT_PLL_CTRL, POWER) ==
+                        CRT_PLL_CTRL_POWER_OFF) ||
+                       (FIELD_GET(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, TIMING) ==
+                        CRT_DISPLAY_CTRL_TIMING_DISABLE))
+               {
+                       return;
+               }
+
+               while (delay-- > 0)
+               {
+                       /* Wait for end of vsync. */
+                       do
+                       {
+                               status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                                                  SYSTEM_CTRL,
+                                                                  CRT_VSYNC);
+                       }
+                       while (status == SYSTEM_CTRL_CRT_VSYNC_ACTIVE);
+
+                       /* Wait for start of vsync. */
+                       do
+                       {
+                               status = FIELD_GET(PEEK32(SYSTEM_CTRL),
+                                                                  SYSTEM_CTRL,
+                                                                  CRT_VSYNC);
+                       }
+                       while (status == SYSTEM_CTRL_CRT_VSYNC_INACTIVE);
+               }
+       }
+}
+
+static void swPanelPowerSequence(int disp,int delay)
+{
+       unsigned int reg;
+
+       /* disp should be 1 to open sequence */
+       reg = PEEK32(PANEL_DISPLAY_CTRL);
+       reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,FPEN,disp);
+       POKE32(PANEL_DISPLAY_CTRL,reg);
+       primaryWaitVerticalSync(delay);
+
+
+       reg = PEEK32(PANEL_DISPLAY_CTRL);
+       reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,DATA,disp);
+       POKE32(PANEL_DISPLAY_CTRL,reg);
+       primaryWaitVerticalSync(delay);
+
+       reg = PEEK32(PANEL_DISPLAY_CTRL);
+       reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,VBIASEN,disp);
+       POKE32(PANEL_DISPLAY_CTRL,reg);
+       primaryWaitVerticalSync(delay);
+
+
+       reg = PEEK32(PANEL_DISPLAY_CTRL);
+       reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,FPEN,disp);
+       POKE32(PANEL_DISPLAY_CTRL,reg);
+       primaryWaitVerticalSync(delay);
+
+}
+
+void ddk750_setLogicalDispOut(disp_output_t output)
+{
+       unsigned int reg;
+       if(output & PNL_2_USAGE){
+               /* set panel path controller select */
+               reg = PEEK32(PANEL_DISPLAY_CTRL);
+               reg = FIELD_VALUE(reg,PANEL_DISPLAY_CTRL,SELECT,(output & PNL_2_MASK)>>PNL_2_OFFSET);
+               POKE32(PANEL_DISPLAY_CTRL,reg);
+       }
+
+       if(output & CRT_2_USAGE){
+               /* set crt path controller select */
+               reg = PEEK32(CRT_DISPLAY_CTRL);
+               reg = FIELD_VALUE(reg,CRT_DISPLAY_CTRL,SELECT,(output & CRT_2_MASK)>>CRT_2_OFFSET);
+               /*se blank off */
+               reg = FIELD_SET(reg,CRT_DISPLAY_CTRL,BLANK,OFF);
+               POKE32(CRT_DISPLAY_CTRL,reg);
+
+       }
+
+       if(output & PRI_TP_USAGE){
+               /* set primary timing and plane en_bit */
+               setDisplayControl(0,(output&PRI_TP_MASK)>>PRI_TP_OFFSET);
+       }
+
+       if(output & SEC_TP_USAGE){
+               /* set secondary timing and plane en_bit*/
+               setDisplayControl(1,(output&SEC_TP_MASK)>>SEC_TP_OFFSET);
+       }
+
+       if(output & PNL_SEQ_USAGE){
+               /* set  panel sequence */
+               swPanelPowerSequence((output&PNL_SEQ_MASK)>>PNL_SEQ_OFFSET,4);
+       }
+
+       if(output & DAC_USAGE)
+               setDAC((output & DAC_MASK)>>DAC_OFFSET);
+
+       if(output & DPMS_USAGE)
+               ddk750_setDPMS((output & DPMS_MASK) >> DPMS_OFFSET);
+}
+
+
+int ddk750_initDVIDisp(void)
+{
+    /* Initialize DVI. If the dviInit fail and the VendorID or the DeviceID are
+       not zeroed, then set the failure flag. If it is zeroe, it might mean
+       that the system is in Dual CRT Monitor configuration. */
+
+    /* De-skew enabled with default 111b value.
+       This will fix some artifacts problem in some mode on board 2.2.
+       Somehow this fix does not affect board 2.1.
+     */
+    if ((dviInit(1,  /* Select Rising Edge */
+                1,  /* Select 24-bit bus */
+                0,  /* Select Single Edge clock */
+                1,  /* Enable HSync as is */
+                1,  /* Enable VSync as is */
+                1,  /* Enable De-skew */
+                7,  /* Set the de-skew setting to maximum setup */
+                1,  /* Enable continuous Sync */
+                1,  /* Enable PLL Filter */
+                4   /* Use the recommended value for PLL Filter value */
+        ) != 0) && (dviGetVendorID() != 0x0000) && (dviGetDeviceID() != 0x0000))
+    {
+        return (-1);
+    }
+
+    /* TODO: Initialize other display component */
+
+    /* Success */
+    return 0;
+
+}
+
diff --git a/drivers/staging/sm750fb/ddk750_display.h b/drivers/staging/sm750fb/ddk750_display.h
new file mode 100644 (file)
index 0000000..ae0f84c
--- /dev/null
@@ -0,0 +1,160 @@
+#ifndef DDK750_DISPLAY_H__
+#define DDK750_DISPLAY_H__
+
+/* panel path select
+       80000[29:28]
+*/
+
+#define PNL_2_OFFSET 0
+#define PNL_2_MASK (3 << PNL_2_OFFSET)
+#define PNL_2_USAGE    (PNL_2_MASK << 16)
+#define PNL_2_PRI      ((0 << PNL_2_OFFSET)|PNL_2_USAGE)
+#define PNL_2_SEC      ((2 << PNL_2_OFFSET)|PNL_2_USAGE)
+
+
+/* primary timing & plane enable bit
+       1: 80000[8] & 80000[2] on
+       0: both off
+*/
+#define PRI_TP_OFFSET 4
+#define PRI_TP_MASK (1 << PRI_TP_OFFSET)
+#define PRI_TP_USAGE (PRI_TP_MASK << 16)
+#define PRI_TP_ON ((0x1 << PRI_TP_OFFSET)|PRI_TP_USAGE)
+#define PRI_TP_OFF ((0x0 << PRI_TP_OFFSET)|PRI_TP_USAGE)
+
+
+/* panel sequency status
+       80000[27:24]
+*/
+#define PNL_SEQ_OFFSET 6
+#define PNL_SEQ_MASK (1 << PNL_SEQ_OFFSET)
+#define PNL_SEQ_USAGE (PNL_SEQ_MASK << 16)
+#define PNL_SEQ_ON ((1 << PNL_SEQ_OFFSET)|PNL_SEQ_USAGE)
+#define PNL_SEQ_OFF ((0 << PNL_SEQ_OFFSET)|PNL_SEQ_USAGE)
+
+/* dual digital output
+       80000[19]
+*/
+#define DUAL_TFT_OFFSET 8
+#define DUAL_TFT_MASK (1 << DUAL_TFT_OFFSET)
+#define DUAL_TFT_USAGE (DUAL_TFT_MASK << 16)
+#define DUAL_TFT_ON ((1 << DUAL_TFT_OFFSET)|DUAL_TFT_USAGE)
+#define DUAL_TFT_OFF ((0 << DUAL_TFT_OFFSET)|DUAL_TFT_USAGE)
+
+/* secondary timing & plane enable bit
+       1:80200[8] & 80200[2] on
+       0: both off
+*/
+#define SEC_TP_OFFSET 5
+#define SEC_TP_MASK (1<< SEC_TP_OFFSET)
+#define SEC_TP_USAGE (SEC_TP_MASK << 16)
+#define SEC_TP_ON  ((0x1 << SEC_TP_OFFSET)|SEC_TP_USAGE)
+#define SEC_TP_OFF ((0x0 << SEC_TP_OFFSET)|SEC_TP_USAGE)
+
+/* crt path select
+       80200[19:18]
+*/
+#define CRT_2_OFFSET 2
+#define CRT_2_MASK (3 << CRT_2_OFFSET)
+#define CRT_2_USAGE (CRT_2_MASK << 16)
+#define CRT_2_PRI ((0x0 << CRT_2_OFFSET)|CRT_2_USAGE)
+#define CRT_2_SEC ((0x2 << CRT_2_OFFSET)|CRT_2_USAGE)
+
+
+/* DAC affect both DVI and DSUB
+       4[20]
+*/
+#define DAC_OFFSET 7
+#define DAC_MASK (1 << DAC_OFFSET)
+#define DAC_USAGE (DAC_MASK << 16)
+#define DAC_ON ((0x0<< DAC_OFFSET)|DAC_USAGE)
+#define DAC_OFF ((0x1 << DAC_OFFSET)|DAC_USAGE)
+
+/* DPMS only affect D-SUB head
+       0[31:30]
+*/
+#define DPMS_OFFSET 9
+#define DPMS_MASK (3 << DPMS_OFFSET)
+#define DPMS_USAGE (DPMS_MASK << 16)
+#define DPMS_OFF ((3 << DPMS_OFFSET)|DPMS_USAGE)
+#define DPMS_ON ((0 << DPMS_OFFSET)|DPMS_USAGE)
+
+
+
+/*
+       LCD1 means panel path TFT1  & panel path DVI (so enable DAC)
+       CRT means crt path DSUB
+*/
+#if 0
+typedef enum _disp_output_t
+{
+       NO_DISPLAY = DPMS_OFF,
+
+       LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DPMS_OFF|DAC_ON,
+       LCD1_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DPMS_OFF|DAC_ON,
+
+       LCD2_PRI = CRT_2_PRI|PRI_TP_ON|DUAL_TFT_ON|DPMS_OFF,
+       LCD2_SEC = CRT_2_SEC|SEC_TP_ON|DUAL_TFT_ON|DPMS_OFF,
+
+       DSUB_PRI = CRT_2_PRI|PRI_TP_ON|DAC_ON,
+       DSUB_SEC = CRT_2_SEC|SEC_TP_ON|DAC_ON,
+
+       LCD1_DSUB_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
+                                       CRT_2_PRI|SEC_TP_OFF|DAC_ON,
+
+       LCD1_DSUB_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
+                                       CRT_2_SEC|PRI_TP_OFF|DAC_ON,
+
+       /* LCD1 show primary and DSUB show secondary */
+       LCD1_DSUB_DUAL = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
+                                        CRT_2_SEC|SEC_TP_ON|DAC_ON,
+
+       /* LCD1 show secondary and DSUB show primary */
+       LCD1_DSUB_DUAL_SWAP = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
+                                                       CRT_2_PRI|PRI_TP_ON|DAC_ON,
+
+       LCD1_LCD2_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|
+                                       CRT_2_PRI|SEC_TP_OFF|DPMS_OFF|DUAL_TFT_ON,
+
+       LCD1_LCD2_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|
+                                       CRT_2_SEC|PRI_TP_OFF|DPMS_OFF|DUAL_TFT_ON,
+
+       LCD1_LCD2_DSUB_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DAC_ON|
+                                               CRT_2_PRI|SEC_TP_OFF|DPMS_ON|DUAL_TFT_ON,
+
+       LCD1_LCD2_DSUB_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DAC_ON|
+                                               CRT_2_SEC|PRI_TP_OFF|DPMS_ON|DUAL_TFT_ON,
+
+
+}
+disp_output_t;
+#else
+typedef enum _disp_output_t{
+       do_LCD1_PRI = PNL_2_PRI|PRI_TP_ON|PNL_SEQ_ON|DAC_ON,
+       do_LCD1_SEC = PNL_2_SEC|SEC_TP_ON|PNL_SEQ_ON|DAC_ON,
+#if 0
+       do_LCD2_PRI = CRT_2_PRI|PRI_TP_ON,
+       do_LCD2_SEC = CRT_2_SEC|SEC_TP_ON,
+#else
+       do_LCD2_PRI = CRT_2_PRI|PRI_TP_ON|DUAL_TFT_ON,
+       do_LCD2_SEC = CRT_2_SEC|SEC_TP_ON|DUAL_TFT_ON,
+#endif
+       /*
+       do_DSUB_PRI = CRT_2_PRI|PRI_TP_ON|DPMS_ON|DAC_ON,
+       do_DSUB_SEC = CRT_2_SEC|SEC_TP_ON|DPMS_ON|DAC_ON,
+       */
+#if 0
+       do_CRT_PRI = CRT_2_PRI|PRI_TP_ON,
+       do_CRT_SEC = CRT_2_SEC|SEC_TP_ON,
+#else
+       do_CRT_PRI = CRT_2_PRI|PRI_TP_ON|DPMS_ON|DAC_ON,
+       do_CRT_SEC = CRT_2_SEC|SEC_TP_ON|DPMS_ON|DAC_ON,
+#endif
+}
+disp_output_t;
+#endif
+
+void ddk750_setLogicalDispOut(disp_output_t);
+int ddk750_initDVIDisp(void);
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_dvi.c b/drivers/staging/sm750fb/ddk750_dvi.c
new file mode 100644 (file)
index 0000000..f5932bb
--- /dev/null
@@ -0,0 +1,99 @@
+#define USE_DVICHIP 
+#ifdef USE_DVICHIP
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_dvi.h"
+#include "ddk750_sii164.h"
+
+
+/* This global variable contains all the supported driver and its corresponding
+   function API. Please set the function pointer to NULL whenever the function
+   is not supported. */
+static dvi_ctrl_device_t g_dcftSupportedDviController[] =
+{
+#ifdef DVI_CTRL_SII164
+    {
+        .pfnInit = sii164InitChip,
+        .pfnGetVendorId = sii164GetVendorID,
+        .pfnGetDeviceId = sii164GetDeviceID,
+#ifdef SII164_FULL_FUNCTIONS
+        .pfnResetChip = sii164ResetChip,
+        .pfnGetChipString = sii164GetChipString,
+        .pfnSetPower = sii164SetPower,
+        .pfnEnableHotPlugDetection = sii164EnableHotPlugDetection,
+        .pfnIsConnected = sii164IsConnected,
+        .pfnCheckInterrupt = sii164CheckInterrupt,
+        .pfnClearInterrupt = sii164ClearInterrupt,
+#endif
+    },
+#endif
+};
+
+
+int dviInit(
+    unsigned char edgeSelect,
+    unsigned char busSelect,
+    unsigned char dualEdgeClkSelect,
+    unsigned char hsyncEnable,
+    unsigned char vsyncEnable,
+    unsigned char deskewEnable,
+    unsigned char deskewSetting,
+    unsigned char continuousSyncEnable,
+    unsigned char pllFilterEnable,
+    unsigned char pllFilterValue
+                       )
+{
+       dvi_ctrl_device_t *pCurrentDviCtrl;
+       pCurrentDviCtrl = g_dcftSupportedDviController;
+       if(pCurrentDviCtrl->pfnInit != NULL)
+       {
+               return pCurrentDviCtrl->pfnInit(edgeSelect, busSelect, dualEdgeClkSelect, hsyncEnable,
+                              vsyncEnable, deskewEnable, deskewSetting, continuousSyncEnable,
+                              pllFilterEnable, pllFilterValue);
+       }
+       return -1;//error
+}
+
+
+/*
+ *  dviGetVendorID
+ *      This function gets the vendor ID of the DVI controller chip.
+ *
+ *  Output:
+ *      Vendor ID
+ */
+unsigned short dviGetVendorID(void)
+{
+    dvi_ctrl_device_t *pCurrentDviCtrl;
+
+    //pCurrentDviCtrl = getDviCtrl();
+    pCurrentDviCtrl = g_dcftSupportedDviController;
+    if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
+        return pCurrentDviCtrl->pfnGetVendorId();
+
+    return 0x0000;
+}
+
+
+/*
+ *  dviGetDeviceID
+ *      This function gets the device ID of the DVI controller chip.
+ *
+ *  Output:
+ *      Device ID
+ */
+unsigned short dviGetDeviceID(void)
+{
+    dvi_ctrl_device_t *pCurrentDviCtrl;
+
+//    pCurrentDviCtrl = getDviCtrl();
+       pCurrentDviCtrl = g_dcftSupportedDviController;
+    if (pCurrentDviCtrl != (dvi_ctrl_device_t *)0)
+        return pCurrentDviCtrl->pfnGetDeviceId();
+
+    return 0x0000;
+}
+
+#endif
+
+
diff --git a/drivers/staging/sm750fb/ddk750_dvi.h b/drivers/staging/sm750fb/ddk750_dvi.h
new file mode 100644 (file)
index 0000000..50bcec2
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef DDK750_DVI_H__
+#define DDK750_DVI_H__
+
+/* dvi chip stuffs structros */
+
+typedef long (*PFN_DVICTRL_INIT)(
+    unsigned char edgeSelect,
+    unsigned char busSelect,
+    unsigned char dualEdgeClkSelect,
+    unsigned char hsyncEnable,
+    unsigned char vsyncEnable,
+    unsigned char deskewEnable,
+    unsigned char deskewSetting,
+    unsigned char continuousSyncEnable,
+    unsigned char pllFilterEnable,
+    unsigned char pllFilterValue);
+typedef void (*PFN_DVICTRL_RESETCHIP)(void);
+typedef char* (*PFN_DVICTRL_GETCHIPSTRING)(void);
+typedef unsigned short (*PFN_DVICTRL_GETVENDORID)(void);
+typedef unsigned short (*PFN_DVICTRL_GETDEVICEID)(void);
+typedef void (*PFN_DVICTRL_SETPOWER)(unsigned char powerUp);
+typedef void (*PFN_DVICTRL_HOTPLUGDETECTION)(unsigned char enableHotPlug);
+typedef unsigned char (*PFN_DVICTRL_ISCONNECTED)(void);
+typedef unsigned char (*PFN_DVICTRL_CHECKINTERRUPT)(void);
+typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void);
+
+
+
+/* Structure to hold all the function pointer to the DVI Controller. */
+typedef struct _dvi_ctrl_device_t
+{
+    PFN_DVICTRL_INIT                pfnInit;
+    PFN_DVICTRL_RESETCHIP           pfnResetChip;
+    PFN_DVICTRL_GETCHIPSTRING       pfnGetChipString;
+    PFN_DVICTRL_GETVENDORID         pfnGetVendorId;
+    PFN_DVICTRL_GETDEVICEID         pfnGetDeviceId;
+    PFN_DVICTRL_SETPOWER            pfnSetPower;
+    PFN_DVICTRL_HOTPLUGDETECTION    pfnEnableHotPlugDetection;
+    PFN_DVICTRL_ISCONNECTED         pfnIsConnected;
+    PFN_DVICTRL_CHECKINTERRUPT      pfnCheckInterrupt;
+    PFN_DVICTRL_CLEARINTERRUPT      pfnClearInterrupt;
+} dvi_ctrl_device_t;
+#define DVI_CTRL_SII164
+
+
+
+/* dvi functions prototype */
+int dviInit(
+    unsigned char edgeSelect,
+    unsigned char busSelect,
+    unsigned char dualEdgeClkSelect,
+    unsigned char hsyncEnable,
+    unsigned char vsyncEnable,
+    unsigned char deskewEnable,
+    unsigned char deskewSetting,
+    unsigned char continuousSyncEnable,
+    unsigned char pllFilterEnable,
+    unsigned char pllFilterValue
+);
+
+unsigned short dviGetVendorID(void);
+unsigned short dviGetDeviceID(void);
+
+
+
+#endif
+
diff --git a/drivers/staging/sm750fb/ddk750_help.c b/drivers/staging/sm750fb/ddk750_help.c
new file mode 100644 (file)
index 0000000..c68ff3b
--- /dev/null
@@ -0,0 +1,19 @@
+//#include "ddk750_reg.h"
+//#include "ddk750_chip.h"
+#include "ddk750_help.h"
+
+void __iomem * mmio750 = NULL;
+char revId750 = 0;
+unsigned short devId750 = 0;
+
+/* after driver mapped io registers, use this function first */
+void ddk750_set_mmio(void __iomem * addr,unsigned short devId,char revId)
+{
+       mmio750 = addr;
+       devId750 = devId;
+       revId750 = revId;
+       if(revId == 0xfe)
+               printk("found sm750le\n");
+}
+
+
diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h
new file mode 100644 (file)
index 0000000..07c8264
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef DDK750_HELP_H__
+#define DDK750_HELP_H__
+#include "ddk750_chip.h"
+#ifndef USE_INTERNAL_REGISTER_ACCESS
+
+#include <linux/ioport.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include "sm750_help.h"
+
+
+#if 0
+/* if 718 big endian turned on,be aware that don't use this driver for general use,only for ppc big-endian */
+#warning "big endian on target cpu and enable nature big endian support of 718 capability !"
+#define PEEK32(addr)                   __raw_readl(mmio750 + addr)
+#define POKE32(addr,data)              __raw_writel(data, mmio750 + addr)
+#else /* software control endianess */
+#define PEEK32(addr) readl(addr + mmio750)
+#define POKE32(addr,data) writel(data, addr + mmio750)
+#endif
+
+extern void __iomem * mmio750;
+extern char revId750;
+extern unsigned short devId750;
+#else
+/* implement if you want use it*/
+#endif
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c b/drivers/staging/sm750fb/ddk750_hwi2c.c
new file mode 100644 (file)
index 0000000..84dfb6f
--- /dev/null
@@ -0,0 +1,271 @@
+#define USE_HW_I2C
+#ifdef USE_HW_I2C
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_hwi2c.h"
+#include "ddk750_power.h"
+
+#define MAX_HWI2C_FIFO                  16
+#define HWI2C_WAIT_TIMEOUT              0xF0000
+
+
+int hwI2CInit(
+    unsigned char busSpeedMode
+)
+{
+    unsigned int value;
+
+    /* Enable GPIO 30 & 31 as IIC clock & data */
+       value = PEEK32(GPIO_MUX);
+
+    value = FIELD_SET(value, GPIO_MUX, 30, I2C) |
+                       FIELD_SET(0, GPIO_MUX, 31, I2C);
+       POKE32(GPIO_MUX, value);
+
+    /* Enable Hardware I2C power.
+       TODO: Check if we need to enable GPIO power?
+     */
+    enableI2C(1);
+
+    /* Enable the I2C Controller and set the bus speed mode */
+    value = PEEK32(I2C_CTRL);
+    if (busSpeedMode == 0)
+        value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD);
+    else
+        value = FIELD_SET(value, I2C_CTRL, MODE, FAST);
+    value = FIELD_SET(value, I2C_CTRL, EN, ENABLE);
+    POKE32(I2C_CTRL, value);
+
+    return 0;
+}
+
+
+void hwI2CClose(void)
+{
+    unsigned int value;
+
+    /* Disable I2C controller */
+    value = PEEK32(I2C_CTRL);
+    value = FIELD_SET(value, I2C_CTRL, EN, DISABLE);
+    POKE32(I2C_CTRL, value);
+
+    /* Disable I2C Power */
+    enableI2C(0);
+
+    /* Set GPIO 30 & 31 back as GPIO pins */
+    value = PEEK32(GPIO_MUX);
+    value = FIELD_SET(value, GPIO_MUX, 30, GPIO);
+    value = FIELD_SET(value, GPIO_MUX, 31, GPIO);
+    POKE32(GPIO_MUX, value);
+}
+
+
+long hwI2CWaitTXDone(void)
+{
+    unsigned int timeout;
+
+    /* Wait until the transfer is completed. */
+    timeout = HWI2C_WAIT_TIMEOUT;
+       while ((FIELD_GET(PEEK32(I2C_STATUS), I2C_STATUS, TX) != I2C_STATUS_TX_COMPLETED) &&
+           (timeout != 0))
+               timeout--;
+
+       if (timeout == 0)
+           return (-1);
+
+    return 0;
+}
+
+
+
+/*
+ *  This function writes data to the i2c slave device registers.
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address
+ *      length          - Total number of bytes to be written to the device
+ *      pBuffer         - The buffer that contains the data to be written to the
+ *                     i2c device.
+ *
+ *  Return Value:
+ *      Total number of bytes those are actually written.
+ */
+unsigned int hwI2CWriteData(
+    unsigned char deviceAddress,
+    unsigned int length,
+    unsigned char *pBuffer
+)
+{
+    unsigned char count, i;
+    unsigned int totalBytes = 0;
+
+    /* Set the Device Address */
+    POKE32(I2C_SLAVE_ADDRESS, deviceAddress & ~0x01);
+
+    /* Write data.
+     * Note:
+     *      Only 16 byte can be accessed per i2c start instruction.
+     */
+    do
+    {
+        /* Reset I2C by writing 0 to I2C_RESET register to clear the previous status. */
+        POKE32(I2C_RESET, 0);
+
+        /* Set the number of bytes to be written */
+        if (length < MAX_HWI2C_FIFO)
+            count = length - 1;
+        else
+            count = MAX_HWI2C_FIFO - 1;
+        POKE32(I2C_BYTE_COUNT, count);
+
+        /* Move the data to the I2C data register */
+           for (i = 0; i <= count; i++)
+            POKE32(I2C_DATA0 + i, *pBuffer++);
+
+        /* Start the I2C */
+        POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+
+        /* Wait until the transfer is completed. */
+        if (hwI2CWaitTXDone() != 0)
+            break;
+
+        /* Substract length */
+        length -= (count + 1);
+
+        /* Total byte written */
+        totalBytes += (count + 1);
+
+    } while (length > 0);
+
+    return totalBytes;
+}
+
+
+
+
+/*
+ *  This function reads data from the slave device and stores them
+ *  in the given buffer
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address
+ *      length          - Total number of bytes to be read
+ *      pBuffer         - Pointer to a buffer to be filled with the data read
+ *                     from the slave device. It has to be the same size as the
+ *                     length to make sure that it can keep all the data read.
+ *
+ *  Return Value:
+ *      Total number of actual bytes read from the slave device
+ */
+unsigned int hwI2CReadData(
+    unsigned char deviceAddress,
+    unsigned int length,
+    unsigned char *pBuffer
+)
+{
+    unsigned char count, i;
+    unsigned int totalBytes = 0;
+
+    /* Set the Device Address */
+    POKE32(I2C_SLAVE_ADDRESS, deviceAddress | 0x01);
+
+    /* Read data and save them to the buffer.
+     * Note:
+     *      Only 16 byte can be accessed per i2c start instruction.
+     */
+    do
+    {
+        /* Reset I2C by writing 0 to I2C_RESET register to clear all the status. */
+        POKE32(I2C_RESET, 0);
+
+        /* Set the number of bytes to be read */
+        if (length <= MAX_HWI2C_FIFO)
+            count = length - 1;
+        else
+            count = MAX_HWI2C_FIFO - 1;
+        POKE32(I2C_BYTE_COUNT, count);
+
+        /* Start the I2C */
+        POKE32(I2C_CTRL, FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START));
+
+        /* Wait until transaction done. */
+        if (hwI2CWaitTXDone() != 0)
+            break;
+
+        /* Save the data to the given buffer */
+        for (i = 0; i <= count; i++)
+                   *pBuffer++ = PEEK32(I2C_DATA0 + i);
+
+        /* Substract length by 16 */
+        length -= (count + 1);
+
+        /* Number of bytes read. */
+        totalBytes += (count + 1);
+
+    } while (length > 0);
+
+    return totalBytes;
+}
+
+
+
+
+/*
+ *  This function reads the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be read from
+ *      registerIndex   - Slave device's register to be read
+ *
+ *  Return Value:
+ *      Register value
+ */
+unsigned char hwI2CReadReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex
+)
+{
+    unsigned char value = (0xFF);
+
+    if (hwI2CWriteData(deviceAddress, 1, &registerIndex) == 1)
+        hwI2CReadData(deviceAddress, 1, &value);
+
+    return value;
+}
+
+
+
+
+
+/*
+ *  This function writes a value to the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be written
+ *      registerIndex   - Slave device's register to be written
+ *      data            - Data to be written to the register
+ *
+ *  Result:
+ *          0   - Success
+ *         -1   - Fail
+ */
+int hwI2CWriteReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex,
+    unsigned char data
+)
+{
+    unsigned char value[2];
+
+    value[0] = registerIndex;
+    value[1] = data;
+    if (hwI2CWriteData(deviceAddress, 2, value) == 2)
+        return 0;
+
+    return (-1);
+}
+
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.h b/drivers/staging/sm750fb/ddk750_hwi2c.h
new file mode 100644 (file)
index 0000000..ad31149
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef DDK750_HWI2C_H__
+#define DDK750_HWI2C_H__
+
+/* hwi2c functions */
+int hwI2CInit(unsigned char busSpeedMode);
+void hwI2CClose(void);
+
+unsigned char hwI2CReadReg(unsigned char deviceAddress,unsigned char registerIndex);
+int hwI2CWriteReg(unsigned char deviceAddress,unsigned char registerIndex,unsigned char data);
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c
new file mode 100644 (file)
index 0000000..2e418fb
--- /dev/null
@@ -0,0 +1,205 @@
+
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_mode.h"
+#include "ddk750_chip.h"
+
+/*
+       SM750LE only:
+    This function takes care extra registers and bit fields required to set
+    up a mode in SM750LE
+
+       Explanation about Display Control register:
+    HW only supports 7 predefined pixel clocks, and clock select is
+    in bit 29:27 of    Display Control register.
+*/
+static unsigned long displayControlAdjust_SM750LE(mode_parameter_t *pModeParam, unsigned long dispControl)
+{
+       unsigned long x, y;
+
+       x = pModeParam->horizontal_display_end;
+       y = pModeParam->vertical_display_end;
+
+    /* SM750LE has to set up the top-left and bottom-right
+       registers as well.
+       Note that normal SM750/SM718 only use those two register for
+       auto-centering mode.
+    */
+    POKE32(CRT_AUTO_CENTERING_TL,
+      FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, TOP, 0)
+    | FIELD_VALUE(0, CRT_AUTO_CENTERING_TL, LEFT, 0));
+
+    POKE32(CRT_AUTO_CENTERING_BR,
+      FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, BOTTOM, y-1)
+    | FIELD_VALUE(0, CRT_AUTO_CENTERING_BR, RIGHT, x-1));
+
+    /* Assume common fields in dispControl have been properly set before
+       calling this function.
+       This function only sets the extra fields in dispControl.
+    */
+
+       /* Clear bit 29:27 of display control register */
+    dispControl &= FIELD_CLEAR(CRT_DISPLAY_CTRL, CLK);
+
+       /* Set bit 29:27 of display control register for the right clock */
+       /* Note that SM750LE only need to supported 7 resoluitons. */
+       if ( x == 800 && y == 600 )
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL41);
+       else if (x == 1024 && y == 768)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL65);
+       else if (x == 1152 && y == 864)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
+       else if (x == 1280 && y == 768)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL80);
+       else if (x == 1280 && y == 720)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL74);
+       else if (x == 1280 && y == 960)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
+       else if (x == 1280 && y == 1024)
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL108);
+       else /* default to VGA clock */
+       dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLK, PLL25);
+
+       /* Set bit 25:24 of display controller */
+    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CRTSELECT, CRT);
+    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, RGBBIT, 24BIT);
+
+    /* Set bit 14 of display controller */
+    dispControl = FIELD_SET(dispControl, CRT_DISPLAY_CTRL, CLOCK_PHASE, ACTIVE_LOW);
+
+    POKE32(CRT_DISPLAY_CTRL, dispControl);
+
+       return dispControl;
+}
+
+
+
+/* only timing related registers will be  programed */
+static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll)
+{
+       int ret = 0;
+       int cnt = 0;
+       unsigned int ulTmpValue,ulReg;
+       if(pll->clockType == SECONDARY_PLL)
+       {
+               /* programe secondary pixel clock */
+               POKE32(CRT_PLL_CTRL,formatPllReg(pll));
+        POKE32(CRT_HORIZONTAL_TOTAL,
+              FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
+            | FIELD_VALUE(0, CRT_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
+
+        POKE32(CRT_HORIZONTAL_SYNC,
+              FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
+            | FIELD_VALUE(0, CRT_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
+
+        POKE32(CRT_VERTICAL_TOTAL,
+              FIELD_VALUE(0, CRT_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
+            | FIELD_VALUE(0, CRT_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
+
+        POKE32(CRT_VERTICAL_SYNC,
+              FIELD_VALUE(0, CRT_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
+            | FIELD_VALUE(0, CRT_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
+
+
+               ulTmpValue = FIELD_VALUE(0,CRT_DISPLAY_CTRL,VSYNC_PHASE,pModeParam->vertical_sync_polarity)|
+                                         FIELD_VALUE(0,CRT_DISPLAY_CTRL,HSYNC_PHASE,pModeParam->horizontal_sync_polarity)|
+                                         FIELD_SET(0,CRT_DISPLAY_CTRL,TIMING,ENABLE)|
+                                         FIELD_SET(0,CRT_DISPLAY_CTRL,PLANE,ENABLE);
+
+
+               if(getChipType() == SM750LE){
+                       displayControlAdjust_SM750LE(pModeParam,ulTmpValue);
+               }else{
+                       ulReg = PEEK32(CRT_DISPLAY_CTRL)
+                                       & FIELD_CLEAR(CRT_DISPLAY_CTRL,VSYNC_PHASE)
+                                       & FIELD_CLEAR(CRT_DISPLAY_CTRL,HSYNC_PHASE)
+                                       & FIELD_CLEAR(CRT_DISPLAY_CTRL,TIMING)
+                                       & FIELD_CLEAR(CRT_DISPLAY_CTRL,PLANE);
+
+                        POKE32(CRT_DISPLAY_CTRL,ulTmpValue|ulReg);
+               }
+
+       }
+       else if(pll->clockType == PRIMARY_PLL)
+       {
+               unsigned int ulReservedBits;
+               POKE32(PANEL_PLL_CTRL,formatPllReg(pll));
+
+        POKE32(PANEL_HORIZONTAL_TOTAL,
+              FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, TOTAL, pModeParam->horizontal_total - 1)
+            | FIELD_VALUE(0, PANEL_HORIZONTAL_TOTAL, DISPLAY_END, pModeParam->horizontal_display_end - 1));
+
+        POKE32(PANEL_HORIZONTAL_SYNC,
+              FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, WIDTH, pModeParam->horizontal_sync_width)
+            | FIELD_VALUE(0, PANEL_HORIZONTAL_SYNC, START, pModeParam->horizontal_sync_start - 1));
+
+        POKE32(PANEL_VERTICAL_TOTAL,
+              FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, TOTAL, pModeParam->vertical_total - 1)
+            | FIELD_VALUE(0, PANEL_VERTICAL_TOTAL, DISPLAY_END, pModeParam->vertical_display_end - 1));
+
+        POKE32(PANEL_VERTICAL_SYNC,
+              FIELD_VALUE(0, PANEL_VERTICAL_SYNC, HEIGHT, pModeParam->vertical_sync_height)
+            | FIELD_VALUE(0, PANEL_VERTICAL_SYNC, START, pModeParam->vertical_sync_start - 1));
+
+               ulTmpValue = FIELD_VALUE(0,PANEL_DISPLAY_CTRL,VSYNC_PHASE,pModeParam->vertical_sync_polarity)|
+                                       FIELD_VALUE(0,PANEL_DISPLAY_CTRL,HSYNC_PHASE,pModeParam->horizontal_sync_polarity)|
+                                       FIELD_VALUE(0,PANEL_DISPLAY_CTRL,CLOCK_PHASE,pModeParam->clock_phase_polarity)|
+                                       FIELD_SET(0,PANEL_DISPLAY_CTRL,TIMING,ENABLE)|
+                                       FIELD_SET(0,PANEL_DISPLAY_CTRL,PLANE,ENABLE);
+
+        ulReservedBits = FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_1_MASK, ENABLE) |
+                         FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_2_MASK, ENABLE) |
+                         FIELD_SET(0, PANEL_DISPLAY_CTRL, RESERVED_3_MASK, ENABLE)|
+                         FIELD_SET(0,PANEL_DISPLAY_CTRL,VSYNC,ACTIVE_LOW);
+
+        ulReg = (PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits)
+              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, CLOCK_PHASE)
+              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, VSYNC_PHASE)
+              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, HSYNC_PHASE)
+              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, TIMING)
+              & FIELD_CLEAR(PANEL_DISPLAY_CTRL, PLANE);
+
+
+               /* May a hardware bug or just my test chip (not confirmed).
+               * PANEL_DISPLAY_CTRL register seems requiring few writes
+               * before a value can be succesfully written in.
+               * Added some masks to mask out the reserved bits.
+               * Note: This problem happens by design. The hardware will wait for the
+               *       next vertical sync to turn on/off the plane.
+               */
+
+               POKE32(PANEL_DISPLAY_CTRL,ulTmpValue|ulReg);
+#if 1
+               while((PEEK32(PANEL_DISPLAY_CTRL) & ~ulReservedBits) != (ulTmpValue|ulReg))
+               {
+                       cnt++;
+                       if(cnt > 1000)
+                               break;
+                       POKE32(PANEL_DISPLAY_CTRL,ulTmpValue|ulReg);
+               }
+#endif
+       }
+       else{
+               ret = -1;
+       }
+       return ret;
+}
+
+int ddk750_setModeTiming(mode_parameter_t * parm,clock_type_t clock)
+{
+       pll_value_t pll;
+       unsigned int uiActualPixelClk;
+       pll.inputFreq = DEFAULT_INPUT_CLOCK;
+       pll.clockType = clock;
+
+       uiActualPixelClk = calcPllValue(parm->pixel_clock,&pll);
+       if(getChipType() == SM750LE){
+               /* set graphic mode via IO method */
+               outb_p(0x88,0x3d4);
+               outb_p(0x06,0x3d5);
+       }
+       programModeRegisters(parm,&pll);
+       return 0;
+}
+
+
diff --git a/drivers/staging/sm750fb/ddk750_mode.h b/drivers/staging/sm750fb/ddk750_mode.h
new file mode 100644 (file)
index 0000000..6f8df96
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef DDK750_MODE_H__
+#define DDK750_MODE_H__
+
+#include "ddk750_chip.h"
+
+typedef enum _spolarity_t
+{
+    POS = 0, /* positive */
+    NEG, /* negative */
+}
+spolarity_t;
+
+
+typedef struct _mode_parameter_t
+{
+    /* Horizontal timing. */
+    unsigned long horizontal_total;
+    unsigned long horizontal_display_end;
+    unsigned long horizontal_sync_start;
+    unsigned long horizontal_sync_width;
+    spolarity_t horizontal_sync_polarity;
+
+    /* Vertical timing. */
+    unsigned long vertical_total;
+    unsigned long vertical_display_end;
+    unsigned long vertical_sync_start;
+    unsigned long vertical_sync_height;
+    spolarity_t vertical_sync_polarity;
+
+    /* Refresh timing. */
+    unsigned long pixel_clock;
+    unsigned long horizontal_frequency;
+    unsigned long vertical_frequency;
+
+    /* Clock Phase. This clock phase only applies to Panel. */
+    spolarity_t clock_phase_polarity;
+}
+mode_parameter_t;
+
+int ddk750_setModeTiming(mode_parameter_t *,clock_type_t);
+
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_power.c b/drivers/staging/sm750fb/ddk750_power.c
new file mode 100644 (file)
index 0000000..cbb9767
--- /dev/null
@@ -0,0 +1,239 @@
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_power.h"
+
+void ddk750_setDPMS(DPMS_t state)
+{
+       unsigned int value;
+       if(getChipType() == SM750LE){
+               value = PEEK32(CRT_DISPLAY_CTRL);
+               POKE32(CRT_DISPLAY_CTRL,FIELD_VALUE(value,CRT_DISPLAY_CTRL,DPMS,state));
+       }else{
+               value = PEEK32(SYSTEM_CTRL);
+               value= FIELD_VALUE(value,SYSTEM_CTRL,DPMS,state);
+               POKE32(SYSTEM_CTRL, value);
+       }
+}
+
+unsigned int getPowerMode(void)
+{
+       if(getChipType() == SM750LE)
+               return 0;
+    return (FIELD_GET(PEEK32(POWER_MODE_CTRL), POWER_MODE_CTRL, MODE));
+}
+
+
+/*
+ * SM50x can operate in one of three modes: 0, 1 or Sleep.
+ * On hardware reset, power mode 0 is default.
+ */
+void setPowerMode(unsigned int powerMode)
+{
+    unsigned int control_value = 0;
+
+    control_value = PEEK32(POWER_MODE_CTRL);
+
+       if(getChipType() == SM750LE)
+               return;
+
+    switch (powerMode)
+    {
+        case POWER_MODE_CTRL_MODE_MODE0:
+            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE0);
+            break;
+
+        case POWER_MODE_CTRL_MODE_MODE1:
+            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, MODE1);
+            break;
+
+        case POWER_MODE_CTRL_MODE_SLEEP:
+            control_value = FIELD_SET(control_value, POWER_MODE_CTRL, MODE, SLEEP);
+            break;
+
+        default:
+            break;
+    }
+
+    /* Set up other fields in Power Control Register */
+    if (powerMode == POWER_MODE_CTRL_MODE_SLEEP)
+    {
+        control_value =
+#ifdef VALIDATION_CHIP
+            FIELD_SET(  control_value, POWER_MODE_CTRL, 336CLK, OFF) |
+#endif
+            FIELD_SET(  control_value, POWER_MODE_CTRL, OSC_INPUT,  OFF);
+    }
+    else
+    {
+        control_value =
+#ifdef VALIDATION_CHIP
+            FIELD_SET(  control_value, POWER_MODE_CTRL, 336CLK, ON) |
+#endif
+            FIELD_SET(  control_value, POWER_MODE_CTRL, OSC_INPUT,  ON);
+    }
+
+    /* Program new power mode. */
+    POKE32(POWER_MODE_CTRL, control_value);
+}
+
+void setCurrentGate(unsigned int gate)
+{
+    unsigned int gate_reg;
+    unsigned int mode;
+
+    /* Get current power mode. */
+    mode = getPowerMode();
+
+    switch (mode)
+    {
+        case POWER_MODE_CTRL_MODE_MODE0:
+            gate_reg = MODE0_GATE;
+            break;
+
+        case POWER_MODE_CTRL_MODE_MODE1:
+            gate_reg = MODE1_GATE;
+            break;
+
+        default:
+            gate_reg = MODE0_GATE;
+            break;
+    }
+    POKE32(gate_reg, gate);
+}
+
+
+
+/*
+ * This function enable/disable the 2D engine.
+ */
+void enable2DEngine(unsigned int enable)
+{
+    uint32_t gate;
+
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+    {
+        gate = FIELD_SET(gate, CURRENT_GATE, DE,  ON);
+        gate = FIELD_SET(gate, CURRENT_GATE, CSC, ON);
+    }
+    else
+    {
+        gate = FIELD_SET(gate, CURRENT_GATE, DE,  OFF);
+        gate = FIELD_SET(gate, CURRENT_GATE, CSC, OFF);
+    }
+
+    setCurrentGate(gate);
+}
+
+
+/*
+ * This function enable/disable the ZV Port.
+ */
+void enableZVPort(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable ZV Port Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+    {
+        gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, ON);
+#if 1
+        /* Using Software I2C */
+        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
+#else
+        /* Using Hardware I2C */
+        gate = FIELD_SET(gate, CURRENT_GATE, I2C,    ON);
+#endif
+    }
+    else
+    {
+        /* Disable ZV Port Gate. There is no way to know whether the GPIO pins are being used
+           or not. Therefore, do not disable the GPIO gate. */
+        gate = FIELD_SET(gate, CURRENT_GATE, ZVPORT, OFF);
+    }
+
+    setCurrentGate(gate);
+}
+
+
+void enableSSP(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable SSP Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+        gate = FIELD_SET(gate, CURRENT_GATE, SSP, ON);
+    else
+        gate = FIELD_SET(gate, CURRENT_GATE, SSP, OFF);
+
+    setCurrentGate(gate);
+}
+
+void enableDMA(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable DMA Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+        gate = FIELD_SET(gate, CURRENT_GATE, DMA, ON);
+    else
+        gate = FIELD_SET(gate, CURRENT_GATE, DMA, OFF);
+
+    setCurrentGate(gate);
+}
+
+/*
+ * This function enable/disable the GPIO Engine
+ */
+void enableGPIO(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable GPIO Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, ON);
+    else
+        gate = FIELD_SET(gate, CURRENT_GATE, GPIO, OFF);
+
+    setCurrentGate(gate);
+}
+
+/*
+ * This function enable/disable the PWM Engine
+ */
+void enablePWM(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable PWM Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+        gate = FIELD_SET(gate, CURRENT_GATE, PWM, ON);
+    else
+        gate = FIELD_SET(gate, CURRENT_GATE, PWM, OFF);
+
+    setCurrentGate(gate);
+}
+
+/*
+ * This function enable/disable the I2C Engine
+ */
+void enableI2C(unsigned int enable)
+{
+    uint32_t gate;
+
+    /* Enable I2C Gate */
+    gate = PEEK32(CURRENT_GATE);
+    if (enable)
+        gate = FIELD_SET(gate, CURRENT_GATE, I2C, ON);
+    else
+        gate = FIELD_SET(gate, CURRENT_GATE, I2C, OFF);
+
+    setCurrentGate(gate);
+}
+
+
diff --git a/drivers/staging/sm750fb/ddk750_power.h b/drivers/staging/sm750fb/ddk750_power.h
new file mode 100644 (file)
index 0000000..71dc7f9
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef DDK750_POWER_H__
+#define DDK750_POWER_H__
+
+typedef enum _DPMS_t
+{
+    crtDPMS_ON = 0x0,
+    crtDPMS_STANDBY = 0x1,
+    crtDPMS_SUSPEND = 0x2,
+    crtDPMS_OFF = 0x3,
+}
+DPMS_t;
+
+#define setDAC(off) \
+               {       \
+               POKE32(MISC_CTRL,FIELD_VALUE(PEEK32(MISC_CTRL), \
+                                                                       MISC_CTRL,      \
+                                                                       DAC_POWER,      \
+                                                                       off));  \
+               }
+
+void ddk750_setDPMS(DPMS_t);
+
+unsigned int getPowerMode(void);
+
+/*
+ * This function sets the current power mode
+ */
+void setPowerMode(unsigned int powerMode);
+
+/*
+ * This function sets current gate
+ */
+void setCurrentGate(unsigned int gate);
+
+/*
+ * This function enable/disable the 2D engine.
+ */
+void enable2DEngine(unsigned int enable);
+
+/*
+ * This function enable/disable the ZV Port
+ */
+void enableZVPort(unsigned int enable);
+
+/*
+ * This function enable/disable the DMA Engine
+ */
+void enableDMA(unsigned int enable);
+
+/*
+ * This function enable/disable the GPIO Engine
+ */
+void enableGPIO(unsigned int enable);
+
+/*
+ * This function enable/disable the PWM Engine
+ */
+void enablePWM(unsigned int enable);
+
+/*
+ * This function enable/disable the I2C Engine
+ */
+void enableI2C(unsigned int enable);
+
+/*
+ * This function enable/disable the SSP.
+ */
+void enableSSP(unsigned int enable);
+
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h
new file mode 100644 (file)
index 0000000..2016f97
--- /dev/null
@@ -0,0 +1,2616 @@
+#ifndef DDK750_REG_H__
+#define DDK750_REG_H__
+
+/* New register for SM750LE */
+#define DE_STATE1                                        0x100054
+#define DE_STATE1_DE_ABORT                               0:0
+#define DE_STATE1_DE_ABORT_OFF                           0
+#define DE_STATE1_DE_ABORT_ON                            1
+
+#define DE_STATE2                                        0x100058
+#define DE_STATE2_DE_FIFO                                3:3
+#define DE_STATE2_DE_FIFO_NOTEMPTY                       0
+#define DE_STATE2_DE_FIFO_EMPTY                          1
+#define DE_STATE2_DE_STATUS                              2:2
+#define DE_STATE2_DE_STATUS_IDLE                         0
+#define DE_STATE2_DE_STATUS_BUSY                         1
+#define DE_STATE2_DE_MEM_FIFO                            1:1
+#define DE_STATE2_DE_MEM_FIFO_NOTEMPTY                   0
+#define DE_STATE2_DE_MEM_FIFO_EMPTY                      1
+#define DE_STATE2_DE_RESERVED                            0:0
+
+
+
+#define SYSTEM_CTRL                                   0x000000
+#define SYSTEM_CTRL_DPMS                              31:30
+#define SYSTEM_CTRL_DPMS_VPHP                         0
+#define SYSTEM_CTRL_DPMS_VPHN                         1
+#define SYSTEM_CTRL_DPMS_VNHP                         2
+#define SYSTEM_CTRL_DPMS_VNHN                         3
+#define SYSTEM_CTRL_PCI_BURST                         29:29
+#define SYSTEM_CTRL_PCI_BURST_OFF                     0
+#define SYSTEM_CTRL_PCI_BURST_ON                      1
+#define SYSTEM_CTRL_PCI_MASTER                        25:25
+#define SYSTEM_CTRL_PCI_MASTER_OFF                    0
+#define SYSTEM_CTRL_PCI_MASTER_ON                     1
+#define SYSTEM_CTRL_LATENCY_TIMER                     24:24
+#define SYSTEM_CTRL_LATENCY_TIMER_ON                  0
+#define SYSTEM_CTRL_LATENCY_TIMER_OFF                 1
+#define SYSTEM_CTRL_DE_FIFO                           23:23
+#define SYSTEM_CTRL_DE_FIFO_NOTEMPTY                  0
+#define SYSTEM_CTRL_DE_FIFO_EMPTY                     1
+#define SYSTEM_CTRL_DE_STATUS                         22:22
+#define SYSTEM_CTRL_DE_STATUS_IDLE                    0
+#define SYSTEM_CTRL_DE_STATUS_BUSY                    1
+#define SYSTEM_CTRL_DE_MEM_FIFO                       21:21
+#define SYSTEM_CTRL_DE_MEM_FIFO_NOTEMPTY              0
+#define SYSTEM_CTRL_DE_MEM_FIFO_EMPTY                 1
+#define SYSTEM_CTRL_CSC_STATUS                        20:20
+#define SYSTEM_CTRL_CSC_STATUS_IDLE                   0
+#define SYSTEM_CTRL_CSC_STATUS_BUSY                   1
+#define SYSTEM_CTRL_CRT_VSYNC                         19:19
+#define SYSTEM_CTRL_CRT_VSYNC_INACTIVE                0
+#define SYSTEM_CTRL_CRT_VSYNC_ACTIVE                  1
+#define SYSTEM_CTRL_PANEL_VSYNC                       18:18
+#define SYSTEM_CTRL_PANEL_VSYNC_INACTIVE              0
+#define SYSTEM_CTRL_PANEL_VSYNC_ACTIVE                1
+#define SYSTEM_CTRL_CURRENT_BUFFER                    17:17
+#define SYSTEM_CTRL_CURRENT_BUFFER_NORMAL             0
+#define SYSTEM_CTRL_CURRENT_BUFFER_FLIP_PENDING       1
+#define SYSTEM_CTRL_DMA_STATUS                        16:16
+#define SYSTEM_CTRL_DMA_STATUS_IDLE                   0
+#define SYSTEM_CTRL_DMA_STATUS_BUSY                   1
+#define SYSTEM_CTRL_PCI_BURST_READ                    15:15
+#define SYSTEM_CTRL_PCI_BURST_READ_OFF                0
+#define SYSTEM_CTRL_PCI_BURST_READ_ON                 1
+#define SYSTEM_CTRL_DE_ABORT                          13:13
+#define SYSTEM_CTRL_DE_ABORT_OFF                      0
+#define SYSTEM_CTRL_DE_ABORT_ON                       1
+#define SYSTEM_CTRL_PCI_SUBSYS_ID_LOCK                11:11
+#define SYSTEM_CTRL_PCI_SUBSYS_ID_LOCK_OFF            0
+#define SYSTEM_CTRL_PCI_SUBSYS_ID_LOCK_ON             1
+#define SYSTEM_CTRL_PCI_RETRY                         7:7
+#define SYSTEM_CTRL_PCI_RETRY_ON                      0
+#define SYSTEM_CTRL_PCI_RETRY_OFF                     1
+#define SYSTEM_CTRL_PCI_SLAVE_BURST_READ_SIZE         5:4
+#define SYSTEM_CTRL_PCI_SLAVE_BURST_READ_SIZE_1       0
+#define SYSTEM_CTRL_PCI_SLAVE_BURST_READ_SIZE_2       1
+#define SYSTEM_CTRL_PCI_SLAVE_BURST_READ_SIZE_4       2
+#define SYSTEM_CTRL_PCI_SLAVE_BURST_READ_SIZE_8       3
+#define SYSTEM_CTRL_CRT_TRISTATE                      3:3
+#define SYSTEM_CTRL_CRT_TRISTATE_OFF                  0
+#define SYSTEM_CTRL_CRT_TRISTATE_ON                   1
+#define SYSTEM_CTRL_PCIMEM_TRISTATE                   2:2
+#define SYSTEM_CTRL_PCIMEM_TRISTATE_OFF               0
+#define SYSTEM_CTRL_PCIMEM_TRISTATE_ON                1
+#define SYSTEM_CTRL_LOCALMEM_TRISTATE                 1:1
+#define SYSTEM_CTRL_LOCALMEM_TRISTATE_OFF             0
+#define SYSTEM_CTRL_LOCALMEM_TRISTATE_ON              1
+#define SYSTEM_CTRL_PANEL_TRISTATE                    0:0
+#define SYSTEM_CTRL_PANEL_TRISTATE_OFF                0
+#define SYSTEM_CTRL_PANEL_TRISTATE_ON                 1
+
+#define MISC_CTRL                                     0x000004
+#define MISC_CTRL_DRAM_RERESH_COUNT                   27:27
+#define MISC_CTRL_DRAM_RERESH_COUNT_1ROW              0
+#define MISC_CTRL_DRAM_RERESH_COUNT_3ROW              1
+#define MISC_CTRL_DRAM_REFRESH_TIME                   26:25
+#define MISC_CTRL_DRAM_REFRESH_TIME_8                 0
+#define MISC_CTRL_DRAM_REFRESH_TIME_16                1
+#define MISC_CTRL_DRAM_REFRESH_TIME_32                2
+#define MISC_CTRL_DRAM_REFRESH_TIME_64                3
+#define MISC_CTRL_INT_OUTPUT                          24:24
+#define MISC_CTRL_INT_OUTPUT_NORMAL                   0
+#define MISC_CTRL_INT_OUTPUT_INVERT                   1
+#define MISC_CTRL_PLL_CLK_COUNT                       23:23
+#define MISC_CTRL_PLL_CLK_COUNT_OFF                   0
+#define MISC_CTRL_PLL_CLK_COUNT_ON                    1
+#define MISC_CTRL_DAC_POWER                           20:20
+#define MISC_CTRL_DAC_POWER_ON                        0
+#define MISC_CTRL_DAC_POWER_OFF                       1
+#define MISC_CTRL_CLK_SELECT                          16:16
+#define MISC_CTRL_CLK_SELECT_OSC                      0
+#define MISC_CTRL_CLK_SELECT_TESTCLK                  1
+#define MISC_CTRL_DRAM_COLUMN_SIZE                    15:14
+#define MISC_CTRL_DRAM_COLUMN_SIZE_256                0
+#define MISC_CTRL_DRAM_COLUMN_SIZE_512                1
+#define MISC_CTRL_DRAM_COLUMN_SIZE_1024               2
+#define MISC_CTRL_LOCALMEM_SIZE                       13:12
+#define MISC_CTRL_LOCALMEM_SIZE_8M                    3
+#define MISC_CTRL_LOCALMEM_SIZE_16M                   0
+#define MISC_CTRL_LOCALMEM_SIZE_32M                   1
+#define MISC_CTRL_LOCALMEM_SIZE_64M                   2
+#define MISC_CTRL_DRAM_TWTR                           11:11
+#define MISC_CTRL_DRAM_TWTR_2CLK                      0
+#define MISC_CTRL_DRAM_TWTR_1CLK                      1
+#define MISC_CTRL_DRAM_TWR                            10:10
+#define MISC_CTRL_DRAM_TWR_3CLK                       0
+#define MISC_CTRL_DRAM_TWR_2CLK                       1
+#define MISC_CTRL_DRAM_TRP                            9:9
+#define MISC_CTRL_DRAM_TRP_3CLK                       0
+#define MISC_CTRL_DRAM_TRP_4CLK                       1
+#define MISC_CTRL_DRAM_TRFC                           8:8
+#define MISC_CTRL_DRAM_TRFC_12CLK                     0
+#define MISC_CTRL_DRAM_TRFC_14CLK                     1
+#define MISC_CTRL_DRAM_TRAS                           7:7
+#define MISC_CTRL_DRAM_TRAS_7CLK                      0
+#define MISC_CTRL_DRAM_TRAS_8CLK                      1
+#define MISC_CTRL_LOCALMEM_RESET                      6:6
+#define MISC_CTRL_LOCALMEM_RESET_RESET                0
+#define MISC_CTRL_LOCALMEM_RESET_NORMAL               1
+#define MISC_CTRL_LOCALMEM_STATE                      5:5
+#define MISC_CTRL_LOCALMEM_STATE_ACTIVE               0
+#define MISC_CTRL_LOCALMEM_STATE_INACTIVE             1
+#define MISC_CTRL_CPU_CAS_LATENCY                     4:4
+#define MISC_CTRL_CPU_CAS_LATENCY_2CLK                0
+#define MISC_CTRL_CPU_CAS_LATENCY_3CLK                1
+#define MISC_CTRL_DLL                                 3:3
+#define MISC_CTRL_DLL_ON                              0
+#define MISC_CTRL_DLL_OFF                             1
+#define MISC_CTRL_DRAM_OUTPUT                         2:2
+#define MISC_CTRL_DRAM_OUTPUT_LOW                     0
+#define MISC_CTRL_DRAM_OUTPUT_HIGH                    1
+#define MISC_CTRL_LOCALMEM_BUS_SIZE                   1:1
+#define MISC_CTRL_LOCALMEM_BUS_SIZE_32                0
+#define MISC_CTRL_LOCALMEM_BUS_SIZE_64                1
+#define MISC_CTRL_EMBEDDED_LOCALMEM                   0:0
+#define MISC_CTRL_EMBEDDED_LOCALMEM_ON                0
+#define MISC_CTRL_EMBEDDED_LOCALMEM_OFF               1
+
+#define GPIO_MUX                                      0x000008
+#define GPIO_MUX_31                                   31:31
+#define GPIO_MUX_31_GPIO                              0
+#define GPIO_MUX_31_I2C                               1
+#define GPIO_MUX_30                                   30:30
+#define GPIO_MUX_30_GPIO                              0
+#define GPIO_MUX_30_I2C                               1
+#define GPIO_MUX_29                                   29:29
+#define GPIO_MUX_29_GPIO                              0
+#define GPIO_MUX_29_SSP1                              1
+#define GPIO_MUX_28                                   28:28
+#define GPIO_MUX_28_GPIO                              0
+#define GPIO_MUX_28_SSP1                              1
+#define GPIO_MUX_27                                   27:27
+#define GPIO_MUX_27_GPIO                              0
+#define GPIO_MUX_27_SSP1                              1
+#define GPIO_MUX_26                                   26:26
+#define GPIO_MUX_26_GPIO                              0
+#define GPIO_MUX_26_SSP1                              1
+#define GPIO_MUX_25                                   25:25
+#define GPIO_MUX_25_GPIO                              0
+#define GPIO_MUX_25_SSP1                              1
+#define GPIO_MUX_24                                   24:24
+#define GPIO_MUX_24_GPIO                              0
+#define GPIO_MUX_24_SSP0                              1
+#define GPIO_MUX_23                                   23:23
+#define GPIO_MUX_23_GPIO                              0
+#define GPIO_MUX_23_SSP0                              1
+#define GPIO_MUX_22                                   22:22
+#define GPIO_MUX_22_GPIO                              0
+#define GPIO_MUX_22_SSP0                              1
+#define GPIO_MUX_21                                   21:21
+#define GPIO_MUX_21_GPIO                              0
+#define GPIO_MUX_21_SSP0                              1
+#define GPIO_MUX_20                                   20:20
+#define GPIO_MUX_20_GPIO                              0
+#define GPIO_MUX_20_SSP0                              1
+#define GPIO_MUX_19                                   19:19
+#define GPIO_MUX_19_GPIO                              0
+#define GPIO_MUX_19_PWM                               1
+#define GPIO_MUX_18                                   18:18
+#define GPIO_MUX_18_GPIO                              0
+#define GPIO_MUX_18_PWM                               1
+#define GPIO_MUX_17                                   17:17
+#define GPIO_MUX_17_GPIO                              0
+#define GPIO_MUX_17_PWM                               1
+#define GPIO_MUX_16                                   16:16
+#define GPIO_MUX_16_GPIO_ZVPORT                       0
+#define GPIO_MUX_16_TEST_DATA                         1
+#define GPIO_MUX_15                                   15:15
+#define GPIO_MUX_15_GPIO_ZVPORT                       0
+#define GPIO_MUX_15_TEST_DATA                         1
+#define GPIO_MUX_14                                   14:14
+#define GPIO_MUX_14_GPIO_ZVPORT                       0
+#define GPIO_MUX_14_TEST_DATA                         1
+#define GPIO_MUX_13                                   13:13
+#define GPIO_MUX_13_GPIO_ZVPORT                       0
+#define GPIO_MUX_13_TEST_DATA                         1
+#define GPIO_MUX_12                                   12:12
+#define GPIO_MUX_12_GPIO_ZVPORT                       0
+#define GPIO_MUX_12_TEST_DATA                         1
+#define GPIO_MUX_11                                   11:11
+#define GPIO_MUX_11_GPIO_ZVPORT                       0
+#define GPIO_MUX_11_TEST_DATA                         1
+#define GPIO_MUX_10                                   10:10
+#define GPIO_MUX_10_GPIO_ZVPORT                       0
+#define GPIO_MUX_10_TEST_DATA                         1
+#define GPIO_MUX_9                                    9:9
+#define GPIO_MUX_9_GPIO_ZVPORT                        0
+#define GPIO_MUX_9_TEST_DATA                          1
+#define GPIO_MUX_8                                    8:8
+#define GPIO_MUX_8_GPIO_ZVPORT                        0
+#define GPIO_MUX_8_TEST_DATA                          1
+#define GPIO_MUX_7                                    7:7
+#define GPIO_MUX_7_GPIO_ZVPORT                        0
+#define GPIO_MUX_7_TEST_DATA                          1
+#define GPIO_MUX_6                                    6:6
+#define GPIO_MUX_6_GPIO_ZVPORT                        0
+#define GPIO_MUX_6_TEST_DATA                          1
+#define GPIO_MUX_5                                    5:5
+#define GPIO_MUX_5_GPIO_ZVPORT                        0
+#define GPIO_MUX_5_TEST_DATA                          1
+#define GPIO_MUX_4                                    4:4
+#define GPIO_MUX_4_GPIO_ZVPORT                        0
+#define GPIO_MUX_4_TEST_DATA                          1
+#define GPIO_MUX_3                                    3:3
+#define GPIO_MUX_3_GPIO_ZVPORT                        0
+#define GPIO_MUX_3_TEST_DATA                          1
+#define GPIO_MUX_2                                    2:2
+#define GPIO_MUX_2_GPIO_ZVPORT                        0
+#define GPIO_MUX_2_TEST_DATA                          1
+#define GPIO_MUX_1                                    1:1
+#define GPIO_MUX_1_GPIO_ZVPORT                        0
+#define GPIO_MUX_1_TEST_DATA                          1
+#define GPIO_MUX_0                                    0:0
+#define GPIO_MUX_0_GPIO_ZVPORT                        0
+#define GPIO_MUX_0_TEST_DATA                          1
+
+#define LOCALMEM_ARBITRATION                          0x00000C
+#define LOCALMEM_ARBITRATION_ROTATE                   28:28
+#define LOCALMEM_ARBITRATION_ROTATE_OFF               0
+#define LOCALMEM_ARBITRATION_ROTATE_ON                1
+#define LOCALMEM_ARBITRATION_VGA                      26:24
+#define LOCALMEM_ARBITRATION_VGA_OFF                  0
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_1           1
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_2           2
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_3           3
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_4           4
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_5           5
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_6           6
+#define LOCALMEM_ARBITRATION_VGA_PRIORITY_7           7
+#define LOCALMEM_ARBITRATION_DMA                      22:20
+#define LOCALMEM_ARBITRATION_DMA_OFF                  0
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_1           1
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_2           2
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_3           3
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_4           4
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_5           5
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_6           6
+#define LOCALMEM_ARBITRATION_DMA_PRIORITY_7           7
+#define LOCALMEM_ARBITRATION_ZVPORT1                  18:16
+#define LOCALMEM_ARBITRATION_ZVPORT1_OFF              0
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_1       1
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_2       2
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_3       3
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_4       4
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_5       5
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_6       6
+#define LOCALMEM_ARBITRATION_ZVPORT1_PRIORITY_7       7
+#define LOCALMEM_ARBITRATION_ZVPORT0                  14:12
+#define LOCALMEM_ARBITRATION_ZVPORT0_OFF              0
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_1       1
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_2       2
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_3       3
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_4       4
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_5       5
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_6       6
+#define LOCALMEM_ARBITRATION_ZVPORT0_PRIORITY_7       7
+#define LOCALMEM_ARBITRATION_VIDEO                    10:8
+#define LOCALMEM_ARBITRATION_VIDEO_OFF                0
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_1         1
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_2         2
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_3         3
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_4         4
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_5         5
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_6         6
+#define LOCALMEM_ARBITRATION_VIDEO_PRIORITY_7         7
+#define LOCALMEM_ARBITRATION_PANEL                    6:4
+#define LOCALMEM_ARBITRATION_PANEL_OFF                0
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_1         1
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_2         2
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_3         3
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_4         4
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_5         5
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_6         6
+#define LOCALMEM_ARBITRATION_PANEL_PRIORITY_7         7
+#define LOCALMEM_ARBITRATION_CRT                      2:0
+#define LOCALMEM_ARBITRATION_CRT_OFF                  0
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_1           1
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_2           2
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_3           3
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_4           4
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_5           5
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_6           6
+#define LOCALMEM_ARBITRATION_CRT_PRIORITY_7           7
+
+#define PCIMEM_ARBITRATION                            0x000010
+#define PCIMEM_ARBITRATION_ROTATE                     28:28
+#define PCIMEM_ARBITRATION_ROTATE_OFF                 0
+#define PCIMEM_ARBITRATION_ROTATE_ON                  1
+#define PCIMEM_ARBITRATION_VGA                        26:24
+#define PCIMEM_ARBITRATION_VGA_OFF                    0
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_1             1
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_2             2
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_3             3
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_4             4
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_5             5
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_6             6
+#define PCIMEM_ARBITRATION_VGA_PRIORITY_7             7
+#define PCIMEM_ARBITRATION_DMA                        22:20
+#define PCIMEM_ARBITRATION_DMA_OFF                    0
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_1             1
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_2             2
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_3             3
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_4             4
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_5             5
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_6             6
+#define PCIMEM_ARBITRATION_DMA_PRIORITY_7             7
+#define PCIMEM_ARBITRATION_ZVPORT1                    18:16
+#define PCIMEM_ARBITRATION_ZVPORT1_OFF                0
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_1         1
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_2         2
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_3         3
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_4         4
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_5         5
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_6         6
+#define PCIMEM_ARBITRATION_ZVPORT1_PRIORITY_7         7
+#define PCIMEM_ARBITRATION_ZVPORT0                    14:12
+#define PCIMEM_ARBITRATION_ZVPORT0_OFF                0
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_1         1
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_2         2
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_3         3
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_4         4
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_5         5
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_6         6
+#define PCIMEM_ARBITRATION_ZVPORT0_PRIORITY_7         7
+#define PCIMEM_ARBITRATION_VIDEO                      10:8
+#define PCIMEM_ARBITRATION_VIDEO_OFF                  0
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_1           1
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_2           2
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_3           3
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_4           4
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_5           5
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_6           6
+#define PCIMEM_ARBITRATION_VIDEO_PRIORITY_7           7
+#define PCIMEM_ARBITRATION_PANEL                      6:4
+#define PCIMEM_ARBITRATION_PANEL_OFF                  0
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_1           1
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_2           2
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_3           3
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_4           4
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_5           5
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_6           6
+#define PCIMEM_ARBITRATION_PANEL_PRIORITY_7           7
+#define PCIMEM_ARBITRATION_CRT                        2:0
+#define PCIMEM_ARBITRATION_CRT_OFF                    0
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_1             1
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_2             2
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_3             3
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_4             4
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_5             5
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_6             6
+#define PCIMEM_ARBITRATION_CRT_PRIORITY_7             7
+
+#define RAW_INT                                       0x000020
+#define RAW_INT_ZVPORT1_VSYNC                         4:4
+#define RAW_INT_ZVPORT1_VSYNC_INACTIVE                0
+#define RAW_INT_ZVPORT1_VSYNC_ACTIVE                  1
+#define RAW_INT_ZVPORT1_VSYNC_CLEAR                   1
+#define RAW_INT_ZVPORT0_VSYNC                         3:3
+#define RAW_INT_ZVPORT0_VSYNC_INACTIVE                0
+#define RAW_INT_ZVPORT0_VSYNC_ACTIVE                  1
+#define RAW_INT_ZVPORT0_VSYNC_CLEAR                   1
+#define RAW_INT_CRT_VSYNC                             2:2
+#define RAW_INT_CRT_VSYNC_INACTIVE                    0
+#define RAW_INT_CRT_VSYNC_ACTIVE                      1
+#define RAW_INT_CRT_VSYNC_CLEAR                       1
+#define RAW_INT_PANEL_VSYNC                           1:1
+#define RAW_INT_PANEL_VSYNC_INACTIVE                  0
+#define RAW_INT_PANEL_VSYNC_ACTIVE                    1
+#define RAW_INT_PANEL_VSYNC_CLEAR                     1
+#define RAW_INT_VGA_VSYNC                             0:0
+#define RAW_INT_VGA_VSYNC_INACTIVE                    0
+#define RAW_INT_VGA_VSYNC_ACTIVE                      1
+#define RAW_INT_VGA_VSYNC_CLEAR                       1
+
+#define INT_STATUS                                    0x000024
+#define INT_STATUS_GPIO31                             31:31
+#define INT_STATUS_GPIO31_INACTIVE                    0
+#define INT_STATUS_GPIO31_ACTIVE                      1
+#define INT_STATUS_GPIO30                             30:30
+#define INT_STATUS_GPIO30_INACTIVE                    0
+#define INT_STATUS_GPIO30_ACTIVE                      1
+#define INT_STATUS_GPIO29                             29:29
+#define INT_STATUS_GPIO29_INACTIVE                    0
+#define INT_STATUS_GPIO29_ACTIVE                      1
+#define INT_STATUS_GPIO28                             28:28
+#define INT_STATUS_GPIO28_INACTIVE                    0
+#define INT_STATUS_GPIO28_ACTIVE                      1
+#define INT_STATUS_GPIO27                             27:27
+#define INT_STATUS_GPIO27_INACTIVE                    0
+#define INT_STATUS_GPIO27_ACTIVE                      1
+#define INT_STATUS_GPIO26                             26:26
+#define INT_STATUS_GPIO26_INACTIVE                    0
+#define INT_STATUS_GPIO26_ACTIVE                      1
+#define INT_STATUS_GPIO25                             25:25
+#define INT_STATUS_GPIO25_INACTIVE                    0
+#define INT_STATUS_GPIO25_ACTIVE                      1
+#define INT_STATUS_I2C                                12:12
+#define INT_STATUS_I2C_INACTIVE                       0
+#define INT_STATUS_I2C_ACTIVE                         1
+#define INT_STATUS_PWM                                11:11
+#define INT_STATUS_PWM_INACTIVE                       0
+#define INT_STATUS_PWM_ACTIVE                         1
+#define INT_STATUS_DMA1                               10:10
+#define INT_STATUS_DMA1_INACTIVE                      0
+#define INT_STATUS_DMA1_ACTIVE                        1
+#define INT_STATUS_DMA0                               9:9
+#define INT_STATUS_DMA0_INACTIVE                      0
+#define INT_STATUS_DMA0_ACTIVE                        1
+#define INT_STATUS_PCI                                8:8
+#define INT_STATUS_PCI_INACTIVE                       0
+#define INT_STATUS_PCI_ACTIVE                         1
+#define INT_STATUS_SSP1                               7:7
+#define INT_STATUS_SSP1_INACTIVE                      0
+#define INT_STATUS_SSP1_ACTIVE                        1
+#define INT_STATUS_SSP0                               6:6
+#define INT_STATUS_SSP0_INACTIVE                      0
+#define INT_STATUS_SSP0_ACTIVE                        1
+#define INT_STATUS_DE                                 5:5
+#define INT_STATUS_DE_INACTIVE                        0
+#define INT_STATUS_DE_ACTIVE                          1
+#define INT_STATUS_ZVPORT1_VSYNC                      4:4
+#define INT_STATUS_ZVPORT1_VSYNC_INACTIVE             0
+#define INT_STATUS_ZVPORT1_VSYNC_ACTIVE               1
+#define INT_STATUS_ZVPORT0_VSYNC                      3:3
+#define INT_STATUS_ZVPORT0_VSYNC_INACTIVE             0
+#define INT_STATUS_ZVPORT0_VSYNC_ACTIVE               1
+#define INT_STATUS_CRT_VSYNC                          2:2
+#define INT_STATUS_CRT_VSYNC_INACTIVE                 0
+#define INT_STATUS_CRT_VSYNC_ACTIVE                   1
+#define INT_STATUS_PANEL_VSYNC                        1:1
+#define INT_STATUS_PANEL_VSYNC_INACTIVE               0
+#define INT_STATUS_PANEL_VSYNC_ACTIVE                 1
+#define INT_STATUS_VGA_VSYNC                          0:0
+#define INT_STATUS_VGA_VSYNC_INACTIVE                 0
+#define INT_STATUS_VGA_VSYNC_ACTIVE                   1
+
+#define INT_MASK                                      0x000028
+#define INT_MASK_GPIO31                               31:31
+#define INT_MASK_GPIO31_DISABLE                       0
+#define INT_MASK_GPIO31_ENABLE                        1
+#define INT_MASK_GPIO30                               30:30
+#define INT_MASK_GPIO30_DISABLE                       0
+#define INT_MASK_GPIO30_ENABLE                        1
+#define INT_MASK_GPIO29                               29:29
+#define INT_MASK_GPIO29_DISABLE                       0
+#define INT_MASK_GPIO29_ENABLE                        1
+#define INT_MASK_GPIO28                               28:28
+#define INT_MASK_GPIO28_DISABLE                       0
+#define INT_MASK_GPIO28_ENABLE                        1
+#define INT_MASK_GPIO27                               27:27
+#define INT_MASK_GPIO27_DISABLE                       0
+#define INT_MASK_GPIO27_ENABLE                        1
+#define INT_MASK_GPIO26                               26:26
+#define INT_MASK_GPIO26_DISABLE                       0
+#define INT_MASK_GPIO26_ENABLE                        1
+#define INT_MASK_GPIO25                               25:25
+#define INT_MASK_GPIO25_DISABLE                       0
+#define INT_MASK_GPIO25_ENABLE                        1
+#define INT_MASK_I2C                                  12:12
+#define INT_MASK_I2C_DISABLE                          0
+#define INT_MASK_I2C_ENABLE                           1
+#define INT_MASK_PWM                                  11:11
+#define INT_MASK_PWM_DISABLE                          0
+#define INT_MASK_PWM_ENABLE                           1
+#define INT_MASK_DMA1                                 10:10
+#define INT_MASK_DMA1_DISABLE                         0
+#define INT_MASK_DMA1_ENABLE                          1
+#define INT_MASK_DMA                                  9:9
+#define INT_MASK_DMA_DISABLE                          0
+#define INT_MASK_DMA_ENABLE                           1
+#define INT_MASK_PCI                                  8:8
+#define INT_MASK_PCI_DISABLE                          0
+#define INT_MASK_PCI_ENABLE                           1
+#define INT_MASK_SSP1                                 7:7
+#define INT_MASK_SSP1_DISABLE                         0
+#define INT_MASK_SSP1_ENABLE                          1
+#define INT_MASK_SSP0                                 6:6
+#define INT_MASK_SSP0_DISABLE                         0
+#define INT_MASK_SSP0_ENABLE                          1
+#define INT_MASK_DE                                   5:5
+#define INT_MASK_DE_DISABLE                           0
+#define INT_MASK_DE_ENABLE                            1
+#define INT_MASK_ZVPORT1_VSYNC                        4:4
+#define INT_MASK_ZVPORT1_VSYNC_DISABLE                0
+#define INT_MASK_ZVPORT1_VSYNC_ENABLE                 1
+#define INT_MASK_ZVPORT0_VSYNC                        3:3
+#define INT_MASK_ZVPORT0_VSYNC_DISABLE                0
+#define INT_MASK_ZVPORT0_VSYNC_ENABLE                 1
+#define INT_MASK_CRT_VSYNC                            2:2
+#define INT_MASK_CRT_VSYNC_DISABLE                    0
+#define INT_MASK_CRT_VSYNC_ENABLE                     1
+#define INT_MASK_PANEL_VSYNC                          1:1
+#define INT_MASK_PANEL_VSYNC_DISABLE                  0
+#define INT_MASK_PANEL_VSYNC_ENABLE                   1
+#define INT_MASK_VGA_VSYNC                            0:0
+#define INT_MASK_VGA_VSYNC_DISABLE                    0
+#define INT_MASK_VGA_VSYNC_ENABLE                     1
+
+#define CURRENT_GATE                                  0x000040
+#define CURRENT_GATE_MCLK                             15:14
+#ifdef VALIDATION_CHIP
+    #define CURRENT_GATE_MCLK_112MHZ                      0
+    #define CURRENT_GATE_MCLK_84MHZ                       1
+    #define CURRENT_GATE_MCLK_56MHZ                       2
+    #define CURRENT_GATE_MCLK_42MHZ                       3
+#else
+    #define CURRENT_GATE_MCLK_DIV_3                       0
+    #define CURRENT_GATE_MCLK_DIV_4                       1
+    #define CURRENT_GATE_MCLK_DIV_6                       2
+    #define CURRENT_GATE_MCLK_DIV_8                       3
+#endif
+#define CURRENT_GATE_M2XCLK                           13:12
+#ifdef VALIDATION_CHIP
+    #define CURRENT_GATE_M2XCLK_336MHZ                    0
+    #define CURRENT_GATE_M2XCLK_168MHZ                    1
+    #define CURRENT_GATE_M2XCLK_112MHZ                    2
+    #define CURRENT_GATE_M2XCLK_84MHZ                     3
+#else
+    #define CURRENT_GATE_M2XCLK_DIV_1                     0
+    #define CURRENT_GATE_M2XCLK_DIV_2                     1
+    #define CURRENT_GATE_M2XCLK_DIV_3                     2
+    #define CURRENT_GATE_M2XCLK_DIV_4                     3
+#endif
+#define CURRENT_GATE_VGA                              10:10
+#define CURRENT_GATE_VGA_OFF                          0
+#define CURRENT_GATE_VGA_ON                           1
+#define CURRENT_GATE_PWM                              9:9
+#define CURRENT_GATE_PWM_OFF                          0
+#define CURRENT_GATE_PWM_ON                           1
+#define CURRENT_GATE_I2C                              8:8
+#define CURRENT_GATE_I2C_OFF                          0
+#define CURRENT_GATE_I2C_ON                           1
+#define CURRENT_GATE_SSP                              7:7
+#define CURRENT_GATE_SSP_OFF                          0
+#define CURRENT_GATE_SSP_ON                           1
+#define CURRENT_GATE_GPIO                             6:6
+#define CURRENT_GATE_GPIO_OFF                         0
+#define CURRENT_GATE_GPIO_ON                          1
+#define CURRENT_GATE_ZVPORT                           5:5
+#define CURRENT_GATE_ZVPORT_OFF                       0
+#define CURRENT_GATE_ZVPORT_ON                        1
+#define CURRENT_GATE_CSC                              4:4
+#define CURRENT_GATE_CSC_OFF                          0
+#define CURRENT_GATE_CSC_ON                           1
+#define CURRENT_GATE_DE                               3:3
+#define CURRENT_GATE_DE_OFF                           0
+#define CURRENT_GATE_DE_ON                            1
+#define CURRENT_GATE_DISPLAY                          2:2
+#define CURRENT_GATE_DISPLAY_OFF                      0
+#define CURRENT_GATE_DISPLAY_ON                       1
+#define CURRENT_GATE_LOCALMEM                         1:1
+#define CURRENT_GATE_LOCALMEM_OFF                     0
+#define CURRENT_GATE_LOCALMEM_ON                      1
+#define CURRENT_GATE_DMA                              0:0
+#define CURRENT_GATE_DMA_OFF                          0
+#define CURRENT_GATE_DMA_ON                           1
+
+#define MODE0_GATE                                    0x000044
+#define MODE0_GATE_MCLK                               15:14
+#define MODE0_GATE_MCLK_112MHZ                        0
+#define MODE0_GATE_MCLK_84MHZ                         1
+#define MODE0_GATE_MCLK_56MHZ                         2
+#define MODE0_GATE_MCLK_42MHZ                         3
+#define MODE0_GATE_M2XCLK                             13:12
+#define MODE0_GATE_M2XCLK_336MHZ                      0
+#define MODE0_GATE_M2XCLK_168MHZ                      1
+#define MODE0_GATE_M2XCLK_112MHZ                      2
+#define MODE0_GATE_M2XCLK_84MHZ                       3
+#define MODE0_GATE_VGA                                10:10
+#define MODE0_GATE_VGA_OFF                            0
+#define MODE0_GATE_VGA_ON                             1
+#define MODE0_GATE_PWM                                9:9
+#define MODE0_GATE_PWM_OFF                            0
+#define MODE0_GATE_PWM_ON                             1
+#define MODE0_GATE_I2C                                8:8
+#define MODE0_GATE_I2C_OFF                            0
+#define MODE0_GATE_I2C_ON                             1
+#define MODE0_GATE_SSP                                7:7
+#define MODE0_GATE_SSP_OFF                            0
+#define MODE0_GATE_SSP_ON                             1
+#define MODE0_GATE_GPIO                               6:6
+#define MODE0_GATE_GPIO_OFF                           0
+#define MODE0_GATE_GPIO_ON                            1
+#define MODE0_GATE_ZVPORT                             5:5
+#define MODE0_GATE_ZVPORT_OFF                         0
+#define MODE0_GATE_ZVPORT_ON                          1
+#define MODE0_GATE_CSC                                4:4
+#define MODE0_GATE_CSC_OFF                            0
+#define MODE0_GATE_CSC_ON                             1
+#define MODE0_GATE_DE                                 3:3
+#define MODE0_GATE_DE_OFF                             0
+#define MODE0_GATE_DE_ON                              1
+#define MODE0_GATE_DISPLAY                            2:2
+#define MODE0_GATE_DISPLAY_OFF                        0
+#define MODE0_GATE_DISPLAY_ON                         1
+#define MODE0_GATE_LOCALMEM                           1:1
+#define MODE0_GATE_LOCALMEM_OFF                       0
+#define MODE0_GATE_LOCALMEM_ON                        1
+#define MODE0_GATE_DMA                                0:0
+#define MODE0_GATE_DMA_OFF                            0
+#define MODE0_GATE_DMA_ON                             1
+
+#define MODE1_GATE                                    0x000048
+#define MODE1_GATE_MCLK                               15:14
+#define MODE1_GATE_MCLK_112MHZ                        0
+#define MODE1_GATE_MCLK_84MHZ                         1
+#define MODE1_GATE_MCLK_56MHZ                         2
+#define MODE1_GATE_MCLK_42MHZ                         3
+#define MODE1_GATE_M2XCLK                             13:12
+#define MODE1_GATE_M2XCLK_336MHZ                      0
+#define MODE1_GATE_M2XCLK_168MHZ                      1
+#define MODE1_GATE_M2XCLK_112MHZ                      2
+#define MODE1_GATE_M2XCLK_84MHZ                       3
+#define MODE1_GATE_VGA                                10:10
+#define MODE1_GATE_VGA_OFF                            0
+#define MODE1_GATE_VGA_ON                             1
+#define MODE1_GATE_PWM                                9:9
+#define MODE1_GATE_PWM_OFF                            0
+#define MODE1_GATE_PWM_ON                             1
+#define MODE1_GATE_I2C                                8:8
+#define MODE1_GATE_I2C_OFF                            0
+#define MODE1_GATE_I2C_ON                             1
+#define MODE1_GATE_SSP                                7:7
+#define MODE1_GATE_SSP_OFF                            0
+#define MODE1_GATE_SSP_ON                             1
+#define MODE1_GATE_GPIO                               6:6
+#define MODE1_GATE_GPIO_OFF                           0
+#define MODE1_GATE_GPIO_ON                            1
+#define MODE1_GATE_ZVPORT                             5:5
+#define MODE1_GATE_ZVPORT_OFF                         0
+#define MODE1_GATE_ZVPORT_ON                          1
+#define MODE1_GATE_CSC                                4:4
+#define MODE1_GATE_CSC_OFF                            0
+#define MODE1_GATE_CSC_ON                             1
+#define MODE1_GATE_DE                                 3:3
+#define MODE1_GATE_DE_OFF                             0
+#define MODE1_GATE_DE_ON                              1
+#define MODE1_GATE_DISPLAY                            2:2
+#define MODE1_GATE_DISPLAY_OFF                        0
+#define MODE1_GATE_DISPLAY_ON                         1
+#define MODE1_GATE_LOCALMEM                           1:1
+#define MODE1_GATE_LOCALMEM_OFF                       0
+#define MODE1_GATE_LOCALMEM_ON                        1
+#define MODE1_GATE_DMA                                0:0
+#define MODE1_GATE_DMA_OFF                            0
+#define MODE1_GATE_DMA_ON                             1
+
+#define POWER_MODE_CTRL                               0x00004C
+#ifdef VALIDATION_CHIP
+    #define POWER_MODE_CTRL_336CLK                    4:4
+    #define POWER_MODE_CTRL_336CLK_OFF                0
+    #define POWER_MODE_CTRL_336CLK_ON                 1
+#endif
+#define POWER_MODE_CTRL_OSC_INPUT                     3:3
+#define POWER_MODE_CTRL_OSC_INPUT_OFF                 0
+#define POWER_MODE_CTRL_OSC_INPUT_ON                  1
+#define POWER_MODE_CTRL_ACPI                          2:2
+#define POWER_MODE_CTRL_ACPI_OFF                      0
+#define POWER_MODE_CTRL_ACPI_ON                       1
+#define POWER_MODE_CTRL_MODE                          1:0
+#define POWER_MODE_CTRL_MODE_MODE0                    0
+#define POWER_MODE_CTRL_MODE_MODE1                    1
+#define POWER_MODE_CTRL_MODE_SLEEP                    2
+
+#define PCI_MASTER_BASE                               0x000050
+#define PCI_MASTER_BASE_ADDRESS                       7:0
+
+#define DEVICE_ID                                     0x000054
+#define DEVICE_ID_DEVICE_ID                           31:16
+#define DEVICE_ID_REVISION_ID                         7:0
+
+#define PLL_CLK_COUNT                                 0x000058
+#define PLL_CLK_COUNT_COUNTER                         15:0
+
+#define PANEL_PLL_CTRL                                0x00005C
+#define PANEL_PLL_CTRL_BYPASS                         18:18
+#define PANEL_PLL_CTRL_BYPASS_OFF                     0
+#define PANEL_PLL_CTRL_BYPASS_ON                      1
+#define PANEL_PLL_CTRL_POWER                          17:17
+#define PANEL_PLL_CTRL_POWER_OFF                      0
+#define PANEL_PLL_CTRL_POWER_ON                       1
+#define PANEL_PLL_CTRL_INPUT                          16:16
+#define PANEL_PLL_CTRL_INPUT_OSC                      0
+#define PANEL_PLL_CTRL_INPUT_TESTCLK                  1
+#ifdef VALIDATION_CHIP
+    #define PANEL_PLL_CTRL_OD                         15:14
+#else
+    #define PANEL_PLL_CTRL_POD                        15:14
+    #define PANEL_PLL_CTRL_OD                         13:12
+#endif
+#define PANEL_PLL_CTRL_N                              11:8
+#define PANEL_PLL_CTRL_M                              7:0
+
+#define CRT_PLL_CTRL                                  0x000060
+#define CRT_PLL_CTRL_BYPASS                           18:18
+#define CRT_PLL_CTRL_BYPASS_OFF                       0
+#define CRT_PLL_CTRL_BYPASS_ON                        1
+#define CRT_PLL_CTRL_POWER                            17:17
+#define CRT_PLL_CTRL_POWER_OFF                        0
+#define CRT_PLL_CTRL_POWER_ON                         1
+#define CRT_PLL_CTRL_INPUT                            16:16
+#define CRT_PLL_CTRL_INPUT_OSC                        0
+#define CRT_PLL_CTRL_INPUT_TESTCLK                    1
+#ifdef VALIDATION_CHIP
+    #define CRT_PLL_CTRL_OD                           15:14
+#else
+    #define CRT_PLL_CTRL_POD                          15:14
+    #define CRT_PLL_CTRL_OD                           13:12
+#endif
+#define CRT_PLL_CTRL_N                                11:8
+#define CRT_PLL_CTRL_M                                7:0
+
+#define VGA_PLL0_CTRL                                 0x000064
+#define VGA_PLL0_CTRL_BYPASS                          18:18
+#define VGA_PLL0_CTRL_BYPASS_OFF                      0
+#define VGA_PLL0_CTRL_BYPASS_ON                       1
+#define VGA_PLL0_CTRL_POWER                           17:17
+#define VGA_PLL0_CTRL_POWER_OFF                       0
+#define VGA_PLL0_CTRL_POWER_ON                        1
+#define VGA_PLL0_CTRL_INPUT                           16:16
+#define VGA_PLL0_CTRL_INPUT_OSC                       0
+#define VGA_PLL0_CTRL_INPUT_TESTCLK                   1
+#ifdef VALIDATION_CHIP
+    #define VGA_PLL0_CTRL_OD                          15:14
+#else
+    #define VGA_PLL0_CTRL_POD                         15:14
+    #define VGA_PLL0_CTRL_OD                          13:12
+#endif
+#define VGA_PLL0_CTRL_N                               11:8
+#define VGA_PLL0_CTRL_M                               7:0
+
+#define VGA_PLL1_CTRL                                 0x000068
+#define VGA_PLL1_CTRL_BYPASS                          18:18
+#define VGA_PLL1_CTRL_BYPASS_OFF                      0
+#define VGA_PLL1_CTRL_BYPASS_ON                       1
+#define VGA_PLL1_CTRL_POWER                           17:17
+#define VGA_PLL1_CTRL_POWER_OFF                       0
+#define VGA_PLL1_CTRL_POWER_ON                        1
+#define VGA_PLL1_CTRL_INPUT                           16:16
+#define VGA_PLL1_CTRL_INPUT_OSC                       0
+#define VGA_PLL1_CTRL_INPUT_TESTCLK                   1
+#ifdef VALIDATION_CHIP
+    #define VGA_PLL1_CTRL_OD                          15:14
+#else
+    #define VGA_PLL1_CTRL_POD                         15:14
+    #define VGA_PLL1_CTRL_OD                          13:12
+#endif
+#define VGA_PLL1_CTRL_N                               11:8
+#define VGA_PLL1_CTRL_M                               7:0
+
+#define SCRATCH_DATA                                  0x00006c
+
+#ifndef VALIDATION_CHIP
+
+#define MXCLK_PLL_CTRL                                0x000070
+#define MXCLK_PLL_CTRL_BYPASS                         18:18
+#define MXCLK_PLL_CTRL_BYPASS_OFF                     0
+#define MXCLK_PLL_CTRL_BYPASS_ON                      1
+#define MXCLK_PLL_CTRL_POWER                          17:17
+#define MXCLK_PLL_CTRL_POWER_OFF                      0
+#define MXCLK_PLL_CTRL_POWER_ON                       1
+#define MXCLK_PLL_CTRL_INPUT                          16:16
+#define MXCLK_PLL_CTRL_INPUT_OSC                      0
+#define MXCLK_PLL_CTRL_INPUT_TESTCLK                  1
+#define MXCLK_PLL_CTRL_POD                            15:14
+#define MXCLK_PLL_CTRL_OD                             13:12
+#define MXCLK_PLL_CTRL_N                              11:8
+#define MXCLK_PLL_CTRL_M                              7:0
+
+#define VGA_CONFIGURATION                             0x000088
+#define VGA_CONFIGURATION_USER_DEFINE                 5:4
+#define VGA_CONFIGURATION_PLL                         2:2
+#define VGA_CONFIGURATION_PLL_VGA                     0
+#define VGA_CONFIGURATION_PLL_PANEL                   1
+#define VGA_CONFIGURATION_MODE                        1:1
+#define VGA_CONFIGURATION_MODE_TEXT                   0
+#define VGA_CONFIGURATION_MODE_GRAPHIC                1
+
+#endif
+
+#define GPIO_DATA                                       0x010000
+#define GPIO_DATA_31                                    31:31
+#define GPIO_DATA_30                                    30:30
+#define GPIO_DATA_29                                    29:29
+#define GPIO_DATA_28                                    28:28
+#define GPIO_DATA_27                                    27:27
+#define GPIO_DATA_26                                    26:26
+#define GPIO_DATA_25                                    25:25
+#define GPIO_DATA_24                                    24:24
+#define GPIO_DATA_23                                    23:23
+#define GPIO_DATA_22                                    22:22
+#define GPIO_DATA_21                                    21:21
+#define GPIO_DATA_20                                    20:20
+#define GPIO_DATA_19                                    19:19
+#define GPIO_DATA_18                                    18:18
+#define GPIO_DATA_17                                    17:17
+#define GPIO_DATA_16                                    16:16
+#define GPIO_DATA_15                                    15:15
+#define GPIO_DATA_14                                    14:14
+#define GPIO_DATA_13                                    13:13
+#define GPIO_DATA_12                                    12:12
+#define GPIO_DATA_11                                    11:11
+#define GPIO_DATA_10                                    10:10
+#define GPIO_DATA_9                                     9:9
+#define GPIO_DATA_8                                     8:8
+#define GPIO_DATA_7                                     7:7
+#define GPIO_DATA_6                                     6:6
+#define GPIO_DATA_5                                     5:5
+#define GPIO_DATA_4                                     4:4
+#define GPIO_DATA_3                                     3:3
+#define GPIO_DATA_2                                     2:2
+#define GPIO_DATA_1                                     1:1
+#define GPIO_DATA_0                                     0:0
+
+#define GPIO_DATA_DIRECTION                             0x010004
+#define GPIO_DATA_DIRECTION_31                          31:31
+#define GPIO_DATA_DIRECTION_31_INPUT                    0
+#define GPIO_DATA_DIRECTION_31_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_30                          30:30
+#define GPIO_DATA_DIRECTION_30_INPUT                    0
+#define GPIO_DATA_DIRECTION_30_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_29                          29:29
+#define GPIO_DATA_DIRECTION_29_INPUT                    0
+#define GPIO_DATA_DIRECTION_29_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_28                          28:28
+#define GPIO_DATA_DIRECTION_28_INPUT                    0
+#define GPIO_DATA_DIRECTION_28_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_27                          27:27
+#define GPIO_DATA_DIRECTION_27_INPUT                    0
+#define GPIO_DATA_DIRECTION_27_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_26                          26:26
+#define GPIO_DATA_DIRECTION_26_INPUT                    0
+#define GPIO_DATA_DIRECTION_26_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_25                          25:25
+#define GPIO_DATA_DIRECTION_25_INPUT                    0
+#define GPIO_DATA_DIRECTION_25_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_24                          24:24
+#define GPIO_DATA_DIRECTION_24_INPUT                    0
+#define GPIO_DATA_DIRECTION_24_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_23                          23:23
+#define GPIO_DATA_DIRECTION_23_INPUT                    0
+#define GPIO_DATA_DIRECTION_23_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_22                          22:22
+#define GPIO_DATA_DIRECTION_22_INPUT                    0
+#define GPIO_DATA_DIRECTION_22_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_21                          21:21
+#define GPIO_DATA_DIRECTION_21_INPUT                    0
+#define GPIO_DATA_DIRECTION_21_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_20                          20:20
+#define GPIO_DATA_DIRECTION_20_INPUT                    0
+#define GPIO_DATA_DIRECTION_20_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_19                          19:19
+#define GPIO_DATA_DIRECTION_19_INPUT                    0
+#define GPIO_DATA_DIRECTION_19_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_18                          18:18
+#define GPIO_DATA_DIRECTION_18_INPUT                    0
+#define GPIO_DATA_DIRECTION_18_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_17                          17:17
+#define GPIO_DATA_DIRECTION_17_INPUT                    0
+#define GPIO_DATA_DIRECTION_17_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_16                          16:16
+#define GPIO_DATA_DIRECTION_16_INPUT                    0
+#define GPIO_DATA_DIRECTION_16_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_15                          15:15
+#define GPIO_DATA_DIRECTION_15_INPUT                    0
+#define GPIO_DATA_DIRECTION_15_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_14                          14:14
+#define GPIO_DATA_DIRECTION_14_INPUT                    0
+#define GPIO_DATA_DIRECTION_14_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_13                          13:13
+#define GPIO_DATA_DIRECTION_13_INPUT                    0
+#define GPIO_DATA_DIRECTION_13_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_12                          12:12
+#define GPIO_DATA_DIRECTION_12_INPUT                    0
+#define GPIO_DATA_DIRECTION_12_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_11                          11:11
+#define GPIO_DATA_DIRECTION_11_INPUT                    0
+#define GPIO_DATA_DIRECTION_11_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_10                          10:10
+#define GPIO_DATA_DIRECTION_10_INPUT                    0
+#define GPIO_DATA_DIRECTION_10_OUTPUT                   1
+#define GPIO_DATA_DIRECTION_9                           9:9
+#define GPIO_DATA_DIRECTION_9_INPUT                     0
+#define GPIO_DATA_DIRECTION_9_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_8                           8:8
+#define GPIO_DATA_DIRECTION_8_INPUT                     0
+#define GPIO_DATA_DIRECTION_8_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_7                           7:7
+#define GPIO_DATA_DIRECTION_7_INPUT                     0
+#define GPIO_DATA_DIRECTION_7_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_6                           6:6
+#define GPIO_DATA_DIRECTION_6_INPUT                     0
+#define GPIO_DATA_DIRECTION_6_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_5                           5:5
+#define GPIO_DATA_DIRECTION_5_INPUT                     0
+#define GPIO_DATA_DIRECTION_5_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_4                           4:4
+#define GPIO_DATA_DIRECTION_4_INPUT                     0
+#define GPIO_DATA_DIRECTION_4_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_3                           3:3
+#define GPIO_DATA_DIRECTION_3_INPUT                     0
+#define GPIO_DATA_DIRECTION_3_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_2                           2:2
+#define GPIO_DATA_DIRECTION_2_INPUT                     0
+#define GPIO_DATA_DIRECTION_2_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_1                           131
+#define GPIO_DATA_DIRECTION_1_INPUT                     0
+#define GPIO_DATA_DIRECTION_1_OUTPUT                    1
+#define GPIO_DATA_DIRECTION_0                           0:0
+#define GPIO_DATA_DIRECTION_0_INPUT                     0
+#define GPIO_DATA_DIRECTION_0_OUTPUT                    1
+
+#define GPIO_INTERRUPT_SETUP                            0x010008
+#define GPIO_INTERRUPT_SETUP_TRIGGER_31                 22:22
+#define GPIO_INTERRUPT_SETUP_TRIGGER_31_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_31_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_30                 21:21
+#define GPIO_INTERRUPT_SETUP_TRIGGER_30_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_30_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_29                 20:20
+#define GPIO_INTERRUPT_SETUP_TRIGGER_29_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_29_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_28                 19:19
+#define GPIO_INTERRUPT_SETUP_TRIGGER_28_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_28_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_27                 18:18
+#define GPIO_INTERRUPT_SETUP_TRIGGER_27_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_27_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_26                 17:17
+#define GPIO_INTERRUPT_SETUP_TRIGGER_26_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_26_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_TRIGGER_25                 16:16
+#define GPIO_INTERRUPT_SETUP_TRIGGER_25_EDGE            0
+#define GPIO_INTERRUPT_SETUP_TRIGGER_25_LEVEL           1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_31                  14:14
+#define GPIO_INTERRUPT_SETUP_ACTIVE_31_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_31_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_30                  13:13
+#define GPIO_INTERRUPT_SETUP_ACTIVE_30_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_30_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_29                  12:12
+#define GPIO_INTERRUPT_SETUP_ACTIVE_29_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_29_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_28                  11:11
+#define GPIO_INTERRUPT_SETUP_ACTIVE_28_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_28_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_27                  10:10
+#define GPIO_INTERRUPT_SETUP_ACTIVE_27_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_27_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_26                  9:9
+#define GPIO_INTERRUPT_SETUP_ACTIVE_26_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_26_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ACTIVE_25                  8:8
+#define GPIO_INTERRUPT_SETUP_ACTIVE_25_LOW              0
+#define GPIO_INTERRUPT_SETUP_ACTIVE_25_HIGH             1
+#define GPIO_INTERRUPT_SETUP_ENABLE_31                  6:6
+#define GPIO_INTERRUPT_SETUP_ENABLE_31_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_31_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_30                  5:5
+#define GPIO_INTERRUPT_SETUP_ENABLE_30_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_30_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_29                  4:4
+#define GPIO_INTERRUPT_SETUP_ENABLE_29_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_29_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_28                  3:3
+#define GPIO_INTERRUPT_SETUP_ENABLE_28_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_28_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_27                  2:2
+#define GPIO_INTERRUPT_SETUP_ENABLE_27_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_27_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_26                  1:1
+#define GPIO_INTERRUPT_SETUP_ENABLE_26_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_26_INTERRUPT        1
+#define GPIO_INTERRUPT_SETUP_ENABLE_25                  0:0
+#define GPIO_INTERRUPT_SETUP_ENABLE_25_GPIO             0
+#define GPIO_INTERRUPT_SETUP_ENABLE_25_INTERRUPT        1
+
+#define GPIO_INTERRUPT_STATUS                           0x01000C
+#define GPIO_INTERRUPT_STATUS_31                        22:22
+#define GPIO_INTERRUPT_STATUS_31_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_31_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_31_RESET                  1
+#define GPIO_INTERRUPT_STATUS_30                        21:21
+#define GPIO_INTERRUPT_STATUS_30_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_30_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_30_RESET                  1
+#define GPIO_INTERRUPT_STATUS_29                        20:20
+#define GPIO_INTERRUPT_STATUS_29_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_29_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_29_RESET                  1
+#define GPIO_INTERRUPT_STATUS_28                        19:19
+#define GPIO_INTERRUPT_STATUS_28_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_28_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_28_RESET                  1
+#define GPIO_INTERRUPT_STATUS_27                        18:18
+#define GPIO_INTERRUPT_STATUS_27_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_27_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_27_RESET                  1
+#define GPIO_INTERRUPT_STATUS_26                        17:17
+#define GPIO_INTERRUPT_STATUS_26_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_26_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_26_RESET                  1
+#define GPIO_INTERRUPT_STATUS_25                        16:16
+#define GPIO_INTERRUPT_STATUS_25_INACTIVE               0
+#define GPIO_INTERRUPT_STATUS_25_ACTIVE                 1
+#define GPIO_INTERRUPT_STATUS_25_RESET                  1
+
+
+#define PANEL_DISPLAY_CTRL                            0x080000
+#define PANEL_DISPLAY_CTRL_RESERVED_1_MASK            31:30
+#define PANEL_DISPLAY_CTRL_RESERVED_1_MASK_DISABLE    0
+#define PANEL_DISPLAY_CTRL_RESERVED_1_MASK_ENABLE     3
+#define PANEL_DISPLAY_CTRL_SELECT                     29:28
+#define PANEL_DISPLAY_CTRL_SELECT_PANEL               0
+#define PANEL_DISPLAY_CTRL_SELECT_VGA                 1
+#define PANEL_DISPLAY_CTRL_SELECT_CRT                 2
+#define PANEL_DISPLAY_CTRL_FPEN                       27:27
+#define PANEL_DISPLAY_CTRL_FPEN_LOW                   0
+#define PANEL_DISPLAY_CTRL_FPEN_HIGH                  1
+#define PANEL_DISPLAY_CTRL_VBIASEN                    26:26
+#define PANEL_DISPLAY_CTRL_VBIASEN_LOW                0
+#define PANEL_DISPLAY_CTRL_VBIASEN_HIGH               1
+#define PANEL_DISPLAY_CTRL_DATA                       25:25
+#define PANEL_DISPLAY_CTRL_DATA_DISABLE               0
+#define PANEL_DISPLAY_CTRL_DATA_ENABLE                1
+#define PANEL_DISPLAY_CTRL_FPVDDEN                    24:24
+#define PANEL_DISPLAY_CTRL_FPVDDEN_LOW                0
+#define PANEL_DISPLAY_CTRL_FPVDDEN_HIGH               1
+#define PANEL_DISPLAY_CTRL_RESERVED_2_MASK            23:20
+#define PANEL_DISPLAY_CTRL_RESERVED_2_MASK_DISABLE    0
+#define PANEL_DISPLAY_CTRL_RESERVED_2_MASK_ENABLE     15
+
+#define PANEL_DISPLAY_CTRL_TFT_DISP 19:18
+#define PANEL_DISPLAY_CTRL_TFT_DISP_24 0
+#define PANEL_DISPLAY_CTRL_TFT_DISP_36 1
+#define PANEL_DISPLAY_CTRL_TFT_DISP_18 2
+
+
+#define PANEL_DISPLAY_CTRL_DUAL_DISPLAY               19:19
+#define PANEL_DISPLAY_CTRL_DUAL_DISPLAY_DISABLE       0
+#define PANEL_DISPLAY_CTRL_DUAL_DISPLAY_ENABLE        1
+#define PANEL_DISPLAY_CTRL_DOUBLE_PIXEL               18:18
+#define PANEL_DISPLAY_CTRL_DOUBLE_PIXEL_DISABLE       0
+#define PANEL_DISPLAY_CTRL_DOUBLE_PIXEL_ENABLE        1
+#define PANEL_DISPLAY_CTRL_FIFO                       17:16
+#define PANEL_DISPLAY_CTRL_FIFO_1                     0
+#define PANEL_DISPLAY_CTRL_FIFO_3                     1
+#define PANEL_DISPLAY_CTRL_FIFO_7                     2
+#define PANEL_DISPLAY_CTRL_FIFO_11                    3
+#define PANEL_DISPLAY_CTRL_RESERVED_3_MASK            15:15
+#define PANEL_DISPLAY_CTRL_RESERVED_3_MASK_DISABLE    0
+#define PANEL_DISPLAY_CTRL_RESERVED_3_MASK_ENABLE     1
+#define PANEL_DISPLAY_CTRL_CLOCK_PHASE                14:14
+#define PANEL_DISPLAY_CTRL_CLOCK_PHASE_ACTIVE_HIGH    0
+#define PANEL_DISPLAY_CTRL_CLOCK_PHASE_ACTIVE_LOW     1
+#define PANEL_DISPLAY_CTRL_VSYNC_PHASE                13:13
+#define PANEL_DISPLAY_CTRL_VSYNC_PHASE_ACTIVE_HIGH    0
+#define PANEL_DISPLAY_CTRL_VSYNC_PHASE_ACTIVE_LOW     1
+#define PANEL_DISPLAY_CTRL_HSYNC_PHASE                12:12
+#define PANEL_DISPLAY_CTRL_HSYNC_PHASE_ACTIVE_HIGH    0
+#define PANEL_DISPLAY_CTRL_HSYNC_PHASE_ACTIVE_LOW     1
+#define PANEL_DISPLAY_CTRL_VSYNC                      11:11
+#define PANEL_DISPLAY_CTRL_VSYNC_ACTIVE_HIGH          0
+#define PANEL_DISPLAY_CTRL_VSYNC_ACTIVE_LOW           1
+#define PANEL_DISPLAY_CTRL_CAPTURE_TIMING             10:10
+#define PANEL_DISPLAY_CTRL_CAPTURE_TIMING_DISABLE     0
+#define PANEL_DISPLAY_CTRL_CAPTURE_TIMING_ENABLE      1
+#define PANEL_DISPLAY_CTRL_COLOR_KEY                  9:9
+#define PANEL_DISPLAY_CTRL_COLOR_KEY_DISABLE          0
+#define PANEL_DISPLAY_CTRL_COLOR_KEY_ENABLE           1
+#define PANEL_DISPLAY_CTRL_TIMING                     8:8
+#define PANEL_DISPLAY_CTRL_TIMING_DISABLE             0
+#define PANEL_DISPLAY_CTRL_TIMING_ENABLE              1
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN_DIR           7:7
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN_DIR_DOWN      0
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN_DIR_UP        1
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN               6:6
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN_DISABLE       0
+#define PANEL_DISPLAY_CTRL_VERTICAL_PAN_ENABLE        1
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN_DIR         5:5
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN_DIR_RIGHT   0
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN_DIR_LEFT    1
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN             4:4
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN_DISABLE     0
+#define PANEL_DISPLAY_CTRL_HORIZONTAL_PAN_ENABLE      1
+#define PANEL_DISPLAY_CTRL_GAMMA                      3:3
+#define PANEL_DISPLAY_CTRL_GAMMA_DISABLE              0
+#define PANEL_DISPLAY_CTRL_GAMMA_ENABLE               1
+#define PANEL_DISPLAY_CTRL_PLANE                      2:2
+#define PANEL_DISPLAY_CTRL_PLANE_DISABLE              0
+#define PANEL_DISPLAY_CTRL_PLANE_ENABLE               1
+#define PANEL_DISPLAY_CTRL_FORMAT                     1:0
+#define PANEL_DISPLAY_CTRL_FORMAT_8                   0
+#define PANEL_DISPLAY_CTRL_FORMAT_16                  1
+#define PANEL_DISPLAY_CTRL_FORMAT_32                  2
+
+#define PANEL_PAN_CTRL                                0x080004
+#define PANEL_PAN_CTRL_VERTICAL_PAN                   31:24
+#define PANEL_PAN_CTRL_VERTICAL_VSYNC                 21:16
+#define PANEL_PAN_CTRL_HORIZONTAL_PAN                 15:8
+#define PANEL_PAN_CTRL_HORIZONTAL_VSYNC               5:0
+
+#define PANEL_COLOR_KEY                               0x080008
+#define PANEL_COLOR_KEY_MASK                          31:16
+#define PANEL_COLOR_KEY_VALUE                         15:0
+
+#define PANEL_FB_ADDRESS                              0x08000C
+#define PANEL_FB_ADDRESS_STATUS                       31:31
+#define PANEL_FB_ADDRESS_STATUS_CURRENT               0
+#define PANEL_FB_ADDRESS_STATUS_PENDING               1
+#define PANEL_FB_ADDRESS_EXT                          27:27
+#define PANEL_FB_ADDRESS_EXT_LOCAL                    0
+#define PANEL_FB_ADDRESS_EXT_EXTERNAL                 1
+#define PANEL_FB_ADDRESS_ADDRESS                      25:0
+
+#define PANEL_FB_WIDTH                                0x080010
+#define PANEL_FB_WIDTH_WIDTH                          29:16
+#define PANEL_FB_WIDTH_OFFSET                         13:0
+
+#define PANEL_WINDOW_WIDTH                            0x080014
+#define PANEL_WINDOW_WIDTH_WIDTH                      27:16
+#define PANEL_WINDOW_WIDTH_X                          11:0
+
+#define PANEL_WINDOW_HEIGHT                           0x080018
+#define PANEL_WINDOW_HEIGHT_HEIGHT                    27:16
+#define PANEL_WINDOW_HEIGHT_Y                         11:0
+
+#define PANEL_PLANE_TL                                0x08001C
+#define PANEL_PLANE_TL_TOP                            26:16
+#define PANEL_PLANE_TL_LEFT                           10:0
+
+#define PANEL_PLANE_BR                                0x080020
+#define PANEL_PLANE_BR_BOTTOM                         26:16
+#define PANEL_PLANE_BR_RIGHT                          10:0
+
+#define PANEL_HORIZONTAL_TOTAL                        0x080024
+#define PANEL_HORIZONTAL_TOTAL_TOTAL                  27:16
+#define PANEL_HORIZONTAL_TOTAL_DISPLAY_END            11:0
+
+#define PANEL_HORIZONTAL_SYNC                         0x080028
+#define PANEL_HORIZONTAL_SYNC_WIDTH                   23:16
+#define PANEL_HORIZONTAL_SYNC_START                   11:0
+
+#define PANEL_VERTICAL_TOTAL                          0x08002C
+#define PANEL_VERTICAL_TOTAL_TOTAL                    26:16
+#define PANEL_VERTICAL_TOTAL_DISPLAY_END              10:0
+
+#define PANEL_VERTICAL_SYNC                           0x080030
+#define PANEL_VERTICAL_SYNC_HEIGHT                    21:16
+#define PANEL_VERTICAL_SYNC_START                     10:0
+
+#define PANEL_CURRENT_LINE                            0x080034
+#define PANEL_CURRENT_LINE_LINE                       10:0
+
+/* Video Control */
+
+#define VIDEO_DISPLAY_CTRL                              0x080040
+#define VIDEO_DISPLAY_CTRL_LINE_BUFFER                  18:18
+#define VIDEO_DISPLAY_CTRL_LINE_BUFFER_DISABLE          0
+#define VIDEO_DISPLAY_CTRL_LINE_BUFFER_ENABLE           1
+#define VIDEO_DISPLAY_CTRL_FIFO                         17:16
+#define VIDEO_DISPLAY_CTRL_FIFO_1                       0
+#define VIDEO_DISPLAY_CTRL_FIFO_3                       1
+#define VIDEO_DISPLAY_CTRL_FIFO_7                       2
+#define VIDEO_DISPLAY_CTRL_FIFO_11                      3
+#define VIDEO_DISPLAY_CTRL_BUFFER                       15:15
+#define VIDEO_DISPLAY_CTRL_BUFFER_0                     0
+#define VIDEO_DISPLAY_CTRL_BUFFER_1                     1
+#define VIDEO_DISPLAY_CTRL_CAPTURE                      14:14
+#define VIDEO_DISPLAY_CTRL_CAPTURE_DISABLE              0
+#define VIDEO_DISPLAY_CTRL_CAPTURE_ENABLE               1
+#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER                13:13
+#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER_DISABLE        0
+#define VIDEO_DISPLAY_CTRL_DOUBLE_BUFFER_ENABLE         1
+#define VIDEO_DISPLAY_CTRL_BYTE_SWAP                    12:12
+#define VIDEO_DISPLAY_CTRL_BYTE_SWAP_DISABLE            0
+#define VIDEO_DISPLAY_CTRL_BYTE_SWAP_ENABLE             1
+#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE               11:11
+#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE_NORMAL        0
+#define VIDEO_DISPLAY_CTRL_VERTICAL_SCALE_HALF          1
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE             10:10
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE_NORMAL      0
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_SCALE_HALF        1
+#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE                9:9
+#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE_REPLICATE      0
+#define VIDEO_DISPLAY_CTRL_VERTICAL_MODE_INTERPOLATE    1
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE              8:8
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE_REPLICATE    0
+#define VIDEO_DISPLAY_CTRL_HORIZONTAL_MODE_INTERPOLATE  1
+#define VIDEO_DISPLAY_CTRL_PIXEL                        7:4
+#define VIDEO_DISPLAY_CTRL_GAMMA                        3:3
+#define VIDEO_DISPLAY_CTRL_GAMMA_DISABLE                0
+#define VIDEO_DISPLAY_CTRL_GAMMA_ENABLE                 1
+#define VIDEO_DISPLAY_CTRL_PLANE                        2:2
+#define VIDEO_DISPLAY_CTRL_PLANE_DISABLE                0
+#define VIDEO_DISPLAY_CTRL_PLANE_ENABLE                 1
+#define VIDEO_DISPLAY_CTRL_FORMAT                       1:0
+#define VIDEO_DISPLAY_CTRL_FORMAT_8                     0
+#define VIDEO_DISPLAY_CTRL_FORMAT_16                    1
+#define VIDEO_DISPLAY_CTRL_FORMAT_32                    2
+#define VIDEO_DISPLAY_CTRL_FORMAT_YUV                   3
+
+#define VIDEO_FB_0_ADDRESS                            0x080044
+#define VIDEO_FB_0_ADDRESS_STATUS                     31:31
+#define VIDEO_FB_0_ADDRESS_STATUS_CURRENT             0
+#define VIDEO_FB_0_ADDRESS_STATUS_PENDING             1
+#define VIDEO_FB_0_ADDRESS_EXT                        27:27
+#define VIDEO_FB_0_ADDRESS_EXT_LOCAL                  0
+#define VIDEO_FB_0_ADDRESS_EXT_EXTERNAL               1
+#define VIDEO_FB_0_ADDRESS_ADDRESS                    25:0
+
+#define VIDEO_FB_WIDTH                                0x080048
+#define VIDEO_FB_WIDTH_WIDTH                          29:16
+#define VIDEO_FB_WIDTH_OFFSET                         13:0
+
+#define VIDEO_FB_0_LAST_ADDRESS                       0x08004C
+#define VIDEO_FB_0_LAST_ADDRESS_EXT                   27:27
+#define VIDEO_FB_0_LAST_ADDRESS_EXT_LOCAL             0
+#define VIDEO_FB_0_LAST_ADDRESS_EXT_EXTERNAL          1
+#define VIDEO_FB_0_LAST_ADDRESS_ADDRESS               25:0
+
+#define VIDEO_PLANE_TL                                0x080050
+#define VIDEO_PLANE_TL_TOP                            26:16
+#define VIDEO_PLANE_TL_LEFT                           10:0
+
+#define VIDEO_PLANE_BR                                0x080054
+#define VIDEO_PLANE_BR_BOTTOM                         26:16
+#define VIDEO_PLANE_BR_RIGHT                          10:0
+
+#define VIDEO_SCALE                                   0x080058
+#define VIDEO_SCALE_VERTICAL_MODE                     31:31
+#define VIDEO_SCALE_VERTICAL_MODE_EXPAND              0
+#define VIDEO_SCALE_VERTICAL_MODE_SHRINK              1
+#define VIDEO_SCALE_VERTICAL_SCALE                    27:16
+#define VIDEO_SCALE_HORIZONTAL_MODE                   15:15
+#define VIDEO_SCALE_HORIZONTAL_MODE_EXPAND            0
+#define VIDEO_SCALE_HORIZONTAL_MODE_SHRINK            1
+#define VIDEO_SCALE_HORIZONTAL_SCALE                  11:0
+
+#define VIDEO_INITIAL_SCALE                           0x08005C
+#define VIDEO_INITIAL_SCALE_FB_1                      27:16
+#define VIDEO_INITIAL_SCALE_FB_0                      11:0
+
+#define VIDEO_YUV_CONSTANTS                           0x080060
+#define VIDEO_YUV_CONSTANTS_Y                         31:24
+#define VIDEO_YUV_CONSTANTS_R                         23:16
+#define VIDEO_YUV_CONSTANTS_G                         15:8
+#define VIDEO_YUV_CONSTANTS_B                         7:0
+
+#define VIDEO_FB_1_ADDRESS                            0x080064
+#define VIDEO_FB_1_ADDRESS_STATUS                     31:31
+#define VIDEO_FB_1_ADDRESS_STATUS_CURRENT             0
+#define VIDEO_FB_1_ADDRESS_STATUS_PENDING             1
+#define VIDEO_FB_1_ADDRESS_EXT                        27:27
+#define VIDEO_FB_1_ADDRESS_EXT_LOCAL                  0
+#define VIDEO_FB_1_ADDRESS_EXT_EXTERNAL               1
+#define VIDEO_FB_1_ADDRESS_ADDRESS                    25:0
+
+#define VIDEO_FB_1_LAST_ADDRESS                       0x080068
+#define VIDEO_FB_1_LAST_ADDRESS_EXT                   27:27
+#define VIDEO_FB_1_LAST_ADDRESS_EXT_LOCAL             0
+#define VIDEO_FB_1_LAST_ADDRESS_EXT_EXTERNAL          1
+#define VIDEO_FB_1_LAST_ADDRESS_ADDRESS               25:0
+
+/* Video Alpha Control */
+
+#define VIDEO_ALPHA_DISPLAY_CTRL                        0x080080
+#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT                 28:28
+#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT_PER_PIXEL       0
+#define VIDEO_ALPHA_DISPLAY_CTRL_SELECT_ALPHA           1
+#define VIDEO_ALPHA_DISPLAY_CTRL_ALPHA                  27:24
+#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO                   17:16
+#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_1                 0
+#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_3                 1
+#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_7                 2
+#define VIDEO_ALPHA_DISPLAY_CTRL_FIFO_11                3
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE             11:11
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE_NORMAL      0
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_SCALE_HALF        1
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE             10:10
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE_NORMAL      0
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_SCALE_HALF        1
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE              9:9
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE_REPLICATE    0
+#define VIDEO_ALPHA_DISPLAY_CTRL_VERT_MODE_INTERPOLATE  1
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE              8:8
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE_REPLICATE    0
+#define VIDEO_ALPHA_DISPLAY_CTRL_HORZ_MODE_INTERPOLATE  1
+#define VIDEO_ALPHA_DISPLAY_CTRL_PIXEL                  7:4
+#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY             3:3
+#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY_DISABLE     0
+#define VIDEO_ALPHA_DISPLAY_CTRL_CHROMA_KEY_ENABLE      1
+#define VIDEO_ALPHA_DISPLAY_CTRL_PLANE                  2:2
+#define VIDEO_ALPHA_DISPLAY_CTRL_PLANE_DISABLE          0
+#define VIDEO_ALPHA_DISPLAY_CTRL_PLANE_ENABLE           1
+#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT                 1:0
+#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_8               0
+#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_16              1
+#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4       2
+#define VIDEO_ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4   3
+
+#define VIDEO_ALPHA_FB_ADDRESS                        0x080084
+#define VIDEO_ALPHA_FB_ADDRESS_STATUS                 31:31
+#define VIDEO_ALPHA_FB_ADDRESS_STATUS_CURRENT         0
+#define VIDEO_ALPHA_FB_ADDRESS_STATUS_PENDING         1
+#define VIDEO_ALPHA_FB_ADDRESS_EXT                    27:27
+#define VIDEO_ALPHA_FB_ADDRESS_EXT_LOCAL              0
+#define VIDEO_ALPHA_FB_ADDRESS_EXT_EXTERNAL           1
+#define VIDEO_ALPHA_FB_ADDRESS_ADDRESS                25:0
+
+#define VIDEO_ALPHA_FB_WIDTH                          0x080088
+#define VIDEO_ALPHA_FB_WIDTH_WIDTH                    29:16
+#define VIDEO_ALPHA_FB_WIDTH_OFFSET                   13:0
+
+#define VIDEO_ALPHA_FB_LAST_ADDRESS                   0x08008C
+#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT               27:27
+#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT_LOCAL         0
+#define VIDEO_ALPHA_FB_LAST_ADDRESS_EXT_EXTERNAL      1
+#define VIDEO_ALPHA_FB_LAST_ADDRESS_ADDRESS           25:0
+
+#define VIDEO_ALPHA_PLANE_TL                          0x080090
+#define VIDEO_ALPHA_PLANE_TL_TOP                      26:16
+#define VIDEO_ALPHA_PLANE_TL_LEFT                     10:0
+
+#define VIDEO_ALPHA_PLANE_BR                          0x080094
+#define VIDEO_ALPHA_PLANE_BR_BOTTOM                   26:16
+#define VIDEO_ALPHA_PLANE_BR_RIGHT                    10:0
+
+#define VIDEO_ALPHA_SCALE                             0x080098
+#define VIDEO_ALPHA_SCALE_VERTICAL_MODE               31:31
+#define VIDEO_ALPHA_SCALE_VERTICAL_MODE_EXPAND        0
+#define VIDEO_ALPHA_SCALE_VERTICAL_MODE_SHRINK        1
+#define VIDEO_ALPHA_SCALE_VERTICAL_SCALE              27:16
+#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE             15:15
+#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE_EXPAND      0
+#define VIDEO_ALPHA_SCALE_HORIZONTAL_MODE_SHRINK      1
+#define VIDEO_ALPHA_SCALE_HORIZONTAL_SCALE            11:0
+
+#define VIDEO_ALPHA_INITIAL_SCALE                     0x08009C
+#define VIDEO_ALPHA_INITIAL_SCALE_VERTICAL            27:16
+#define VIDEO_ALPHA_INITIAL_SCALE_HORIZONTAL          11:0
+
+#define VIDEO_ALPHA_CHROMA_KEY                        0x0800A0
+#define VIDEO_ALPHA_CHROMA_KEY_MASK                   31:16
+#define VIDEO_ALPHA_CHROMA_KEY_VALUE                  15:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_01                   0x0800A4
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_1                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_1_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_0                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_01_0_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_23                   0x0800A8
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_3                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_3_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_2                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_23_2_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_45                   0x0800AC
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_5                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_5_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_4                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_45_4_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_67                   0x0800B0
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_7                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_7_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_6                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_67_6_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_89                   0x0800B4
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_9                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_9_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_8                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_89_8_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB                   0x0800B8
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_B_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_AB_A_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD                   0x0800BC
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_D_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_CD_C_BLUE            4:0
+
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF                   0x0800C0
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F                 31:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_RED             31:27
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_GREEN           26:21
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_F_BLUE            20:16
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E                 15:0
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_RED             15:11
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_GREEN           10:5
+#define VIDEO_ALPHA_COLOR_LOOKUP_EF_E_BLUE            4:0
+
+/* Panel Cursor Control */
+
+#define PANEL_HWC_ADDRESS                             0x0800F0
+#define PANEL_HWC_ADDRESS_ENABLE                      31:31
+#define PANEL_HWC_ADDRESS_ENABLE_DISABLE              0
+#define PANEL_HWC_ADDRESS_ENABLE_ENABLE               1
+#define PANEL_HWC_ADDRESS_EXT                         27:27
+#define PANEL_HWC_ADDRESS_EXT_LOCAL                   0
+#define PANEL_HWC_ADDRESS_EXT_EXTERNAL                1
+#define PANEL_HWC_ADDRESS_ADDRESS                     25:0
+
+#define PANEL_HWC_LOCATION                            0x0800F4
+#define PANEL_HWC_LOCATION_TOP                        27:27
+#define PANEL_HWC_LOCATION_TOP_INSIDE                 0
+#define PANEL_HWC_LOCATION_TOP_OUTSIDE                1
+#define PANEL_HWC_LOCATION_Y                          26:16
+#define PANEL_HWC_LOCATION_LEFT                       11:11
+#define PANEL_HWC_LOCATION_LEFT_INSIDE                0
+#define PANEL_HWC_LOCATION_LEFT_OUTSIDE               1
+#define PANEL_HWC_LOCATION_X                          10:0
+
+#define PANEL_HWC_COLOR_12                            0x0800F8
+#define PANEL_HWC_COLOR_12_2_RGB565                   31:16
+#define PANEL_HWC_COLOR_12_1_RGB565                   15:0
+
+#define PANEL_HWC_COLOR_3                             0x0800FC
+#define PANEL_HWC_COLOR_3_RGB565                      15:0
+
+/* Old Definitions +++ */
+#define PANEL_HWC_COLOR_01                            0x0800F8
+#define PANEL_HWC_COLOR_01_1_RED                      31:27
+#define PANEL_HWC_COLOR_01_1_GREEN                    26:21
+#define PANEL_HWC_COLOR_01_1_BLUE                     20:16
+#define PANEL_HWC_COLOR_01_0_RED                      15:11
+#define PANEL_HWC_COLOR_01_0_GREEN                    10:5
+#define PANEL_HWC_COLOR_01_0_BLUE                     4:0
+
+#define PANEL_HWC_COLOR_2                             0x0800FC
+#define PANEL_HWC_COLOR_2_RED                         15:11
+#define PANEL_HWC_COLOR_2_GREEN                       10:5
+#define PANEL_HWC_COLOR_2_BLUE                        4:0
+/* Old Definitions --- */
+
+/* Alpha Control */
+
+#define ALPHA_DISPLAY_CTRL                            0x080100
+#define ALPHA_DISPLAY_CTRL_SELECT                     28:28
+#define ALPHA_DISPLAY_CTRL_SELECT_PER_PIXEL           0
+#define ALPHA_DISPLAY_CTRL_SELECT_ALPHA               1
+#define ALPHA_DISPLAY_CTRL_ALPHA                      27:24
+#define ALPHA_DISPLAY_CTRL_FIFO                       17:16
+#define ALPHA_DISPLAY_CTRL_FIFO_1                     0
+#define ALPHA_DISPLAY_CTRL_FIFO_3                     1
+#define ALPHA_DISPLAY_CTRL_FIFO_7                     2
+#define ALPHA_DISPLAY_CTRL_FIFO_11                    3
+#define ALPHA_DISPLAY_CTRL_PIXEL                      7:4
+#define ALPHA_DISPLAY_CTRL_CHROMA_KEY                 3:3
+#define ALPHA_DISPLAY_CTRL_CHROMA_KEY_DISABLE         0
+#define ALPHA_DISPLAY_CTRL_CHROMA_KEY_ENABLE          1
+#define ALPHA_DISPLAY_CTRL_PLANE                      2:2
+#define ALPHA_DISPLAY_CTRL_PLANE_DISABLE              0
+#define ALPHA_DISPLAY_CTRL_PLANE_ENABLE               1
+#define ALPHA_DISPLAY_CTRL_FORMAT                     1:0
+#define ALPHA_DISPLAY_CTRL_FORMAT_16                  1
+#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4           2
+#define ALPHA_DISPLAY_CTRL_FORMAT_ALPHA_4_4_4_4       3
+
+#define ALPHA_FB_ADDRESS                              0x080104
+#define ALPHA_FB_ADDRESS_STATUS                       31:31
+#define ALPHA_FB_ADDRESS_STATUS_CURRENT               0
+#define ALPHA_FB_ADDRESS_STATUS_PENDING               1
+#define ALPHA_FB_ADDRESS_EXT                          27:27
+#define ALPHA_FB_ADDRESS_EXT_LOCAL                    0
+#define ALPHA_FB_ADDRESS_EXT_EXTERNAL                 1
+#define ALPHA_FB_ADDRESS_ADDRESS                      25:0
+
+#define ALPHA_FB_WIDTH                                0x080108
+#define ALPHA_FB_WIDTH_WIDTH                          29:16
+#define ALPHA_FB_WIDTH_OFFSET                         13:0
+
+#define ALPHA_PLANE_TL                                0x08010C
+#define ALPHA_PLANE_TL_TOP                            26:16
+#define ALPHA_PLANE_TL_LEFT                           10:0
+
+#define ALPHA_PLANE_BR                                0x080110
+#define ALPHA_PLANE_BR_BOTTOM                         26:16
+#define ALPHA_PLANE_BR_RIGHT                          10:0
+
+#define ALPHA_CHROMA_KEY                              0x080114
+#define ALPHA_CHROMA_KEY_MASK                         31:16
+#define ALPHA_CHROMA_KEY_VALUE                        15:0
+
+#define ALPHA_COLOR_LOOKUP_01                         0x080118
+#define ALPHA_COLOR_LOOKUP_01_1                       31:16
+#define ALPHA_COLOR_LOOKUP_01_1_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_01_1_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_01_1_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_01_0                       15:0
+#define ALPHA_COLOR_LOOKUP_01_0_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_01_0_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_01_0_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_23                         0x08011C
+#define ALPHA_COLOR_LOOKUP_23_3                       31:16
+#define ALPHA_COLOR_LOOKUP_23_3_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_23_3_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_23_3_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_23_2                       15:0
+#define ALPHA_COLOR_LOOKUP_23_2_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_23_2_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_23_2_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_45                         0x080120
+#define ALPHA_COLOR_LOOKUP_45_5                       31:16
+#define ALPHA_COLOR_LOOKUP_45_5_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_45_5_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_45_5_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_45_4                       15:0
+#define ALPHA_COLOR_LOOKUP_45_4_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_45_4_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_45_4_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_67                         0x080124
+#define ALPHA_COLOR_LOOKUP_67_7                       31:16
+#define ALPHA_COLOR_LOOKUP_67_7_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_67_7_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_67_7_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_67_6                       15:0
+#define ALPHA_COLOR_LOOKUP_67_6_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_67_6_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_67_6_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_89                         0x080128
+#define ALPHA_COLOR_LOOKUP_89_9                       31:16
+#define ALPHA_COLOR_LOOKUP_89_9_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_89_9_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_89_9_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_89_8                       15:0
+#define ALPHA_COLOR_LOOKUP_89_8_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_89_8_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_89_8_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_AB                         0x08012C
+#define ALPHA_COLOR_LOOKUP_AB_B                       31:16
+#define ALPHA_COLOR_LOOKUP_AB_B_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_AB_B_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_AB_B_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_AB_A                       15:0
+#define ALPHA_COLOR_LOOKUP_AB_A_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_AB_A_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_AB_A_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_CD                         0x080130
+#define ALPHA_COLOR_LOOKUP_CD_D                       31:16
+#define ALPHA_COLOR_LOOKUP_CD_D_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_CD_D_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_CD_D_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_CD_C                       15:0
+#define ALPHA_COLOR_LOOKUP_CD_C_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_CD_C_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_CD_C_BLUE                  4:0
+
+#define ALPHA_COLOR_LOOKUP_EF                         0x080134
+#define ALPHA_COLOR_LOOKUP_EF_F                       31:16
+#define ALPHA_COLOR_LOOKUP_EF_F_RED                   31:27
+#define ALPHA_COLOR_LOOKUP_EF_F_GREEN                 26:21
+#define ALPHA_COLOR_LOOKUP_EF_F_BLUE                  20:16
+#define ALPHA_COLOR_LOOKUP_EF_E                       15:0
+#define ALPHA_COLOR_LOOKUP_EF_E_RED                   15:11
+#define ALPHA_COLOR_LOOKUP_EF_E_GREEN                 10:5
+#define ALPHA_COLOR_LOOKUP_EF_E_BLUE                  4:0
+
+/* CRT Graphics Control */
+
+#define CRT_DISPLAY_CTRL                              0x080200
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK                         31:27
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_DISABLE                         0
+#define CRT_DISPLAY_CTRL_RESERVED_1_MASK_ENABLE                          0x1F
+
+/* SM750LE definition */
+#define CRT_DISPLAY_CTRL_DPMS                         31:30
+#define CRT_DISPLAY_CTRL_DPMS_0                       0
+#define CRT_DISPLAY_CTRL_DPMS_1                       1
+#define CRT_DISPLAY_CTRL_DPMS_2                       2
+#define CRT_DISPLAY_CTRL_DPMS_3                       3
+#define CRT_DISPLAY_CTRL_CLK                          29:27
+#define CRT_DISPLAY_CTRL_CLK_PLL25                    0
+#define CRT_DISPLAY_CTRL_CLK_PLL41                    1
+#define CRT_DISPLAY_CTRL_CLK_PLL62                    2
+#define CRT_DISPLAY_CTRL_CLK_PLL65                    3
+#define CRT_DISPLAY_CTRL_CLK_PLL74                    4
+#define CRT_DISPLAY_CTRL_CLK_PLL80                    5
+#define CRT_DISPLAY_CTRL_CLK_PLL108                   6
+#define CRT_DISPLAY_CTRL_CLK_RESERVED                 7
+#define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC                26:26
+#define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC_DISABLE        1
+#define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC_ENABLE         0
+
+
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK                         25:24
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_ENABLE                          3
+#define CRT_DISPLAY_CTRL_RESERVED_2_MASK_DISABLE                         0
+
+/* SM750LE definition */
+#define CRT_DISPLAY_CTRL_CRTSELECT                    25:25
+#define CRT_DISPLAY_CTRL_CRTSELECT_VGA                0
+#define CRT_DISPLAY_CTRL_CRTSELECT_CRT                1
+#define CRT_DISPLAY_CTRL_RGBBIT                       24:24
+#define CRT_DISPLAY_CTRL_RGBBIT_24BIT                 0
+#define CRT_DISPLAY_CTRL_RGBBIT_12BIT                 1
+
+
+#define CRT_DISPLAY_CTRL_RESERVED_3_MASK                         15:15
+#define CRT_DISPLAY_CTRL_RESERVED_3_MASK_DISABLE      0
+#define CRT_DISPLAY_CTRL_RESERVED_3_MASK_ENABLE       1
+
+#define CRT_DISPLAY_CTRL_RESERVED_4_MASK                         9:9
+#define CRT_DISPLAY_CTRL_RESERVED_4_MASK_DISABLE      0
+#define CRT_DISPLAY_CTRL_RESERVED_4_MASK_ENABLE       1
+
+#ifndef VALIDATION_CHIP
+    #define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC            26:26
+    #define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC_DISABLE    1
+    #define CRT_DISPLAY_CTRL_SHIFT_VGA_DAC_ENABLE     0
+    #define CRT_DISPLAY_CTRL_CENTERING                24:24
+    #define CRT_DISPLAY_CTRL_CENTERING_DISABLE        0
+    #define CRT_DISPLAY_CTRL_CENTERING_ENABLE         1
+#endif
+#define CRT_DISPLAY_CTRL_LOCK_TIMING                  23:23
+#define CRT_DISPLAY_CTRL_LOCK_TIMING_DISABLE          0
+#define CRT_DISPLAY_CTRL_LOCK_TIMING_ENABLE           1
+#define CRT_DISPLAY_CTRL_EXPANSION                    22:22
+#define CRT_DISPLAY_CTRL_EXPANSION_DISABLE            0
+#define CRT_DISPLAY_CTRL_EXPANSION_ENABLE             1
+#define CRT_DISPLAY_CTRL_VERTICAL_MODE                21:21
+#define CRT_DISPLAY_CTRL_VERTICAL_MODE_REPLICATE      0
+#define CRT_DISPLAY_CTRL_VERTICAL_MODE_INTERPOLATE    1
+#define CRT_DISPLAY_CTRL_HORIZONTAL_MODE              20:20
+#define CRT_DISPLAY_CTRL_HORIZONTAL_MODE_REPLICATE    0
+#define CRT_DISPLAY_CTRL_HORIZONTAL_MODE_INTERPOLATE  1
+#define CRT_DISPLAY_CTRL_SELECT                       19:18
+#define CRT_DISPLAY_CTRL_SELECT_PANEL                 0
+#define CRT_DISPLAY_CTRL_SELECT_VGA                   1
+#define CRT_DISPLAY_CTRL_SELECT_CRT                   2
+#define CRT_DISPLAY_CTRL_FIFO                         17:16
+#define CRT_DISPLAY_CTRL_FIFO_1                       0
+#define CRT_DISPLAY_CTRL_FIFO_3                       1
+#define CRT_DISPLAY_CTRL_FIFO_7                       2
+#define CRT_DISPLAY_CTRL_FIFO_11                      3
+#define CRT_DISPLAY_CTRL_CLOCK_PHASE                  14:14
+#define CRT_DISPLAY_CTRL_CLOCK_PHASE_ACTIVE_HIGH      0
+#define CRT_DISPLAY_CTRL_CLOCK_PHASE_ACTIVE_LOW       1
+#define CRT_DISPLAY_CTRL_VSYNC_PHASE                  13:13
+#define CRT_DISPLAY_CTRL_VSYNC_PHASE_ACTIVE_HIGH      0
+#define CRT_DISPLAY_CTRL_VSYNC_PHASE_ACTIVE_LOW       1
+#define CRT_DISPLAY_CTRL_HSYNC_PHASE                  12:12
+#define CRT_DISPLAY_CTRL_HSYNC_PHASE_ACTIVE_HIGH      0
+#define CRT_DISPLAY_CTRL_HSYNC_PHASE_ACTIVE_LOW       1
+#define CRT_DISPLAY_CTRL_BLANK                        10:10
+#define CRT_DISPLAY_CTRL_BLANK_OFF                    0
+#define CRT_DISPLAY_CTRL_BLANK_ON                     1
+#define CRT_DISPLAY_CTRL_TIMING                       8:8
+#define CRT_DISPLAY_CTRL_TIMING_DISABLE               0
+#define CRT_DISPLAY_CTRL_TIMING_ENABLE                1
+#define CRT_DISPLAY_CTRL_PIXEL                        7:4
+#define CRT_DISPLAY_CTRL_GAMMA                        3:3
+#define CRT_DISPLAY_CTRL_GAMMA_DISABLE                0
+#define CRT_DISPLAY_CTRL_GAMMA_ENABLE                 1
+#define CRT_DISPLAY_CTRL_PLANE                        2:2
+#define CRT_DISPLAY_CTRL_PLANE_DISABLE                0
+#define CRT_DISPLAY_CTRL_PLANE_ENABLE                 1
+#define CRT_DISPLAY_CTRL_FORMAT                       1:0
+#define CRT_DISPLAY_CTRL_FORMAT_8                     0
+#define CRT_DISPLAY_CTRL_FORMAT_16                    1
+#define CRT_DISPLAY_CTRL_FORMAT_32                    2
+#define CRT_DISPLAY_CTRL_RESERVED_BITS_MASK           0xFF000200
+
+#define CRT_FB_ADDRESS                                0x080204
+#define CRT_FB_ADDRESS_STATUS                         31:31
+#define CRT_FB_ADDRESS_STATUS_CURRENT                 0
+#define CRT_FB_ADDRESS_STATUS_PENDING                 1
+#define CRT_FB_ADDRESS_EXT                            27:27
+#define CRT_FB_ADDRESS_EXT_LOCAL                      0
+#define CRT_FB_ADDRESS_EXT_EXTERNAL                   1
+#define CRT_FB_ADDRESS_ADDRESS                        25:0
+
+#define CRT_FB_WIDTH                                  0x080208
+#define CRT_FB_WIDTH_WIDTH                            29:16
+#define CRT_FB_WIDTH_OFFSET                           13:0
+
+#define CRT_HORIZONTAL_TOTAL                          0x08020C
+#define CRT_HORIZONTAL_TOTAL_TOTAL                    27:16
+#define CRT_HORIZONTAL_TOTAL_DISPLAY_END              11:0
+
+#define CRT_HORIZONTAL_SYNC                           0x080210
+#define CRT_HORIZONTAL_SYNC_WIDTH                     23:16
+#define CRT_HORIZONTAL_SYNC_START                     11:0
+
+#define CRT_VERTICAL_TOTAL                            0x080214
+#define CRT_VERTICAL_TOTAL_TOTAL                      26:16
+#define CRT_VERTICAL_TOTAL_DISPLAY_END                10:0
+
+#define CRT_VERTICAL_SYNC                             0x080218
+#define CRT_VERTICAL_SYNC_HEIGHT                      21:16
+#define CRT_VERTICAL_SYNC_START                       10:0
+
+#define CRT_SIGNATURE_ANALYZER                        0x08021C
+#define CRT_SIGNATURE_ANALYZER_STATUS                 31:16
+#define CRT_SIGNATURE_ANALYZER_ENABLE                 3:3
+#define CRT_SIGNATURE_ANALYZER_ENABLE_DISABLE         0
+#define CRT_SIGNATURE_ANALYZER_ENABLE_ENABLE          1
+#define CRT_SIGNATURE_ANALYZER_RESET                  2:2
+#define CRT_SIGNATURE_ANALYZER_RESET_NORMAL           0
+#define CRT_SIGNATURE_ANALYZER_RESET_RESET            1
+#define CRT_SIGNATURE_ANALYZER_SOURCE                 1:0
+#define CRT_SIGNATURE_ANALYZER_SOURCE_RED             0
+#define CRT_SIGNATURE_ANALYZER_SOURCE_GREEN           1
+#define CRT_SIGNATURE_ANALYZER_SOURCE_BLUE            2
+
+#define CRT_CURRENT_LINE                              0x080220
+#define CRT_CURRENT_LINE_LINE                         10:0
+
+#define CRT_MONITOR_DETECT                            0x080224
+#define CRT_MONITOR_DETECT_VALUE                      25:25
+#define CRT_MONITOR_DETECT_VALUE_DISABLE              0
+#define CRT_MONITOR_DETECT_VALUE_ENABLE               1
+#define CRT_MONITOR_DETECT_ENABLE                     24:24
+#define CRT_MONITOR_DETECT_ENABLE_DISABLE             0
+#define CRT_MONITOR_DETECT_ENABLE_ENABLE              1
+#define CRT_MONITOR_DETECT_RED                        23:16
+#define CRT_MONITOR_DETECT_GREEN                      15:8
+#define CRT_MONITOR_DETECT_BLUE                       7:0
+
+#define CRT_SCALE                                     0x080228
+#define CRT_SCALE_VERTICAL_MODE                       31:31
+#define CRT_SCALE_VERTICAL_MODE_EXPAND                0
+#define CRT_SCALE_VERTICAL_MODE_SHRINK                1
+#define CRT_SCALE_VERTICAL_SCALE                      27:16
+#define CRT_SCALE_HORIZONTAL_MODE                     15:15
+#define CRT_SCALE_HORIZONTAL_MODE_EXPAND              0
+#define CRT_SCALE_HORIZONTAL_MODE_SHRINK              1
+#define CRT_SCALE_HORIZONTAL_SCALE                    11:0
+
+/* CRT Cursor Control */
+
+#define CRT_HWC_ADDRESS                               0x080230
+#define CRT_HWC_ADDRESS_ENABLE                        31:31
+#define CRT_HWC_ADDRESS_ENABLE_DISABLE                0
+#define CRT_HWC_ADDRESS_ENABLE_ENABLE                 1
+#define CRT_HWC_ADDRESS_EXT                           27:27
+#define CRT_HWC_ADDRESS_EXT_LOCAL                     0
+#define CRT_HWC_ADDRESS_EXT_EXTERNAL                  1
+#define CRT_HWC_ADDRESS_ADDRESS                       25:0
+
+#define CRT_HWC_LOCATION                              0x080234
+#define CRT_HWC_LOCATION_TOP                          27:27
+#define CRT_HWC_LOCATION_TOP_INSIDE                   0
+#define CRT_HWC_LOCATION_TOP_OUTSIDE                  1
+#define CRT_HWC_LOCATION_Y                            26:16
+#define CRT_HWC_LOCATION_LEFT                         11:11
+#define CRT_HWC_LOCATION_LEFT_INSIDE                  0
+#define CRT_HWC_LOCATION_LEFT_OUTSIDE                 1
+#define CRT_HWC_LOCATION_X                            10:0
+
+#define CRT_HWC_COLOR_12                              0x080238
+#define CRT_HWC_COLOR_12_2_RGB565                     31:16
+#define CRT_HWC_COLOR_12_1_RGB565                     15:0
+
+#define CRT_HWC_COLOR_3                               0x08023C
+#define CRT_HWC_COLOR_3_RGB565                        15:0
+
+/* Old Definitions +++. Need to be removed if no application use it. */
+#if 0
+    #define CRT_HWC_COLOR_01                          0x080238
+    #define CRT_HWC_COLOR_01_1_RED                    31:27
+    #define CRT_HWC_COLOR_01_1_GREEN                  26:21
+    #define CRT_HWC_COLOR_01_1_BLUE                   20:16
+    #define CRT_HWC_COLOR_01_0_RED                    15:11
+    #define CRT_HWC_COLOR_01_0_GREEN                  10:5
+    #define CRT_HWC_COLOR_01_0_BLUE                   4:0
+
+    #define CRT_HWC_COLOR_2                           0x08023C
+    #define CRT_HWC_COLOR_2_RED                       15:11
+    #define CRT_HWC_COLOR_2_GREEN                     10:5
+    #define CRT_HWC_COLOR_2_BLUE                      4:0
+#endif
+/* Old Definitions --- */
+
+/* This vertical expansion below start at 0x080240 ~ 0x080264 */
+#define CRT_VERTICAL_EXPANSION                        0x080240
+#ifndef VALIDATION_CHIP
+    #define CRT_VERTICAL_CENTERING_VALUE              31:24
+#endif
+#define CRT_VERTICAL_EXPANSION_COMPARE_VALUE          23:16
+#define CRT_VERTICAL_EXPANSION_LINE_BUFFER            15:12
+#define CRT_VERTICAL_EXPANSION_SCALE_FACTOR           11:0
+
+/* This horizontal expansion below start at 0x080268 ~ 0x08027C */
+#define CRT_HORIZONTAL_EXPANSION                      0x080268
+#ifndef VALIDATION_CHIP
+    #define CRT_HORIZONTAL_CENTERING_VALUE            31:24
+#endif
+#define CRT_HORIZONTAL_EXPANSION_COMPARE_VALUE        23:16
+#define CRT_HORIZONTAL_EXPANSION_SCALE_FACTOR         11:0
+
+#ifndef VALIDATION_CHIP
+    /* Auto Centering */
+    #define CRT_AUTO_CENTERING_TL                     0x080280
+    #define CRT_AUTO_CENTERING_TL_TOP                 26:16
+    #define CRT_AUTO_CENTERING_TL_LEFT                10:0
+
+    #define CRT_AUTO_CENTERING_BR                     0x080284
+    #define CRT_AUTO_CENTERING_BR_BOTTOM              26:16
+    #define CRT_AUTO_CENTERING_BR_RIGHT               10:0
+#endif
+
+/* sm750le new register to control panel output */
+#define DISPLAY_CONTROL_750LE  0x80288
+/* Palette RAM */
+
+/* Panel Pallete register starts at 0x080400 ~ 0x0807FC */
+#define PANEL_PALETTE_RAM                             0x080400
+
+/* Panel Pallete register starts at 0x080C00 ~ 0x080FFC */
+#define CRT_PALETTE_RAM                               0x080C00
+
+/* 2D registers
+ * move their defination into general lynx_accel.h file
+ * because all smi graphic chip share the same drawing engine
+ * register format */
+#if 0
+#define DE_SOURCE                                       0x100000
+#define DE_SOURCE_WRAP                                  31:31
+#define DE_SOURCE_WRAP_DISABLE                          0
+#define DE_SOURCE_WRAP_ENABLE                           1
+
+/*
+ * The following definitions are used in different setting
+ */
+
+/* Use these definitions in XY addressing mode or linear addressing mode. */
+#define DE_SOURCE_X_K1                                  27:16
+#define DE_SOURCE_Y_K2                                  11:0
+
+/* Use this definition in host write mode for mono. The Y_K2 is not used
+   in host write mode. */
+#define DE_SOURCE_X_K1_MONO                             20:16
+
+/* Use these definitions in Bresenham line drawing mode. */
+#define DE_SOURCE_X_K1_LINE                             29:16
+#define DE_SOURCE_Y_K2_LINE                             13:0
+
+#define DE_DESTINATION                                  0x100004
+#define DE_DESTINATION_WRAP                             31:31
+#define DE_DESTINATION_WRAP_DISABLE                     0
+#define DE_DESTINATION_WRAP_ENABLE                      1
+#if 1
+    #define DE_DESTINATION_X                            27:16
+    #define DE_DESTINATION_Y                            11:0
+#else
+    #define DE_DESTINATION_X                            28:16
+    #define DE_DESTINATION_Y                            15:0
+#endif
+
+#define DE_DIMENSION                                    0x100008
+#define DE_DIMENSION_X                                  28:16
+#define DE_DIMENSION_Y_ET                               15:0
+
+#define DE_CONTROL                                      0x10000C
+#define DE_CONTROL_STATUS                               31:31
+#define DE_CONTROL_STATUS_STOP                          0
+#define DE_CONTROL_STATUS_START                         1
+#define DE_CONTROL_PATTERN                              30:30
+#define DE_CONTROL_PATTERN_MONO                         0
+#define DE_CONTROL_PATTERN_COLOR                        1
+#define DE_CONTROL_UPDATE_DESTINATION_X                 29:29
+#define DE_CONTROL_UPDATE_DESTINATION_X_DISABLE         0
+#define DE_CONTROL_UPDATE_DESTINATION_X_ENABLE          1
+#define DE_CONTROL_QUICK_START                          28:28
+#define DE_CONTROL_QUICK_START_DISABLE                  0
+#define DE_CONTROL_QUICK_START_ENABLE                   1
+#define DE_CONTROL_DIRECTION                            27:27
+#define DE_CONTROL_DIRECTION_LEFT_TO_RIGHT              0
+#define DE_CONTROL_DIRECTION_RIGHT_TO_LEFT              1
+#define DE_CONTROL_MAJOR                                26:26
+#define DE_CONTROL_MAJOR_X                              0
+#define DE_CONTROL_MAJOR_Y                              1
+#define DE_CONTROL_STEP_X                               25:25
+#define DE_CONTROL_STEP_X_POSITIVE                      0
+#define DE_CONTROL_STEP_X_NEGATIVE                      1
+#define DE_CONTROL_STEP_Y                               24:24
+#define DE_CONTROL_STEP_Y_POSITIVE                      0
+#define DE_CONTROL_STEP_Y_NEGATIVE                      1
+#define DE_CONTROL_STRETCH                              23:23
+#define DE_CONTROL_STRETCH_DISABLE                      0
+#define DE_CONTROL_STRETCH_ENABLE                       1
+#define DE_CONTROL_HOST                                 22:22
+#define DE_CONTROL_HOST_COLOR                           0
+#define DE_CONTROL_HOST_MONO                            1
+#define DE_CONTROL_LAST_PIXEL                           21:21
+#define DE_CONTROL_LAST_PIXEL_OFF                       0
+#define DE_CONTROL_LAST_PIXEL_ON                        1
+#define DE_CONTROL_COMMAND                              20:16
+#define DE_CONTROL_COMMAND_BITBLT                       0
+#define DE_CONTROL_COMMAND_RECTANGLE_FILL               1
+#define DE_CONTROL_COMMAND_DE_TILE                      2
+#define DE_CONTROL_COMMAND_TRAPEZOID_FILL               3
+#define DE_CONTROL_COMMAND_ALPHA_BLEND                  4
+#define DE_CONTROL_COMMAND_RLE_STRIP                    5
+#define DE_CONTROL_COMMAND_SHORT_STROKE                 6
+#define DE_CONTROL_COMMAND_LINE_DRAW                    7
+#define DE_CONTROL_COMMAND_HOST_WRITE                   8
+#define DE_CONTROL_COMMAND_HOST_READ                    9
+#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP         10
+#define DE_CONTROL_COMMAND_ROTATE                       11
+#define DE_CONTROL_COMMAND_FONT                         12
+#define DE_CONTROL_COMMAND_TEXTURE_LOAD                 15
+#define DE_CONTROL_ROP_SELECT                           15:15
+#define DE_CONTROL_ROP_SELECT_ROP3                      0
+#define DE_CONTROL_ROP_SELECT_ROP2                      1
+#define DE_CONTROL_ROP2_SOURCE                          14:14
+#define DE_CONTROL_ROP2_SOURCE_BITMAP                   0
+#define DE_CONTROL_ROP2_SOURCE_PATTERN                  1
+#define DE_CONTROL_MONO_DATA                            13:12
+#define DE_CONTROL_MONO_DATA_NOT_PACKED                 0
+#define DE_CONTROL_MONO_DATA_8_PACKED                   1
+#define DE_CONTROL_MONO_DATA_16_PACKED                  2
+#define DE_CONTROL_MONO_DATA_32_PACKED                  3
+#define DE_CONTROL_REPEAT_ROTATE                        11:11
+#define DE_CONTROL_REPEAT_ROTATE_DISABLE                0
+#define DE_CONTROL_REPEAT_ROTATE_ENABLE                 1
+#define DE_CONTROL_TRANSPARENCY_MATCH                   10:10
+#define DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE            0
+#define DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT       1
+#define DE_CONTROL_TRANSPARENCY_SELECT                  9:9
+#define DE_CONTROL_TRANSPARENCY_SELECT_SOURCE           0
+#define DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION      1
+#define DE_CONTROL_TRANSPARENCY                         8:8
+#define DE_CONTROL_TRANSPARENCY_DISABLE                 0
+#define DE_CONTROL_TRANSPARENCY_ENABLE                  1
+#define DE_CONTROL_ROP                                  7:0
+
+/* Pseudo fields. */
+
+#define DE_CONTROL_SHORT_STROKE_DIR                     27:24
+#define DE_CONTROL_SHORT_STROKE_DIR_225                 0
+#define DE_CONTROL_SHORT_STROKE_DIR_135                 1
+#define DE_CONTROL_SHORT_STROKE_DIR_315                 2
+#define DE_CONTROL_SHORT_STROKE_DIR_45                  3
+#define DE_CONTROL_SHORT_STROKE_DIR_270                 4
+#define DE_CONTROL_SHORT_STROKE_DIR_90                  5
+#define DE_CONTROL_SHORT_STROKE_DIR_180                 8
+#define DE_CONTROL_SHORT_STROKE_DIR_0                   10
+#define DE_CONTROL_ROTATION                             25:24
+#define DE_CONTROL_ROTATION_0                           0
+#define DE_CONTROL_ROTATION_270                         1
+#define DE_CONTROL_ROTATION_90                          2
+#define DE_CONTROL_ROTATION_180                         3
+
+#define DE_PITCH                                        0x100010
+#define DE_PITCH_DESTINATION                            28:16
+#define DE_PITCH_SOURCE                                 12:0
+
+#define DE_FOREGROUND                                   0x100014
+#define DE_FOREGROUND_COLOR                             31:0
+
+#define DE_BACKGROUND                                   0x100018
+#define DE_BACKGROUND_COLOR                             31:0
+
+#define DE_STRETCH_FORMAT                               0x10001C
+#define DE_STRETCH_FORMAT_PATTERN_XY                    30:30
+#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL             0
+#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE          1
+#define DE_STRETCH_FORMAT_PATTERN_Y                     29:27
+#define DE_STRETCH_FORMAT_PATTERN_X                     25:23
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT                  21:20
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8                0
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16               1
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32               2
+#define DE_STRETCH_FORMAT_ADDRESSING                    19:16
+#define DE_STRETCH_FORMAT_ADDRESSING_XY                 0
+#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR             15
+#define DE_STRETCH_FORMAT_SOURCE_HEIGHT                 11:0
+
+#define DE_COLOR_COMPARE                                0x100020
+#define DE_COLOR_COMPARE_COLOR                          23:0
+
+#define DE_COLOR_COMPARE_MASK                           0x100024
+#define DE_COLOR_COMPARE_MASK_MASKS                     23:0
+
+#define DE_MASKS                                        0x100028
+#define DE_MASKS_BYTE_MASK                              31:16
+#define DE_MASKS_BIT_MASK                               15:0
+
+#define DE_CLIP_TL                                      0x10002C
+#define DE_CLIP_TL_TOP                                  31:16
+#define DE_CLIP_TL_STATUS                               13:13
+#define DE_CLIP_TL_STATUS_DISABLE                       0
+#define DE_CLIP_TL_STATUS_ENABLE                        1
+#define DE_CLIP_TL_INHIBIT                              12:12
+#define DE_CLIP_TL_INHIBIT_OUTSIDE                      0
+#define DE_CLIP_TL_INHIBIT_INSIDE                       1
+#define DE_CLIP_TL_LEFT                                 11:0
+
+#define DE_CLIP_BR                                      0x100030
+#define DE_CLIP_BR_BOTTOM                               31:16
+#define DE_CLIP_BR_RIGHT                                12:0
+
+#define DE_MONO_PATTERN_LOW                             0x100034
+#define DE_MONO_PATTERN_LOW_PATTERN                     31:0
+
+#define DE_MONO_PATTERN_HIGH                            0x100038
+#define DE_MONO_PATTERN_HIGH_PATTERN                    31:0
+
+#define DE_WINDOW_WIDTH                                 0x10003C
+#define DE_WINDOW_WIDTH_DESTINATION                     28:16
+#define DE_WINDOW_WIDTH_SOURCE                          12:0
+
+#define DE_WINDOW_SOURCE_BASE                           0x100040
+#define DE_WINDOW_SOURCE_BASE_EXT                       27:27
+#define DE_WINDOW_SOURCE_BASE_EXT_LOCAL                 0
+#define DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL              1
+#define DE_WINDOW_SOURCE_BASE_CS                        26:26
+#define DE_WINDOW_SOURCE_BASE_CS_0                      0
+#define DE_WINDOW_SOURCE_BASE_CS_1                      1
+#define DE_WINDOW_SOURCE_BASE_ADDRESS                   25:0
+
+#define DE_WINDOW_DESTINATION_BASE                      0x100044
+#define DE_WINDOW_DESTINATION_BASE_EXT                  27:27
+#define DE_WINDOW_DESTINATION_BASE_EXT_LOCAL            0
+#define DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL         1
+#define DE_WINDOW_DESTINATION_BASE_CS                   26:26
+#define DE_WINDOW_DESTINATION_BASE_CS_0                 0
+#define DE_WINDOW_DESTINATION_BASE_CS_1                 1
+#define DE_WINDOW_DESTINATION_BASE_ADDRESS              25:0
+
+#define DE_ALPHA                                        0x100048
+#define DE_ALPHA_VALUE                                  7:0
+
+#define DE_WRAP                                         0x10004C
+#define DE_WRAP_X                                       31:16
+#define DE_WRAP_Y                                       15:0
+
+#define DE_STATUS                                       0x100050
+#define DE_STATUS_CSC                                   1:1
+#define DE_STATUS_CSC_CLEAR                             0
+#define DE_STATUS_CSC_NOT_ACTIVE                        0
+#define DE_STATUS_CSC_ACTIVE                            1
+#define DE_STATUS_2D                                    0:0
+#define DE_STATUS_2D_CLEAR                              0
+#define DE_STATUS_2D_NOT_ACTIVE                         0
+#define DE_STATUS_2D_ACTIVE                             1
+#endif
+/* Color Space Conversion registers. */
+
+#define CSC_Y_SOURCE_BASE                               0x1000C8
+#define CSC_Y_SOURCE_BASE_EXT                           27:27
+#define CSC_Y_SOURCE_BASE_EXT_LOCAL                     0
+#define CSC_Y_SOURCE_BASE_EXT_EXTERNAL                  1
+#define CSC_Y_SOURCE_BASE_CS                            26:26
+#define CSC_Y_SOURCE_BASE_CS_0                          0
+#define CSC_Y_SOURCE_BASE_CS_1                          1
+#define CSC_Y_SOURCE_BASE_ADDRESS                       25:0
+
+#define CSC_CONSTANTS                                   0x1000CC
+#define CSC_CONSTANTS_Y                                 31:24
+#define CSC_CONSTANTS_R                                 23:16
+#define CSC_CONSTANTS_G                                 15:8
+#define CSC_CONSTANTS_B                                 7:0
+
+#define CSC_Y_SOURCE_X                                  0x1000D0
+#define CSC_Y_SOURCE_X_INTEGER                          26:16
+#define CSC_Y_SOURCE_X_FRACTION                         15:3
+
+#define CSC_Y_SOURCE_Y                                  0x1000D4
+#define CSC_Y_SOURCE_Y_INTEGER                          27:16
+#define CSC_Y_SOURCE_Y_FRACTION                         15:3
+
+#define CSC_U_SOURCE_BASE                               0x1000D8
+#define CSC_U_SOURCE_BASE_EXT                           27:27
+#define CSC_U_SOURCE_BASE_EXT_LOCAL                     0
+#define CSC_U_SOURCE_BASE_EXT_EXTERNAL                  1
+#define CSC_U_SOURCE_BASE_CS                            26:26
+#define CSC_U_SOURCE_BASE_CS_0                          0
+#define CSC_U_SOURCE_BASE_CS_1                          1
+#define CSC_U_SOURCE_BASE_ADDRESS                       25:0
+
+#define CSC_V_SOURCE_BASE                               0x1000DC
+#define CSC_V_SOURCE_BASE_EXT                           27:27
+#define CSC_V_SOURCE_BASE_EXT_LOCAL                     0
+#define CSC_V_SOURCE_BASE_EXT_EXTERNAL                  1
+#define CSC_V_SOURCE_BASE_CS                            26:26
+#define CSC_V_SOURCE_BASE_CS_0                          0
+#define CSC_V_SOURCE_BASE_CS_1                          1
+#define CSC_V_SOURCE_BASE_ADDRESS                       25:0
+
+#define CSC_SOURCE_DIMENSION                            0x1000E0
+#define CSC_SOURCE_DIMENSION_X                          31:16
+#define CSC_SOURCE_DIMENSION_Y                          15:0
+
+#define CSC_SOURCE_PITCH                                0x1000E4
+#define CSC_SOURCE_PITCH_Y                              31:16
+#define CSC_SOURCE_PITCH_UV                             15:0
+
+#define CSC_DESTINATION                                 0x1000E8
+#define CSC_DESTINATION_WRAP                            31:31
+#define CSC_DESTINATION_WRAP_DISABLE                    0
+#define CSC_DESTINATION_WRAP_ENABLE                     1
+#define CSC_DESTINATION_X                               27:16
+#define CSC_DESTINATION_Y                               11:0
+
+#define CSC_DESTINATION_DIMENSION                       0x1000EC
+#define CSC_DESTINATION_DIMENSION_X                     31:16
+#define CSC_DESTINATION_DIMENSION_Y                     15:0
+
+#define CSC_DESTINATION_PITCH                           0x1000F0
+#define CSC_DESTINATION_PITCH_X                         31:16
+#define CSC_DESTINATION_PITCH_Y                         15:0
+
+#define CSC_SCALE_FACTOR                                0x1000F4
+#define CSC_SCALE_FACTOR_HORIZONTAL                     31:16
+#define CSC_SCALE_FACTOR_VERTICAL                       15:0
+
+#define CSC_DESTINATION_BASE                            0x1000F8
+#define CSC_DESTINATION_BASE_EXT                        27:27
+#define CSC_DESTINATION_BASE_EXT_LOCAL                  0
+#define CSC_DESTINATION_BASE_EXT_EXTERNAL               1
+#define CSC_DESTINATION_BASE_CS                         26:26
+#define CSC_DESTINATION_BASE_CS_0                       0
+#define CSC_DESTINATION_BASE_CS_1                       1
+#define CSC_DESTINATION_BASE_ADDRESS                    25:0
+
+#define CSC_CONTROL                                     0x1000FC
+#define CSC_CONTROL_STATUS                              31:31
+#define CSC_CONTROL_STATUS_STOP                         0
+#define CSC_CONTROL_STATUS_START                        1
+#define CSC_CONTROL_SOURCE_FORMAT                       30:28
+#define CSC_CONTROL_SOURCE_FORMAT_YUV422                0
+#define CSC_CONTROL_SOURCE_FORMAT_YUV420I               1
+#define CSC_CONTROL_SOURCE_FORMAT_YUV420                2
+#define CSC_CONTROL_SOURCE_FORMAT_YVU9                  3
+#define CSC_CONTROL_SOURCE_FORMAT_IYU1                  4
+#define CSC_CONTROL_SOURCE_FORMAT_IYU2                  5
+#define CSC_CONTROL_SOURCE_FORMAT_RGB565                6
+#define CSC_CONTROL_SOURCE_FORMAT_RGB8888               7
+#define CSC_CONTROL_DESTINATION_FORMAT                  27:26
+#define CSC_CONTROL_DESTINATION_FORMAT_RGB565           0
+#define CSC_CONTROL_DESTINATION_FORMAT_RGB8888          1
+#define CSC_CONTROL_HORIZONTAL_FILTER                   25:25
+#define CSC_CONTROL_HORIZONTAL_FILTER_DISABLE           0
+#define CSC_CONTROL_HORIZONTAL_FILTER_ENABLE            1
+#define CSC_CONTROL_VERTICAL_FILTER                     24:24
+#define CSC_CONTROL_VERTICAL_FILTER_DISABLE             0
+#define CSC_CONTROL_VERTICAL_FILTER_ENABLE              1
+#define CSC_CONTROL_BYTE_ORDER                          23:23
+#define CSC_CONTROL_BYTE_ORDER_YUYV                     0
+#define CSC_CONTROL_BYTE_ORDER_UYVY                     1
+
+#define DE_DATA_PORT                                    0x110000
+
+#define I2C_BYTE_COUNT                                  0x010040
+#define I2C_BYTE_COUNT_COUNT                            3:0
+
+#define I2C_CTRL                                        0x010041
+#define I2C_CTRL_INT                                    4:4
+#define I2C_CTRL_INT_DISABLE                            0
+#define I2C_CTRL_INT_ENABLE                             1
+#define I2C_CTRL_DIR                                    3:3
+#define I2C_CTRL_DIR_WR                                 0
+#define I2C_CTRL_DIR_RD                                 1
+#define I2C_CTRL_CTRL                                   2:2
+#define I2C_CTRL_CTRL_STOP                              0
+#define I2C_CTRL_CTRL_START                             1
+#define I2C_CTRL_MODE                                   1:1
+#define I2C_CTRL_MODE_STANDARD                          0
+#define I2C_CTRL_MODE_FAST                              1
+#define I2C_CTRL_EN                                     0:0
+#define I2C_CTRL_EN_DISABLE                             0
+#define I2C_CTRL_EN_ENABLE                              1
+
+#define I2C_STATUS                                      0x010042
+#define I2C_STATUS_TX                                   3:3
+#define I2C_STATUS_TX_PROGRESS                          0
+#define I2C_STATUS_TX_COMPLETED                         1
+#define I2C_TX_DONE                                     0x08
+#define I2C_STATUS_ERR                                  2:2
+#define I2C_STATUS_ERR_NORMAL                           0
+#define I2C_STATUS_ERR_ERROR                            1
+#define I2C_STATUS_ERR_CLEAR                            0
+#define I2C_STATUS_ACK                                  1:1
+#define I2C_STATUS_ACK_RECEIVED                         0
+#define I2C_STATUS_ACK_NOT                              1
+#define I2C_STATUS_BSY                                  0:0
+#define I2C_STATUS_BSY_IDLE                             0
+#define I2C_STATUS_BSY_BUSY                             1
+
+#define I2C_RESET                                       0x010042
+#define I2C_RESET_BUS_ERROR                             2:2
+#define I2C_RESET_BUS_ERROR_CLEAR                       0
+
+#define I2C_SLAVE_ADDRESS                               0x010043
+#define I2C_SLAVE_ADDRESS_ADDRESS                       7:1
+#define I2C_SLAVE_ADDRESS_RW                            0:0
+#define I2C_SLAVE_ADDRESS_RW_W                          0
+#define I2C_SLAVE_ADDRESS_RW_R                          1
+
+#define I2C_DATA0                                       0x010044
+#define I2C_DATA1                                       0x010045
+#define I2C_DATA2                                       0x010046
+#define I2C_DATA3                                       0x010047
+#define I2C_DATA4                                       0x010048
+#define I2C_DATA5                                       0x010049
+#define I2C_DATA6                                       0x01004A
+#define I2C_DATA7                                       0x01004B
+#define I2C_DATA8                                       0x01004C
+#define I2C_DATA9                                       0x01004D
+#define I2C_DATA10                                      0x01004E
+#define I2C_DATA11                                      0x01004F
+#define I2C_DATA12                                      0x010050
+#define I2C_DATA13                                      0x010051
+#define I2C_DATA14                                      0x010052
+#define I2C_DATA15                                      0x010053
+
+
+#define ZV0_CAPTURE_CTRL                                0x090000
+#define ZV0_CAPTURE_CTRL_FIELD_INPUT                    27:27
+#define ZV0_CAPTURE_CTRL_FIELD_INPUT_EVEN_FIELD         0
+#define ZV0_CAPTURE_CTRL_FIELD_INPUT_ODD_FIELD          1
+#define ZV0_CAPTURE_CTRL_SCAN                           26:26
+#define ZV0_CAPTURE_CTRL_SCAN_PROGRESSIVE               0
+#define ZV0_CAPTURE_CTRL_SCAN_INTERLACE                 1
+#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER                 25:25
+#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER_0               0
+#define ZV0_CAPTURE_CTRL_CURRENT_BUFFER_1               1
+#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC                  24:24
+#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC_INACTIVE         0
+#define ZV0_CAPTURE_CTRL_VERTICAL_SYNC_ACTIVE           1
+#define ZV0_CAPTURE_CTRL_ADJ                            19:19
+#define ZV0_CAPTURE_CTRL_ADJ_NORMAL                     0
+#define ZV0_CAPTURE_CTRL_ADJ_DELAY                      1
+#define ZV0_CAPTURE_CTRL_HA                             18:18
+#define ZV0_CAPTURE_CTRL_HA_DISABLE                     0
+#define ZV0_CAPTURE_CTRL_HA_ENABLE                      1
+#define ZV0_CAPTURE_CTRL_VSK                            17:17
+#define ZV0_CAPTURE_CTRL_VSK_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_VSK_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_HSK                            16:16
+#define ZV0_CAPTURE_CTRL_HSK_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_HSK_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_FD                             15:15
+#define ZV0_CAPTURE_CTRL_FD_RISING                      0
+#define ZV0_CAPTURE_CTRL_FD_FALLING                     1
+#define ZV0_CAPTURE_CTRL_VP                             14:14
+#define ZV0_CAPTURE_CTRL_VP_HIGH                        0
+#define ZV0_CAPTURE_CTRL_VP_LOW                         1
+#define ZV0_CAPTURE_CTRL_HP                             13:13
+#define ZV0_CAPTURE_CTRL_HP_HIGH                        0
+#define ZV0_CAPTURE_CTRL_HP_LOW                         1
+#define ZV0_CAPTURE_CTRL_CP                             12:12
+#define ZV0_CAPTURE_CTRL_CP_HIGH                        0
+#define ZV0_CAPTURE_CTRL_CP_LOW                         1
+#define ZV0_CAPTURE_CTRL_UVS                            11:11
+#define ZV0_CAPTURE_CTRL_UVS_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_UVS_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_BS                             10:10
+#define ZV0_CAPTURE_CTRL_BS_DISABLE                     0
+#define ZV0_CAPTURE_CTRL_BS_ENABLE                      1
+#define ZV0_CAPTURE_CTRL_CS                             9:9
+#define ZV0_CAPTURE_CTRL_CS_16                          0
+#define ZV0_CAPTURE_CTRL_CS_8                           1
+#define ZV0_CAPTURE_CTRL_CF                             8:8
+#define ZV0_CAPTURE_CTRL_CF_YUV                         0
+#define ZV0_CAPTURE_CTRL_CF_RGB                         1
+#define ZV0_CAPTURE_CTRL_FS                             7:7
+#define ZV0_CAPTURE_CTRL_FS_DISABLE                     0
+#define ZV0_CAPTURE_CTRL_FS_ENABLE                      1
+#define ZV0_CAPTURE_CTRL_WEAVE                          6:6
+#define ZV0_CAPTURE_CTRL_WEAVE_DISABLE                  0
+#define ZV0_CAPTURE_CTRL_WEAVE_ENABLE                   1
+#define ZV0_CAPTURE_CTRL_BOB                            5:5
+#define ZV0_CAPTURE_CTRL_BOB_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_BOB_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_DB                             4:4
+#define ZV0_CAPTURE_CTRL_DB_DISABLE                     0
+#define ZV0_CAPTURE_CTRL_DB_ENABLE                      1
+#define ZV0_CAPTURE_CTRL_CC                             3:3
+#define ZV0_CAPTURE_CTRL_CC_CONTINUE                    0
+#define ZV0_CAPTURE_CTRL_CC_CONDITION                   1
+#define ZV0_CAPTURE_CTRL_RGB                            2:2
+#define ZV0_CAPTURE_CTRL_RGB_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_RGB_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_656                            1:1
+#define ZV0_CAPTURE_CTRL_656_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_656_ENABLE                     1
+#define ZV0_CAPTURE_CTRL_CAP                            0:0
+#define ZV0_CAPTURE_CTRL_CAP_DISABLE                    0
+#define ZV0_CAPTURE_CTRL_CAP_ENABLE                     1
+
+#define ZV0_CAPTURE_CLIP                                0x090004
+#define ZV0_CAPTURE_CLIP_YCLIP_EVEN_FIELD                25:16
+#define ZV0_CAPTURE_CLIP_YCLIP                          25:16
+#define ZV0_CAPTURE_CLIP_XCLIP                          9:0
+
+#define ZV0_CAPTURE_SIZE                                0x090008
+#define ZV0_CAPTURE_SIZE_HEIGHT                         26:16
+#define ZV0_CAPTURE_SIZE_WIDTH                          10:0
+
+#define ZV0_CAPTURE_BUF0_ADDRESS                        0x09000C
+#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS                 31:31
+#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS_CURRENT         0
+#define ZV0_CAPTURE_BUF0_ADDRESS_STATUS_PENDING         1
+#define ZV0_CAPTURE_BUF0_ADDRESS_EXT                    27:27
+#define ZV0_CAPTURE_BUF0_ADDRESS_EXT_LOCAL              0
+#define ZV0_CAPTURE_BUF0_ADDRESS_EXT_EXTERNAL           1
+#define ZV0_CAPTURE_BUF0_ADDRESS_CS                     26:26
+#define ZV0_CAPTURE_BUF0_ADDRESS_CS_0                   0
+#define ZV0_CAPTURE_BUF0_ADDRESS_CS_1                   1
+#define ZV0_CAPTURE_BUF0_ADDRESS_ADDRESS                25:0
+
+#define ZV0_CAPTURE_BUF1_ADDRESS                        0x090010
+#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS                 31:31
+#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS_CURRENT         0
+#define ZV0_CAPTURE_BUF1_ADDRESS_STATUS_PENDING         1
+#define ZV0_CAPTURE_BUF1_ADDRESS_EXT                    27:27
+#define ZV0_CAPTURE_BUF1_ADDRESS_EXT_LOCAL              0
+#define ZV0_CAPTURE_BUF1_ADDRESS_EXT_EXTERNAL           1
+#define ZV0_CAPTURE_BUF1_ADDRESS_CS                     26:26
+#define ZV0_CAPTURE_BUF1_ADDRESS_CS_0                   0
+#define ZV0_CAPTURE_BUF1_ADDRESS_CS_1                   1
+#define ZV0_CAPTURE_BUF1_ADDRESS_ADDRESS                25:0
+
+#define ZV0_CAPTURE_BUF_OFFSET                          0x090014
+#ifndef VALIDATION_CHIP
+    #define ZV0_CAPTURE_BUF_OFFSET_YCLIP_ODD_FIELD      25:16
+#endif
+#define ZV0_CAPTURE_BUF_OFFSET_OFFSET                   15:0
+
+#define ZV0_CAPTURE_FIFO_CTRL                           0x090018
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO                      2:0
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_0                    0
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_1                    1
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_2                    2
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_3                    3
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_4                    4
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_5                    5
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_6                    6
+#define ZV0_CAPTURE_FIFO_CTRL_FIFO_7                    7
+
+#define ZV0_CAPTURE_YRGB_CONST                          0x09001C
+#define ZV0_CAPTURE_YRGB_CONST_Y                        31:24
+#define ZV0_CAPTURE_YRGB_CONST_R                        23:16
+#define ZV0_CAPTURE_YRGB_CONST_G                        15:8
+#define ZV0_CAPTURE_YRGB_CONST_B                        7:0
+
+#define ZV0_CAPTURE_LINE_COMP                           0x090020
+#define ZV0_CAPTURE_LINE_COMP_LC                        10:0
+
+/* ZV1 */
+
+#define ZV1_CAPTURE_CTRL                                0x098000
+#define ZV1_CAPTURE_CTRL_FIELD_INPUT                    27:27
+#define ZV1_CAPTURE_CTRL_FIELD_INPUT_EVEN_FIELD         0
+#define ZV1_CAPTURE_CTRL_FIELD_INPUT_ODD_FIELD          0
+#define ZV1_CAPTURE_CTRL_SCAN                           26:26
+#define ZV1_CAPTURE_CTRL_SCAN_PROGRESSIVE               0
+#define ZV1_CAPTURE_CTRL_SCAN_INTERLACE                 1
+#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER                 25:25
+#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER_0               0
+#define ZV1_CAPTURE_CTRL_CURRENT_BUFFER_1               1
+#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC                  24:24
+#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC_INACTIVE         0
+#define ZV1_CAPTURE_CTRL_VERTICAL_SYNC_ACTIVE           1
+#define ZV1_CAPTURE_CTRL_PANEL                          20:20
+#define ZV1_CAPTURE_CTRL_PANEL_DISABLE                  0
+#define ZV1_CAPTURE_CTRL_PANEL_ENABLE                   1
+#define ZV1_CAPTURE_CTRL_ADJ                            19:19
+#define ZV1_CAPTURE_CTRL_ADJ_NORMAL                     0
+#define ZV1_CAPTURE_CTRL_ADJ_DELAY                      1
+#define ZV1_CAPTURE_CTRL_HA                             18:18
+#define ZV1_CAPTURE_CTRL_HA_DISABLE                     0
+#define ZV1_CAPTURE_CTRL_HA_ENABLE                      1
+#define ZV1_CAPTURE_CTRL_VSK                            17:17
+#define ZV1_CAPTURE_CTRL_VSK_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_VSK_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_HSK                            16:16
+#define ZV1_CAPTURE_CTRL_HSK_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_HSK_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_FD                             15:15
+#define ZV1_CAPTURE_CTRL_FD_RISING                      0
+#define ZV1_CAPTURE_CTRL_FD_FALLING                     1
+#define ZV1_CAPTURE_CTRL_VP                             14:14
+#define ZV1_CAPTURE_CTRL_VP_HIGH                        0
+#define ZV1_CAPTURE_CTRL_VP_LOW                         1
+#define ZV1_CAPTURE_CTRL_HP                             13:13
+#define ZV1_CAPTURE_CTRL_HP_HIGH                        0
+#define ZV1_CAPTURE_CTRL_HP_LOW                         1
+#define ZV1_CAPTURE_CTRL_CP                             12:12
+#define ZV1_CAPTURE_CTRL_CP_HIGH                        0
+#define ZV1_CAPTURE_CTRL_CP_LOW                         1
+#define ZV1_CAPTURE_CTRL_UVS                            11:11
+#define ZV1_CAPTURE_CTRL_UVS_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_UVS_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_BS                             10:10
+#define ZV1_CAPTURE_CTRL_BS_DISABLE                     0
+#define ZV1_CAPTURE_CTRL_BS_ENABLE                      1
+#define ZV1_CAPTURE_CTRL_CS                             9:9
+#define ZV1_CAPTURE_CTRL_CS_16                          0
+#define ZV1_CAPTURE_CTRL_CS_8                           1
+#define ZV1_CAPTURE_CTRL_CF                             8:8
+#define ZV1_CAPTURE_CTRL_CF_YUV                         0
+#define ZV1_CAPTURE_CTRL_CF_RGB                         1
+#define ZV1_CAPTURE_CTRL_FS                             7:7
+#define ZV1_CAPTURE_CTRL_FS_DISABLE                     0
+#define ZV1_CAPTURE_CTRL_FS_ENABLE                      1
+#define ZV1_CAPTURE_CTRL_WEAVE                          6:6
+#define ZV1_CAPTURE_CTRL_WEAVE_DISABLE                  0
+#define ZV1_CAPTURE_CTRL_WEAVE_ENABLE                   1
+#define ZV1_CAPTURE_CTRL_BOB                            5:5
+#define ZV1_CAPTURE_CTRL_BOB_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_BOB_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_DB                             4:4
+#define ZV1_CAPTURE_CTRL_DB_DISABLE                     0
+#define ZV1_CAPTURE_CTRL_DB_ENABLE                      1
+#define ZV1_CAPTURE_CTRL_CC                             3:3
+#define ZV1_CAPTURE_CTRL_CC_CONTINUE                    0
+#define ZV1_CAPTURE_CTRL_CC_CONDITION                   1
+#define ZV1_CAPTURE_CTRL_RGB                            2:2
+#define ZV1_CAPTURE_CTRL_RGB_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_RGB_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_656                            1:1
+#define ZV1_CAPTURE_CTRL_656_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_656_ENABLE                     1
+#define ZV1_CAPTURE_CTRL_CAP                            0:0
+#define ZV1_CAPTURE_CTRL_CAP_DISABLE                    0
+#define ZV1_CAPTURE_CTRL_CAP_ENABLE                     1
+
+#define ZV1_CAPTURE_CLIP                                0x098004
+#define ZV1_CAPTURE_CLIP_YCLIP                          25:16
+#define ZV1_CAPTURE_CLIP_XCLIP                          9:0
+
+#define ZV1_CAPTURE_SIZE                                0x098008
+#define ZV1_CAPTURE_SIZE_HEIGHT                         26:16
+#define ZV1_CAPTURE_SIZE_WIDTH                          10:0
+
+#define ZV1_CAPTURE_BUF0_ADDRESS                        0x09800C
+#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS                 31:31
+#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS_CURRENT         0
+#define ZV1_CAPTURE_BUF0_ADDRESS_STATUS_PENDING         1
+#define ZV1_CAPTURE_BUF0_ADDRESS_EXT                    27:27
+#define ZV1_CAPTURE_BUF0_ADDRESS_EXT_LOCAL              0
+#define ZV1_CAPTURE_BUF0_ADDRESS_EXT_EXTERNAL           1
+#define ZV1_CAPTURE_BUF0_ADDRESS_CS                     26:26
+#define ZV1_CAPTURE_BUF0_ADDRESS_CS_0                   0
+#define ZV1_CAPTURE_BUF0_ADDRESS_CS_1                   1
+#define ZV1_CAPTURE_BUF0_ADDRESS_ADDRESS                25:0
+
+#define ZV1_CAPTURE_BUF1_ADDRESS                        0x098010
+#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS                 31:31
+#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS_CURRENT         0
+#define ZV1_CAPTURE_BUF1_ADDRESS_STATUS_PENDING         1
+#define ZV1_CAPTURE_BUF1_ADDRESS_EXT                    27:27
+#define ZV1_CAPTURE_BUF1_ADDRESS_EXT_LOCAL              0
+#define ZV1_CAPTURE_BUF1_ADDRESS_EXT_EXTERNAL           1
+#define ZV1_CAPTURE_BUF1_ADDRESS_CS                     26:26
+#define ZV1_CAPTURE_BUF1_ADDRESS_CS_0                   0
+#define ZV1_CAPTURE_BUF1_ADDRESS_CS_1                   1
+#define ZV1_CAPTURE_BUF1_ADDRESS_ADDRESS                25:0
+
+#define ZV1_CAPTURE_BUF_OFFSET                          0x098014
+#define ZV1_CAPTURE_BUF_OFFSET_OFFSET                   15:0
+
+#define ZV1_CAPTURE_FIFO_CTRL                           0x098018
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO                      2:0
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_0                    0
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_1                    1
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_2                    2
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_3                    3
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_4                    4
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_5                    5
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_6                    6
+#define ZV1_CAPTURE_FIFO_CTRL_FIFO_7                    7
+
+#define ZV1_CAPTURE_YRGB_CONST                          0x09801C
+#define ZV1_CAPTURE_YRGB_CONST_Y                        31:24
+#define ZV1_CAPTURE_YRGB_CONST_R                        23:16
+#define ZV1_CAPTURE_YRGB_CONST_G                        15:8
+#define ZV1_CAPTURE_YRGB_CONST_B                        7:0
+
+#define DMA_1_SOURCE                                    0x0D0010
+#define DMA_1_SOURCE_ADDRESS_EXT                        27:27
+#define DMA_1_SOURCE_ADDRESS_EXT_LOCAL                  0
+#define DMA_1_SOURCE_ADDRESS_EXT_EXTERNAL               1
+#define DMA_1_SOURCE_ADDRESS_CS                         26:26
+#define DMA_1_SOURCE_ADDRESS_CS_0                       0
+#define DMA_1_SOURCE_ADDRESS_CS_1                       1
+#define DMA_1_SOURCE_ADDRESS                            25:0
+
+#define DMA_1_DESTINATION                               0x0D0014
+#define DMA_1_DESTINATION_ADDRESS_EXT                   27:27
+#define DMA_1_DESTINATION_ADDRESS_EXT_LOCAL             0
+#define DMA_1_DESTINATION_ADDRESS_EXT_EXTERNAL          1
+#define DMA_1_DESTINATION_ADDRESS_CS                    26:26
+#define DMA_1_DESTINATION_ADDRESS_CS_0                  0
+#define DMA_1_DESTINATION_ADDRESS_CS_1                  1
+#define DMA_1_DESTINATION_ADDRESS                       25:0
+
+#define DMA_1_SIZE_CONTROL                              0x0D0018
+#define DMA_1_SIZE_CONTROL_STATUS                       31:31
+#define DMA_1_SIZE_CONTROL_STATUS_IDLE                  0
+#define DMA_1_SIZE_CONTROL_STATUS_ACTIVE                1
+#define DMA_1_SIZE_CONTROL_SIZE                         23:0
+
+#define DMA_ABORT_INTERRUPT                             0x0D0020
+#define DMA_ABORT_INTERRUPT_ABORT_1                     5:5
+#define DMA_ABORT_INTERRUPT_ABORT_1_ENABLE              0
+#define DMA_ABORT_INTERRUPT_ABORT_1_ABORT               1
+#define DMA_ABORT_INTERRUPT_ABORT_0                     4:4
+#define DMA_ABORT_INTERRUPT_ABORT_0_ENABLE              0
+#define DMA_ABORT_INTERRUPT_ABORT_0_ABORT               1
+#define DMA_ABORT_INTERRUPT_INT_1                       1:1
+#define DMA_ABORT_INTERRUPT_INT_1_CLEAR                 0
+#define DMA_ABORT_INTERRUPT_INT_1_FINISHED              1
+#define DMA_ABORT_INTERRUPT_INT_0                       0:0
+#define DMA_ABORT_INTERRUPT_INT_0_CLEAR                 0
+#define DMA_ABORT_INTERRUPT_INT_0_FINISHED              1
+
+
+
+
+
+/* Default i2c CLK and Data GPIO. These are the default i2c pins */
+#define DEFAULT_I2C_SCL                     30
+#define DEFAULT_I2C_SDA                     31
+
+
+#define GPIO_DATA_SM750LE                               0x020018
+#define GPIO_DATA_SM750LE_1                             1:1
+#define GPIO_DATA_SM750LE_0                             0:0
+
+#define GPIO_DATA_DIRECTION_SM750LE                     0x02001C
+#define GPIO_DATA_DIRECTION_SM750LE_1                   1:1
+#define GPIO_DATA_DIRECTION_SM750LE_1_INPUT             0
+#define GPIO_DATA_DIRECTION_SM750LE_1_OUTPUT            1
+#define GPIO_DATA_DIRECTION_SM750LE_0                   0:0
+#define GPIO_DATA_DIRECTION_SM750LE_0_INPUT             0
+#define GPIO_DATA_DIRECTION_SM750LE_0_OUTPUT            1
+
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c
new file mode 100644 (file)
index 0000000..3d224d6
--- /dev/null
@@ -0,0 +1,425 @@
+#define USE_DVICHIP
+#ifdef USE_DVICHIP
+
+#include "ddk750_sii164.h"
+#include "ddk750_hwi2c.h"
+
+/* I2C Address of each SII164 chip */
+#define SII164_I2C_ADDRESS                  0x70
+
+/* Define this definition to use hardware i2c. */
+#define USE_HW_I2C
+
+#ifdef USE_HW_I2C
+    #define i2cWriteReg hwI2CWriteReg
+    #define i2cReadReg  hwI2CReadReg
+#else
+    #define i2cWriteReg swI2CWriteReg
+    #define i2cReadReg  swI2CReadReg
+#endif
+
+/* SII164 Vendor and Device ID */
+#define SII164_VENDOR_ID                    0x0001
+#define SII164_DEVICE_ID                    0x0006
+
+#ifdef SII164_FULL_FUNCTIONS
+/* Name of the DVI Controller chip */
+static char *gDviCtrlChipName = "Silicon Image SiI 164";
+#endif
+
+/*
+ *  sii164GetVendorID
+ *      This function gets the vendor ID of the DVI controller chip.
+ *
+ *  Output:
+ *      Vendor ID
+ */
+unsigned short sii164GetVendorID(void)
+{
+    unsigned short vendorID;
+
+    vendorID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_HIGH) << 8) |
+                (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_LOW);
+
+    return vendorID;
+}
+
+/*
+ *  sii164GetDeviceID
+ *      This function gets the device ID of the DVI controller chip.
+ *
+ *  Output:
+ *      Device ID
+ */
+unsigned short sii164GetDeviceID(void)
+{
+    unsigned short deviceID;
+
+    deviceID = ((unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_HIGH) << 8) |
+                (unsigned short) i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_LOW);
+
+    return deviceID;
+}
+
+
+
+/* DVI.C will handle all SiI164 chip stuffs and try it best to make code minimal and useful */
+
+/*
+ *  sii164InitChip
+ *      This function initialize and detect the DVI controller chip.
+ *
+ *  Input:
+ *      edgeSelect          - Edge Select:
+ *                              0 = Input data is falling edge latched (falling edge
+ *                                  latched first in dual edge mode)
+ *                              1 = Input data is rising edge latched (rising edge
+ *                                  latched first in dual edge mode)
+ *      busSelect           - Input Bus Select:
+ *                              0 = Input data bus is 12-bits wide
+ *                              1 = Input data bus is 24-bits wide
+ *      dualEdgeClkSelect   - Dual Edge Clock Select
+ *                              0 = Input data is single edge latched
+ *                              1 = Input data is dual edge latched
+ *      hsyncEnable         - Horizontal Sync Enable:
+ *                              0 = HSYNC input is transmitted as fixed LOW
+ *                              1 = HSYNC input is transmitted as is
+ *      vsyncEnable         - Vertical Sync Enable:
+ *                              0 = VSYNC input is transmitted as fixed LOW
+ *                              1 = VSYNC input is transmitted as is
+ *      deskewEnable        - De-skewing Enable:
+ *                              0 = De-skew disabled
+ *                              1 = De-skew enabled
+ *      deskewSetting       - De-skewing Setting (increment of 260psec)
+ *                              0 = 1 step --> minimum setup / maximum hold
+ *                              1 = 2 step
+ *                              2 = 3 step
+ *                              3 = 4 step
+ *                              4 = 5 step
+ *                              5 = 6 step
+ *                              6 = 7 step
+ *                              7 = 8 step --> maximum setup / minimum hold
+ *      continuousSyncEnable- SYNC Continuous:
+ *                              0 = Disable
+ *                              1 = Enable
+ *      pllFilterEnable     - PLL Filter Enable
+ *                              0 = Disable PLL Filter
+ *                              1 = Enable PLL Filter
+ *      pllFilterValue      - PLL Filter characteristics:
+ *                              0~7 (recommended value is 4)
+ *
+ *  Output:
+ *      0   - Success
+ *     -1   - Fail.
+ */
+long sii164InitChip(
+    unsigned char edgeSelect,
+    unsigned char busSelect,
+    unsigned char dualEdgeClkSelect,
+    unsigned char hsyncEnable,
+    unsigned char vsyncEnable,
+    unsigned char deskewEnable,
+    unsigned char deskewSetting,
+    unsigned char continuousSyncEnable,
+    unsigned char pllFilterEnable,
+    unsigned char pllFilterValue
+)
+{
+    //unsigned char ucRegIndex, ucRegValue;
+    //unsigned char ucDeviceAddress,
+       unsigned char config;
+    //unsigned long delayCount;
+
+    /* Initialize the i2c bus */
+#ifdef USE_HW_I2C
+    /* Use fast mode. */
+    hwI2CInit(1);
+#else
+    swI2CInit(DEFAULT_I2C_SCL, DEFAULT_I2C_SDA);
+#endif
+
+    /* Check if SII164 Chip exists */
+    if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID))
+    {
+
+#ifdef DDKDEBUG
+        //sii164PrintRegisterValues();
+#endif
+        /*
+         *  Initialize SII164 controller chip.
+         */
+
+        /* Select the edge */
+        if (edgeSelect == 0)
+            config = SII164_CONFIGURATION_LATCH_FALLING;
+        else
+            config = SII164_CONFIGURATION_LATCH_RISING;
+
+        /* Select bus wide */
+        if (busSelect == 0)
+            config |= SII164_CONFIGURATION_BUS_12BITS;
+        else
+            config |= SII164_CONFIGURATION_BUS_24BITS;
+
+        /* Select Dual/Single Edge Clock */
+        if (dualEdgeClkSelect == 0)
+            config |= SII164_CONFIGURATION_CLOCK_SINGLE;
+        else
+            config |= SII164_CONFIGURATION_CLOCK_DUAL;
+
+        /* Select HSync Enable */
+        if (hsyncEnable == 0)
+            config |= SII164_CONFIGURATION_HSYNC_FORCE_LOW;
+        else
+            config |= SII164_CONFIGURATION_HSYNC_AS_IS;
+
+        /* Select VSync Enable */
+        if (vsyncEnable == 0)
+            config |= SII164_CONFIGURATION_VSYNC_FORCE_LOW;
+        else
+            config |= SII164_CONFIGURATION_VSYNC_AS_IS;
+
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+
+        /* De-skew enabled with default 111b value.
+           This will fix some artifacts problem in some mode on board 2.2.
+           Somehow this fix does not affect board 2.1.
+         */
+        if (deskewEnable == 0)
+            config = SII164_DESKEW_DISABLE;
+        else
+            config = SII164_DESKEW_ENABLE;
+
+        switch (deskewSetting)
+        {
+            case 0:
+                config |= SII164_DESKEW_1_STEP;
+                break;
+            case 1:
+                config |= SII164_DESKEW_2_STEP;
+                break;
+            case 2:
+                config |= SII164_DESKEW_3_STEP;
+                break;
+            case 3:
+                config |= SII164_DESKEW_4_STEP;
+                break;
+            case 4:
+                config |= SII164_DESKEW_5_STEP;
+                break;
+            case 5:
+                config |= SII164_DESKEW_6_STEP;
+                break;
+            case 6:
+                config |= SII164_DESKEW_7_STEP;
+                break;
+            case 7:
+                config |= SII164_DESKEW_8_STEP;
+                break;
+        }
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_DESKEW, config);
+
+        /* Enable/Disable Continuous Sync. */
+        if (continuousSyncEnable == 0)
+            config = SII164_PLL_FILTER_SYNC_CONTINUOUS_DISABLE;
+        else
+            config = SII164_PLL_FILTER_SYNC_CONTINUOUS_ENABLE;
+
+        /* Enable/Disable PLL Filter */
+        if (pllFilterEnable == 0)
+            config |= SII164_PLL_FILTER_DISABLE;
+        else
+            config |= SII164_PLL_FILTER_ENABLE;
+
+        /* Set the PLL Filter value */
+        config |= ((pllFilterValue & 0x07) << 1);
+
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_PLL, config);
+
+        /* Recover from Power Down and enable output. */
+        config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
+        config |= SII164_CONFIGURATION_POWER_NORMAL;
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+
+#ifdef DDKDEBUG
+        //sii164PrintRegisterValues();
+#endif
+
+        return 0;
+    }
+
+    /* Return -1 if initialization fails. */
+    return (-1);
+}
+
+
+
+
+
+/* below sii164 function is not neccessary */
+
+#ifdef SII164_FULL_FUNCTIONS
+
+/*
+ *  sii164ResetChip
+ *      This function resets the DVI Controller Chip.
+ */
+void sii164ResetChip(void)
+{
+    /* Power down */
+    sii164SetPower(0);
+    sii164SetPower(1);
+}
+
+
+/*
+ * sii164GetChipString
+ *      This function returns a char string name of the current DVI Controller chip.
+ *      It's convenient for application need to display the chip name.
+ */
+char *sii164GetChipString(void)
+{
+    return gDviCtrlChipName;
+}
+
+
+/*
+ *  sii164SetPower
+ *      This function sets the power configuration of the DVI Controller Chip.
+ *
+ *  Input:
+ *      powerUp - Flag to set the power down or up
+ */
+void sii164SetPower(
+    unsigned char powerUp
+)
+{
+    unsigned char config;
+
+    config = i2cReadReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION);
+    if (powerUp == 1)
+    {
+        /* Power up the chip */
+        config &= ~SII164_CONFIGURATION_POWER_MASK;
+        config |= SII164_CONFIGURATION_POWER_NORMAL;
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+    }
+    else
+    {
+        /* Power down the chip */
+        config &= ~SII164_CONFIGURATION_POWER_MASK;
+        config |= SII164_CONFIGURATION_POWER_DOWN;
+        i2cWriteReg(SII164_I2C_ADDRESS, SII164_CONFIGURATION, config);
+    }
+}
+
+
+/*
+ *  sii164SelectHotPlugDetectionMode
+ *      This function selects the mode of the hot plug detection.
+ */
+static void sii164SelectHotPlugDetectionMode(
+    sii164_hot_plug_mode_t hotPlugMode
+)
+{
+    unsigned char detectReg;
+
+    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & ~SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG;
+    switch (hotPlugMode)
+    {
+        case SII164_HOTPLUG_DISABLE:
+            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HIGH;
+            break;
+        case SII164_HOTPLUG_USE_MDI:
+            detectReg &= ~SII164_DETECT_INTERRUPT_MASK;
+            detectReg |= SII164_DETECT_INTERRUPT_BY_HTPLG_PIN;
+            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_MDI;
+            break;
+        case SII164_HOTPLUG_USE_RSEN:
+            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_RSEN;
+            break;
+        case SII164_HOTPLUG_USE_HTPLG:
+            detectReg |= SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG;
+            break;
+    }
+
+    i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg);
+}
+
+/*
+ *  sii164EnableHotPlugDetection
+ *      This function enables the Hot Plug detection.
+ *
+ *  enableHotPlug   - Enable (=1) / disable (=0) Hot Plug detection
+ */
+void sii164EnableHotPlugDetection(
+    unsigned char enableHotPlug
+)
+{
+    unsigned char detectReg;
+    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
+
+    /* Depending on each DVI controller, need to enable the hot plug based on each
+       individual chip design. */
+    if (enableHotPlug != 0)
+        sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI);
+    else
+        sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_DISABLE);
+}
+
+/*
+ *  sii164IsConnected
+ *      Check if the DVI Monitor is connected.
+ *
+ *  Output:
+ *      0   - Not Connected
+ *      1   - Connected
+ */
+unsigned char sii164IsConnected(void)
+{
+    unsigned char hotPlugValue;
+
+    hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_HOT_PLUG_STATUS_MASK;
+    if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON)
+        return 1;
+    else
+        return 0;
+}
+
+/*
+ *  sii164CheckInterrupt
+ *      Checks if interrupt has occured.
+ *
+ *  Output:
+ *      0   - No interrupt
+ *      1   - Interrupt occurs
+ */
+unsigned char sii164CheckInterrupt(void)
+{
+    unsigned char detectReg;
+
+    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_MONITOR_STATE_MASK;
+    if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE)
+        return 1;
+    else
+        return 0;
+}
+
+/*
+ *  sii164ClearInterrupt
+ *      Clear the hot plug interrupt.
+ */
+void sii164ClearInterrupt(void)
+{
+    unsigned char detectReg;
+
+    /* Clear the MDI interrupt */
+    detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT);
+    i2cWriteReg(SII164_I2C_ADDRESS, SII164_DETECT, detectReg | SII164_DETECT_MONITOR_STATE_CLEAR);
+}
+
+#endif
+
+#endif
+
+
diff --git a/drivers/staging/sm750fb/ddk750_sii164.h b/drivers/staging/sm750fb/ddk750_sii164.h
new file mode 100644 (file)
index 0000000..2b4c7d3
--- /dev/null
@@ -0,0 +1,172 @@
+#ifndef DDK750_SII164_H__
+#define DDK750_SII164_H__
+
+#define USE_DVICHIP
+
+/* Hot Plug detection mode structure */
+typedef enum _sii164_hot_plug_mode_t
+{
+    SII164_HOTPLUG_DISABLE = 0,         /* Disable Hot Plug output bit (always high). */
+    SII164_HOTPLUG_USE_MDI,             /* Use Monitor Detect Interrupt bit. */
+    SII164_HOTPLUG_USE_RSEN,            /* Use Receiver Sense detect bit. */
+    SII164_HOTPLUG_USE_HTPLG            /* Use Hot Plug detect bit. */
+} sii164_hot_plug_mode_t;
+
+
+/* Silicon Image SiI164 chip prototype */
+long sii164InitChip(
+    unsigned char edgeSelect,
+    unsigned char busSelect,
+    unsigned char dualEdgeClkSelect,
+    unsigned char hsyncEnable,
+    unsigned char vsyncEnable,
+    unsigned char deskewEnable,
+    unsigned char deskewSetting,
+    unsigned char continuousSyncEnable,
+    unsigned char pllFilterEnable,
+    unsigned char pllFilterValue
+);
+
+unsigned short sii164GetVendorID(void);
+unsigned short sii164GetDeviceID(void);
+
+
+#ifdef SII164_FULL_FUNCTIONS
+void sii164ResetChip(void);
+char *sii164GetChipString(void);
+void sii164SetPower(unsigned char powerUp);
+void sii164EnableHotPlugDetection(unsigned char enableHotPlug);
+unsigned char sii164IsConnected(void);
+unsigned char sii164CheckInterrupt(void);
+void sii164ClearInterrupt(void);
+#endif
+/* below register definination is used for Silicon Image SiI164 DVI controller chip */
+/*
+ * Vendor ID registers
+ */
+#define SII164_VENDOR_ID_LOW                        0x00
+#define SII164_VENDOR_ID_HIGH                       0x01
+
+/*
+ * Device ID registers
+ */
+#define SII164_DEVICE_ID_LOW                        0x02
+#define SII164_DEVICE_ID_HIGH                       0x03
+
+/*
+ * Device Revision
+ */
+#define SII164_DEVICE_REVISION                      0x04
+
+/*
+ * Frequency Limitation registers
+ */
+#define SII164_FREQUENCY_LIMIT_LOW                  0x06
+#define SII164_FREQUENCY_LIMIT_HIGH                 0x07
+
+/*
+ * Power Down and Input Signal Configuration registers
+ */
+#define SII164_CONFIGURATION                        0x08
+
+/* Power down (PD) */
+#define SII164_CONFIGURATION_POWER_DOWN             0x00
+#define SII164_CONFIGURATION_POWER_NORMAL           0x01
+#define SII164_CONFIGURATION_POWER_MASK             0x01
+
+/* Input Edge Latch Select (EDGE) */
+#define SII164_CONFIGURATION_LATCH_FALLING          0x00
+#define SII164_CONFIGURATION_LATCH_RISING           0x02
+
+/* Bus Select (BSEL) */
+#define SII164_CONFIGURATION_BUS_12BITS             0x00
+#define SII164_CONFIGURATION_BUS_24BITS             0x04
+
+/* Dual Edge Clock Select (DSEL) */
+#define SII164_CONFIGURATION_CLOCK_SINGLE           0x00
+#define SII164_CONFIGURATION_CLOCK_DUAL             0x08
+
+/* Horizontal Sync Enable (HEN) */
+#define SII164_CONFIGURATION_HSYNC_FORCE_LOW        0x00
+#define SII164_CONFIGURATION_HSYNC_AS_IS            0x10
+
+/* Vertical Sync Enable (VEN) */
+#define SII164_CONFIGURATION_VSYNC_FORCE_LOW        0x00
+#define SII164_CONFIGURATION_VSYNC_AS_IS            0x20
+
+/*
+ * Detection registers
+ */
+#define SII164_DETECT                               0x09
+
+/* Monitor Detect Interrupt (MDI) */
+#define SII164_DETECT_MONITOR_STATE_CHANGE          0x00
+#define SII164_DETECT_MONITOR_STATE_NO_CHANGE       0x01
+#define SII164_DETECT_MONITOR_STATE_CLEAR           0x01
+#define SII164_DETECT_MONITOR_STATE_MASK            0x01
+
+/* Hot Plug detect Input (HTPLG) */
+#define SII164_DETECT_HOT_PLUG_STATUS_OFF           0x00
+#define SII164_DETECT_HOT_PLUG_STATUS_ON            0x02
+#define SII164_DETECT_HOT_PLUG_STATUS_MASK          0x02
+
+/* Receiver Sense (RSEN) */
+#define SII164_DETECT_RECEIVER_SENSE_NOT_DETECTED   0x00
+#define SII164_DETECT_RECEIVER_SENSE_DETECTED       0x04
+
+/* Interrupt Generation Method (TSEL) */
+#define SII164_DETECT_INTERRUPT_BY_RSEN_PIN         0x00
+#define SII164_DETECT_INTERRUPT_BY_HTPLG_PIN        0x08
+#define SII164_DETECT_INTERRUPT_MASK                0x08
+
+/* Monitor Sense Output (MSEN) */
+#define SII164_DETECT_MONITOR_SENSE_OUTPUT_HIGH     0x00
+#define SII164_DETECT_MONITOR_SENSE_OUTPUT_MDI      0x10
+#define SII164_DETECT_MONITOR_SENSE_OUTPUT_RSEN     0x20
+#define SII164_DETECT_MONITOR_SENSE_OUTPUT_HTPLG    0x30
+#define SII164_DETECT_MONITOR_SENSE_OUTPUT_FLAG     0x30
+
+/*
+ * Skewing registers
+ */
+#define SII164_DESKEW                               0x0A
+
+/* General Purpose Input (CTL[3:1]) */
+#define SII164_DESKEW_GENERAL_PURPOSE_INPUT_MASK    0x0E
+
+/* De-skewing Enable bit (DKEN) */
+#define SII164_DESKEW_DISABLE                       0x00
+#define SII164_DESKEW_ENABLE                        0x10
+
+/* De-skewing Setting (DK[3:1])*/
+#define SII164_DESKEW_1_STEP                        0x00
+#define SII164_DESKEW_2_STEP                        0x20
+#define SII164_DESKEW_3_STEP                        0x40
+#define SII164_DESKEW_4_STEP                        0x60
+#define SII164_DESKEW_5_STEP                        0x80
+#define SII164_DESKEW_6_STEP                        0xA0
+#define SII164_DESKEW_7_STEP                        0xC0
+#define SII164_DESKEW_8_STEP                        0xE0
+
+/*
+ * User Configuration Data registers (CFG 7:0)
+ */
+#define SII164_USER_CONFIGURATION                   0x0B
+
+/*
+ * PLL registers
+ */
+#define SII164_PLL                                  0x0C
+
+/* PLL Filter Value (PLLF) */
+#define SII164_PLL_FILTER_VALUE_MASK                0x0E
+
+/* PLL Filter Enable (PFEN) */
+#define SII164_PLL_FILTER_DISABLE                   0x00
+#define SII164_PLL_FILTER_ENABLE                    0x01
+
+/* Sync Continuous (SCNT) */
+#define SII164_PLL_FILTER_SYNC_CONTINUOUS_DISABLE   0x00
+#define SII164_PLL_FILTER_SYNC_CONTINUOUS_ENABLE    0x80
+
+#endif
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c
new file mode 100644 (file)
index 0000000..901b373
--- /dev/null
@@ -0,0 +1,522 @@
+/*******************************************************************
+*
+*         Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
+*
+*  All rights are reserved. Reproduction or in part is prohibited
+*  without the written consent of the copyright owner.
+*
+*  swi2c.c --- SM750/SM718 DDK
+*  This file contains the source code for I2C using software
+*  implementation.
+*
+*******************************************************************/
+#include "ddk750_help.h"
+#include "ddk750_reg.h"
+#include "ddk750_swi2c.h"
+#include "ddk750_power.h"
+
+
+/*******************************************************************
+ * I2C Software Master Driver:
+ * ===========================
+ * Each i2c cycle is split into 4 sections. Each of these section marks
+ * a point in time where the SCL or SDA may be changed.
+ *
+ * 1 Cycle == |  Section I. |  Section 2. |  Section 3. |  Section 4. |
+ *            +-------------+-------------+-------------+-------------+
+ *            | SCL set LOW |SCL no change| SCL set HIGH|SCL no change|
+ *
+ *                                          ____________ _____________
+ * SCL == XXXX _____________ ____________ /
+ *
+ * I.e. the SCL may only be changed in section 1. and section 3. while
+ * the SDA may only be changed in section 2. and section 4. The table
+ * below gives the changes for these 2 lines in the varios sections.
+ *
+ * Section changes Table:
+ * ======================
+ * blank = no change, L = set bit LOW, H = set bit HIGH
+ *
+ *                                | 1.| 2.| 3.| 4.|
+ *                 ---------------+---+---+---+---+
+ *                 Tx Start   SDA |   | H |   | L |
+ *                            SCL | L |   | H |   |
+ *                 ---------------+---+---+---+---+
+ *                 Tx Stop    SDA |   | L |   | H |
+ *                            SCL | L |   | H |   |
+ *                 ---------------+---+---+---+---+
+ *                 Tx bit H   SDA |   | H |   |   |
+ *                            SCL | L |   | H |   |
+ *                 ---------------+---+---+---+---+
+ *                 Tx bit L   SDA |   | L |   |   |
+ *                            SCL | L |   | H |   |
+ *                 ---------------+---+---+---+---+
+ *
+ ******************************************************************/
+
+/* GPIO pins used for this I2C. It ranges from 0 to 63. */
+static unsigned char g_i2cClockGPIO = DEFAULT_I2C_SCL;
+static unsigned char g_i2cDataGPIO = DEFAULT_I2C_SDA;
+
+/*
+ *  Below is the variable declaration for the GPIO pin register usage
+ *  for the i2c Clock and i2c Data.
+ *
+ *  Note:
+ *      Notice that the GPIO usage for the i2c clock and i2c Data are
+ *      separated. This is to make this code flexible enough when
+ *      two separate GPIO pins for the clock and data are located
+ *      in two different GPIO register set (worst case).
+ */
+
+/* i2c Clock GPIO Register usage */
+static unsigned long g_i2cClkGPIOMuxReg = GPIO_MUX;
+static unsigned long g_i2cClkGPIODataReg = GPIO_DATA;
+static unsigned long g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION;
+
+/* i2c Data GPIO Register usage */
+static unsigned long g_i2cDataGPIOMuxReg = GPIO_MUX;
+static unsigned long g_i2cDataGPIODataReg = GPIO_DATA;
+static unsigned long g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION;
+
+/*
+ *  This function puts a delay between command
+ */
+static void swI2CWait(void)
+{
+       /* find a bug:
+        * peekIO method works well before suspend/resume
+        * but after suspend, peekIO(0x3ce,0x61) & 0x10
+        * always be non-zero,which makes the while loop
+        * never finish.
+        * use non-ultimate for loop below is safe
+        * */
+#if 0
+    /* Change wait algorithm to use PCI bus clock,
+       it's more reliable than counter loop ..
+       write 0x61 to 0x3ce and read from 0x3cf
+       */
+       while(peekIO(0x3ce,0x61) & 0x10);
+#else
+    int i, Temp;
+
+    for(i=0; i<600; i++)
+    {
+        Temp = i;
+        Temp += i;
+    }
+#endif
+}
+
+/*
+ *  This function set/reset the SCL GPIO pin
+ *
+ *  Parameters:
+ *      value    - Bit value to set to the SCL or SDA (0 = low, 1 = high)
+ *
+ *  Notes:
+ *      When setting SCL to high, just set the GPIO as input where the pull up
+ *      resistor will pull the signal up. Do not use software to pull up the
+ *      signal because the i2c will fail when other device try to drive the
+ *      signal due to SM50x will drive the signal to always high.
+ */
+void swI2CSCL(unsigned char value)
+{
+    unsigned long ulGPIOData;
+    unsigned long ulGPIODirection;
+
+    ulGPIODirection = PEEK32(g_i2cClkGPIODataDirReg);
+    if (value)      /* High */
+    {
+        /* Set direction as input. This will automatically pull the signal up. */
+        ulGPIODirection &= ~(1 << g_i2cClockGPIO);
+        POKE32(g_i2cClkGPIODataDirReg, ulGPIODirection);
+    }
+    else            /* Low */
+    {
+        /* Set the signal down */
+        ulGPIOData = PEEK32(g_i2cClkGPIODataReg);
+        ulGPIOData &= ~(1 << g_i2cClockGPIO);
+        POKE32(g_i2cClkGPIODataReg, ulGPIOData);
+
+        /* Set direction as output */
+        ulGPIODirection |= (1 << g_i2cClockGPIO);
+        POKE32(g_i2cClkGPIODataDirReg, ulGPIODirection);
+    }
+}
+
+/*
+ *  This function set/reset the SDA GPIO pin
+ *
+ *  Parameters:
+ *      value    - Bit value to set to the SCL or SDA (0 = low, 1 = high)
+ *
+ *  Notes:
+ *      When setting SCL to high, just set the GPIO as input where the pull up
+ *      resistor will pull the signal up. Do not use software to pull up the
+ *      signal because the i2c will fail when other device try to drive the
+ *      signal due to SM50x will drive the signal to always high.
+ */
+void swI2CSDA(unsigned char value)
+{
+    unsigned long ulGPIOData;
+    unsigned long ulGPIODirection;
+
+    ulGPIODirection = PEEK32(g_i2cDataGPIODataDirReg);
+    if (value)      /* High */
+    {
+        /* Set direction as input. This will automatically pull the signal up. */
+        ulGPIODirection &= ~(1 << g_i2cDataGPIO);
+        POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+    }
+    else            /* Low */
+    {
+        /* Set the signal down */
+        ulGPIOData = PEEK32(g_i2cDataGPIODataReg);
+        ulGPIOData &= ~(1 << g_i2cDataGPIO);
+        POKE32(g_i2cDataGPIODataReg, ulGPIOData);
+
+        /* Set direction as output */
+        ulGPIODirection |= (1 << g_i2cDataGPIO);
+        POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+    }
+}
+
+/*
+ *  This function read the data from the SDA GPIO pin
+ *
+ *  Return Value:
+ *      The SDA data bit sent by the Slave
+ */
+static unsigned char swI2CReadSDA(void)
+{
+    unsigned long ulGPIODirection;
+    unsigned long ulGPIOData;
+
+    /* Make sure that the direction is input (High) */
+    ulGPIODirection = PEEK32(g_i2cDataGPIODataDirReg);
+    if ((ulGPIODirection & (1 << g_i2cDataGPIO)) != (~(1 << g_i2cDataGPIO)))
+    {
+        ulGPIODirection &= ~(1 << g_i2cDataGPIO);
+        POKE32(g_i2cDataGPIODataDirReg, ulGPIODirection);
+    }
+
+    /* Now read the SDA line */
+    ulGPIOData = PEEK32(g_i2cDataGPIODataReg);
+    if (ulGPIOData & (1 << g_i2cDataGPIO))
+        return 1;
+    else
+        return 0;
+}
+
+/*
+ *  This function sends ACK signal
+ */
+static void swI2CAck(void)
+{
+    return;  /* Single byte read is ok without it. */
+}
+
+/*
+ *  This function sends the start command to the slave device
+ */
+static void swI2CStart(void)
+{
+    /* Start I2C */
+    swI2CSDA(1);
+    swI2CSCL(1);
+    swI2CSDA(0);
+}
+
+/*
+ *  This function sends the stop command to the slave device
+ */
+static void swI2CStop(void)
+{
+    /* Stop the I2C */
+    swI2CSCL(1);
+    swI2CSDA(0);
+    swI2CSDA(1);
+}
+
+/*
+ *  This function writes one byte to the slave device
+ *
+ *  Parameters:
+ *      data    - Data to be write to the slave device
+ *
+ *  Return Value:
+ *       0   - Success
+ *      -1   - Fail to write byte
+ */
+static long swI2CWriteByte(unsigned char data)
+{
+    unsigned char value = data;
+    int i;
+
+    /* Sending the data bit by bit */
+    for (i=0; i<8; i++)
+    {
+        /* Set SCL to low */
+        swI2CSCL(0);
+
+        /* Send data bit */
+        if ((value & 0x80) != 0)
+            swI2CSDA(1);
+        else
+            swI2CSDA(0);
+
+        swI2CWait();
+
+        /* Toggle clk line to one */
+        swI2CSCL(1);
+        swI2CWait();
+
+        /* Shift byte to be sent */
+        value = value << 1;
+    }
+
+    /* Set the SCL Low and SDA High (prepare to get input) */
+    swI2CSCL(0);
+    swI2CSDA(1);
+
+    /* Set the SCL High for ack */
+    swI2CWait();
+    swI2CSCL(1);
+    swI2CWait();
+
+    /* Read SDA, until SDA==0 */
+    for(i=0; i<0xff; i++)
+    {
+        if (!swI2CReadSDA())
+            break;
+
+        swI2CSCL(0);
+        swI2CWait();
+        swI2CSCL(1);
+        swI2CWait();
+    }
+
+    /* Set the SCL Low and SDA High */
+    swI2CSCL(0);
+    swI2CSDA(1);
+
+    if (i<0xff)
+        return 0;
+    else
+        return -1;
+}
+
+/*
+ *  This function reads one byte from the slave device
+ *
+ *  Parameters:
+ *      ack    - Flag to indicate either to send the acknowledge
+ *            message to the slave device or not
+ *
+ *  Return Value:
+ *      One byte data read from the Slave device
+ */
+static unsigned char swI2CReadByte(unsigned char ack)
+{
+    int i;
+    unsigned char data = 0;
+
+    for(i=7; i>=0; i--)
+    {
+        /* Set the SCL to Low and SDA to High (Input) */
+        swI2CSCL(0);
+        swI2CSDA(1);
+        swI2CWait();
+
+        /* Set the SCL High */
+        swI2CSCL(1);
+        swI2CWait();
+
+        /* Read data bits from SDA */
+        data |= (swI2CReadSDA() << i);
+    }
+
+    if (ack)
+        swI2CAck();
+
+    /* Set the SCL Low and SDA High */
+    swI2CSCL(0);
+    swI2CSDA(1);
+
+    return data;
+}
+
+/*
+ * This function initializes GPIO port for SW I2C communication.
+ *
+ * Parameters:
+ *      i2cClkGPIO      - The GPIO pin to be used as i2c SCL
+ *      i2cDataGPIO     - The GPIO pin to be used as i2c SDA
+ *
+ * Return Value:
+ *      -1   - Fail to initialize the i2c
+ *       0   - Success
+ */
+static long swI2CInit_SM750LE(unsigned char i2cClkGPIO,
+                             unsigned char i2cDataGPIO)
+{
+    int i;
+
+    /* Initialize the GPIO pin for the i2c Clock Register */
+    g_i2cClkGPIODataReg = GPIO_DATA_SM750LE;
+    g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION_SM750LE;
+
+    /* Initialize the Clock GPIO Offset */
+    g_i2cClockGPIO = i2cClkGPIO;
+
+    /* Initialize the GPIO pin for the i2c Data Register */
+    g_i2cDataGPIODataReg = GPIO_DATA_SM750LE;
+    g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION_SM750LE;
+
+    /* Initialize the Data GPIO Offset */
+    g_i2cDataGPIO = i2cDataGPIO;
+
+    /* Note that SM750LE don't have GPIO MUX and power is always on */
+
+    /* Clear the i2c lines. */
+    for(i=0; i<9; i++)
+        swI2CStop();
+
+    return 0;
+}
+
+/*
+ * This function initializes the i2c attributes and bus
+ *
+ * Parameters:
+ *      i2cClkGPIO      - The GPIO pin to be used as i2c SCL
+ *      i2cDataGPIO     - The GPIO pin to be used as i2c SDA
+ *
+ * Return Value:
+ *      -1   - Fail to initialize the i2c
+ *       0   - Success
+ */
+long swI2CInit(
+    unsigned char i2cClkGPIO,
+    unsigned char i2cDataGPIO
+)
+{
+    int i;
+
+    /* Return 0 if the GPIO pins to be used is out of range. The range is only from [0..63] */
+    if ((i2cClkGPIO > 31) || (i2cDataGPIO > 31))
+        return -1;
+
+    if (getChipType() == SM750LE)
+        return swI2CInit_SM750LE(i2cClkGPIO, i2cDataGPIO);
+
+    /* Initialize the GPIO pin for the i2c Clock Register */
+    g_i2cClkGPIOMuxReg = GPIO_MUX;
+    g_i2cClkGPIODataReg = GPIO_DATA;
+    g_i2cClkGPIODataDirReg = GPIO_DATA_DIRECTION;
+
+    /* Initialize the Clock GPIO Offset */
+    g_i2cClockGPIO = i2cClkGPIO;
+
+    /* Initialize the GPIO pin for the i2c Data Register */
+    g_i2cDataGPIOMuxReg = GPIO_MUX;
+    g_i2cDataGPIODataReg = GPIO_DATA;
+    g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION;
+
+    /* Initialize the Data GPIO Offset */
+    g_i2cDataGPIO = i2cDataGPIO;
+
+    /* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */
+    POKE32(g_i2cClkGPIOMuxReg,
+                      PEEK32(g_i2cClkGPIOMuxReg) & ~(1 << g_i2cClockGPIO));
+    POKE32(g_i2cDataGPIOMuxReg,
+                      PEEK32(g_i2cDataGPIOMuxReg) & ~(1 << g_i2cDataGPIO));
+
+    /* Enable GPIO power */
+    enableGPIO(1);
+
+    /* Clear the i2c lines. */
+    for(i=0; i<9; i++)
+        swI2CStop();
+
+    return 0;
+}
+
+/*
+ *  This function reads the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be read from
+ *      registerIndex   - Slave device's register to be read
+ *
+ *  Return Value:
+ *      Register value
+ */
+unsigned char swI2CReadReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex
+)
+{
+    unsigned char data;
+
+    /* Send the Start signal */
+    swI2CStart();
+
+    /* Send the device address */
+    swI2CWriteByte(deviceAddress);
+
+    /* Send the register index */
+    swI2CWriteByte(registerIndex);
+
+    /* Get the bus again and get the data from the device read address */
+    swI2CStart();
+    swI2CWriteByte(deviceAddress + 1);
+    data = swI2CReadByte(1);
+
+    /* Stop swI2C and release the bus */
+    swI2CStop();
+
+    return data;
+}
+
+/*
+ *  This function writes a value to the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be written
+ *      registerIndex   - Slave device's register to be written
+ *      data            - Data to be written to the register
+ *
+ *  Result:
+ *          0   - Success
+ *         -1   - Fail
+ */
+long swI2CWriteReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex,
+    unsigned char data
+)
+{
+    long returnValue = 0;
+
+    /* Send the Start signal */
+    swI2CStart();
+
+    /* Send the device address and read the data. All should return success
+       in order for the writing processed to be successful
+     */
+    if ((swI2CWriteByte(deviceAddress) != 0) ||
+        (swI2CWriteByte(registerIndex) != 0) ||
+        (swI2CWriteByte(data) != 0))
+    {
+        returnValue = -1;
+    }
+
+    /* Stop i2c and release the bus */
+    swI2CStop();
+
+    return returnValue;
+}
diff --git a/drivers/staging/sm750fb/ddk750_swi2c.h b/drivers/staging/sm750fb/ddk750_swi2c.h
new file mode 100644 (file)
index 0000000..ec5463b
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************
+*
+*         Copyright (c) 2007 by Silicon Motion, Inc. (SMI)
+*
+*  All rights are reserved. Reproduction or in part is prohibited
+*  without the written consent of the copyright owner.
+*
+*  swi2c.h --- SM750/SM718 DDK
+*  This file contains the definitions for i2c using software
+*  implementation.
+*
+*******************************************************************/
+#ifndef _SWI2C_H_
+#define _SWI2C_H_
+
+/* Default i2c CLK and Data GPIO. These are the default i2c pins */
+#define DEFAULT_I2C_SCL                     30
+#define DEFAULT_I2C_SDA                     31
+
+/*
+ * This function initializes the i2c attributes and bus
+ *
+ * Parameters:
+ *      i2cClkGPIO  - The GPIO pin to be used as i2c SCL
+ *      i2cDataGPIO - The GPIO pin to be used as i2c SDA
+ *
+ * Return Value:
+ *      -1   - Fail to initialize the i2c
+ *       0   - Success
+ */
+long swI2CInit(
+    unsigned char i2cClkGPIO,
+    unsigned char i2cDataGPIO
+);
+
+/*
+ *  This function reads the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be read from
+ *      registerIndex   - Slave device's register to be read
+ *
+ *  Return Value:
+ *      Register value
+ */
+unsigned char swI2CReadReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex
+);
+
+/*
+ *  This function writes a value to the slave device's register
+ *
+ *  Parameters:
+ *      deviceAddress   - i2c Slave device address which register
+ *                        to be written
+ *      registerIndex   - Slave device's register to be written
+ *      data            - Data to be written to the register
+ *
+ *  Result:
+ *          0   - Success
+ *         -1   - Fail
+ */
+long swI2CWriteReg(
+    unsigned char deviceAddress,
+    unsigned char registerIndex,
+    unsigned char data
+);
+
+/*
+ *  These two functions are used to toggle the data on the SCL and SDA I2C lines.
+ *  The used of these two functions are not recommended unless it is necessary.
+ */
+
+/*
+ *  This function set/reset the SCL GPIO pin
+ *
+ *  Parameters:
+ *      value  - Bit value to set to the SCL or SDA (0 = low, 1 = high)
+ */
+void swI2CSCL(unsigned char value);
+
+/*
+ *  This function set/reset the SDA GPIO pin
+ *
+ *  Parameters:
+ *      value  - Bit value to set to the SCL or SDA (0 = low, 1 = high)
+ */
+void swI2CSDA(unsigned char value);
+
+#endif  /* _SWI2C_H_ */
diff --git a/drivers/staging/sm750fb/modedb.h b/drivers/staging/sm750fb/modedb.h
new file mode 100644 (file)
index 0000000..c5275c6
--- /dev/null
@@ -0,0 +1,221 @@
+
+static const struct fb_videomode modedb2[] = {
+    {
+       /* 640x400 @ 70 Hz, 31.5 kHz hsync */
+       NULL, 70, 640, 400, 39721, 40, 24, 39, 9, 96, 2,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 640x480 @ 60 Hz, 31.5 kHz hsync */
+       NULL, 60, 640, 480, 39721, 40, 24, 32, 11, 96, 2,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 800x600 @ 56 Hz, 35.15 kHz hsync */
+       NULL, 56, 800, 600, 27777, 128, 24, 22, 1, 72, 2,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 87 Hz interlaced, 35.5 kHz hsync */
+       NULL, 87, 1024, 768, 22271, 56, 24, 33, 8, 160, 8,
+       0, FB_VMODE_INTERLACED
+    }, {
+       /* 640x400 @ 85 Hz, 37.86 kHz hsync */
+       NULL, 85, 640, 400, 31746, 96, 32, 41, 1, 64, 3,
+       FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 640x480 @ 72 Hz, 36.5 kHz hsync */
+       NULL, 72, 640, 480, 31746, 144, 40, 30, 8, 40, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 640x480 @ 75 Hz, 37.50 kHz hsync */
+       NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 800x600 @ 60 Hz, 37.8 kHz hsync */
+       NULL, 60, 800, 600, 25000, 88, 40, 23, 1, 128, 4,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 640x480 @ 85 Hz, 43.27 kHz hsync */
+       NULL, 85, 640, 480, 27777, 80, 56, 25, 1, 56, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 89 Hz interlaced, 44 kHz hsync */
+       NULL, 69, 1152, 864, 15384, 96, 16, 110, 1, 216, 10,
+       0, FB_VMODE_INTERLACED
+    }, {
+       /* 800x600 @ 72 Hz, 48.0 kHz hsync */
+       NULL, 72, 800, 600, 20000, 64, 56, 23, 37, 120, 6,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 60 Hz, 48.4 kHz hsync */
+       NULL, 60, 1024, 768, 15384, 168, 8, 29, 3, 144, 6,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 640x480 @ 100 Hz, 53.01 kHz hsync */
+       NULL, 100, 640, 480, 21834, 96, 32, 36, 8, 96, 6,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 60 Hz, 53.5 kHz hsync */
+       NULL, 60, 1152, 864, 11123, 208, 64, 16, 4, 256, 8,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 800x600 @ 85 Hz, 55.84 kHz hsync */
+       NULL, 85, 800, 600, 16460, 160, 64, 36, 16, 64, 5,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 70 Hz, 56.5 kHz hsync */
+       NULL, 70, 1024, 768, 13333, 144, 24, 29, 3, 136, 6,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+        /*  1280x960-60 VESA */
+        NULL, 60, 1280, 960, 9259, 312, 96, 36, 1, 112, 3,
+        FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,  FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA
+    }, {
+        /*  1280x1024-60 VESA */
+        NULL, 60, 1280, 1024, 9259, 248, 48, 38, 1, 112, 3,
+        FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA
+    }, {
+       /* 1280x1024 @ 87 Hz interlaced, 51 kHz hsync */
+       NULL, 87, 1280, 1024, 12500, 56, 16, 128, 1, 216, 12,
+       0, FB_VMODE_INTERLACED
+    }, {
+       /* 800x600 @ 100 Hz, 64.02 kHz hsync */
+       NULL, 100, 800, 600, 14357, 160, 64, 30, 4, 64, 6,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 76 Hz, 62.5 kHz hsync */
+       NULL, 76, 1024, 768, 11764, 208, 8, 36, 16, 120, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 70 Hz, 62.4 kHz hsync */
+       NULL, 70, 1152, 864, 10869, 106, 56, 20, 1, 160, 10,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 61 Hz, 64.2 kHz hsync */
+       NULL, 61, 1280, 1024, 9090, 200, 48, 26, 1, 184, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1400x1050 @ 60Hz, 63.9 kHz hsync */
+       NULL, 68, 1400, 1050, 9259, 136, 40, 13, 1, 112, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1400x1050 @ 75,107 Hz, 82,392 kHz +hsync +vsync*/
+       NULL, 75, 1400, 1050, 9271, 120, 56, 13, 0, 112, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1400x1050 @ 60 Hz, ? kHz +hsync +vsync*/
+        NULL, 60, 1400, 1050, 9259, 128, 40, 12, 0, 112, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 85 Hz, 70.24 kHz hsync */
+       NULL, 85, 1024, 768, 10111, 192, 32, 34, 14, 160, 6,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 78 Hz, 70.8 kHz hsync */
+       NULL, 78, 1152, 864, 9090, 228, 88, 32, 0, 84, 12,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 70 Hz, 74.59 kHz hsync */
+       NULL, 70, 1280, 1024, 7905, 224, 32, 28, 8, 160, 8,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1600x1200 @ 60Hz, 75.00 kHz hsync */
+       NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 84 Hz, 76.0 kHz hsync */
+       NULL, 84, 1152, 864, 7407, 184, 312, 32, 0, 128, 12,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 74 Hz, 78.85 kHz hsync */
+       NULL, 74, 1280, 1024, 7407, 256, 32, 34, 3, 144, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1024x768 @ 100Hz, 80.21 kHz hsync */
+       NULL, 100, 1024, 768, 8658, 192, 32, 21, 3, 192, 10,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 76 Hz, 81.13 kHz hsync */
+       NULL, 76, 1280, 1024, 7407, 248, 32, 34, 3, 104, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1600x1200 @ 70 Hz, 87.50 kHz hsync */
+       NULL, 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1152x864 @ 100 Hz, 89.62 kHz hsync */
+       NULL, 100, 1152, 864, 7264, 224, 32, 17, 2, 128, 19,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 85 Hz, 91.15 kHz hsync */
+       NULL, 85, 1280, 1024, 6349, 224, 64, 44, 1, 160, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1600x1200 @ 75 Hz, 93.75 kHz hsync */
+       NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1600x1200 @ 85 Hz, 105.77 kHz hsync */
+       NULL, 85, 1600, 1200, 4545, 272, 16, 37, 4, 192, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1280x1024 @ 100 Hz, 107.16 kHz hsync */
+       NULL, 100, 1280, 1024, 5502, 256, 32, 26, 7, 128, 15,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1800x1440 @ 64Hz, 96.15 kHz hsync  */
+       NULL, 64, 1800, 1440, 4347, 304, 96, 46, 1, 192, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 1800x1440 @ 70Hz, 104.52 kHz hsync  */
+       NULL, 70, 1800, 1440, 4000, 304, 96, 46, 1, 192, 3,
+       FB_SYNC_HOR_HIGH_ACT|FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED
+    }, {
+       /* 512x384 @ 78 Hz, 31.50 kHz hsync */
+       NULL, 78, 512, 384, 49603, 48, 16, 16, 1, 64, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 512x384 @ 85 Hz, 34.38 kHz hsync */
+       NULL, 85, 512, 384, 45454, 48, 16, 16, 1, 64, 3,
+       0, FB_VMODE_NONINTERLACED
+    }, {
+       /* 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio */
+       NULL, 70, 320, 200, 79440, 16, 16, 20, 4, 48, 1,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio */
+       NULL, 60, 320, 240, 79440, 16, 16, 16, 5, 48, 1,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 320x240 @ 72 Hz, 36.5 kHz hsync */
+       NULL, 72, 320, 240, 63492, 16, 16, 16, 4, 48, 2,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio */
+       NULL, 56, 400, 300, 55555, 64, 16, 10, 1, 32, 1,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 400x300 @ 60 Hz, 37.8 kHz hsync */
+       NULL, 60, 400, 300, 50000, 48, 16, 11, 1, 64, 2,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 400x300 @ 72 Hz, 48.0 kHz hsync */
+       NULL, 72, 400, 300, 40000, 32, 24, 11, 19, 64, 3,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 480x300 @ 56 Hz, 35.2 kHz hsync, 8:5 aspect ratio */
+       NULL, 56, 480, 300, 46176, 80, 16, 10, 1, 40, 1,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 480x300 @ 60 Hz, 37.8 kHz hsync */
+       NULL, 60, 480, 300, 41858, 56, 16, 11, 1, 80, 2,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 480x300 @ 63 Hz, 39.6 kHz hsync */
+       NULL, 63, 480, 300, 40000, 56, 16, 11, 1, 80, 2,
+       0, FB_VMODE_DOUBLE
+    }, {
+       /* 480x300 @ 72 Hz, 48.0 kHz hsync */
+       NULL, 72, 480, 300, 33386, 40, 24, 11, 19, 80, 3,
+       0, FB_VMODE_DOUBLE
+    },
+};
+static const int nmodedb2 = sizeof(modedb2);
diff --git a/drivers/staging/sm750fb/readme b/drivers/staging/sm750fb/readme
new file mode 100644 (file)
index 0000000..ab9af79
--- /dev/null
@@ -0,0 +1,38 @@
+Introduction:
+       SM750 of Silicon MOtion is pci express display controller device.
+       The SM750 embedded graphics features include:
+       - dual display
+       - 2D acceleration
+       - 16MB integrated video memory
+
+About the kernel module paramter of driver:
+
+       Use 1280,8bpp index color and 60 hz mode:
+       insmod ./sm750fb.ko g_option="1280x1024-8@60"
+
+       Disable MTRR,Disable 2d acceleration,Disable hardware cursor,
+       and use a 800x600 mode :
+       insmod ./sm750fb.ko g_option="noaccel:nomtrr:nohwc:800x600"
+
+       dual frame buffer for driver with "dual" parameter
+       insmod ./sm750fb.ko g_option="dual,800x600:1024x768"
+       it will create fb0 and fb1 (or fb1,fb2 if fb0 already exist) under /dev
+       and user can use con2fb to link fbX and ttyX
+
+       Notes:
+       1) if you build the driver with built-in method, the paramter
+               you edited in the grub config file will be also the
+               same format as above modular method,but additionaly add
+               "video=sm750fb:"
+               ahead of parameters,so,it looks like:
+               video=sm750fb:noaccel,1280x1024@60,otherparam,etc...
+               it equal to modular method with below command:
+               insmod ./sm750fb.ko g_option="noaccel:1280x1024@60:otherparm:etc..."
+
+       2) if you put 800x600 into the paramter without bpp and
+               refresh rate, kernel driver will defaulty use 16bpp and 60hz
+
+Important:
+       if you have vesafb enabled in your config then /dev/fb0 will be created by vesafb
+       and this driver will use fb1, fb2. In that case, you need to configure your X-server
+       to use fb1. Another simple althernative is to disable vesafb from your config.
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
new file mode 100644 (file)
index 0000000..a7b1b9c
--- /dev/null
@@ -0,0 +1,1380 @@
+#include<linux/kernel.h>
+#include<linux/module.h>
+#include<linux/errno.h>
+#include<linux/string.h>
+#include<linux/mm.h>
+#include<linux/slab.h>
+#include<linux/delay.h>
+#include<linux/fb.h>
+#include<linux/ioport.h>
+#include<linux/init.h>
+#include<linux/pci.h>
+#include<linux/mm_types.h>
+#include<linux/vmalloc.h>
+#include<linux/pagemap.h>
+#include<linux/screen_info.h>
+#include<linux/vmalloc.h>
+#include<linux/pagemap.h>
+#include <linux/console.h>
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
+#include <asm/fb.h>
+#include "sm750.h"
+#include "sm750_hw.h"
+#include "sm750_accel.h"
+#include "sm750_cursor.h"
+
+#include "modedb.h"
+
+int smi_indent = 0;
+
+
+/*
+#ifdef __BIG_ENDIAN
+ssize_t lynxfb_ops_write(struct fb_info *info, const char __user *buf,
+           size_t count, loff_t *ppos);
+ssize_t lynxfb_ops_read(struct fb_info *info, char __user *buf,
+                          size_t count, loff_t *ppos);
+#endif
+ */
+
+typedef void (*PROC_SPEC_SETUP)(struct lynx_share*,char *);
+typedef int (*PROC_SPEC_MAP)(struct lynx_share*,struct pci_dev*);
+typedef int (*PROC_SPEC_INITHW)(struct lynx_share*,struct pci_dev*);
+
+
+/* common var for all device */
+static int g_hwcursor = 1;
+static int g_noaccel;
+#ifdef CONFIG_MTRR
+static int g_nomtrr;
+#endif
+static const char * g_fbmode[] = {NULL,NULL};
+static const char * g_def_fbmode = "800x600-16@60";
+static char * g_settings = NULL;
+static int g_dualview;
+static char * g_option = NULL;
+
+/* if not use spin_lock,system will die if user load driver
+ * and immediatly unload driver frequently (dual)*/
+static inline void myspin_lock(spinlock_t * sl){
+       struct lynx_share * share;
+       share = container_of(sl,struct lynx_share,slock);
+       if(share->dual){
+               spin_lock(sl);
+       }
+}
+
+static inline void myspin_unlock(spinlock_t * sl){
+       struct lynx_share * share;
+       share = container_of(sl,struct lynx_share,slock);
+       if(share->dual){
+               spin_unlock(sl);
+       }
+}
+static const struct fb_videomode lynx750_ext[] = {
+       /*      1024x600-60 VESA        [1.71:1]        */
+       {NULL,  60, 1024, 600, 20423, 144,  40, 18, 1, 104, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1024x600-70 VESA */
+       {NULL,  70, 1024, 600, 17211, 152,  48, 21, 1, 104, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1024x600-75 VESA */
+       {NULL,  75, 1024, 600, 15822, 160,  56, 23, 1, 104, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1024x600-85 VESA */
+       {NULL,  85, 1024, 600, 13730, 168,  56, 26, 1, 112, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      720x480 */
+       {NULL, 60,  720,  480,  37427, 88,   16, 13, 1,   72,  3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1280x720                [1.78:1]        */
+       {NULL, 60,  1280,  720,  13426, 162, 86, 22, 1,  136, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+
+       /* 1280x768@60 */
+       {NULL,60,1280,768,12579,192,64,20,3,128,7,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+
+       {NULL,60,1360,768,11804,208,64,23,1,144,3,
+       FB_SYNC_HOR_HIGH_ACT|FB_VMODE_NONINTERLACED},
+
+       /*      1360 x 768      [1.77083:1]     */
+       {NULL,  60, 1360, 768, 11804, 208,  64, 23, 1, 144, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1368 x 768      [1.78:1]        */
+       {NULL, 60,  1368,  768,  11647, 216, 72, 23, 1,  144, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1440 x 900              [16:10] */
+       {NULL, 60, 1440, 900, 9392, 232, 80, 28, 1, 152, 3,
+       FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+
+       /*      1440x960                [15:10] */
+       {NULL, 60, 1440, 960, 8733, 240, 88, 30, 1, 152, 3,
+       FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, FB_VMODE_NONINTERLACED},
+
+       /*      1920x1080       [16:9]  */
+       {NULL, 60, 1920, 1080, 6734, 148, 88, 41, 1, 44, 3,
+       FB_SYNC_VERT_HIGH_ACT,FB_VMODE_NONINTERLACED},
+};
+
+
+
+
+/* no hardware cursor supported under version 2.6.10, kernel bug */
+static int lynxfb_ops_cursor(struct fb_info* info,struct fb_cursor* fbcursor)
+{
+       struct lynxfb_par * par;
+       struct lynxfb_crtc * crtc;
+       struct lynx_cursor * cursor;
+
+       par = info->par;
+       crtc = &par->crtc;
+       cursor = &crtc->cursor;
+
+       if(fbcursor->image.width > cursor->maxW ||
+               fbcursor->image.height > cursor->maxH ||
+                fbcursor->image.depth > 1){
+               return -ENXIO;
+       }
+
+       cursor->disable(cursor);
+       if(fbcursor->set & FB_CUR_SETSIZE){
+               cursor->setSize(cursor,fbcursor->image.width,fbcursor->image.height);
+       }
+
+       if(fbcursor->set & FB_CUR_SETPOS){
+               cursor->setPos(cursor,fbcursor->image.dx - info->var.xoffset,
+                                                               fbcursor->image.dy - info->var.yoffset);
+       }
+
+       if(fbcursor->set & FB_CUR_SETCMAP){
+               /* get the 16bit color of kernel means */
+               u16 fg,bg;
+               fg = ((info->cmap.red[fbcursor->image.fg_color] & 0xf800))|
+                               ((info->cmap.green[fbcursor->image.fg_color] & 0xfc00) >> 5)|
+                               ((info->cmap.blue[fbcursor->image.fg_color] & 0xf800) >> 11);
+
+               bg = ((info->cmap.red[fbcursor->image.bg_color] & 0xf800))|
+                               ((info->cmap.green[fbcursor->image.bg_color] & 0xfc00) >> 5)|
+                               ((info->cmap.blue[fbcursor->image.bg_color] & 0xf800) >> 11);
+
+               cursor->setColor(cursor,fg,bg);
+       }
+
+
+       if(fbcursor->set & (FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
+       {
+               cursor->setData(cursor,
+                                               fbcursor->rop,
+                                               fbcursor->image.data,
+                                               fbcursor->mask);
+       }
+
+       if(fbcursor->enable){
+               cursor->enable(cursor);
+       }
+
+       return 0;
+}
+
+static void lynxfb_ops_fillrect(struct fb_info* info,const struct fb_fillrect* region)
+{
+       struct lynxfb_par * par;
+       struct lynx_share * share;
+       unsigned int base,pitch,Bpp,rop;
+       u32 color;
+
+       if(info->state != FBINFO_STATE_RUNNING){
+               return;
+       }
+
+       par = info->par;
+       share = par->share;
+
+       /* each time 2d function begin to work,below three variable always need
+        * be set, seems we can put them together in some place  */
+       base = par->crtc.oScreen;
+       pitch = info->fix.line_length;
+       Bpp = info->var.bits_per_pixel >> 3;
+
+       color = (Bpp == 1)?region->color:((u32*)info->pseudo_palette)[region->color];
+       rop = ( region->rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY;
+
+       myspin_lock(&share->slock);
+       share->accel.de_fillrect(&share->accel,
+                                                       base,pitch,Bpp,
+                                                       region->dx,region->dy,
+                                                       region->width,region->height,
+                                                       color,rop);
+       myspin_unlock(&share->slock);
+}
+
+static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea * region)
+{
+       struct lynxfb_par * par;
+       struct lynx_share * share;
+       unsigned int base,pitch,Bpp;
+
+       par = info->par;
+       share = par->share;
+
+       /* each time 2d function begin to work,below three variable always need
+        * be set, seems we can put them together in some place  */
+       base = par->crtc.oScreen;
+       pitch = info->fix.line_length;
+       Bpp = info->var.bits_per_pixel >> 3;
+
+       myspin_lock(&share->slock);
+       share->accel.de_copyarea(&share->accel,
+                                                       base,pitch,region->sx,region->sy,
+                                                       base,pitch,Bpp,region->dx,region->dy,
+                                                       region->width,region->height,HW_ROP2_COPY);
+       myspin_unlock(&share->slock);
+}
+
+static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* image)
+{
+       unsigned int base,pitch,Bpp;
+       unsigned int fgcol,bgcol;
+       struct lynxfb_par * par;
+       struct lynx_share * share;
+
+       par = info->par;
+       share = par->share;
+       /* each time 2d function begin to work,below three variable always need
+        * be set, seems we can put them together in some place  */
+       base = par->crtc.oScreen;
+       pitch = info->fix.line_length;
+       Bpp = info->var.bits_per_pixel >> 3;
+
+       if(image->depth == 1){
+               if(info->fix.visual == FB_VISUAL_TRUECOLOR ||
+                       info->fix.visual == FB_VISUAL_DIRECTCOLOR)
+               {
+                       fgcol = ((u32*)info->pseudo_palette)[image->fg_color];
+                       bgcol = ((u32*)info->pseudo_palette)[image->bg_color];
+               }
+               else
+               {
+                       fgcol = image->fg_color;
+                       bgcol = image->bg_color;
+               }
+               goto _do_work;
+       }
+       return;
+_do_work:
+       myspin_lock(&share->slock);
+       share->accel.de_imageblit(&share->accel,
+                                       image->data,image->width>>3,0,
+                                       base,pitch,Bpp,
+                                       image->dx,image->dy,
+                                       image->width,image->height,
+                                       fgcol,bgcol,HW_ROP2_COPY);
+       myspin_unlock(&share->slock);
+}
+
+static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
+        struct fb_info *info)
+{
+    struct lynxfb_par * par;
+    struct lynxfb_crtc * crtc;
+    int ret;
+    
+
+    if(!info)
+        return -EINVAL;
+
+    ret = 0;
+    par = info->par;
+    crtc = &par->crtc;
+    ret = crtc->proc_panDisplay(crtc, var, info);
+
+    return ret;
+}
+
+static int lynxfb_ops_set_par(struct fb_info * info)
+{
+       struct lynxfb_par * par;
+       struct lynx_share * share;
+       struct lynxfb_crtc * crtc;
+       struct lynxfb_output * output;
+       struct fb_var_screeninfo * var;
+       struct fb_fix_screeninfo * fix;
+       int ret;
+       unsigned int line_length;
+
+       if(!info)
+               return -EINVAL;
+
+       ret = 0;
+       par = info->par;
+       share = par->share;
+       crtc = &par->crtc;
+       output = &par->output;
+       var = &info->var;
+       fix = &info->fix;
+
+       /* fix structur is not so FIX ... */
+       line_length = var->xres_virtual * var->bits_per_pixel / 8;
+       line_length = PADDING(crtc->line_pad,line_length);
+       fix->line_length = line_length;
+       pr_err("fix->line_length = %d\n",fix->line_length);
+
+       /* var->red,green,blue,transp are need to be set by driver
+        * and these data should be set before setcolreg routine
+        * */
+
+       switch(var->bits_per_pixel){
+       case 8:
+               fix->visual = FB_VISUAL_PSEUDOCOLOR;
+               var->red.offset = 0;
+               var->red.length = 8;
+               var->green.offset = 0;
+               var->green.length = 8;
+               var->blue.offset = 0;
+               var->blue.length = 8;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               break;
+       case 16:
+               var->red.offset = 11;
+               var->red.length = 5;
+               var->green.offset = 5;
+               var->green.length = 6;
+               var->blue.offset = 0;
+               var->blue.length = 5;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               fix->visual = FB_VISUAL_TRUECOLOR;
+               break;
+       case 24:
+       case 32:
+               var->red.offset = 16;
+               var->red.length = 8;
+               var->green.offset = 8;
+               var->green.length = 8;
+               var->blue.offset = 0 ;
+               var->blue.length = 8;
+               fix->visual = FB_VISUAL_TRUECOLOR;
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       var->height = var->width = -1;
+       var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
+
+       if(ret){
+               pr_err("pixel bpp format not satisfied\n.");
+               return ret;
+       }
+       ret = crtc->proc_setMode(crtc,var,fix);
+       if(!ret)
+               ret = output->proc_setMode(output,var,fix);
+       return ret;
+}
+
+static inline unsigned int chan_to_field(unsigned int chan,struct fb_bitfield * bf)
+{
+       chan &= 0xffff;
+       chan >>= 16 - bf->length;
+       return chan << bf->offset;
+}
+
+#ifdef CONFIG_PM
+static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg)
+{
+       struct fb_info *info;
+       struct lynx_share *share;
+       int ret;
+
+       if (mesg.event == pdev->dev.power.power_state.event)
+               return 0;
+
+       ret = 0;
+       share = pci_get_drvdata(pdev);
+       switch (mesg.event) {
+       case PM_EVENT_FREEZE:
+       case PM_EVENT_PRETHAW:
+               pdev->dev.power.power_state = mesg;
+               return 0;
+       }
+
+       console_lock();
+       if (mesg.event & PM_EVENT_SLEEP) {
+               info = share->fbinfo[0];
+               if (info)
+                       /* 1 means do suspend*/
+                       fb_set_suspend(info, 1);
+               info = share->fbinfo[1];
+               if (info)
+                       /* 1 means do suspend*/
+                       fb_set_suspend(info, 1);
+
+               ret = pci_save_state(pdev);
+               if (ret) {
+                       pr_err("error:%d occurred in pci_save_state\n", ret);
+                       return ret;
+               }
+
+               /* set chip to sleep mode*/
+               if (share->suspend)
+                       (*share->suspend)(share);
+
+               pci_disable_device(pdev);
+               ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg));
+               if (ret) {
+                       pr_err("error:%d occurred in pci_set_power_state\n", ret);
+                       return ret;
+               }
+       }
+
+       pdev->dev.power.power_state = mesg;
+       console_unlock();
+       return ret;
+}
+
+static int lynxfb_resume(struct pci_dev* pdev)
+{
+       struct fb_info * info;
+       struct lynx_share * share;
+
+       struct lynxfb_par * par;
+       struct lynxfb_crtc * crtc;
+       struct lynx_cursor * cursor;
+
+       int ret;
+       
+
+       ret = 0;
+       share = pci_get_drvdata(pdev);
+
+       console_lock();
+
+       if((ret = pci_set_power_state(pdev, PCI_D0)) != 0){
+               pr_err("error:%d occured in pci_set_power_state\n",ret);
+               return ret;
+       }
+
+
+       if(pdev->dev.power.power_state.event != PM_EVENT_FREEZE){
+               pci_restore_state(pdev);
+               if ((ret = pci_enable_device(pdev)) != 0){
+                       pr_err("error:%d occured in pci_enable_device\n",ret);
+                       return ret;
+               }
+               pci_set_master(pdev);
+       }
+       if(share->resume)
+               (*share->resume)(share);
+
+       hw_sm750_inithw(share,pdev);
+
+
+       info = share->fbinfo[0];
+
+       if(info){
+               par = info->par;
+               crtc = &par->crtc;
+               cursor = &crtc->cursor;
+               memset(cursor->vstart, 0x0, cursor->size);
+               memset(crtc->vScreen,0x0,crtc->vidmem_size);
+               lynxfb_ops_set_par(info);
+               fb_set_suspend(info, 0);
+       }
+
+       info = share->fbinfo[1];
+
+       if(info){
+               par = info->par;
+               crtc = &par->crtc;
+               cursor = &crtc->cursor;
+               memset(cursor->vstart, 0x0, cursor->size);
+               memset(crtc->vScreen,0x0,crtc->vidmem_size);
+               lynxfb_ops_set_par(info);
+               fb_set_suspend(info, 0);
+       }
+
+
+       console_unlock();
+       return ret;
+}
+#endif
+
+static int lynxfb_ops_check_var(struct fb_var_screeninfo* var,struct fb_info* info)
+{
+       struct lynxfb_par * par;
+       struct lynxfb_crtc * crtc;
+       struct lynxfb_output * output;
+       struct lynx_share * share;
+       int ret;
+       resource_size_t request;
+
+       
+       par = info->par;
+       crtc = &par->crtc;
+       output = &par->output;
+       share = par->share;
+       ret = 0;
+
+       pr_debug("check var:%dx%d-%d\n",
+                       var->xres,
+                       var->yres,
+                       var->bits_per_pixel);
+
+
+       switch(var->bits_per_pixel){
+       case 8:
+       case 16:
+       case 24: /* support 24 bpp for only lynx712/722/720 */
+       case 32:
+               break;
+       default:
+               pr_err("bpp %d not supported\n",var->bits_per_pixel);
+               ret = -EINVAL;
+               goto exit;
+       }
+
+       switch(var->bits_per_pixel){
+       case 8:
+               info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+               var->red.offset = 0;
+               var->red.length = 8;
+               var->green.offset = 0;
+               var->green.length = 8;
+               var->blue.offset = 0;
+               var->blue.length = 8;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               break;
+       case 16:
+               var->red.offset = 11;
+               var->red.length = 5;
+               var->green.offset = 5;
+               var->green.length = 6;
+               var->blue.offset = 0;
+               var->blue.length = 5;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               info->fix.visual = FB_VISUAL_TRUECOLOR;
+               break;
+       case 24:
+       case 32:
+               var->red.offset = 16;
+               var->red.length = 8;
+               var->green.offset = 8;
+               var->green.length = 8;
+               var->blue.offset = 0 ;
+               var->blue.length = 8;
+               info->fix.visual = FB_VISUAL_TRUECOLOR;
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       var->height = var->width = -1;
+       var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
+
+       /* check if current fb's video memory big enought to hold the onscreen */
+       request = var->xres_virtual * (var->bits_per_pixel >> 3);
+       /* defaulty crtc->channel go with par->index */
+
+       request = PADDING(crtc->line_pad,request);
+       request = request * var->yres_virtual;
+       if(crtc->vidmem_size < request){
+               pr_err("not enough video memory for mode\n");
+               return -ENOMEM;
+       }
+
+       ret = output->proc_checkMode(output,var);
+       if(!ret)
+               ret = crtc->proc_checkMode(crtc,var);
+exit:
+       return ret;
+}
+
+
+static int lynxfb_ops_setcolreg(unsigned regno,unsigned red,
+                                                                       unsigned green,unsigned blue,
+                                                                       unsigned transp,struct fb_info * info)
+{
+    struct lynxfb_par * par;
+    struct lynxfb_crtc * crtc;
+    struct fb_var_screeninfo * var;
+    int ret;
+
+    par = info->par;
+    crtc = &par->crtc;
+    var = &info->var;
+    ret = 0;
+
+    //pr_debug("regno=%d,red=%d,green=%d,blue=%d\n",regno,red,green,blue);
+    if(regno > 256){
+        pr_err("regno = %d\n",regno);
+        return -EINVAL;
+    }
+
+    if(info->var.grayscale)
+        red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
+
+    if(var->bits_per_pixel == 8 && info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
+    {
+        red >>= 8;
+        green >>= 8;
+        blue >>= 8;
+        ret = crtc->proc_setColReg(crtc,regno,red,green,blue);
+        goto exit;
+    }
+
+
+    if(info->fix.visual == FB_VISUAL_TRUECOLOR && regno < 256 )
+    {
+        u32 val;
+        if(var->bits_per_pixel == 16 ||
+                var->bits_per_pixel == 32 ||
+                var->bits_per_pixel == 24)
+        {
+            val = chan_to_field(red,&var->red);
+            val |= chan_to_field(green,&var->green);
+            val |= chan_to_field(blue,&var->blue);
+            par->pseudo_palette[regno] = val;
+            goto exit;
+        }
+    }
+
+    ret = -EINVAL;
+
+exit:
+    return ret;
+}
+
+static int lynxfb_ops_blank(int blank,struct fb_info* info)
+{
+       struct lynxfb_par * par;
+       struct lynxfb_output * output;
+       
+       pr_debug("blank = %d.\n",blank);
+       par = info->par;
+       output = &par->output;
+       return output->proc_setBLANK(output,blank);
+}
+
+static int sm750fb_set_drv(struct lynxfb_par * par)
+{
+    int ret;
+    struct lynx_share * share;
+    struct sm750_share * spec_share;
+    struct lynxfb_output * output;
+    struct lynxfb_crtc * crtc;
+    
+    ret = 0;
+
+    share = par->share;
+    spec_share = container_of(share,struct sm750_share,share);
+    output = &par->output;
+    crtc = &par->crtc;
+
+    crtc->vidmem_size = (share->dual)?share->vidmem_size>>1:share->vidmem_size;
+    /* setup crtc and output member */
+    spec_share->hwCursor = g_hwcursor;
+
+    crtc->proc_setMode = hw_sm750_crtc_setMode;
+    crtc->proc_checkMode = hw_sm750_crtc_checkMode;
+    crtc->proc_setColReg = hw_sm750_setColReg;
+    crtc->proc_panDisplay = hw_sm750_pan_display;
+    crtc->clear = hw_sm750_crtc_clear;
+    crtc->line_pad = 16;
+    //crtc->xpanstep = crtc->ypanstep = crtc->ywrapstep = 0;
+    crtc->xpanstep = 8;
+    crtc->ypanstep = 1;
+    crtc->ywrapstep = 0;
+
+    output->proc_setMode = hw_sm750_output_setMode;
+    output->proc_checkMode = hw_sm750_output_checkMode;
+
+    output->proc_setBLANK = (share->revid == SM750LE_REVISION_ID)?hw_sm750le_setBLANK:hw_sm750_setBLANK;
+    output->clear = hw_sm750_output_clear;
+    /* chip specific phase */
+    share->accel.de_wait = (share->revid == SM750LE_REVISION_ID)?hw_sm750le_deWait: hw_sm750_deWait;
+    switch (spec_share->state.dataflow)
+    {
+        case sm750_simul_pri:
+            output->paths = sm750_pnc;
+            crtc->channel = sm750_primary;
+            crtc->oScreen = 0;
+            crtc->vScreen = share->pvMem;
+            pr_info("use simul primary mode\n");
+            break;
+        case sm750_simul_sec:
+            output->paths = sm750_pnc;
+            crtc->channel = sm750_secondary;
+            crtc->oScreen = 0;
+            crtc->vScreen = share->pvMem;
+            break;
+        case sm750_dual_normal:
+            if(par->index == 0){
+                output->paths = sm750_panel;
+                crtc->channel = sm750_primary;
+                crtc->oScreen = 0;
+                crtc->vScreen = share->pvMem;
+            }else{
+                output->paths = sm750_crt;
+                crtc->channel = sm750_secondary;
+                /* not consider of padding stuffs for oScreen,need fix*/
+                crtc->oScreen = (share->vidmem_size >> 1);
+                crtc->vScreen = share->pvMem + crtc->oScreen;
+            }
+            break;
+        case sm750_dual_swap:
+            if(par->index == 0){
+                output->paths = sm750_panel;
+                crtc->channel = sm750_secondary;
+                crtc->oScreen = 0;
+                crtc->vScreen = share->pvMem;
+            }else{
+                output->paths = sm750_crt;
+                crtc->channel = sm750_primary;
+                /* not consider of padding stuffs for oScreen,need fix*/
+                crtc->oScreen = (share->vidmem_size >> 1);
+                crtc->vScreen = share->pvMem + crtc->oScreen;
+            }
+            break;
+        default:
+            ret = -EINVAL;
+    }
+
+    return ret;
+}
+
+static struct fb_ops lynxfb_ops={
+       .owner = THIS_MODULE,
+       .fb_check_var =  lynxfb_ops_check_var,
+       .fb_set_par = lynxfb_ops_set_par,
+       .fb_setcolreg = lynxfb_ops_setcolreg,
+       .fb_blank = lynxfb_ops_blank,
+       .fb_fillrect = cfb_fillrect,
+       .fb_imageblit = cfb_imageblit,
+       .fb_copyarea = cfb_copyarea,
+       /* cursor */
+       .fb_cursor = lynxfb_ops_cursor,
+};
+
+
+static int lynxfb_set_fbinfo(struct fb_info* info,int index)
+{
+    int i;
+    struct lynxfb_par * par;
+    struct lynx_share * share;
+    struct lynxfb_crtc * crtc;
+    struct lynxfb_output * output;
+    struct fb_var_screeninfo * var;
+    struct fb_fix_screeninfo * fix;
+
+    const struct fb_videomode * pdb[] = {
+        lynx750_ext, NULL,vesa_modes,
+    };
+    int cdb[] = {ARRAY_SIZE(lynx750_ext),0,VESA_MODEDB_SIZE};
+    static const char * mdb_desc[] ={
+        "driver prepared modes",
+        "kernel prepared default modedb",
+        "kernel HELPERS prepared vesa_modes",
+    };
+
+
+    static const char * fixId[2]=
+    {
+        "sm750_fb1","sm750_fb2",
+    };
+
+    int ret,line_length;
+    
+    ret = 0;
+    par = (struct lynxfb_par *)info->par;
+    share = par->share;
+    crtc = &par->crtc;
+    output = &par->output;
+    var = &info->var;
+    fix = &info->fix;
+
+    /* set index */
+    par->index = index;
+    output->channel = &crtc->channel;
+       sm750fb_set_drv(par);
+        lynxfb_ops.fb_pan_display = lynxfb_ops_pan_display;
+
+
+    /* set current cursor variable and proc pointer,
+     * must be set after crtc member initialized */
+       crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024;
+        crtc->cursor.mmio = share->pvReg + 0x800f0 + (int)crtc->channel * 0x140;
+
+        pr_info("crtc->cursor.mmio = %p\n",crtc->cursor.mmio);
+        crtc->cursor.maxH = crtc->cursor.maxW = 64;
+        crtc->cursor.size = crtc->cursor.maxH*crtc->cursor.maxW*2/8;
+        crtc->cursor.disable = hw_cursor_disable;
+        crtc->cursor.enable = hw_cursor_enable;
+        crtc->cursor.setColor = hw_cursor_setColor;
+        crtc->cursor.setPos = hw_cursor_setPos;
+        crtc->cursor.setSize = hw_cursor_setSize;
+        crtc->cursor.setData = hw_cursor_setData;
+        crtc->cursor.vstart = share->pvMem + crtc->cursor.offset;
+
+
+    crtc->cursor.share = share;
+    memset(crtc->cursor.vstart, 0, crtc->cursor.size);
+    if(!g_hwcursor){
+        lynxfb_ops.fb_cursor = NULL;
+        crtc->cursor.disable(&crtc->cursor);
+    }
+
+
+    /* set info->fbops, must be set before fb_find_mode */
+    if(!share->accel_off){
+        /* use 2d acceleration */
+        lynxfb_ops.fb_fillrect = lynxfb_ops_fillrect;
+        lynxfb_ops.fb_copyarea = lynxfb_ops_copyarea;
+        lynxfb_ops.fb_imageblit = lynxfb_ops_imageblit;
+    }
+    info->fbops = &lynxfb_ops;
+
+    if(!g_fbmode[index]){
+        g_fbmode[index] = g_def_fbmode;
+        if(index)
+            g_fbmode[index] = g_fbmode[0];
+    }
+
+
+       for(i=0;i<3;i++){
+
+               ret = fb_find_mode(var,info,g_fbmode[index],
+                               pdb[i],cdb[i],NULL,8);
+
+               if(ret == 1){
+                       pr_info("success! use specified mode:%s in %s\n",
+                                       g_fbmode[index],
+                                       mdb_desc[i]);
+                       break;
+               }else if(ret == 2){
+                       pr_warn("use specified mode:%s in %s,with an ignored refresh rate\n",
+                                       g_fbmode[index],
+                                       mdb_desc[i]);
+                       break;
+               }else if(ret == 3){
+                       pr_warn("wanna use default mode\n");
+//                     break;
+               }else if(ret == 4){
+                       pr_warn("fall back to any valid mode\n");
+               }else{
+                       pr_warn("ret = %d,fb_find_mode failed,with %s\n",ret,mdb_desc[i]);
+               }
+       }
+
+    /* some member of info->var had been set by fb_find_mode */
+
+    pr_info("Member of info->var is :\n\
+            xres=%d\n\
+            yres=%d\n\
+            xres_virtual=%d\n\
+            yres_virtual=%d\n\
+            xoffset=%d\n\
+            yoffset=%d\n\
+            bits_per_pixel=%d\n \
+            ...\n",var->xres,var->yres,var->xres_virtual,var->yres_virtual,
+            var->xoffset,var->yoffset,var->bits_per_pixel);
+
+    /* set par */
+    par->info = info;
+
+    /* set info */
+    line_length = PADDING(crtc->line_pad,
+            (var->xres_virtual * var->bits_per_pixel/8));
+
+    info->pseudo_palette = &par->pseudo_palette[0];
+    info->screen_base = crtc->vScreen;
+    pr_debug("screen_base vaddr = %p\n",info->screen_base);
+       info->screen_size = line_length * var->yres_virtual;
+       info->flags = FBINFO_FLAG_DEFAULT|0;
+
+    /* set info->fix */
+    fix->type = FB_TYPE_PACKED_PIXELS;
+    fix->type_aux = 0;
+    fix->xpanstep = crtc->xpanstep;
+    fix->ypanstep = crtc->ypanstep;
+    fix->ywrapstep = crtc->ywrapstep;
+    fix->accel = FB_ACCEL_SMI;
+
+    strlcpy(fix->id,fixId[index],sizeof(fix->id));
+
+
+       fix->smem_start = crtc->oScreen + share->vidmem_start;
+       pr_info("fix->smem_start = %lx\n",fix->smem_start);
+    /* according to mmap experiment from user space application,
+     * fix->mmio_len should not larger than virtual size
+     * (xres_virtual x yres_virtual x ByPP)
+     * Below line maybe buggy when user mmap fb dev node and write
+     * data into the bound over virtual size
+     * */
+    fix->smem_len = crtc->vidmem_size;
+    pr_info("fix->smem_len = %x\n",fix->smem_len);
+    info->screen_size = fix->smem_len;
+    fix->line_length = line_length;
+    fix->mmio_start = share->vidreg_start;
+    pr_info("fix->mmio_start = %lx\n",fix->mmio_start);
+    fix->mmio_len = share->vidreg_size;
+    pr_info("fix->mmio_len = %x\n",fix->mmio_len);
+    switch(var->bits_per_pixel)
+    {
+        case 8:
+            fix->visual = FB_VISUAL_PSEUDOCOLOR;
+            break;
+        case 16:
+        case 32:
+            fix->visual = FB_VISUAL_TRUECOLOR;
+            break;
+    }
+
+    /* set var */
+    var->activate = FB_ACTIVATE_NOW;
+    var->accel_flags = 0;
+    var->vmode = FB_VMODE_NONINTERLACED;
+
+    pr_debug("#1 show info->cmap : \nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+            info->cmap.start,info->cmap.len,
+            info->cmap.red,info->cmap.green,info->cmap.blue,
+            info->cmap.transp);
+
+    if((ret = fb_alloc_cmap(&info->cmap,256,0)) < 0){
+        pr_err("Could not allcate memory for cmap.\n");
+        goto exit;
+    }
+
+    pr_debug("#2 show info->cmap : \nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+            info->cmap.start,info->cmap.len,
+            info->cmap.red,info->cmap.green,info->cmap.blue,
+            info->cmap.transp);
+
+exit:
+       lynxfb_ops_check_var(var,info);
+//    lynxfb_ops_set_par(info);
+    return ret;
+}
+
+/*     chip specific g_option configuration routine */
+static void sm750fb_setup(struct lynx_share * share,char * src)
+{
+       struct sm750_share * spec_share;
+       char * opt;
+#ifdef CAP_EXPENSION
+       char * exp_res;
+#endif
+       int swap;
+       
+
+       spec_share = container_of(share,struct sm750_share,share);
+#ifdef CAP_EXPENSIION
+        exp_res = NULL;
+#endif
+        swap = 0;
+
+        spec_share->state.initParm.chip_clk = 0;
+        spec_share->state.initParm.mem_clk = 0;
+        spec_share->state.initParm.master_clk = 0;
+        spec_share->state.initParm.powerMode = 0;
+        spec_share->state.initParm.setAllEngOff = 0;
+        spec_share->state.initParm.resetMemory = 1;
+
+        /*defaultly turn g_hwcursor on for both view */
+        g_hwcursor = 3;
+
+        if(!src || !*src){
+            pr_warn("no specific g_option.\n");
+            goto NO_PARAM;
+        }
+
+        while((opt = strsep(&src,":")) != NULL && *opt != 0){
+                       pr_err("opt=%s\n",opt);
+                       pr_err("src=%s\n",src);
+
+            if(!strncmp(opt,"swap",strlen("swap")))
+                swap = 1;
+            else if(!strncmp(opt,"nocrt",strlen("nocrt")))
+                spec_share->state.nocrt = 1;
+            else if(!strncmp(opt,"36bit",strlen("36bit")))
+                spec_share->state.pnltype = sm750_doubleTFT;
+            else if(!strncmp(opt,"18bit",strlen("18bit")))
+                spec_share->state.pnltype = sm750_dualTFT;
+            else if(!strncmp(opt,"24bit",strlen("24bit")))
+                spec_share->state.pnltype = sm750_24TFT;
+#ifdef CAP_EXPANSION
+            else if(!strncmp(opt,"exp:",strlen("exp:")))
+                exp_res = opt + strlen("exp:");
+#endif
+            else if(!strncmp(opt,"nohwc0",strlen("nohwc0")))
+                g_hwcursor &= ~0x1;
+            else if(!strncmp(opt,"nohwc1",strlen("nohwc1")))
+                g_hwcursor &= ~0x2;
+            else if(!strncmp(opt,"nohwc",strlen("nohwc")))
+                g_hwcursor = 0;
+            else
+            {
+                if(!g_fbmode[0]){
+                    g_fbmode[0] = opt;
+                    pr_info("find fbmode0 : %s\n",g_fbmode[0]);
+                }else if(!g_fbmode[1]){
+                    g_fbmode[1] = opt;
+                    pr_info("find fbmode1 : %s\n",g_fbmode[1]);
+                }else{
+                    pr_warn("How many view you wann set?\n");
+                }
+            }
+        }
+#ifdef CAP_EXPANSION
+        if(getExpRes(exp_res,&spec_share->state.xLCD,&spec_share->state.yLCD))
+        {
+            /* seems exp_res is not valid*/
+            spec_share->state.xLCD = spec_share->state.yLCD = 0;
+        }
+#endif
+
+NO_PARAM:
+        if(share->revid != SM750LE_REVISION_ID){
+            if(share->dual)
+            {
+                if(swap)
+                    spec_share->state.dataflow = sm750_dual_swap;
+                else
+                    spec_share->state.dataflow = sm750_dual_normal;
+            }else{
+                if(swap)
+                    spec_share->state.dataflow = sm750_simul_sec;
+                else
+                    spec_share->state.dataflow = sm750_simul_pri;
+            }
+        }else{
+            /* SM750LE only have one crt channel */
+            spec_share->state.dataflow = sm750_simul_sec;
+            /* sm750le do not have complex attributes*/
+            spec_share->state.nocrt = 0;
+        }
+}
+
+static int lynxfb_pci_probe(struct pci_dev * pdev,
+               const struct pci_device_id * ent)
+{
+       struct fb_info * info[] = {NULL,NULL};
+       struct lynx_share * share = NULL;
+
+       struct sm750_share *spec_share = NULL;
+       size_t spec_offset = 0;
+       int fbidx;
+       
+
+       /* enable device */
+       if(pci_enable_device(pdev)){
+               pr_err("can not enable device.\n");
+               goto err_enable;
+       }
+
+       /* though offset of share in sm750_share is 0,
+        * we use this marcro as the same */
+       spec_offset = offsetof(struct sm750_share,share);
+
+       spec_share = kzalloc(sizeof(*spec_share),GFP_KERNEL);
+       if(!spec_share){
+               pr_err("Could not allocate memory for share.\n");
+               goto err_share;
+       }
+
+       /* setting share structure */
+       share = (struct lynx_share * )(&(spec_share->share));
+       share->fbinfo[0] = share->fbinfo[1] = NULL;
+       share->devid = pdev->device;
+       share->revid = pdev->revision;
+
+       pr_info("share->revid = %02x\n",share->revid);
+       share->pdev = pdev;
+#ifdef CONFIG_MTRR
+       share->mtrr_off = g_nomtrr;
+       share->mtrr.vram = 0;
+       share->mtrr.vram_added = 0;
+#endif
+       share->accel_off = g_noaccel;
+       share->dual = g_dualview;
+       spin_lock_init(&share->slock);
+
+       if(!share->accel_off){
+               /* hook deInit and 2d routines, notes that below hw_xxx
+                * routine can work on most of lynx chips
+                * if some chip need specific function,please hook it in smXXX_set_drv
+                * routine */
+               share->accel.de_init = hw_de_init;
+               share->accel.de_fillrect = hw_fillrect;
+               share->accel.de_copyarea = hw_copyarea;
+               share->accel.de_imageblit = hw_imageblit;
+               pr_info("enable 2d acceleration\n");
+       }else{
+               pr_info("disable 2d acceleration\n");
+       }
+
+       /* call chip specific setup routine  */
+       sm750fb_setup(share,g_settings);
+
+       /* call chip specific mmap routine */
+       if(hw_sm750_map(share,pdev)){
+               pr_err("Memory map failed\n");
+               goto err_map;
+       }
+
+#ifdef CONFIG_MTRR
+       if(!share->mtrr_off){
+               pr_info("enable mtrr\n");
+               share->mtrr.vram = mtrr_add(share->vidmem_start,
+                               share->vidmem_size,
+                               MTRR_TYPE_WRCOMB,1);
+
+               if(share->mtrr.vram < 0){
+                       /* don't block driver with the failure of MTRR */
+                       pr_err("Unable to setup MTRR.\n");
+               }else{
+                       share->mtrr.vram_added = 1;
+                       pr_info("MTRR added succesfully\n");
+               }
+       }
+#endif
+
+       memset(share->pvMem,0,share->vidmem_size);
+
+       pr_info("sm%3x mmio address = %p\n",share->devid,share->pvReg);
+
+       pci_set_drvdata(pdev,share);
+
+       /* call chipInit routine */
+       hw_sm750_inithw(share,pdev);
+
+       /* allocate frame buffer info structor according to g_dualview */
+               fbidx = 0;
+ALLOC_FB:
+               info[fbidx] = framebuffer_alloc(sizeof(struct lynxfb_par),&pdev->dev);
+               if(!info[fbidx])
+               {
+                       pr_err("Could not allocate framebuffer #%d.\n",fbidx);
+                       if(fbidx == 0)
+                               goto err_info0_alloc;
+                       else
+                               goto err_info1_alloc;
+               }
+               else
+               {
+                       struct lynxfb_par * par;
+                       int errno;
+                       pr_info("framebuffer #%d alloc okay\n",fbidx);
+                       share->fbinfo[fbidx] = info[fbidx];
+                       par = info[fbidx]->par;
+                       par->share = share;
+
+                       /* set fb_info structure */
+                       if(lynxfb_set_fbinfo(info[fbidx],fbidx)){
+                               pr_err("Failed to initial fb_info #%d.\n",fbidx);
+                               if(fbidx == 0)
+                                       goto err_info0_set;
+                               else
+                                       goto err_info1_set;
+                       }
+
+                       /* register frame buffer*/
+                       pr_info("Ready to register framebuffer #%d.\n",fbidx);
+                       errno = register_framebuffer(info[fbidx]);
+                       if (errno < 0) {
+                               pr_err("Failed to register fb_info #%d. err %d\n",fbidx, errno);
+                               if(fbidx == 0)
+                                       goto err_register0;
+                               else
+                                       goto err_register1;
+                       }
+                       pr_info("Accomplished register framebuffer #%d.\n",fbidx);
+               }
+
+               /* no dual view by far */
+               fbidx++;
+               if(share->dual && fbidx < 2)
+                       goto ALLOC_FB;
+
+       return 0;
+
+err_register1:
+err_info1_set:
+       framebuffer_release(info[1]);
+err_info1_alloc:
+       unregister_framebuffer(info[0]);
+err_register0:
+err_info0_set:
+       framebuffer_release(info[0]);
+err_info0_alloc:
+err_map:
+       kfree(spec_share);
+err_share:
+err_enable:
+       return -ENODEV;
+}
+
+static void __exit lynxfb_pci_remove(struct pci_dev * pdev)
+{
+       struct fb_info * info;
+       struct lynx_share * share;
+       void * spec_share;
+       struct lynxfb_par * par;
+       int cnt;
+
+       cnt = 2;
+       share = pci_get_drvdata(pdev);
+
+       while(cnt-- > 0){
+               info = share->fbinfo[cnt];
+               if(!info)
+                       continue;
+               par = info->par;
+
+               unregister_framebuffer(info);
+               /* clean crtc & output allocations*/
+               par->crtc.clear(&par->crtc);
+               par->output.clear(&par->output);
+               /* release frame buffer*/
+               framebuffer_release(info);
+       }
+#ifdef CONFIG_MTRR
+       if(share->mtrr.vram_added)
+               mtrr_del(share->mtrr.vram,share->vidmem_start,share->vidmem_size);
+#endif
+       //      pci_release_regions(pdev);
+
+       iounmap(share->pvReg);
+       iounmap(share->pvMem);
+       spec_share = container_of(share,struct sm750_share,share);
+       kfree(g_settings);
+       kfree(spec_share);
+       pci_set_drvdata(pdev,NULL);
+}
+
+static int __init lynxfb_setup(char * options)
+{
+       int len;
+       char * opt,*tmp;
+       
+
+       if(!options || !*options){
+               pr_warn("no options.\n");
+               return 0;
+       }
+
+       pr_info("options:%s\n",options);
+
+       len = strlen(options) + 1;
+       g_settings = kzalloc(len, GFP_KERNEL);
+       if(!g_settings)
+               return -ENOMEM;
+
+       tmp = g_settings;
+
+       /*      Notes:
+               char * strsep(char **s,const char * ct);
+               @s: the string to be searched
+               @ct :the characters to search for
+
+               strsep() updates @options to pointer after the first found token
+               it also returns the pointer ahead the token.
+               */
+       while((opt = strsep(&options,":"))!=NULL)
+       {
+               /* options that mean for any lynx chips are configured here */
+               if(!strncmp(opt,"noaccel",strlen("noaccel")))
+                       g_noaccel = 1;
+#ifdef CONFIG_MTRR
+               else if(!strncmp(opt,"nomtrr",strlen("nomtrr")))
+                       g_nomtrr = 1;
+#endif
+               else if(!strncmp(opt,"dual",strlen("dual")))
+                       g_dualview = 1;
+               else
+               {
+                       strcat(tmp,opt);
+                       tmp += strlen(opt);
+                       if(options != NULL)
+                               *tmp++ = ':';
+                       else
+                               *tmp++ = 0;
+               }
+       }
+
+       /* misc g_settings are transport to chip specific routines */
+       pr_info("parameter left for chip specific analysis:%s\n",g_settings);
+       return 0;
+}
+
+static struct pci_device_id smi_pci_table[] = {
+       { PCI_DEVICE(0x126f, 0x0750), },
+       {0,}
+};
+
+MODULE_DEVICE_TABLE(pci,smi_pci_table);
+
+static struct pci_driver lynxfb_driver = {
+       .name =         "sm750fb",
+       .id_table =     smi_pci_table,
+       .probe =        lynxfb_pci_probe,
+       .remove =       lynxfb_pci_remove,
+#ifdef CONFIG_PM
+       .suspend = lynxfb_suspend,
+       .resume = lynxfb_resume,
+#endif
+};
+
+
+static int __init lynxfb_init(void)
+{
+       char *option ;
+       int ret;
+
+#ifdef MODULE
+       option = g_option;
+#else
+       if(fb_get_options("sm750fb",&option))
+               return -ENODEV;
+#endif
+
+       lynxfb_setup(option);
+       ret = pci_register_driver(&lynxfb_driver);
+       return ret;
+}
+module_init(lynxfb_init);
+
+static void __exit lynxfb_exit(void)
+{
+       pci_unregister_driver(&lynxfb_driver);
+}
+module_exit(lynxfb_exit);
+
+module_param(g_option,charp,S_IRUGO);
+
+MODULE_PARM_DESC(g_option,
+               "\n\t\tCommon options:\n"
+               "\t\tnoaccel:disable 2d capabilities\n"
+               "\t\tnomtrr:disable MTRR attribute for video memory\n"
+               "\t\tdualview:dual frame buffer feature enabled\n"
+               "\t\tnohwc:disable hardware cursor\n"
+               "\t\tUsual example:\n"
+               "\t\tinsmod ./sm750fb.ko g_option=\"noaccel,nohwc,1280x1024-8@60\"\n"
+               );
+
+MODULE_AUTHOR("monk liu <monk.liu@siliconmotion.com>");
+MODULE_AUTHOR("Sudip Mukherjee <sudip@vectorindia.org>");
+MODULE_DESCRIPTION("Frame buffer driver for SM750 chipset");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
new file mode 100644 (file)
index 0000000..0847d2b
--- /dev/null
@@ -0,0 +1,186 @@
+#ifndef LYNXDRV_H_
+#define LYNXDRV_H_
+
+
+
+#define FB_ACCEL_SMI 0xab
+/* please use revision id to distinguish sm750le and sm750*/
+#define SPC_SM750      0
+
+//#define SPC_SM750LE 8
+
+#define MB(x) ((x)<<20)
+#define MHZ(x) ((x) * 1000000)
+/* align should be 2,4,8,16 */
+#define PADDING(align,data) (((data)+(align)-1)&(~((align) -1)))
+extern int smi_indent;
+
+
+struct lynx_accel{
+       /* base virtual address of DPR registers */
+       volatile unsigned char __iomem * dprBase;
+       /* base virtual address of de data port */
+       volatile unsigned char __iomem * dpPortBase;
+
+       /* function fointers */
+       void (*de_init)(struct lynx_accel *);
+
+       int (*de_wait)(void);/* see if hardware ready to work */
+
+       int (*de_fillrect)(struct lynx_accel *,u32,u32,u32,
+                                                       u32,u32,u32,u32,u32,u32);
+
+       int (*de_copyarea)(struct lynx_accel *,u32,u32,u32,u32,
+                                               u32,u32,u32,u32,
+                                               u32,u32,u32,u32);
+
+       int (*de_imageblit)(struct lynx_accel *,const char *,u32,u32,u32,
+                                               u32,u32,u32,u32,u32,u32,u32,u32,u32);
+
+};
+
+/*     lynx_share stands for a presentation of two frame buffer
+       that use one smi adaptor , it is similar to a basic class of C++
+*/
+struct lynx_share{
+       /* common members */
+       u16 devid;
+       u8 revid;
+       struct pci_dev * pdev;
+       struct fb_info * fbinfo[2];
+       struct lynx_accel accel;
+       int accel_off;
+       int dual;
+#ifdef CONFIG_MTRR
+               int mtrr_off;
+               struct{
+                       int vram;
+                       int vram_added;
+               }mtrr;
+#endif
+       /* all smi graphic adaptor got below attributes */
+       unsigned long vidmem_start;
+       unsigned long vidreg_start;
+       __u32 vidmem_size;
+       __u32 vidreg_size;
+       void __iomem * pvReg;
+       unsigned char __iomem * pvMem;
+       /* locks*/
+       spinlock_t slock;
+       /* function pointers */
+       void (*suspend)(struct lynx_share*);
+       void (*resume)(struct lynx_share*);
+};
+
+struct lynx_cursor{
+       /* cursor width ,height and size */
+       int w;
+       int h;
+       int size;
+       /* hardware limitation */
+       int maxW;
+       int maxH;
+       /* base virtual address and offset  of cursor image */
+       char __iomem * vstart;
+       int offset;
+       /* mmio addr of hw cursor */
+       volatile char __iomem * mmio;
+       /* the lynx_share of this adaptor */
+       struct lynx_share * share;
+       /* proc_routines */
+       void (*enable)(struct lynx_cursor *);
+       void (*disable)(struct lynx_cursor *);
+       void (*setSize)(struct lynx_cursor *,int,int);
+       void (*setPos)(struct lynx_cursor *,int,int);
+       void (*setColor)(struct lynx_cursor *,u32,u32);
+       void (*setData)(struct lynx_cursor *,u16,const u8*,const u8*);
+};
+
+struct lynxfb_crtc{
+       unsigned char __iomem * vCursor;//virtual address of cursor
+       unsigned char __iomem * vScreen;//virtual address of on_screen
+       int oCursor;//cursor address offset in vidmem
+       int oScreen;//onscreen address offset in vidmem
+       int channel;/* which channel this crtc stands for*/
+       resource_size_t vidmem_size;/* this view's video memory max size */
+
+       /* below attributes belong to info->fix, their value depends on specific adaptor*/
+       u16 line_pad;/* padding information:0,1,2,4,8,16,... */
+       u16 xpanstep;
+       u16 ypanstep;
+       u16 ywrapstep;
+
+       void * priv;
+
+       int(*proc_setMode)(struct lynxfb_crtc*,
+                                               struct fb_var_screeninfo*,
+                                               struct fb_fix_screeninfo*);
+
+       int(*proc_checkMode)(struct lynxfb_crtc*,struct fb_var_screeninfo*);
+       int(*proc_setColReg)(struct lynxfb_crtc*,ushort,ushort,ushort,ushort);
+       void (*clear)(struct lynxfb_crtc*);
+        /* pan display */
+       int (*proc_panDisplay)(struct lynxfb_crtc *,
+                              const struct fb_var_screeninfo *,
+                              const struct fb_info *);
+       /* cursor information */
+       struct lynx_cursor cursor;
+};
+
+struct lynxfb_output{
+       int dpms;
+       int paths;
+       /*      which paths(s) this output stands for,for sm750:
+               paths=1:means output for panel paths
+               paths=2:means output for crt paths
+               paths=3:means output for both panel and crt paths
+       */
+
+       int * channel;
+       /*      which channel these outputs linked with,for sm750:
+               *channel=0 means primary channel
+               *channel=1 means secondary channel
+               output->channel ==> &crtc->channel
+       */
+       void * priv;
+
+       int(*proc_setMode)(struct lynxfb_output*,
+                                               struct fb_var_screeninfo*,
+                                               struct fb_fix_screeninfo*);
+
+       int(*proc_checkMode)(struct lynxfb_output*,struct fb_var_screeninfo*);
+       int(*proc_setBLANK)(struct lynxfb_output*,int);
+       void  (*clear)(struct lynxfb_output*);
+};
+
+struct lynxfb_par{
+       /* either 0 or 1 for dual head adaptor,0 is the older one registered */
+       int index;
+       unsigned int pseudo_palette[256];
+       struct lynxfb_crtc crtc;
+       struct lynxfb_output output;
+       struct fb_info * info;
+       struct lynx_share * share;
+};
+
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+
+#define PS_TO_HZ(ps)   \
+                       ({      \
+                       unsigned long long hz = 1000*1000*1000*1000ULL; \
+                       do_div(hz,ps);  \
+                       (unsigned long)hz;})
+
+static inline unsigned long ps_to_hz(unsigned int psvalue)
+{
+       unsigned long long numerator=1000*1000*1000*1000ULL;
+       /* 10^12 / picosecond period gives frequency in Hz */
+       do_div(numerator, psvalue);
+       return (unsigned long)numerator;
+}
+
+
+#endif
diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c
new file mode 100644 (file)
index 0000000..6521c3b
--- /dev/null
@@ -0,0 +1,515 @@
+#include<linux/module.h>
+#include<linux/kernel.h>
+#include<linux/errno.h>
+#include<linux/string.h>
+#include<linux/mm.h>
+#include<linux/slab.h>
+#include<linux/delay.h>
+#include<linux/fb.h>
+#include<linux/ioport.h>
+#include<linux/init.h>
+#include<linux/pci.h>
+#include<linux/vmalloc.h>
+#include<linux/pagemap.h>
+#include <linux/console.h>
+#include<linux/platform_device.h>
+#include<linux/screen_info.h>
+
+#include "sm750.h"
+#include "sm750_accel.h"
+#include "sm750_help.h"
+static inline void write_dpr(struct lynx_accel * accel,int offset,u32 regValue)
+{
+       writel(regValue,accel->dprBase + offset);
+}
+
+static inline u32 read_dpr(struct lynx_accel * accel,int offset)
+{
+       return readl(accel->dprBase + offset);
+}
+
+static inline void write_dpPort(struct lynx_accel * accel,u32 data)
+{
+       writel(data,accel->dpPortBase);
+}
+
+void hw_de_init(struct lynx_accel * accel)
+{
+       /* setup 2d engine registers */
+       u32 reg,clr;
+       
+       write_dpr(accel,DE_MASKS,0xFFFFFFFF);
+
+       /* dpr1c */
+       reg = FIELD_SET(0,DE_STRETCH_FORMAT,PATTERN_XY,NORMAL)|
+               FIELD_VALUE(0,DE_STRETCH_FORMAT,PATTERN_Y,0)|
+               FIELD_VALUE(0,DE_STRETCH_FORMAT,PATTERN_X,0)|
+               FIELD_SET(0,DE_STRETCH_FORMAT,ADDRESSING,XY)|
+               FIELD_VALUE(0,DE_STRETCH_FORMAT,SOURCE_HEIGHT,3);
+
+       clr = FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_XY)&
+               FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_Y)&
+               FIELD_CLEAR(DE_STRETCH_FORMAT,PATTERN_X)&
+               FIELD_CLEAR(DE_STRETCH_FORMAT,ADDRESSING)&
+               FIELD_CLEAR(DE_STRETCH_FORMAT,SOURCE_HEIGHT);
+
+       /* DE_STRETCH bpp format need be initilized in setMode routine */
+       write_dpr(accel,DE_STRETCH_FORMAT,(read_dpr(accel,DE_STRETCH_FORMAT) & clr) | reg);
+
+       /* disable clipping and transparent */
+       write_dpr(accel,DE_CLIP_TL,0);//dpr2c
+       write_dpr(accel,DE_CLIP_BR,0);//dpr30
+
+       write_dpr(accel,DE_COLOR_COMPARE_MASK,0);//dpr24
+       write_dpr(accel,DE_COLOR_COMPARE,0);
+
+       reg = FIELD_SET(0,DE_CONTROL,TRANSPARENCY,DISABLE)|
+               FIELD_SET(0,DE_CONTROL,TRANSPARENCY_MATCH,OPAQUE)|
+               FIELD_SET(0,DE_CONTROL,TRANSPARENCY_SELECT,SOURCE);
+
+       clr = FIELD_CLEAR(DE_CONTROL,TRANSPARENCY)&
+               FIELD_CLEAR(DE_CONTROL,TRANSPARENCY_MATCH)&
+               FIELD_CLEAR(DE_CONTROL,TRANSPARENCY_SELECT);
+
+       /* dpr0c */
+       write_dpr(accel,DE_CONTROL,(read_dpr(accel,DE_CONTROL)&clr)|reg);
+}
+
+/* set2dformat only be called from setmode functions
+ * but if you need dual framebuffer driver,need call set2dformat
+ * every time you use 2d function */
+
+void hw_set2dformat(struct lynx_accel * accel,int fmt)
+{
+       u32 reg;
+       
+       /* fmt=0,1,2 for 8,16,32,bpp on sm718/750/502 */
+       reg = read_dpr(accel,DE_STRETCH_FORMAT);
+       reg = FIELD_VALUE(reg,DE_STRETCH_FORMAT,PIXEL_FORMAT,fmt);
+       write_dpr(accel,DE_STRETCH_FORMAT,reg);
+}
+
+/* seems sm712 RectFill command is broken,so need use BitBlt to
+ * replace it. */
+
+int hw712_fillrect(struct lynx_accel * accel,
+                               u32 base,u32 pitch,u32 Bpp,
+                               u32 x,u32 y,u32 width,u32 height,
+                               u32 color,u32 rop)
+{
+       u32 deCtrl;
+       if(accel->de_wait() != 0)
+       {
+               /* int time wait and always busy,seems hardware
+                * got something error */
+               pr_debug("%s:De engine always bussy\n",__func__);
+               return -1;
+       }
+       /* 24bpp 2d acceleration still not work,we already support 2d on
+        * both 8/16/32 bpp now, so there is no harm if we disable 2d on
+        * 24bpp for current stage. */
+#if 0
+       if(Bpp == 3){
+               width *= 3;
+               x *= 3;
+               write_dpr(accel,DE_PITCH,
+                       FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch)|
+                       FIELD_VALUE(0,DE_PITCH,SOURCE,pitch));//dpr10
+       }
+       else
+#endif
+       {
+               write_dpr(accel,DE_PITCH,
+                       FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)|
+                       FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10
+
+       }
+
+       write_dpr(accel,DE_FOREGROUND,color);//DPR14
+       write_dpr(accel,DE_MONO_PATTERN_HIGH,~0);//DPR34
+       write_dpr(accel,DE_MONO_PATTERN_LOW,~0);//DPR38
+
+       write_dpr(accel,DE_WINDOW_SOURCE_BASE,base);//dpr44
+       write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40
+
+
+       write_dpr(accel,DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)|
+                       FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr3c
+
+
+       write_dpr(accel,DE_DESTINATION,
+                       FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)|
+                       FIELD_VALUE(0,DE_DESTINATION,X,x)|
+                       FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4
+
+       write_dpr(accel,DE_DIMENSION,
+                       FIELD_VALUE(0,DE_DIMENSION,X,width)|
+                       FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8
+
+       deCtrl =
+               FIELD_SET(0,DE_CONTROL,STATUS,START)|
+               FIELD_SET(0,DE_CONTROL,COMMAND,BITBLT)|
+               FIELD_SET(0,DE_CONTROL,ROP2_SOURCE,PATTERN)|
+               FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)|
+               FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc
+#if 0
+               /* dump registers */
+               int i;
+               inf_msg("x,y,w,h = %d,%d,%d,%d\n",x,y,width,height);
+               for(i=0x04;i<=0x44;i+=4){
+                       inf_msg("dpr%02x = %08x\n",i,read_dpr(accel,i));
+               }
+               inf_msg("deCtrl = %08x\n",deCtrl);
+#endif
+
+       write_dpr(accel,DE_CONTROL,deCtrl);
+       return 0;
+}
+
+int hw_fillrect(struct lynx_accel * accel,
+                               u32 base,u32 pitch,u32 Bpp,
+                               u32 x,u32 y,u32 width,u32 height,
+                               u32 color,u32 rop)
+{
+       u32 deCtrl;
+
+       if(accel->de_wait() != 0)
+       {
+               /* int time wait and always busy,seems hardware
+                * got something error */
+               pr_debug("%s:De engine always bussy\n",__func__);
+               return -1;
+       }
+
+       write_dpr(accel,DE_WINDOW_DESTINATION_BASE,base);//dpr40
+       write_dpr(accel,DE_PITCH,
+                       FIELD_VALUE(0,DE_PITCH,DESTINATION,pitch/Bpp)|
+                       FIELD_VALUE(0,DE_PITCH,SOURCE,pitch/Bpp));//dpr10
+
+       write_dpr(accel,DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0,DE_WINDOW_WIDTH,DESTINATION,pitch/Bpp)|
+                       FIELD_VALUE(0,DE_WINDOW_WIDTH,SOURCE,pitch/Bpp));//dpr44
+
+       write_dpr(accel,DE_FOREGROUND,color);//DPR14
+
+       write_dpr(accel,DE_DESTINATION,
+                       FIELD_SET(0,DE_DESTINATION,WRAP,DISABLE)|
+                       FIELD_VALUE(0,DE_DESTINATION,X,x)|
+                       FIELD_VALUE(0,DE_DESTINATION,Y,y));//dpr4
+
+       write_dpr(accel,DE_DIMENSION,
+                       FIELD_VALUE(0,DE_DIMENSION,X,width)|
+                       FIELD_VALUE(0,DE_DIMENSION,Y_ET,height));//dpr8
+
+       deCtrl =
+               FIELD_SET(0,DE_CONTROL,STATUS,START)|
+               FIELD_SET(0,DE_CONTROL,DIRECTION,LEFT_TO_RIGHT)|
+               FIELD_SET(0,DE_CONTROL,LAST_PIXEL,ON)|
+               FIELD_SET(0,DE_CONTROL,COMMAND,RECTANGLE_FILL)|
+               FIELD_SET(0,DE_CONTROL,ROP_SELECT,ROP2)|
+               FIELD_VALUE(0,DE_CONTROL,ROP,rop);//dpr0xc
+
+       write_dpr(accel,DE_CONTROL,deCtrl);
+       return 0;
+}
+
+int hw_copyarea(
+struct lynx_accel * accel,
+unsigned int sBase,  /* Address of source: offset in frame buffer */
+unsigned int sPitch, /* Pitch value of source surface in BYTE */
+unsigned int sx,
+unsigned int sy,     /* Starting coordinate of source surface */
+unsigned int dBase,  /* Address of destination: offset in frame buffer */
+unsigned int dPitch, /* Pitch value of destination surface in BYTE */
+unsigned int Bpp,    /* Color depth of destination surface */
+unsigned int dx,
+unsigned int dy,     /* Starting coordinate of destination surface */
+unsigned int width,
+unsigned int height, /* width and height of rectangle in pixel value */
+unsigned int rop2)   /* ROP value */
+{
+    unsigned int nDirection, de_ctrl;
+    int opSign;
+    nDirection = LEFT_TO_RIGHT;
+       /* Direction of ROP2 operation: 1 = Left to Right, (-1) = Right to Left */
+    opSign = 1;
+    de_ctrl = 0;
+
+    /* If source and destination are the same surface, need to check for overlay cases */
+    if (sBase == dBase && sPitch == dPitch)
+    {
+        /* Determine direction of operation */
+        if (sy < dy)
+        {
+            /* +----------+
+               |S         |
+               |   +----------+
+               |   |      |   |
+               |   |      |   |
+               +---|------+   |
+                   |         D|
+                   +----------+ */
+
+            nDirection = BOTTOM_TO_TOP;
+        }
+        else if (sy > dy)
+        {
+            /* +----------+
+               |D         |
+               |   +----------+
+               |   |      |   |
+               |   |      |   |
+               +---|------+   |
+                   |         S|
+                   +----------+ */
+
+            nDirection = TOP_TO_BOTTOM;
+        }
+        else
+        {
+            /* sy == dy */
+
+            if (sx <= dx)
+            {
+                /* +------+---+------+
+                   |S     |   |     D|
+                   |      |   |      |
+                   |      |   |      |
+                   |      |   |      |
+                   +------+---+------+ */
+
+                nDirection = RIGHT_TO_LEFT;
+            }
+            else
+            {
+                /* sx > dx */
+
+                /* +------+---+------+
+                   |D     |   |     S|
+                   |      |   |      |
+                   |      |   |      |
+                   |      |   |      |
+                   +------+---+------+ */
+
+                nDirection = LEFT_TO_RIGHT;
+            }
+        }
+    }
+
+    if ((nDirection == BOTTOM_TO_TOP) || (nDirection == RIGHT_TO_LEFT))
+    {
+        sx += width - 1;
+        sy += height - 1;
+        dx += width - 1;
+        dy += height - 1;
+        opSign = (-1);
+    }
+
+    /* Note:
+       DE_FOREGROUND are DE_BACKGROUND are don't care.
+       DE_COLOR_COMPARE and DE_COLOR_COMPARE_MAKS are set by set deSetTransparency().
+    */
+
+    /* 2D Source Base.
+       It is an address offset (128 bit aligned) from the beginning of frame buffer.
+    */
+    write_dpr(accel,DE_WINDOW_SOURCE_BASE, sBase);//dpr40
+
+    /* 2D Destination Base.
+       It is an address offset (128 bit aligned) from the beginning of frame buffer.
+    */
+    write_dpr(accel,DE_WINDOW_DESTINATION_BASE, dBase);//dpr44
+
+#if 0
+    /* Program pitch (distance between the 1st points of two adjacent lines).
+       Note that input pitch is BYTE value, but the 2D Pitch register uses
+       pixel values. Need Byte to pixel convertion.
+    */
+       if(Bpp == 3){
+                       sx *= 3;
+                       dx *= 3;
+                       width *= 3;
+               write_dpr(accel,DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
+                               FIELD_VALUE(0, DE_PITCH, SOURCE,      sPitch));//dpr10
+       }
+       else
+#endif
+       {
+               write_dpr(accel,DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION, (dPitch/Bpp)) |
+                               FIELD_VALUE(0, DE_PITCH, SOURCE,      (sPitch/Bpp)));//dpr10
+       }
+
+    /* Screen Window width in Pixels.
+       2D engine uses this value to calculate the linear address in frame buffer for a given point.
+    */
+    write_dpr(accel,DE_WINDOW_WIDTH,
+        FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/Bpp)) |
+        FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (sPitch/Bpp)));//dpr3c
+
+       if (accel->de_wait() != 0){
+               return -1;
+       }
+
+    {
+
+        write_dpr(accel,DE_SOURCE,
+            FIELD_SET  (0, DE_SOURCE, WRAP, DISABLE) |
+            FIELD_VALUE(0, DE_SOURCE, X_K1, sx)   |
+            FIELD_VALUE(0, DE_SOURCE, Y_K2, sy));//dpr0
+        write_dpr(accel,DE_DESTINATION,
+            FIELD_SET  (0, DE_DESTINATION, WRAP, DISABLE) |
+            FIELD_VALUE(0, DE_DESTINATION, X,    dx)  |
+            FIELD_VALUE(0, DE_DESTINATION, Y,    dy));//dpr04
+        write_dpr(accel,DE_DIMENSION,
+            FIELD_VALUE(0, DE_DIMENSION, X,    width) |
+            FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08
+
+        de_ctrl =
+            FIELD_VALUE(0, DE_CONTROL, ROP, rop2) |
+            FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+            FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) |
+            ((nDirection == RIGHT_TO_LEFT) ?
+            FIELD_SET(0, DE_CONTROL, DIRECTION, RIGHT_TO_LEFT)
+            : FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT)) |
+            FIELD_SET(0, DE_CONTROL, STATUS, START);
+               write_dpr(accel,DE_CONTROL,de_ctrl);//dpr0c
+    }
+
+    return 0;
+}
+
+static unsigned int deGetTransparency(struct lynx_accel * accel)
+{
+    unsigned int de_ctrl;
+
+    de_ctrl = read_dpr(accel,DE_CONTROL);
+
+    de_ctrl &=
+        FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) |
+        FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT)|
+        FIELD_MASK(DE_CONTROL_TRANSPARENCY);
+
+    return de_ctrl;
+}
+
+int hw_imageblit(struct lynx_accel *accel,
+                const char *pSrcbuf, /* pointer to start of source buffer in system memory */
+                u32 srcDelta,          /* Pitch value (in bytes) of the source buffer, +ive means top down and -ive mean button up */
+                u32 startBit, /* Mono data can start at any bit in a byte, this value should be 0 to 7 */
+                u32 dBase,    /* Address of destination: offset in frame buffer */
+                u32 dPitch,   /* Pitch value of destination surface in BYTE */
+                u32 bytePerPixel,      /* Color depth of destination surface */
+                u32 dx,
+                u32 dy,       /* Starting coordinate of destination surface */
+                u32 width,
+                u32 height,   /* width and height of rectange in pixel value */
+                u32 fColor,   /* Foreground color (corresponding to a 1 in the monochrome data */
+                u32 bColor,   /* Background color (corresponding to a 0 in the monochrome data */
+                u32 rop2)     /* ROP value */
+{
+    unsigned int ulBytesPerScan;
+    unsigned int ul4BytesPerScan;
+    unsigned int ulBytesRemain;
+    unsigned int de_ctrl = 0;
+    unsigned char ajRemain[4];
+    int i, j;
+
+    startBit &= 7; /* Just make sure the start bit is within legal range */
+    ulBytesPerScan = (width + startBit + 7) / 8;
+    ul4BytesPerScan = ulBytesPerScan & ~3;
+    ulBytesRemain = ulBytesPerScan & 3;
+
+       if(accel->de_wait() != 0)
+    {
+//             inf_msg("*** ImageBlit return -1 ***\n");
+        return -1;
+    }
+
+    /* 2D Source Base.
+       Use 0 for HOST Blt.
+    */
+    write_dpr(accel,DE_WINDOW_SOURCE_BASE, 0);
+
+    /* 2D Destination Base.
+       It is an address offset (128 bit aligned) from the beginning of frame buffer.
+    */
+    write_dpr(accel,DE_WINDOW_DESTINATION_BASE, dBase);
+#if 0
+    /* Program pitch (distance between the 1st points of two adjacent lines).
+       Note that input pitch is BYTE value, but the 2D Pitch register uses
+       pixel values. Need Byte to pixel convertion.
+    */
+       if(bytePerPixel == 3 ){
+               dx *= 3;
+               width *= 3;
+               startBit *= 3;
+               write_dpr(accel,DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch) |
+                               FIELD_VALUE(0, DE_PITCH, SOURCE,      dPitch));//dpr10
+
+       }
+       else
+#endif
+       {
+               write_dpr(accel,DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION, dPitch/bytePerPixel) |
+                               FIELD_VALUE(0, DE_PITCH, SOURCE,      dPitch/bytePerPixel));//dpr10
+       }
+
+    /* Screen Window width in Pixels.
+       2D engine uses this value to calculate the linear address in frame buffer for a given point.
+    */
+    write_dpr(accel,DE_WINDOW_WIDTH,
+        FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION, (dPitch/bytePerPixel)) |
+        FIELD_VALUE(0, DE_WINDOW_WIDTH, SOURCE,      (dPitch/bytePerPixel)));
+
+    /* Note: For 2D Source in Host Write, only X_K1_MONO field is needed, and Y_K2 field is not used.
+             For mono bitmap, use startBit for X_K1. */
+    write_dpr(accel,DE_SOURCE,
+        FIELD_SET  (0, DE_SOURCE, WRAP, DISABLE)       |
+        FIELD_VALUE(0, DE_SOURCE, X_K1_MONO, startBit));//dpr00
+
+    write_dpr(accel,DE_DESTINATION,
+        FIELD_SET  (0, DE_DESTINATION, WRAP, DISABLE) |
+        FIELD_VALUE(0, DE_DESTINATION, X,    dx)    |
+        FIELD_VALUE(0, DE_DESTINATION, Y,    dy));//dpr04
+
+    write_dpr(accel,DE_DIMENSION,
+        FIELD_VALUE(0, DE_DIMENSION, X,    width) |
+        FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));//dpr08
+
+    write_dpr(accel,DE_FOREGROUND, fColor);
+    write_dpr(accel,DE_BACKGROUND, bColor);
+
+       de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2)         |
+               FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2)    |
+               FIELD_SET(0, DE_CONTROL, COMMAND, HOST_WRITE) |
+               FIELD_SET(0, DE_CONTROL, HOST, MONO)          |
+               FIELD_SET(0, DE_CONTROL, STATUS, START);
+
+       write_dpr(accel,DE_CONTROL, de_ctrl | deGetTransparency(accel));
+
+    /* Write MONO data (line by line) to 2D Engine data port */
+    for (i=0; i<height; i++)
+    {
+        /* For each line, send the data in chunks of 4 bytes */
+        for (j=0; j<(ul4BytesPerScan/4); j++)
+        {
+            write_dpPort(accel, *(unsigned int *)(pSrcbuf + (j * 4)));
+        }
+
+        if (ulBytesRemain)
+        {
+            memcpy(ajRemain, pSrcbuf+ul4BytesPerScan, ulBytesRemain);
+            write_dpPort(accel, *(unsigned int *)ajRemain);
+        }
+
+        pSrcbuf += srcDelta;
+    }
+
+    return 0;
+}
+
diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h
new file mode 100644 (file)
index 0000000..3ee0bd8
--- /dev/null
@@ -0,0 +1,275 @@
+#ifndef ACCEL_H__
+#define ACCEL_H__
+
+#define HW_ROP2_COPY 0xc
+#define HW_ROP2_XOR 0x6
+
+/* notes: below address are the offset value from de_base_address (0x100000)*/
+
+/* for sm718/750/502 de_base is at mmreg_1mb*/
+#define DE_BASE_ADDR_TYPE1     0x100000
+/* for sm712,de_base is at mmreg_32kb */
+#define DE_BASE_ADDR_TYPE2  0x8000
+/* for sm722,de_base is at mmreg_0 */
+#define DE_BASE_ADDR_TYPE3 0
+
+/* type1 data port address is at mmreg_0x110000*/
+#define DE_PORT_ADDR_TYPE1 0x110000
+/* for sm712,data port address is at mmreg_0 */
+#define DE_PORT_ADDR_TYPE2 0x100000
+/* for sm722,data port address is at mmreg_1mb */
+#define DE_PORT_ADDR_TYPE3 0x100000
+
+#define DE_SOURCE                                       0x0
+#define DE_SOURCE_WRAP                                  31:31
+#define DE_SOURCE_WRAP_DISABLE                          0
+#define DE_SOURCE_WRAP_ENABLE                           1
+#define DE_SOURCE_X_K1                                  29:16
+#define DE_SOURCE_Y_K2                                  15:0
+#define DE_SOURCE_X_K1_MONO                                                    20:16
+
+#define DE_DESTINATION                                  0x4
+#define DE_DESTINATION_WRAP                             31:31
+#define DE_DESTINATION_WRAP_DISABLE                     0
+#define DE_DESTINATION_WRAP_ENABLE                      1
+#define DE_DESTINATION_X                                28:16
+#define DE_DESTINATION_Y                                15:0
+
+#define DE_DIMENSION                                    0x8
+#define DE_DIMENSION_X                                  28:16
+#define DE_DIMENSION_Y_ET                               15:0
+
+#define DE_CONTROL                                      0xC
+#define DE_CONTROL_STATUS                               31:31
+#define DE_CONTROL_STATUS_STOP                          0
+#define DE_CONTROL_STATUS_START                         1
+#define DE_CONTROL_PATTERN                              30:30
+#define DE_CONTROL_PATTERN_MONO                         0
+#define DE_CONTROL_PATTERN_COLOR                        1
+#define DE_CONTROL_UPDATE_DESTINATION_X                 29:29
+#define DE_CONTROL_UPDATE_DESTINATION_X_DISABLE         0
+#define DE_CONTROL_UPDATE_DESTINATION_X_ENABLE          1
+#define DE_CONTROL_QUICK_START                          28:28
+#define DE_CONTROL_QUICK_START_DISABLE                  0
+#define DE_CONTROL_QUICK_START_ENABLE                   1
+#define DE_CONTROL_DIRECTION                            27:27
+#define DE_CONTROL_DIRECTION_LEFT_TO_RIGHT              0
+#define DE_CONTROL_DIRECTION_RIGHT_TO_LEFT              1
+#define DE_CONTROL_MAJOR                                26:26
+#define DE_CONTROL_MAJOR_X                              0
+#define DE_CONTROL_MAJOR_Y                              1
+#define DE_CONTROL_STEP_X                               25:25
+#define DE_CONTROL_STEP_X_POSITIVE                      1
+#define DE_CONTROL_STEP_X_NEGATIVE                      0
+#define DE_CONTROL_STEP_Y                               24:24
+#define DE_CONTROL_STEP_Y_POSITIVE                      1
+#define DE_CONTROL_STEP_Y_NEGATIVE                      0
+#define DE_CONTROL_STRETCH                              23:23
+#define DE_CONTROL_STRETCH_DISABLE                      0
+#define DE_CONTROL_STRETCH_ENABLE                       1
+#define DE_CONTROL_HOST                                 22:22
+#define DE_CONTROL_HOST_COLOR                           0
+#define DE_CONTROL_HOST_MONO                            1
+#define DE_CONTROL_LAST_PIXEL                           21:21
+#define DE_CONTROL_LAST_PIXEL_OFF                       0
+#define DE_CONTROL_LAST_PIXEL_ON                        1
+#define DE_CONTROL_COMMAND                              20:16
+#define DE_CONTROL_COMMAND_BITBLT                       0
+#define DE_CONTROL_COMMAND_RECTANGLE_FILL               1
+#define DE_CONTROL_COMMAND_DE_TILE                      2
+#define DE_CONTROL_COMMAND_TRAPEZOID_FILL               3
+#define DE_CONTROL_COMMAND_ALPHA_BLEND                  4
+#define DE_CONTROL_COMMAND_RLE_STRIP                    5
+#define DE_CONTROL_COMMAND_SHORT_STROKE                 6
+#define DE_CONTROL_COMMAND_LINE_DRAW                    7
+#define DE_CONTROL_COMMAND_HOST_WRITE                   8
+#define DE_CONTROL_COMMAND_HOST_READ                    9
+#define DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP         10
+#define DE_CONTROL_COMMAND_ROTATE                       11
+#define DE_CONTROL_COMMAND_FONT                         12
+#define DE_CONTROL_COMMAND_TEXTURE_LOAD                 15
+#define DE_CONTROL_ROP_SELECT                           15:15
+#define DE_CONTROL_ROP_SELECT_ROP3                      0
+#define DE_CONTROL_ROP_SELECT_ROP2                      1
+#define DE_CONTROL_ROP2_SOURCE                          14:14
+#define DE_CONTROL_ROP2_SOURCE_BITMAP                   0
+#define DE_CONTROL_ROP2_SOURCE_PATTERN                  1
+#define DE_CONTROL_MONO_DATA                            13:12
+#define DE_CONTROL_MONO_DATA_NOT_PACKED                 0
+#define DE_CONTROL_MONO_DATA_8_PACKED                   1
+#define DE_CONTROL_MONO_DATA_16_PACKED                  2
+#define DE_CONTROL_MONO_DATA_32_PACKED                  3
+#define DE_CONTROL_REPEAT_ROTATE                        11:11
+#define DE_CONTROL_REPEAT_ROTATE_DISABLE                0
+#define DE_CONTROL_REPEAT_ROTATE_ENABLE                 1
+#define DE_CONTROL_TRANSPARENCY_MATCH                   10:10
+#define DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE            0
+#define DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT       1
+#define DE_CONTROL_TRANSPARENCY_SELECT                  9:9
+#define DE_CONTROL_TRANSPARENCY_SELECT_SOURCE           0
+#define DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION      1
+#define DE_CONTROL_TRANSPARENCY                         8:8
+#define DE_CONTROL_TRANSPARENCY_DISABLE                 0
+#define DE_CONTROL_TRANSPARENCY_ENABLE                  1
+#define DE_CONTROL_ROP                                  7:0
+
+// Pseudo fields.
+
+#define DE_CONTROL_SHORT_STROKE_DIR                     27:24
+#define DE_CONTROL_SHORT_STROKE_DIR_225                 0
+#define DE_CONTROL_SHORT_STROKE_DIR_135                 1
+#define DE_CONTROL_SHORT_STROKE_DIR_315                 2
+#define DE_CONTROL_SHORT_STROKE_DIR_45                  3
+#define DE_CONTROL_SHORT_STROKE_DIR_270                 4
+#define DE_CONTROL_SHORT_STROKE_DIR_90                  5
+#define DE_CONTROL_SHORT_STROKE_DIR_180                 8
+#define DE_CONTROL_SHORT_STROKE_DIR_0                   10
+#define DE_CONTROL_ROTATION                             25:24
+#define DE_CONTROL_ROTATION_0                           0
+#define DE_CONTROL_ROTATION_270                         1
+#define DE_CONTROL_ROTATION_90                          2
+#define DE_CONTROL_ROTATION_180                         3
+
+#define DE_PITCH                                        0x000010
+#define DE_PITCH_DESTINATION                            28:16
+#define DE_PITCH_SOURCE                                 12:0
+
+#define DE_FOREGROUND                                   0x000014
+#define DE_FOREGROUND_COLOR                             31:0
+
+#define DE_BACKGROUND                                   0x000018
+#define DE_BACKGROUND_COLOR                             31:0
+
+#define DE_STRETCH_FORMAT                               0x00001C
+#define DE_STRETCH_FORMAT_PATTERN_XY                    30:30
+#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL             0
+#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE          1
+#define DE_STRETCH_FORMAT_PATTERN_Y                     29:27
+#define DE_STRETCH_FORMAT_PATTERN_X                     25:23
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT                  21:20
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8                0
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16               1
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32               2
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24               3
+
+#define DE_STRETCH_FORMAT_ADDRESSING                    19:16
+#define DE_STRETCH_FORMAT_ADDRESSING_XY                 0
+#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR             15
+#define DE_STRETCH_FORMAT_SOURCE_HEIGHT                 11:0
+
+#define DE_COLOR_COMPARE                                0x000020
+#define DE_COLOR_COMPARE_COLOR                          23:0
+
+#define DE_COLOR_COMPARE_MASK                           0x000024
+#define DE_COLOR_COMPARE_MASK_MASKS                     23:0
+
+#define DE_MASKS                                        0x000028
+#define DE_MASKS_BYTE_MASK                              31:16
+#define DE_MASKS_BIT_MASK                               15:0
+
+#define DE_CLIP_TL                                      0x00002C
+#define DE_CLIP_TL_TOP                                  31:16
+#define DE_CLIP_TL_STATUS                               13:13
+#define DE_CLIP_TL_STATUS_DISABLE                       0
+#define DE_CLIP_TL_STATUS_ENABLE                        1
+#define DE_CLIP_TL_INHIBIT                              12:12
+#define DE_CLIP_TL_INHIBIT_OUTSIDE                      0
+#define DE_CLIP_TL_INHIBIT_INSIDE                       1
+#define DE_CLIP_TL_LEFT                                 11:0
+
+#define DE_CLIP_BR                                      0x000030
+#define DE_CLIP_BR_BOTTOM                               31:16
+#define DE_CLIP_BR_RIGHT                                12:0
+
+#define DE_MONO_PATTERN_LOW                             0x000034
+#define DE_MONO_PATTERN_LOW_PATTERN                     31:0
+
+#define DE_MONO_PATTERN_HIGH                            0x000038
+#define DE_MONO_PATTERN_HIGH_PATTERN                    31:0
+
+#define DE_WINDOW_WIDTH                                 0x00003C
+#define DE_WINDOW_WIDTH_DESTINATION                     28:16
+#define DE_WINDOW_WIDTH_SOURCE                          12:0
+
+#define DE_WINDOW_SOURCE_BASE                           0x000040
+#define DE_WINDOW_SOURCE_BASE_EXT                       27:27
+#define DE_WINDOW_SOURCE_BASE_EXT_LOCAL                 0
+#define DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL              1
+#define DE_WINDOW_SOURCE_BASE_CS                        26:26
+#define DE_WINDOW_SOURCE_BASE_CS_0                      0
+#define DE_WINDOW_SOURCE_BASE_CS_1                      1
+#define DE_WINDOW_SOURCE_BASE_ADDRESS                   25:0
+
+#define DE_WINDOW_DESTINATION_BASE                      0x000044
+#define DE_WINDOW_DESTINATION_BASE_EXT                  27:27
+#define DE_WINDOW_DESTINATION_BASE_EXT_LOCAL            0
+#define DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL         1
+#define DE_WINDOW_DESTINATION_BASE_CS                   26:26
+#define DE_WINDOW_DESTINATION_BASE_CS_0                 0
+#define DE_WINDOW_DESTINATION_BASE_CS_1                 1
+#define DE_WINDOW_DESTINATION_BASE_ADDRESS              25:0
+
+#define DE_ALPHA                                        0x000048
+#define DE_ALPHA_VALUE                                  7:0
+
+#define DE_WRAP                                         0x00004C
+#define DE_WRAP_X                                       31:16
+#define DE_WRAP_Y                                       15:0
+
+#define DE_STATUS                                       0x000050
+#define DE_STATUS_CSC                                   1:1
+#define DE_STATUS_CSC_CLEAR                             0
+#define DE_STATUS_CSC_NOT_ACTIVE                        0
+#define DE_STATUS_CSC_ACTIVE                            1
+#define DE_STATUS_2D                                    0:0
+#define DE_STATUS_2D_CLEAR                              0
+#define DE_STATUS_2D_NOT_ACTIVE                         0
+#define DE_STATUS_2D_ACTIVE                             1
+
+
+
+/* blt direction */
+#define TOP_TO_BOTTOM 0
+#define LEFT_TO_RIGHT 0
+#define BOTTOM_TO_TOP 1
+#define RIGHT_TO_LEFT 1
+
+void hw_set2dformat(struct lynx_accel * accel,int fmt);
+
+void hw_de_init(struct lynx_accel * accel);
+
+int hw_fillrect(struct lynx_accel * accel,
+                               u32 base,u32 pitch,u32 Bpp,
+                               u32 x,u32 y,u32 width,u32 height,
+                               u32 color,u32 rop);
+
+int hw_copyarea(
+struct lynx_accel * accel,
+unsigned int sBase,  /* Address of source: offset in frame buffer */
+unsigned int sPitch, /* Pitch value of source surface in BYTE */
+unsigned int sx,
+unsigned int sy,     /* Starting coordinate of source surface */
+unsigned int dBase,  /* Address of destination: offset in frame buffer */
+unsigned int dPitch, /* Pitch value of destination surface in BYTE */
+unsigned int bpp,    /* Color depth of destination surface */
+unsigned int dx,
+unsigned int dy,     /* Starting coordinate of destination surface */
+unsigned int width,
+unsigned int height, /* width and height of rectangle in pixel value */
+unsigned int rop2);
+
+int hw_imageblit(struct lynx_accel *accel,
+                const char *pSrcbuf, /* pointer to start of source buffer in system memory */
+                u32 srcDelta,          /* Pitch value (in bytes) of the source buffer, +ive means top down and -ive mean button up */
+                u32 startBit, /* Mono data can start at any bit in a byte, this value should be 0 to 7 */
+                u32 dBase,    /* Address of destination: offset in frame buffer */
+                u32 dPitch,   /* Pitch value of destination surface in BYTE */
+                u32 bytePerPixel,      /* Color depth of destination surface */
+                u32 dx,
+                u32 dy,       /* Starting coordinate of destination surface */
+                u32 width,
+                u32 height,   /* width and height of rectange in pixel value */
+                u32 fColor,   /* Foreground color (corresponding to a 1 in the monochrome data */
+                u32 bColor,   /* Background color (corresponding to a 0 in the monochrome data */
+                u32 rop2);
+#endif
diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c
new file mode 100644 (file)
index 0000000..6cceef1
--- /dev/null
@@ -0,0 +1,251 @@
+#include<linux/module.h>
+#include<linux/kernel.h>
+#include<linux/errno.h>
+#include<linux/string.h>
+#include<linux/mm.h>
+#include<linux/slab.h>
+#include<linux/delay.h>
+#include<linux/fb.h>
+#include<linux/ioport.h>
+#include<linux/init.h>
+#include<linux/pci.h>
+#include<linux/vmalloc.h>
+#include<linux/pagemap.h>
+#include <linux/console.h>
+#include<linux/platform_device.h>
+#include<linux/screen_info.h>
+
+#include "sm750.h"
+#include "sm750_help.h"
+#include "sm750_cursor.h"
+
+
+#define PEEK32(addr) \
+readl(cursor->mmio + (addr))
+
+#define POKE32(addr,data) \
+writel((data),cursor->mmio + (addr))
+
+/* cursor control for voyager and 718/750*/
+#define HWC_ADDRESS                         0x0
+#define HWC_ADDRESS_ENABLE                  31:31
+#define HWC_ADDRESS_ENABLE_DISABLE          0
+#define HWC_ADDRESS_ENABLE_ENABLE           1
+#define HWC_ADDRESS_EXT                     27:27
+#define HWC_ADDRESS_EXT_LOCAL               0
+#define HWC_ADDRESS_EXT_EXTERNAL            1
+#define HWC_ADDRESS_CS                      26:26
+#define HWC_ADDRESS_CS_0                    0
+#define HWC_ADDRESS_CS_1                    1
+#define HWC_ADDRESS_ADDRESS                 25:0
+
+#define HWC_LOCATION                        0x4
+#define HWC_LOCATION_TOP                    27:27
+#define HWC_LOCATION_TOP_INSIDE             0
+#define HWC_LOCATION_TOP_OUTSIDE            1
+#define HWC_LOCATION_Y                      26:16
+#define HWC_LOCATION_LEFT                   11:11
+#define HWC_LOCATION_LEFT_INSIDE            0
+#define HWC_LOCATION_LEFT_OUTSIDE           1
+#define HWC_LOCATION_X                      10:0
+
+#define HWC_COLOR_12                        0x8
+#define HWC_COLOR_12_2_RGB565               31:16
+#define HWC_COLOR_12_1_RGB565               15:0
+
+#define HWC_COLOR_3                         0xC
+#define HWC_COLOR_3_RGB565                  15:0
+
+
+/* hw_cursor_xxx works for voyager,718 and 750 */
+void hw_cursor_enable(struct lynx_cursor * cursor)
+{
+       u32 reg;
+       reg = FIELD_VALUE(0,HWC_ADDRESS,ADDRESS,cursor->offset)|
+                       FIELD_SET(0,HWC_ADDRESS,EXT,LOCAL)|
+                       FIELD_SET(0,HWC_ADDRESS,ENABLE,ENABLE);
+       POKE32(HWC_ADDRESS,reg);
+}
+void hw_cursor_disable(struct lynx_cursor * cursor)
+{
+       POKE32(HWC_ADDRESS,0);
+}
+
+void hw_cursor_setSize(struct lynx_cursor * cursor,
+                                               int w,int h)
+{
+       cursor->w = w;
+       cursor->h = h;
+}
+void hw_cursor_setPos(struct lynx_cursor * cursor,
+                                               int x,int y)
+{
+       u32 reg;
+       reg = FIELD_VALUE(0,HWC_LOCATION,Y,y)|
+                       FIELD_VALUE(0,HWC_LOCATION,X,x);
+       POKE32(HWC_LOCATION,reg);
+}
+void hw_cursor_setColor(struct lynx_cursor * cursor,
+                                               u32 fg,u32 bg)
+{
+       POKE32(HWC_COLOR_12,(fg<<16)|(bg&0xffff));
+       POKE32(HWC_COLOR_3,0xffe0);
+}
+
+void hw_cursor_setData(struct lynx_cursor * cursor,
+                       u16 rop,const u8* pcol,const u8* pmsk)
+{
+       int i,j,count,pitch,offset;
+       u8 color,mask,opr;
+       u16 data;
+       u16 * pbuffer,*pstart;
+
+       /*  in byte*/
+       pitch = cursor->w >> 3;
+
+       /* in byte      */
+       count = pitch * cursor->h;
+
+       /* in ushort */
+       offset = cursor->maxW * 2 / 8 / 2;
+
+       data = 0;
+       pstart = (u16 *)cursor->vstart;
+       pbuffer = pstart;
+
+/*
+       if(odd &1){
+               hw_cursor_setData2(cursor,rop,pcol,pmsk);
+       }
+       odd++;
+       if(odd > 0xfffffff0)
+               odd=0;
+*/
+
+       for(i=0;i<count;i++)
+       {
+               color = *pcol++;
+               mask = *pmsk++;
+               data = 0;
+
+               /* either method below works well,
+                * but method 2 shows no lag
+                * and method 1 seems a bit wrong*/
+#if 0
+               if(rop == ROP_XOR)
+                       opr = mask ^ color;
+               else
+                       opr = mask & color;
+
+               for(j=0;j<8;j++)
+               {
+
+                       if(opr & (0x80 >> j))
+                       {       //use fg color,id = 2
+                               data |= 2 << (j*2);
+                       }else{
+                               //use bg color,id = 1
+                               data |= 1 << (j*2);
+                       }
+               }
+#else
+               for(j=0;j<8;j++){
+                       if(mask & (0x80>>j)){
+                               if(rop == ROP_XOR)
+                                       opr = mask ^ color;
+                               else
+                                       opr = mask & color;
+
+                               /* 2 stands for forecolor and 1 for backcolor */
+                               data |= ((opr & (0x80>>j))?2:1)<<(j*2);
+                       }
+               }
+#endif
+               *pbuffer = data;
+
+               /* assume pitch is 1,2,4,8,...*/
+#if 0
+               if(!((i+1)&(pitch-1)))   /* below line equal to is line */
+#else
+               if((i+1) % pitch == 0)
+#endif
+               {
+                       /* need a return */
+                       pstart += offset;
+                       pbuffer = pstart;
+               }else{
+                       pbuffer++;
+               }
+
+       }
+
+
+}
+
+
+void hw_cursor_setData2(struct lynx_cursor * cursor,
+                       u16 rop,const u8* pcol,const u8* pmsk)
+{
+       int i,j,count,pitch,offset;
+       u8 color, mask;
+       u16 data;
+       u16 * pbuffer,*pstart;
+
+       /*  in byte*/
+       pitch = cursor->w >> 3;
+
+       /* in byte      */
+       count = pitch * cursor->h;
+
+       /* in ushort */
+       offset = cursor->maxW * 2 / 8 / 2;
+
+       data = 0;
+       pstart = (u16 *)cursor->vstart;
+       pbuffer = pstart;
+
+       for(i=0;i<count;i++)
+       {
+               color = *pcol++;
+               mask = *pmsk++;
+               data = 0;
+
+               /* either method below works well, but method 2 shows no lag */
+#if 0
+               if(rop == ROP_XOR)
+                       opr = mask ^ color;
+               else
+                       opr = mask & color;
+
+               for(j=0;j<8;j++)
+               {
+
+                       if(opr & (0x80 >> j))
+                       {       //use fg color,id = 2
+                               data |= 2 << (j*2);
+                       }else{
+                               //use bg color,id = 1
+                               data |= 1 << (j*2);
+                       }
+               }
+#else
+               for(j=0;j<8;j++){
+                       if(mask & (1<<j))
+                               data |= ((color & (1<<j))?1:2)<<(j*2);
+               }
+#endif
+               *pbuffer = data;
+
+               /* assume pitch is 1,2,4,8,...*/
+               if(!(i&(pitch-1)))
+               //if((i+1) % pitch == 0)
+               {
+                       /* need a return */
+                       pstart += offset;
+                       pbuffer = pstart;
+               }else{
+                       pbuffer++;
+               }
+
+       }
+}
diff --git a/drivers/staging/sm750fb/sm750_cursor.h b/drivers/staging/sm750fb/sm750_cursor.h
new file mode 100644 (file)
index 0000000..8cede07
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef LYNX_CURSOR_H__
+#define LYNX_CURSOR_H__
+
+/* hw_cursor_xxx works for voyager,718 and 750 */
+void hw_cursor_enable(struct lynx_cursor * cursor);
+void hw_cursor_disable(struct lynx_cursor * cursor);
+void hw_cursor_setSize(struct lynx_cursor * cursor,
+                                               int w,int h);
+void hw_cursor_setPos(struct lynx_cursor * cursor,
+                                               int x,int y);
+void hw_cursor_setColor(struct lynx_cursor * cursor,
+                                               u32 fg,u32 bg);
+void hw_cursor_setData(struct lynx_cursor * cursor,
+                       u16 rop,const u8* data,const u8* mask);
+void hw_cursor_setData2(struct lynx_cursor * cursor,
+                       u16 rop,const u8* data,const u8* mask);
+#endif
diff --git a/drivers/staging/sm750fb/sm750_help.h b/drivers/staging/sm750fb/sm750_help.h
new file mode 100644 (file)
index 0000000..e0128d2
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef LYNX_HELP_H__
+#define LYNX_HELP_H__
+/*****************************************************************************\
+ *                                FIELD MACROS                               *
+\*****************************************************************************/
+
+#define _LSB(f)             (0 ? f)
+#define _MSB(f)             (1 ? f)
+#define _COUNT(f)           (_MSB(f) - _LSB(f) + 1)
+
+#define RAW_MASK(f)         (0xFFFFFFFF >> (32 - _COUNT(f)))
+#define GET_MASK(f)         (RAW_MASK(f) << _LSB(f))
+#define GET_FIELD(d,f)      (((d) >> _LSB(f)) & RAW_MASK(f))
+#define TEST_FIELD(d,f,v)   (GET_FIELD(d,f) == f ## _ ## v)
+#define SET_FIELD(d,f,v)    (((d) & ~GET_MASK(f)) | \
+                            (((f ## _ ## v) & RAW_MASK(f)) << _LSB(f)))
+#define SET_FIELDV(d,f,v)   (((d) & ~GET_MASK(f)) | \
+                            (((v) & RAW_MASK(f)) << _LSB(f)))
+
+
+////////////////////////////////////////////////////////////////////////////////
+//                                                                            //
+// Internal macros                                                            //
+//                                                                            //
+////////////////////////////////////////////////////////////////////////////////
+
+#define _F_START(f)             (0 ? f)
+#define _F_END(f)               (1 ? f)
+#define _F_SIZE(f)              (1 + _F_END(f) - _F_START(f))
+#define _F_MASK(f)              (((1 << _F_SIZE(f)) - 1) << _F_START(f))
+#define _F_NORMALIZE(v, f)      (((v) & _F_MASK(f)) >> _F_START(f))
+#define _F_DENORMALIZE(v, f)    (((v) << _F_START(f)) & _F_MASK(f))
+
+
+////////////////////////////////////////////////////////////////////////////////
+//                                                                            //
+// Global macros                                                              //
+//                                                                            //
+////////////////////////////////////////////////////////////////////////////////
+
+#define FIELD_GET(x, reg, field) \
+( \
+    _F_NORMALIZE((x), reg ## _ ## field) \
+)
+
+#define FIELD_SET(x, reg, field, value) \
+( \
+    (x & ~_F_MASK(reg ## _ ## field)) \
+    | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \
+)
+
+#define FIELD_VALUE(x, reg, field, value) \
+( \
+    (x & ~_F_MASK(reg ## _ ## field)) \
+    | _F_DENORMALIZE(value, reg ## _ ## field) \
+)
+
+#define FIELD_CLEAR(reg, field) \
+( \
+    ~ _F_MASK(reg ## _ ## field) \
+)
+
+
+////////////////////////////////////////////////////////////////////////////////
+//                                                                            //
+// Field Macros                                                               //
+//                                                                            //
+////////////////////////////////////////////////////////////////////////////////
+
+#define FIELD_START(field)              (0 ? field)
+#define FIELD_END(field)                (1 ? field)
+#define FIELD_SIZE(field)               (1 + FIELD_END(field) - FIELD_START(field))
+#define FIELD_MASK(field)               (((1 << (FIELD_SIZE(field)-1)) | ((1 << (FIELD_SIZE(field)-1)) - 1)) << FIELD_START(field))
+#define FIELD_NORMALIZE(reg, field)     (((reg) & FIELD_MASK(field)) >> FIELD_START(field))
+#define FIELD_DENORMALIZE(field, value) (((value) << FIELD_START(field)) & FIELD_MASK(field))
+
+#define FIELD_INIT(reg, field, value)   FIELD_DENORMALIZE(reg ## _ ## field, \
+                                                          reg ## _ ## field ## _ ## value)
+#define FIELD_INIT_VAL(reg, field, value) \
+                                        (FIELD_DENORMALIZE(reg ## _ ## field, value))
+#define FIELD_VAL_SET(x, r, f, v)       x = x & ~FIELD_MASK(r ## _ ## f) \
+                                              | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v)
+
+#define RGB(r, g, b) \
+( \
+    (unsigned long) (((r) << 16) | ((g) << 8) | (b)) \
+)
+
+#define RGB16(r, g, b) \
+( \
+    (unsigned short) ((((r) & 0xF8) << 8) | (((g) & 0xFC) << 3) | (((b) & 0xF8) >> 3)) \
+)
+
+static inline unsigned int absDiff(unsigned int a,unsigned int b)
+{
+       if(a<b)
+               return b-a;
+       else
+               return a-b;
+}
+
+/* n / d + 1 / 2 = (2n + d) / 2d */
+#define roundedDiv(num,denom)  ((2 * (num) + (denom)) / (2 * (denom)))
+#define MB(x) ((x)<<20)
+#define KB(x) ((x)<<10)
+#define MHz(x) ((x) * 1000000)
+
+
+
+
+#endif
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
new file mode 100644 (file)
index 0000000..9f0d06d
--- /dev/null
@@ -0,0 +1,642 @@
+#include <linux/version.h>
+#include<linux/module.h>
+#include<linux/kernel.h>
+#include<linux/errno.h>
+#include<linux/string.h>
+#include<linux/mm.h>
+#include<linux/slab.h>
+#include<linux/delay.h>
+#include<linux/fb.h>
+#include<linux/ioport.h>
+#include<linux/init.h>
+#include<linux/pci.h>
+#include<linux/vmalloc.h>
+#include<linux/pagemap.h>
+#include <linux/console.h>
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
+#include<linux/platform_device.h>
+#include<linux/screen_info.h>
+
+#include "sm750.h"
+#include "sm750_hw.h"
+#include "ddk750.h"
+#include "sm750_accel.h"
+
+int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
+{
+       int ret;
+       struct sm750_share * spec_share;
+       
+
+       spec_share = container_of(share, struct sm750_share,share);
+       ret = 0;
+
+       share->vidreg_start  = pci_resource_start(pdev, 1);
+       share->vidreg_size = MB(2);
+
+       pr_info("mmio phyAddr = %lx\n", share->vidreg_start);
+
+       /* reserve the vidreg space of smi adaptor
+        * if you do this, u need to add release region code
+        * in lynxfb_remove, or memory will not be mapped again
+        * successfully
+        * */
+
+       if((ret = pci_request_region(pdev, 1, "sm750fb")))
+       {
+               pr_err("Can not request PCI regions.\n");
+               goto exit;
+       }
+
+       /* now map mmio and vidmem*/
+       share->pvReg = ioremap_nocache(share->vidreg_start, share->vidreg_size);
+       if(!share->pvReg){
+               pr_err("mmio failed\n");
+               ret = -EFAULT;
+               goto exit;
+       }else{
+               pr_info("mmio virtual addr = %p\n", share->pvReg);
+       }
+
+       
+       share->accel.dprBase = share->pvReg + DE_BASE_ADDR_TYPE1;
+       share->accel.dpPortBase = share->pvReg + DE_PORT_ADDR_TYPE1;
+
+       ddk750_set_mmio(share->pvReg,share->devid, share->revid);
+
+       share->vidmem_start = pci_resource_start(pdev, 0);
+       /* don't use pdev_resource[x].end - resource[x].start to
+        * calculate the resource size,its only the maximum available
+        * size but not the actual size,use
+        * @hw_sm750_getVMSize function can be safe.
+        * */
+       share->vidmem_size = hw_sm750_getVMSize(share);
+       pr_info("video memory phyAddr = %lx, size = %u bytes\n",
+       share->vidmem_start, share->vidmem_size);
+
+       /* reserve the vidmem space of smi adaptor */
+#if 0
+       if((ret = pci_request_region(pdev,0,_moduleName_)))
+       {
+               pr_err("Can not request PCI regions.\n");
+               goto exit;
+       }
+#endif
+
+       share->pvMem = ioremap(share->vidmem_start,
+                                                       share->vidmem_size);
+
+       if(!share->pvMem){
+               pr_err("Map video memory failed\n");
+               ret = -EFAULT;
+               goto exit;
+       }else{
+               pr_info("video memory vaddr = %p\n", share->pvMem);
+       }
+exit:
+       return ret;
+}
+
+
+
+int hw_sm750_inithw(struct lynx_share* share, struct pci_dev * pdev)
+{
+       struct sm750_share * spec_share;
+       struct init_status * parm;
+       
+       spec_share = container_of(share, struct sm750_share,share);
+       parm = &spec_share->state.initParm;
+       if(parm->chip_clk == 0)
+               parm->chip_clk = (getChipType() == SM750LE)?
+                                               DEFAULT_SM750LE_CHIP_CLOCK :
+                                               DEFAULT_SM750_CHIP_CLOCK;
+
+       if(parm->mem_clk == 0)
+               parm->mem_clk = parm->chip_clk;
+       if(parm->master_clk == 0)
+               parm->master_clk = parm->chip_clk/3;
+
+       ddk750_initHw((initchip_param_t *)&spec_share->state.initParm);
+       /* for sm718,open pci burst */
+       if(share->devid == 0x718){
+               POKE32(SYSTEM_CTRL,
+                               FIELD_SET(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, PCI_BURST, ON));
+       }
+
+       /* sm750 use sii164, it can be setup with default value
+        * by on power, so initDVIDisp can be skipped */
+#if 0
+       ddk750_initDVIDisp();
+#endif
+
+       if(getChipType() != SM750LE)
+       {
+               /* does user need CRT ?*/
+               if(spec_share->state.nocrt){
+                       POKE32(MISC_CTRL,
+                                       FIELD_SET(PEEK32(MISC_CTRL),
+                                       MISC_CTRL,
+                                       DAC_POWER, OFF));
+                       /* shut off dpms */
+                       POKE32(SYSTEM_CTRL,
+                                       FIELD_SET(PEEK32(SYSTEM_CTRL),
+                                       SYSTEM_CTRL,
+                                       DPMS, VNHN));
+               }else{
+                       POKE32(MISC_CTRL,
+                                       FIELD_SET(PEEK32(MISC_CTRL),
+                                       MISC_CTRL,
+                                       DAC_POWER, ON));
+                       /* turn on dpms */
+                       POKE32(SYSTEM_CTRL,
+                                       FIELD_SET(PEEK32(SYSTEM_CTRL),
+                                       SYSTEM_CTRL,
+                                       DPMS, VPHP));
+               }
+
+               switch (spec_share->state.pnltype){
+                       case sm750_doubleTFT:
+                       case sm750_24TFT:
+                       case sm750_dualTFT:
+                       POKE32(PANEL_DISPLAY_CTRL,
+                               FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL),
+                                                       PANEL_DISPLAY_CTRL,
+                                                       TFT_DISP,
+                                                       spec_share->state.pnltype));
+                       break;
+               }
+       }else{
+               /* for 750LE ,no DVI chip initilization makes Monitor no signal */
+               /* Set up GPIO for software I2C to program DVI chip in the
+                  Xilinx SP605 board, in order to have video signal.
+                */
+        swI2CInit(0,1);
+
+
+        /* Customer may NOT use CH7301 DVI chip, which has to be
+           initialized differently.
+         */
+        if (swI2CReadReg(0xec, 0x4a) == 0x95)
+        {
+            /* The following register values for CH7301 are from
+               Chrontel app note and our experiment.
+             */
+                       pr_info("yes,CH7301 DVI chip found\n");
+            swI2CWriteReg(0xec, 0x1d, 0x16);
+            swI2CWriteReg(0xec, 0x21, 0x9);
+            swI2CWriteReg(0xec, 0x49, 0xC0);
+                       pr_info("okay,CH7301 DVI chip setup done\n");
+        }
+       }
+
+       /* init 2d engine */
+       if(!share->accel_off){
+               hw_sm750_initAccel(share);
+//             share->accel.de_wait = hw_sm750_deWait;
+       }
+
+       return 0;
+}
+
+
+resource_size_t hw_sm750_getVMSize(struct lynx_share * share)
+{
+       resource_size_t ret;
+       
+       ret = ddk750_getVMSize();
+       return ret;
+}
+
+
+
+int hw_sm750_output_checkMode(struct lynxfb_output* output, struct fb_var_screeninfo* var)
+{
+       
+       return 0;
+}
+
+
+int hw_sm750_output_setMode(struct lynxfb_output* output,
+                                                                       struct fb_var_screeninfo* var, struct fb_fix_screeninfo* fix)
+{
+       int ret;
+       disp_output_t dispSet;
+       int channel;
+       
+       ret = 0;
+       dispSet = 0;
+       channel = *output->channel;
+
+
+       if(getChipType() != SM750LE){
+               if(channel == sm750_primary){
+                       pr_info("primary channel\n");
+                       if(output->paths & sm750_panel)
+                               dispSet |= do_LCD1_PRI;
+                       if(output->paths & sm750_crt)
+                               dispSet |= do_CRT_PRI;
+
+               }else{
+                       pr_info("secondary channel\n");
+                       if(output->paths & sm750_panel)
+                               dispSet |= do_LCD1_SEC;
+                       if(output->paths & sm750_crt)
+                               dispSet |= do_CRT_SEC;
+
+               }
+               ddk750_setLogicalDispOut(dispSet);
+       }else{
+               /* just open DISPLAY_CONTROL_750LE register bit 3:0*/
+               u32 reg;
+               reg = PEEK32(DISPLAY_CONTROL_750LE);
+               reg |= 0xf;
+               POKE32(DISPLAY_CONTROL_750LE, reg);
+       }
+
+       pr_info("ddk setlogicdispout done \n");
+       return ret;
+}
+
+void hw_sm750_output_clear(struct lynxfb_output* output)
+{
+       
+       return;
+}
+
+int hw_sm750_crtc_checkMode(struct lynxfb_crtc* crtc, struct fb_var_screeninfo* var)
+{
+       struct lynx_share * share;
+       
+
+       share = container_of(crtc, struct lynxfb_par,crtc)->share;
+
+       switch (var->bits_per_pixel){
+               case 8:
+               case 16:
+                       break;
+               case 32:
+                       if (share->revid == SM750LE_REVISION_ID) {
+                               pr_debug("750le do not support 32bpp\n");
+                               return -EINVAL;
+                       }
+                       break;
+               default:
+                       return -EINVAL;
+
+       }
+
+       return 0;
+}
+
+
+/*
+       set the controller's mode for @crtc charged with @var and @fix parameters
+*/
+int hw_sm750_crtc_setMode(struct lynxfb_crtc* crtc,
+                                                               struct fb_var_screeninfo* var,
+                                                               struct fb_fix_screeninfo* fix)
+{
+       int ret,fmt;
+       u32 reg;
+       mode_parameter_t modparm;
+       clock_type_t clock;
+       struct lynx_share * share;
+       struct lynxfb_par * par;
+
+       
+       ret = 0;
+       par = container_of(crtc, struct lynxfb_par, crtc);
+       share = par->share;
+#if 1
+       if(!share->accel_off){
+               /* set 2d engine pixel format according to mode bpp */
+               switch(var->bits_per_pixel){
+                       case 8:
+                               fmt = 0;
+                               break;
+                       case 16:
+                               fmt = 1;
+                               break;
+                       case 32:
+                       default:
+                               fmt = 2;
+                               break;
+               }
+               hw_set2dformat(&share->accel, fmt);
+       }
+#endif
+
+       /* set timing */
+//     modparm.pixel_clock = PS_TO_HZ(var->pixclock);
+       modparm.pixel_clock = ps_to_hz(var->pixclock);
+       modparm.vertical_sync_polarity = (var->sync & FB_SYNC_HOR_HIGH_ACT) ? POS:NEG;
+       modparm.horizontal_sync_polarity = (var->sync & FB_SYNC_VERT_HIGH_ACT) ? POS:NEG;
+       modparm.clock_phase_polarity = (var->sync& FB_SYNC_COMP_HIGH_ACT) ? POS:NEG;
+       modparm.horizontal_display_end = var->xres;
+       modparm.horizontal_sync_width = var->hsync_len;
+       modparm.horizontal_sync_start = var->xres + var->right_margin;
+       modparm.horizontal_total = var->xres + var->left_margin + var->right_margin + var->hsync_len;
+       modparm.vertical_display_end = var->yres;
+       modparm.vertical_sync_height = var->vsync_len;
+       modparm.vertical_sync_start = var->yres + var->lower_margin;
+       modparm.vertical_total = var->yres + var->upper_margin + var->lower_margin + var->vsync_len;
+
+       /* choose pll */
+       if(crtc->channel != sm750_secondary)
+               clock = PRIMARY_PLL;
+       else
+               clock = SECONDARY_PLL;
+
+       pr_debug("Request pixel clock = %lu\n", modparm.pixel_clock);
+       ret = ddk750_setModeTiming(&modparm, clock);
+       if(ret){
+               pr_err("Set mode timing failed\n");
+               goto exit;
+       }
+
+       if(crtc->channel != sm750_secondary){
+               /* set pitch, offset ,width,start address ,etc... */
+               POKE32(PANEL_FB_ADDRESS,
+                       FIELD_SET(0, PANEL_FB_ADDRESS, STATUS, CURRENT)|
+                       FIELD_SET(0, PANEL_FB_ADDRESS, EXT, LOCAL)|
+                       FIELD_VALUE(0, PANEL_FB_ADDRESS, ADDRESS, crtc->oScreen));
+
+               reg = var->xres * (var->bits_per_pixel >> 3);
+               /* crtc->channel is not equal to par->index on numeric,be aware of that */
+               reg = PADDING(crtc->line_pad,reg);
+
+               POKE32(PANEL_FB_WIDTH,
+                       FIELD_VALUE(0, PANEL_FB_WIDTH, WIDTH, reg)|
+                       FIELD_VALUE(0, PANEL_FB_WIDTH, OFFSET, fix->line_length));
+
+               POKE32(PANEL_WINDOW_WIDTH,
+                       FIELD_VALUE(0, PANEL_WINDOW_WIDTH, WIDTH, var->xres -1)|
+                       FIELD_VALUE(0, PANEL_WINDOW_WIDTH, X, var->xoffset));
+
+               POKE32(PANEL_WINDOW_HEIGHT,
+                       FIELD_VALUE(0, PANEL_WINDOW_HEIGHT, HEIGHT, var->yres_virtual - 1)|
+                       FIELD_VALUE(0, PANEL_WINDOW_HEIGHT, Y, var->yoffset));
+
+               POKE32(PANEL_PLANE_TL, 0);
+
+               POKE32(PANEL_PLANE_BR,
+                       FIELD_VALUE(0, PANEL_PLANE_BR, BOTTOM, var->yres - 1)|
+                       FIELD_VALUE(0, PANEL_PLANE_BR,RIGHT, var->xres - 1));
+
+               /* set pixel format */
+               reg = PEEK32(PANEL_DISPLAY_CTRL);
+               POKE32(PANEL_DISPLAY_CTRL,
+                       FIELD_VALUE(reg,
+                       PANEL_DISPLAY_CTRL, FORMAT,
+                       (var->bits_per_pixel >> 4)
+                       ));
+       }else{
+               /* not implemented now */
+               POKE32(CRT_FB_ADDRESS, crtc->oScreen);
+               reg = var->xres * (var->bits_per_pixel >> 3);
+               /* crtc->channel is not equal to par->index on numeric,be aware of that */
+               reg = PADDING(crtc->line_pad, reg);
+
+               POKE32(CRT_FB_WIDTH,
+                       FIELD_VALUE(0, CRT_FB_WIDTH, WIDTH, reg)|
+                       FIELD_VALUE(0, CRT_FB_WIDTH, OFFSET, fix->line_length));
+
+               /* SET PIXEL FORMAT */
+               reg = PEEK32(CRT_DISPLAY_CTRL);
+               reg = FIELD_VALUE(reg, CRT_DISPLAY_CTRL, FORMAT, var->bits_per_pixel >> 4);
+               POKE32(CRT_DISPLAY_CTRL, reg);
+
+       }
+
+
+exit:
+       return ret;
+}
+
+void hw_sm750_crtc_clear(struct lynxfb_crtc* crtc)
+{
+       
+       return;
+}
+
+int hw_sm750_setColReg(struct lynxfb_crtc* crtc, ushort index,
+                                                               ushort red, ushort green, ushort blue)
+{
+       static unsigned int add[]={PANEL_PALETTE_RAM,CRT_PALETTE_RAM};
+       POKE32(add[crtc->channel] + index*4, (red<<16)|(green<<8)|blue);
+       return 0;
+}
+
+int hw_sm750le_setBLANK(struct lynxfb_output * output, int blank){
+       int dpms,crtdb;
+       
+       switch(blank)
+       {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_UNBLANK:
+#else
+               case VESA_NO_BLANKING:
+#endif
+                       dpms = CRT_DISPLAY_CTRL_DPMS_0;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_NORMAL:
+                       dpms = CRT_DISPLAY_CTRL_DPMS_0;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_VSYNC_SUSPEND:
+#else
+               case VESA_VSYNC_SUSPEND:
+#endif
+                       dpms = CRT_DISPLAY_CTRL_DPMS_2;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_HSYNC_SUSPEND:
+#else
+               case VESA_HSYNC_SUSPEND:
+#endif
+                       dpms = CRT_DISPLAY_CTRL_DPMS_1;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_POWERDOWN:
+#else
+               case VESA_POWERDOWN:
+#endif
+                       dpms = CRT_DISPLAY_CTRL_DPMS_3;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+               default:
+                       return -EINVAL;
+       }
+
+       if(output->paths & sm750_crt){
+               POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, DPMS, dpms));
+               POKE32(CRT_DISPLAY_CTRL, FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL, BLANK, crtdb));
+       }
+       return 0;
+}
+
+int hw_sm750_setBLANK(struct lynxfb_output* output,int blank)
+{
+       unsigned int dpms, pps, crtdb;
+       
+       dpms = pps = crtdb = 0;
+
+       switch (blank)
+       {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_UNBLANK:
+#else
+               case VESA_NO_BLANKING:
+#endif
+                       pr_info("flag = FB_BLANK_UNBLANK \n");
+                       dpms = SYSTEM_CTRL_DPMS_VPHP;
+                       pps = PANEL_DISPLAY_CTRL_DATA_ENABLE;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_OFF;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_NORMAL:
+                       pr_info("flag = FB_BLANK_NORMAL \n");
+                       dpms = SYSTEM_CTRL_DPMS_VPHP;
+                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_VSYNC_SUSPEND:
+#else
+               case VESA_VSYNC_SUSPEND:
+#endif
+                       dpms = SYSTEM_CTRL_DPMS_VNHP;
+                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_HSYNC_SUSPEND:
+#else
+               case VESA_HSYNC_SUSPEND:
+#endif
+                       dpms = SYSTEM_CTRL_DPMS_VPHN;
+                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)
+               case FB_BLANK_POWERDOWN:
+#else
+               case VESA_POWERDOWN:
+#endif
+                       dpms = SYSTEM_CTRL_DPMS_VNHN;
+                       pps = PANEL_DISPLAY_CTRL_DATA_DISABLE;
+                       crtdb = CRT_DISPLAY_CTRL_BLANK_ON;
+                       break;
+       }
+
+       if(output->paths & sm750_crt){
+
+               POKE32(SYSTEM_CTRL,FIELD_VALUE(PEEK32(SYSTEM_CTRL), SYSTEM_CTRL, DPMS, dpms));
+               POKE32(CRT_DISPLAY_CTRL,FIELD_VALUE(PEEK32(CRT_DISPLAY_CTRL), CRT_DISPLAY_CTRL,BLANK, crtdb));
+       }
+
+       if(output->paths & sm750_panel){
+               POKE32(PANEL_DISPLAY_CTRL, FIELD_VALUE(PEEK32(PANEL_DISPLAY_CTRL), PANEL_DISPLAY_CTRL, DATA, pps));
+       }
+
+       return 0;
+}
+
+
+void hw_sm750_initAccel(struct lynx_share * share)
+{
+       u32 reg;
+       enable2DEngine(1);
+
+       if(getChipType() == SM750LE){
+               reg = PEEK32(DE_STATE1);
+               reg = FIELD_SET(reg, DE_STATE1, DE_ABORT,ON);
+               POKE32(DE_STATE1,reg);
+
+               reg = PEEK32(DE_STATE1);
+               reg = FIELD_SET(reg, DE_STATE1, DE_ABORT,OFF);
+               POKE32(DE_STATE1, reg);
+
+       }else{
+               /* engine reset */
+               reg = PEEK32(SYSTEM_CTRL);
+           reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT,ON);
+               POKE32(SYSTEM_CTRL, reg);
+
+               reg = PEEK32(SYSTEM_CTRL);
+               reg = FIELD_SET(reg, SYSTEM_CTRL, DE_ABORT,OFF);
+               POKE32(SYSTEM_CTRL, reg);
+       }
+
+       /* call 2d init */
+       share->accel.de_init(&share->accel);
+}
+
+int hw_sm750le_deWait(void)
+{
+       int i=0x10000000;
+       while(i--){
+               unsigned int dwVal = PEEK32(DE_STATE2);
+               if((FIELD_GET(dwVal, DE_STATE2, DE_STATUS) == DE_STATE2_DE_STATUS_IDLE) &&
+                       (FIELD_GET(dwVal, DE_STATE2, DE_FIFO)  == DE_STATE2_DE_FIFO_EMPTY) &&
+                       (FIELD_GET(dwVal, DE_STATE2, DE_MEM_FIFO) == DE_STATE2_DE_MEM_FIFO_EMPTY))
+               {
+                       return 0;
+               }
+       }
+       /* timeout error */
+       return -1;
+}
+
+
+int hw_sm750_deWait(void)
+{
+       int i=0x10000000;
+       while(i--){
+               unsigned int dwVal = PEEK32(SYSTEM_CTRL);
+               if((FIELD_GET(dwVal,SYSTEM_CTRL,DE_STATUS) == SYSTEM_CTRL_DE_STATUS_IDLE) &&
+                       (FIELD_GET(dwVal,SYSTEM_CTRL,DE_FIFO)  == SYSTEM_CTRL_DE_FIFO_EMPTY) &&
+                       (FIELD_GET(dwVal,SYSTEM_CTRL,DE_MEM_FIFO) == SYSTEM_CTRL_DE_MEM_FIFO_EMPTY))
+               {
+                       return 0;
+               }
+       }
+       /* timeout error */
+       return -1;
+}
+
+int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
+        const struct fb_var_screeninfo *var,
+        const struct fb_info *info)
+{
+    uint32_t total;
+    //check params
+    if ((var->xoffset + var->xres > var->xres_virtual) ||
+            (var->yoffset + var->yres > var->yres_virtual)) {
+        return -EINVAL;
+    }
+
+    total = var->yoffset * info->fix.line_length +
+        ((var->xoffset * var->bits_per_pixel) >> 3);
+    total += crtc->oScreen;
+    if (crtc->channel == sm750_primary) {
+        POKE32(PANEL_FB_ADDRESS,
+                FIELD_VALUE(PEEK32(PANEL_FB_ADDRESS),
+                    PANEL_FB_ADDRESS, ADDRESS, total));
+    } else {
+        POKE32(CRT_FB_ADDRESS,
+                FIELD_VALUE(PEEK32(CRT_FB_ADDRESS),
+                    CRT_FB_ADDRESS, ADDRESS, total));
+    }
+    return 0;
+}
+
diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h
new file mode 100644 (file)
index 0000000..b05be5e
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef LYNX_HW750_H__
+#define LYNX_HW750_H__
+
+
+#define DEFAULT_SM750_CHIP_CLOCK               290
+#define DEFAULT_SM750LE_CHIP_CLOCK     333
+#ifndef SM750LE_REVISION_ID
+#define SM750LE_REVISION_ID (unsigned char)0xfe
+#endif
+
+//#define DEFAULT_MEM_CLOCK    (DEFAULT_SM750_CHIP_CLOCK/1)
+//#define DEFAULT_MASTER_CLOCK (DEFAULT_SM750_CHIP_CLOCK/3)
+
+
+enum sm750_pnltype{
+
+       sm750_24TFT = 0,/* 24bit tft */
+
+       sm750_dualTFT = 2,/* dual 18 bit tft */
+
+       sm750_doubleTFT = 1,/* 36 bit double pixel tft */
+};
+
+/* vga channel is not concerned  */
+enum sm750_dataflow{
+       sm750_simul_pri,/* primary => all head */
+
+       sm750_simul_sec,/* secondary => all head */
+
+       sm750_dual_normal,/*    primary => panel head and secondary => crt */
+
+       sm750_dual_swap,/*      primary => crt head and secondary => panel */
+};
+
+
+enum sm750_channel{
+       sm750_primary = 0,
+       /* enum value equal to the register filed data */
+       sm750_secondary = 1,
+};
+
+enum sm750_path{
+       sm750_panel = 1,
+       sm750_crt = 2,
+       sm750_pnc = 3,/* panel and crt */
+};
+
+struct init_status{
+       ushort powerMode;
+       /* below three clocks are in unit of MHZ*/
+       ushort chip_clk;
+       ushort mem_clk;
+       ushort master_clk;
+       ushort setAllEngOff;
+       ushort resetMemory;
+};
+
+struct sm750_state{
+       struct init_status initParm;
+       enum sm750_pnltype pnltype;
+       enum sm750_dataflow dataflow;
+       int nocrt;
+       int xLCD;
+       int yLCD;
+};
+
+/*     sm750_share stands for a presentation of two frame buffer
+       that use one sm750 adaptor, it is similiar to the super class of lynx_share
+       in C++
+*/
+
+struct sm750_share{
+       /* it's better to put lynx_share struct to the first place of sm750_share */
+       struct lynx_share share;
+       struct sm750_state state;
+       int hwCursor;
+       /*      0: no hardware cursor
+               1: primary crtc hw cursor enabled,
+               2: secondary crtc hw cursor enabled
+               3: both ctrc hw cursor enabled
+       */
+};
+
+int hw_sm750_map(struct lynx_share* share,struct pci_dev* pdev);
+int hw_sm750_inithw(struct lynx_share*,struct pci_dev *);
+void hw_sm750_initAccel(struct lynx_share *);
+int hw_sm750_deWait(void);
+int hw_sm750le_deWait(void);
+
+resource_size_t hw_sm750_getVMSize(struct lynx_share *);
+int hw_sm750_output_checkMode(struct lynxfb_output*,struct fb_var_screeninfo*);
+int hw_sm750_output_setMode(struct lynxfb_output*,struct fb_var_screeninfo*,struct fb_fix_screeninfo*);
+int hw_sm750_crtc_checkMode(struct lynxfb_crtc*,struct fb_var_screeninfo*);
+int hw_sm750_crtc_setMode(struct lynxfb_crtc*,struct fb_var_screeninfo*,struct fb_fix_screeninfo*);
+int hw_sm750_setColReg(struct lynxfb_crtc*,ushort,ushort,ushort,ushort);
+int hw_sm750_setBLANK(struct lynxfb_output*,int);
+int hw_sm750le_setBLANK(struct lynxfb_output*,int);
+void hw_sm750_crtc_clear(struct lynxfb_crtc*);
+void hw_sm750_output_clear(struct lynxfb_output*);
+int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
+        const struct fb_var_screeninfo *var,
+        const struct fb_info *info);
+
+#endif
index 7cc1896938b60b13992d6e5982f680a71822eea7..c5d62534e4a4cebb54f85dc400952e56c122bdec 100644 (file)
@@ -119,7 +119,7 @@ struct ModeInit {
 /**********************************************************************
                         SM712 Mode table.
  **********************************************************************/
-struct ModeInit vgamode[] = {
+static struct ModeInit vgamode[] = {
        {
         /*  mode#0: 640 x 480  16Bpp  60Hz */
         640, 480, 16, 60,
index ebd95365ffae83e1afd456a5d451d7217397cb87..abdb02115cac1a8bf83e0bfafd704dfd34110777 100644 (file)
@@ -113,13 +113,15 @@ static struct vesa_mode vesa_mode_table[] = {
 
 static struct screen_info smtc_scr_info;
 
+static char *mode_option;
+
 /* process command line options, get vga parameter */
-static int __init sm7xx_vga_setup(char *options)
+static void __init sm7xx_vga_setup(char *options)
 {
        int i;
 
        if (!options || !*options)
-               return -EINVAL;
+               return;
 
        smtc_scr_info.lfb_width = 0;
        smtc_scr_info.lfb_height = 0;
@@ -133,13 +135,10 @@ static int __init sm7xx_vga_setup(char *options)
                        smtc_scr_info.lfb_height =
                                                vesa_mode_table[i].lfb_height;
                        smtc_scr_info.lfb_depth  = vesa_mode_table[i].lfb_depth;
-                       return 0;
+                       return;
                }
        }
-
-       return -1;
 }
-__setup("vga=", sm7xx_vga_setup);
 
 static void sm712_setpalette(int regno, unsigned red, unsigned green,
                             unsigned blue, struct fb_info *info)
@@ -1017,7 +1016,29 @@ static struct pci_driver smtcfb_driver = {
        .driver.pm  = SM7XX_PM_OPS,
 };
 
-module_pci_driver(smtcfb_driver);
+static int __init sm712fb_init(void)
+{
+#ifndef MODULE
+       char *option = NULL;
+
+       if (fb_get_options("sm712fb", &option))
+               return -ENODEV;
+       if (option && *option)
+               mode_option = option;
+#endif
+       sm7xx_vga_setup(mode_option);
+
+       return pci_register_driver(&smtcfb_driver);
+}
+
+module_init(sm712fb_init);
+
+static void __exit sm712fb_exit(void)
+{
+       pci_unregister_driver(&smtcfb_driver);
+}
+
+module_exit(sm712fb_exit);
 
 MODULE_AUTHOR("Siliconmotion ");
 MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards");
index 3708bc13ae86eed59570bdfad3fa1953ee04293e..0211df60004a6e267698b2171dd449a797258f2c 100644 (file)
@@ -840,12 +840,10 @@ static ssize_t message_show(struct kobject *kobj,
 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 = spk_find_msg_group(attr->attr.name);
 
        BUG_ON(!group);
-       retval = message_store_helper(buf, count, group);
-       return retval;
+       return message_store_helper(buf, count, group);
 }
 
 /*
index e9f0c150d2467632a3581eb98459431ca2aa7973..1249f910aed15343d74bf100e36474da1e94adf5 100644 (file)
@@ -1527,7 +1527,7 @@ static void update_color_buffer(struct vc_data *vc, const char *ic, int len)
        int i, bi, hi;
        int vc_num = vc->vc_num;
 
-       bi = ((vc->vc_attr & 0x70) >> 4);
+       bi = (vc->vc_attr & 0x70) >> 4;
        hi = speakup_console[vc_num]->ht.highsize[bi];
 
        i = 0;
index f0bfd9e991913903e51d57926030ef0e20e6772c..f418893928ece6c019f5870ff4d1aed56152c6b4 100644 (file)
@@ -318,18 +318,8 @@ module_param_named(start, synth_acntpc.startup, short, S_IRUGO);
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init acntpc_init(void)
-{
-       return synth_add(&synth_acntpc);
-}
-
-static void __exit acntpc_exit(void)
-{
-       synth_remove(&synth_acntpc);
-}
+module_spk_synth(synth_acntpc);
 
-module_init(acntpc_init);
-module_exit(acntpc_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Accent PC synthesizer");
index 3f2b5698a3d86606c5920c3ad5c93cc88311cfdf..af2690f38950c737345542035ac6c6be0f46b42a 100644 (file)
@@ -143,18 +143,8 @@ module_param_named(start, synth_acntsa.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init acntsa_init(void)
-{
-       return synth_add(&synth_acntsa);
-}
-
-static void __exit acntsa_exit(void)
-{
-       synth_remove(&synth_acntsa);
-}
+module_spk_synth(synth_acntsa);
 
-module_init(acntsa_init);
-module_exit(acntsa_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer");
index 678b263e551c4cee34e8ef73e87af7c92d6c8f03..51788f7d4480cb740a6773352dbca9f978d9940a 100644 (file)
@@ -207,18 +207,8 @@ module_param_named(start, synth_apollo.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init apollo_init(void)
-{
-       return synth_add(&synth_apollo);
-}
-
-static void __exit apollo_exit(void)
-{
-       synth_remove(&synth_apollo);
-}
+module_spk_synth(synth_apollo);
 
-module_init(apollo_init);
-module_exit(apollo_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer");
index 5cbaec8335fe373a4d52a5b3aa1d52bdfe541500..ea89e36ecd0d3eb544d1858ef5b1492116c3f706 100644 (file)
@@ -177,18 +177,8 @@ module_param_named(start, synth_audptr.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init audptr_init(void)
-{
-       return synth_add(&synth_audptr);
-}
-
-static void __exit audptr_exit(void)
-{
-       synth_remove(&synth_audptr);
-}
+module_spk_synth(synth_audptr);
 
-module_init(audptr_init);
-module_exit(audptr_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Audapter synthesizer");
index 2f070282a85de6f87f4f4b7000745d06bb92610f..80f8358d4199ca0e49920092fb730e114402b386 100644 (file)
@@ -127,18 +127,8 @@ module_param_named(start, synth_bns.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init bns_init(void)
-{
-       return synth_add(&synth_bns);
-}
+module_spk_synth(synth_bns);
 
-static void __exit bns_exit(void)
-{
-       synth_remove(&synth_bns);
-}
-
-module_init(bns_init);
-module_exit(bns_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Braille 'n Speak synthesizers");
index 555029036dc2bb3dc32895ffdb5f51a8b34e0318..2b772f8522f17ec84659e66db966b11422020623 100644 (file)
@@ -234,18 +234,8 @@ module_param_named(start, synth_decext.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init decext_init(void)
-{
-       return synth_add(&synth_decext);
-}
-
-static void __exit decext_exit(void)
-{
-       synth_remove(&synth_decext);
-}
+module_spk_synth(synth_decext);
 
-module_init(decext_init);
-module_exit(decext_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for DECtalk External synthesizers");
index 7c9c432e48d99fd11d71b6c2722eb36bd8fdef48..f7b9c8a3a1a59d776c121d01d473ff11a77c982c 100644 (file)
@@ -491,18 +491,8 @@ module_param_named(start, synth_dec_pc.startup, short, S_IRUGO);
 
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init decpc_init(void)
-{
-       return synth_add(&synth_dec_pc);
-}
-
-static void __exit decpc_exit(void)
-{
-       synth_remove(&synth_dec_pc);
-}
+module_spk_synth(synth_dec_pc);
 
-module_init(decpc_init);
-module_exit(decpc_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for DECtalk PC synthesizers");
index 69e7c2b41b9493d791987e5cf9103dd50bdd2e37..b5a23d42f4d5dc49fa2ad17fbea65685e9e95f3b 100644 (file)
@@ -306,18 +306,8 @@ module_param_named(start, synth_dectlk.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init dectlk_init(void)
-{
-       return synth_add(&synth_dectlk);
-}
-
-static void __exit dectlk_exit(void)
-{
-       synth_remove(&synth_dectlk);
-}
+module_spk_synth(synth_dectlk);
 
-module_init(dectlk_init);
-module_exit(dectlk_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for DECtalk Express synthesizers");
index 89592c0b915147e878fa83b29b07a6fec7c0bd66..345efd3344b06b11a66363add33fb2a7b62c6f67 100644 (file)
@@ -388,18 +388,8 @@ module_param_named(start, synth_dtlk.startup, short, S_IRUGO);
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init dtlk_init(void)
-{
-       return synth_add(&synth_dtlk);
-}
-
-static void __exit dtlk_exit(void)
-{
-       synth_remove(&synth_dtlk);
-}
+module_spk_synth(synth_dtlk);
 
-module_init(dtlk_init);
-module_exit(dtlk_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for DoubleTalk PC synthesizers");
index 362342a194afb2975b8fcd2328282c11d48781ed..f66811269475a6864a64062ce93bf6191ef103ae 100644 (file)
@@ -129,18 +129,8 @@ module_param_named(start, synth_dummy.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init dummy_init(void)
-{
-       return synth_add(&synth_dummy);
-}
+module_spk_synth(synth_dummy);
 
-static void __exit dummy_exit(void)
-{
-       synth_remove(&synth_dummy);
-}
-
-module_init(dummy_init);
-module_exit(dummy_exit);
 MODULE_AUTHOR("Samuel Thibault <samuel.thibault@ens-lyon.org>");
 MODULE_DESCRIPTION("Speakup support for text console");
 MODULE_LICENSE("GPL");
index cef20fdda64684038293b8e09778e23d28df4501..6ea02736566443a6db010865428fe029a6cc633d 100644 (file)
@@ -319,18 +319,8 @@ module_param_named(start, synth_keypc.startup, short, S_IRUGO);
 MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init keypc_init(void)
-{
-       return synth_add(&synth_keypc);
-}
-
-static void __exit keypc_exit(void)
-{
-       synth_remove(&synth_keypc);
-}
+module_spk_synth(synth_keypc);
 
-module_init(keypc_init);
-module_exit(keypc_exit);
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Keynote Gold PC synthesizers");
 MODULE_LICENSE("GPL");
index 377a6e2b8b9390038b1607c06c06cac73a6c8278..cc4806be806b2a6c782adc5c6bd6b8fb0935e948 100644 (file)
@@ -175,18 +175,8 @@ module_param_named(start, synth_ltlk.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init ltlk_init(void)
-{
-       return synth_add(&synth_ltlk);
-}
-
-static void __exit ltlk_exit(void)
-{
-       synth_remove(&synth_ltlk);
-}
+module_spk_synth(synth_ltlk);
 
-module_init(ltlk_init);
-module_exit(ltlk_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers");
index e6e93fbd183a090bcb7636f9745abe8438cada07..fb31bb95d83a1b591b47f34e571979cd2660228f 100644 (file)
@@ -350,19 +350,8 @@ module_param_named(start, synth_soft.startup, short, S_IRUGO);
 
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
+module_spk_synth(synth_soft);
 
-static int __init soft_init(void)
-{
-       return synth_add(&synth_soft);
-}
-
-static void __exit soft_exit(void)
-{
-       synth_remove(&synth_soft);
-}
-
-module_init(soft_init);
-module_exit(soft_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_DESCRIPTION("Speakup userspace software synthesizer support");
 MODULE_LICENSE("GPL");
index bccddf8b89fd23baf7b2043f690bd312d29d4870..1007a6168c3cc3e28d7d58fa9b499acb7eec6719 100644 (file)
@@ -146,18 +146,8 @@ module_param_named(start, synth_spkout.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init spkout_init(void)
-{
-       return synth_add(&synth_spkout);
-}
-
-static void __exit spkout_exit(void)
-{
-       synth_remove(&synth_spkout);
-}
+module_spk_synth(synth_spkout);
 
-module_init(spkout_init);
-module_exit(spkout_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers");
index dbe84b13772c08cc8e124e13dab8121cdef860da..6c21e7112210afc3dee54ca95984fd42a852f092 100644 (file)
@@ -127,18 +127,8 @@ module_param_named(start, synth_txprt.startup, short, S_IRUGO);
 MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based).");
 MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded.");
 
-static int __init txprt_init(void)
-{
-       return synth_add(&synth_txprt);
-}
+module_spk_synth(synth_txprt);
 
-static void __exit txprt_exit(void)
-{
-       synth_remove(&synth_txprt);
-}
-
-module_init(txprt_init);
-module_exit(txprt_exit);
 MODULE_AUTHOR("Kirk Reiser <kirk@braille.uwo.ca>");
 MODULE_AUTHOR("David Borowski");
 MODULE_DESCRIPTION("Speakup support for Transport synthesizers");
index 637ba6760ec060fb75a32fe661fe0a8880511970..1ef3795b865d32ae3dbbbcf807034affa1676da1 100644 (file)
 
 #define KT_SPKUP 15
 
-extern const struct old_serial_port *spk_serial_init(int index);
-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);
-extern void spk_serial_release(void);
+const struct old_serial_port *spk_serial_init(int index);
+void spk_stop_serial_interrupt(void);
+int spk_wait_for_xmitr(void);
+unsigned char spk_serial_in(void);
+unsigned char spk_serial_in_nowait(void);
+int spk_serial_out(const char ch);
+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 *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);
+char synth_buffer_getc(void);
+char synth_buffer_peek(void);
+int synth_buffer_empty(void);
+struct var_t *spk_get_var(enum var_id_t var_id);
+ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr,
+                    char *buf);
+ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
+                     const char *buf, size_t count);
 
-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);
-extern int spk_synth_is_alive_nop(struct spk_synth *synth);
-extern int spk_synth_is_alive_restart(struct spk_synth *synth);
-extern void synth_printf(const char *buf, ...);
-extern int synth_request_region(u_long, u_long);
-extern int synth_release_region(u_long, u_long);
-extern int synth_add(struct spk_synth *in_synth);
-extern void synth_remove(struct spk_synth *in_synth);
+int spk_serial_synth_probe(struct spk_synth *synth);
+const char *spk_synth_immediate(struct spk_synth *synth, const char *buff);
+void spk_do_catch_up(struct spk_synth *synth);
+void spk_synth_flush(struct spk_synth *synth);
+int spk_synth_is_alive_nop(struct spk_synth *synth);
+int spk_synth_is_alive_restart(struct spk_synth *synth);
+void synth_printf(const char *buf, ...);
+int synth_request_region(u_long, u_long);
+int synth_release_region(u_long, u_long);
+int synth_add(struct spk_synth *in_synth);
+void synth_remove(struct spk_synth *in_synth);
 
 extern struct speakup_info_t speakup_info;
 
index 8c565c94b8b25445242c34c4e1308925e1416194..55d6c9b3b4726e04101d2343abb32f7bbd1d653f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/io.h>          /* for inb_p, outb_p, inb, outb, etc... */
+#include <linux/device.h>
 
 enum var_type_t {
        VAR_NUM = 0,
@@ -179,6 +180,16 @@ struct spk_synth {
        struct attribute_group attributes;
 };
 
+/**
+ * module_spk_synth() - Helper macro for registering a speakup driver
+ * @__spk_synth: spk_synth struct
+ * Helper macro for speakup 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_spk_synth(__spk_synth) \
+       module_driver(__spk_synth, synth_add, synth_remove)
+
 struct speakup_info_t {
        spinlock_t spinlock;
        int port_tts;
index f92ae1d24f9f9a5ba417777294e8c2eb2ce428ea..0f524bb7b41d5bfaba0e038e20846c63d24b7785 100644 (file)
@@ -209,7 +209,7 @@ static int synaptics_rmi4_set_page(struct synaptics_rmi4_data *pdata,
                txbuf[1]        = page;
                retval  = i2c_master_send(i2c, txbuf, PAGE_LEN);
                if (retval != PAGE_LEN)
-                       dev_err(&i2c->dev, "%s:failed:%d\n", __func__, retval);
+                       dev_err(&i2c->dev, "failed:%d\n", retval);
                else
                        pdata->current_page = page;
        } else
@@ -283,7 +283,7 @@ static int synaptics_rmi4_i2c_byte_write(struct synaptics_rmi4_data *pdata,
        retval          = i2c_master_send(pdata->i2c_client, txbuf, 2);
        /* Add in retry on writes only in certain error return values */
        if (retval != 2) {
-               dev_err(&i2c->dev, "%s:failed:%d\n", __func__, retval);
+               dev_err(&i2c->dev, "failed:%d\n", retval);
                retval = -EIO;
        } else
                retval = 1;
@@ -830,8 +830,8 @@ static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata)
 
        /* Check if this is a Synaptics device - report if not. */
        if (pdata->rmi4_mod_info.manufacturer_id != 1)
-               dev_err(&client->dev, "%s: non-Synaptics mfg id:%d\n",
-                       __func__, pdata->rmi4_mod_info.manufacturer_id);
+               dev_err(&client->dev, "non-Synaptics mfg id:%d\n",
+                       pdata->rmi4_mod_info.manufacturer_id);
 
        list_for_each_entry(rfi, &pdata->rmi4_mod_info.support_fn_list, link)
                data_sources += rfi->num_of_data_sources;
@@ -990,8 +990,8 @@ static int synaptics_rmi4_probe
                                        platformdata->irq_type,
                                        DRIVER_NAME, rmi4_data);
        if (retval) {
-               dev_err(&client->dev, "%s:Unable to get attn irq %d\n",
-                               __func__, client->irq);
+               dev_err(&client->dev, "Unable to get attn irq %d\n",
+                       client->irq);
                goto err_query_dev;
        }
 
@@ -1112,12 +1112,11 @@ static int synaptics_rmi4_resume(struct device *dev)
        return 0;
 }
 
-static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = {
-       .suspend = synaptics_rmi4_suspend,
-       .resume  = synaptics_rmi4_resume,
-};
 #endif
 
+static SIMPLE_DEV_PM_OPS(synaptics_rmi4_dev_pm_ops, synaptics_rmi4_suspend,
+                        synaptics_rmi4_resume);
+
 static const struct i2c_device_id synaptics_rmi4_id_table[] = {
        { DRIVER_NAME, 0 },
        { },
@@ -1128,9 +1127,7 @@ static struct i2c_driver synaptics_rmi4_driver = {
        .driver = {
                .name   =       DRIVER_NAME,
                .owner  =       THIS_MODULE,
-#ifdef CONFIG_PM
                .pm     =       &synaptics_rmi4_dev_pm_ops,
-#endif
        },
        .probe          =       synaptics_rmi4_probe,
        .remove         =       synaptics_rmi4_remove,
index eb7efe484f6f905c8c43a47c46fe4459583aca09..3bd7579e1daf85800249f804e246a72f9e6a0491 100644 (file)
@@ -337,7 +337,7 @@ struct uiscmdrsp_scsi {
     /* peripheral type of 3 - processor */
     /* specifies device capable, but not present */
 
-#define DEV_HISUPPORT 0x10;    /* HiSup = 1; shows support for report luns */
+#define DEV_HISUPPORT 0x10     /* HiSup = 1; shows support for report luns */
     /* must be returned for lun 0. */
 
 /* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
index 78333719c4967164a95e93efd88347d81f1ce344..59a7459eb96243708d21cadc99bcff4eba51802b 100644 (file)
@@ -79,18 +79,15 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples  */
 #define ISSUE_IO_VMCALL(method, param, result) \
        (result = unisys_vmcall(method, (param) & 0xFFFFFFFF,   \
                                (param) >> 32))
-#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2,       \
-                                param3, result)                        \
-       (result = unisys_extended_vmcall(method, param1,        \
-                                        param2, param3))
+#define ISSUE_IO_EXTENDED_VMCALL(method, param1, param2, param3) \
+       unisys_extended_vmcall(method, param1, param2, param3)
 
     /* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
      * not used much */
 #define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity)          \
 do {                                                                   \
-       u32 _tempresult = VMCALL_SUCCESS;                               \
        ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity,   \
-                                MDS_APPOS, postcode, _tempresult);     \
+                                MDS_APPOS, postcode);                  \
 } while (0)
 #endif
 
index 1174056ec3d960e4a347a921cc581b2428daea7c..809c6794290ea00313f20dc5794acf6e6fd23a59 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef __PROCOBJECTTREE_H__
 #define __PROCOBJECTTREE_H__
 
-#include "uniklog.h"
 #include "timskmod.h"
 
 /* These are opaque structures to users.
index 4019a0d63645fe53380caec301679a68f9979e87..5a933d7bf39fa760526fe82c29909522a5c03b79 100644 (file)
 #define HOSTADDRESS unsigned long long
 #endif
 
-/** Try to evaulate the provided expression, and do a RETINT(x) iff
- *  the expression evaluates to < 0.
- */
-#define ASSERT(cond)                                           \
-       do { if (!(cond))                                      \
-                       HUHDRV("ASSERT failed - %s",           \
-                              __stringify(cond));             \
-       } while (0)
-
 #define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
 /** "Covered quotient" function */
 #define COVQ(v, d)  (((v) + (d) - 1) / (d))
                (void *)(p2) = SWAPPOINTERS_TEMP;       \
        } while (0)
 
-#define PRINTKDRV(fmt, args...) LOGINF(fmt, ## args)
-#define TBDDRV(fmt, args...)    LOGERR(fmt, ## args)
-#define HUHDRV(fmt, args...)    LOGERR(fmt, ## args)
-#define ERRDRV(fmt, args...)    LOGERR(fmt, ## args)
 #define WARNDRV(fmt, args...)   LOGWRN(fmt, ## args)
 #define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args)
-#define INFODRV(fmt, args...)   LOGINF(fmt, ## args)
-#define DEBUGDRV(fmt, args...)  DBGINF(fmt, ## args)
 
 #define PRINTKDEV(devname, fmt, args...)  LOGINFDEV(devname, fmt, ## args)
 #define TBDDEV(devname, fmt, args...)     LOGERRDEV(devname, fmt, ## args)
 #define SECUREDEV(devname, fmt, args...)  LOGWRNDEV(devname, fmt, ## args)
 #define INFODEV(devname, fmt, args...)    LOGINFDEV(devname, fmt, ## args)
 #define INFODEVX(devno, fmt, args...)     LOGINFDEVX(devno, fmt, ## args)
-#define DEBUGDEV(devname, fmt, args...)   DBGINFDEV(devname, fmt, ## args)
 
 /** Verifies the consistency of your PRIVATEDEVICEDATA structure using
  *  conventional "signature" fields:
index 25b6181d78af99c3beafebfe5d1e25dac3ee42a3..08ba16ea840ee5087a633840fd5fba15d26daf90 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "linux/version.h"
 #include "iochannel.h"
-#include "uniklog.h"
 #include <linux/atomic.h>
 #include <linux/semaphore.h>
 #include <linux/uuid.h>
index aa86ade7cb13a9c00559e48249fb0e8f87e7bb36..52c3eb4ded2c5c3deb465b32bb012026d922ae36 100644 (file)
@@ -27,7 +27,6 @@
 struct uisthread_info {
        struct task_struct *task;
        int id;
-       int should_stop;
        struct completion has_stopped;
 };
 
index 7414220676d3d9c3aeb5e3ebb05916d53d1762c1..c7d0ba8aafd8aa77f9b4adab81b03f6933d73766 100644 (file)
@@ -65,17 +65,7 @@ struct req_handler_info {
        struct list_head list_link;     /* links into ReqHandlerInfo_list */
 };
 
-struct req_handler_info *req_handler_add(uuid_le switch_uuid,
-                               const char *switch_type_name,
-                               int (*controlfunc)(struct io_msgs *),
-                               unsigned long min_channel_bytes,
-                               int (*svr_channel_ok)(unsigned long
-                                                        channel_bytes),
-                               int (*svr_channel_init)(void *x,
-                                               unsigned char *client_str,
-                                               u32 client_str_len, u64 bytes));
 struct req_handler_info *req_handler_find(uuid_le switch_uuid);
-int req_handler_del(uuid_le switch_uuid);
 
 #define uislib_ioremap_cache(addr, size) \
        dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
@@ -115,19 +105,7 @@ int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
 
 int uisctrl_register_req_handler(int type, void *fptr,
                        struct ultra_vbus_deviceinfo *chipset_driver_info);
-int uisctrl_register_req_handler_ex(uuid_le switch_guid,
-                       const char *switch_type_name,
-                       int (*fptr)(struct io_msgs *),
-                       unsigned long min_channel_bytes,
-                       int (*svr_channel_ok)(unsigned long
-                                             channel_bytes),
-                       int (*svr_channel_init)(void *x,
-                                               unsigned char *client_str,
-                                               u32 client_str_len,
-                                               u64 bytes),
-                       struct ultra_vbus_deviceinfo *chipset_driver_info);
 
-int uisctrl_unregister_req_handler_ex(uuid_le switch_uuid);
 unsigned char *util_map_virt(struct phys_info *sg);
 void util_unmap_virt(struct phys_info *sg);
 unsigned char *util_map_virt_atomic(struct phys_info *sg);
@@ -206,21 +184,10 @@ wait_for_valid_guid(uuid_le __iomem *guid)
                              (void __iomem *)guid, sizeof(uuid_le));
                if (uuid_le_cmp(tmpguid, NULL_UUID_LE) != 0)
                        break;
-               LOGERR("Waiting for non-0 GUID (why???)...\n");
                UIS_THREAD_WAIT_SEC(5);
        }
-       LOGERR("OK... GUID is non-0 now\n");
 }
 
-/* CopyFragsInfoFromSkb returns the number of entries added to frags array
- * Returns -1 on failure.
- */
-unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx,
-                                            void *skb_in,
-                                            unsigned int firstfraglen,
-                                            unsigned int frags_max,
-                                            struct phys_info frags[]);
-
 static inline unsigned int
 issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
 {
diff --git a/drivers/staging/unisys/include/uniklog.h b/drivers/staging/unisys/include/uniklog.h
deleted file mode 100644 (file)
index ecd1bdb..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/* uniklog.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* This module contains macros to aid developers in logging messages.
- *
- * This module is affected by the DEBUG compiletime option.
- *
- */
-#ifndef __UNIKLOG_H__
-#define __UNIKLOG_H__
-
-#include <linux/printk.h>
-
-/*
- * # DBGINF
- *
- * \brief Log debug informational message - log a LOG_INFO message only
- *        if DEBUG compiletime option enabled
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the
- *             format string.
- * \return nothing
- *
- * Log a message at the LOG_INFO level, but only if DEBUG is enabled.  If
- * DEBUG is disabled, this expands to a no-op.
- */
-
-/*
- * # DBGVER
- *
- * \brief Log debug verbose message - log a LOG_DEBUG message only if
- *        DEBUG compiletime option enabled
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the
- *             format string.
- * \return nothing
- *
- * Log a message at the LOG_DEBUG level, but only if DEBUG is enabled.  If
- * DEBUG is disabled, this expands to a no-op.  Note also that LOG_DEBUG
- * messages can be enabled/disabled at runtime as well.
- */
-#define DBGINFDEV(devname, fmt, args...)        do { } while (0)
-#define DBGVERDEV(devname, fmt, args...)        do { } while (0)
-#define DBGINF(fmt, args...)                    do { } while (0)
-#define DBGVER(fmt, args...)                    do { } while (0)
-
-/*
- * # LOGINF
- *
- * \brief Log informational message - logs a message at the LOG_INFO level
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the
- *             format string.
- * \return nothing
- *
- * Logs the specified message at the LOG_INFO level.
- */
-
-#define LOGINF(fmt, args...) pr_info(fmt, ## args)
-#define LOGINFDEV(devname, fmt, args...) \
-       pr_info("%s " fmt, devname, ## args)
-#define LOGINFDEVX(devno, fmt, args...) \
-       pr_info("dev%d " fmt, devno, ## args)
-#define LOGINFNAME(vnic, fmt, args...)                         \
-       do {                                                            \
-               if (vnic != NULL) {                                     \
-                       pr_info("%s " fmt, vnic->name, ## args);        \
-               } else {                                                \
-                       pr_info(fmt, ## args);                          \
-               }                                                       \
-       } while (0)
-
-/*
- * # LOGVER
- *
- * \brief Log verbose message - logs a message at the LOG_DEBUG level,
- *        which can be disabled at runtime
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the format
- * \param string.
- * \return nothing
- *
- * Logs the specified message at the LOG_DEBUG level.  Note also that
- * LOG_DEBUG messages can be enabled/disabled at runtime as well.
- */
-#define LOGVER(fmt, args...) pr_debug(fmt, ## args)
-#define LOGVERDEV(devname, fmt, args...) \
-       pr_debug("%s " fmt, devname, ## args)
-#define LOGVERNAME(vnic, fmt, args...)                                 \
-       do {                                                            \
-               if (vnic != NULL) {                                     \
-                       pr_debug("%s " fmt, vnic->name, ## args);       \
-               } else {                                                \
-                       pr_debug(fmt, ## args);                         \
-               }                                                       \
-       } while (0)
-
-/*
- * # LOGERR
- *
- * \brief Log error message - logs a message at the LOG_ERR level,
- *        including source line number information
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the format
- * \param string.
- * \return nothing
- *
- * Logs the specified error message at the LOG_ERR level.  It will also
- * include the file, line number, and function name of where the error
- * originated in the log message.
- */
-#define LOGERR(fmt, args...) pr_err(fmt, ## args)
-#define LOGERRDEV(devname, fmt, args...) \
-       pr_err("%s " fmt, devname, ## args)
-#define LOGERRDEVX(devno, fmt, args...) \
-       pr_err("dev%d " fmt, devno, ## args)
-#define LOGERRNAME(vnic, fmt, args...)                         \
-       do {                                                            \
-               if (vnic != NULL) {                                     \
-                       pr_err("%s " fmt, vnic->name, ## args); \
-               } else {                                                \
-                       pr_err(fmt, ## args);                           \
-               }                                                       \
-       } while (0)
-#define LOGORDUMPERR(seqfile, fmt, args...) do {               \
-               if (seqfile) {                                  \
-                       seq_printf(seqfile, fmt, ## args);      \
-               } else {                                        \
-                       LOGERR(fmt, ## args);                   \
-               }                                               \
-       } while (0)
-
-/*
- * # LOGWRN
- *
- * \brief Log warning message - Logs a message at the LOG_WARNING level,
- *        including source line number information
- *
- * \param devname the device name of the device reporting this message, or
- *                NULL if this message is NOT device-related.
- * \param fmt printf()-style format string containing the message to log.
- * \param args Optional arguments to be formatted and inserted into the format
- * \param string.
- * \return nothing
- *
- * Logs the specified error message at the LOG_WARNING level.  It will also
- * include the file, line number, and function name of where the error
- * originated in the log message.
- */
-#define LOGWRN(fmt, args...) pr_warn(fmt, ## args)
-#define LOGWRNDEV(devname, fmt, args...) \
-       pr_warn("%s " fmt, devname, ## args)
-#define LOGWRNNAME(vnic, fmt, args...) \
-       do {                                                            \
-               if (vnic != NULL) {                                     \
-                       pr_warn("%s " fmt, vnic->name, ## args);        \
-               } else {                                                \
-                       pr_warn(fmt, ## args);                          \
-               }                                                       \
-       } while (0)
-
-#endif /* __UNIKLOG_H__ */
index a712eb82224a4f68ae34e812f09140d4bffdf2b2..c39a0a21ae5fa7699c10099da1072c8d8dff6038 100644 (file)
@@ -4,7 +4,7 @@
 
 config UNISYS_UISLIB
        tristate "Unisys uislib driver"
-       depends on UNISYSSPAR && UNISYS_VISORCHIPSET && HAS_IOMEM
+       select UNISYS_VISORCHIPSET
        ---help---
        If you say Y here, you will enable the Unisys uislib driver.
 
index 08e620d1749792feff77f39616f5b4872793b965..860f494f132faff2c784f01651468168ecdfa873 100644 (file)
@@ -7,8 +7,6 @@ obj-$(CONFIG_UNISYS_UISLIB)     += visoruislib.o
 visoruislib-y := uislib.o uisqueue.o  uisthread.o  uisutils.o
 
 ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/channels
 ccflags-y += -Idrivers/staging/unisys/visorchipset
-ccflags-y += -Idrivers/staging/unisys/sparstopdriver
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
 ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
index a9eeddeba7354cf8466e7ad0709070ab569fb06a..d23e0df16b011ffe8e8857891a4004d91f45e56c 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/uuid.h>
 
 #include <linux/version.h>
-#include "uniklog.h"
 #include "diagnostics/appos_subsystems.h"
 #include "uisutils.h"
 #include "vbuschannel.h"
@@ -132,14 +131,10 @@ static __iomem void *init_vbus_channel(u64 ch_addr, u32 ch_bytes)
 {
        void __iomem *ch = uislib_ioremap_cache(ch_addr, ch_bytes);
 
-       if (!ch) {
-               LOGERR("CONTROLVM_BUS_CREATE error: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed",
-                      (unsigned long long)ch_addr,
-                      (unsigned long long)ch_bytes);
+       if (!ch)
                return NULL;
-       }
+
        if (!SPAR_VBUS_CHANNEL_OK_CLIENT(ch)) {
-               ERRDRV("%s channel cannot be used", __func__);
                uislib_iounmap(ch);
                return NULL;
        }
@@ -154,8 +149,6 @@ create_bus(struct controlvm_message *msg, char *buf)
        size_t size;
 
        if (max_bus_count == bus_list_count) {
-               LOGERR("CONTROLVM_BUS_CREATE Failed: max buses:%d already created\n",
-                      max_bus_count);
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, max_bus_count,
                                 POSTCODE_SEVERITY_ERR);
                return CONTROLVM_RESP_ERROR_MAX_BUSES;
@@ -172,7 +165,6 @@ create_bus(struct controlvm_message *msg, char *buf)
            (dev_count * sizeof(struct device_info *));
        bus = kzalloc(size, GFP_ATOMIC);
        if (!bus) {
-               LOGERR("CONTROLVM_BUS_CREATE Failed: kmalloc for bus failed.\n");
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
@@ -209,8 +201,6 @@ create_bus(struct controlvm_message *msg, char *buf)
                /* found a bus already in the list with same bus_no -
                 * reject add
                 */
-               LOGERR("CONTROLVM_BUS_CREATE Failed: bus %d already exists.\n",
-                      bus->bus_no);
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                 POSTCODE_SEVERITY_ERR);
                kfree(bus);
@@ -234,14 +224,12 @@ create_bus(struct controlvm_message *msg, char *buf)
                cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid;
                cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid;
                if (!virt_control_chan_func) {
-                       LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci callback not registered.");
                        POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                         POSTCODE_SEVERITY_ERR);
                        kfree(bus);
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
                if (!virt_control_chan_func(&cmd)) {
-                       LOGERR("CONTROLVM_BUS_CREATE Failed: virtpci GUEST_ADD_VBUS returned error.");
                        POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
                                         POSTCODE_SEVERITY_ERR);
                        kfree(bus);
@@ -287,8 +275,6 @@ destroy_bus(struct controlvm_message *msg, char *buf)
        }
 
        if (!bus) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: failed to find bus %d.\n",
-                      bus_no);
                read_unlock(&bus_list_lock);
                return CONTROLVM_RESP_ERROR_ALREADY_DONE;
        }
@@ -296,8 +282,6 @@ destroy_bus(struct controlvm_message *msg, char *buf)
        /* verify that this bus has no devices. */
        for (i = 0; i < bus->device_count; i++) {
                if (bus->device[i] != NULL) {
-                       LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.",
-                              i, bus_no);
                        read_unlock(&bus_list_lock);
                        return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED;
                }
@@ -311,14 +295,11 @@ destroy_bus(struct controlvm_message *msg, char *buf)
           with this bus. */
        cmd.msgtype = GUEST_DEL_VBUS;
        cmd.del_vbus.bus_no = bus_no;
-       if (!virt_control_chan_func) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci callback not registered.");
+       if (!virt_control_chan_func)
                return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-       }
-       if (!virt_control_chan_func(&cmd)) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error.");
+
+       if (!virt_control_chan_func(&cmd))
                return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
-       }
 
        /* finally, remove the bus from the list */
 remove:
@@ -357,7 +338,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
 
        dev = kzalloc(sizeof(*dev), GFP_ATOMIC);
        if (!dev) {
-               LOGERR("CONTROLVM_DEVICE_CREATE Failed: kmalloc for dev failed.\n");
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
@@ -381,9 +361,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                         */
                        min_size = req_handler->min_channel_bytes;
                if (min_size > msg->cmd.create_device.channel_bytes) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: channel size is too small, channel size:0x%lx, required size:0x%lx",
-                              (ulong)msg->cmd.create_device.channel_bytes,
-                              (ulong)min_size);
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
                        result = CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL;
@@ -393,9 +370,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                    uislib_ioremap_cache(dev->channel_addr,
                                         msg->cmd.create_device.channel_bytes);
                if (!dev->chanptr) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed",
-                              dev->channel_addr,
-                              msg->cmd.create_device.channel_bytes);
                        result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
@@ -411,8 +385,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                        continue;
                /* make sure the device number is valid */
                if (dev_no >= bus->device_count) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: device (%d) >= deviceCount (%d).",
-                              dev_no, bus->device_count);
                        result = CONTROLVM_RESP_ERROR_MAX_DEVICES;
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
@@ -421,8 +393,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                }
                /* make sure this device is not already set */
                if (bus->device[dev_no]) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: device %d is already exists.",
-                              dev_no);
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
                                         dev_no, bus_no,
                                         POSTCODE_SEVERITY_ERR);
@@ -445,8 +415,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                        wait_for_valid_guid(&((struct channel_header __iomem *)
                                            (dev->chanptr))->chtype);
                        if (!SPAR_VHBA_CHANNEL_OK_CLIENT(dev->chanptr)) {
-                               LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.",
-                                      dev_no);
                                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
                                                 dev_no, bus_no,
                                                 POSTCODE_SEVERITY_ERR);
@@ -464,8 +432,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                        wait_for_valid_guid(&((struct channel_header __iomem *)
                                            (dev->chanptr))->chtype);
                        if (!SPAR_VNIC_CHANNEL_OK_CLIENT(dev->chanptr)) {
-                               LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.",
-                                      dev_no);
                                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
                                                 dev_no, bus_no,
                                                 POSTCODE_SEVERITY_ERR);
@@ -479,7 +445,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                        cmd.add_vnic.instance_uuid = dev->instance_uuid;
                        cmd.add_vhba.intr = dev->intr;
                } else {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: unknown channelTypeGuid.\n");
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
                        result = CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
@@ -487,7 +452,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                }
 
                if (!virt_control_chan_func) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci callback not registered.");
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
                        result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
@@ -495,7 +459,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
                }
 
                if (!virt_control_chan_func(&cmd)) {
-                       LOGERR("CONTROLVM_DEVICE_CREATE Failed: virtpci GUEST_ADD_[VHBA||VNIC] returned error.");
                        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
                                         bus_no, POSTCODE_SEVERITY_ERR);
                        result =
@@ -510,8 +473,6 @@ static int create_device(struct controlvm_message *msg, char *buf)
        }
        read_unlock(&bus_list_lock);
 
-       LOGERR("CONTROLVM_DEVICE_CREATE Failed: failed to find bus %d.",
-              bus_no);
        POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_ERR);
        result = CONTROLVM_RESP_ERROR_BUS_INVALID;
@@ -542,15 +503,11 @@ static int pause_device(struct controlvm_message *msg)
                if (bus->bus_no == bus_no) {
                        /* make sure the device number is valid */
                        if (dev_no >= bus->device_count) {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device(%d) >= deviceCount(%d).",
-                                      dev_no, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
                                dev = bus->device[dev_no];
                                if (!dev) {
-                                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: device %d does not exist.",
-                                              dev_no);
                                        retval =
                                          CONTROLVM_RESP_ERROR_ALREADY_DONE;
                                }
@@ -558,11 +515,9 @@ static int pause_device(struct controlvm_message *msg)
                        break;
                }
        }
-       if (!bus) {
-               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: bus %d does not exist",
-                      bus_no);
+       if (!bus)
                retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
-       }
+
        read_unlock(&bus_list_lock);
        if (retval == CONTROLVM_RESP_SUCCESS) {
                /* the msg is bound for virtpci; send
@@ -577,15 +532,11 @@ static int pause_device(struct controlvm_message *msg)
                        cmd.msgtype = GUEST_PAUSE_VNIC;
                        cmd.pause_vnic.chanptr = dev->chanptr;
                } else {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: unknown channelTypeGuid.\n");
                        return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
-               if (!virt_control_chan_func) {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
+               if (!virt_control_chan_func)
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-               }
                if (!virt_control_chan_func(&cmd)) {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:pause Failed: virtpci GUEST_PAUSE_[VHBA||VNIC] returned error.");
                        return
                          CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
                }
@@ -609,15 +560,11 @@ static int resume_device(struct controlvm_message *msg)
                if (bus->bus_no == bus_no) {
                        /* make sure the device number is valid */
                        if (dev_no >= bus->device_count) {
-                               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device(%d) >= deviceCount(%d).",
-                                      dev_no, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
                                dev = bus->device[dev_no];
                                if (!dev) {
-                                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: device %d does not exist.",
-                                              dev_no);
                                        retval =
                                          CONTROLVM_RESP_ERROR_ALREADY_DONE;
                                }
@@ -626,11 +573,9 @@ static int resume_device(struct controlvm_message *msg)
                }
        }
 
-       if (!bus) {
-               LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: bus %d does not exist",
-                      bus_no);
+       if (!bus)
                retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
-       }
+
        read_unlock(&bus_list_lock);
        /* the msg is bound for virtpci; send
         * guest_msgs struct to callback
@@ -645,15 +590,11 @@ static int resume_device(struct controlvm_message *msg)
                        cmd.msgtype = GUEST_RESUME_VNIC;
                        cmd.resume_vnic.chanptr = dev->chanptr;
                } else {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: unknown channelTypeGuid.\n");
                        return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
-               if (!virt_control_chan_func) {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: virtpci callback not registered.");
+               if (!virt_control_chan_func)
                        return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-               }
                if (!virt_control_chan_func(&cmd)) {
-                       LOGERR("CONTROLVM_DEVICE_CHANGESTATE:resume Failed: virtpci GUEST_RESUME_[VHBA||VNIC] returned error.");
                        return
                          CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
                }
@@ -673,21 +614,15 @@ static int destroy_device(struct controlvm_message *msg, char *buf)
        dev_no = msg->cmd.destroy_device.bus_no;
 
        read_lock(&bus_list_lock);
-       LOGINF("destroy_device called for bus_no=%u, dev_no=%u", bus_no,
-              dev_no);
        for (bus = bus_list; bus; bus = bus->next) {
                if (bus->bus_no == bus_no) {
                        /* make sure the device number is valid */
                        if (dev_no >= bus->device_count) {
-                               LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device(%d) >= device_count(%d).",
-                                      dev_no, bus->device_count);
                                retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                        } else {
                                /* make sure this device exists */
                                dev = bus->device[dev_no];
                                if (!dev) {
-                                       LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.",
-                                              dev_no);
                                        retval =
                                             CONTROLVM_RESP_ERROR_ALREADY_DONE;
                                }
@@ -696,11 +631,8 @@ static int destroy_device(struct controlvm_message *msg, char *buf)
                }
        }
 
-       if (!bus) {
-               LOGERR("CONTROLVM_DEVICE_DESTROY Failed: bus %d does not exist",
-                      bus_no);
+       if (!bus)
                retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
-       }
        read_unlock(&bus_list_lock);
        if (retval == CONTROLVM_RESP_SUCCESS) {
                /* the msg is bound for virtpci; send
@@ -715,17 +647,14 @@ static int destroy_device(struct controlvm_message *msg, char *buf)
                        cmd.msgtype = GUEST_DEL_VNIC;
                        cmd.del_vnic.chanptr = dev->chanptr;
                } else {
-                       LOGERR("CONTROLVM_DEVICE_DESTROY Failed: unknown channelTypeGuid.\n");
                        return
                            CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
                }
                if (!virt_control_chan_func) {
-                       LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci callback not registered.");
                        return
                            CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
                }
                if (!virt_control_chan_func(&cmd)) {
-                       LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error.");
                        return
                            CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
                }
@@ -734,15 +663,11 @@ static int destroy_device(struct controlvm_message *msg, char *buf)
  * on which accesses the channel and you will get a "unable to handle
  * kernel paging request"
  */
-               if (dev->polling) {
-                       LOGINF("calling uislib_disable_channel_interrupts");
+               if (dev->polling)
                        uislib_disable_channel_interrupts(bus_no, dev_no);
-               }
                /* unmap the channel memory for the device. */
-               if (!msg->hdr.flags.test_message) {
-                       LOGINF("destroy_device, doing iounmap");
+               if (!msg->hdr.flags.test_message)
                        uislib_iounmap(dev->chanptr);
-               }
                kfree(dev);
                bus->device[dev_no] = NULL;
        }
@@ -780,10 +705,8 @@ static int delete_bus_glue(u32 bus_no)
 
        init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0);
        msg.cmd.destroy_bus.bus_no = bus_no;
-       if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("destroy_bus failed. bus_no=0x%x\n", bus_no);
+       if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
                return 0;
-       }
        return 1;
 }
 
@@ -794,11 +717,8 @@ static int delete_device_glue(u32 bus_no, u32 dev_no)
        init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0);
        msg.cmd.destroy_device.bus_no = bus_no;
        msg.cmd.destroy_device.dev_no = dev_no;
-       if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("destroy_device failed. bus_no=0x%x dev_no=0x%x\n",
-                      bus_no, dev_no);
+       if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
                return 0;
-       }
        return 1;
 }
 
@@ -808,7 +728,6 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
 {
        struct controlvm_message msg;
 
-       LOGINF("enter busNo=0x%x\n", bus_no);
        /* step 0: init the chipset */
        POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
@@ -824,11 +743,8 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
                */
                msg.cmd.init_chipset.bus_count = 23;
                msg.cmd.init_chipset.switch_count = 0;
-               if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-                       LOGERR("init_chipset failed.\n");
+               if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
                        return 0;
-               }
-               LOGINF("chipset initialized\n");
                POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, bus_no,
                                 POSTCODE_SEVERITY_INFO);
        }
@@ -842,7 +758,6 @@ uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
        msg.cmd.create_bus.channel_addr = channel_addr;
        msg.cmd.create_bus.channel_bytes = n_channel_bytes;
        if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("create_bus failed.\n");
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
@@ -871,11 +786,8 @@ uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no)
        msg.cmd.device_change_state.dev_no = dev_no;
        msg.cmd.device_change_state.state = segment_state_standby;
        rc = pause_device(&msg);
-       if (rc != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VHBA pause_device failed. busNo=0x%x devNo=0x%x\n",
-                      bus_no, dev_no);
+       if (rc != CONTROLVM_RESP_SUCCESS)
                return rc;
-       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba);
@@ -891,11 +803,8 @@ uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no)
        msg.cmd.device_change_state.dev_no = dev_no;
        msg.cmd.device_change_state.state = segment_state_running;
        rc = resume_device(&msg);
-       if (rc != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VHBA resume_device failed. busNo=0x%x devNo=0x%x\n",
-                      bus_no, dev_no);
+       if (rc != CONTROLVM_RESP_SUCCESS)
                return rc;
-       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba);
@@ -908,7 +817,6 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
 {
        struct controlvm_message msg;
 
-       LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no);
        /* chipset init'ed with bus bus has been previously created -
        * Verify it still exists step 2: create the VHBA device on the
        * bus
@@ -932,8 +840,6 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
                       sizeof(struct irq_info));
        msg.cmd.create_device.channel_addr = phys_chan_addr;
        if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
-               LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n",
-                      chan_bytes, (unsigned int)MIN_IO_CHANNEL_SIZE);
                POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, chan_bytes,
                                 MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
                return 0;
@@ -941,7 +847,6 @@ uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
        msg.cmd.create_device.channel_bytes = chan_bytes;
        msg.cmd.create_device.data_type_uuid = spar_vhba_channel_protocol_uuid;
        if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VHBA create_device failed.\n");
                POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
@@ -967,7 +872,6 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
 {
        struct controlvm_message msg;
 
-       LOGINF(" enter busNo=0x%x devNo=0x%x\n", bus_no, dev_no);
        /* chipset init'ed with bus bus has been previously created -
        * Verify it still exists step 2: create the VNIC device on the
        * bus
@@ -991,8 +895,6 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
                       sizeof(struct irq_info));
        msg.cmd.create_device.channel_addr = phys_chan_addr;
        if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
-               LOGERR("wrong channel size.chan_bytes = 0x%x IO_CHANNEL_SIZE= 0x%x\n",
-                      chan_bytes, (unsigned int)MIN_IO_CHANNEL_SIZE);
                POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, chan_bytes,
                                 MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
                return 0;
@@ -1000,7 +902,6 @@ uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
        msg.cmd.create_device.channel_bytes = chan_bytes;
        msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid;
        if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VNIC create_device failed.\n");
                POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
@@ -1023,11 +924,8 @@ uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no)
        msg.cmd.device_change_state.dev_no = dev_no;
        msg.cmd.device_change_state.state = segment_state_standby;
        rc = pause_device(&msg);
-       if (rc != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VNIC pause_device failed. busNo=0x%x devNo=0x%x\n",
-                      bus_no, dev_no);
+       if (rc != CONTROLVM_RESP_SUCCESS)
                return -1;
-       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic);
@@ -1043,11 +941,8 @@ uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no)
        msg.cmd.device_change_state.dev_no = dev_no;
        msg.cmd.device_change_state.state = segment_state_running;
        rc = resume_device(&msg);
-       if (rc != CONTROLVM_RESP_SUCCESS) {
-               LOGERR("VNIC resume_device failed. busNo=0x%x devNo=0x%x\n",
-                      bus_no, dev_no);
+       if (rc != CONTROLVM_RESP_SUCCESS)
                return -1;
-       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic);
@@ -1069,11 +964,8 @@ uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln)
        */
        void *p = kmem_cache_alloc(cur_pool, GFP_ATOMIC | __GFP_NORETRY);
 
-       if (p == NULL) {
-               LOGERR("uislib_malloc failed to alloc uiscmdrsp @%s:%d",
-                      fn, ln);
+       if (p == NULL)
                return NULL;
-       }
        return p;
 }
 EXPORT_SYMBOL_GPL(uislib_cache_alloc);
@@ -1081,10 +973,8 @@ EXPORT_SYMBOL_GPL(uislib_cache_alloc);
 void
 uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln)
 {
-       if (p == NULL) {
-               LOGERR("uislib_free NULL pointer @%s:%d", fn, ln);
+       if (p == NULL)
                return;
-       }
        kmem_cache_free(cur_pool, p);
 }
 EXPORT_SYMBOL_GPL(uislib_cache_free);
@@ -1163,19 +1053,15 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
 
 /* *start = buf; */
        if (debug_buf == NULL) {
-               DBGINF("debug_buf == NULL; allocating buffer.\n.");
                debug_buf = vmalloc(PROC_READ_BUFFER_SIZE);
 
-               if (debug_buf == NULL) {
-                       LOGERR("failed to allocate buffer to provide proc data.\n");
+               if (debug_buf == NULL)
                        return -ENOMEM;
-               }
        }
 
        temp = debug_buf;
 
        if ((*offset == 0) || (!debug_buf_valid)) {
-               DBGINF("calling info_debugfs_read_helper.\n");
                /* if the read fails, then -1 will be returned */
                total_bytes = info_debugfs_read_helper(&temp, &remaining_bytes);
                debug_buf_valid = 1;
@@ -1196,17 +1082,9 @@ static struct device_info *find_dev(u32 bus_no, u32 dev_no)
        for (bus = bus_list; bus; bus = bus->next) {
                if (bus->bus_no == bus_no) {
                        /* make sure the device number is valid */
-                       if (dev_no >= bus->device_count) {
-                               LOGERR("%s bad bus_no, dev_no=%d,%d",
-                                      __func__,
-                                      (int)bus_no, (int)dev_no);
+                       if (dev_no >= bus->device_count)
                                break;
-                       }
                        dev = bus->device[dev_no];
-                       if (!dev)
-                               LOGERR("%s bad bus_no, dev_no=%d,%d",
-                                      __func__,
-                                      (int)bus_no, (int)dev_no);
                        break;
                }
        }
@@ -1253,7 +1131,6 @@ static int process_incoming(void *v)
                                wait_cycles = (cur_cycles - old_cycles);
                }
        }
-       LOGINF("wait_cycles=%llu", wait_cycles);
        cycles_before_wait = wait_cycles;
        idle_cycles = 0;
        poll_dev_start = 0;
@@ -1294,7 +1171,7 @@ static int process_incoming(void *v)
                                        }
                                }
                        }
-                       if (incoming_ti.should_stop)
+                       if (kthread_should_stop())
                                break;
                }
                if (new_tail != NULL) {
@@ -1311,12 +1188,10 @@ static int process_incoming(void *v)
                * - there is no input waiting on any of the channels
                * - we have received a signal to stop this thread
                */
-               if (incoming_ti.should_stop)
+               if (kthread_should_stop())
                        break;
-               if (en_smart_wakeup == 0xFF) {
-                       LOGINF("en_smart_wakeup set to 0xff, to force exiting process_incoming");
+               if (en_smart_wakeup == 0xFF)
                        break;
-               }
                /* wait for POLLJIFFIES_NORMAL jiffies, or until
                * someone wakes up poll_dev_wake_q,
                * whichever comes first only do a wait when we have
@@ -1335,7 +1210,6 @@ static int process_incoming(void *v)
                        idle_cycles = idle_cycles + delta_cycles;
                }
        }
-       DBGINF("exiting.\n");
        complete_and_exit(&incoming_ti.has_stopped, 0);
 }
 
@@ -1346,7 +1220,6 @@ initialize_incoming_thread(void)
                return TRUE;
        if (!uisthread_start(&incoming_ti,
                             &process_incoming, NULL, "dev_incoming")) {
-               LOGERR("uisthread_start initialize_incoming_thread ****FAILED");
                return FALSE;
        }
        incoming_started = TRUE;
@@ -1367,11 +1240,9 @@ uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no,
        struct device_info *dev;
 
        dev = find_dev(bus_no, dev_no);
-       if (!dev) {
-               LOGERR("%s busNo=%d, devNo=%d", __func__, (int)(bus_no),
-                      (int)(dev_no));
+       if (!dev)
                return;
-       }
+
        down(&poll_dev_lock);
        initialize_incoming_thread();
        dev->interrupt = interrupt;
@@ -1392,11 +1263,8 @@ uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no)
        struct device_info *dev;
 
        dev = find_dev(bus_no, dev_no);
-       if (!dev) {
-               LOGERR("%s busNo=%d, devNo=%d", __func__, (int)(bus_no),
-                      (int)(dev_no));
+       if (!dev)
                return;
-       }
        down(&poll_dev_lock);
        list_del(&dev->list_polling_device_channels);
        dev->polling = FALSE;
@@ -1446,27 +1314,6 @@ uislib_mod_init(void)
        if (!unisys_spar_platform)
                return -ENODEV;
 
-       LOGINF("MONITORAPIS");
-
-       LOGINF("sizeof(struct uiscmdrsp):%lu bytes\n",
-              (ulong)sizeof(struct uiscmdrsp));
-       LOGINF("sizeof(struct phys_info):%lu\n",
-              (ulong)sizeof(struct phys_info));
-       LOGINF("sizeof(uiscmdrsp_scsi):%lu\n",
-              (ulong)sizeof(struct uiscmdrsp_scsi));
-       LOGINF("sizeof(uiscmdrsp_net):%lu\n",
-              (ulong)sizeof(struct uiscmdrsp_net));
-       LOGINF("sizeof(CONTROLVM_MESSAGE):%lu bytes\n",
-              (ulong)sizeof(struct controlvm_message));
-       LOGINF("sizeof(struct spar_controlvm_channel_protocol):%lu bytes\n",
-              (ulong)sizeof(struct spar_controlvm_channel_protocol));
-       LOGINF("sizeof(CHANNEL_HEADER):%lu bytes\n",
-              (ulong)sizeof(struct channel_header));
-       LOGINF("sizeof(struct spar_io_channel_protocol):%lu bytes\n",
-              (ulong)sizeof(struct spar_io_channel_protocol));
-       LOGINF("SIZEOF_CMDRSP:%lu bytes\n", SIZEOF_CMDRSP);
-       LOGINF("SIZEOF_PROTOCOL:%lu bytes\n", SIZEOF_PROTOCOL);
-
        /* initialize global pointers to NULL */
        bus_list = NULL;
        bus_list_count = 0;
@@ -1514,8 +1361,6 @@ uislib_mod_exit(void)
        debugfs_remove(cycles_before_wait_debugfs_read);
        debugfs_remove(platformnumber_debugfs_read);
        debugfs_remove(dir_debugfs);
-
-       DBGINF("goodbye.\n");
 }
 
 module_init(uislib_mod_init);
index 71bb7b608e9a4615b02aee7dccacac1f1c2d2bad..d46dd7428a30ab7462039108607ef63f0b56895a 100644 (file)
@@ -295,12 +295,10 @@ uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
        while (!do_locked_client_insert(queueinfo, whichqueue, cmdrsp,
                                        (spinlock_t *)insertlock,
                                        channel_id)) {
-               if (oktowait != OK_TO_WAIT) {
-                       LOGERR("****FAILED visor_signal_insert failed; cannot wait; insert aborted\n");
+               if (oktowait != OK_TO_WAIT)
                        return 0;       /* failed to queue */
-               }
+
                /* try again */
-               LOGERR("****FAILED visor_signal_insert failed; waiting to try again\n");
                set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(msecs_to_jiffies(10));
        }
index 25adf1a7307c9d1112908f790e60c5ec1331a37b..d3c973b617ee7fe1de8da632779e6ad7d97294bf 100644 (file)
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/kthread.h>
-#include "uniklog.h"
 #include "uisutils.h"
 #include "uisthread.h"
 
-#define KILL(a, b, c) kill_pid(find_vpid(a), b, c)
-
 /* this is shorter than using __FILE__ (full path name) in
  * debug/info/error messages
  */
@@ -41,17 +38,14 @@ int
 uisthread_start(struct uisthread_info *thrinfo,
                int (*threadfn)(void *), void *thrcontext, char *name)
 {
-       thrinfo->should_stop = 0;
        /* used to stop the thread */
        init_completion(&thrinfo->has_stopped);
-       thrinfo->task = kthread_create(threadfn, thrcontext, name, NULL);
+       thrinfo->task = kthread_run(threadfn, thrcontext, name);
        if (IS_ERR(thrinfo->task)) {
                thrinfo->id = 0;
                return 0;       /* failure */
        }
        thrinfo->id = thrinfo->task->pid;
-       wake_up_process(thrinfo->task);
-       LOGINF("started thread pid:%d\n", thrinfo->id);
        return 1;
 }
 EXPORT_SYMBOL_GPL(uisthread_start);
@@ -59,27 +53,17 @@ EXPORT_SYMBOL_GPL(uisthread_start);
 void
 uisthread_stop(struct uisthread_info *thrinfo)
 {
-       int ret;
        int stopped = 0;
 
        if (thrinfo->id == 0)
                return;         /* thread not running */
 
-       LOGINF("uisthread_stop stopping id:%d\n", thrinfo->id);
-       thrinfo->should_stop = 1;
-       ret = KILL(thrinfo->id, SIGHUP, 1);
-       if (ret) {
-               LOGERR("unable to signal thread %d\n", ret);
-       } else {
-               /* give up if the thread has NOT died in 1 minute */
-               if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
-                       stopped = 1;
-               else
-                       LOGERR("timed out trying to signal thread\n");
-       }
-       if (stopped) {
-               LOGINF("uisthread_stop stopped id:%d\n", thrinfo->id);
+       kthread_stop(thrinfo->task);
+       /* give up if the thread has NOT died in 1 minute */
+       if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
+               stopped = 1;
+
+       if (stopped)
                thrinfo->id = 0;
-       }
 }
 EXPORT_SYMBOL_GPL(uisthread_stop);
index 31318d246252981189ebeea753889313bcc16419..26ab76526813712cf27863e03c09ac46289c1181 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/uuid.h>
 #include <linux/spinlock.h>
 #include <linux/list.h>
-#include "uniklog.h"
 #include "uisutils.h"
 #include "version.h"
 #include "vbushelper.h"
@@ -53,7 +52,6 @@ uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
        va_list args;
        int len;
 
-       DBGINF("buffer = 0x%p : *buffer = 0x%p.\n", buffer, *buffer);
        va_start(args, format);
        len = vsnprintf(*buffer, *buffer_remaining, format, args);
        va_end(args);
@@ -61,7 +59,6 @@ uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
                *buffer += *buffer_remaining;
                *total += *buffer_remaining;
                *buffer_remaining = 0;
-               LOGERR("bytes remaining is too small!\n");
                return -1;
        }
        *buffer_remaining -= len;
@@ -75,8 +72,6 @@ int
 uisctrl_register_req_handler(int type, void *fptr,
                             struct ultra_vbus_deviceinfo *chipset_driver_info)
 {
-       LOGINF("type = %d, fptr = 0x%p.\n", type, fptr);
-
        switch (type) {
        case 2:
                if (fptr) {
@@ -91,7 +86,6 @@ uisctrl_register_req_handler(int type, void *fptr,
                break;
 
        default:
-               LOGERR("invalid type %d.\n", type);
                return 0;
        }
        if (chipset_driver_info)
@@ -102,71 +96,6 @@ uisctrl_register_req_handler(int type, void *fptr,
 }
 EXPORT_SYMBOL_GPL(uisctrl_register_req_handler);
 
-int
-uisctrl_register_req_handler_ex(uuid_le switch_uuid,
-                       const char *switch_type_name,
-                       int (*controlfunc)(struct io_msgs *),
-                       unsigned long min_channel_bytes,
-                       int (*server_channel_ok)(unsigned long channel_bytes),
-                       int (*server_channel_init)(void *x,
-                                               unsigned char *client_str,
-                                               u32 client_str_len, u64 bytes),
-                       struct ultra_vbus_deviceinfo *chipset_driver_info)
-{
-       struct req_handler_info *req_handler;
-
-       LOGINF("type=%pUL, controlfunc=0x%p.\n",
-              &switch_uuid, controlfunc);
-       if (!controlfunc) {
-               LOGERR("%pUL: controlfunc must be supplied\n", &switch_uuid);
-               return 0;
-       }
-       if (!server_channel_ok) {
-               LOGERR("%pUL: Server_Channel_Ok must be supplied\n",
-                               &switch_uuid);
-               return 0;
-       }
-       if (!server_channel_init) {
-               LOGERR("%pUL: Server_Channel_Init must be supplied\n",
-                               &switch_uuid);
-               return 0;
-       }
-       req_handler = req_handler_add(switch_uuid,
-                                     switch_type_name,
-                                     controlfunc,
-                                     min_channel_bytes,
-                                     server_channel_ok, server_channel_init);
-       if (!req_handler) {
-               LOGERR("failed to add %pUL to server list\n", &switch_uuid);
-               return 0;
-       }
-
-       atomic_inc(&uisutils_registered_services);
-       if (chipset_driver_info) {
-               bus_device_info_init(chipset_driver_info, "chipset",
-                                    "uislib", VERSION, NULL);
-               return 1;
-       }
-
-       LOGERR("failed to register type %pUL.\n", &switch_uuid);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(uisctrl_register_req_handler_ex);
-
-int
-uisctrl_unregister_req_handler_ex(uuid_le switch_uuid)
-{
-       LOGINF("type=%pUL.\n", &switch_uuid);
-       if (req_handler_del(switch_uuid) < 0) {
-               LOGERR("failed to remove %pUL from server list\n",
-                      &switch_uuid);
-               return 0;
-       }
-       atomic_dec(&uisutils_registered_services);
-       return 1;
-}
-EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex);
-
 /*
  * unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx,
  *                                          void *skb_in,
@@ -185,116 +114,10 @@ EXPORT_SYMBOL_GPL(uisctrl_unregister_req_handler_ex);
  *                                         return value indicates number of
  *                                         entries filled in frags
  */
-unsigned int
-uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx, void *skb_in,
-                               unsigned int firstfraglen,
-                               unsigned int frags_max,
-                               struct phys_info frags[])
-{
-       unsigned int count = 0, ii, size, offset = 0, numfrags;
-       struct sk_buff *skb = skb_in;
-
-       numfrags = skb_shinfo(skb)->nr_frags;
-
-       while (firstfraglen) {
-               if (count == frags_max) {
-                       LOGERR("%s frags array too small: max:%d count:%d\n",
-                              calling_ctx, frags_max, count);
-                       return -1;      /* failure */
-               }
-               frags[count].pi_pfn =
-                   page_to_pfn(virt_to_page(skb->data + offset));
-               frags[count].pi_off =
-                   (unsigned long)(skb->data + offset) & PI_PAGE_MASK;
-               size =
-                   min(firstfraglen,
-                       (unsigned int)(PI_PAGE_SIZE - frags[count].pi_off));
-               /* can take smallest of firstfraglen(what's left) OR
-               * bytes left in the page
-               */
-               frags[count].pi_len = size;
-               firstfraglen -= size;
-               offset += size;
-               count++;
-       }
-       if (!numfrags)
-               goto dolist;
-
-       if ((count + numfrags) > frags_max) {
-               LOGERR("**** FAILED %s frags array too small: max:%d count+nr_frags:%d\n",
-                      calling_ctx, frags_max, count + numfrags);
-               return -1;      /* failure */
-       }
-
-       for (ii = 0; ii < numfrags; ii++) {
-               count = add_physinfo_entries(page_to_pfn(
-                               skb_frag_page(&skb_shinfo(skb)->frags[ii])),
-                                       skb_shinfo(skb)->frags[ii].
-                                       page_offset,
-                                       skb_shinfo(skb)->frags[ii].
-                                       size, count, frags_max,
-                                       frags);
-               if (count == 0) {
-                       LOGERR("**** FAILED to add physinfo entries\n");
-                       return -1;      /* failure */
-               }
-       }
-
-dolist: if (skb_shinfo(skb)->frag_list) {
-               struct sk_buff *skbinlist;
-               int c;
-
-               for (skbinlist = skb_shinfo(skb)->frag_list; skbinlist;
-                    skbinlist = skbinlist->next) {
-                       c = uisutil_copy_fragsinfo_from_skb("recursive",
-                               skbinlist,
-                               skbinlist->len - skbinlist->data_len,
-                               frags_max - count,
-                               &frags[count]);
-                       if (c == -1) {
-                               LOGERR("**** FAILED recursive call failed\n");
-                               return -1;
-                       }
-                       count += c;
-               }
-       }
-       return count;
-}
-EXPORT_SYMBOL_GPL(uisutil_copy_fragsinfo_from_skb);
 
 static LIST_HEAD(req_handler_info_list); /* list of struct req_handler_info */
 static DEFINE_SPINLOCK(req_handler_info_list_lock);
 
-struct req_handler_info *
-req_handler_add(uuid_le switch_uuid,
-             const char *switch_type_name,
-             int (*controlfunc)(struct io_msgs *),
-             unsigned long min_channel_bytes,
-             int (*server_channel_ok)(unsigned long channel_bytes),
-             int (*server_channel_init)
-              (void *x, unsigned char *clientstr, u32 clientstr_len,
-               u64 bytes))
-{
-       struct req_handler_info *rc = NULL;
-
-       rc = kzalloc(sizeof(*rc), GFP_ATOMIC);
-       if (!rc)
-               return NULL;
-       rc->switch_uuid = switch_uuid;
-       rc->controlfunc = controlfunc;
-       rc->min_channel_bytes = min_channel_bytes;
-       rc->server_channel_ok = server_channel_ok;
-       rc->server_channel_init = server_channel_init;
-       if (switch_type_name)
-               strncpy(rc->switch_type_name, switch_type_name,
-                       sizeof(rc->switch_type_name) - 1);
-       spin_lock(&req_handler_info_list_lock);
-       list_add_tail(&rc->list_link, &req_handler_info_list);
-       spin_unlock(&req_handler_info_list_lock);
-
-       return rc;
-}
-
 struct req_handler_info *
 req_handler_find(uuid_le switch_uuid)
 {
@@ -312,23 +135,3 @@ req_handler_find(uuid_le switch_uuid)
        spin_unlock(&req_handler_info_list_lock);
        return NULL;
 }
-
-int
-req_handler_del(uuid_le switch_uuid)
-{
-       struct list_head *lelt, *tmp;
-       struct req_handler_info *entry = NULL;
-       int rc = -1;
-
-       spin_lock(&req_handler_info_list_lock);
-       list_for_each_safe(lelt, tmp, &req_handler_info_list) {
-               entry = list_entry(lelt, struct req_handler_info, list_link);
-               if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) {
-                       list_del(lelt);
-                       kfree(entry);
-                       rc++;
-               }
-       }
-       spin_unlock(&req_handler_info_list_lock);
-       return rc;
-}
index 9af98fc7acbc389b7b296bf62d044006b69c7ced..dfadfc49114aba7fb13b684d500efda75ace498c 100644 (file)
@@ -4,7 +4,10 @@
 
 config UNISYS_VIRTHBA
        tristate "Unisys virthba driver"
-       depends on UNISYSSPAR && UNISYS_VISORCHIPSET && UNISYS_UISLIB && UNISYS_VIRTPCI && SCSI
+       depends on SCSI
+       select UNISYS_VISORCHIPSET
+       select UNISYS_UISLIB
+       select UNISYS_VIRTPCI
        ---help---
        If you say Y here, you will enable the Unisys virthba driver.
 
index ba55ae12488e021d6a5ff5734c9f9a1afa8a88e0..a4e4037391832760423e53dc1159b257245893fa 100644 (file)
@@ -6,7 +6,6 @@ obj-$(CONFIG_UNISYS_VIRTHBA)    += virthba.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/timskmod
 ccflags-y += -Idrivers/staging/unisys/visorchipset
 ccflags-y += -Idrivers/staging/unisys/virtpci
 ccflags-y += -Idrivers/staging/unisys/common-spar/include
index e6ecea560495fabab567ca94983b99be1a423d56..d9001cca0f73575fd47ae94073af268dde4770f3 100644 (file)
  * which start with an 8 digit sequence number, a colon, and then
  * letters after that */
 
-#undef DBGINF
-
 #include <linux/kernel.h>
 #ifdef CONFIG_MODVERSIONS
 #include <config/modversions.h>
 #endif
 
-#include "uniklog.h"
 #include "diagnostics/appos_subsystems.h"
 #include "uisutils.h"
 #include "uisqueue.h"
@@ -261,11 +258,9 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char cmdtype, void *new)
 
        spin_lock_irqsave(&vhbainfo->privlock, flags);
        insert_location = vhbainfo->nextinsert;
-       while (vhbainfo->pending[insert_location].sent != NULL) {
+       while (vhbainfo->pending[insert_location].sent) {
                insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
                if (insert_location == (int)vhbainfo->nextinsert) {
-                       LOGERR("Queue should be full. insert_location<<%d>>  Unable to find open slot for pending commands.\n",
-                            insert_location);
                        spin_unlock_irqrestore(&vhbainfo->privlock, flags);
                        return -1;
                }
@@ -286,7 +281,6 @@ add_scsipending_entry_with_wait(struct virthba_info *vhbainfo, char cmdtype,
        int insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
 
        while (insert_location == -1) {
-               LOGERR("Failed to find empty queue slot.  Waiting to try again\n");
                set_current_state(TASK_INTERRUPTIBLE);
                schedule_timeout(msecs_to_jiffies(10));
                insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
@@ -301,16 +295,8 @@ del_scsipending_entry(struct virthba_info *vhbainfo, uintptr_t del)
        unsigned long flags;
        void *sent = NULL;
 
-       if (del >= MAX_PENDING_REQUESTS) {
-               LOGERR("Invalid queue position <<%lu>> given to delete. MAX_PENDING_REQUESTS <<%d>>\n",
-                    (unsigned long)del, MAX_PENDING_REQUESTS);
-       } else {
+       if (del < MAX_PENDING_REQUESTS) {
                spin_lock_irqsave(&vhbainfo->privlock, flags);
-
-               if (vhbainfo->pending[del].sent == NULL)
-                       LOGERR("Deleting already cleared queue entry at <<%lu>>.\n",
-                            (unsigned long)del);
-
                sent = vhbainfo->pending[del].sent;
 
                vhbainfo->pending[del].cmdtype = 0;
@@ -357,13 +343,7 @@ send_disk_add_remove(struct diskaddremove *dar)
                error =
                    scsi_add_device(dar->shost, dar->channel, dar->id,
                                    dar->lun);
-               if (error)
-                       LOGERR("Failed scsi_add_device: host_no=%d[chan=%d:id=%d:lun=%d]\n",
-                            dar->shost->host_no, dar->channel, dar->id,
-                            dar->lun);
-       } else
-               LOGERR("Failed scsi_device_lookup:[chan=%d:id=%d:lun=%d]\n",
-                      dar->channel, dar->id, dar->lun);
+       }
        kfree(dar);
 }
 
@@ -408,10 +388,6 @@ process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp)
                dar->id = cmdrsp->disknotify.id;
                dar->lun = cmdrsp->disknotify.lun;
                QUEUE_DISKADDREMOVE(dar);
-       } else {
-               LOGERR("kmalloc failed for dar. host_no=%d[chan=%d:id=%d:lun=%d]\n",
-                    shost->host_no, cmdrsp->disknotify.channel,
-                    cmdrsp->disknotify.id, cmdrsp->disknotify.lun);
        }
 }
 
@@ -427,7 +403,7 @@ virthba_isr(int irq, void *dev_id)
        u64 mask;
        unsigned long long rc1;
 
-       if (virthbainfo == NULL)
+       if (!virthbainfo)
                return IRQ_NONE;
        virthbainfo->interrupts_rcvd++;
        channel_header = virthbainfo->chinfo.queueinfo->chan;
@@ -467,13 +443,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        struct signal_queue_header __iomem *pqhdr;
        u64 mask;
 
-       LOGVER("entering virthba_probe...\n");
-       LOGVER("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
-
-       LOGINF("entering virthba_probe...\n");
-       LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
        POSTCODE_LINUX_2(VHBA_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        /* call scsi_host_alloc to register a scsi host adapter
         * instance - this virthba that has just been created is an
@@ -482,7 +451,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
         * initialization.  The host is not published to the scsi
         * midlayer until scsi_add_host is called.
         */
-       DBGINF("calling scsi_host_alloc.\n");
 
        /* arg 2 passed in length of extra space we want allocated
         * with scsi_host struct for our own use scsi_host_alloc
@@ -490,12 +458,9 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
         */
        scsihost = scsi_host_alloc(&virthba_driver_template,
                                   sizeof(struct virthba_info));
-       if (scsihost == NULL)
+       if (!scsihost)
                return -ENODEV;
 
-       DBGINF("scsihost: 0x%p, scsihost->this_id: %d, host_no: %d.\n",
-              scsihost, scsihost->this_id, scsihost->host_no);
-
        scsihost->this_id = UIS_MAGIC_VHBA;
        /* linux treats max-channel differently than max-id & max-lun.
         * In the latter cases, those two values result in 0 to max-1
@@ -503,12 +468,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
         * scan is 0 to max (inclusive); so we will subtract one from
         * the max-channel value.
         */
-       LOGINF("virtpcidev->scsi.max.max_channel=%u, max_id=%u, max_lun=%u, cmd_per_lun=%u, max_io_size=%u\n",
-            (unsigned)virtpcidev->scsi.max.max_channel - 1,
-            (unsigned)virtpcidev->scsi.max.max_id,
-            (unsigned)virtpcidev->scsi.max.max_lun,
-            (unsigned)virtpcidev->scsi.max.cmd_per_lun,
-            (unsigned)virtpcidev->scsi.max.max_io_size);
        scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel;
        scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id;
        scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun;
@@ -519,15 +478,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
            (unsigned short)(virtpcidev->scsi.max.max_io_size / PAGE_SIZE);
        if (scsihost->sg_tablesize > MAX_PHYS_INFO)
                scsihost->sg_tablesize = MAX_PHYS_INFO;
-       LOGINF("scsihost->max_channel=%u, max_id=%u, max_lun=%llu, cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n",
-            scsihost->max_channel, scsihost->max_id, scsihost->max_lun,
-            scsihost->cmd_per_lun, scsihost->max_sectors,
-            scsihost->sg_tablesize);
-       LOGINF("scsihost->can_queue=%u, scsihost->cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n",
-            scsihost->can_queue, scsihost->cmd_per_lun, scsihost->max_sectors,
-            scsihost->sg_tablesize);
-
-       DBGINF("calling scsi_add_host\n");
 
        /* this creates "host%d" in sysfs.  If 2nd argument is NULL,
         * then this generic /sys/devices/platform/host?  device is
@@ -538,7 +488,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
         */
        error = scsi_add_host(scsihost, &virtpcidev->generic_dev);
        if (error) {
-               LOGERR("scsi_add_host ****FAILED 0x%x  TBD - RECOVER\n", error);
                POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                /* decr refcount on scsihost which was incremented by
                 * scsi_add_host so the scsi_host gets deleted
@@ -550,7 +499,7 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        virthbainfo = (struct virthba_info *)scsihost->hostdata;
        memset(virthbainfo, 0, sizeof(struct virthba_info));
        for (i = 0; i < VIRTHBASOPENMAX; i++) {
-               if (virthbas_open[i].virthbainfo == NULL) {
+               if (!virthbas_open[i].virthbainfo) {
                        virthbas_open[i].virthbainfo = virthbainfo;
                        break;
                }
@@ -560,9 +509,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        virthbainfo->virtpcidev = virtpcidev;
        spin_lock_init(&virthbainfo->chinfo.insertlock);
 
-       DBGINF("generic_dev: 0x%p, queueinfo: 0x%p.\n",
-              &virtpcidev->generic_dev, &virtpcidev->queueinfo);
-
        init_waitqueue_head(&virthbainfo->rsp_queue);
        spin_lock_init(&virthbainfo->privlock);
        memset(&virthbainfo->pending, 0, sizeof(virthbainfo->pending));
@@ -584,8 +530,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
               ULTRA_IO_CHANNEL_IS_POLLING,
               &virthbainfo->chinfo.queueinfo->chan->features);
        /* start thread that will receive scsicmnd responses */
-       DBGINF("starting rsp thread -- queueinfo: 0x%p, threadinfo: 0x%p.\n",
-              virthbainfo->chinfo.queueinfo, &virthbainfo->chinfo.threadinfo);
 
        channel_header = virthbainfo->chinfo.queueinfo->chan;
        pqhdr = (struct signal_queue_header __iomem *)
@@ -596,7 +540,6 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
        if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
                             process_incoming_rsps,
                             virthbainfo, "vhba_incoming")) {
-               LOGERR("uisthread_start rsp ****FAILED\n");
                /* decr refcount on scsihost which was incremented by
                 * scsi_add_host so the scsi_host gets deleted
                 */
@@ -604,42 +547,26 @@ virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
                scsi_host_put(scsihost);
                return -ENODEV;
        }
-       LOGINF("sendInterruptHandle=0x%16llX",
-              virthbainfo->intr.send_irq_handle);
-       LOGINF("recvInterruptHandle=0x%16llX",
-              virthbainfo->intr.recv_irq_handle);
-       LOGINF("recvInterruptVector=0x%8X",
-              virthbainfo->intr.recv_irq_vector);
-       LOGINF("recvInterruptShared=0x%2X",
-              virthbainfo->intr.recv_irq_shared);
-       LOGINF("scsihost.hostt->name=%s", scsihost->hostt->name);
        virthbainfo->interrupt_vector =
            virthbainfo->intr.recv_irq_handle & INTERRUPT_VECTOR_MASK;
        rsp = request_irq(virthbainfo->interrupt_vector, handler, IRQF_SHARED,
                          scsihost->hostt->name, virthbainfo);
        if (rsp != 0) {
-               LOGERR("request_irq(%d) uislib_virthba_ISR request failed with rsp=%d\n",
-                      virthbainfo->interrupt_vector, rsp);
                virthbainfo->interrupt_vector = -1;
                POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
        } else {
-               u64 __iomem *Features_addr =
+               u64 __iomem *features_addr =
                    &virthbainfo->chinfo.queueinfo->chan->features;
-               LOGERR("request_irq(%d) uislib_virthba_ISR request succeeded\n",
-                      virthbainfo->interrupt_vector);
                mask = ~(ULTRA_IO_CHANNEL_IS_POLLING |
                         ULTRA_IO_DRIVER_DISABLES_INTS);
-               uisqueue_interlocked_and(Features_addr, mask);
+               uisqueue_interlocked_and(features_addr, mask);
                mask = ULTRA_IO_DRIVER_ENABLES_INTS;
-               uisqueue_interlocked_or(Features_addr, mask);
+               uisqueue_interlocked_or(features_addr, mask);
                rsltq_wait_usecs = 4000000;
        }
 
-       DBGINF("calling scsi_scan_host.\n");
        scsi_scan_host(scsihost);
-       DBGINF("return from scsi_scan_host.\n");
 
-       LOGINF("virthba added scsihost:0x%p\n", scsihost);
        POSTCODE_LINUX_2(VHBA_PROBE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 0;
 }
@@ -651,28 +578,18 @@ virthba_remove(struct virtpci_dev *virtpcidev)
        struct Scsi_Host *scsihost =
            (struct Scsi_Host *)virtpcidev->scsi.scsihost;
 
-       LOGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
        virthbainfo = (struct virthba_info *)scsihost->hostdata;
        if (virthbainfo->interrupt_vector != -1)
                free_irq(virthbainfo->interrupt_vector, virthbainfo);
-       LOGINF("Removing virtpcidev: 0x%p, virthbainfo: 0x%p\n", virtpcidev,
-              virthbainfo);
 
-       DBGINF("removing scsihost: 0x%p, scsihost->this_id: %d\n", scsihost,
-              scsihost->this_id);
        scsi_remove_host(scsihost);
 
-       DBGINF("stopping thread.\n");
        uisthread_stop(&virthbainfo->chinfo.threadinfo);
 
-       DBGINF("calling scsi_host_put\n");
-
        /* decr refcount on scsihost which was incremented by
         * scsi_add_host so the scsi_host gets deleted
         */
        scsi_host_put(scsihost);
-       LOGINF("virthba removed scsi_host.\n");
 }
 
 static int
@@ -686,19 +603,12 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype,
        int notifyresult = 0xffff;
        wait_queue_head_t notifyevent;
 
-       LOGINF("vDiskMgmt:%d %d:%d:%d\n", vdiskcmdtype,
-              vdest->channel, vdest->id, vdest->lun);
-
-       if (virthbainfo->serverdown || virthbainfo->serverchangingstate) {
-               DBGINF("Server is down/changing state. Returning Failure.\n");
+       if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
                return FAILED;
-       }
 
        cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
-       if (cmdrsp == NULL) {
-               LOGERR("kmalloc of cmdrsp failed.\n");
-               return FAILED;  /* reject */
-       }
+       if (!cmdrsp)
+               return FAILED;  /* reject */
 
        init_waitqueue_head(&notifyevent);
 
@@ -727,10 +637,7 @@ forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype,
                                             &virthbainfo->chinfo.insertlock,
                                             DONT_ISSUE_INTERRUPT, (u64)NULL,
                                             OK_TO_WAIT, "vhba");
-       LOGINF("VdiskMgmt waiting on event notifyevent=0x%p\n",
-              cmdrsp->scsitaskmgmt.notify);
        wait_event(notifyevent, notifyresult != 0xffff);
-       LOGINF("VdiskMgmt complete; result:%d\n", cmdrsp->vdiskmgmt.result);
        kfree(cmdrsp);
        return SUCCESS;
 }
@@ -749,19 +656,12 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype,
        int notifyresult = 0xffff;
        wait_queue_head_t notifyevent;
 
-       LOGINF("TaskMgmt:%d %d:%d:%llu\n", tasktype,
-              scsidev->channel, scsidev->id, scsidev->lun);
-
-       if (virthbainfo->serverdown || virthbainfo->serverchangingstate) {
-               DBGINF("Server is down/changing state. Returning Failure.\n");
+       if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
                return FAILED;
-       }
 
        cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
-       if (cmdrsp == NULL) {
-               LOGERR("kmalloc of cmdrsp failed.\n");
+       if (!cmdrsp)
                return FAILED;  /* reject */
-       }
 
        init_waitqueue_head(&notifyevent);
 
@@ -789,10 +689,7 @@ forward_taskmgmt_command(enum task_mgmt_types tasktype,
                                             &virthbainfo->chinfo.insertlock,
                                             DONT_ISSUE_INTERRUPT, (u64)NULL,
                                             OK_TO_WAIT, "vhba");
-       LOGINF("TaskMgmt waiting on event notifyevent=0x%p\n",
-              cmdrsp->scsitaskmgmt.notify);
        wait_event(notifyevent, notifyresult != 0xffff);
-       LOGINF("TaskMgmt complete; result:%d\n", cmdrsp->scsitaskmgmt.result);
        kfree(cmdrsp);
        return SUCCESS;
 }
@@ -882,7 +779,6 @@ static int
 virthba_host_reset_handler(struct scsi_cmnd *scsicmd)
 {
        /* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */
-       LOGERR("virthba_host_reset_handler Not yet implemented\n");
        return SUCCESS;
 }
 
@@ -899,7 +795,6 @@ virthba_get_info(struct Scsi_Host *shp)
 static int
 virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg)
 {
-       DBGINF("In virthba_ioctl: ioctl: cmd=0x%x\n", cmd);
        return -EINVAL;
 }
 
@@ -923,16 +818,11 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
        struct scatterlist *sgl = NULL;
        int sg_failed = 0;
 
-       if (virthbainfo->serverdown || virthbainfo->serverchangingstate) {
-               DBGINF("Server is down/changing state. Returning SCSI_MLQUEUE_DEVICE_BUSY.\n");
+       if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
                return SCSI_MLQUEUE_DEVICE_BUSY;
-       }
-
        cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
-       if (cmdrsp == NULL) {
-               LOGERR("kmalloc of cmdrsp failed.\n");
+       if (!cmdrsp)
                return 1;       /* reject the command */
-       }
 
        /* now saving everything we need from scsi_cmd into cmdrsp
         * before we queue cmdrsp set type to command - as opposed to
@@ -947,7 +837,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
        if (insert_location != -1) {
                cmdrsp->scsi.scsicmd = (void *)(uintptr_t)insert_location;
        } else {
-               LOGERR("Queue is full. Returning busy.\n");
                kfree(cmdrsp);
                return SCSI_MLQUEUE_DEVICE_BUSY;
        }
@@ -968,8 +857,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
                max_buff_len = cmdrsp->scsi.bufflen;
 
        if (scsi_sg_count(scsicmd) > MAX_PHYS_INFO) {
-               LOGERR("scsicmd use_sg:%d greater than MAX:%d\n",
-                      scsi_sg_count(scsicmd), MAX_PHYS_INFO);
                del_scsipending_entry(virthbainfo, (uintptr_t)insert_location);
                kfree(cmdrsp);
                return 1;       /* reject the command */
@@ -982,11 +869,8 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
        /* convert buffer to phys information */
        if (scsi_sg_count(scsicmd) == 0) {
                if (scsi_bufflen(scsicmd) > 0) {
-                       LOGERR("**** FAILED No scatter list for bufflen > 0\n");
                        BUG_ON(scsi_sg_count(scsicmd) == 0);
                }
-               DBGINF("No sg; buffer:0x%p bufflen:%d\n",
-                      scsi_sglist(scsicmd), scsi_bufflen(scsicmd));
        } else {
                /* buffer is scatterlist - copy it out */
                sgl = scsi_sglist(scsicmd);
@@ -994,21 +878,9 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
                for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) {
                        cmdrsp->scsi.gpi_list[i].address = sg_phys(sg);
                        cmdrsp->scsi.gpi_list[i].length = sg->length;
-                       if ((i != 0) && (sg->offset != 0))
-                               LOGINF("Offset on a sg_entry other than zero =<<%d>>.\n",
-                                      sg->offset);
                }
 
                if (sg_failed) {
-                       LOGERR("Start sg_list dump (entries %d, bufflen %d)...\n",
-                              scsi_sg_count(scsicmd), cmdrsp->scsi.bufflen);
-                       for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) {
-                               LOGERR("   Entry(%d): page->[0x%p], phys->[0x%Lx], off(%d), len(%d)\n",
-                                      i, sg_page(sg),
-                                      (unsigned long long)sg_phys(sg),
-                                      sg->offset, sg->length);
-                       }
-                       LOGERR("Done sg_list dump.\n");
                        /* BUG(); ***** For now, let it fail in uissd
                         * if it is a problem, as it might just
                         * work
@@ -1027,7 +899,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
                                                 (u64)NULL, DONT_WAIT, "vhba");
        if (i == 0) {
                /* queue must be full - and we said don't wait - return busy */
-               LOGERR("uisqueue_put_cmdrsp_with_lock ****FAILED\n");
                kfree(cmdrsp);
                del_scsipending_entry(virthbainfo, (uintptr_t)insert_location);
                return SCSI_MLQUEUE_DEVICE_BUSY;
@@ -1052,10 +923,9 @@ virthba_slave_alloc(struct scsi_device *scsidev)
        struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host;
 
        virthbainfo = (struct virthba_info *)scsihost->hostdata;
-       if (!virthbainfo) {
-               LOGERR("Could not find virthba_info for scsihost\n");
+       if (!virthbainfo)
                return 0;       /* even though we errored, treat as success */
-       }
+
        for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) {
                if (vdisk->next->valid &&
                    (vdisk->next->channel == scsidev->channel) &&
@@ -1064,10 +934,8 @@ virthba_slave_alloc(struct scsi_device *scsidev)
                        return 0;
        }
        tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC);
-       if (!tmpvdisk) {        /* error allocating */
-               LOGERR("Could not allocate memory for disk\n");
+       if (!tmpvdisk)
                return 0;
-       }
 
        tmpvdisk->channel = scsidev->channel;
        tmpvdisk->id = scsidev->id;
@@ -1094,8 +962,6 @@ virthba_slave_destroy(struct scsi_device *scsidev)
        struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host;
 
        virthbainfo = (struct virthba_info *)scsihost->hostdata;
-       if (!virthbainfo)
-               LOGERR("Could not find virthba_info for scsihost\n");
        for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) {
                if (vdisk->next->valid &&
                    (vdisk->next->channel == scsidev->channel) &&
@@ -1140,19 +1006,6 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 
                if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) {
                        atomic_inc(&vdisk->error_count);
-                       LOGERR("SCSICMD ****FAILED scsicmd:0x%p op:0x%x <%d:%d:%d:%llu> 0x%x-0x%x-0x%x-0x%x-0x%x.\n",
-                              scsicmd, cmdrsp->scsi.cmnd[0],
-                              scsidev->host->host_no, scsidev->id,
-                              scsidev->channel, scsidev->lun,
-                              cmdrsp->scsi.linuxstat, sd->valid, sd->sense_key,
-                              sd->additional_sense_code,
-                              sd->additional_sense_code_qualifier);
-                       if (atomic_read(&vdisk->error_count) ==
-                           VIRTHBA_ERROR_COUNT) {
-                               LOGERR("Throtling SCSICMD errors disk <%d:%d:%d:%llu>\n",
-                                      scsidev->host->host_no, scsidev->id,
-                                      scsidev->channel, scsidev->lun);
-                       }
                        atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD);
                }
        }
@@ -1188,7 +1041,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 
                if (scsi_sg_count(scsicmd) == 0) {
                        if (scsi_bufflen(scsicmd) > 0) {
-                               LOGERR("**** FAILED No scatter list for bufflen > 0\n");
                                BUG_ON(scsi_sg_count(scsicmd) ==
                                       0);
                        }
@@ -1199,8 +1051,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 
                sg = scsi_sglist(scsicmd);
                for (i = 0; i < scsi_sg_count(scsicmd); i++) {
-                       DBGVER("copying OUT OF buf into 0x%p %d\n",
-                              sg_page(sg + i), sg[i].length);
                        thispage_orig = kmap_atomic(sg_page(sg + i));
                        thispage = (void *)((unsigned long)thispage_orig |
                                             sg[i].offset);
@@ -1219,7 +1069,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
                        if (atomic_read(&vdisk->ios_threshold) > 0) {
                                atomic_dec(&vdisk->ios_threshold);
                                if (atomic_read(&vdisk->ios_threshold) == 0) {
-                                       LOGERR("Resetting error count for disk\n");
                                        atomic_set(&vdisk->error_count, 0);
                                }
                        }
@@ -1230,8 +1079,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 static void
 complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
 {
-       DBGINF("cmdrsp: 0x%p, scsistat:0x%x.\n", cmdrsp, cmdrsp->scsi.scsistat);
-
        /* take what we need out of cmdrsp and complete the scsicmd */
        scsicmd->result = cmdrsp->scsi.linuxstat;
        if (cmdrsp->scsi.linuxstat)
@@ -1239,10 +1086,8 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
        else
                do_scsi_nolinuxstat(cmdrsp, scsicmd);
 
-       if (scsicmd->scsi_done) {
-               DBGVER("Scsi_DONE\n");
+       if (scsicmd->scsi_done)
                scsicmd->scsi_done(scsicmd);
-       }
 }
 
 static inline void
@@ -1252,7 +1097,6 @@ complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp)
        /* wake up the error handler that is waiting for this */
        *(int *)cmdrsp->vdiskmgmt.notifyresult = cmdrsp->vdiskmgmt.result;
        wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify);
-       LOGINF("set notify result to %d\n", cmdrsp->vdiskmgmt.result);
 }
 
 static inline void
@@ -1263,7 +1107,6 @@ complete_taskmgmt_command(struct uiscmdrsp *cmdrsp)
        *(int *)cmdrsp->scsitaskmgmt.notifyresult =
            cmdrsp->scsitaskmgmt.result;
        wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify);
-       LOGINF("set notify result to %d\n", cmdrsp->scsitaskmgmt.result);
 }
 
 static void
@@ -1319,8 +1162,7 @@ drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc,
                                                    cmdrsp->vdiskmgmt.scsicmd))
                                break;
                        complete_vdiskmgmt_command(cmdrsp);
-               } else
-                       LOGERR("Invalid cmdtype %d\n", cmdrsp->cmdtype);
+               }
                /* cmdrsp is now available for reuse */
        }
 }
@@ -1341,13 +1183,14 @@ process_incoming_rsps(void *v)
        UIS_DAEMONIZE("vhba_incoming");
        /* alloc once and reuse */
        cmdrsp = kmalloc(SZ, GFP_ATOMIC);
-       if (cmdrsp == NULL) {
-               LOGERR("process_incoming_rsps ****FAILED to malloc - thread exiting\n");
+       if (!cmdrsp) {
                complete_and_exit(&dc->threadinfo.has_stopped, 0);
                return 0;
        }
        mask = ULTRA_CHANNEL_ENABLE_INTS;
        while (1) {
+               if (kthread_should_stop())
+                       break;
                wait_event_interruptible_timeout(virthbainfo->rsp_queue,
                         (atomic_read(&virthbainfo->interrupt_rcvd) == 1),
                                      usecs_to_jiffies(rsltq_wait_usecs));
@@ -1355,13 +1198,10 @@ process_incoming_rsps(void *v)
                /* drain queue */
                drain_queue(virthbainfo, dc, cmdrsp);
                rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
-               if (dc->threadinfo.should_stop)
-                       break;
        }
 
        kfree(cmdrsp);
 
-       DBGINF("exiting processing incoming rsps.\n");
        complete_and_exit(&dc->threadinfo.has_stopped, 0);
 }
 
@@ -1386,7 +1226,7 @@ static ssize_t info_debugfs_read(struct file *file,
                return -ENOMEM;
 
        for (i = 0; i < VIRTHBASOPENMAX; i++) {
-               if (virthbas_open[i].virthbainfo == NULL)
+               if (!virthbas_open[i].virthbainfo)
                        continue;
 
                virthbainfo = virthbas_open[i].virthbainfo;
@@ -1436,23 +1276,17 @@ static ssize_t enable_ints_write(struct file *file, const char __user *buffer,
                return -EINVAL;
 
        buf[count] = '\0';
-       if (copy_from_user(buf, buffer, count)) {
-               LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
-                      (int)count, buf, count);
+       if (copy_from_user(buf, buffer, count))
                return -EFAULT;
-       }
 
        i = kstrtoint(buf, 10, &new_value);
 
-       if (i != 0) {
-               LOGERR("Failed to scan value for enable_ints, buf<<%.*s>>",
-                      (int)count, buf);
+       if (i != 0)
                return -EFAULT;
-       }
 
        /* set all counts to new_value usually 0 */
        for (i = 0; i < VIRTHBASOPENMAX; i++) {
-               if (virthbas_open[i].virthbainfo != NULL) {
+               if (virthbas_open[i].virthbainfo) {
                        virthbainfo = virthbas_open[i].virthbainfo;
                        features_addr =
                                &virthbainfo->chinfo.queueinfo->chan->features;
@@ -1484,17 +1318,11 @@ virthba_serverup(struct virtpci_dev *virtpcidev)
            (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi.
                                     scsihost)->hostdata;
 
-       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
-
-       if (!virthbainfo->serverdown) {
-               DBGINF("Server up message received while server is already up.\n");
+       if (!virthbainfo->serverdown)
                return 1;
-       }
-       if (virthbainfo->serverchangingstate) {
-               LOGERR("Server already processing change state message\n");
+
+       if (virthbainfo->serverchangingstate)
                return 0;
-       }
 
        virthbainfo->serverchangingstate = true;
        /* Must transition channel to ATTACHED state BEFORE we
@@ -1508,7 +1336,6 @@ virthba_serverup(struct virtpci_dev *virtpcidev)
        if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
                             process_incoming_rsps,
                             virthbainfo, "vhba_incoming")) {
-               LOGERR("uisthread_start rsp ****FAILED\n");
                return 0;
        }
        virthbainfo->serverdown = false;
@@ -1543,18 +1370,16 @@ virthba_serverdown_complete(struct work_struct *work)
                switch (pendingdel->cmdtype) {
                case CMD_SCSI_TYPE:
                        scsicmd = (struct scsi_cmnd *)pendingdel->sent;
-                       scsicmd->result = (DID_RESET << 16);
+                       scsicmd->result = DID_RESET << 16;
                        if (scsicmd->scsi_done)
                                scsicmd->scsi_done(scsicmd);
                        break;
                case CMD_SCSITASKMGMT_TYPE:
                        cmdrsp = (struct uiscmdrsp *)pendingdel->sent;
-                       DBGINF("cmdrsp=0x%x, notify=0x%x\n", cmdrsp,
-                              cmdrsp->scsitaskmgmt.notify);
-                       *(int *)cmdrsp->scsitaskmgmt.notifyresult =
-                           TASK_MGMT_FAILED;
                        wake_up_all((wait_queue_head_t *)
                                    cmdrsp->scsitaskmgmt.notify);
+                       *(int *)cmdrsp->scsitaskmgmt.notifyresult =
+                               TASK_MGMT_FAILED;
                        break;
                case CMD_VDISKMGMT_TYPE:
                        cmdrsp = (struct uiscmdrsp *)pendingdel->sent;
@@ -1564,9 +1389,7 @@ virthba_serverdown_complete(struct work_struct *work)
                                    cmdrsp->vdiskmgmt.notify);
                        break;
                default:
-                       if (pendingdel->sent != NULL)
-                               LOGERR("Unknown command type: 0x%x.  Only freeing list structure.\n",
-                                    pendingdel->cmdtype);
+                       break;
                }
                pendingdel->cmdtype = 0;
                pendingdel->sent = NULL;
@@ -1575,8 +1398,6 @@ virthba_serverdown_complete(struct work_struct *work)
 
        virtpcidev = virthbainfo->virtpcidev;
 
-       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
        virthbainfo->serverdown = true;
        virthbainfo->serverchangingstate = false;
        /* Return the ServerDown response to Command */
@@ -1594,19 +1415,12 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state)
            (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi.
                                     scsihost)->hostdata;
 
-       DBGINF("virthba_serverdown");
-       DBGINF("virtpcidev bus_no<<%d>>devNo<<%d>>", virtpcidev->bus_no,
-              virtpcidev->device_no);
-
        if (!virthbainfo->serverdown && !virthbainfo->serverchangingstate) {
                virthbainfo->serverchangingstate = true;
                queue_work(virthba_serverdown_workqueue,
                           &virthbainfo->serverdown_completion);
        } else if (virthbainfo->serverchangingstate) {
-               LOGERR("Server already processing change state message\n");
                stat = 0;
-       } else {
-               LOGERR("Server already down, but another server down message received.");
        }
 
        return stat;
@@ -1619,7 +1433,6 @@ virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state)
 static int __init
 virthba_parse_line(char *str)
 {
-       DBGINF("In virthba_parse_line %s\n", str);
        return 1;
 }
 
@@ -1629,14 +1442,13 @@ virthba_parse_options(char *line)
        char *next = line;
 
        POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-       if (line == NULL || !*line)
+       if (!line || !*line)
                return;
-       while ((line = next) != NULL) {
+       while ((line = next)) {
                next = strchr(line, ' ');
-               if (next != NULL)
+               if (next)
                        *next++ = 0;
-               if (!virthba_parse_line(line))
-                       DBGINF("Unknown option '%s'\n", line);
+               virthba_parse_line(line);
        }
 
        POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
@@ -1651,14 +1463,11 @@ virthba_mod_init(void)
        if (!unisys_spar_platform)
                return -ENODEV;
 
-       LOGINF("Entering virthba_mod_init...\n");
-
        POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        virthba_parse_options(virthba_options);
 
        error = virtpci_register_driver(&virthba_driver);
        if (error < 0) {
-               LOGERR("register ****FAILED 0x%x\n", error);
                POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error,
                                 POSTCODE_SEVERITY_ERR);
        } else {
@@ -1681,8 +1490,7 @@ virthba_mod_init(void)
                /* Initialize the serverdown workqueue */
                virthba_serverdown_workqueue =
                    create_singlethread_workqueue("virthba_serverdown");
-               if (virthba_serverdown_workqueue == NULL) {
-                       LOGERR("**** FAILED virthba_serverdown_workqueue creation\n");
+               if (!virthba_serverdown_workqueue) {
                        POSTCODE_LINUX_2(VHBA_CREATE_FAILURE_PC,
                                         POSTCODE_SEVERITY_ERR);
                        error = -1;
@@ -1690,7 +1498,6 @@ virthba_mod_init(void)
        }
 
        POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
-       LOGINF("Leaving virthba_mod_init\n");
        return error;
 }
 
@@ -1740,8 +1547,6 @@ static DEVICE_ATTRIBUTE *virthba_shost_attrs[] = {
 static void __exit
 virthba_mod_exit(void)
 {
-       LOGINF("entering virthba_mod_exit...\n");
-
        virtpci_unregister_driver(&virthba_driver);
        /* unregister is going to call virthba_remove */
        /* destroy serverdown completion workqueue */
@@ -1751,7 +1556,6 @@ virthba_mod_exit(void)
        }
 
        debugfs_remove_recursive(virthba_debugfs_dir);
-       LOGINF("Leaving virthba_mod_exit\n");
 }
 
 /* specify function to be run at module insertion time */
index e59efcbc4d3b6b9b22d78d81b73198c216e36b36..6d19482ce11badcc7b2da0788869736ed16578b1 100644 (file)
@@ -4,7 +4,7 @@
 
 config UNISYS_VIRTPCI
        tristate "Unisys virtpci driver"
-       depends on UNISYSSPAR && UNISYS_UISLIB
+       select UNISYS_UISLIB
        ---help---
        If you say Y here, you will enable the Unisys virtpci driver.
 
index 8fdfd6f3605f0b1bcdfccc7fe8df607bec7a577f..d5ad01783c07214aff8f35b8f4745f78137f58f2 100644 (file)
@@ -21,7 +21,6 @@
 #ifdef CONFIG_MODVERSIONS
 #include <config/modversions.h>
 #endif
-#include "uniklog.h"
 #include "diagnostics/appos_subsystems.h"
 #include "uisutils.h"
 #include "vbuschannel.h"
@@ -187,13 +186,11 @@ static int write_vbus_chp_info(struct spar_vbus_channel_protocol *chan,
 {
        int off;
 
-       if (!chan) {
-               LOGERR("vbus channel not present");
+       if (!chan)
                return -1;
-       }
+
        off = sizeof(struct channel_header) + chan->hdr_info.chp_info_offset;
        if (chan->hdr_info.chp_info_offset == 0) {
-               LOGERR("vbus channel not used, because chp_info_offset == 0");
                return -1;
        }
        memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
@@ -206,15 +203,12 @@ static int write_vbus_bus_info(struct spar_vbus_channel_protocol *chan,
 {
        int off;
 
-       if (!chan) {
-               LOGERR("vbus channel not present");
+       if (!chan)
                return -1;
-       }
+
        off = sizeof(struct channel_header) + chan->hdr_info.bus_info_offset;
-       if (chan->hdr_info.bus_info_offset == 0) {
-               LOGERR("vbus channel not used, because bus_info_offset == 0");
+       if (chan->hdr_info.bus_info_offset == 0)
                return -1;
-       }
        memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
        return 0;
 }
@@ -228,18 +222,16 @@ write_vbus_dev_info(struct spar_vbus_channel_protocol *chan,
 {
        int off;
 
-       if (!chan) {
-               LOGERR("vbus channel not present");
+       if (!chan)
                return -1;
-       }
+
        off =
            (sizeof(struct channel_header) +
             chan->hdr_info.dev_info_offset) +
            (chan->hdr_info.device_info_struct_bytes * devix);
-       if (chan->hdr_info.dev_info_offset == 0) {
-               LOGERR("vbus channel not used, because dev_info_offset == 0");
+       if (chan->hdr_info.dev_info_offset == 0)
                return -1;
-       }
+
        memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
        return 0;
 }
@@ -271,7 +263,6 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
         */
        ret = device_register(vbus);
        if (ret) {
-               LOGERR("device_register FAILED:%d\n", ret);
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
@@ -279,8 +270,6 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
                            &chipset_driver_info);
        write_vbus_bus_info(vbus->platform_data /* chanptr */,
                            &bus_driver_info);
-       LOGINF("Added vbus %d; device %s created successfully\n",
-              addparams->bus_no, BUS_ID(vbus));
        POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 1;
 }
@@ -312,7 +301,6 @@ static int add_vhba(struct add_virt_guestpart *addparams)
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!WAIT_FOR_IO_CHANNEL
            ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
-               LOGERR("Timed out.  Channel not ready\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
@@ -323,19 +311,11 @@ static int add_vhba(struct add_virt_guestpart *addparams)
        sprintf(busid, "vbus%d", addparams->bus_no);
        vbus = bus_find_device(&virtpci_bus_type, NULL,
                               (void *)busid, match_busid);
-       if (!vbus) {
-               LOGERR("**** FAILED to find vbus %s\n", busid);
+       if (!vbus)
                return 0;
-       }
 
-       LOGINF("Adding vhba wwnn:%x:%x config:%d-%d-%d-%d chanptr:%p\n",
-              scsi.wwnn.wwnn1, scsi.wwnn.wwnn2,
-              scsi.max.max_channel, scsi.max.max_id, scsi.max.max_lun,
-              scsi.max.cmd_per_lun, addparams->chanptr);
        i = virtpci_device_add(vbus, VIRTHBA_TYPE, addparams, &scsi, NULL);
        if (i) {
-               LOGINF("Added vhba wwnn:%x:%x chanptr:%p\n", scsi.wwnn.wwnn1,
-                      scsi.wwnn.wwnn2, addparams->chanptr);
                POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i,
                                 POSTCODE_SEVERITY_INFO);
        }
@@ -375,7 +355,6 @@ add_vnic(struct add_virt_guestpart *addparams)
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (!WAIT_FOR_IO_CHANNEL
            ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
-               LOGERR("Timed out, channel not ready\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
@@ -386,20 +365,11 @@ add_vnic(struct add_virt_guestpart *addparams)
        sprintf(busid, "vbus%d", addparams->bus_no);
        vbus = bus_find_device(&virtpci_bus_type, NULL,
                               (void *)busid, match_busid);
-       if (!vbus) {
-               LOGERR("**** FAILED to find vbus %s\n", busid);
+       if (!vbus)
                return 0;
-       }
 
-       LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d mtu:%d chanptr:%p%pUL\n",
-              net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-              net.mac_addr[3], net.mac_addr[4], net.mac_addr[5],
-              net.num_rcv_bufs, net.mtu, addparams->chanptr, &net.zone_uuid);
        i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net);
        if (i) {
-               LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                      net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-                      net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
                POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i,
                                 POSTCODE_SEVERITY_INFO);
                return 1;
@@ -420,34 +390,24 @@ delete_vbus(struct del_vbus_guestpart *delparams)
        sprintf(busid, "vbus%d", delparams->bus_no);
        vbus = bus_find_device(&virtpci_bus_type, NULL,
                               (void *)busid, match_busid);
-       if (!vbus) {
-               LOGERR("**** FAILED to find vbus %s\n", busid);
+       if (!vbus)
                return 0;
-       }
 
        /* ensure that bus has no devices? -- TBD */
-       LOGINF("Deleting %s\n", BUS_ID(vbus));
-       if (delete_vbus_device(vbus, NULL))
-               return 0;       /* failure */
-       LOGINF("Deleted vbus %d\n", delparams->bus_no);
        return 1;
 }
 
 static int
 delete_vbus_device(struct device *vbus, void *data)
 {
-       int checkforroot = (data != NULL);
        struct device *dev = &virtpci_rootbus_device;
 
-       if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(dev))) {
+       if ((data) && match_busid(vbus, (void *)BUS_ID(dev))) {
                /* skip it - don't delete root bus */
-               LOGINF("skipping root bus\n");
                return 0;       /* pretend no error */
        }
-       LOGINF("Calling unregister for %s\n", BUS_ID(vbus));
        device_unregister(vbus);
        kfree(vbus);
-       LOGINF("VBus unregister and freed\n");
        return 0;               /* no error */
 }
 
@@ -461,12 +421,8 @@ static int pause_vhba(struct pause_virt_guestpart *pauseparams)
 
        GET_SCSIADAPINFO_FROM_CHANPTR(pauseparams->chanptr);
 
-       LOGINF("Pausing vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2);
        i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTHBA_TYPE,
                                      &scsi.wwnn, NULL);
-       if (i)
-               LOGINF("Paused vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1,
-                      scsi.wwnn.wwnn2);
        return i;
 }
 
@@ -480,16 +436,8 @@ static int pause_vnic(struct pause_virt_guestpart *pauseparams)
 
        GET_NETADAPINFO_FROM_CHANPTR(pauseparams->chanptr);
 
-       LOGINF("Pausing vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-              net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-              net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
        i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTNIC_TYPE,
                                      NULL, net.mac_addr);
-       if (i) {
-               LOGINF(" Paused vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                      net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-                      net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
-       }
        return i;
 }
 
@@ -503,12 +451,8 @@ static int resume_vhba(struct resume_virt_guestpart *resumeparams)
 
        GET_SCSIADAPINFO_FROM_CHANPTR(resumeparams->chanptr);
 
-       LOGINF("Resuming vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2);
        i = virtpci_device_serverup(NULL /*no parent bus */, VIRTHBA_TYPE,
                                    &scsi.wwnn, NULL);
-       if (i)
-               LOGINF("Resumed vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1,
-                      scsi.wwnn.wwnn2);
        return i;
 }
 
@@ -523,16 +467,8 @@ resume_vnic(struct resume_virt_guestpart *resumeparams)
 
        GET_NETADAPINFO_FROM_CHANPTR(resumeparams->chanptr);
 
-       LOGINF("Resuming vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-              net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-              net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
        i = virtpci_device_serverup(NULL /*no parent bus */, VIRTNIC_TYPE,
                                    NULL, net.mac_addr);
-       if (i) {
-               LOGINF(" Resumed vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                      net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-                      net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
-       }
        return i;
 }
 
@@ -546,12 +482,9 @@ static int delete_vhba(struct del_virt_guestpart *delparams)
 
        GET_SCSIADAPINFO_FROM_CHANPTR(delparams->chanptr);
 
-       LOGINF("Deleting vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1, scsi.wwnn.wwnn2);
        i = virtpci_device_del(NULL /*no parent bus */, VIRTHBA_TYPE,
                               &scsi.wwnn, NULL);
        if (i) {
-               LOGINF("Deleted vhba wwnn:%x:%x\n", scsi.wwnn.wwnn1,
-                      scsi.wwnn.wwnn2);
                return 1;
        }
        return 0;
@@ -567,23 +500,13 @@ static int delete_vnic(struct del_virt_guestpart *delparams)
 
        GET_NETADAPINFO_FROM_CHANPTR(delparams->chanptr);
 
-       LOGINF("Deleting vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-              net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-              net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
        i = virtpci_device_del(NULL /*no parent bus */, VIRTNIC_TYPE, NULL,
                               net.mac_addr);
-       if (i) {
-               LOGINF("Deleted vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
-                      net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
-                      net.mac_addr[3], net.mac_addr[4], net.mac_addr[5]);
-       }
        return i;
 }
 
 #define DELETE_ONE_VPCIDEV(vpcidev) { \
-       LOGINF("calling device_unregister:%p\n", &vpcidev->generic_dev); \
        device_unregister(&vpcidev->generic_dev); \
-       LOGINF("Deleted %p\n", vpcidev); \
        kfree(vpcidev); \
 }
 
@@ -610,12 +533,10 @@ static void delete_all(void)
                tmpvpcidev = nextvpcidev;
                count++;
        }
-       LOGINF("Deleted %d vhbas/vnics.\n", count);
 
        /* now delete each vbus */
-       if (bus_for_each_dev
-           (&virtpci_bus_type, NULL, (void *)1, delete_vbus_device))
-               LOGERR("delete of all vbus failed\n");
+       bus_for_each_dev(&virtpci_bus_type, NULL, (void *)1,
+                        delete_vbus_device);
 }
 
 /* deletes all vnics or vhbas
@@ -632,24 +553,14 @@ static int delete_all_virt(enum virtpci_dev_type devtype,
        sprintf(busid, "vbus%d", delparams->bus_no);
        vbus = bus_find_device(&virtpci_bus_type, NULL,
                               (void *)busid, match_busid);
-       if (!vbus) {
-               LOGERR("**** FAILED to find vbus %s\n", busid);
+       if (!vbus)
                return 0;
-       }
 
-       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
-               LOGERR("**** FAILED to delete all devices; devtype:%d not vhba:%d or vnic:%d\n",
-                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
                return 0;
-       }
 
-       LOGINF("Deleting all %s in vbus %s\n",
-              devtype == VIRTHBA_TYPE ? "vhbas" : "vnics", busid);
        /* delete all vhbas/vnics */
        i = virtpci_device_del(vbus, devtype, NULL, NULL);
-       if (i > 0)
-               LOGINF("Deleted %d %s\n", i,
-                      devtype == VIRTHBA_TYPE ? "vhbas" : "vnics");
        return 1;
 }
 
@@ -684,7 +595,6 @@ static int virtpci_ctrlchan_func(struct guest_msgs *msg)
        case GUEST_RESUME_VNIC:
                return resume_vnic(&msg->resume_vnic);
        default:
-               LOGERR("invalid message type %d.\n", msg->msgtype);
                return 0;
        }
 }
@@ -708,9 +618,6 @@ virtpci_match_device(const struct pci_device_id *ids,
                     const struct virtpci_dev *dev)
 {
        while (ids->vendor || ids->subvendor || ids->class_mask) {
-               DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x dev->device:%x\n",
-                      ids->vendor, dev->vendor, ids->device, dev->device);
-
                if ((ids->vendor == dev->vendor) &&
                    (ids->device == dev->device))
                        return ids;
@@ -731,20 +638,15 @@ static int virtpci_bus_match(struct device *dev, struct device_driver *drv)
        struct virtpci_driver *virtpcidrv = driver_to_virtpci_driver(drv);
        int match = 0;
 
-       DBGINF("In virtpci_bus_match dev->bus_id:%s drv->name:%s\n",
-              dev->bus_id, drv->name);
-
        /* check ids list for a match */
        if (virtpci_match_device(virtpcidrv->id_table, virtpcidev))
                match = 1;
 
-       DBGINF("returning match:%d\n", match);
        return match;           /* 0 - no match; 1 - yes it matches */
 }
 
 static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
-       DBGINF("In virtpci_hotplug\n");
        /* add variables to the environment prior to the generation of
         * hotplug events to user space
         */
@@ -766,24 +668,19 @@ static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type,
        struct ultra_vbus_deviceinfo dev_info;
        const char *stype;
 
-       if (!dev) {
-               LOGERR("%s dev is NULL", __func__);
+       if (!dev)
                return;
-       }
-       if (!virtpcidrv) {
-               LOGERR("%s driver is NULL", __func__);
+       if (!virtpcidrv)
                return;
-       }
+
        vbus = dev->parent;
-       if (!vbus) {
-               LOGERR("%s dev has no parent bus", __func__);
+       if (!vbus)
                return;
-       }
+
        chan = vbus->platform_data;
-       if (!chan) {
-               LOGERR("%s dev bus has no channel", __func__);
+       if (!chan)
                return;
-       }
+
        switch (dev_type) {
        case PCI_DEVICE_ID_VIRTHBA:
                stype = "vHBA";
@@ -820,8 +717,6 @@ static int virtpci_device_probe(struct device *dev)
        const struct pci_device_id *id;
        int error = 0;
 
-       LOGINF("In virtpci_device_probe dev:%p virtpcidev:%p virtpcidrv:%p\n",
-              dev, virtpcidev, virtpcidrv);    /* VERBOSE/DEBUG ? */
        POSTCODE_LINUX_2(VPCI_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        /* static match and static probe vs dynamic match & dynamic
         * probe - do we care?.
@@ -866,9 +761,6 @@ static int virtpci_device_remove(struct device *dev_)
        struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev_);
        struct virtpci_driver *virtpcidrv = virtpcidev->mydriver;
 
-       LOGINF("In virtpci_device_remove bus_id:%s dev_:%p virtpcidev:%p dev->driver:%p drivername:%s\n",
-              BUS_ID(dev_), dev_, virtpcidev, dev_->driver,
-              dev_->driver->name);     /* VERBOSE/DEBUG */
        if (virtpcidrv) {
                /* TEMP: assuming we have only one such driver for now */
                if (virtpcidrv->remove)
@@ -876,10 +768,7 @@ static int virtpci_device_remove(struct device *dev_)
                virtpcidev->mydriver = NULL;
        }
 
-       DBGINF("calling putdevice\n");
        put_device(dev_);
-
-       DBGINF("Leaving\n");
        return 0;
 }
 
@@ -889,11 +778,6 @@ static int virtpci_device_remove(struct device *dev_)
 
 static void virtpci_bus_release(struct device *dev)
 {
-       /* this function is called when the last reference to the
-        * device is removed
-        */
-       DBGINF("In virtpci_bus_release\n");
-       /* what else is supposed to happen here? */
 }
 
 /*****************************************************/
@@ -915,14 +799,9 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
        struct spar_io_channel_protocol __iomem *io_chan = NULL;
        struct device *dev;
 
-       LOGINF("virtpci_device_add parentbus:%p chanptr:%p\n", parentbus,
-              addparams->chanptr);
-
        POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
 
        if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
-               LOGERR("**** FAILED to add device; devtype:%d not vhba:%d or vnic:%d\n",
-                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
                POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype,
                                 POSTCODE_SEVERITY_ERR);
                return 0;
@@ -930,8 +809,7 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
 
        /* add a Virtual Device */
        virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC);
-       if (virtpcidev == NULL) {
-               LOGERR("can't add device - malloc FALLED\n");
+       if (!virtpcidev) {
                POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
@@ -993,7 +871,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
                 */
                write_unlock_irqrestore(&vpcidev_list_lock, flags);
                kfree(virtpcidev);
-               LOGERR("**** FAILED vhba/vnic already exists in the list\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                return 0;
        }
@@ -1024,8 +901,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
        * list. Otherwise, a device_unregister from this function can
        * cause a "scheduling while atomic".
        */
-       DBGINF("registering device:%p with bus_id:%s\n",
-              &virtpcidev->generic_dev, virtpcidev->generic_dev.bus_id);
        ret = device_register(&virtpcidev->generic_dev);
        /* NOTE: THIS IS CALLING HOTPLUG virtpci_hotplug!!!
         * This call to device_register results in virtpci_bus_match
@@ -1037,7 +912,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
         * virtpci_device_probe is successful
         */
        if (ret) {
-               LOGERR("device_register returned %d\n", ret);
                dev = &virtpcidev->generic_dev;
                SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
                                               BUS_ID(dev),
@@ -1060,10 +934,6 @@ static int virtpci_device_add(struct device *parentbus, int devtype,
                return 0;
        }
 
-       LOGINF("Added %s:%d:%d &virtpcidev->generic_dev:%p\n",
-              (devtype == VIRTHBA_TYPE) ? "virthba" : "virtnic",
-              addparams->bus_no, addparams->device_no,
-              &virtpcidev->generic_dev);
        POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 1;
 }
@@ -1080,11 +950,8 @@ static int virtpci_device_serverdown(struct device *parentbus,
        unsigned long flags;
        int rc = 0;
 
-       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
-               LOGERR("**** FAILED to pause device; devtype:%d not vhba:%d or vnic:%d\n",
-                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
                return 0;
-       }
 
        /* find the vhba or vnic in virtpci device list */
        write_lock_irqsave(&vpcidev_list_lock, flags);
@@ -1119,10 +986,8 @@ static int virtpci_device_serverdown(struct device *parentbus,
        }
        write_unlock_irqrestore(&vpcidev_list_lock, flags);
 
-       if (!found) {
-               LOGERR("**** FAILED to find vhba/vnic in the list\n");
+       if (!found)
                return 0;
-       }
 
        return rc;
 }
@@ -1139,11 +1004,9 @@ static int virtpci_device_serverup(struct device *parentbus,
        unsigned long flags;
        int rc = 0;
 
-       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
-               LOGERR("**** FAILED to resume device; devtype:%d not vhba:%d or vnic:%d\n",
-                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
                return 0;
-       }
+
 
        /* find the vhba or vnic in virtpci device list */
        write_lock_irqsave(&vpcidev_list_lock, flags);
@@ -1187,10 +1050,8 @@ static int virtpci_device_serverup(struct device *parentbus,
 
        write_unlock_irqrestore(&vpcidev_list_lock, flags);
 
-       if (!found) {
-               LOGERR("**** FAILED to find vhba/vnic in the list\n");
+       if (!found)
                return 0;
-       }
 
        return rc;
 }
@@ -1209,17 +1070,14 @@ static int virtpci_device_del(struct device *parentbus,
        continue; \
 }
 
-       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
-               LOGERR("**** FAILED to delete device; devtype:%d not vhba:%d or vnic:%d\n",
-                      devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+       if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
                return 0;
-       }
 
        /* see if we are to delete all - NOTE: all implies we have a
         * valid parentbus
         */
-       all = ((devtype == VIRTHBA_TYPE) && (wwnn == NULL)) ||
-           ((devtype == VIRTNIC_TYPE) && (macaddr == NULL));
+       all = ((devtype == VIRTHBA_TYPE) && (!wwnn)) ||
+           ((devtype == VIRTNIC_TYPE) && (!macaddr));
 
        /* find all the vhba or vnic or both in virtpci device list
        * keep list of ones we are deleting so we can call
@@ -1280,10 +1138,8 @@ static int virtpci_device_del(struct device *parentbus,
        }
        write_unlock_irqrestore(&vpcidev_list_lock, flags);
 
-       if (!all && (count == 0)) {
-               LOGERR("**** FAILED to find vhba/vnic in the list\n");
+       if (!all && (count == 0))
                return 0;
-       }
 
        /* now delete each one from delete list */
        while (dellist) {
@@ -1303,7 +1159,6 @@ static void virtpci_device_release(struct device *dev_)
        /* this function is called when the last reference to the
         * device is removed
         */
-       LOGINF("In virtpci_device_release:%p - NOT YET IMPLEMENTED\n", dev_);
 }
 
 /*****************************************************/
@@ -1324,8 +1179,6 @@ static ssize_t virtpci_driver_attr_show(struct kobject *kobj,
        struct driver_private *dprivate = to_driver(kobj);
        struct device_driver *driver = dprivate->driver;
 
-       DBGINF("In virtpci_driver_attr_show driver->name:%s\n", driver->name);
-
        if (dattr->show)
                ret = dattr->show(driver, buf);
 
@@ -1342,8 +1195,6 @@ static ssize_t virtpci_driver_attr_store(struct kobject *kobj,
        struct driver_private *dprivate = to_driver(kobj);
        struct device_driver *driver = dprivate->driver;
 
-       DBGINF("In virtpci_driver_attr_store driver->name:%s\n", driver->name);
-
        if (dattr->store)
                ret = dattr->store(driver, buf, count);
 
@@ -1355,12 +1206,8 @@ int virtpci_register_driver(struct virtpci_driver *drv)
 {
        int result = 0;
 
-       DBGINF("In virtpci_register_driver\n");
-
-       if (drv->id_table == NULL) {
-               LOGERR("id_table missing\n");
+       if (!drv->id_table)
                return 1;
-       }
        /* initialize core driver fields needed to call driver_register */
        drv->core_driver.name = drv->name;      /* name of driver in sysfs */
        drv->core_driver.bus = &virtpci_bus_type;       /* type of bus this
@@ -1389,7 +1236,6 @@ EXPORT_SYMBOL_GPL(virtpci_register_driver);
 
 void virtpci_unregister_driver(struct virtpci_driver *drv)
 {
-       DBGINF("In virtpci_unregister_driver drv:%p\n", drv);
        driver_unregister(&drv->core_driver);
        /* driver_unregister calls bus_remove_driver
         * bus_remove_driver calls device_detach
@@ -1399,7 +1245,6 @@ void virtpci_unregister_driver(struct virtpci_driver *drv)
         * virtpci_device_remove
         * virtpci_device_remove calls virthba_remove
         */
-       DBGINF("Leaving\n");
 }
 EXPORT_SYMBOL_GPL(virtpci_unregister_driver);
 
@@ -1442,9 +1287,8 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
        printparam.str_pos = &str_pos;
        printparam.buf = vbuf;
        printparam.len = &len;
-       if (bus_for_each_dev(&virtpci_bus_type, NULL,
-                            (void *)&printparam, print_vbus))
-               LOGERR("Failed to find bus\n");
+       bus_for_each_dev(&virtpci_bus_type, NULL, (void *)&printparam,
+                        print_vbus);
 
        str_pos += scnprintf(vbuf + str_pos, len - str_pos,
                        "\n Virtual PCI devices\n");
@@ -1464,15 +1308,10 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
                                        tmpvpcidev->scsi.max.cmd_per_lun);
                } else {
                        str_pos += scnprintf(vbuf + str_pos, len - str_pos,
-                                       "[%d:%d] VNic:%02x:%02x:%02x:%02x:%02x:%02x num_rcv_bufs:%d mtu:%d",
+                                       "[%d:%d] VNic:%pM num_rcv_bufs:%d mtu:%d",
                                        tmpvpcidev->bus_no,
                                        tmpvpcidev->device_no,
-                                       tmpvpcidev->net.mac_addr[0],
-                                       tmpvpcidev->net.mac_addr[1],
-                                       tmpvpcidev->net.mac_addr[2],
-                                       tmpvpcidev->net.mac_addr[3],
-                                       tmpvpcidev->net.mac_addr[4],
-                                       tmpvpcidev->net.mac_addr[5],
+                                       tmpvpcidev->net.mac_addr,
                                        tmpvpcidev->net.num_rcv_bufs,
                                        tmpvpcidev->net.mtu);
                }
@@ -1507,58 +1346,44 @@ static int __init virtpci_mod_init(void)
         * drivers directory
         */
        if (ret) {
-               LOGERR("bus_register ****FAILED:%d\n", ret);
                POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret,
                                 POSTCODE_SEVERITY_ERR);
                return ret;
        }
-       DBGINF("bus_register successful\n");
        bus_device_info_init(&bus_driver_info, "clientbus", "virtpci",
                             VERSION, NULL);
 
        /* create a root bus used to parent all the virtpci buses. */
        ret = device_register(&virtpci_rootbus_device);
        if (ret) {
-               LOGERR("device_register FAILED:%d\n", ret);
                bus_unregister(&virtpci_bus_type);
                POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret,
                                 POSTCODE_SEVERITY_ERR);
                return ret;
        }
-       DBGINF("device_register successful ret:%x\n", ret);
 
        if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func,
                                          &chipset_driver_info)) {
-               LOGERR("uisctrl_register_req_handler ****FAILED.\n");
                POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
                device_unregister(&virtpci_rootbus_device);
                bus_unregister(&virtpci_bus_type);
                return -1;
        }
 
-       LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as callback.\n",
-              (void *)&virtpci_ctrlchan_func);
        /* create debugfs directory and info file inside. */
        virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL);
        debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir,
                            NULL, &debugfs_info_fops);
-       LOGINF("Leaving\n");
        POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return 0;
 }
 
 static void __exit virtpci_mod_exit(void)
 {
-       LOGINF("virtpci_mod_exit...\n");
-
        /* unregister the callback function */
-       if (!uisctrl_register_req_handler(2, NULL, NULL))
-               LOGERR("uisctrl_register_req_handler ****FAILED.\n");
-
        device_unregister(&virtpci_rootbus_device);
        bus_unregister(&virtpci_bus_type);
        debugfs_remove_recursive(virtpci_debugfs_dir);
-       LOGINF("Leaving\n");
 }
 
 module_init(virtpci_mod_init);
index 41c3b4b997eb8039e54fa2f449434cb312ed0101..8d31bebf039abfbdda261e5e464d114867e0b3e4 100644 (file)
@@ -4,7 +4,7 @@
 
 config UNISYS_VISORCHANNEL
        tristate "Unisys visorchannel driver"
-       depends on UNISYSSPAR && UNISYS_VISORUTIL
+       select UNISYS_VISORUTIL
        ---help---
        If you say Y here, you will enable the Unisys visorchannel driver.
 
index 581ed83fe6d07afe25b49cf2e4ab827eac5e3bda..0ed8e1d8033a8d8ca6ae4a92fc3befa706183c2e 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef __VISORCHANNEL_GLOBALS_H__
 #define __VISORCHANNEL_GLOBALS_H__
 
-#include "uniklog.h"
 #include "timskmod.h"
 #include "memregion.h"
 #include "version.h"
index 0188ef866fdd8a9630cf767a8f78e834e4bc84c8..7a9a7242f75d928d982585c6f1b340ecfa7e51d4 100644 (file)
@@ -58,8 +58,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
        void *rc = NULL;
 
        p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
-       if (p == NULL) {
-               ERRDRV("allocation failed: (status=0)\n");
+       if (!p) {
                rc = NULL;
                goto cleanup;
        }
@@ -69,7 +68,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
        spin_lock_init(&p->remove_lock);
 
        /* prepare chan_hdr (abstraction to read/write channel memory) */
-       if (parent == NULL)
+       if (!parent)
                p->memregion =
                    visor_memregion_create(physaddr,
                                           sizeof(struct channel_header));
@@ -77,14 +76,12 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
                p->memregion =
                    visor_memregion_create_overlapped(parent->memregion,
                                off, sizeof(struct channel_header));
-       if (p->memregion == NULL) {
-               ERRDRV("visor_memregion_create failed failed: (status=0)\n");
+       if (!p->memregion) {
                rc = NULL;
                goto cleanup;
        }
        if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
                                 sizeof(struct channel_header)) < 0) {
-               ERRDRV("visor_memregion_read failed: (status=0)\n");
                rc = NULL;
                goto cleanup;
        }
@@ -95,7 +92,6 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
                /* we had better be a CLIENT of this channel */
                guid = p->chan_hdr.chtype;
        if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
-               ERRDRV("visor_memregion_resize failed: (status=0)\n");
                rc = NULL;
                goto cleanup;
        }
@@ -105,8 +101,8 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
        rc = p;
 cleanup:
 
-       if (rc == NULL) {
-               if (p != NULL) {
+       if (!rc) {
+               if (!p) {
                        visorchannel_destroy(p);
                        p = NULL;
                }
@@ -154,9 +150,9 @@ EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
 void
 visorchannel_destroy(struct visorchannel *channel)
 {
-       if (channel == NULL)
+       if (!channel)
                return;
-       if (channel->memregion != NULL) {
+       if (channel->memregion) {
                visor_memregion_destroy(channel->memregion);
                channel->memregion = NULL;
        }
@@ -256,10 +252,9 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
        int written = 0;
        u8 *buf = vmalloc(bufsize);
 
-       if (buf == NULL) {
-               ERRDRV("%s failed memory allocation", __func__);
+       if (!buf)
                goto cleanup;
-       }
+
        memset(buf, ch, bufsize);
        while (nbytes > 0) {
                ulong thisbytes = bufsize;
@@ -279,7 +274,7 @@ visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
        rc = 0;
 
 cleanup:
-       if (buf != NULL) {
+       if (buf) {
                vfree(buf);
                buf = NULL;
        }
@@ -324,10 +319,8 @@ sig_read_header(struct visorchannel *channel, u32 queue,
 {
        BOOL rc = FALSE;
 
-       if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header)) {
-               ERRDRV("oChannelSpace too small: (status=%d)\n", rc);
+       if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
                goto cleanup;
-       }
 
        /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
 
@@ -335,10 +328,6 @@ sig_read_header(struct visorchannel *channel, u32 queue,
                                 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
                                 sig_hdr,
                                 sizeof(struct signal_queue_header)) < 0) {
-               ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d",
-                      queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue));
-               ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n",
-                      rc);
                goto cleanup;
        }
        rc = TRUE;
@@ -358,15 +347,11 @@ sig_do_data(struct visorchannel *channel, u32 queue,
                if (visor_memregion_write(channel->memregion,
                                          signal_data_offset,
                                          data, sig_hdr->signal_size) < 0) {
-                       ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n",
-                              rc);
                        goto cleanup;
                }
        } else {
                if (visor_memregion_read(channel->memregion, signal_data_offset,
                                         data, sig_hdr->signal_size) < 0) {
-                       ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n",
-                              rc);
                        goto cleanup;
                }
        }
@@ -404,8 +389,6 @@ safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
                punsafe_sqh->head = *phead;
                punsafe_sqh->tail = *ptail;
 
-               ERRDRV("safe_sig_queue_validate: head = 0x%x, tail = 0x%x, MaxSlots = 0x%x",
-                      *phead, *ptail, psafe_sqh->max_slots);
                return 0;
        }
        return 1;
@@ -416,15 +399,13 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
 {
        struct signal_queue_header sig_hdr;
 
-       if (!sig_read_header(channel, queue, &sig_hdr)) {
+       if (!sig_read_header(channel, queue, &sig_hdr))
                return FALSE;
-       }
        if (sig_hdr.head == sig_hdr.tail)
                return FALSE;   /* no signals to remove */
 
        sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
        if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) {
-               ERRDRV("sig_read_data failed\n");
                return FALSE;
        }
        sig_hdr.num_received++;
@@ -433,14 +414,10 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
         * update host memory.
         */
        mb(); /* required for channel synch */
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail)) {
-               ERRDRV("visor_memregion_write of Tail failed\n");
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
                return FALSE;
-       }
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received)) {
-               ERRDRV("visor_memregion_write of NumSignalsReceived failed\n");
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
                return FALSE;
-       }
        return TRUE;
 }
 
@@ -466,35 +443,34 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
 {
        struct signal_queue_header sig_hdr;
 
-       if (!sig_read_header(channel, queue, &sig_hdr)) {
+       if (!sig_read_header(channel, queue, &sig_hdr))
                return FALSE;
-       }
 
        sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
        if (sig_hdr.head == sig_hdr.tail) {
                sig_hdr.num_overflows++;
-               if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_overflows))
-                       ERRDRV("visor_memregion_write of NumOverflows failed\n");
-
+               visor_memregion_write(channel->memregion,
+                                     SIG_QUEUE_OFFSET(&channel->chan_hdr,
+                                                      queue) +
+                                     offsetof(struct signal_queue_header,
+                                              num_overflows),
+                                     &(sig_hdr.num_overflows),
+                                     sizeof(sig_hdr.num_overflows));
                return FALSE;
        }
 
-       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg)) {
-               ERRDRV("sig_write_data failed\n");
+       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
                return FALSE;
-       }
+
        sig_hdr.num_sent++;
 
        /* For each data field in SIGNAL_QUEUE_HEADER that was modified,
         * update host memory.
         */
        mb(); /* required for channel synch */
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head)) {
-               ERRDRV("visor_memregion_write of Head failed\n");
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
                return FALSE;
-       }
        if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) {
-               ERRDRV("visor_memregion_write of NumSignalsSent failed\n");
                return FALSE;
        }
 
@@ -584,15 +560,12 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
        int i = 0;
        int errcode = 0;
 
-       if (channel == NULL) {
-               ERRDRV("%s no channel", __func__);
+       if (!channel)
                return;
-       }
        memregion = channel->memregion;
-       if (memregion == NULL) {
-               ERRDRV("%s no memregion", __func__);
+       if (!memregion)
                return;
-       }
+
        addr = visor_memregion_get_physaddr(memregion);
        nbytes_region = visor_memregion_get_nbytes(memregion);
        errcode = visorchannel_read(channel, off,
@@ -672,11 +645,8 @@ visorchannel_dump_section(struct visorchannel *chan, char *s,
                goto fmt_failed;
 
        errcode = visorchannel_read(chan, off, buf, len);
-       if (errcode < 0) {
-               ERRDRV("%s failed to read %s from channel errcode=%d",
-                      s, __func__, errcode);
+       if (errcode < 0)
                goto read_failed;
-       }
        seq_printf(seq, "channel %s:\n", s);
        tbuf = buf;
        while (len > 0) {
index f4be2e62c97dbb0d2387042c7ff5de8151847a38..787d4774b1990fac44bbc1362f68a23b775ab00c 100644 (file)
@@ -32,14 +32,12 @@ visorchannel_init(void)
        if (!unisys_spar_platform)
                return -ENODEV;
 
-       INFODRV("driver version %s loaded", VERSION);
        return 0;
 }
 
 static void
 visorchannel_exit(void)
 {
-       INFODRV("driver unloaded");
 }
 
 module_init(visorchannel_init);
index e86836f84243c7265cca27c2ff191ce7f5a43ce0..b03bfc5c3043f1cf15fd8b5094b1150e1fca769e 100644 (file)
@@ -4,7 +4,8 @@
 
 config UNISYS_VISORCHIPSET
        tristate "Unisys visorchipset driver"
-       depends on UNISYSSPAR && UNISYS_VISORUTIL && UNISYS_VISORCHANNEL && HAS_IOMEM
+       select UNISYS_VISORUTIL
+       select UNISYS_VISORCHANNEL
        ---help---
        If you say Y here, you will enable the Unisys visorchipset driver.
 
index e51fd4e3fa2ddfb89364fe9a6ffafa078205a57e..9ca7f1eb1e7e31794ce04ec01507ff67a47ede5b 100644 (file)
@@ -36,7 +36,8 @@ static BOOL registered = FALSE;
 static int visorchipset_open(struct inode *inode, struct file *file);
 static int visorchipset_release(struct inode *inode, struct file *file);
 static int visorchipset_mmap(struct file *file, struct vm_area_struct *vma);
-long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+static long visorchipset_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg);
 
 static const struct file_operations visorchipset_fops = {
        .owner = THIS_MODULE,
@@ -59,29 +60,18 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
        file_cdev.owner = THIS_MODULE;
        if (MAJOR(majordev) == 0) {
                /* dynamic major device number registration required */
-               if (alloc_chrdev_region(&majordev, 0, 1, MYDRVNAME) < 0) {
-                       ERRDRV("Unable to allocate+register char device %s",
-                              MYDRVNAME);
+               if (alloc_chrdev_region(&majordev, 0, 1, MYDRVNAME) < 0)
                        return -1;
-               }
                registered = TRUE;
-               INFODRV("New major number %d registered\n", MAJOR(majordev));
        } else {
                /* static major device number registration required */
-               if (register_chrdev_region(majordev, 1, MYDRVNAME) < 0) {
-                       ERRDRV("Unable to register char device %s", MYDRVNAME);
+               if (register_chrdev_region(majordev, 1, MYDRVNAME) < 0)
                        return -1;
-               }
                registered = TRUE;
-               INFODRV("Static major number %d registered\n", MAJOR(majordev));
        }
        rc = cdev_add(&file_cdev, MKDEV(MAJOR(majordev), 0), 1);
-       if (rc  < 0) {
-               ERRDRV("failed to create char device: (status=%d)\n", rc);
+       if (rc  < 0)
                return -1;
-       }
-       INFODRV("Registered char device for %s (major=%d)",
-               MYDRVNAME, MAJOR(majordev));
        return 0;
 }
 
@@ -105,7 +95,6 @@ visorchipset_open(struct inode *inode, struct file *file)
 {
        unsigned minor_number = iminor(inode);
 
-       DEBUGDRV("%s", __func__);
        if (minor_number != 0)
                return -ENODEV;
        file->private_data = NULL;
@@ -115,7 +104,6 @@ visorchipset_open(struct inode *inode, struct file *file)
 static int
 visorchipset_release(struct inode *inode, struct file *file)
 {
-       DEBUGDRV("%s", __func__);
        return 0;
 }
 
@@ -127,16 +115,13 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
        GUEST_PHYSICAL_ADDRESS addr = 0;
 
        /* sv_enable_dfp(); */
-       DEBUGDRV("%s", __func__);
-       if (offset & (PAGE_SIZE - 1)) {
-               ERRDRV("%s virtual address NOT page-aligned!", __func__);
+       if (offset & (PAGE_SIZE - 1))
                return -ENXIO;  /* need aligned offsets */
-       }
+
        switch (offset) {
        case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
                vma->vm_flags |= VM_IO;
                if (*file_controlvm_channel == NULL) {
-                       ERRDRV("%s no controlvm channel yet", __func__);
                        return -ENXIO;
                }
                visorchannel_read(*file_controlvm_channel,
@@ -144,33 +129,29 @@ visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
                                 gp_control_channel),
                        &addr, sizeof(addr));
                if (addr == 0) {
-                       ERRDRV("%s control channel address is 0", __func__);
                        return -ENXIO;
                }
                physaddr = (ulong)addr;
-               DEBUGDRV("mapping physical address = 0x%lx", physaddr);
                if (remap_pfn_range(vma, vma->vm_start,
                                    physaddr >> PAGE_SHIFT,
                                    vma->vm_end - vma->vm_start,
                                    /*pgprot_noncached */
                                    (vma->vm_page_prot))) {
-                       ERRDRV("%s remap_pfn_range failed", __func__);
                        return -EAGAIN;
                }
                break;
        default:
                return -ENOSYS;
        }
-       DEBUGDRV("%s success!", __func__);
        return 0;
 }
 
-long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+static long visorchipset_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg)
 {
        s64 adjustment;
        s64 vrtc_offset;
 
-       DBGINF("entered visorchipset_ioctl, cmd=%d", cmd);
        switch (cmd) {
        case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
                /* get the physical rtc offset */
@@ -179,19 +160,14 @@ long visorchipset_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                    ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) {
                        return -EFAULT;
                }
-               DBGINF("insde visorchipset_ioctl, cmd=%d, vrtc_offset=%lld",
-                      cmd, vrtc_offset);
                return SUCCESS;
        case VMCALL_UPDATE_PHYSICAL_TIME:
                if (copy_from_user
                    (&adjustment, (void __user *)arg, sizeof(adjustment))) {
                        return -EFAULT;
                }
-               DBGINF("insde visorchipset_ioctl, cmd=%d, adjustment=%lld", cmd,
-                      adjustment);
                return issue_vmcall_update_physical_time(adjustment);
        default:
-               LOGERR("visorchipset_ioctl received invalid command");
                return -EFAULT;
        }
 }
index a1d35d4bef2e45ae7ae4270cc6b3bce54c4e4e41..f76e498a36b5f00a871acca8d7df38cc372075be 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef __VISORCHIPSET_GLOBALS_H__
 #define __VISORCHIPSET_GLOBALS_H__
 
-#include "uniklog.h"
 #include "diagnostics/appos_subsystems.h"
 #include "timskmod.h"
 #include "visorchipset.h"
index 9edbd3bbd186d056d3a0a64eda166df60bd25707..f10b4439f593608293fc9f0a282bb7b687b2486f 100644 (file)
@@ -29,9 +29,9 @@
  * incoming payloads.  This serves as a throttling mechanism.
  */
 #define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
-static ulong Controlvm_Payload_Bytes_Buffered;
+static ulong controlvm_payload_bytes_buffered;
 
-struct PARSER_CONTEXT_Tag {
+struct parser_context {
        ulong allocbytes;
        ulong param_bytes;
        u8 *curr;
@@ -40,41 +40,36 @@ struct PARSER_CONTEXT_Tag {
        char data[0];
 };
 
-static PARSER_CONTEXT *
-parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
-                BOOL hasStandardPayloadHeader, BOOL *tryAgain)
+static struct parser_context *
+parser_init_guts(u64 addr, u32 bytes, BOOL local,
+                BOOL standard_payload_header, BOOL *retry)
 {
-       int allocbytes = sizeof(PARSER_CONTEXT) + bytes;
-       PARSER_CONTEXT *rc = NULL;
-       PARSER_CONTEXT *ctx = NULL;
+       int allocbytes = sizeof(struct parser_context) + bytes;
+       struct parser_context *rc = NULL;
+       struct parser_context *ctx = NULL;
        struct memregion *rgn = NULL;
        struct spar_controlvm_parameters_header *phdr = NULL;
 
-       if (tryAgain)
-               *tryAgain = FALSE;
-       if (!hasStandardPayloadHeader)
+       if (retry)
+               *retry = FALSE;
+       if (!standard_payload_header)
                /* alloc and 0 extra byte to ensure payload is
                 * '\0'-terminated
                 */
                allocbytes++;
-       if ((Controlvm_Payload_Bytes_Buffered + bytes)
+       if ((controlvm_payload_bytes_buffered + bytes)
            > MAX_CONTROLVM_PAYLOAD_BYTES) {
-               ERRDRV("%s (%s:%d) - prevented allocation of %d bytes to prevent exceeding throttling max (%d)",
-                      __func__, __FILE__, __LINE__, allocbytes,
-                      MAX_CONTROLVM_PAYLOAD_BYTES);
-               if (tryAgain)
-                       *tryAgain = TRUE;
+               if (retry)
+                       *retry = TRUE;
                rc = NULL;
-               goto Away;
+               goto cleanup;
        }
        ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
-       if (ctx == NULL) {
-               ERRDRV("%s (%s:%d) - failed to allocate %d bytes",
-                      __func__, __FILE__, __LINE__, allocbytes);
-               if (tryAgain)
-                       *tryAgain = TRUE;
+       if (!ctx) {
+               if (retry)
+                       *retry = TRUE;
                rc = NULL;
-               goto Away;
+               goto cleanup;
        }
 
        ctx->allocbytes = allocbytes;
@@ -82,15 +77,12 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
        ctx->curr = NULL;
        ctx->bytes_remaining = 0;
        ctx->byte_stream = FALSE;
-       if (isLocal) {
+       if (local) {
                void *p;
 
                if (addr > virt_to_phys(high_memory - 1)) {
-                       ERRDRV("%s - bad local address (0x%-16.16Lx for %lu)",
-                              __func__,
-                              (unsigned long long) addr, (ulong) bytes);
                        rc = NULL;
-                       goto Away;
+                       goto cleanup;
                }
                p = __va((ulong) (addr));
                memcpy(ctx->data, p, bytes);
@@ -98,54 +90,42 @@ parser_init_guts(u64 addr, u32 bytes, BOOL isLocal,
                rgn = visor_memregion_create(addr, bytes);
                if (!rgn) {
                        rc = NULL;
-                       goto Away;
+                       goto cleanup;
                }
                if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
                        rc = NULL;
-                       goto Away;
+                       goto cleanup;
                }
        }
-       if (!hasStandardPayloadHeader) {
+       if (!standard_payload_header) {
                ctx->byte_stream = TRUE;
                rc = ctx;
-               goto Away;
+               goto cleanup;
        }
        phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
        if (phdr->total_length != bytes) {
-               ERRDRV("%s - bad total length %lu (should be %lu)",
-                      __func__,
-                      (ulong) (phdr->total_length), (ulong) (bytes));
                rc = NULL;
-               goto Away;
+               goto cleanup;
        }
        if (phdr->total_length < phdr->header_length) {
-               ERRDRV("%s - total length < header length (%lu < %lu)",
-                      __func__,
-                      (ulong) (phdr->total_length),
-                      (ulong) (phdr->header_length));
                rc = NULL;
-               goto Away;
+               goto cleanup;
        }
        if (phdr->header_length <
            sizeof(struct spar_controlvm_parameters_header)) {
-               ERRDRV("%s - header is too small (%lu < %lu)",
-                      __func__,
-                      (ulong) (phdr->header_length),
-                      (ulong)(sizeof(
-                               struct spar_controlvm_parameters_header)));
                rc = NULL;
-               goto Away;
+               goto cleanup;
        }
 
        rc = ctx;
-Away:
+cleanup:
        if (rgn) {
                visor_memregion_destroy(rgn);
                rgn = NULL;
        }
-       if (rc)
-               Controlvm_Payload_Bytes_Buffered += ctx->param_bytes;
-       else {
+       if (rc) {
+               controlvm_payload_bytes_buffered += ctx->param_bytes;
+       else {
                if (ctx) {
                        parser_done(ctx);
                        ctx = NULL;
@@ -154,10 +134,10 @@ Away:
        return rc;
 }
 
-PARSER_CONTEXT *
-parser_init(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
+struct parser_context *
+parser_init(u64 addr, u32 bytes, BOOL local, BOOL *retry)
 {
-       return parser_init_guts(addr, bytes, isLocal, TRUE, tryAgain);
+       return parser_init_guts(addr, bytes, local, TRUE, retry);
 }
 
 /* Call this instead of parser_init() if the payload area consists of just
@@ -165,7 +145,7 @@ parser_init(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
  * structures.  Afterwards, you can call parser_simpleString_get() or
  * parser_byteStream_get() to obtain the data.
  */
-PARSER_CONTEXT *
+struct parser_context *
 parser_init_byteStream(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
 {
        return parser_init_guts(addr, bytes, isLocal, FALSE, tryAgain);
@@ -174,7 +154,7 @@ parser_init_byteStream(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
 /* Obtain '\0'-terminated copy of string in payload area.
  */
 char *
-parser_simpleString_get(PARSER_CONTEXT *ctx)
+parser_simpleString_get(struct parser_context *ctx)
 {
        if (!ctx->byte_stream)
                return NULL;
@@ -186,7 +166,7 @@ parser_simpleString_get(PARSER_CONTEXT *ctx)
 /* Obtain a copy of the buffer in the payload area.
  */
 void *
-parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes)
+parser_byteStream_get(struct parser_context *ctx, ulong *nbytes)
 {
        if (!ctx->byte_stream)
                return NULL;
@@ -196,29 +176,23 @@ parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes)
 }
 
 uuid_le
-parser_id_get(PARSER_CONTEXT *ctx)
+parser_id_get(struct parser_context *ctx)
 {
        struct spar_controlvm_parameters_header *phdr = NULL;
 
-       if (ctx == NULL) {
-               ERRDRV("%s (%s:%d) - no context",
-                      __func__, __FILE__, __LINE__);
+       if (ctx == NULL)
                return NULL_UUID_LE;
-       }
        phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
        return phdr->id;
 }
 
 void
-parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string)
+parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
 {
        struct spar_controlvm_parameters_header *phdr = NULL;
 
-       if (ctx == NULL) {
-               ERRDRV("%s (%s:%d) - no context",
-                      __func__, __FILE__, __LINE__);
+       if (ctx == NULL)
                goto Away;
-       }
        phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
        switch (which_string) {
        case PARSERSTRING_INITIATOR:
@@ -238,7 +212,6 @@ parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string)
                ctx->bytes_remaining = phdr->name_length;
                break;
        default:
-               ERRDRV("%s - bad which_string %d", __func__, which_string);
                break;
        }
 
@@ -247,11 +220,11 @@ Away:
 }
 
 void
-parser_done(PARSER_CONTEXT *ctx)
+parser_done(struct parser_context *ctx)
 {
        if (!ctx)
                return;
-       Controlvm_Payload_Bytes_Buffered -= ctx->param_bytes;
+       controlvm_payload_bytes_buffered -= ctx->param_bytes;
        kfree(ctx);
 }
 
@@ -290,7 +263,7 @@ string_length_no_trail(char *s, int len)
  *    parameter
  */
 void *
-parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
+parser_param_get(struct parser_context *ctx, char *nam, int namesize)
 {
        u8 *pscan, *pnam = nam;
        ulong nscan;
@@ -321,25 +294,18 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
        }
 
        while (*pscan != ':') {
-               if (namesize <= 0) {
-                       ERRDRV("%s - name too big", __func__);
+               if (namesize <= 0)
                        return NULL;
-               }
                *pnam = toupper(*pscan);
                pnam++;
                namesize--;
                pscan++;
                nscan--;
-               if (nscan == 0) {
-                       ERRDRV("%s - unexpected end of input parsing name",
-                              __func__);
+               if (nscan == 0)
                        return NULL;
-               }
        }
-       if (namesize <= 0) {
-               ERRDRV("%s - name too big", __func__);
+       if (namesize <= 0)
                return NULL;
-       }
        *pnam = '\0';
        nam[string_length_no_trail(nam, strlen(nam))] = '\0';
 
@@ -350,26 +316,17 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
        while (isspace(*pscan)) {
                pscan++;
                nscan--;
-               if (nscan == 0) {
-                       ERRDRV("%s - unexpected end of input looking for value",
-                              __func__);
+               if (nscan == 0)
                        return NULL;
-               }
        }
-       if (nscan == 0) {
-               ERRDRV("%s - unexpected end of input looking for value",
-                      __func__);
+       if (nscan == 0)
                return NULL;
-       }
        if (*pscan == '\'' || *pscan == '"') {
                closing_quote = *pscan;
                pscan++;
                nscan--;
-               if (nscan == 0) {
-                       ERRDRV("%s - unexpected end of input after %c",
-                              __func__, closing_quote);
+               if (nscan == 0)
                        return NULL;
-               }
        }
 
        /* look for a separator character, terminator character, or
@@ -377,10 +334,8 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
         */
        for (i = 0, value_length = -1; i < nscan; i++) {
                if (closing_quote) {
-                       if (pscan[i] == '\0') {
-                               ERRDRV("%s - unexpected end of input parsing quoted value", __func__);
+                       if (pscan[i] == '\0')
                                return NULL;
-                       }
                        if (pscan[i] == closing_quote) {
                                value_length = i;
                                break;
@@ -393,10 +348,8 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
                }
        }
        if (value_length < 0) {
-               if (closing_quote) {
-                       ERRDRV("%s - unexpected end of input parsing quoted value", __func__);
+               if (closing_quote)
                        return NULL;
-               }
                value_length = nscan;
        }
        orig_value_length = value_length;
@@ -433,7 +386,6 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
                                pscan++;
                                nscan--;
                        } else if (*pscan != '\0') {
-                               ERRDRV("%s - missing separator after quoted string", __func__);
                                kfree(value);
                                value = NULL;
                                return NULL;
@@ -446,7 +398,7 @@ parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize)
 }
 
 void *
-parser_string_get(PARSER_CONTEXT *ctx)
+parser_string_get(struct parser_context *ctx)
 {
        u8 *pscan;
        ulong nscan;
index 9fbe3b5b7cc374690c1c1d52bd419da16bce38eb..aa50ff8780a368d9ae3e45afe388b84ec0593ade 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <linux/uuid.h>
 
-#include "uniklog.h"
 #include "timskmod.h"
 #include "channel.h"
 
@@ -31,17 +30,17 @@ typedef enum {
        PARSERSTRING_NAME,
 } PARSER_WHICH_STRING;
 
-typedef struct PARSER_CONTEXT_Tag PARSER_CONTEXT;
-
-PARSER_CONTEXT *parser_init(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain);
-PARSER_CONTEXT *parser_init_byteStream(u64 addr, u32 bytes, BOOL isLocal,
+struct parser_context *parser_init(u64 addr, u32 bytes, BOOL isLocal,
+                                  BOOL *tryAgain);
+struct parser_context *parser_init_byteStream(u64 addr, u32 bytes, BOOL isLocal,
                                       BOOL *tryAgain);
-void parser_param_start(PARSER_CONTEXT *ctx, PARSER_WHICH_STRING which_string);
-void *parser_param_get(PARSER_CONTEXT *ctx, char *nam, int namesize);
-void *parser_string_get(PARSER_CONTEXT *ctx);
-uuid_le parser_id_get(PARSER_CONTEXT *ctx);
-char *parser_simpleString_get(PARSER_CONTEXT *ctx);
-void *parser_byteStream_get(PARSER_CONTEXT *ctx, ulong *nbytes);
-void parser_done(PARSER_CONTEXT *ctx);
+void parser_param_start(struct parser_context *ctx,
+                       PARSER_WHICH_STRING which_string);
+void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
+void *parser_string_get(struct parser_context *ctx);
+uuid_le parser_id_get(struct parser_context *ctx);
+char *parser_simpleString_get(struct parser_context *ctx);
+void *parser_byteStream_get(struct parser_context *ctx, ulong *nbytes);
+void parser_done(struct parser_context *ctx);
 
 #endif
index f606ee9e0de908fb1107ce6f66fbe07785f3f6c9..284ed4f75f61db1fec5b70972e1c609532a788ec 100644 (file)
@@ -22,7 +22,6 @@
 #include "periodic_work.h"
 #include "file.h"
 #include "parser.h"
-#include "uniklog.h"
 #include "uisutils.h"
 #include "controlvmcompletionstatus.h"
 #include "guestlinuxdebug.h"
@@ -49,7 +48,7 @@
 * message, we switch back to fast polling mode.
 */
 #define MIN_IDLE_SECONDS 10
-static ulong Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
 static ulong Most_recent_message_jiffies;      /* when we got our last
                                                 * controlvm message */
 static inline char *
@@ -70,11 +69,6 @@ static struct delayed_work Periodic_controlvm_work;
 static struct workqueue_struct *Periodic_controlvm_workqueue;
 static DEFINE_SEMAPHORE(NotifierLock);
 
-typedef struct {
-       struct controlvm_message message;
-       unsigned int crc;
-} MESSAGE_ENVELOPE;
-
 static struct controlvm_message_header g_DiagMsgHdr;
 static struct controlvm_message_header g_ChipSetMsgHdr;
 static struct controlvm_message_header g_DelDumpMsgHdr;
@@ -103,19 +97,19 @@ static LIST_HEAD(DevInfoList);
 
 static struct visorchannel *ControlVm_channel;
 
-typedef struct {
+struct controlvm_payload_info {
        u8 __iomem *ptr;        /* pointer to base address of payload pool */
        u64 offset;             /* offset from beginning of controlvm
                                 * channel to beginning of payload * pool */
        u32 bytes;              /* number of bytes in payload pool */
-} CONTROLVM_PAYLOAD_INFO;
+};
 
 /* Manages the request payload in the controlvm channel */
-static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info;
+static struct controlvm_payload_info ControlVm_payload_info;
 
 static struct channel_header *Test_Vnic_channel;
 
-typedef struct {
+struct livedump_info {
        struct controlvm_message_header Dumpcapture_header;
        struct controlvm_message_header Gettextdump_header;
        struct controlvm_message_header Dumpcomplete_header;
@@ -124,11 +118,11 @@ typedef struct {
        ulong length;
        atomic_t buffers_in_use;
        ulong destination;
-} LIVEDUMP_INFO;
+};
 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
  * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
  */
-static LIVEDUMP_INFO LiveDump_info;
+static struct livedump_info LiveDump_info;
 
 /* The following globals are used to handle the scenario where we are unable to
  * offload the payload from a controlvm message due to memory requirements.  In
@@ -150,7 +144,7 @@ static const char Putfile_buffer_list_pool_name[] =
  */
 struct putfile_buffer_entry {
        struct list_head next;  /* putfile_buffer_entry list */
-       PARSER_CONTEXT *parser_ctx; /* points to buffer containing input data */
+       struct parser_context *parser_ctx; /* points to input data buffer */
 };
 
 /* List of struct putfile_request *, via next_putfile_request member.
@@ -165,7 +159,7 @@ static LIST_HEAD(Putfile_request_list);
  */
 struct putfile_active_buffer {
        /* a payload from a controlvm message, containing a file data buffer */
-       PARSER_CONTEXT *parser_ctx;
+       struct parser_context *parser_ctx;
        /* points within data area of parser_ctx to next byte of data */
        u8 *pnext;
        /* # bytes left from <pnext> to the end of this data buffer */
@@ -664,7 +658,6 @@ chipset_init(struct controlvm_message *inmsg)
 
        POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
        if (chipset_inited) {
-               LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done.");
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
                goto Away;
        }
@@ -717,14 +710,11 @@ controlvm_respond(struct controlvm_message_header *msgHdr, int response)
            && g_DeviceChangeStatePacket.device_change_state.dev_no ==
            g_diagpoolDevNo)
                outmsg.cmd = g_DeviceChangeStatePacket;
-       if (outmsg.hdr.flags.test_message == 1) {
-               LOGINF("%s controlvm_msg=0x%x response=%d for test message",
-                      __func__, outmsg.hdr.id, response);
+       if (outmsg.hdr.flags.test_message == 1)
                return;
-       }
+
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
@@ -740,7 +730,6 @@ controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr,
        outmsg.cmd.init_chipset.features = features;
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
@@ -756,7 +745,6 @@ static void controlvm_respond_physdev_changestate(
        outmsg.cmd.device_change_state.flags.phys_device = 1;
        if (!visorchannel_signalinsert(ControlVm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
@@ -773,15 +761,12 @@ visorchipset_save_message(struct controlvm_message *msg,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_count),
                              &localSavedCrashMsgCount, sizeof(u16)) < 0) {
-               LOGERR("failed to get Saved Message Count");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) {
-               LOGERR("Saved Message Count incorrect %d",
-                      localSavedCrashMsgCount);
                POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
                                 localSavedCrashMsgCount,
                                 POSTCODE_SEVERITY_ERR);
@@ -793,7 +778,6 @@ visorchipset_save_message(struct controlvm_message *msg,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_offset),
                              &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
-               LOGERR("failed to get Saved Message Offset");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -804,7 +788,6 @@ visorchipset_save_message(struct controlvm_message *msg,
                                       localSavedCrashMsgOffset,
                                       msg,
                                       sizeof(struct controlvm_message)) < 0) {
-                       LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!");
                        POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
                                         POSTCODE_SEVERITY_ERR);
                        return;
@@ -814,7 +797,6 @@ visorchipset_save_message(struct controlvm_message *msg,
                                       localSavedCrashMsgOffset +
                                       sizeof(struct controlvm_message), msg,
                                       sizeof(struct controlvm_message)) < 0) {
-                       LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!");
                        POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
                                         POSTCODE_SEVERITY_ERR);
                        return;
@@ -830,10 +812,9 @@ bus_responder(enum controlvm_id cmdId, ulong busNo, int response)
        BOOL need_clear = FALSE;
 
        p = findbus(&BusInfoList, busNo);
-       if (!p) {
-               LOGERR("internal error busNo=%lu", busNo);
+       if (!p)
                return;
-       }
+
        if (response < 0) {
                if ((cmdId == CONTROLVM_BUS_CREATE) &&
                    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
@@ -846,14 +827,10 @@ bus_responder(enum controlvm_id cmdId, ulong busNo, int response)
                        need_clear = TRUE;
        }
 
-       if (p->pending_msg_hdr.id == CONTROLVM_INVALID) {
-               LOGERR("bus_responder no pending msg");
+       if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
                return;         /* no controlvm response needed */
-       }
-       if (p->pending_msg_hdr.id != (u32) cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id);
+       if (p->pending_msg_hdr.id != (u32) cmdId)
                return;
-       }
        controlvm_respond(&p->pending_msg_hdr, response);
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
        if (need_clear) {
@@ -871,18 +848,12 @@ device_changestate_responder(enum controlvm_id cmdId,
        struct controlvm_message outmsg;
 
        p = finddevice(&DevInfoList, busNo, devNo);
-       if (!p) {
-               LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
+       if (!p)
                return;
-       }
-       if (p->pending_msg_hdr.id == CONTROLVM_INVALID) {
-               LOGERR("device_responder no pending msg");
+       if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
                return;         /* no controlvm response needed */
-       }
-       if (p->pending_msg_hdr.id != cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id);
+       if (p->pending_msg_hdr.id != cmdId)
                return;
-       }
 
        controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
 
@@ -891,10 +862,8 @@ device_changestate_responder(enum controlvm_id cmdId,
        outmsg.cmd.device_change_state.state = responseState;
 
        if (!visorchannel_signalinsert(ControlVm_channel,
-                                      CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
+                                      CONTROLVM_QUEUE_REQUEST, &outmsg))
                return;
-       }
 
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
 }
@@ -907,10 +876,8 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
        BOOL need_clear = FALSE;
 
        p = finddevice(&DevInfoList, busNo, devNo);
-       if (!p) {
-               LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
+       if (!p)
                return;
-       }
        if (response >= 0) {
                if (cmdId == CONTROLVM_DEVICE_CREATE)
                        p->state.created = 1;
@@ -918,14 +885,12 @@ device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
                        need_clear = TRUE;
        }
 
-       if (p->pending_msg_hdr.id == CONTROLVM_INVALID) {
-               LOGERR("device_responder no pending msg");
+       if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
                return;         /* no controlvm response needed */
-       }
-       if (p->pending_msg_hdr.id != (u32) cmdId) {
-               LOGERR("expected=%d, found=%d", cmdId, p->pending_msg_hdr.id);
+
+       if (p->pending_msg_hdr.id != (u32) cmdId)
                return;
-       }
+
        controlvm_respond(&p->pending_msg_hdr, response);
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
        if (need_clear)
@@ -941,10 +906,9 @@ bus_epilog(u32 busNo,
 
        struct visorchipset_bus_info *pBusInfo = findbus(&BusInfoList, busNo);
 
-       if (!pBusInfo) {
-               LOGERR("HUH? bad busNo=%d", busNo);
+       if (!pBusInfo)
                return;
-       }
+
        if (needResponse) {
                memcpy(&pBusInfo->pending_msg_hdr, msgHdr,
                       sizeof(struct controlvm_message_header));
@@ -1014,10 +978,9 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                NULL
        };
 
-       if (!pDevInfo) {
-               LOGERR("HUH? bad busNo=%d, devNo=%d", busNo, devNo);
+       if (!pDevInfo)
                return;
-       }
+
        if (for_visorbus)
                notifiers = &BusDev_Server_Notifiers;
        else
@@ -1068,8 +1031,6 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                                 */
                                if (busNo == g_diagpoolBusNo
                                    && devNo == g_diagpoolDevNo) {
-                                       LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)",
-                                            busNo, devNo);
                                        /* this will trigger the
                                         * diag_shutdown.sh script in
                                         * the visorchipset hotplug */
@@ -1109,8 +1070,6 @@ bus_create(struct controlvm_message *inmsg)
 
        pBusInfo = findbus(&BusInfoList, busNo);
        if (pBusInfo && (pBusInfo->state.created == 1)) {
-               LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu already exists",
-                      busNo);
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
@@ -1118,8 +1077,6 @@ bus_create(struct controlvm_message *inmsg)
        }
        pBusInfo = kzalloc(sizeof(struct visorchipset_bus_info), GFP_KERNEL);
        if (pBusInfo == NULL) {
-               LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
-                      busNo);
                POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
@@ -1163,13 +1120,10 @@ bus_destroy(struct controlvm_message *inmsg)
 
        pBusInfo = findbus(&BusInfoList, busNo);
        if (!pBusInfo) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
                goto Away;
        }
        if (pBusInfo->state.created == 0) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed",
-                    busNo);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
                goto Away;
        }
@@ -1180,7 +1134,8 @@ Away:
 }
 
 static void
-bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx)
+bus_configure(struct controlvm_message *inmsg,
+             struct parser_context *parser_ctx)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
        ulong busNo = cmd->configure_bus.bus_no;
@@ -1193,16 +1148,12 @@ bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx)
 
        pBusInfo = findbus(&BusInfoList, busNo);
        if (!pBusInfo) {
-               LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid",
-                      busNo);
                POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
                goto Away;
        }
        if (pBusInfo->state.created == 0) {
-               LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet",
-                    busNo);
                POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
@@ -1210,8 +1161,6 @@ bus_configure(struct controlvm_message *inmsg, PARSER_CONTEXT *parser_ctx)
        }
        /* TBD - add this check to other commands also... */
        if (pBusInfo->pending_msg_hdr.id != CONTROLVM_INVALID) {
-               LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding",
-                    busNo, (uint) pBusInfo->pending_msg_hdr.id);
                POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
@@ -1242,8 +1191,6 @@ my_device_create(struct controlvm_message *inmsg)
 
        pDevInfo = finddevice(&DevInfoList, busNo, devNo);
        if (pDevInfo && (pDevInfo->state.created == 1)) {
-               LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu already exists",
-                    busNo, devNo);
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
@@ -1251,16 +1198,12 @@ my_device_create(struct controlvm_message *inmsg)
        }
        pBusInfo = findbus(&BusInfoList, busNo);
        if (!pBusInfo) {
-               LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range",
-                    busNo);
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
                goto Away;
        }
        if (pBusInfo->state.created == 0) {
-               LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet",
-                    busNo);
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
@@ -1268,8 +1211,6 @@ my_device_create(struct controlvm_message *inmsg)
        }
        pDevInfo = kzalloc(sizeof(struct visorchipset_device_info), GFP_KERNEL);
        if (pDevInfo == NULL) {
-               LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
-                    busNo, devNo);
                POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
@@ -1301,8 +1242,6 @@ Away:
            is_diagpool_channel(pDevInfo->chan_info.channel_type_uuid)) {
                g_diagpoolBusNo = busNo;
                g_diagpoolDevNo = devNo;
-               LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu",
-                    g_diagpoolBusNo, g_diagpoolDevNo);
        }
        device_epilog(busNo, devNo, segment_state_running,
                      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
@@ -1322,16 +1261,12 @@ my_device_changestate(struct controlvm_message *inmsg)
 
        pDevInfo = finddevice(&DevInfoList, busNo, devNo);
        if (!pDevInfo) {
-               LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (doesn't exist)",
-                    busNo, devNo);
                POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                goto Away;
        }
        if (pDevInfo->state.created == 0) {
-               LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)",
-                    busNo, devNo);
                POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
@@ -1356,14 +1291,10 @@ my_device_destroy(struct controlvm_message *inmsg)
 
        pDevInfo = finddevice(&DevInfoList, busNo, devNo);
        if (!pDevInfo) {
-               LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid",
-                    busNo, devNo);
                rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
                goto Away;
        }
        if (pDevInfo->state.created == 0) {
-               LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed",
-                    busNo, devNo);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
        }
 
@@ -1379,33 +1310,27 @@ Away:
 /* When provided with the physical address of the controlvm channel
  * (phys_addr), the offset to the payload area we need to manage
  * (offset), and the size of this payload area (bytes), fills in the
- * CONTROLVM_PAYLOAD_INFO struct.  Returns TRUE for success or FALSE
+ * controlvm_payload_info struct.  Returns TRUE for success or FALSE
  * for failure.
  */
 static int
 initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
-                                 CONTROLVM_PAYLOAD_INFO *info)
+                                 struct controlvm_payload_info *info)
 {
        u8 __iomem *payload = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
        if (info == NULL) {
-               LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d",
-                    __FILE__, __LINE__);
                rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
                goto Away;
        }
-       memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO));
+       memset(info, 0, sizeof(struct controlvm_payload_info));
        if ((offset == 0) || (bytes == 0)) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed: request_payload_offset=%llu request_payload_bytes=%llu!",
-                    (u64) offset, (u64) bytes);
                rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
                goto Away;
        }
        payload = ioremap_cache(phys_addr + offset, bytes);
        if (payload == NULL) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed",
-                    (u64) offset, (u64) bytes);
                rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
                goto Away;
        }
@@ -1413,8 +1338,6 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
        info->offset = offset;
        info->bytes = bytes;
        info->ptr = payload;
-       LOGINF("offset=%llu, bytes=%lu, ptr=%p",
-              (u64) (info->offset), (ulong) (info->bytes), info->ptr);
 
 Away:
        if (rc < 0) {
@@ -1427,13 +1350,13 @@ Away:
 }
 
 static void
-destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO *info)
+destroy_controlvm_payload_info(struct controlvm_payload_info *info)
 {
        if (info->ptr != NULL) {
                iounmap(info->ptr);
                info->ptr = NULL;
        }
-       memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO));
+       memset(info, 0, sizeof(struct controlvm_payload_info));
 }
 
 static void
@@ -1447,7 +1370,6 @@ initialize_controlvm_payload(void)
                              offsetof(struct spar_controlvm_channel_protocol,
                                       request_payload_offset),
                              &payloadOffset, sizeof(payloadOffset)) < 0) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -1456,7 +1378,6 @@ initialize_controlvm_payload(void)
                              offsetof(struct spar_controlvm_channel_protocol,
                                       request_payload_bytes),
                              &payloadBytes, sizeof(payloadBytes)) < 0) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -1515,7 +1436,6 @@ chipset_ready(struct controlvm_message_header *msgHdr)
                 * and disks mounted for the partition
                 */
                g_ChipSetMsgHdr = *msgHdr;
-               LOGINF("Holding CHIPSET_READY response");
        }
 }
 
@@ -1550,11 +1470,8 @@ read_controlvm_event(struct controlvm_message *msg)
        if (visorchannel_signalremove(ControlVm_channel,
                                      CONTROLVM_QUEUE_EVENT, msg)) {
                /* got a message */
-               if (msg->hdr.flags.test_message == 1) {
-                       LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)",
-                              msg->hdr.id);
+               if (msg->hdr.flags.test_message == 1)
                        return FALSE;
-               }
                return TRUE;
        }
        return FALSE;
@@ -1604,9 +1521,9 @@ parahotplug_next_expiration(void)
 static struct parahotplug_request *
 parahotplug_request_create(struct controlvm_message *msg)
 {
-       struct parahotplug_request *req =
-           kmalloc(sizeof(struct parahotplug_request),
-                   GFP_KERNEL|__GFP_NORETRY);
+       struct parahotplug_request *req;
+
+       req = kmalloc(sizeof(*req), GFP_KERNEL|__GFP_NORETRY);
        if (req == NULL)
                return NULL;
 
@@ -1652,12 +1569,6 @@ parahotplug_request_kickoff(struct parahotplug_request *req)
        sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
                cmd->device_change_state.dev_no & 0x7);
 
-       LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n",
-              cmd->device_change_state.state.active,
-              cmd->device_change_state.bus_no,
-              cmd->device_change_state.dev_no >> 3,
-              cmd->device_change_state.dev_no & 7, req->id);
-
        kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
                           envp);
 }
@@ -1738,10 +1649,8 @@ parahotplug_process_message(struct controlvm_message *inmsg)
 
        req = parahotplug_request_create(inmsg);
 
-       if (req == NULL) {
-               LOGERR("parahotplug_process_message: couldn't allocate request");
+       if (req == NULL)
                return;
-       }
 
        if (inmsg->cmd.device_change_state.state.active) {
                /* For enable messages, just respond with success
@@ -1789,16 +1698,14 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
        struct controlvm_message_packet *cmd = &inmsg.cmd;
        u64 parametersAddr = 0;
        u32 parametersBytes = 0;
-       PARSER_CONTEXT *parser_ctx = NULL;
+       struct parser_context *parser_ctx = NULL;
        BOOL isLocalAddr = FALSE;
        struct controlvm_message ackmsg;
 
        /* create parsing context if necessary */
        isLocalAddr = (inmsg.hdr.flags.test_message == 1);
-       if (channel_addr == 0) {
-               LOGERR("HUH? channel_addr is 0!");
+       if (channel_addr == 0)
                return TRUE;
-       }
        parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset;
        parametersBytes = inmsg.hdr.payload_bytes;
 
@@ -1812,67 +1719,38 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
                parser_ctx =
                    parser_init_byteStream(parametersAddr, parametersBytes,
                                           isLocalAddr, &retry);
-               if (!parser_ctx) {
-                       if (retry) {
-                               LOGWRN("throttling to copy payload");
-                               return FALSE;
-                       }
-                       LOGWRN("parsing failed");
-                       LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.id);
-                       LOGWRN("parametersAddr=0x%llx", (u64) parametersAddr);
-                       LOGWRN("parametersBytes=%lu", (ulong) parametersBytes);
-                       LOGWRN("isLocalAddr=%d", isLocalAddr);
-               }
+               if (!parser_ctx && retry)
+                       return FALSE;
        }
 
        if (!isLocalAddr) {
                controlvm_init_response(&ackmsg, &inmsg.hdr,
                                        CONTROLVM_RESP_SUCCESS);
-               if ((ControlVm_channel)
-                   &&
-                   (!visorchannel_signalinsert
-                    (ControlVm_channel, CONTROLVM_QUEUE_ACK, &ackmsg)))
-                       LOGWRN("failed to send ACK failed");
+               if (ControlVm_channel)
+                       visorchannel_signalinsert(ControlVm_channel,
+                                                 CONTROLVM_QUEUE_ACK,
+                                                 &ackmsg);
        }
        switch (inmsg.hdr.id) {
        case CONTROLVM_CHIPSET_INIT:
-               LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)",
-                      (ulong) inmsg.cmd.init_chipset.bus_count,
-                      (ulong) inmsg.cmd.init_chipset.switch_count);
                chipset_init(&inmsg);
                break;
        case CONTROLVM_BUS_CREATE:
-               LOGINF("BUS_CREATE(%lu,#devs=%lu)",
-                      (ulong) cmd->create_bus.bus_no,
-                      (ulong) cmd->create_bus.dev_count);
                bus_create(&inmsg);
                break;
        case CONTROLVM_BUS_DESTROY:
-               LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroy_bus.bus_no);
                bus_destroy(&inmsg);
                break;
        case CONTROLVM_BUS_CONFIGURE:
-               LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configure_bus.bus_no);
                bus_configure(&inmsg, parser_ctx);
                break;
        case CONTROLVM_DEVICE_CREATE:
-               LOGINF("DEVICE_CREATE(%lu,%lu)",
-                      (ulong) cmd->create_device.bus_no,
-                      (ulong) cmd->create_device.dev_no);
                my_device_create(&inmsg);
                break;
        case CONTROLVM_DEVICE_CHANGESTATE:
                if (cmd->device_change_state.flags.phys_device) {
-                       LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)",
-                            (ulong) cmd->device_change_state.bus_no,
-                            (ulong) cmd->device_change_state.dev_no,
-                            (ulong) cmd->device_change_state.state.active);
                        parahotplug_process_message(&inmsg);
                } else {
-                       LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)",
-                            (ulong) cmd->device_change_state.bus_no,
-                            (ulong) cmd->device_change_state.dev_no,
-                            (ulong) cmd->device_change_state.state.alive);
                        /* save the hdr and cmd structures for later use */
                        /* when sending back the response to Command */
                        my_device_changestate(&inmsg);
@@ -1882,33 +1760,23 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
                }
                break;
        case CONTROLVM_DEVICE_DESTROY:
-               LOGINF("DEVICE_DESTROY(%lu,%lu)",
-                      (ulong) cmd->destroy_device.bus_no,
-                      (ulong) cmd->destroy_device.dev_no);
                my_device_destroy(&inmsg);
                break;
        case CONTROLVM_DEVICE_CONFIGURE:
-               LOGINF("DEVICE_CONFIGURE(%lu,%lu)",
-                      (ulong) cmd->configure_device.bus_no,
-                      (ulong) cmd->configure_device.dev_no);
                /* no op for now, just send a respond that we passed */
                if (inmsg.hdr.flags.response_expected)
                        controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
                break;
        case CONTROLVM_CHIPSET_READY:
-               LOGINF("CHIPSET_READY");
                chipset_ready(&inmsg.hdr);
                break;
        case CONTROLVM_CHIPSET_SELFTEST:
-               LOGINF("CHIPSET_SELFTEST");
                chipset_selftest(&inmsg.hdr);
                break;
        case CONTROLVM_CHIPSET_STOP:
-               LOGINF("CHIPSET_STOP");
                chipset_notready(&inmsg.hdr);
                break;
        default:
-               LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.id);
                if (inmsg.hdr.flags.response_expected)
                        controlvm_respond(&inmsg.hdr,
                                          -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
@@ -1927,12 +1795,9 @@ static HOSTADDRESS controlvm_get_channel_address(void)
        u64 addr = 0;
        u32 size = 0;
 
-       if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size))) {
-               ERRDRV("%s - vmcall to determine controlvm channel addr failed",
-                      __func__);
+       if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size)))
                return 0;
-       }
-       INFODRV("controlvm addr=%Lx", addr);
+
        return addr;
 }
 
@@ -1965,7 +1830,6 @@ controlvm_periodic_work(struct work_struct *work)
        if (visorchipset_holdchipsetready
            && (g_ChipSetMsgHdr.id != CONTROLVM_INVALID)) {
                if (check_chipset_events() == 1) {
-                       LOGINF("Sending CHIPSET_READY response");
                        controlvm_respond(&g_ChipSetMsgHdr, 0);
                        clear_chipset_events();
                        memset(&g_ChipSetMsgHdr, 0,
@@ -1976,12 +1840,6 @@ controlvm_periodic_work(struct work_struct *work)
        while (visorchannel_signalremove(ControlVm_channel,
                                         CONTROLVM_QUEUE_RESPONSE,
                                         &inmsg)) {
-               if (inmsg.hdr.payload_max_bytes != 0) {
-                       LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
-                            (ulong) inmsg.hdr.payload_max_bytes,
-                            (ulong) inmsg.hdr.payload_vm_offset,
-                            inmsg.hdr.id);
-               }
        }
        if (!gotACommand) {
                if (ControlVm_Pending_Msg_Valid) {
@@ -2027,19 +1885,15 @@ Away:
                * processed our last controlvm message; slow down the
                * polling
                */
-               if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW) {
-                       LOGINF("switched to slow controlvm polling");
-                       Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
-               }
+               if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW)
+                       poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
        } else {
-               if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST) {
-                       Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-                       LOGINF("switched to fast controlvm polling");
-               }
+               if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST)
+                       poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
        }
 
        queue_delayed_work(Periodic_controlvm_workqueue,
-                          &Periodic_controlvm_work, Poll_jiffies);
+                          &Periodic_controlvm_work, poll_jiffies);
 }
 
 static void
@@ -2076,15 +1930,12 @@ setup_crash_devices_work_queue(struct work_struct *work)
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_count),
                              &localSavedCrashMsgCount, sizeof(u16)) < 0) {
-               LOGERR("failed to get Saved Message Count");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) {
-               LOGERR("Saved Message Count incorrect %d",
-                      localSavedCrashMsgCount);
                POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
                                 localSavedCrashMsgCount,
                                 POSTCODE_SEVERITY_ERR);
@@ -2096,7 +1947,6 @@ setup_crash_devices_work_queue(struct work_struct *work)
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_offset),
                              &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
-               LOGERR("failed to get Saved Message Offset");
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -2107,7 +1957,6 @@ setup_crash_devices_work_queue(struct work_struct *work)
                              localSavedCrashMsgOffset,
                              &localCrashCreateBusMsg,
                              sizeof(struct controlvm_message)) < 0) {
-               LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!");
                POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -2119,7 +1968,6 @@ setup_crash_devices_work_queue(struct work_struct *work)
                              sizeof(struct controlvm_message),
                              &localCrashCreateDevMsg,
                              sizeof(struct controlvm_message)) < 0) {
-               LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!");
                POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -2129,7 +1977,6 @@ setup_crash_devices_work_queue(struct work_struct *work)
        if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0)
                bus_create(&localCrashCreateBusMsg);
        else {
-               LOGERR("CrashCreateBusMsg is null, no dump will be taken");
                POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
@@ -2139,21 +1986,19 @@ setup_crash_devices_work_queue(struct work_struct *work)
        if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0)
                my_device_create(&localCrashCreateDevMsg);
        else {
-               LOGERR("CrashCreateDevMsg is null, no dump will be taken");
                POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
-       LOGINF("Bus and device ready for dumping");
        POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO);
        return;
 
 Away:
 
-       Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
+       poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
 
        queue_delayed_work(Periodic_controlvm_workqueue,
-                          &Periodic_controlvm_work, Poll_jiffies);
+                          &Periodic_controlvm_work, poll_jiffies);
 }
 
 static void
@@ -2203,10 +2048,8 @@ visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info)
 {
        void *p = findbus(&BusInfoList, bus_no);
 
-       if (!p) {
-               LOGERR("(%lu) failed", bus_no);
+       if (!p)
                return FALSE;
-       }
        memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
        return TRUE;
 }
@@ -2217,10 +2060,8 @@ visorchipset_set_bus_context(ulong bus_no, void *context)
 {
        struct visorchipset_bus_info *p = findbus(&BusInfoList, bus_no);
 
-       if (!p) {
-               LOGERR("(%lu) failed", bus_no);
+       if (!p)
                return FALSE;
-       }
        p->bus_driver_context = context;
        return TRUE;
 }
@@ -2232,10 +2073,8 @@ visorchipset_get_device_info(ulong bus_no, ulong dev_no,
 {
        void *p = finddevice(&DevInfoList, bus_no, dev_no);
 
-       if (!p) {
-               LOGERR("(%lu,%lu) failed", bus_no, dev_no);
+       if (!p)
                return FALSE;
-       }
        memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
        return TRUE;
 }
@@ -2247,10 +2086,8 @@ visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context)
        struct visorchipset_device_info *p =
                        finddevice(&DevInfoList, bus_no, dev_no);
 
-       if (!p) {
-               LOGERR("(%lu,%lu) failed", bus_no, dev_no);
+       if (!p)
                return FALSE;
-       }
        p->bus_driver_context = context;
        return TRUE;
 }
@@ -2278,10 +2115,9 @@ visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block,
         */
        gfp |= __GFP_NORETRY;
        p = kmem_cache_alloc(pool, gfp);
-       if (!p) {
-               LOGERR("kmem_cache_alloc failed early @%s:%d\n", fn, ln);
+       if (!p)
                return NULL;
-       }
+
        atomic_inc(&Visorchipset_cache_buffers_in_use);
        return p;
 }
@@ -2291,10 +2127,9 @@ visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block,
 void
 visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
 {
-       if (!p) {
-               LOGERR("NULL pointer @%s:%d\n", fn, ln);
+       if (!p)
                return;
-       }
+
        atomic_dec(&Visorchipset_cache_buffers_in_use);
        kmem_cache_free(pool, p);
 }
@@ -2353,25 +2188,11 @@ static int __init
 visorchipset_init(void)
 {
        int rc = 0, x = 0;
-       char s[64];
        HOSTADDRESS addr;
 
        if (!unisys_spar_platform)
                return -ENODEV;
 
-       LOGINF("chipset driver version %s loaded", VERSION);
-       /* process module options */
-       POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
-       LOGINF("option - testvnic=%d", visorchipset_testvnic);
-       LOGINF("option - testvnicclient=%d", visorchipset_testvnicclient);
-       LOGINF("option - testmsg=%d", visorchipset_testmsg);
-       LOGINF("option - testteardown=%d", visorchipset_testteardown);
-       LOGINF("option - major=%d", visorchipset_major);
-       LOGINF("option - serverregwait=%d", visorchipset_serverregwait);
-       LOGINF("option - clientregwait=%d", visorchipset_clientregwait);
-       LOGINF("option - holdchipsetready=%d", visorchipset_holdchipsetready);
-
        memset(&BusDev_Server_Notifiers, 0, sizeof(BusDev_Server_Notifiers));
        memset(&BusDev_Client_Notifiers, 0, sizeof(BusDev_Client_Notifiers));
        memset(&ControlVm_payload_info, 0, sizeof(ControlVm_payload_info));
@@ -2379,8 +2200,6 @@ visorchipset_init(void)
        atomic_set(&LiveDump_info.buffers_in_use, 0);
 
        if (visorchipset_testvnic) {
-               ERRDRV("testvnic option no longer supported: (status = %d)\n",
-                      x);
                POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
                rc = x;
                goto Away;
@@ -2395,24 +2214,19 @@ visorchipset_init(void)
                     spar_controlvm_channel_protocol_uuid);
                if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
                                visorchannel_get_header(ControlVm_channel))) {
-                       LOGINF("Channel %s (ControlVm) discovered",
-                              visorchannel_id(ControlVm_channel, s));
                        initialize_controlvm_payload();
                } else {
-                       LOGERR("controlvm channel is invalid");
                        visorchannel_destroy(ControlVm_channel);
                        ControlVm_channel = NULL;
                        return -ENODEV;
                }
        } else {
-               LOGERR("no controlvm channel discovered");
                return -ENODEV;
        }
 
        MajorDev = MKDEV(visorchipset_major, 0);
        rc = visorchipset_file_init(MajorDev, &ControlVm_channel);
        if (rc < 0) {
-               ERRDRV("visorchipset_file_init(MajorDev, &ControlVm_channel): error (status=%d)\n", rc);
                POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
                goto Away;
        }
@@ -2428,14 +2242,11 @@ visorchipset_init(void)
                              sizeof(struct putfile_buffer_entry),
                              0, SLAB_HWCACHE_ALIGN, NULL);
        if (!Putfile_buffer_list_pool) {
-               ERRDRV("failed to alloc Putfile_buffer_list_pool: (status=-1)\n");
                POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
                rc = -1;
                goto Away;
        }
-       if (visorchipset_disable_controlvm) {
-               LOGINF("visorchipset_init:controlvm disabled");
-       } else {
+       if (!visorchipset_disable_controlvm) {
                /* if booting in a crash kernel */
                if (visorchipset_crash_kernel)
                        INIT_DELAYED_WORK(&Periodic_controlvm_work,
@@ -2447,19 +2258,16 @@ visorchipset_init(void)
                    create_singlethread_workqueue("visorchipset_controlvm");
 
                if (Periodic_controlvm_workqueue == NULL) {
-                       ERRDRV("cannot create controlvm workqueue: (status=%d)\n",
-                              -ENOMEM);
                        POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
                                         DIAG_SEVERITY_ERR);
                        rc = -ENOMEM;
                        goto Away;
                }
                Most_recent_message_jiffies = jiffies;
-               Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+               poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
                rc = queue_delayed_work(Periodic_controlvm_workqueue,
-                                       &Periodic_controlvm_work, Poll_jiffies);
+                                       &Periodic_controlvm_work, poll_jiffies);
                if (rc < 0) {
-                       ERRDRV("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies): error (status=%d)\n", rc);
                        POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
                                         DIAG_SEVERITY_ERR);
                        goto Away;
@@ -2469,17 +2277,14 @@ visorchipset_init(void)
 
        Visorchipset_platform_device.dev.devt = MajorDev;
        if (platform_device_register(&Visorchipset_platform_device) < 0) {
-               ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n");
                POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
                rc = -1;
                goto Away;
        }
-       LOGINF("visorchipset device created");
        POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
        rc = 0;
 Away:
        if (rc) {
-               LOGERR("visorchipset_init failed");
                POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
                                 POSTCODE_SEVERITY_ERR);
        }
@@ -2489,8 +2294,6 @@ Away:
 static void
 visorchipset_exit(void)
 {
-       char s[99];
-
        POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 
        if (visorchipset_disable_controlvm) {
@@ -2516,13 +2319,10 @@ visorchipset_exit(void)
 
        memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header));
 
-       LOGINF("Channel %s (ControlVm) disconnected",
-              visorchannel_id(ControlVm_channel, s));
        visorchannel_destroy(ControlVm_channel);
 
        visorchipset_file_cleanup();
        POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
-       LOGINF("chipset driver unloaded");
 }
 
 module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
index 74b474eac25265d530bb0bca3b16ca90137481a1..be9c2cf890ccd72678abb357e16acc2fc128a6cd 100644 (file)
@@ -4,7 +4,6 @@
 
 config UNISYS_VISORUTIL
        tristate "Unisys visorutil driver"
-       depends on UNISYSSPAR && HAS_IOMEM
        ---help---
        If you say Y here, you will enable the Unisys visorutil driver.
 
index ac7acb7c5b7955eb63c1c7403eebb314f2fc5cb9..c91752a2d06b6f385f137a08a44cd82622c321c1 100644 (file)
@@ -36,13 +36,11 @@ struct charqueue {
 struct charqueue *visor_charqueue_create(ulong nslots)
 {
        int alloc_size = sizeof(struct charqueue) + nslots + 1;
-       struct charqueue *cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY);
+       struct charqueue *cq;
 
-       if (cq == NULL) {
-               ERRDRV("visor_charqueue_create allocation failed (alloc_size=%d)",
-                      alloc_size);
+       cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY);
+       if (cq == NULL)
                return NULL;
-       }
        cq->alloc_size = alloc_size;
        cq->nslots = nslots;
        cq->head = 0;
index 56c1f79a54b0487ebd83297a1a8d77f96ea6ea06..f46a776b935bd4809fb9469eee247c479989d4a1 100644 (file)
@@ -18,7 +18,6 @@
 #ifndef __CHARQUEUE_H__
 #define __CHARQUEUE_H__
 
-#include "uniklog.h"
 #include "timskmod.h"
 
 /* struct charqueue is an opaque structure to users.
index 40f1ae9a155c5af2d084a9d4b737a2938004d8fa..3cb55d39370be17614de0d892942d077765c1506 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <linux/proc_fs.h>
 
-#include "uniklog.h"
 #include "timskmod.h"
 #include "easyproc.h"
 
@@ -61,9 +60,6 @@ static struct proc_dir_entry *
        createProcDir(char *name, struct proc_dir_entry *parent)
 {
        struct proc_dir_entry *p = proc_mkdir_mode(name, S_IFDIR, parent);
-
-       if (p == NULL)
-               ERRDRV("failed to create /proc directory %s", name);
        return p;
 }
 
@@ -114,8 +110,6 @@ void visor_easyproc_InitDriver(struct easyproc_driver_info *pdriver,
 {
        memset(pdriver, 0, sizeof(struct easyproc_driver_info));
        pdriver->ProcId = procId;
-       if (pdriver->ProcId == NULL)
-               ERRDRV("ProcId cannot be NULL (trouble ahead)!");
        pdriver->Show_driver_info = show_driver_info;
        pdriver->Show_device_info = show_device_info;
        if (pdriver->ProcDir == NULL)
@@ -132,9 +126,6 @@ void visor_easyproc_InitDriver(struct easyproc_driver_info *pdriver,
                        proc_create_data("diag", 0,
                                         pdriver->ProcDriverDir,
                                         &proc_fops_driver, pdriver);
-               if (pdriver->ProcDriverDiagFile == NULL)
-                       ERRDRV("failed to register /proc/%s/driver/diag entry",
-                              pdriver->ProcId);
        }
 }
 EXPORT_SYMBOL_GPL(visor_easyproc_InitDriver);
@@ -209,10 +200,6 @@ void visor_easyproc_InitDevice(struct easyproc_driver_info *pdriver,
                p->procDevicexDiagFile =
                        proc_create_data("diag", 0, p->procDevicexDir,
                                         &proc_fops_device, p);
-               if (p->procDevicexDiagFile == NULL)
-                       ERRDEVX(devno, "failed to register /proc/%s/device/%d/diag entry",
-                               pdriver->ProcId, devno
-                              );
        }
        memset(&(p->device_property_info[0]), 0,
               sizeof(p->device_property_info));
@@ -229,34 +216,26 @@ void visor_easyproc_CreateDeviceProperty(struct easyproc_device_info *p,
        size_t i;
        struct easyproc_device_property_info *px = NULL;
 
-       if (p->procDevicexDir == NULL) {
-               ERRDRV("state error");
+       if (p->procDevicexDir == NULL)
                return;
-       }
        for (i = 0; i < ARRAY_SIZE(p->device_property_info); i++) {
                if (p->device_property_info[i].procEntry == NULL) {
                        px = &(p->device_property_info[i]);
                        break;
                }
        }
-       if (!px) {
-               ERRDEVX(p->devno, "too many device properties");
+       if (!px)
                return;
-       }
+
        px->devdata = p->devdata;
        px->pdriver = p->pdriver;
        px->procEntry = proc_create_data(property_name, 0, p->procDevicexDir,
                                         &proc_fops_device_property, px);
        if (strlen(property_name)+1 > sizeof(px->property_name)) {
-               ERRDEVX(p->devno, "device property name %s too long",
-                       property_name);
                return;
        }
        strcpy(px->property_name, property_name);
        if (px->procEntry == NULL) {
-               ERRDEVX(p->devno,
-                       "failed to register /proc/%s/device/%d/%s entry",
-                       p->pdriver->ProcId, p->devno, property_name);
                return;
        }
        px->show_device_property_info = show_property_info;
index 33522cc8c22c9687d9c9fee70c764a7cfea5dcd1..eb7422fbe20f4f08db705e8ce6f982450975d750 100644 (file)
@@ -20,7 +20,6 @@
  *  channel memory (in main memory of the host system) from code running in
  *  a virtual partition.
  */
-#include "uniklog.h"
 #include "timskmod.h"
 #include "memregion.h"
 
@@ -41,12 +40,12 @@ struct memregion *
 visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
 {
        struct memregion *rc = NULL;
-       struct memregion *memregion = kzalloc(sizeof(*memregion),
-                                             GFP_KERNEL | __GFP_NORETRY);
-       if (memregion == NULL) {
-               ERRDRV("visor_memregion_create allocation failed");
+       struct memregion *memregion;
+
+       memregion = kzalloc(sizeof(*memregion), GFP_KERNEL | __GFP_NORETRY);
+       if (memregion == NULL)
                return NULL;
-       }
+
        memregion->physaddr = physaddr;
        memregion->nbytes = nbytes;
        memregion->overlapped = FALSE;
@@ -70,25 +69,19 @@ visor_memregion_create_overlapped(struct memregion *parent, ulong offset,
 {
        struct memregion *memregion = NULL;
 
-       if (parent == NULL) {
-               ERRDRV("%s parent is NULL", __func__);
+       if (parent == NULL)
                return NULL;
-       }
-       if (parent->mapped == NULL) {
-               ERRDRV("%s parent is not mapped!", __func__);
+
+       if (parent->mapped == NULL)
                return NULL;
-       }
+
        if ((offset >= parent->nbytes) ||
-           ((offset + nbytes) >= parent->nbytes)) {
-               ERRDRV("%s range (%lu,%lu) out of parent range",
-                      __func__, offset, nbytes);
+           ((offset + nbytes) >= parent->nbytes))
                return NULL;
-       }
+
        memregion = kzalloc(sizeof(*memregion), GFP_KERNEL|__GFP_NORETRY);
-       if (memregion == NULL) {
-               ERRDRV("%s allocation failed", __func__);
+       if (memregion == NULL)
                return NULL;
-       }
 
        memregion->physaddr = parent->physaddr + offset;
        memregion->nbytes = nbytes;
@@ -106,17 +99,11 @@ mapit(struct memregion *memregion)
        ulong nbytes = memregion->nbytes;
 
        memregion->requested = FALSE;
-       if (!request_mem_region(physaddr, nbytes, MYDRVNAME))
-               ERRDRV("cannot reserve channel memory @0x%lx for 0x%lx-- no big deal",
-                      physaddr, nbytes);
-       else
+       if (request_mem_region(physaddr, nbytes, MYDRVNAME))
                memregion->requested = TRUE;
        memregion->mapped = ioremap_cache(physaddr, nbytes);
-       if (memregion->mapped == NULL) {
-               ERRDRV("cannot ioremap_cache channel memory @0x%lx for 0x%lx",
-                      physaddr, nbytes);
+       if (!memregion->mapped)
                return FALSE;
-       }
        return TRUE;
 }
 
@@ -180,10 +167,9 @@ memregion_readwrite(BOOL is_write,
                    struct memregion *memregion, ulong offset,
                    void *local, ulong nbytes)
 {
-       if (offset + nbytes > memregion->nbytes) {
-               ERRDRV("memregion_readwrite offset out of range!!");
+       if (offset + nbytes > memregion->nbytes)
                return -EIO;
-       }
+
        if (is_write)
                memcpy_toio(memregion->mapped + offset, local, nbytes);
        else
index 0908bf929401be23dd35e2845487b1e007889709..abbfb48894f309e5405f9d7ae2ab3751786bc956 100644 (file)
@@ -19,7 +19,6 @@
  *  Helper functions to schedule periodic work in Linux kernel mode.
  */
 
-#include "uniklog.h"
 #include "timskmod.h"
 #include "periodic_work.h"
 
@@ -90,7 +89,6 @@ BOOL visor_periodic_work_nextperiod(struct periodic_work *pw)
                goto unlock;
        } else if (queue_delayed_work(pw->workqueue, &pw->work,
                                      pw->jiffy_interval) < 0) {
-               ERRDEV(pw->devnam, "queue_delayed_work failed!");
                pw->is_scheduled = FALSE;
                rc = FALSE;
                goto unlock;
@@ -116,15 +114,12 @@ BOOL visor_periodic_work_start(struct periodic_work *pw)
                goto unlock;
        }
        if (pw->want_to_stop) {
-               ERRDEV(pw->devnam,
-                      "dev_start_periodic_work failed!");
                rc = FALSE;
                goto unlock;
        }
        INIT_DELAYED_WORK(&pw->work, &periodic_work_func);
        if (queue_delayed_work(pw->workqueue, &pw->work,
                               pw->jiffy_interval) < 0) {
-               ERRDEV(pw->devnam, "%s queue_delayed_work failed!", __func__);
                rc = FALSE;
                goto unlock;
        }
@@ -182,7 +177,7 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw)
                        /* We get here if the delayed work was pending as
                         * delayed work, but was NOT run.
                         */
-                       ASSERT(pw->is_scheduled);
+                       WARN_ON(!pw->is_scheduled);
                        pw->is_scheduled = FALSE;
                } else {
                        /* If we get here, either the delayed work:
@@ -197,14 +192,6 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw)
                }
                if (pw->is_scheduled) {
                        write_unlock(&pw->lock);
-                       WARNDEV(pw->devnam,
-                               "waiting for delayed work...");
-                       /* We rely on the delayed work function running here,
-                        * and eventually calling
-                        * visor_periodic_work_nextperiod(),
-                        * which will see that want_to_stop is set, and
-                        * subsequently clear is_scheduled.
-                        */
                        SLEEPJIFFIES(10);
                        write_lock(&pw->lock);
                } else {
index 82279ca5fbe1d5bfaa2844a78ffebb0b4cc1e18b..e4e954ed57ef906e6f8f2f67af7cfcb1b470b3a1 100644 (file)
@@ -96,8 +96,6 @@ createProcDir(const char *name, struct proc_dir_entry *parent)
 {
        struct proc_dir_entry *p = proc_mkdir_mode(name, S_IFDIR, parent);
 
-       if (p == NULL)
-               ERRDRV("failed to create /proc directory %s", name);
        return p;
 }
 
@@ -107,8 +105,6 @@ createProcFile(const char *name, struct proc_dir_entry *parent,
 {
        struct proc_dir_entry *p = proc_create_data(name, 0, parent,
                                                    fops, data);
-       if (p == NULL)
-               ERRDRV("failed to create /proc file %s", name);
        return p;
 }
 
@@ -137,19 +133,16 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
        MYPROCTYPE *rc = NULL, *type = NULL;
        struct proc_dir_entry *parent = NULL;
 
-       if (procDirRoot == NULL) {
-               ERRDRV("procDirRoot cannot be NULL!\n");
+       if (procDirRoot == NULL)
                goto Away;
-       }
-       if (name == NULL || name[0] == NULL) {
-               ERRDRV("name must contain at least 1 node name!\n");
+
+       if (name == NULL || name[0] == NULL)
                goto Away;
-       }
+
        type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY);
-       if (type == NULL) {
-               ERRDRV("out of memory\n");
+       if (type == NULL)
                goto Away;
-       }
+
        type->name = name;
        type->propertyNames = propertyNames;
        type->nProperties = 0;
@@ -161,13 +154,11 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
                        type->nProperties++;
        while (type->name[type->nNames] != NULL)
                type->nNames++;
-       type->procDirs = kzalloc((type->nNames + 1) *
+       type->procDirs = kcalloc((type->nNames + 1),
                                 sizeof(struct proc_dir_entry *),
                                 GFP_KERNEL | __GFP_NORETRY);
-       if (type->procDirs == NULL) {
-               ERRDRV("out of memory\n");
+       if (type->procDirs == NULL)
                goto Away;
-       }
        parent = procDirRoot;
        for (i = 0; i < type->nNames; i++) {
                type->procDirs[i] = createProcDir(type->name[i], parent);
@@ -226,15 +217,13 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
        MYPROCOBJECT *obj = NULL, *rc = NULL;
        int i = 0;
 
-       if (type == NULL) {
-               ERRDRV("type cannot be NULL\n");
+       if (type == NULL)
                goto Away;
-       }
+
        obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
-       if (obj == NULL) {
-               ERRDRV("out of memory\n");
+       if (obj == NULL)
                goto Away;
-       }
+
        obj->type = type;
        obj->context = context;
        if (name == NULL) {
@@ -245,7 +234,6 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
                obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY);
                if (obj->name == NULL) {
                        obj->namesize = 0;
-                       ERRDRV("out of memory\n");
                        goto Away;
                }
                strcpy(obj->name, name);
@@ -254,20 +242,16 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
                        goto Away;
        }
        obj->procDirPropertyContexts =
-               kzalloc((type->nProperties + 1) *
+               kcalloc((type->nProperties + 1),
                        sizeof(struct proc_dir_entry_context),
                        GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirPropertyContexts == NULL) {
-               ERRDRV("out of memory\n");
+       if (obj->procDirPropertyContexts == NULL)
                goto Away;
-       }
-       obj->procDirProperties = kzalloc((type->nProperties + 1) *
+       obj->procDirProperties = kcalloc((type->nProperties + 1),
                                         sizeof(struct proc_dir_entry *),
                                         GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirProperties == NULL) {
-               ERRDRV("out of memory\n");
+       if (obj->procDirProperties == NULL)
                goto Away;
-       }
        for (i = 0; i < type->nProperties; i++) {
                obj->procDirPropertyContexts[i].procObject = obj;
                obj->procDirPropertyContexts[i].propertyIndex = i;
@@ -343,10 +327,8 @@ static int seq_show(struct seq_file *seq, void *offset)
 {
        struct proc_dir_entry_context *ctx = seq->private;
 
-       if (ctx == NULL) {
-               ERRDRV("I don't have a freakin' clue...");
+       if (ctx == NULL)
                return 0;
-       }
        (*ctx->show_property)(seq, ctx->procObject->context,
                              ctx->propertyIndex);
        return 0;
index 556e2642d2d976f1ff829792d1583491f2fa479b..62f0f7046e1734d4c697642c5563dd320da63335 100644 (file)
@@ -15,7 +15,6 @@
  * details.
  */
 
-#include "uniklog.h"
 #include "timskmod.h"
 
 #define MYDRVNAME "timskmodutils"
index 84c5a07e8f6a70b215664b2541c99bf66c0066c7..eabbcc710a2024d68d9e2c69c9bb88b9d3b5b179 100644 (file)
@@ -13,7 +13,6 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
index da34d5529f5154d35f259ec81eca147e868cf3e1..77901b345a716f7c3c0d7dc0347d910fba810ae0 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
index 8b1f533314331e5d9882316259954ef42254d355..19ba749bb122c92e5ad22a8b8b360c9489adefe7 100644 (file)
@@ -17,6 +17,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/atomic.h>
 #include <linux/cdev.h>
 #include <linux/delay.h>
 #include <linux/device.h>
@@ -41,7 +42,6 @@
 
 #include "vme_user.h"
 
-static DEFINE_MUTEX(vme_user_mutex);
 static const char driver_name[] = "vme_user";
 
 static int bus[VME_USER_BUS_MAX];
@@ -100,6 +100,7 @@ struct image_desc {
        struct device *device;  /* Sysfs device */
        struct vme_resource *resource;  /* VME resource */
        int users;              /* Number of current users */
+       int mmap_count;         /* Number of current mmap's */
 };
 static struct image_desc image[VME_DEVS];
 
@@ -135,6 +136,10 @@ static ssize_t vme_user_write(struct file *, const char __user *, size_t,
        loff_t *);
 static loff_t vme_user_llseek(struct file *, loff_t, int);
 static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long);
+static int vme_user_mmap(struct file *file, struct vm_area_struct *vma);
+
+static void vme_user_vm_open(struct vm_area_struct *vma);
+static void vme_user_vm_close(struct vm_area_struct *vma);
 
 static int vme_user_match(struct vme_dev *);
 static int vme_user_probe(struct vme_dev *);
@@ -148,6 +153,17 @@ static const struct file_operations vme_user_fops = {
        .llseek = vme_user_llseek,
        .unlocked_ioctl = vme_user_unlocked_ioctl,
        .compat_ioctl = vme_user_unlocked_ioctl,
+       .mmap = vme_user_mmap,
+};
+
+struct vme_user_vma_priv {
+       unsigned int minor;
+       atomic_t refcnt;
+};
+
+static const struct vm_operations_struct vme_user_vm_ops = {
+       .open = vme_user_vm_open,
+       .close = vme_user_vm_close,
 };
 
 
@@ -489,6 +505,11 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
 
                case VME_SET_MASTER:
 
+                       if (image[minor].mmap_count != 0) {
+                               pr_warn("Can't adjust mapped window\n");
+                               return -EPERM;
+                       }
+
                        copied = copy_from_user(&master, argp, sizeof(master));
                        if (copied != 0) {
                                pr_warn("Partial copy from userspace\n");
@@ -555,14 +576,79 @@ static long
 vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        int ret;
+       struct inode *inode = file_inode(file);
+       unsigned int minor = MINOR(inode->i_rdev);
 
-       mutex_lock(&vme_user_mutex);
-       ret = vme_user_ioctl(file_inode(file), file, cmd, arg);
-       mutex_unlock(&vme_user_mutex);
+       mutex_lock(&image[minor].mutex);
+       ret = vme_user_ioctl(inode, file, cmd, arg);
+       mutex_unlock(&image[minor].mutex);
 
        return ret;
 }
 
+static void vme_user_vm_open(struct vm_area_struct *vma)
+{
+       struct vme_user_vma_priv *vma_priv = vma->vm_private_data;
+
+       atomic_inc(&vma_priv->refcnt);
+}
+
+static void vme_user_vm_close(struct vm_area_struct *vma)
+{
+       struct vme_user_vma_priv *vma_priv = vma->vm_private_data;
+       unsigned int minor = vma_priv->minor;
+
+       if (!atomic_dec_and_test(&vma_priv->refcnt))
+               return;
+
+       mutex_lock(&image[minor].mutex);
+       image[minor].mmap_count--;
+       mutex_unlock(&image[minor].mutex);
+
+       kfree(vma_priv);
+}
+
+static int vme_user_master_mmap(unsigned int minor, struct vm_area_struct *vma)
+{
+       int err;
+       struct vme_user_vma_priv *vma_priv;
+
+       mutex_lock(&image[minor].mutex);
+
+       err = vme_master_mmap(image[minor].resource, vma);
+       if (err) {
+               mutex_unlock(&image[minor].mutex);
+               return err;
+       }
+
+       vma_priv = kmalloc(sizeof(struct vme_user_vma_priv), GFP_KERNEL);
+       if (vma_priv == NULL) {
+               mutex_unlock(&image[minor].mutex);
+               return -ENOMEM;
+       }
+
+       vma_priv->minor = minor;
+       atomic_set(&vma_priv->refcnt, 1);
+       vma->vm_ops = &vme_user_vm_ops;
+       vma->vm_private_data = vma_priv;
+
+       image[minor].mmap_count++;
+
+       mutex_unlock(&image[minor].mutex);
+
+       return 0;
+}
+
+static int vme_user_mmap(struct file *file, struct vm_area_struct *vma)
+{
+       unsigned int minor = MINOR(file_inode(file)->i_rdev);
+
+       if (type[minor] == MASTER_MINOR)
+               return vme_user_master_mmap(minor, vma);
+
+       return -ENODEV;
+}
+
 
 /*
  * Unallocate a previously allocated buffer
index 565ba189afb2abda8ad3b713f0dff17f971ec493..b0ea38f1911c1bdca61a95b25208126d141645d7 100644 (file)
@@ -2021,14 +2021,20 @@ bool BBbVT3253Init(struct vnt_private *priv)
        if (byRFType == RF_RFMD2959) {
                if (byLocalID <= REV_ID_VT3253_A1) {
                        for (ii = 0; ii < CB_VT3253_INIT_FOR_RFMD; ii++)
-                               bResult &= BBbWriteEmbedded(priv, byVT3253InitTab_RFMD[ii][0], byVT3253InitTab_RFMD[ii][1]);
+                               bResult &= BBbWriteEmbedded(priv,
+                                       byVT3253InitTab_RFMD[ii][0],
+                                       byVT3253InitTab_RFMD[ii][1]);
 
                } else {
                        for (ii = 0; ii < CB_VT3253B0_INIT_FOR_RFMD; ii++)
-                               bResult &= BBbWriteEmbedded(priv, byVT3253B0_RFMD[ii][0], byVT3253B0_RFMD[ii][1]);
+                               bResult &= BBbWriteEmbedded(priv,
+                                       byVT3253B0_RFMD[ii][0],
+                                       byVT3253B0_RFMD[ii][1]);
 
                        for (ii = 0; ii < CB_VT3253B0_AGC_FOR_RFMD2959; ii++)
-                               bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC4_RFMD2959[ii][0], byVT3253B0_AGC4_RFMD2959[ii][1]);
+                               bResult &= BBbWriteEmbedded(priv,
+                                       byVT3253B0_AGC4_RFMD2959[ii][0],
+                                       byVT3253B0_AGC4_RFMD2959[ii][1]);
 
                        VNSvOutPortD(dwIoBase + MAC_REG_ITRTMSET, 0x23);
                        MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0));
@@ -2043,10 +2049,13 @@ bool BBbVT3253Init(struct vnt_private *priv)
                priv->ldBmThreshold[3] = 0;
        } else if ((byRFType == RF_AIROHA) || (byRFType == RF_AL2230S)) {
                for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AIROHA2230[ii][0],
+                               byVT3253B0_AIROHA2230[ii][1]);
 
                for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
 
                priv->abyBBVGA[0] = 0x1C;
                priv->abyBBVGA[1] = 0x10;
@@ -2058,10 +2067,14 @@ bool BBbVT3253Init(struct vnt_private *priv)
                priv->ldBmThreshold[3] = 0;
        } else if (byRFType == RF_UW2451) {
                for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_UW2451[ii][0],
+                               byVT3253B0_UW2451[ii][1]);
 
                for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AGC[ii][0],
+                               byVT3253B0_AGC[ii][1]);
 
                VNSvOutPortB(dwIoBase + MAC_REG_ITRTMSET, 0x23);
                MACvRegBitsOn(dwIoBase, MAC_REG_PAPEDELAY, BIT(0));
@@ -2076,7 +2089,9 @@ bool BBbVT3253Init(struct vnt_private *priv)
                priv->ldBmThreshold[3] = 0;
        } else if (byRFType == RF_UW2452) {
                for (ii = 0; ii < CB_VT3253B0_INIT_FOR_UW2451; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_UW2451[ii][0], byVT3253B0_UW2451[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_UW2451[ii][0],
+                               byVT3253B0_UW2451[ii][1]);
 
                /* Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) */
                /*bResult &= BBbWriteEmbedded(dwIoBase,0x09,0x41);*/
@@ -2097,7 +2112,8 @@ bool BBbVT3253Init(struct vnt_private *priv)
                bResult &= BBbWriteEmbedded(priv, 0xb0, 0x58);
 
                for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
 
                priv->abyBBVGA[0] = 0x14;
                priv->abyBBVGA[1] = 0x0A;
@@ -2111,10 +2127,13 @@ bool BBbVT3253Init(struct vnt_private *priv)
 
        } else if (byRFType == RF_VT3226) {
                for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AIROHA2230[ii][0],
+                               byVT3253B0_AIROHA2230[ii][1]);
 
                for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
 
                priv->abyBBVGA[0] = 0x1C;
                priv->abyBBVGA[1] = 0x10;
@@ -2129,7 +2148,9 @@ bool BBbVT3253Init(struct vnt_private *priv)
                /* {{ RobertYu: 20050104 */
        } else if (byRFType == RF_AIROHA7230) {
                for (ii = 0; ii < CB_VT3253B0_INIT_FOR_AIROHA2230; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AIROHA2230[ii][0], byVT3253B0_AIROHA2230[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AIROHA2230[ii][0],
+                               byVT3253B0_AIROHA2230[ii][1]);
 
 
                /* {{ RobertYu:20050223, request by JerryChung */
@@ -2142,7 +2163,8 @@ bool BBbVT3253Init(struct vnt_private *priv)
                /* }} */
 
                for (ii = 0; ii < CB_VT3253B0_AGC; ii++)
-                       bResult &= BBbWriteEmbedded(priv, byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
+                       bResult &= BBbWriteEmbedded(priv,
+                               byVT3253B0_AGC[ii][0], byVT3253B0_AGC[ii][1]);
 
                priv->abyBBVGA[0] = 0x1C;
                priv->abyBBVGA[1] = 0x10;
index 3c17725d5910d1c2ccae323b3a56fc48b93bfbc9..7a717828fa09d37e11151d659c7514af430eb596 100644 (file)
@@ -193,7 +193,8 @@ bool set_channel(void *pDeviceHandler, struct ieee80211_channel *ch)
        /* clear NAV */
        MACvRegBitsOn(pDevice->PortOffset, MAC_REG_MACCR, MACCR_CLRNAV);
 
-       /* TX_PE will reserve 3 us for MAX2829 A mode only, it is for better TX throughput */
+       /* TX_PE will reserve 3 us for MAX2829 A mode only,
+          it is for better TX throughput */
 
        if (pDevice->byRFType == RF_AIROHA7230)
                RFbAL7230SelectChannelPostProcess(pDevice, pDevice->byCurrentCh,
@@ -217,9 +218,11 @@ bool set_channel(void *pDeviceHandler, struct ieee80211_channel *ch)
                /* set HW default power register */
                MACvSelectPage1(pDevice->PortOffset);
                RFbSetPower(pDevice, RATE_1M, pDevice->byCurrentCh);
-               VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK, pDevice->byCurPwr);
+               VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWRCCK,
+                            pDevice->byCurPwr);
                RFbSetPower(pDevice, RATE_6M, pDevice->byCurrentCh);
-               VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM, pDevice->byCurPwr);
+               VNSvOutPortB(pDevice->PortOffset + MAC_REG_PWROFDM,
+                            pDevice->byCurPwr);
                MACvSelectPage0(pDevice->PortOffset);
 
                spin_unlock_irqrestore(&pDevice->lock, flags);
index 03b2a90b9ac0b6f73109686b66623c61f0cd5ccb..4bb4f8ee41321a23134bcaf750ff3d2896350e82 100644 (file)
@@ -64,9 +64,9 @@
 #include <linux/slab.h>
 
 /*---------------------  Static Definitions -------------------------*/
-//
-// Define module options
-//
+/*
+ * Define module options
+ */
 MODULE_AUTHOR("VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver");
@@ -126,9 +126,9 @@ DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
 
 DEVICE_PARAM(BasebandType, "baseband type");
 
-//
-// Static vars definitions
-//
+/*
+ * Static vars definitions
+ */
 static CHIP_INFO chip_info_table[] = {
        { VT3253,       "VIA Networking Solomon-A/B/G Wireless LAN Adapter ",
          256, 1,     DEVICE_FLAGS_IP_ALIGN|DEVICE_FLAGS_TX_ALIGN },
@@ -231,9 +231,9 @@ device_set_options(struct vnt_private *pDevice)
        pr_debug(" byBBType= %d\n", (int)pDevice->byBBType);
 }
 
-//
-// Initialisation of MAC & BBP registers
-//
+/*
+ * Initialisation of MAC & BBP registers
+ */
 
 static void device_init_registers(struct vnt_private *pDevice)
 {
@@ -530,12 +530,12 @@ static bool device_init_rings(struct vnt_private *pDevice)
        void *vir_pool;
 
        /*allocate all RD/TD rings a single pool*/
-       vir_pool = pci_zalloc_consistent(pDevice->pcid,
+       vir_pool = dma_zalloc_coherent(&pDevice->pcid->dev,
                                         pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
                                         pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
                                         pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
                                         pDevice->sOpts.nTxDescs[1] * sizeof(STxDesc),
-                                        &pDevice->pool_dma);
+                                        &pDevice->pool_dma, GFP_ATOMIC);
        if (vir_pool == NULL) {
                dev_err(&pDevice->pcid->dev, "allocate desc dma memory failed\n");
                return false;
@@ -549,16 +549,17 @@ static bool device_init_rings(struct vnt_private *pDevice)
        pDevice->rd1_pool_dma = pDevice->rd0_pool_dma +
                pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc);
 
-       pDevice->tx0_bufs = pci_zalloc_consistent(pDevice->pcid,
+       pDevice->tx0_bufs = dma_zalloc_coherent(&pDevice->pcid->dev,
                                                  pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
                                                  pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
                                                  CB_BEACON_BUF_SIZE +
                                                  CB_MAX_BUF_SIZE,
-                                                 &pDevice->tx_bufs_dma0);
+                                                 &pDevice->tx_bufs_dma0,
+                                                 GFP_ATOMIC);
        if (pDevice->tx0_bufs == NULL) {
                dev_err(&pDevice->pcid->dev, "allocate buf dma memory failed\n");
 
-               pci_free_consistent(pDevice->pcid,
+               dma_free_coherent(&pDevice->pcid->dev,
                                    pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
                                    pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
                                    pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
@@ -574,7 +575,7 @@ static bool device_init_rings(struct vnt_private *pDevice)
        pDevice->td1_pool_dma = pDevice->td0_pool_dma +
                pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc);
 
-       // vir_pool: pvoid type
+       /* vir_pool: pvoid type */
        pDevice->apTD0Rings = vir_pool
                + pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc)
                + pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc);
@@ -604,7 +605,7 @@ static bool device_init_rings(struct vnt_private *pDevice)
 
 static void device_free_rings(struct vnt_private *pDevice)
 {
-       pci_free_consistent(pDevice->pcid,
+       dma_free_coherent(&pDevice->pcid->dev,
                            pDevice->sOpts.nRxDescs0 * sizeof(SRxDesc) +
                            pDevice->sOpts.nRxDescs1 * sizeof(SRxDesc) +
                            pDevice->sOpts.nTxDescs[0] * sizeof(STxDesc) +
@@ -614,7 +615,7 @@ static void device_free_rings(struct vnt_private *pDevice)
                );
 
        if (pDevice->tx0_bufs)
-               pci_free_consistent(pDevice->pcid,
+               dma_free_coherent(&pDevice->pcid->dev,
                                    pDevice->sOpts.nTxDescs[0] * PKT_BUF_SZ +
                                    pDevice->sOpts.nTxDescs[1] * PKT_BUF_SZ +
                                    CB_BEACON_BUF_SIZE +
@@ -679,8 +680,8 @@ static void device_free_rd0_ring(struct vnt_private *pDevice)
                PSRxDesc        pDesc = &(pDevice->aRD0Ring[i]);
                PDEVICE_RD_INFO  pRDInfo = pDesc->pRDInfo;
 
-               pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma,
-                                pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+               dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma,
+                                pDevice->rx_buf_sz, DMA_FROM_DEVICE);
 
                dev_kfree_skb(pRDInfo->skb);
 
@@ -696,8 +697,8 @@ static void device_free_rd1_ring(struct vnt_private *pDevice)
                PSRxDesc        pDesc = &(pDevice->aRD1Ring[i]);
                PDEVICE_RD_INFO  pRDInfo = pDesc->pRDInfo;
 
-               pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma,
-                                pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+               dma_unmap_single(&pDevice->pcid->dev, pRDInfo->skb_dma,
+                                pDevice->rx_buf_sz, DMA_FROM_DEVICE);
 
                dev_kfree_skb(pRDInfo->skb);
 
@@ -765,8 +766,8 @@ static void device_free_td0_ring(struct vnt_private *pDevice)
                PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
 
                if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
-                       pci_unmap_single(pDevice->pcid, pTDInfo->skb_dma,
-                                        pTDInfo->skb->len, PCI_DMA_TODEVICE);
+                       dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
+                                        pTDInfo->skb->len, DMA_TO_DEVICE);
 
                if (pTDInfo->skb)
                        dev_kfree_skb(pTDInfo->skb);
@@ -784,8 +785,8 @@ static void device_free_td1_ring(struct vnt_private *pDevice)
                PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
 
                if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma))
-                       pci_unmap_single(pDevice->pcid, pTDInfo->skb_dma,
-                                        pTDInfo->skb->len, PCI_DMA_TODEVICE);
+                       dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
+                                        pTDInfo->skb->len, DMA_TO_DEVICE);
 
                if (pTDInfo->skb)
                        dev_kfree_skb(pTDInfo->skb);
@@ -831,9 +832,9 @@ static bool device_alloc_rx_buf(struct vnt_private *pDevice, PSRxDesc pRD)
        ASSERT(pRDInfo->skb);
 
        pRDInfo->skb_dma =
-               pci_map_single(pDevice->pcid,
+               dma_map_single(&pDevice->pcid->dev,
                               skb_put(pRDInfo->skb, skb_tailroom(pRDInfo->skb)),
-                              pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
+                              pDevice->rx_buf_sz, DMA_FROM_DEVICE);
 
        *((unsigned int *)&(pRD->m_rd0RD0)) = 0; /* FIX cast */
 
@@ -933,7 +934,7 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx)
                byTsr0 = pTD->m_td0TD0.byTSR0;
                byTsr1 = pTD->m_td0TD0.byTSR1;
 
-               //Only the status of first TD in the chain is correct
+               /* Only the status of first TD in the chain is correct */
                if (pTD->m_td1TD1.byTCR & TCR_STP) {
                        if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) {
 
@@ -982,10 +983,10 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc)
        PDEVICE_TD_INFO  pTDInfo = pDesc->pTDInfo;
        struct sk_buff *skb = pTDInfo->skb;
 
-       // pre-allocated buf_dma can't be unmapped.
+       /* pre-allocated buf_dma can't be unmapped. */
        if (pTDInfo->skb_dma && (pTDInfo->skb_dma != pTDInfo->buf_dma)) {
-               pci_unmap_single(pDevice->pcid, pTDInfo->skb_dma, skb->len,
-                                PCI_DMA_TODEVICE);
+               dma_unmap_single(&pDevice->pcid->dev, pTDInfo->skb_dma,
+                                skb->len, DMA_TO_DEVICE);
        }
 
        if (pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)
@@ -1074,7 +1075,7 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance)
 
        spin_lock_irqsave(&pDevice->lock, flags);
 
-       //Make sure current page is 0
+       /* Make sure current page is 0 */
        VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
        if (byOrgPageSel == 1)
                MACvSelectPage0(pDevice->PortOffset);
@@ -1082,10 +1083,12 @@ static  irqreturn_t  device_intr(int irq,  void *dev_instance)
                byOrgPageSel = 0;
 
        MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
-       // TBD....
-       // Must do this after doing rx/tx, cause ISR bit is slow
-       // than RD/TD write back
-       // update ISR counter
+       /*
+        * TBD....
+        * Must do this after doing rx/tx, cause ISR bit is slow
+        * than RD/TD write back
+        * update ISR counter
+        */
        STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter);
        while (pDevice->dwIsr != 0) {
                STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
index 3c5b87ffdcaccbfb50ddfb3a602bda84f774ad66..b25ee962558d786776df34cedcbefe5ee9999b7a 100644 (file)
@@ -140,8 +140,8 @@ bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd)
 
        skb = rd_info->skb;
 
-       pci_unmap_single(priv->pcid, rd_info->skb_dma,
-                        priv->rx_buf_sz, PCI_DMA_FROMDEVICE);
+       dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
+                        priv->rx_buf_sz, DMA_FROM_DEVICE);
 
        frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount)
                        - cpu_to_le16(curr_rd->m_rd0RD0.wResCount);
index c01d4afb6ab8c5d6ddcd4e306d3ca0a516e92cc8..261f8181d4105ac6f1793d4c5118fa276e02cc84 100644 (file)
@@ -66,4 +66,4 @@ int vnt_key_init_table(struct vnt_private *);
 int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
                 struct ieee80211_vif *vif, struct ieee80211_key_conf *key);
 
-#endif // __KEY_H__
+#endif /* __KEY_H__ */
index 3653a2bd1e36014d39e2454d74cd8258785ed6c9..8048b3263360828b3f5c819df7505e030998fa85 100644 (file)
@@ -141,7 +141,7 @@ bool MACbIsIntDisable(void __iomem *dwIoBase)
  */
 void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit)
 {
-       // set SRT
+       /* set SRT */
        VNSvOutPortB(dwIoBase + MAC_REG_SRT, byRetryLimit);
 }
 
@@ -162,7 +162,7 @@ void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit)
  */
 void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit)
 {
-       // set LRT
+       /* set LRT */
        VNSvOutPortB(dwIoBase + MAC_REG_LRT, byRetryLimit);
 }
 
@@ -186,7 +186,7 @@ void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode)
 
        ASSERT(byLoopbackMode < 3);
        byLoopbackMode <<= 6;
-       // set TCR
+       /* set TCR */
        VNSvInPortB(dwIoBase + MAC_REG_TEST, &byOrgValue);
        byOrgValue = byOrgValue & 0x3F;
        byOrgValue = byOrgValue | byLoopbackMode;
@@ -210,13 +210,13 @@ void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
 {
        int         ii;
 
-       // read page0 register
+       /* read page0 register */
        for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE0; ii++)
                VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + ii));
 
        MACvSelectPage1(dwIoBase);
 
-       // read page1 register
+       /* read page1 register */
        for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++)
                VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
 
@@ -242,27 +242,27 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
        int         ii;
 
        MACvSelectPage1(dwIoBase);
-       // restore page1
+       /* restore page1 */
        for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++)
                VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
 
        MACvSelectPage0(dwIoBase);
 
-       // restore RCR,TCR,IMR...
+       /* restore RCR,TCR,IMR... */
        for (ii = MAC_REG_RCR; ii < MAC_REG_ISR; ii++)
                VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
 
-       // restore MAC Config.
+       /* restore MAC Config. */
        for (ii = MAC_REG_LRT; ii < MAC_REG_PAGE1SEL; ii++)
                VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
 
        VNSvOutPortB(dwIoBase + MAC_REG_CFG, *(pbyCxtBuf + MAC_REG_CFG));
 
-       // restore PS Config.
+       /* restore PS Config. */
        for (ii = MAC_REG_PSCFG; ii < MAC_REG_BBREGCTL; ii++)
                VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
 
-       // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
+       /* restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR */
        VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0));
        VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR));
        VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR));
@@ -290,7 +290,7 @@ bool MACbSoftwareReset(void __iomem *dwIoBase)
        unsigned char byData;
        unsigned short ww;
 
-       // turn on HOSTCR_SOFTRST, just write 0x01 to reset
+       /* turn on HOSTCR_SOFTRST, just write 0x01 to reset */
        VNSvOutPortB(dwIoBase + MAC_REG_HOSTCR, 0x01);
 
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
@@ -321,15 +321,15 @@ bool MACbSafeSoftwareReset(void __iomem *dwIoBase)
        unsigned char abyTmpRegData[MAC_MAX_CONTEXT_SIZE_PAGE0+MAC_MAX_CONTEXT_SIZE_PAGE1];
        bool bRetVal;
 
-       // PATCH....
-       // save some important register's value, then do
-       // reset, then restore register's value
-
-       // save MAC context
+       /* PATCH....
+        * save some important register's value, then do
+        * reset, then restore register's value
+        */
+       /* save MAC context */
        MACvSaveContext(dwIoBase, abyTmpRegData);
-       // do reset
+       /* do reset */
        bRetVal = MACbSoftwareReset(dwIoBase);
-       // restore MAC context, except CR0
+       /* restore MAC context, except CR0 */
        MACvRestoreContext(dwIoBase, abyTmpRegData);
 
        return bRetVal;
@@ -354,9 +354,9 @@ bool MACbSafeRxOff(void __iomem *dwIoBase)
        unsigned long dwData;
        unsigned char byData;
 
-       // turn off wow temp for turn off Rx safely
+       /* turn off wow temp for turn off Rx safely */
 
-       // Clear RX DMA0,1
+       /* Clear RX DMA0,1 */
        VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL0, DMACTL_CLRRUN);
        VNSvOutPortD(dwIoBase + MAC_REG_RXDMACTL1, DMACTL_CLRRUN);
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
@@ -380,9 +380,9 @@ bool MACbSafeRxOff(void __iomem *dwIoBase)
                return false;
        }
 
-       // try to safe shutdown RX
+       /* try to safe shutdown RX */
        MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_RXON);
-       // W_MAX_TIMEOUT is the timeout period
+       /* W_MAX_TIMEOUT is the timeout period */
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
                VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData);
                if (!(byData & HOSTCR_RXONST))
@@ -415,10 +415,10 @@ bool MACbSafeTxOff(void __iomem *dwIoBase)
        unsigned long dwData;
        unsigned char byData;
 
-       // Clear TX DMA
-       //Tx0
+       /* Clear TX DMA */
+       /* Tx0 */
        VNSvOutPortD(dwIoBase + MAC_REG_TXDMACTL0, DMACTL_CLRRUN);
-       //AC0
+       /* AC0 */
        VNSvOutPortD(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_CLRRUN);
 
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
@@ -442,10 +442,10 @@ bool MACbSafeTxOff(void __iomem *dwIoBase)
                return false;
        }
 
-       // try to safe shutdown TX
+       /* try to safe shutdown TX */
        MACvRegBitsOff(dwIoBase, MAC_REG_HOSTCR, HOSTCR_TXON);
 
-       // W_MAX_TIMEOUT is the timeout period
+       /* W_MAX_TIMEOUT is the timeout period */
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
                VNSvInPortB(dwIoBase + MAC_REG_HOSTCR, &byData);
                if (!(byData & HOSTCR_TXONST))
@@ -509,10 +509,10 @@ bool MACbSafeStop(void __iomem *dwIoBase)
  */
 bool MACbShutdown(void __iomem *dwIoBase)
 {
-       // disable MAC IMR
+       /* disable MAC IMR */
        MACvIntDisable(dwIoBase);
        MACvSetLoopbackMode(dwIoBase, MAC_LB_INTERNAL);
-       // stop the adapter
+       /* stop the adapter */
        if (!MACbSafeStop(dwIoBase)) {
                MACvSetLoopbackMode(dwIoBase, MAC_LB_NONE);
                return false;
@@ -536,18 +536,18 @@ bool MACbShutdown(void __iomem *dwIoBase)
  */
 void MACvInitialize(void __iomem *dwIoBase)
 {
-       // clear sticky bits
+       /* clear sticky bits */
        MACvClearStckDS(dwIoBase);
-       // disable force PME-enable
+       /* disable force PME-enable */
        VNSvOutPortB(dwIoBase + MAC_REG_PMC1, PME_OVR);
-       // only 3253 A
+       /* only 3253 A */
 
-       // do reset
+       /* do reset */
        MACbSoftwareReset(dwIoBase);
 
-       // reset TSF counter
+       /* reset TSF counter */
        VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
-       // enable TSF counter
+       /* enable TSF counter */
        VNSvOutPortB(dwIoBase + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
 }
 
@@ -678,7 +678,7 @@ void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd
  * Return Value: none
  *
  */
-//TxDMA1 = AC0DMA
+/* TxDMA1 = AC0DMA */
 void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
        unsigned short ww;
@@ -733,7 +733,7 @@ void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay)
        VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
        VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelay);
        VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, (TMCTL_TMD | TMCTL_TE));
-       for (ii = 0; ii < 66; ii++) {  // assume max PCI clock is 66Mhz
+       for (ii = 0; ii < 66; ii++) {  /* assume max PCI clock is 66Mhz */
                for (uu = 0; uu < uDelay; uu++) {
                        VNSvInPortB(dwIoBase + MAC_REG_TMCTL0, &byValue);
                        if ((byValue == 0) ||
@@ -780,14 +780,14 @@ bool MACbPSWakeup(void __iomem *dwIoBase)
 {
        unsigned char byOrgValue;
        unsigned int ww;
-       // Read PSCTL
+       /* Read PSCTL */
        if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS))
                return true;
 
-       // Disable PS
+       /* Disable PS */
        MACvRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PSEN);
 
-       // Check if SyncFlushOK
+       /* Check if SyncFlushOK */
        for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
                VNSvInPortB(dwIoBase + MAC_REG_PSCTL, &byOrgValue);
                if (byOrgValue & PSCTL_WAKEDONE)
@@ -859,7 +859,7 @@ void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned in
 
        wOffset += (uKeyIdx * 4);
        for (ii = 0; ii < 4; ii++) {
-               // always push 128 bits
+               /* always push 128 bits */
                pr_debug("3.(%d) wOffset: %d, Data: %X\n",
                         ii, wOffset+ii, *pdwKey);
                VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset+ii);
index d2f351d19ff8a84df5d197f5175b0c4e735cd04c..d55c762027ed4f44e9592b1a037ed88aa6480ced 100644 (file)
@@ -63,51 +63,51 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr)
        /**********************/
        /* ABNORMAL interrupt */
        /**********************/
-       // not any IMR bit invoke irq
+       /* not any IMR bit invoke irq */
 
        if (dwIsr == 0) {
                pStatistic->ISRStat.dwIsrUnknown++;
                return;
        }
 
-//Added by Kyle
-       if (dwIsr & ISR_TXDMA0)               // ISR, bit0
-               pStatistic->ISRStat.dwIsrTx0OK++;             // TXDMA0 successful
+/* Added by Kyle */
+       if (dwIsr & ISR_TXDMA0)               /* ISR, bit0 */
+               pStatistic->ISRStat.dwIsrTx0OK++;             /* TXDMA0 successful */
 
-       if (dwIsr & ISR_AC0DMA)               // ISR, bit1
-               pStatistic->ISRStat.dwIsrAC0TxOK++;           // AC0DMA successful
+       if (dwIsr & ISR_AC0DMA)               /* ISR, bit1 */
+               pStatistic->ISRStat.dwIsrAC0TxOK++;           /* AC0DMA successful */
 
-       if (dwIsr & ISR_BNTX)                 // ISR, bit2
-               pStatistic->ISRStat.dwIsrBeaconTxOK++;        // BeaconTx successful
+       if (dwIsr & ISR_BNTX)                 /* ISR, bit2 */
+               pStatistic->ISRStat.dwIsrBeaconTxOK++;        /* BeaconTx successful */
 
-       if (dwIsr & ISR_RXDMA0)               // ISR, bit3
-               pStatistic->ISRStat.dwIsrRx0OK++;             // Rx0 successful
+       if (dwIsr & ISR_RXDMA0)               /* ISR, bit3 */
+               pStatistic->ISRStat.dwIsrRx0OK++;             /* Rx0 successful */
 
-       if (dwIsr & ISR_TBTT)                 // ISR, bit4
-               pStatistic->ISRStat.dwIsrTBTTInt++;           // TBTT successful
+       if (dwIsr & ISR_TBTT)                 /* ISR, bit4 */
+               pStatistic->ISRStat.dwIsrTBTTInt++;           /* TBTT successful */
 
-       if (dwIsr & ISR_SOFTTIMER)            // ISR, bit6
+       if (dwIsr & ISR_SOFTTIMER)            /* ISR, bit6 */
                pStatistic->ISRStat.dwIsrSTIMERInt++;
 
-       if (dwIsr & ISR_WATCHDOG)             // ISR, bit7
+       if (dwIsr & ISR_WATCHDOG)             /* ISR, bit7 */
                pStatistic->ISRStat.dwIsrWatchDog++;
 
-       if (dwIsr & ISR_FETALERR)             // ISR, bit8
+       if (dwIsr & ISR_FETALERR)             /* ISR, bit8 */
                pStatistic->ISRStat.dwIsrUnrecoverableError++;
 
-       if (dwIsr & ISR_SOFTINT)              // ISR, bit9
-               pStatistic->ISRStat.dwIsrSoftInterrupt++;     // software interrupt
+       if (dwIsr & ISR_SOFTINT)              /* ISR, bit9 */
+               pStatistic->ISRStat.dwIsrSoftInterrupt++;     /* software interrupt */
 
-       if (dwIsr & ISR_MIBNEARFULL)          // ISR, bit10
+       if (dwIsr & ISR_MIBNEARFULL)          /* ISR, bit10 */
                pStatistic->ISRStat.dwIsrMIBNearfull++;
 
-       if (dwIsr & ISR_RXNOBUF)              // ISR, bit11
-               pStatistic->ISRStat.dwIsrRxNoBuf++;           // Rx No Buff
+       if (dwIsr & ISR_RXNOBUF)              /* ISR, bit11 */
+               pStatistic->ISRStat.dwIsrRxNoBuf++;           /* Rx No Buff */
 
-       if (dwIsr & ISR_RXDMA1)               // ISR, bit12
-               pStatistic->ISRStat.dwIsrRx1OK++;             // Rx1 successful
+       if (dwIsr & ISR_RXDMA1)               /* ISR, bit12 */
+               pStatistic->ISRStat.dwIsrRx1OK++;             /* Rx1 successful */
 
-       if (dwIsr & ISR_SOFTTIMER1)           // ISR, bit21
+       if (dwIsr & ISR_SOFTTIMER1)           /* ISR, bit21 */
                pStatistic->ISRStat.dwIsrSTIMER1Int++;
 }
 
index 07ce3fd88e70dd69595816fe7af72fb2db21baf1..5b869d1f9e40450998f917fc3cedcc8b016b8ace 100644 (file)
 /*---------------------  Static Functions  --------------------------*/
 
 /*---------------------  Static Definitions -------------------------*/
-#define CRITICAL_PACKET_LEN      256    // if packet size < 256 -> in-direct send
-                                        //    packet size >= 256 -> direct send
+#define CRITICAL_PACKET_LEN      256    /* if packet size < 256 -> in-direct send
+                                            packet size >= 256 -> direct send */
 
 static const unsigned short wTimeStampOff[2][MAX_RATE] = {
-       {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
-       {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble
+       {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, /* Long Preamble */
+       {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, /* Short Preamble */
 };
 
 static const unsigned short wFB_Opt0[2][5] = {
-       {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, // fallback_rate0
-       {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, // fallback_rate1
+       {RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M}, /* fallback_rate0 */
+       {RATE_12M, RATE_12M, RATE_18M, RATE_24M, RATE_36M}, /* fallback_rate1 */
 };
 static const unsigned short wFB_Opt1[2][5] = {
-       {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, // fallback_rate0
-       {RATE_6M , RATE_6M,  RATE_12M, RATE_12M, RATE_18M}, // fallback_rate1
+       {RATE_12M, RATE_18M, RATE_24M, RATE_24M, RATE_36M}, /* fallback_rate0 */
+       {RATE_6M , RATE_6M,  RATE_12M, RATE_12M, RATE_18M}, /* fallback_rate1 */
 };
 
 #define RTSDUR_BB       0
@@ -176,9 +176,9 @@ s_uGetTxRsvTime(
        unsigned int uDataTime, uAckTime;
 
        uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate);
-       if (byPktType == PK_TYPE_11B) //llb,CCK mode
+       if (byPktType == PK_TYPE_11B) /* llb,CCK mode */
                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopCCKBasicRate);
-       else //11g 2.4G OFDM mode & 11a 5G OFDM mode
+       else /* 11g 2.4G OFDM mode & 11a 5G OFDM mode */
                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, (unsigned short)pDevice->byTopOFDMBasicRate);
 
        if (bNeedAck)
@@ -194,7 +194,7 @@ static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type,
                                                frame_length, rate, need_ack));
 }
 
-//byFreqType: 0=>5GHZ 1=>2.4GHZ
+/* byFreqType: 0=>5GHZ 1=>2.4GHZ */
 static
 __le16
 s_uGetRTSCTSRsvTime(
@@ -210,29 +210,29 @@ s_uGetRTSCTSRsvTime(
        uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0;
 
        uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate);
-       if (byRTSRsvType == 0) { //RTSTxRrvTime_bb
+       if (byRTSRsvType == 0) { /* RTSTxRrvTime_bb */
                uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate);
                uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
-       } else if (byRTSRsvType == 1) { //RTSTxRrvTime_ba, only in 2.4GHZ
+       } else if (byRTSRsvType == 1) { /* RTSTxRrvTime_ba, only in 2.4GHZ */
                uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate);
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
-       } else if (byRTSRsvType == 2) { //RTSTxRrvTime_aa
+       } else if (byRTSRsvType == 2) { /* RTSTxRrvTime_aa */
                uRTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate);
                uCTSTime = uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
-       } else if (byRTSRsvType == 3) { //CTSTxRrvTime_ba, only in 2.4GHZ
+       } else if (byRTSRsvType == 3) { /* CTSTxRrvTime_ba, only in 2.4GHZ */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->uSIFS;
                return cpu_to_le16((u16)uRrvTime);
        }
 
-       //RTSRrvTime
+       /* RTSRrvTime */
        uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS;
        return cpu_to_le16((u16)uRrvTime);
 }
 
-//byFreqType 0: 5GHz, 1:2.4Ghz
+/* byFreqType 0: 5GHz, 1:2.4Ghz */
 static
 unsigned int
 s_uGetDataDuration(
@@ -248,22 +248,22 @@ s_uGetDataDuration(
        unsigned char byFBOption
 )
 {
-       bool bLastFrag = 0;
+       bool bLastFrag = false;
        unsigned int uAckTime = 0, uNextPktTime = 0;
 
        if (uFragIdx == (uMACfragNum-1))
-               bLastFrag = 1;
+               bLastFrag = true;
 
        switch (byDurType) {
-       case DATADUR_B:    //DATADUR_B
-               if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag
+       case DATADUR_B:    /* DATADUR_B */
+               if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */
                        if (bNeedAck) {
                                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                                return pDevice->uSIFS + uAckTime;
                        } else {
                                return 0;
                        }
-               } else {//First Frag or Mid Frag
+               } else {/* First Frag or Mid Frag */
                        if (uFragIdx == (uMACfragNum-2))
                                uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
                        else
@@ -278,15 +278,15 @@ s_uGetDataDuration(
                }
                break;
 
-       case DATADUR_A:    //DATADUR_A
-               if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag
+       case DATADUR_A:    /* DATADUR_A */
+               if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */
                        if (bNeedAck) {
                                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                                return pDevice->uSIFS + uAckTime;
                        } else {
                                return 0;
                        }
-               } else {//First Frag or Mid Frag
+               } else {/* First Frag or Mid Frag */
                        if (uFragIdx == (uMACfragNum-2))
                                uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
                        else
@@ -301,15 +301,15 @@ s_uGetDataDuration(
                }
                break;
 
-       case DATADUR_A_F0:    //DATADUR_A_F0
-               if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag
+       case DATADUR_A_F0:    /* DATADUR_A_F0 */
+               if (((uMACfragNum == 1)) || bLastFrag) {/* Non Frag or Last Frag */
                        if (bNeedAck) {
                                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                                return pDevice->uSIFS + uAckTime;
                        } else {
                                return 0;
                        }
-               } else { //First Frag or Mid Frag
+               } else { /* First Frag or Mid Frag */
                        if (byFBOption == AUTO_FB_0) {
                                if (wRate < RATE_18M)
                                        wRate = RATE_18M;
@@ -321,7 +321,7 @@ s_uGetDataDuration(
                                else
                                        uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
 
-                       } else { // (byFBOption == AUTO_FB_1)
+                       } else { /* (byFBOption == AUTO_FB_1) */
                                if (wRate < RATE_18M)
                                        wRate = RATE_18M;
                                else if (wRate > RATE_54M)
@@ -343,15 +343,15 @@ s_uGetDataDuration(
                }
                break;
 
-       case DATADUR_A_F1:    //DATADUR_A_F1
-               if (((uMACfragNum == 1)) || bLastFrag) {//Non Frag or Last Frag
+       case DATADUR_A_F1:    /* DATADUR_A_F1 */
+               if (((uMACfragNum == 1)) || bLastFrag) { /* Non Frag or Last Frag */
                        if (bNeedAck) {
                                uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                                return pDevice->uSIFS + uAckTime;
                        } else {
                                return 0;
                        }
-               } else { //First Frag or Mid Frag
+               } else { /* First Frag or Mid Frag */
                        if (byFBOption == AUTO_FB_0) {
                                if (wRate < RATE_18M)
                                        wRate = RATE_18M;
@@ -363,7 +363,7 @@ s_uGetDataDuration(
                                else
                                        uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
 
-                       } else { // (byFBOption == AUTO_FB_1)
+                       } else { /* (byFBOption == AUTO_FB_1) */
                                if (wRate < RATE_18M)
                                        wRate = RATE_18M;
                                else if (wRate > RATE_54M)
@@ -391,7 +391,7 @@ s_uGetDataDuration(
        return 0;
 }
 
-//byFreqType: 0=>5GHZ 1=>2.4GHZ
+/* byFreqType: 0=>5GHZ 1=>2.4GHZ */
 static
 __le16
 s_uGetRTSCTSDuration(
@@ -407,26 +407,26 @@ s_uGetRTSCTSDuration(
        unsigned int uCTSTime = 0, uDurTime = 0;
 
        switch (byDurType) {
-       case RTSDUR_BB:    //RTSDuration_bb
+       case RTSDUR_BB:    /* RTSDuration_bb */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
                break;
 
-       case RTSDUR_BA:    //RTSDuration_ba
+       case RTSDUR_BA:    /* RTSDuration_ba */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
                break;
 
-       case RTSDUR_AA:    //RTSDuration_aa
+       case RTSDUR_AA:    /* RTSDuration_aa */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
                break;
 
-       case CTSDUR_BA:    //CTSDuration_ba
+       case CTSDUR_BA:    /* CTSDuration_ba */
                uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
                break;
 
-       case RTSDUR_BA_F0: //RTSDuration_ba_f0
+       case RTSDUR_BA_F0: /* RTSDuration_ba_f0 */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = uCTSTime + 2 * pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
@@ -435,7 +435,7 @@ s_uGetRTSCTSDuration(
 
                break;
 
-       case RTSDUR_AA_F0: //RTSDuration_aa_f0
+       case RTSDUR_AA_F0: /* RTSDuration_aa_f0 */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
@@ -444,7 +444,7 @@ s_uGetRTSCTSDuration(
 
                break;
 
-       case RTSDUR_BA_F1: //RTSDuration_ba_f1
+       case RTSDUR_BA_F1: /* RTSDuration_ba_f1 */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate);
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
@@ -453,7 +453,7 @@ s_uGetRTSCTSDuration(
 
                break;
 
-       case RTSDUR_AA_F1: //RTSDuration_aa_f1
+       case RTSDUR_AA_F1: /* RTSDuration_aa_f1 */
                uCTSTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate);
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = uCTSTime + 2*pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
@@ -462,7 +462,7 @@ s_uGetRTSCTSDuration(
 
                break;
 
-       case CTSDUR_BA_F0: //CTSDuration_ba_f0
+       case CTSDUR_BA_F0: /* CTSDuration_ba_f0 */
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck);
                else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
@@ -470,7 +470,7 @@ s_uGetRTSCTSDuration(
 
                break;
 
-       case CTSDUR_BA_F1: //CTSDuration_ba_f1
+       case CTSDUR_BA_F1: /* CTSDuration_ba_f1 */
                if ((byFBOption == AUTO_FB_0) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
                        uDurTime = pDevice->uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck);
                else if ((byFBOption == AUTO_FB_1) && (wRate >= RATE_18M) && (wRate <= RATE_54M))
@@ -565,7 +565,7 @@ s_uFillDataHead(
                        buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate);
 
                        return buf->duration_a;
-               } //if (byFBOption == AUTO_FB_NONE)
+               } /* if (byFBOption == AUTO_FB_NONE) */
        } else if (byPktType == PK_TYPE_11A) {
                if ((byFBOption != AUTO_FB_NONE)) {
                        /* Auto Fallback */
@@ -651,13 +651,13 @@ s_vFillRTSHead(
                return;
 
        if (bDisCRC) {
-               // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame,
-               // in this case we need to decrease its length by 4.
+               /* When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame,
+                in this case we need to decrease its length by 4. */
                uRTSFrameLen -= 4;
        }
 
-       // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
-       //       Otherwise, we need to modify codes for them.
+       /* Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
+              Otherwise, we need to modify codes for them. */
        if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
                if (byFBOption == AUTO_FB_NONE) {
                        struct vnt_rts_g *buf = pvRTS;
@@ -748,7 +748,7 @@ s_vFillRTSHead(
 
                        ether_addr_copy(buf->data.ra, hdr->addr1);
                        ether_addr_copy(buf->data.ta, hdr->addr2);
-               } // if (byFBOption == AUTO_FB_NONE)
+               } /* if (byFBOption == AUTO_FB_NONE) */
        } else if (byPktType == PK_TYPE_11A) {
                if (byFBOption == AUTO_FB_NONE) {
                        struct vnt_rts_ab *buf = pvRTS;
@@ -843,14 +843,14 @@ s_vFillCTSHead(
                return;
 
        if (bDisCRC) {
-               // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame,
-               // in this case we need to decrease its length by 4.
+               /* When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame,
+                in this case we need to decrease its length by 4. */
                uCTSFrameLen -= 4;
        }
 
        if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
                if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) {
-                       // Auto Fall back
+                       /* Auto Fall back */
                        struct vnt_cts_fb *buf = pvCTS;
                        /* Get SignalField, ServiceField & Length */
                        vnt_get_phy_field(pDevice, uCTSFrameLen,
@@ -888,7 +888,7 @@ s_vFillCTSHead(
 
                        ether_addr_copy(buf->data.ra,
                                        pDevice->abyCurrentNetAddr);
-               } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
+               } else { /* if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) */
                        struct vnt_cts *buf = pvCTS;
                        /* Get SignalField, ServiceField & Length */
                        vnt_get_phy_field(pDevice, uCTSFrameLen,
@@ -937,8 +937,8 @@ s_vFillCTSHead(
  *
  * Return Value: none
  *
- -*/
-// unsigned int cbFrameSize,//Hdr+Payload+FCS
+ -
+ * unsigned int cbFrameSize, Hdr+Payload+FCS */
 static
 void
 s_vGenerateTxParameter(
@@ -976,8 +976,8 @@ s_vGenerateTxParameter(
                return;
 
        if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
-               if (pvRTS != NULL) { //RTS_need
-                       /* Fill RsvTime */
+               if (pvRTS != NULL) { /RTS_need
+                        Fill RsvTime */
                        struct vnt_rrv_time_rts *buf = pvRrvTime;
 
                        buf->rts_rrv_time_aa = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate);
@@ -987,40 +987,40 @@ s_vGenerateTxParameter(
                        buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK);
 
                        s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
-               } else {//RTS_needless, PCF mode
+               } else {/* RTS_needless, PCF mode */
                        struct vnt_rrv_time_cts *buf = pvRrvTime;
 
                        buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK);
                        buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK);
                        buf->cts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate);
 
-                       //Fill CTS
+                       /* Fill CTS */
                        s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption);
                }
        } else if (byPktType == PK_TYPE_11A) {
-               if (pvRTS != NULL) {//RTS_need, non PCF mode
+               if (pvRTS != NULL) {/* RTS_need, non PCF mode */
                        struct vnt_rrv_time_ab *buf = pvRrvTime;
 
                        buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate);
                        buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK);
 
-                       //Fill RTS
+                       /* Fill RTS */
                        s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
-               } else if (pvRTS == NULL) {//RTS_needless, non PCF mode
+               } else if (pvRTS == NULL) {/* RTS_needless, non PCF mode */
                        struct vnt_rrv_time_ab *buf = pvRrvTime;
 
                        buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK);
                }
        } else if (byPktType == PK_TYPE_11B) {
-               if ((pvRTS != NULL)) {//RTS_need, non PCF mode
+               if ((pvRTS != NULL)) {/* RTS_need, non PCF mode */
                        struct vnt_rrv_time_ab *buf = pvRrvTime;
 
                        buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate);
                        buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK);
 
-                       //Fill RTS
+                       /* Fill RTS */
                        s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
-               } else { //RTS_needless, non PCF mode
+               } else { /* RTS_needless, non PCF mode */
                        struct vnt_rrv_time_ab *buf = pvRrvTime;
 
                        buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK);
@@ -1058,7 +1058,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
        void *pvRTS;
        void *pvCTS;
        void *pvTxDataHd;
-       unsigned short wTxBufSize;   // FFinfo size
+       unsigned short wTxBufSize;   /* FFinfo size */
        unsigned char byFBOption = AUTO_FB_NONE;
 
        pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL;
@@ -1076,27 +1076,27 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                cbFrameSize += info->control.hw_key->icv_len;
 
                if (pDevice->byLocalID > REV_ID_VT3253_A1) {
-                       //MAC Header should be padding 0 to DW alignment.
+                       /* MAC Header should be padding 0 to DW alignment. */
                        uPadding = 4 - (ieee80211_get_hdrlen_from_skb(skb) % 4);
                        uPadding %= 4;
                }
        }
 
-       //
-       // Use for AUTO FALL BACK
-       //
+       /*
+       * Use for AUTO FALL BACK
+       */
        if (fifo_ctl & FIFOCTL_AUTO_FB_0)
                byFBOption = AUTO_FB_0;
        else if (fifo_ctl & FIFOCTL_AUTO_FB_1)
                byFBOption = AUTO_FB_1;
 
-       //////////////////////////////////////////////////////
-       //Set RrvTime/RTS/CTS Buffer
+
+       /* Set RrvTime/RTS/CTS Buffer */
        wTxBufSize = sizeof(STxBufHead);
-       if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet
+       if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {/* 802.11g packet */
 
                if (byFBOption == AUTO_FB_NONE) {
-                       if (bRTS == true) {//RTS_need
+                       if (bRTS == true) {/* RTS_need */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts));
                                pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR);
@@ -1106,7 +1106,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) +
                                                        cbMICHDR + sizeof(struct vnt_rts_g) +
                                                        sizeof(struct vnt_tx_datahead_g);
-                       } else { //RTS_needless
+                       } else { /* RTS_needless */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts));
                                pvRTS = NULL;
@@ -1117,8 +1117,8 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                                        cbMICHDR + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g);
                        }
                } else {
-                       // Auto Fall Back
-                       if (bRTS == true) {//RTS_need
+                       /* Auto Fall Back */
+                       if (bRTS == true) {/* RTS_need */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts));
                                pvRTS = (void *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR);
@@ -1127,7 +1127,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                        cbMICHDR + sizeof(struct vnt_rts_g_fb));
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) +
                                        cbMICHDR + sizeof(struct vnt_rts_g_fb) + sizeof(struct vnt_tx_datahead_g_fb);
-                       } else { //RTS_needless
+                       } else { /* RTS_needless */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts));
                                pvRTS = NULL;
@@ -1137,8 +1137,8 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) +
                                        cbMICHDR + sizeof(struct vnt_cts_fb) + sizeof(struct vnt_tx_datahead_g_fb);
                        }
-               } // Auto Fall Back
-       } else {//802.11a/b packet
+               } /* Auto Fall Back */
+       } else {/* 802.11a/b packet */
 
                if (byFBOption == AUTO_FB_NONE) {
                        if (bRTS == true) {
@@ -1150,7 +1150,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                        sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab));
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
                                        cbMICHDR + sizeof(struct vnt_rts_ab) + sizeof(struct vnt_tx_datahead_ab);
-                       } else { //RTS_needless, need MICHDR
+                       } else { /* RTS_needless, need MICHDR */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab));
                                pvRTS = NULL;
@@ -1160,8 +1160,8 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                        cbMICHDR + sizeof(struct vnt_tx_datahead_ab);
                        }
                } else {
-                       // Auto Fall Back
-                       if (bRTS == true) {//RTS_need
+                       /* Auto Fall Back */
+                       if (bRTS == true) { /* RTS_need */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab));
                                pvRTS = (void *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR);
@@ -1170,7 +1170,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                        sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb));
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
                                        cbMICHDR + sizeof(struct vnt_rts_a_fb) + sizeof(struct vnt_tx_datahead_a_fb);
-                       } else { //RTS_needless
+                       } else { /* RTS_needless */
                                pvRrvTime = (void *)(pbyTxBufferAddr + wTxBufSize);
                                pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab));
                                pvRTS = NULL;
@@ -1179,7 +1179,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType,
                                cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) +
                                        cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb);
                        }
-               } // Auto Fall Back
+               } /* Auto Fall Back */
        }
 
        td_info->mic_hdr = pMICHDR;
@@ -1505,8 +1505,6 @@ int vnt_beacon_make(struct vnt_private *priv, struct ieee80211_vif *vif)
 int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif,
                      struct ieee80211_bss_conf *conf)
 {
-       int ret;
-
        VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
 
        VNSvOutPortB(priv->PortOffset + MAC_REG_TFTCTL, TFTCTL_TSFCNTREN);
@@ -1515,7 +1513,5 @@ int vnt_beacon_enable(struct vnt_private *priv, struct ieee80211_vif *vif,
 
        CARDbSetBeaconPeriod(priv, conf->beacon_int);
 
-       ret = vnt_beacon_make(priv, vif);
-
-       return ret;
+       return vnt_beacon_make(priv, vif);
 }
index 7d3e3ef9f17fffc4299bda8a3b1f5451c493a832..531bf0069373fa0c8a9a934de045b465e1ba0e09 100644 (file)
@@ -24,7 +24,6 @@
  * Author: Jerry Chen
  *
  * Date: Jan 29, 2003
- *
  */
 
 #ifndef __SROM_H__
 
 #define EEP_MAX_CONTEXT_SIZE    256
 
-#define CB_EEPROM_READBYTE_WAIT 900     //us
+#define CB_EEPROM_READBYTE_WAIT 900     /* us */
 
 #define W_MAX_I2CRETRY          0x0fff
 
-//
-// Contents in the EEPROM
-//
-#define EEP_OFS_PAR         0x00        // physical address
+/* Contents in the EEPROM */
+#define EEP_OFS_PAR         0x00        /* physical address */
 #define EEP_OFS_ANTENNA     0x16
 #define EEP_OFS_RADIOCTL    0x17
-#define EEP_OFS_RFTYPE      0x1B        // for select RF
-#define EEP_OFS_MINCHANNEL  0x1C        // Min Channel #
-#define EEP_OFS_MAXCHANNEL  0x1D        // Max Channel #
-#define EEP_OFS_SIGNATURE   0x1E        //
-#define EEP_OFS_ZONETYPE    0x1F        //
-#define EEP_OFS_RFTABLE     0x20        // RF POWER TABLE
+#define EEP_OFS_RFTYPE      0x1B        /* for select RF */
+#define EEP_OFS_MINCHANNEL  0x1C        /* Min Channel # */
+#define EEP_OFS_MAXCHANNEL  0x1D        /* Max Channel # */
+#define EEP_OFS_SIGNATURE   0x1E
+#define EEP_OFS_ZONETYPE    0x1F
+#define EEP_OFS_RFTABLE     0x20        /* RF POWER TABLE */
 #define EEP_OFS_PWR_CCK     0x20
 #define EEP_OFS_SETPT_CCK   0x21
 #define EEP_OFS_PWR_OFDMG   0x23
 #define EEP_OFS_SETPT_OFDMG 0x24
-#define EEP_OFS_PWR_FORMULA_OST  0x26   //
+#define EEP_OFS_PWR_FORMULA_OST  0x26
 #define EEP_OFS_MAJOR_VER 0x2E
 #define EEP_OFS_MINOR_VER 0x2F
 #define EEP_OFS_CCK_PWR_TBL     0x30
 #define EEP_OFS_CCK_PWR_dBm     0x3F
 #define EEP_OFS_OFDM_PWR_TBL    0x40
 #define EEP_OFS_OFDM_PWR_dBm    0x4F
-//{{ RobertYu: 20041124
+/*{{ RobertYu: 20041124 */
 #define EEP_OFS_SETPT_OFDMA         0x4E
 #define EEP_OFS_OFDMA_PWR_TBL       0x50
-//}}
+/*}}*/
 #define EEP_OFS_OFDMA_PWR_dBm       0xD2
 
-//----------need to remove --------------------
-#define EEP_OFS_BBTAB_LEN   0x70        // BB Table Length
-#define EEP_OFS_BBTAB_ADR   0x71        // BB Table Offset
-#define EEP_OFS_CHECKSUM    0xFF        // reserved area for baseband 28h ~ 78h
+/*----------need to remove --------------------*/
+#define EEP_OFS_BBTAB_LEN   0x70        /* BB Table Length */
+#define EEP_OFS_BBTAB_ADR   0x71        /* BB Table Offset */
+#define EEP_OFS_CHECKSUM    0xFF        /* reserved area for baseband 28h~78h */
 
-#define EEP_I2C_DEV_ID      0x50        // EEPROM device address on the I2C bus
+#define EEP_I2C_DEV_ID      0x50        /* EEPROM device address on I2C bus */
 
-//
-// Bits in EEP_OFS_ANTENNA
-//
+/* Bits in EEP_OFS_ANTENNA */
 #define EEP_ANTENNA_MAIN    0x01
 #define EEP_ANTENNA_AUX     0x02
 #define EEP_ANTINV          0x04
 
-//
-// Bits in EEP_OFS_RADIOCTL
-//
+/* Bits in EEP_OFS_RADIOCTL */
 #define EEP_RADIOCTL_ENABLE 0x80
 #define EEP_RADIOCTL_INV    0x01
 
 
 /*---------------------  Export Functions  --------------------------*/
 
-unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset);
+unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase,
+                                unsigned char byContntOffset);
 
 void SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs);
 
-void SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress);
+void SROMvReadEtherAddress(void __iomem *dwIoBase,
+                          unsigned char *pbyEtherAddress);
 
-#endif // __EEPROM_H__
+#endif /* __EEPROM_H__*/
index 607b78f7a6a03aa45ba5d08628822a0584677469..597efefc017f9b8f9f0d4ab7a3975a7e78aff487 100644 (file)
@@ -55,4 +55,4 @@
 #define MAKEDWORD(lw, hw)   ((unsigned long)(((unsigned short)(lw)) | (((unsigned long)((unsigned short)(hw))) << 16)))
 #endif
 
-#endif // __TMACRO_H__
+#endif /* __TMACRO_H__ */
index a177645af83e6e8d5b37491b0b6096f74fdf55b9..d440f284bf1891c8bec4c1afc95996a8241debea 100644 (file)
@@ -61,7 +61,7 @@ int vnt_download_firmware(struct vnt_private *priv)
 
        buffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL);
        if (!buffer)
-               goto out;
+               goto free_fw;
 
        for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
                length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
index bb37e33b9ffa00001fc64597649adee59848420f..5dfac05b9cf17002d1cb0f049ed9d92d6bb91488 100644 (file)
@@ -30,6 +30,8 @@
  * Revision History:
  */
 
+#include <linux/etherdevice.h>
+
 #include "desc.h"
 #include "mac.h"
 #include "usbpipe.h"
@@ -126,7 +128,7 @@ void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
        offset += (entry_idx * MISCFIFO_KEYENTRYSIZE);
 
        set_key.u.write.key_ctl = cpu_to_le16(key_ctl);
-       memcpy(set_key.u.write.addr, addr, ETH_ALEN);
+       ether_addr_copy(set_key.u.write.addr, addr);
 
        /* swap over swap[0] and swap[1] to get correct write order */
        swap(set_key.u.swap[0], set_key.u.swap[1]);
index 71adc1f61838654c0abb10bd377057de19a18a43..ab3ab84cb0a717179472971d2817724441cbb350 100644 (file)
@@ -963,6 +963,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
        hw = ieee80211_alloc_hw(sizeof(struct vnt_private), &vnt_mac_ops);
        if (!hw) {
                dev_err(&udev->dev, "could not register ieee80211_hw\n");
+               rc = -ENOMEM;
                goto err_nomem;
        }
 
index 33baf26de4b581b1a354f872baa536466f920c09..f6c2cf8590c4811471a88c9e82be1d4151a11618 100644 (file)
@@ -755,9 +755,9 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
                else
                        mic_hdr->hlen = cpu_to_be16(22);
 
-               memcpy(mic_hdr->addr1, hdr->addr1, ETH_ALEN);
-               memcpy(mic_hdr->addr2, hdr->addr2, ETH_ALEN);
-               memcpy(mic_hdr->addr3, hdr->addr3, ETH_ALEN);
+               ether_addr_copy(mic_hdr->addr1, hdr->addr1);
+               ether_addr_copy(mic_hdr->addr2, hdr->addr2);
+               ether_addr_copy(mic_hdr->addr3, hdr->addr3);
 
                mic_hdr->frame_control = cpu_to_le16(
                        le16_to_cpu(hdr->frame_control) & 0xc78f);
@@ -765,7 +765,7 @@ static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
                                le16_to_cpu(hdr->seq_ctrl) & 0xf);
 
                if (ieee80211_has_a4(hdr->frame_control))
-                       memcpy(mic_hdr->addr4, hdr->addr4, ETH_ALEN);
+                       ether_addr_copy(mic_hdr->addr4, hdr->addr4);
 
 
                memcpy(key_buffer, tx_key->key, WLAN_KEY_LEN_CCMP);
index 8f2091070491fce457c0e29ffb7ddcf8af61a9f5..73c646bc50d9d8a38ee1028a5f3a383660eea6fe 100644 (file)
@@ -1413,7 +1413,8 @@ int hfa384x_drvr_start(hfa384x_t *hw);
 int hfa384x_drvr_stop(hfa384x_t *hw);
 int
 hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb,
-                    union p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep);
+                    union p80211_hdr *p80211_hdr,
+                    struct p80211_metawep *p80211_wep);
 void hfa384x_tx_timeout(wlandevice_t *wlandev);
 
 int hfa384x_cmd_initialize(hfa384x_t *hw);
index 28cd1c4c02c8501a07a9791b9126b0a3c83f1b94..e109a7fd422ffe387f0457c695eb39518472d956 100644 (file)
@@ -557,17 +557,13 @@ void hfa384x_create(hfa384x_t *hw, struct usb_device *usb)
        INIT_WORK(&hw->link_bh, prism2sta_processing_defer);
        INIT_WORK(&hw->usb_work, hfa384x_usb_defer);
 
-       init_timer(&hw->throttle);
-       hw->throttle.function = hfa384x_usb_throttlefn;
-       hw->throttle.data = (unsigned long)hw;
+       setup_timer(&hw->throttle, hfa384x_usb_throttlefn, (unsigned long)hw);
 
-       init_timer(&hw->resptimer);
-       hw->resptimer.function = hfa384x_usbctlx_resptimerfn;
-       hw->resptimer.data = (unsigned long)hw;
+       setup_timer(&hw->resptimer, hfa384x_usbctlx_resptimerfn,
+                   (unsigned long)hw);
 
-       init_timer(&hw->reqtimer);
-       hw->reqtimer.function = hfa384x_usbctlx_reqtimerfn;
-       hw->reqtimer.data = (unsigned long)hw;
+       setup_timer(&hw->reqtimer, hfa384x_usbctlx_reqtimerfn,
+                   (unsigned long)hw);
 
        usb_init_urb(&hw->rx_urb);
        usb_init_urb(&hw->tx_urb);
@@ -577,9 +573,8 @@ void hfa384x_create(hfa384x_t *hw, struct usb_device *usb)
        hw->state = HFA384x_STATE_INIT;
 
        INIT_WORK(&hw->commsqual_bh, prism2sta_commsqual_defer);
-       init_timer(&hw->commsqual_timer);
-       hw->commsqual_timer.data = (unsigned long)hw;
-       hw->commsqual_timer.function = prism2sta_commsqual_timer;
+       setup_timer(&hw->commsqual_timer, prism2sta_commsqual_timer,
+                   (unsigned long)hw);
 }
 
 /*----------------------------------------------------------------
@@ -624,11 +619,10 @@ static hfa384x_usbctlx_t *usbctlx_alloc(void)
 {
        hfa384x_usbctlx_t *ctlx;
 
-       ctlx = kmalloc(sizeof(*ctlx), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
-       if (ctlx != NULL) {
-               memset(ctlx, 0, sizeof(*ctlx));
+       ctlx = kzalloc(sizeof(*ctlx),
+                      in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
+       if (ctlx != NULL)
                init_completion(&ctlx->done);
-       }
 
        return ctlx;
 }
index 0163e062b650810b9310bf5faefde96be2972ee8..b4a15ef3a405ce78bb0044aeff03a86f566da5a8 100644 (file)
@@ -582,8 +582,6 @@ static int prism2mib_privacyinvoked(struct mibrec *mib,
                                    struct p80211msg_dot11req_mibset *msg,
                                    void *data)
 {
-       int result;
-
        if (wlandev->hostwep & HOSTWEP_DECRYPT) {
                if (wlandev->hostwep & HOSTWEP_DECRYPT)
                        mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_RXCRYPT;
@@ -591,9 +589,7 @@ static int prism2mib_privacyinvoked(struct mibrec *mib,
                        mib->parm2 |= HFA384x_WEPFLAGS_DISABLE_TXCRYPT;
        }
 
-       result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
-
-       return result;
+       return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
 }
 
 /*----------------------------------------------------------------
@@ -628,11 +624,8 @@ static int prism2mib_excludeunencrypted(struct mibrec *mib,
                                        struct p80211msg_dot11req_mibset *msg,
                                        void *data)
 {
-       int result;
-
-       result = prism2mib_flag(mib, isget, wlandev, hw, msg, data);
 
-       return result;
+       return prism2mib_flag(mib, isget, wlandev, hw, msg, data);
 }
 
 /*----------------------------------------------------------------
index 10ad24a89ddd24c30913e14be13f6cd15ca0bee0..ddb294e7044ff1a9e0cd614eb965551f27aab35f 100644 (file)
@@ -51,7 +51,6 @@
 */
 
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
@@ -60,6 +59,7 @@
 #include <linux/netdevice.h>
 #include <linux/workqueue.h>
 #include <linux/byteorder/generic.h>
+#include <linux/etherdevice.h>
 
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -243,7 +243,6 @@ static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
                             struct p80211_metawep *p80211_wep)
 {
        hfa384x_t *hw = (hfa384x_t *) wlandev->priv;
-       int result;
 
        /* If necessary, set the 802.11 WEP bit */
        if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) ==
@@ -251,9 +250,7 @@ static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb,
                p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
        }
 
-       result = hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
-
-       return result;
+       return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep);
 }
 
 /*----------------------------------------------------------------
@@ -1548,7 +1545,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
         ** authentication.
         */
 
-       memcpy(rec.address, inf->info.authreq.sta_addr, ETH_ALEN);
+       ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
        rec.status = P80211ENUM_status_unspec_failure;
 
        /*
@@ -1661,8 +1658,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
                        if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
                                rec.status = P80211ENUM_status_ap_full;
                        } else {
-                               memcpy(hw->authlist.addr[hw->authlist.cnt],
-                                      rec.address, ETH_ALEN);
+                               ether_addr_copy(hw->authlist.addr[hw->authlist.cnt],
+                                               rec.address);
                                hw->authlist.cnt++;
                                added = 1;
                        }
index 935c714f592a4768d9d3f41ec56b9131f05243f5..74e88200726ccd7da5f92f966517eb2e1dfe2d5c 100644 (file)
@@ -106,7 +106,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
 
        sr_data = XGI_CRT1Table[index].CR[5];
 
-       HDE = (XGI330_RefIndex[RefreshRateTableIndex].XRes >> 3);
+       HDE = XGI330_RefIndex[RefreshRateTableIndex].XRes >> 3;
 
        cr_data = XGI_CRT1Table[index].CR[3];
 
@@ -1011,8 +1011,8 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
                               XGIbios_mode[xgifb_info->mode_idx].mode_no);
                        return -EINVAL;
                }
-               info->fix.line_length = ((info->var.xres_virtual
-                               * info->var.bits_per_pixel) >> 6);
+               info->fix.line_length = (info->var.xres_virtual
+                               * info->var.bits_per_pixel) >> 6;
 
                xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
 
index 1f6f699e238c35eb818611d6d048a7ebebefa6e6..a47395e92d20aecaa90eb4de981e4fba3a78ceaf 100644 (file)
@@ -308,11 +308,11 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
                data |= data1;
                xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
                data = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
-               data = data >> 5;
+               data >>= 5;
                data = data + 3;
                if (data > 7)
                        data = data - 7;
-               data = data << 5;
+               data <<= 5;
                xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
        }
 }
@@ -347,7 +347,7 @@ static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
 
        data = pVBInfo->TimingV.data[6];
        data &= 0x80;
-       data = data >> 2;
+       data >>= 2;
 
        i = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;
        i &= DoubleScanMode;
@@ -693,18 +693,18 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
        tempbx = XGI330_ModeResInfo[resindex].VTotal;
 
        if (modeflag & HalfDCLK)
-               tempax = tempax >> 1;
+               tempax >>= 1;
 
        if (modeflag & HalfDCLK)
-               tempax = tempax << 1;
+               tempax <<= 1;
 
        temp = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
 
        if (temp & InterlaceMode)
-               tempbx = tempbx >> 1;
+               tempbx >>= 1;
 
        if (modeflag & DoubleScanMode)
-               tempbx = tempbx << 1;
+               tempbx <<= 1;
 
        tempcx = 8;
 
@@ -721,7 +721,7 @@ static void XGI_SetCRT1DE(unsigned short ModeIdIndex,
                        (unsigned short) ((tempcx & 0x0ff00) >> 10));
        xgifb_reg_set(pVBInfo->P3d4, 0x12, (unsigned short) (tempbx & 0xff));
        tempax = 0;
-       tempbx = tempbx >> 8;
+       tempbx >>= 8;
 
        if (tempbx & 0x01)
                tempax |= 0x02;
@@ -750,14 +750,14 @@ static void XGI_SetCRT1Offset(unsigned short ModeNo,
 
        /* GetOffset */
        temp = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeInfo;
-       temp = temp >> 8;
+       temp >>= 8;
        temp = XGI330_ScreenOffset[temp];
 
        temp2 = XGI330_RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
        temp2 &= InterlaceMode;
 
        if (temp2)
-               temp = temp << 1;
+               temp <<= 1;
 
        temp2 = pVBInfo->ModeType - ModeEGA;
 
@@ -792,7 +792,7 @@ static void XGI_SetCRT1Offset(unsigned short ModeNo,
        /* SetOffset */
        DisplayUnit = temp;
        temp2 = temp;
-       temp = temp >> 8; /* ah */
+       temp >>= 8; /* ah */
        temp &= 0x0F;
        i = xgifb_reg_get(pVBInfo->P3c4, 0x0E);
        i &= 0xF0;
@@ -809,7 +809,7 @@ static void XGI_SetCRT1Offset(unsigned short ModeNo,
        if (temp2)
                DisplayUnit >>= 1;
 
-       DisplayUnit = DisplayUnit << 5;
+       DisplayUnit <<= 5;
        ah = (DisplayUnit & 0xff00) >> 8;
        al = DisplayUnit & 0x00ff;
        if (al == 0)
@@ -912,7 +912,7 @@ static void XGI_SetCRT1VCLK(unsigned short ModeIdIndex,
                        index = data;
                        index &= 0xE0;
                        data &= 0x1F;
-                       data = data << 1;
+                       data <<= 1;
                        data += 1;
                        data |= index;
                        xgifb_reg_set(pVBInfo->P3c4, 0x2C, data);
@@ -1011,7 +1011,7 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
        data2 = 0;
        data2 |= 0x02;
        data3 = pVBInfo->ModeType - ModeVGA;
-       data3 = data3 << 2;
+       data3 <<= 2;
        data2 |= data3;
        data &= InterlaceMode;
 
@@ -1126,7 +1126,7 @@ static void XGI_LoadDAC(struct vb_device_info *pVBInfo)
                                data2 += 0x15;
 
                        outb(data2, pVBInfo->P3c9);
-                       data = data >> 2;
+                       data >>= 2;
                }
        }
 
@@ -1185,10 +1185,10 @@ static void XGI_GetLVDSResInfo(unsigned short ModeIdIndex,
        yres = XGI330_ModeResInfo[resindex].VTotal;
 
        if (modeflag & HalfDCLK)
-               xres = xres << 1;
+               xres <<= 1;
 
        if (modeflag & DoubleScanMode)
-               yres = yres << 1;
+               yres <<= 1;
 
        if (xres == 720)
                xres = 640;
@@ -1450,8 +1450,8 @@ static void XGI_SetLVDSRegs(unsigned short ModeIdIndex,
 
        xgifb_reg_set(pVBInfo->Part1Port, 0x1A, tempbx & 0x07);
 
-       tempcx = tempcx >> 3;
-       tempbx = tempbx >> 3;
+       tempcx >>= 3;
+       tempbx >>= 3;
 
        xgifb_reg_set(pVBInfo->Part1Port, 0x16,
                        (unsigned short) (tempbx & 0xff));
@@ -1473,9 +1473,9 @@ static void XGI_SetLVDSRegs(unsigned short ModeIdIndex,
                tempcx -= tempax;
 
        tempax = tempbx & 0x07;
-       tempax = tempax >> 5;
-       tempcx = tempcx >> 3;
-       tempbx = tempbx >> 3;
+       tempax >>= 5;
+       tempcx >>= 3;
+       tempbx >>= 3;
 
        tempcx &= 0x1f;
        tempax |= tempcx;
@@ -1600,7 +1600,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeIdIndex,
        temp1 = pVBInfo->VGAHDE << 16;
 
        temp1 /= temp3;
-       temp3 = temp3 << 16;
+       temp3 <<= 16;
        temp1 -= 1;
 
        temp3 = (temp3 & 0xffff0000) + (temp1 & 0xffff);
@@ -1622,10 +1622,10 @@ static void XGI_SetLVDSRegs(unsigned short ModeIdIndex,
        xgifb_reg_set(pVBInfo->Part1Port, 0x21,
                        (unsigned short) (tempbx & 0xff));
 
-       temp3 = temp3 >> 16;
+       temp3 >>= 16;
 
        if (modeflag & HalfDCLK)
-               temp3 = temp3 >> 1;
+               temp3 >>= 1;
 
        xgifb_reg_set(pVBInfo->Part1Port, 0x22,
                        (unsigned short) ((temp3 >> 8) & 0xff));
@@ -1909,7 +1909,7 @@ static void XGI_GetVBInfo(unsigned short ModeIdIndex,
        tempbx = tempbx | temp;
        temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
        push = temp;
-       push = push << 8;
+       push <<= 8;
        tempax = temp << 8;
        tempbx = tempbx | tempax;
        temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
@@ -2107,7 +2107,7 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex,
                        if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
                                tempax &= 0x0F;
                        else
-                               tempax = tempax >> 4;
+                               tempax >>= 4;
 
                        if ((resinfo == 6) || (resinfo == 9)) {
                                if (tempax >= 3)
@@ -2182,7 +2182,7 @@ static unsigned char XG21GPIODataTransfer(unsigned char ujDate)
        unsigned char i = 0;
 
        for (i = 0; i < 8; i++) {
-               ujRet = ujRet << 1;
+               ujRet <<= 1;
                ujRet |= (ujDate >> i) & 1;
        }
 
@@ -2494,7 +2494,7 @@ static void XGI_GetRAMDAC2DATA(unsigned short ModeIdIndex,
        tempcx = (unsigned short)
                        XGI_CRT1Table[CRT1Index].CR[14] << 8;
        tempcx &= 0x0100;
-       tempcx = tempcx << 2;
+       tempcx <<= 2;
        tempbx |= tempcx;
        temp1 = (unsigned short) XGI_CRT1Table[CRT1Index].CR[9];
 
@@ -2745,7 +2745,7 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo,
        temp = XGI330_ScreenOffset[index];
 
        if (infoflag & InterlaceMode)
-               temp = temp << 1;
+               temp <<= 1;
 
        colordepth = XGI_GetColorDepth(ModeIdIndex);
 
@@ -2754,7 +2754,7 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo,
                colordepth = ColorDepth[temp];
                temp = 0x6B;
                if (infoflag & InterlaceMode)
-                       temp = temp << 1;
+                       temp <<= 1;
        }
        return temp * colordepth;
 }
@@ -2826,7 +2826,7 @@ static void XGI_SetGroup1(unsigned short ModeIdIndex,
                xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
                tempcx = ((pVBInfo->VGAHT - pVBInfo->VGAHDE) / 2) >> 2;
                pushbx = pVBInfo->VGAHDE / 2 + 16;
-               tempcx = tempcx >> 1;
+               tempcx >>= 1;
                tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
                tempcx += tempbx;
 
@@ -2861,7 +2861,7 @@ static void XGI_SetGroup1(unsigned short ModeIdIndex,
                xgifb_reg_set(pVBInfo->Part1Port, 0x0A, temp);
                tempcx = (pVBInfo->VGAHT - pVBInfo->VGAHDE) >> 2; /* cx */
                pushbx = pVBInfo->VGAHDE + 16;
-               tempcx = tempcx >> 1;
+               tempcx >>= 1;
                tempbx = pushbx + tempcx; /* bx BTVGA@HRS 0x0B,0x0C */
                tempcx += tempbx;
 
@@ -2980,7 +2980,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
        tempax = pVBInfo->VGAHDE; /* 0x04 Horizontal Display End */
 
        if (modeflag & HalfDCLK)
-               tempax = tempax >> 1;
+               tempax >>= 1;
 
        tempax = (tempax / tempcx) - 1;
        tempbx |= ((tempax & 0x00FF) << 8);
@@ -3015,7 +3015,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                tempax = pVBInfo->VGAHT;
 
        if (modeflag & HalfDCLK)
-               tempax = tempax >> 1;
+               tempax >>= 1;
 
        tempax = (tempax / tempcx) - 5;
        tempcx = tempax; /* 20030401 0x07 horizontal Retrace Start */
@@ -3142,11 +3142,11 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        tempax = push1;
        tempax -= tempbx; /* 0x0C Vertical Retrace Start */
-       tempax = tempax >> 2;
+       tempax >>= 2;
        push1 = tempax; /* push ax */
 
        if (resinfo != 0x09) {
-               tempax = tempax << 1;
+               tempax <<= 1;
                tempbx += tempax;
        }
 
@@ -3179,7 +3179,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
                }
        }
        tempax = push1;
-       tempax = tempax >> 2;
+       tempax >>= 2;
        tempax++;
        tempax += tempbx;
        push1 = tempax; /* push ax */
@@ -3332,7 +3332,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
 
        if (pVBInfo->VDE <= tempax) {
                tempax -= pVBInfo->VDE;
-               tempax = tempax >> 2;
+               tempax >>= 2;
                tempax = (tempax & 0x00FF) | ((tempax & 0x00FF) << 8);
                push1 = tempax;
                temp = (tempax & 0xFF00) >> 8;
@@ -3377,7 +3377,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
        tempcx = pVBInfo->HT;
 
        if (XGI_IsLCDDualLink(pVBInfo))
-               tempcx = tempcx >> 1;
+               tempcx >>= 1;
 
        tempcx -= 2;
        temp = tempcx & 0x00FF;
@@ -3394,7 +3394,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                tempcx -= 4;
 
        temp = tempcx & 0x00FF;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x22, 0x0F, temp);
 
        tempbx = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
@@ -3403,7 +3403,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
        temp = tempbx & 0x00FF;
        xgifb_reg_set(pVBInfo->Part2Port, 0x24, temp);
        temp = (tempbx & 0xFF00) >> 8;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
 
        tempbx = push2;
@@ -3428,7 +3428,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                tempcx -= 4;
 
        temp = tempcx & 0xFF;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x2A, 0x0F, temp);
 
        tempcx = push1; /* pop cx */
@@ -3436,7 +3436,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
        temp = TimingPoint[j] | ((TimingPoint[j + 1]) << 8);
        tempcx -= temp;
        temp = tempcx & 0x00FF;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x2D, 0x0F, temp);
 
        tempcx -= 11;
@@ -3462,9 +3462,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                    (VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
                        if (!(pVBInfo->TVInfo &
                            (TVSetYPbPr525p | TVSetYPbPr750p)))
-                               tempbx = tempbx >> 1;
+                               tempbx >>= 1;
                } else
-                       tempbx = tempbx >> 1;
+                       tempbx >>= 1;
        }
 
        tempbx -= 2;
@@ -3514,7 +3514,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
                if (pVBInfo->VBInfo & SetCRT2ToTV) {
                        if (!(pVBInfo->TVInfo & (TVSetYPbPr525p
                                        | TVSetYPbPr750p)))
-                               tempbx = tempbx >> 1;
+                               tempbx >>= 1;
                }
 
                if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
@@ -3627,7 +3627,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
        xgifb_reg_set(pVBInfo->Part2Port, 0x4c, temp);
 
        temp = ((tempcx & 0xFF00) >> 8) & 0x03;
-       temp = temp << 2;
+       temp <<= 2;
        temp |= ((tempbx & 0xFF00) >> 8) & 0x03;
 
        if (pVBInfo->VBInfo & SetCRT2ToYPbPr525750) {
@@ -3691,13 +3691,13 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        tempbx = pVBInfo->HDE; /* RHACTE=HDE-1 */
 
        if (XGI_IsLCDDualLink(pVBInfo))
-               tempbx = tempbx >> 1;
+               tempbx >>= 1;
 
        tempbx -= 1;
        temp = tempbx & 0x00FF;
        xgifb_reg_set(pVBInfo->Part2Port, 0x2C, temp);
        temp = (tempbx & 0xFF00) >> 8;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
        temp = 0x01;
 
@@ -3713,7 +3713,7 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        temp = tempcx & 0x00FF; /* RVTVT=VT-1 */
        xgifb_reg_set(pVBInfo->Part2Port, 0x19, temp);
        temp = (tempcx & 0xFF00) >> 8;
-       temp = temp << 5;
+       temp <<= 5;
        xgifb_reg_set(pVBInfo->Part2Port, 0x1A, temp);
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x09, 0xF0, 0x00);
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0xF0, 0x00);
@@ -3770,7 +3770,7 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        tempch = ((tempcx & 0xFF00) >> 8) & 0x07;
        tempbh = ((tempbx & 0xFF00) >> 8) & 0x07;
        tempah = tempch;
-       tempah = tempah << 3;
+       tempah <<= 3;
        tempah |= tempbh;
        xgifb_reg_set(pVBInfo->Part2Port, 0x02, tempah);
 
@@ -3787,7 +3787,7 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        temp = tempbx & 0x00FF; /* RTVACTEE=lcdvrs */
        xgifb_reg_set(pVBInfo->Part2Port, 0x04, temp);
        temp = (tempbx & 0xFF00) >> 8;
-       temp = temp << 4;
+       temp <<= 4;
        temp |= (tempcx & 0x000F);
        xgifb_reg_set(pVBInfo->Part2Port, 0x01, temp);
        tempcx = pushbx;
@@ -3796,9 +3796,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        tempbx &= 0x0FFF;
 
        if (XGI_IsLCDDualLink(pVBInfo)) {
-               tempax = tempax >> 1;
-               tempbx = tempbx >> 1;
-               tempcx = tempcx >> 1;
+               tempax >>= 1;
+               tempbx >>= 1;
+               tempcx >>= 1;
        }
 
        if (pVBInfo->VBType & VB_SIS302LV)
@@ -3826,9 +3826,9 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        tempax = pVBInfo->HT;
        tempbx = pVBInfo->LCDHRS;
        if (XGI_IsLCDDualLink(pVBInfo)) {
-               tempax = tempax >> 1;
-               tempbx = tempbx >> 1;
-               tempcx = tempcx >> 1;
+               tempax >>= 1;
+               tempbx >>= 1;
+               tempcx >>= 1;
        }
 
        if (pVBInfo->VBType & VB_SIS302LV)
@@ -3843,7 +3843,7 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex,
        xgifb_reg_set(pVBInfo->Part2Port, 0x1C, temp);
 
        temp = (tempbx & 0xFF00) >> 8;
-       temp = temp << 4;
+       temp <<= 4;
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x1D, ~0x0F0, temp);
        temp = tempcx & 0x00FF; /* RHSYEXP2S=lcdhre */
        xgifb_reg_set(pVBInfo->Part2Port, 0x21, temp);
@@ -4044,10 +4044,10 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,
        tempbx = pVBInfo->VGAHDE;
 
        if (modeflag & HalfDCLK)
-               tempbx = tempbx >> 1;
+               tempbx >>= 1;
 
        if (XGI_IsLCDDualLink(pVBInfo))
-               tempbx = tempbx >> 1;
+               tempbx >>= 1;
 
        if (tempcx & SetCRT2ToHiVision) {
                temp = 0;
@@ -4107,7 +4107,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,
        xgifb_reg_set(pVBInfo->Part4Port, 0x1A, temp);
        tempbx = (unsigned short) (tempebx >> 16);
        temp = tempbx & 0x00FF;
-       temp = temp << 4;
+       temp <<= 4;
        temp |= ((tempcx & 0xFF00) >> 8);
        xgifb_reg_set(pVBInfo->Part4Port, 0x19, temp);
 
@@ -4118,10 +4118,10 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,
                xgifb_reg_set(pVBInfo->Part4Port, 0x1C, temp);
                tempax = pVBInfo->VGAHDE;
                if (modeflag & HalfDCLK)
-                       tempax = tempax >> 1;
+                       tempax >>= 1;
 
                if (XGI_IsLCDDualLink(pVBInfo))
-                       tempax = tempax >> 1;
+                       tempax >>= 1;
 
                if (pVBInfo->VBInfo & SetCRT2ToLCD) {
                        if (tempax > 800)
@@ -4162,7 +4162,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,
                xgifb_reg_and_or(pVBInfo->Part4Port, 0x1F, 0x00C0, temp);
                tempbx = pVBInfo->HT;
                if (XGI_IsLCDDualLink(pVBInfo))
-                       tempbx = tempbx >> 1;
+                       tempbx >>= 1;
                tempbx = (tempbx >> 1) - 2;
                temp = ((tempbx & 0x0700) >> 8) << 3;
                xgifb_reg_and_or(pVBInfo->Part4Port, 0x21, 0x00C0, temp);
@@ -4622,7 +4622,7 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
                        tempbl = XGI301TVDelay;
 
                        if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
-                               tempbl = tempbl >> 4;
+                               tempbl >>= 4;
                        if (pVBInfo->VBInfo &
                            (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
                                tempbh = XGI301LCDDelay;
@@ -4785,7 +4785,7 @@ static void XGI_SetAntiFlicker(struct vb_device_info *pVBInfo)
        tempbx = XGI_GetTVPtrIndex(pVBInfo);
        tempbx &= 0xFE;
        tempah = TVAntiFlickList[tempbx];
-       tempah = tempah << 4;
+       tempah <<= 4;
 
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah);
 }
@@ -4799,7 +4799,7 @@ static void XGI_SetEdgeEnhance(struct vb_device_info *pVBInfo)
        tempbx = XGI_GetTVPtrIndex(pVBInfo);
        tempbx &= 0xFE;
        tempah = TVEdgeList[tempbx];
-       tempah = tempah << 5;
+       tempah <<= 5;
 
        xgifb_reg_and_or(pVBInfo->Part2Port, 0x3A, 0x1F, tempah);
 }
@@ -5101,7 +5101,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
        unsigned short RefreshRateTableIndex, i, index, temp;
 
        index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
-       index = index >> pVBInfo->SelectCRT2Rate;
+       index >>= pVBInfo->SelectCRT2Rate;
        index &= 0x0F;
 
        if (pVBInfo->LCDInfo & LCDNonExpanding)
index e07cfa8001bbf0ab2a253eae50b6290c3a60a984..895c2a31918df1d7bbabe1977faefe0f7543f0b2 100644 (file)
@@ -587,11 +587,6 @@ static int tsi148_slave_set(struct vme_slave_resource *image, int enabled,
                granularity = 0x10000;
                addr |= TSI148_LCSR_ITAT_AS_A64;
                break;
-       case VME_CRCSR:
-       case VME_USER1:
-       case VME_USER2:
-       case VME_USER3:
-       case VME_USER4:
        default:
                dev_err(tsi148_bridge->parent, "Invalid address space\n");
                return -EINVAL;
@@ -2471,7 +2466,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                master_image->locked = 0;
                master_image->number = i;
                master_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
-                       VME_A64;
+                       VME_A64 | VME_CRCSR | VME_USER1 | VME_USER2 |
+                       VME_USER3 | VME_USER4;
                master_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
                        VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 |
                        VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER |
@@ -2500,8 +2496,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                slave_image->locked = 0;
                slave_image->number = i;
                slave_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
-                       VME_A64 | VME_CRCSR | VME_USER1 | VME_USER2 |
-                       VME_USER3 | VME_USER4;
+                       VME_A64;
                slave_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
                        VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 |
                        VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER |
index d95fb848dd03368c26c4d0b59020e5ac02a0b893..6bab2c4ed77c9f8b0ba4335932203680aceb6af7 100644 (file)
@@ -609,6 +609,32 @@ unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
 }
 EXPORT_SYMBOL(vme_master_rmw);
 
+int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma)
+{
+       struct vme_master_resource *image;
+       phys_addr_t phys_addr;
+       unsigned long vma_size;
+
+       if (resource->type != VME_MASTER) {
+               pr_err("Not a master resource\n");
+               return -EINVAL;
+       }
+
+       image = list_entry(resource->entry, struct vme_master_resource, list);
+       phys_addr = image->bus_resource.start + (vma->vm_pgoff << PAGE_SHIFT);
+       vma_size = vma->vm_end - vma->vm_start;
+
+       if (phys_addr + vma_size > image->bus_resource.end + 1) {
+               pr_err("Map size cannot exceed the window size\n");
+               return -EFAULT;
+       }
+
+       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+       return vm_iomap_memory(vma, phys_addr, vma->vm_end - vma->vm_start);
+}
+EXPORT_SYMBOL(vme_master_mmap);
+
 void vme_master_free(struct vme_resource *resource)
 {
        struct vme_master_resource *master_image;
index 8cd6f19ca518c254a1911b2aa0e1c36dc05951df..79242e9c06b8cdcc11a2742d7280a15b81c80f6b 100644 (file)
@@ -137,6 +137,7 @@ ssize_t vme_master_read(struct vme_resource *, void *, size_t, loff_t);
 ssize_t vme_master_write(struct vme_resource *, void *, size_t, loff_t);
 unsigned int vme_master_rmw(struct vme_resource *, unsigned int, unsigned int,
        unsigned int, loff_t);
+int vme_master_mmap(struct vme_resource *resource, struct vm_area_struct *vma);
 void vme_master_free(struct vme_resource *);
 
 struct vme_resource *vme_dma_request(struct vme_dev *, u32);
This page took 1.126705 seconds and 5 git commands to generate.