]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Merge tag 'staging-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Apr 2015 00:37:33 +0000 (17:37 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 14 Apr 2015 00:37:33 +0000 (17:37 -0700)
Pull staging driver updates from Greg KH:
 "Here's the big staging driver patchset for 4.1-rc1.

  There's a lot of patches here, the Outreachy application period
  happened during this development cycle, so that means that there was a
  lot of cleanup patches accepted.  Other than the normal coding style
  and sparse fixes here, there are some driver updates and work toward
  making some of the drivers into "mergable" shape (like the Unisys
  drivers.)

  All of these have been in linux-next for a while"

* tag 'staging-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1214 commits)
  staging: lustre: orthography & coding style
  staging: lustre: lnet: lnet: fix error return code
  staging: lustre: fix sparse warning
  Revert "Staging: sm750fb: Fix C99 Comments"
  Staging: rtl8192u: use correct array for debug output
  staging: rtl8192e: Remove dead code
  staging: rtl8192e: Comment cleanup (style/format)
  staging: rtl8192e: Fix indentation in rtllib_rx_auth_resp()
  staging: rtl8192e: Decrease nesting of rtllib_rx_auth_resp()
  staging: rtl8192e: Divide rtllib_rx_auth()
  staging: rtl8192e: Fix PRINTK_WITHOUT_KERN_LEVEL warnings
  staging: rtl8192e: Fix DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON warning
  staging: rtl8192e: Fix BRACES warning
  staging: rtl8192e: Fix LINE_CONTINUATIONS warning
  staging: rtl8192e: Fix UNNECESSARY_PARENTHESES warnings
  staging: rtl8192e: remove unused EXPORT_SYMBOL_RSL macro
  staging: rtl8192e: Fix RETURN_VOID warnings
  staging: rtl8192e: Fix UNNECESSARY_ELSE warning
  staging: rtl8723au: Remove unneeded comments
  staging: rtl8723au: Use __func__ in trace logs
  ...

828 files changed:
Documentation/ABI/testing/sysfs-bus-iio
Documentation/devicetree/bindings/iio/adc/mcp320x.txt [new file with mode: 0644]
Documentation/devicetree/bindings/iio/adc/mcp3422.txt [new file with mode: 0644]
Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt [new file with mode: 0644]
Documentation/devicetree/bindings/iio/st-sensors.txt
MAINTAINERS
drivers/dma/ste_dma40.c
drivers/iio/accel/bmc150-accel.c
drivers/iio/accel/kxcjk-1013.c
drivers/iio/accel/mma9551.c
drivers/iio/accel/mma9553.c
drivers/iio/accel/st_accel.h
drivers/iio/accel/st_accel_core.c
drivers/iio/accel/st_accel_i2c.c
drivers/iio/adc/Kconfig
drivers/iio/adc/ad7793.c
drivers/iio/adc/vf610_adc.c
drivers/iio/common/ssp_sensors/ssp_dev.c
drivers/iio/dac/Kconfig
drivers/iio/dac/max517.c
drivers/iio/gyro/bmg160.c
drivers/iio/gyro/itg3200_core.c
drivers/iio/gyro/st_gyro_core.c
drivers/iio/imu/inv_mpu6050/Makefile
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c [new file with mode: 0644]
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
drivers/iio/imu/kmx61.c
drivers/iio/industrialio-buffer.c
drivers/iio/kfifo_buf.c
drivers/iio/light/Kconfig
drivers/iio/light/Makefile
drivers/iio/light/cm3232.c
drivers/iio/light/cm3323.c [new file with mode: 0644]
drivers/iio/light/gp2ap020a00f.c
drivers/iio/light/jsa1212.c
drivers/iio/light/ltr501.c
drivers/iio/magnetometer/mag3110.c
drivers/iio/pressure/Kconfig
drivers/iio/pressure/Makefile
drivers/iio/pressure/ms5611.h [new file with mode: 0644]
drivers/iio/pressure/ms5611_core.c [new file with mode: 0644]
drivers/iio/pressure/ms5611_i2c.c [new file with mode: 0644]
drivers/iio/pressure/ms5611_spi.c [new file with mode: 0644]
drivers/iio/proximity/sx9500.c
drivers/iio/temperature/mlx90614.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/android/ion/ion.c
drivers/staging/android/ion/ion_test.c
drivers/staging/android/sync.c
drivers/staging/comedi/Kconfig
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedi_internal.h
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.c
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/aio_iiro_16.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_fc.h [deleted file]
drivers/staging/comedi/drivers/comedi_isadma.c
drivers/staging/comedi/drivers/comedi_parport.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_isadma.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/pcl726.c
drivers/staging/comedi/drivers/pcl812.c
drivers/staging/comedi/drivers/pcl816.c
drivers/staging/comedi/drivers/pcl818.c
drivers/staging/comedi/drivers/pcmmio.c
drivers/staging/comedi/drivers/pcmuio.c
drivers/staging/comedi/drivers/quatech_daqp_cs.c
drivers/staging/comedi/drivers/rtd520.c
drivers/staging/comedi/drivers/s626.c
drivers/staging/comedi/drivers/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 [deleted file]
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 [deleted file]
drivers/staging/dgnc/dgnc_utils.c
drivers/staging/dgnc/dgnc_utils.h
drivers/staging/dgnc/digi.h
drivers/staging/dgnc/dpacompat.h [deleted file]
drivers/staging/emxx_udc/emxx_udc.c
drivers/staging/emxx_udc/emxx_udc.h
drivers/staging/fbtft/Kconfig
drivers/staging/fbtft/Makefile
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_hx8347d.c
drivers/staging/fbtft/fb_hx8353d.c
drivers/staging/fbtft/fb_ili9163.c [new file with mode: 0644]
drivers/staging/fbtft/fb_ili9320.c
drivers/staging/fbtft/fb_ili9325.c
drivers/staging/fbtft/fb_ili9340.c
drivers/staging/fbtft/fb_ili9341.c
drivers/staging/fbtft/fb_ili9481.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_ssd1289.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_tinylcd.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.h
drivers/staging/fbtft/fbtft_device.c
drivers/staging/fbtft/flexfb.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 [deleted file]
drivers/staging/iio/Documentation/iio_event_monitor.c [deleted file]
drivers/staging/iio/Documentation/iio_utils.h [deleted file]
drivers/staging/iio/Documentation/lsiio.c [deleted file]
drivers/staging/iio/accel/adis16201.h
drivers/staging/iio/accel/adis16201_core.c
drivers/staging/iio/accel/adis16203.h
drivers/staging/iio/accel/adis16203_core.c
drivers/staging/iio/accel/adis16204.h
drivers/staging/iio/accel/adis16204_core.c
drivers/staging/iio/accel/adis16209.h
drivers/staging/iio/accel/adis16209_core.c
drivers/staging/iio/accel/adis16220.h
drivers/staging/iio/accel/adis16220_core.c
drivers/staging/iio/accel/adis16240.h
drivers/staging/iio/accel/adis16240_core.c
drivers/staging/iio/accel/lis3l02dq.h
drivers/staging/iio/accel/lis3l02dq_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/accel/sca3000_ring.c
drivers/staging/iio/adc/ad7192.c
drivers/staging/iio/adc/ad7280a.c
drivers/staging/iio/adc/ad7280a.h
drivers/staging/iio/adc/ad7606_ring.c
drivers/staging/iio/adc/ad7780.c
drivers/staging/iio/adc/mxs-lradc.c
drivers/staging/iio/adc/spear_adc.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_dummy_evgen.c
drivers/staging/iio/iio_simple_dummy.c
drivers/staging/iio/iio_simple_dummy_buffer.c
drivers/staging/iio/impedance-analyzer/ad5933.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/magnetometer/hmc5843_spi.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/ade7758_trigger.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/iio/trigger/iio-trig-periodic-rtc.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/api-ni.c
drivers/staging/lustre/lnet/lnet/config.c
drivers/staging/lustre/lnet/lnet/lib-eq.c
drivers/staging/lustre/lnet/lnet/lib-md.c
drivers/staging/lustre/lnet/lnet/lib-move.c
drivers/staging/lustre/lnet/lnet/peer.c
drivers/staging/lustre/lnet/lnet/router.c
drivers/staging/lustre/lnet/selftest/brw_test.c
drivers/staging/lustre/lnet/selftest/conctl.c
drivers/staging/lustre/lnet/selftest/console.c
drivers/staging/lustre/lnet/selftest/console.h
drivers/staging/lustre/lnet/selftest/framework.c
drivers/staging/lustre/lnet/selftest/module.c
drivers/staging/lustre/lnet/selftest/ping_test.c
drivers/staging/lustre/lnet/selftest/rpc.c
drivers/staging/lustre/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_import.h
drivers/staging/lustre/lustre/include/lustre_net.h
drivers/staging/lustre/lustre/include/obd_class.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/ldlm/ldlm_resource.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-module.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_internal.h
drivers/staging/lustre/lustre/lov/lov_io.c
drivers/staging/lustre/lustre/lov/lov_lock.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/lov_request.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/class_obd.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_cache.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/import.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-usb/octeon-hcd.h
drivers/staging/octeon/ethernet-mdio.c
drivers/staging/octeon/ethernet-mdio.h
drivers/staging/octeon/ethernet.c
drivers/staging/olpc_dcon/olpc_dcon.c
drivers/staging/ozwpan/ozhcd.c
drivers/staging/ozwpan/ozmain.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_cmdpkt.h
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/r819xE_phyreg.h
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.h
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_BAProc.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/rtl8712/xmit_linux.c
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_cmd.c
drivers/staging/rtl8723au/core/rtw_efuse.c
drivers/staging/rtl8723au/core/rtw_ieee80211.c
drivers/staging/rtl8723au/core/rtw_mlme.c
drivers/staging/rtl8723au/core/rtw_mlme_ext.c
drivers/staging/rtl8723au/core/rtw_pwrctrl.c
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/core/rtw_security.c
drivers/staging/rtl8723au/core/rtw_sta_mgt.c
drivers/staging/rtl8723au/core/rtw_wlan_util.c
drivers/staging/rtl8723au/core/rtw_xmit.c
drivers/staging/rtl8723au/hal/HalDMOutSrc8723A_CE.c
drivers/staging/rtl8723au/hal/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_debug.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/rtl8723au_xmit.c
drivers/staging/rtl8723au/hal/usb_halinit.c
drivers/staging/rtl8723au/hal/usb_ops_linux.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/include/rtw_debug.h
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
drivers/staging/rtl8723au/os_dep/os_intfs.c
drivers/staging/rtl8723au/os_dep/recv_linux.c
drivers/staging/rtl8723au/os_dep/usb_intf.c
drivers/staging/rtl8723au/os_dep/usb_ops_linux.c
drivers/staging/rtl8723au/os_dep/xmit_linux.c
drivers/staging/rts5208/Makefile
drivers/staging/rts5208/ms.c
drivers/staging/rts5208/ms.h
drivers/staging/rts5208/rtsx.c
drivers/staging/rts5208/rtsx.h
drivers/staging/rts5208/rtsx_card.c
drivers/staging/rts5208/rtsx_card.h
drivers/staging/rts5208/rtsx_chip.c
drivers/staging/rts5208/rtsx_chip.h
drivers/staging/rts5208/rtsx_scsi.c
drivers/staging/rts5208/rtsx_transport.c
drivers/staging/rts5208/sd.c
drivers/staging/rts5208/sd.h
drivers/staging/rts5208/spi.c
drivers/staging/rts5208/trace.c [new file with mode: 0644]
drivers/staging/rts5208/trace.h
drivers/staging/rts5208/xd.c
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/serialio.h
drivers/staging/speakup/speakup.h
drivers/staging/speakup/speakup_acntpc.c
drivers/staging/speakup/speakup_acntsa.c
drivers/staging/speakup/speakup_apollo.c
drivers/staging/speakup/speakup_audptr.c
drivers/staging/speakup/speakup_bns.c
drivers/staging/speakup/speakup_decext.c
drivers/staging/speakup/speakup_decpc.c
drivers/staging/speakup/speakup_dectlk.c
drivers/staging/speakup/speakup_dtlk.c
drivers/staging/speakup/speakup_dummy.c
drivers/staging/speakup/speakup_keypc.c
drivers/staging/speakup/speakup_ltlk.c
drivers/staging/speakup/speakup_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/file.h
drivers/staging/unisys/visorchipset/globals.h
drivers/staging/unisys/visorchipset/parser.c
drivers/staging/unisys/visorchipset/parser.h
drivers/staging/unisys/visorchipset/visorchipset.h
drivers/staging/unisys/visorchipset/visorchipset_main.c
drivers/staging/unisys/visorutil/Kconfig
drivers/staging/unisys/visorutil/Makefile
drivers/staging/unisys/visorutil/charqueue.c
drivers/staging/unisys/visorutil/charqueue.h
drivers/staging/unisys/visorutil/easyproc.c [deleted file]
drivers/staging/unisys/visorutil/easyproc.h [deleted file]
drivers/staging/unisys/visorutil/memregion_direct.c
drivers/staging/unisys/visorutil/periodic_work.c
drivers/staging/unisys/visorutil/procobjecttree.c [deleted file]
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/iio/buffer.h
include/linux/iio/dac/max517.h
include/linux/iio/events.h
include/linux/iio/iio.h
include/linux/iio/types.h
include/linux/vme.h
include/uapi/linux/Kbuild
include/uapi/linux/iio/Kbuild [new file with mode: 0644]
include/uapi/linux/iio/events.h [new file with mode: 0644]
include/uapi/linux/iio/types.h [new file with mode: 0644]
tools/iio/Makefile [new file with mode: 0644]
tools/iio/generic_buffer.c [new file with mode: 0644]
tools/iio/iio_event_monitor.c [new file with mode: 0644]
tools/iio/iio_utils.c [new file with mode: 0644]
tools/iio/iio_utils.h [new file with mode: 0644]
tools/iio/lsiio.c [new file with mode: 0644]

index 9a70c31619ea8a72e3d756413e4b24f65c7aab4b..3befcb19f41415393e56a6ef496675ab31c4bc2a 100644 (file)
@@ -253,6 +253,8 @@ What:               /sys/bus/iio/devices/iio:deviceX/in_temp_offset
 What:          /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset
 What:          /sys/bus/iio/devices/iio:deviceX/in_pressure_offset
 What:          /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_offset
+What:          /sys/bus/iio/devices/iio:deviceX/in_magn_offset
+What:          /sys/bus/iio/devices/iio:deviceX/in_rot_offset
 KernelVersion: 2.6.35
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -296,6 +298,7 @@ What:               /sys/bus/iio/devices/iio:deviceX/in_pressureY_scale
 What:          /sys/bus/iio/devices/iio:deviceX/in_pressure_scale
 What:          /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_scale
 What:          /sys/bus/iio/devices/iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_scale
+What:          /sys/bus/iio/devices/iio:deviceX/in_illuminance_scale
 KernelVersion: 2.6.35
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -336,6 +339,7 @@ what                /sys/bus/iio/devices/iio:deviceX/in_illuminance0_calibscale
 what           /sys/bus/iio/devices/iio:deviceX/in_proximity0_calibscale
 What:          /sys/bus/iio/devices/iio:deviceX/in_pressureY_calibscale
 What:          /sys/bus/iio/devices/iio:deviceX/in_pressure_calibscale
+What:          /sys/bus/iio/devices/iio:deviceX/in_illuminance_calibscale
 KernelVersion: 2.6.35
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -347,7 +351,7 @@ What:               /sys/bus/iio/devices/iio:deviceX/in_activity_calibgender
 What:          /sys/bus/iio/devices/iio:deviceX/in_energy_calibgender
 What:          /sys/bus/iio/devices/iio:deviceX/in_distance_calibgender
 What:          /sys/bus/iio/devices/iio:deviceX/in_velocity_calibgender
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Gender of the user (e.g.: male, female) used by some pedometers
@@ -358,7 +362,7 @@ What:               /sys/bus/iio/devices/iio:deviceX/in_activity_calibgender_available
 What:          /sys/bus/iio/devices/iio:deviceX/in_energy_calibgender_available
 What:          /sys/bus/iio/devices/iio:deviceX/in_distance_calibgender_available
 What:          /sys/bus/iio/devices/iio:deviceX/in_velocity_calibgender_available
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Lists all available gender values (e.g.: male, female).
@@ -375,7 +379,7 @@ Description:
                type.
 
 What:          /sys/bus/iio/devices/iio:deviceX/in_energy_calibweight
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Weight of the user (in kg). It is needed by some pedometers
@@ -612,6 +616,8 @@ Description:
                a given event type is enabled a future point (and not those for
                whatever event was previously enabled).
 
+What:          /sys/.../events/in_accel_thresh_rising_value
+What:          /sys/.../events/in_accel_thresh_falling_value
 What:          /sys/.../events/in_accel_x_raw_thresh_rising_value
 What:          /sys/.../events/in_accel_x_raw_thresh_falling_value
 What:          /sys/.../events/in_accel_y_raw_thresh_rising_value
@@ -661,6 +667,24 @@ Description:
                value is in raw device units or in processed units (as _raw
                and _input do on sysfs direct channel read attributes).
 
+What:          /sys/.../events/in_accel_scale
+What:          /sys/.../events/in_accel_peak_scale
+What:          /sys/.../events/in_anglvel_scale
+What:          /sys/.../events/in_magn_scale
+What:          /sys/.../events/in_rot_from_north_magnetic_scale
+What:          /sys/.../events/in_rot_from_north_true_scale
+What:          /sys/.../events/in_voltage_scale
+What:          /sys/.../events/in_voltage_supply_scale
+What:          /sys/.../events/in_temp_scale
+What:          /sys/.../events/in_illuminance_scale
+What:          /sys/.../events/in_proximity_scale
+KernelVersion: 3.21
+Contact:       linux-iio@vger.kernel.org
+Description:
+                Specifies the conversion factor from the standard units
+                to device specific units used to set the event trigger
+                threshold.
+
 What:          /sys/.../events/in_accel_x_thresh_rising_hysteresis
 What:          /sys/.../events/in_accel_x_thresh_falling_hysteresis
 What:          /sys/.../events/in_accel_x_thresh_either_hysteresis
@@ -776,7 +800,7 @@ Description:
 
 What:          /sys/.../events/in_accel_x_thresh_rising_period
 What:          /sys/.../events/in_accel_x_thresh_falling_period
-hat:           /sys/.../events/in_accel_x_roc_rising_period
+What:          /sys/.../events/in_accel_x_roc_rising_period
 What:          /sys/.../events/in_accel_x_roc_falling_period
 What:          /sys/.../events/in_accel_y_thresh_rising_period
 What:          /sys/.../events/in_accel_y_thresh_falling_period
@@ -923,7 +947,7 @@ Description:
                this type.
 
 What:          /sys/.../events/in_steps_change_en
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Event generated when channel passes a threshold on the absolute
@@ -932,7 +956,7 @@ Description:
                in_steps_change_value.
 
 What:          /sys/.../events/in_steps_change_value
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Specifies the value of change threshold that the
@@ -997,6 +1021,7 @@ What:              /sys/.../iio:deviceX/scan_elements/in_incli_y_en
 What:          /sys/.../iio:deviceX/scan_elements/in_pressureY_en
 What:          /sys/.../iio:deviceX/scan_elements/in_pressure_en
 What:          /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_en
+What:          /sys/.../iio:deviceX/scan_elements/in_proximity_en
 KernelVersion: 2.6.37
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -1013,6 +1038,7 @@ What:             /sys/.../iio:deviceX/scan_elements/in_timestamp_type
 What:          /sys/.../iio:deviceX/scan_elements/in_pressureY_type
 What:          /sys/.../iio:deviceX/scan_elements/in_pressure_type
 What:          /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_type
+What:          /sys/.../iio:deviceX/scan_elements/in_proximity_type
 KernelVersion: 2.6.37
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -1064,6 +1090,7 @@ What:             /sys/.../iio:deviceX/scan_elements/in_timestamp_index
 What:          /sys/.../iio:deviceX/scan_elements/in_pressureY_index
 What:          /sys/.../iio:deviceX/scan_elements/in_pressure_index
 What:          /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_index
+What:          /sys/.../iio:deviceX/scan_elements/in_proximity_index
 KernelVersion: 2.6.37
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -1104,7 +1131,7 @@ Description:
 
 What:          /sys/.../iio:deviceX/in_energy_input
 What:          /sys/.../iio:deviceX/in_energy_raw
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                This attribute is used to read the energy value reported by the
@@ -1113,7 +1140,7 @@ Description:
 
 What:          /sys/.../iio:deviceX/in_distance_input
 What:          /sys/.../iio:deviceX/in_distance_raw
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                This attribute is used to read the distance covered by the user
@@ -1143,9 +1170,13 @@ Description:
                values should behave in the same way as a distance, i.e. lower
                values indicate something is closer to the sensor.
 
+What:          /sys/.../iio:deviceX/in_illuminance_input
+What:          /sys/.../iio:deviceX/in_illuminance_raw
 What:          /sys/.../iio:deviceX/in_illuminanceY_input
 What:          /sys/.../iio:deviceX/in_illuminanceY_raw
 What:          /sys/.../iio:deviceX/in_illuminanceY_mean_raw
+What:          /sys/.../iio:deviceX/in_illuminance_ir_raw
+What:          /sys/.../iio:deviceX/in_illuminance_clear_raw
 KernelVersion: 3.4
 Contact:       linux-iio@vger.kernel.org
 Description:
@@ -1174,7 +1205,7 @@ Description:
                seconds.
 
 What:          /sys/.../iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_integration_time
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Number of seconds in which to compute speed.
@@ -1236,7 +1267,7 @@ Description:
                Units after application of scale are m/s.
 
 What:          /sys/.../iio:deviceX/in_steps_debounce_count
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Specifies the number of steps that must occur within
@@ -1244,8 +1275,92 @@ Description:
                consumer is making steps.
 
 What:          /sys/.../iio:deviceX/in_steps_debounce_time
-KernelVersion: 3.20
+KernelVersion: 4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Specifies number of seconds in which we compute the steps
                that occur in order to decide if the consumer is making steps.
+
+What:          /sys/bus/iio/devices/iio:deviceX/buffer/watermark
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               A single positive integer specifying the maximum number of scan
+               elements to wait for.
+               Poll will block until the watermark is reached.
+               Blocking read will wait until the minimum between the requested
+               read amount or the low water mark is available.
+               Non-blocking read will retrieve the available samples from the
+               buffer even if there are less samples then watermark level. This
+               allows the application to block on poll with a timeout and read
+               the available samples after the timeout expires and thus have a
+               maximum delay guarantee.
+
+What:          /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_enabled
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               A read-only boolean value that indicates if the hardware fifo is
+               currently enabled or disabled. If the device does not have a
+               hardware fifo this entry is not present.
+               The hardware fifo is enabled when the buffer is enabled if the
+               current hardware fifo watermark level is set and other current
+               device settings allows it (e.g. if a trigger is set that samples
+               data differently that the hardware fifo does then hardware fifo
+               will not enabled).
+               If the hardware fifo is enabled and the level of the hardware
+               fifo reaches the hardware fifo watermark level the device will
+               flush its hardware fifo to the device buffer. Doing a non
+               blocking read on the device when no samples are present in the
+               device buffer will also force a flush.
+               When the hardware fifo is enabled there is no need to use a
+               trigger to use buffer mode since the watermark settings
+               guarantees that the hardware fifo is flushed to the device
+               buffer.
+
+What:          /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_watermark
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               Read-only entry that contains a single integer specifying the
+               current watermark level for the hardware fifo. If the device
+               does not have a hardware fifo this entry is not present.
+               The watermark level for the hardware fifo is set by the driver
+               based on the value set by the user in buffer/watermark but
+               taking into account hardware limitations (e.g. most hardware
+               buffers are limited to 32-64 samples, some hardware buffers
+               watermarks are fixed or have minimum levels).  A value of 0
+               means that the hardware watermark is unset.
+
+What:          /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_watermark_min
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               A single positive integer specifying the minimum watermark level
+               for the hardware fifo of this device. If the device does not
+               have a hardware fifo this entry is not present.
+               If the user sets buffer/watermark to a value less than this one,
+               then the hardware watermark will remain unset.
+
+What:         /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_watermark_max
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               A single positive integer specifying the maximum watermark level
+               for the hardware fifo of this device. If the device does not
+               have a hardware fifo this entry is not present.
+               If the user sets buffer/watermark to a value greater than this
+               one, then the hardware watermark will be capped at this value.
+
+What:         /sys/bus/iio/devices/iio:deviceX/buffer/hwfifo_watermark_available
+KernelVersion: 4.2
+Contact:       linux-iio@vger.kernel.org
+Description:
+               A list of positive integers specifying the available watermark
+               levels for the hardware fifo. This entry is optional and if it
+               is not present it means that all the values between
+               hwfifo_watermark_min and hwfifo_watermark_max are supported.
+               If the user sets buffer/watermark to a value greater than
+               hwfifo_watermak_min but not equal to any of the values in this
+               list, the driver will chose an appropriate value for the
+               hardware fifo watermark level.
diff --git a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
new file mode 100644 (file)
index 0000000..b851843
--- /dev/null
@@ -0,0 +1,30 @@
+* Microchip Analog to Digital Converter (ADC)
+
+The node for this driver must be a child node of a SPI controller, hence
+all mandatory properties described in
+
+        Documentation/devicetree/bindings/spi/spi-bus.txt
+
+must be specified.
+
+Required properties:
+       - compatible:   Must be one of the following, depending on the
+                       model:
+                               "mcp3001"
+                               "mcp3002"
+                               "mcp3004"
+                               "mcp3008"
+                               "mcp3201"
+                               "mcp3202"
+                               "mcp3204"
+                               "mcp3208"
+
+
+Examples:
+spi_controller {
+       mcp3x0x@0 {
+               compatible = "mcp3002";
+               reg = <0>;
+               spi-max-frequency = <1000000>;
+       };
+};
diff --git a/Documentation/devicetree/bindings/iio/adc/mcp3422.txt b/Documentation/devicetree/bindings/iio/adc/mcp3422.txt
new file mode 100644 (file)
index 0000000..333139c
--- /dev/null
@@ -0,0 +1,17 @@
+* Microchip mcp3422/3/4/6/7/8 chip family (ADC)
+
+Required properties:
+ - compatible: Should be
+       "microchip,mcp3422" or
+       "microchip,mcp3423" or
+       "microchip,mcp3424" or
+       "microchip,mcp3426" or
+       "microchip,mcp3427" or
+       "microchip,mcp3428"
+ - reg: I2C address for the device
+
+Example:
+adc@0 {
+       compatible = "microchip,mcp3424";
+       reg = <0x68>;
+};
diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
new file mode 100644 (file)
index 0000000..42ca7de
--- /dev/null
@@ -0,0 +1,18 @@
+* Texas Instruments' ADC128S052 ADC chip
+
+Required properties:
+ - compatible: Should be "ti,adc128s052"
+ - reg: spi chip select number for the device
+ - vref-supply: The regulator supply for ADC reference voltage
+
+Recommended properties:
+ - spi-max-frequency: Definition as per
+               Documentation/devicetree/bindings/spi/spi-bus.txt
+
+Example:
+adc@0 {
+       compatible = "ti,adc128s052";
+       reg = <0>;
+       vref-supply = <&vdd_supply>;
+       spi-max-frequency = <1000000>;
+};
index a7a0a15913ad21727c71f4a40ec5cc7a01044e61..d2aaca97453196cc351fe0f6a2e067cc8403a9b3 100644 (file)
@@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
 Valid compatible strings:
 
 Accelerometers:
+- st,lis3lv02dl-accel
 - st,lsm303dlh-accel
 - st,lsm303dlhc-accel
 - st,lis3dh-accel
index 45825b91ccafe24e37e90123b2135c2ed27c9daa..38579ac581cebe678ee6eabda15c7933d89bfcee 100644 (file)
@@ -724,7 +724,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
@@ -4169,6 +4169,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
@@ -4954,6 +4960,7 @@ S:        Maintained
 F:     drivers/iio/
 F:     drivers/staging/iio/
 F:     include/linux/iio/
+F:     tools/iio/
 
 IKANOS/ADI EAGLE ADSL USB DRIVER
 M:     Matthieu Castet <castet.matthieu@free.fr>
@@ -9363,6 +9370,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 75567fd457dcc4b9bd7c147fdc4cb229cdbaf0c4..73e87739d2191831187ab30416b4111dcfda8ecc 100644 (file)
@@ -70,7 +70,9 @@
 #define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE       BIT(2)
 
 #define BMC150_ACCEL_REG_INT_MAP_1             0x1A
-#define BMC150_ACCEL_INT_MAP_1_BIT_DATA        BIT(0)
+#define BMC150_ACCEL_INT_MAP_1_BIT_DATA                BIT(0)
+#define BMC150_ACCEL_INT_MAP_1_BIT_FWM         BIT(1)
+#define BMC150_ACCEL_INT_MAP_1_BIT_FFULL       BIT(2)
 
 #define BMC150_ACCEL_REG_INT_RST_LATCH         0x21
 #define BMC150_ACCEL_INT_MODE_LATCH_RESET      0x80
@@ -83,7 +85,9 @@
 #define BMC150_ACCEL_INT_EN_BIT_SLP_Z          BIT(2)
 
 #define BMC150_ACCEL_REG_INT_EN_1              0x17
-#define BMC150_ACCEL_INT_EN_BIT_DATA_EN        BIT(4)
+#define BMC150_ACCEL_INT_EN_BIT_DATA_EN                BIT(4)
+#define BMC150_ACCEL_INT_EN_BIT_FFULL_EN       BIT(5)
+#define BMC150_ACCEL_INT_EN_BIT_FWM_EN         BIT(6)
 
 #define BMC150_ACCEL_REG_INT_OUT_CTRL          0x20
 #define BMC150_ACCEL_INT_OUT_CTRL_INT1_LVL     BIT(0)
 #define BMC150_ACCEL_AXIS_TO_REG(axis) (BMC150_ACCEL_REG_XOUT_L + (axis * 2))
 #define BMC150_AUTO_SUSPEND_DELAY_MS           2000
 
+#define BMC150_ACCEL_REG_FIFO_STATUS           0x0E
+#define BMC150_ACCEL_REG_FIFO_CONFIG0          0x30
+#define BMC150_ACCEL_REG_FIFO_CONFIG1          0x3E
+#define BMC150_ACCEL_REG_FIFO_DATA             0x3F
+#define BMC150_ACCEL_FIFO_LENGTH               32
+
 enum bmc150_accel_axis {
        AXIS_X,
        AXIS_Y,
@@ -147,20 +157,46 @@ struct bmc150_accel_chip_info {
        const struct bmc150_scale_info scale_table[4];
 };
 
+struct bmc150_accel_interrupt {
+       const struct bmc150_accel_interrupt_info *info;
+       atomic_t users;
+};
+
+struct bmc150_accel_trigger {
+       struct bmc150_accel_data *data;
+       struct iio_trigger *indio_trig;
+       int (*setup)(struct bmc150_accel_trigger *t, bool state);
+       int intr;
+       bool enabled;
+};
+
+enum bmc150_accel_interrupt_id {
+       BMC150_ACCEL_INT_DATA_READY,
+       BMC150_ACCEL_INT_ANY_MOTION,
+       BMC150_ACCEL_INT_WATERMARK,
+       BMC150_ACCEL_INTERRUPTS,
+};
+
+enum bmc150_accel_trigger_id {
+       BMC150_ACCEL_TRIGGER_DATA_READY,
+       BMC150_ACCEL_TRIGGER_ANY_MOTION,
+       BMC150_ACCEL_TRIGGERS,
+};
+
 struct bmc150_accel_data {
        struct i2c_client *client;
-       struct iio_trigger *dready_trig;
-       struct iio_trigger *motion_trig;
+       struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS];
+       atomic_t active_intr;
+       struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
        struct mutex mutex;
+       u8 fifo_mode, watermark;
        s16 buffer[8];
        u8 bw_bits;
        u32 slope_dur;
        u32 slope_thres;
        u32 range;
        int ev_enable_state;
-       bool dready_trigger_on;
-       bool motion_trigger_on;
-       int64_t timestamp;
+       int64_t timestamp, old_timestamp;
        const struct bmc150_accel_chip_info *chip_info;
 };
 
@@ -269,6 +305,46 @@ static int bmc150_accel_set_bw(struct bmc150_accel_data *data, int val,
        return -EINVAL;
 }
 
+static int bmc150_accel_update_slope(struct bmc150_accel_data *data)
+{
+       int ret, val;
+
+       ret = i2c_smbus_write_byte_data(data->client, BMC150_ACCEL_REG_INT_6,
+                                       data->slope_thres);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error writing reg_int_6\n");
+               return ret;
+       }
+
+       ret = i2c_smbus_read_byte_data(data->client, BMC150_ACCEL_REG_INT_5);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error reading reg_int_5\n");
+               return ret;
+       }
+
+       val = (ret & ~BMC150_ACCEL_SLOPE_DUR_MASK) | data->slope_dur;
+       ret = i2c_smbus_write_byte_data(data->client, BMC150_ACCEL_REG_INT_5,
+                                       val);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error write reg_int_5\n");
+               return ret;
+       }
+
+       dev_dbg(&data->client->dev, "%s: %x %x\n", __func__, data->slope_thres,
+               data->slope_dur);
+
+       return ret;
+}
+
+static int bmc150_accel_any_motion_setup(struct bmc150_accel_trigger *t,
+                                        bool state)
+{
+       if (state)
+               return bmc150_accel_update_slope(t->data);
+
+       return 0;
+}
+
 static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
 {
        int ret;
@@ -307,32 +383,12 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
 
        data->range = BMC150_ACCEL_DEF_RANGE_4G;
 
-       /* Set default slope duration */
-       ret = i2c_smbus_read_byte_data(data->client, BMC150_ACCEL_REG_INT_5);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error reading reg_int_5\n");
-               return ret;
-       }
-       data->slope_dur |= BMC150_ACCEL_DEF_SLOPE_DURATION;
-       ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_5,
-                                       data->slope_dur);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_5\n");
-               return ret;
-       }
-       dev_dbg(&data->client->dev, "slope_dur %x\n", data->slope_dur);
-
-       /* Set default slope thresholds */
-       ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_6,
-                                       BMC150_ACCEL_DEF_SLOPE_THRESHOLD);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_6\n");
-               return ret;
-       }
+       /* Set default slope duration and thresholds */
        data->slope_thres = BMC150_ACCEL_DEF_SLOPE_THRESHOLD;
-       dev_dbg(&data->client->dev, "slope_thres %x\n", data->slope_thres);
+       data->slope_dur = BMC150_ACCEL_DEF_SLOPE_DURATION;
+       ret = bmc150_accel_update_slope(data);
+       if (ret < 0)
+               return ret;
 
        /* Set default as latched interrupts */
        ret = i2c_smbus_write_byte_data(data->client,
@@ -348,155 +404,6 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
        return 0;
 }
 
-static int bmc150_accel_setup_any_motion_interrupt(
-                                       struct bmc150_accel_data *data,
-                                       bool status)
-{
-       int ret;
-
-       /* Enable/Disable INT1 mapping */
-       ret = i2c_smbus_read_byte_data(data->client,
-                                      BMC150_ACCEL_REG_INT_MAP_0);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error reading reg_int_map_0\n");
-               return ret;
-       }
-       if (status)
-               ret |= BMC150_ACCEL_INT_MAP_0_BIT_SLOPE;
-       else
-               ret &= ~BMC150_ACCEL_INT_MAP_0_BIT_SLOPE;
-
-       ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_MAP_0,
-                                       ret);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_map_0\n");
-               return ret;
-       }
-
-       if (status) {
-               /* Set slope duration (no of samples) */
-               ret = i2c_smbus_write_byte_data(data->client,
-                                               BMC150_ACCEL_REG_INT_5,
-                                               data->slope_dur);
-               if (ret < 0) {
-                       dev_err(&data->client->dev, "Error write reg_int_5\n");
-                       return ret;
-               }
-
-               /* Set slope thresholds */
-               ret = i2c_smbus_write_byte_data(data->client,
-                                               BMC150_ACCEL_REG_INT_6,
-                                               data->slope_thres);
-               if (ret < 0) {
-                       dev_err(&data->client->dev, "Error write reg_int_6\n");
-                       return ret;
-               }
-
-               /*
-                * New data interrupt is always non-latched,
-                * which will have higher priority, so no need
-                * to set latched mode, we will be flooded anyway with INTR
-                */
-               if (!data->dready_trigger_on) {
-                       ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_RST_LATCH,
-                                       BMC150_ACCEL_INT_MODE_LATCH_INT |
-                                       BMC150_ACCEL_INT_MODE_LATCH_RESET);
-                       if (ret < 0) {
-                               dev_err(&data->client->dev,
-                                       "Error writing reg_int_rst_latch\n");
-                               return ret;
-                       }
-               }
-
-               ret = i2c_smbus_write_byte_data(data->client,
-                                               BMC150_ACCEL_REG_INT_EN_0,
-                                               BMC150_ACCEL_INT_EN_BIT_SLP_X |
-                                               BMC150_ACCEL_INT_EN_BIT_SLP_Y |
-                                               BMC150_ACCEL_INT_EN_BIT_SLP_Z);
-       } else
-               ret = i2c_smbus_write_byte_data(data->client,
-                                               BMC150_ACCEL_REG_INT_EN_0,
-                                               0);
-
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_en_0\n");
-               return ret;
-       }
-
-       return 0;
-}
-
-static int bmc150_accel_setup_new_data_interrupt(struct bmc150_accel_data *data,
-                                          bool status)
-{
-       int ret;
-
-       /* Enable/Disable INT1 mapping */
-       ret = i2c_smbus_read_byte_data(data->client,
-                                      BMC150_ACCEL_REG_INT_MAP_1);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error reading reg_int_map_1\n");
-               return ret;
-       }
-       if (status)
-               ret |= BMC150_ACCEL_INT_MAP_1_BIT_DATA;
-       else
-               ret &= ~BMC150_ACCEL_INT_MAP_1_BIT_DATA;
-
-       ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_MAP_1,
-                                       ret);
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_map_1\n");
-               return ret;
-       }
-
-       if (status) {
-               /*
-                * Set non latched mode interrupt and clear any latched
-                * interrupt
-                */
-               ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_RST_LATCH,
-                                       BMC150_ACCEL_INT_MODE_NON_LATCH_INT |
-                                       BMC150_ACCEL_INT_MODE_LATCH_RESET);
-               if (ret < 0) {
-                       dev_err(&data->client->dev,
-                               "Error writing reg_int_rst_latch\n");
-                       return ret;
-               }
-
-               ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_EN_1,
-                                       BMC150_ACCEL_INT_EN_BIT_DATA_EN);
-
-       } else {
-               /* Restore default interrupt mode */
-               ret = i2c_smbus_write_byte_data(data->client,
-                                       BMC150_ACCEL_REG_INT_RST_LATCH,
-                                       BMC150_ACCEL_INT_MODE_LATCH_INT |
-                                       BMC150_ACCEL_INT_MODE_LATCH_RESET);
-               if (ret < 0) {
-                       dev_err(&data->client->dev,
-                               "Error writing reg_int_rst_latch\n");
-                       return ret;
-               }
-
-               ret = i2c_smbus_write_byte_data(data->client,
-                                               BMC150_ACCEL_REG_INT_EN_1,
-                                               0);
-       }
-
-       if (ret < 0) {
-               dev_err(&data->client->dev, "Error writing reg_int_en_1\n");
-               return ret;
-       }
-
-       return 0;
-}
-
 static int bmc150_accel_get_bw(struct bmc150_accel_data *data, int *val,
                               int *val2)
 {
@@ -554,6 +461,120 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
 }
 #endif
 
+static const struct bmc150_accel_interrupt_info {
+       u8 map_reg;
+       u8 map_bitmask;
+       u8 en_reg;
+       u8 en_bitmask;
+} bmc150_accel_interrupts[BMC150_ACCEL_INTERRUPTS] = {
+       { /* data ready interrupt */
+               .map_reg = BMC150_ACCEL_REG_INT_MAP_1,
+               .map_bitmask = BMC150_ACCEL_INT_MAP_1_BIT_DATA,
+               .en_reg = BMC150_ACCEL_REG_INT_EN_1,
+               .en_bitmask = BMC150_ACCEL_INT_EN_BIT_DATA_EN,
+       },
+       {  /* motion interrupt */
+               .map_reg = BMC150_ACCEL_REG_INT_MAP_0,
+               .map_bitmask = BMC150_ACCEL_INT_MAP_0_BIT_SLOPE,
+               .en_reg = BMC150_ACCEL_REG_INT_EN_0,
+               .en_bitmask =  BMC150_ACCEL_INT_EN_BIT_SLP_X |
+                       BMC150_ACCEL_INT_EN_BIT_SLP_Y |
+                       BMC150_ACCEL_INT_EN_BIT_SLP_Z
+       },
+       { /* fifo watermark interrupt */
+               .map_reg = BMC150_ACCEL_REG_INT_MAP_1,
+               .map_bitmask = BMC150_ACCEL_INT_MAP_1_BIT_FWM,
+               .en_reg = BMC150_ACCEL_REG_INT_EN_1,
+               .en_bitmask = BMC150_ACCEL_INT_EN_BIT_FWM_EN,
+       },
+};
+
+static void bmc150_accel_interrupts_setup(struct iio_dev *indio_dev,
+                                         struct bmc150_accel_data *data)
+{
+       int i;
+
+       for (i = 0; i < BMC150_ACCEL_INTERRUPTS; i++)
+               data->interrupts[i].info = &bmc150_accel_interrupts[i];
+}
+
+static int bmc150_accel_set_interrupt(struct bmc150_accel_data *data, int i,
+                                     bool state)
+{
+       struct bmc150_accel_interrupt *intr = &data->interrupts[i];
+       const struct bmc150_accel_interrupt_info *info = intr->info;
+       int ret;
+
+       if (state) {
+               if (atomic_inc_return(&intr->users) > 1)
+                       return 0;
+       } else {
+               if (atomic_dec_return(&intr->users) > 0)
+                       return 0;
+       }
+
+       /*
+        * We will expect the enable and disable to do operation in
+        * in reverse order. This will happen here anyway as our
+        * resume operation uses sync mode runtime pm calls, the
+        * suspend operation will be delayed by autosuspend delay
+        * So the disable operation will still happen in reverse of
+        * enable operation. When runtime pm is disabled the mode
+        * is always on so sequence doesn't matter
+        */
+       ret = bmc150_accel_set_power_state(data, state);
+       if (ret < 0)
+               return ret;
+
+       /* map the interrupt to the appropriate pins */
+       ret = i2c_smbus_read_byte_data(data->client, info->map_reg);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error reading reg_int_map\n");
+               goto out_fix_power_state;
+       }
+       if (state)
+               ret |= info->map_bitmask;
+       else
+               ret &= ~info->map_bitmask;
+
+       ret = i2c_smbus_write_byte_data(data->client, info->map_reg,
+                                       ret);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error writing reg_int_map\n");
+               goto out_fix_power_state;
+       }
+
+       /* enable/disable the interrupt */
+       ret = i2c_smbus_read_byte_data(data->client, info->en_reg);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error reading reg_int_en\n");
+               goto out_fix_power_state;
+       }
+
+       if (state)
+               ret |= info->en_bitmask;
+       else
+               ret &= ~info->en_bitmask;
+
+       ret = i2c_smbus_write_byte_data(data->client, info->en_reg, ret);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error writing reg_int_en\n");
+               goto out_fix_power_state;
+       }
+
+       if (state)
+               atomic_inc(&data->active_intr);
+       else
+               atomic_dec(&data->active_intr);
+
+       return 0;
+
+out_fix_power_state:
+       bmc150_accel_set_power_state(data, false);
+       return ret;
+}
+
+
 static int bmc150_accel_set_scale(struct bmc150_accel_data *data, int val)
 {
        int ret, i;
@@ -732,7 +753,7 @@ static int bmc150_accel_read_event(struct iio_dev *indio_dev,
                *val = data->slope_thres;
                break;
        case IIO_EV_INFO_PERIOD:
-               *val = data->slope_dur & BMC150_ACCEL_SLOPE_DUR_MASK;
+               *val = data->slope_dur;
                break;
        default:
                return -EINVAL;
@@ -755,11 +776,10 @@ static int bmc150_accel_write_event(struct iio_dev *indio_dev,
 
        switch (info) {
        case IIO_EV_INFO_VALUE:
-               data->slope_thres = val;
+               data->slope_thres = val & 0xFF;
                break;
        case IIO_EV_INFO_PERIOD:
-               data->slope_dur &= ~BMC150_ACCEL_SLOPE_DUR_MASK;
-               data->slope_dur |= val & BMC150_ACCEL_SLOPE_DUR_MASK;
+               data->slope_dur = val & BMC150_ACCEL_SLOPE_DUR_MASK;
                break;
        default:
                return -EINVAL;
@@ -788,36 +808,14 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
        struct bmc150_accel_data *data = iio_priv(indio_dev);
        int ret;
 
-       if (state && data->ev_enable_state)
+       if (state == data->ev_enable_state)
                return 0;
 
        mutex_lock(&data->mutex);
 
-       if (!state && data->motion_trigger_on) {
-               data->ev_enable_state = 0;
-               mutex_unlock(&data->mutex);
-               return 0;
-       }
-
-       /*
-        * We will expect the enable and disable to do operation in
-        * in reverse order. This will happen here anyway as our
-        * resume operation uses sync mode runtime pm calls, the
-        * suspend operation will be delayed by autosuspend delay
-        * So the disable operation will still happen in reverse of
-        * enable operation. When runtime pm is disabled the mode
-        * is always on so sequence doesn't matter
-        */
-
-       ret = bmc150_accel_set_power_state(data, state);
-       if (ret < 0) {
-               mutex_unlock(&data->mutex);
-               return ret;
-       }
-
-       ret =  bmc150_accel_setup_any_motion_interrupt(data, state);
+       ret = bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_ANY_MOTION,
+                                        state);
        if (ret < 0) {
-               bmc150_accel_set_power_state(data, false);
                mutex_unlock(&data->mutex);
                return ret;
        }
@@ -832,13 +830,224 @@ static int bmc150_accel_validate_trigger(struct iio_dev *indio_dev,
                                   struct iio_trigger *trig)
 {
        struct bmc150_accel_data *data = iio_priv(indio_dev);
+       int i;
 
-       if (data->dready_trig != trig && data->motion_trig != trig)
-               return -EINVAL;
+       for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) {
+               if (data->triggers[i].indio_trig == trig)
+                       return 0;
+       }
+
+       return -EINVAL;
+}
+
+static ssize_t bmc150_accel_get_fifo_watermark(struct device *dev,
+                                              struct device_attribute *attr,
+                                              char *buf)
+{
+       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       int wm;
+
+       mutex_lock(&data->mutex);
+       wm = data->watermark;
+       mutex_unlock(&data->mutex);
+
+       return sprintf(buf, "%d\n", wm);
+}
+
+static ssize_t bmc150_accel_get_fifo_state(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       bool state;
+
+       mutex_lock(&data->mutex);
+       state = data->fifo_mode;
+       mutex_unlock(&data->mutex);
+
+       return sprintf(buf, "%d\n", state);
+}
+
+static IIO_CONST_ATTR(hwfifo_watermark_min, "1");
+static IIO_CONST_ATTR(hwfifo_watermark_max,
+                     __stringify(BMC150_ACCEL_FIFO_LENGTH));
+static IIO_DEVICE_ATTR(hwfifo_enabled, S_IRUGO,
+                      bmc150_accel_get_fifo_state, NULL, 0);
+static IIO_DEVICE_ATTR(hwfifo_watermark, S_IRUGO,
+                      bmc150_accel_get_fifo_watermark, NULL, 0);
+
+static const struct attribute *bmc150_accel_fifo_attributes[] = {
+       &iio_const_attr_hwfifo_watermark_min.dev_attr.attr,
+       &iio_const_attr_hwfifo_watermark_max.dev_attr.attr,
+       &iio_dev_attr_hwfifo_watermark.dev_attr.attr,
+       &iio_dev_attr_hwfifo_enabled.dev_attr.attr,
+       NULL,
+};
+
+static int bmc150_accel_set_watermark(struct iio_dev *indio_dev, unsigned val)
+{
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+
+       if (val > BMC150_ACCEL_FIFO_LENGTH)
+               val = BMC150_ACCEL_FIFO_LENGTH;
+
+       mutex_lock(&data->mutex);
+       data->watermark = val;
+       mutex_unlock(&data->mutex);
 
        return 0;
 }
 
+/*
+ * We must read at least one full frame in one burst, otherwise the rest of the
+ * frame data is discarded.
+ */
+static int bmc150_accel_fifo_transfer(const struct i2c_client *client,
+                                     char *buffer, int samples)
+{
+       int sample_length = 3 * 2;
+       u8 reg_fifo_data = BMC150_ACCEL_REG_FIFO_DATA;
+       int ret = -EIO;
+
+       if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+               struct i2c_msg msg[2] = {
+                       {
+                               .addr = client->addr,
+                               .flags = 0,
+                               .buf = &reg_fifo_data,
+                               .len = sizeof(reg_fifo_data),
+                       },
+                       {
+                               .addr = client->addr,
+                               .flags = I2C_M_RD,
+                               .buf = (u8 *)buffer,
+                               .len = samples * sample_length,
+                       }
+               };
+
+               ret = i2c_transfer(client->adapter, msg, 2);
+               if (ret != 2)
+                       ret = -EIO;
+               else
+                       ret = 0;
+       } else {
+               int i, step = I2C_SMBUS_BLOCK_MAX / sample_length;
+
+               for (i = 0; i < samples * sample_length; i += step) {
+                       ret = i2c_smbus_read_i2c_block_data(client,
+                                                           reg_fifo_data, step,
+                                                           &buffer[i]);
+                       if (ret != step) {
+                               ret = -EIO;
+                               break;
+                       }
+
+                       ret = 0;
+               }
+       }
+
+       if (ret)
+               dev_err(&client->dev, "Error transferring data from fifo\n");
+
+       return ret;
+}
+
+static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
+                                    unsigned samples, bool irq)
+{
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       int ret, i;
+       u8 count;
+       u16 buffer[BMC150_ACCEL_FIFO_LENGTH * 3];
+       int64_t tstamp;
+       uint64_t sample_period;
+       ret = i2c_smbus_read_byte_data(data->client,
+                                      BMC150_ACCEL_REG_FIFO_STATUS);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error reading reg_fifo_status\n");
+               return ret;
+       }
+
+       count = ret & 0x7F;
+
+       if (!count)
+               return 0;
+
+       /*
+        * If we getting called from IRQ handler we know the stored timestamp is
+        * fairly accurate for the last stored sample. Otherwise, if we are
+        * called as a result of a read operation from userspace and hence
+        * before the watermark interrupt was triggered, take a timestamp
+        * now. We can fall anywhere in between two samples so the error in this
+        * case is at most one sample period.
+        */
+       if (!irq) {
+               data->old_timestamp = data->timestamp;
+               data->timestamp = iio_get_time_ns();
+       }
+
+       /*
+        * Approximate timestamps for each of the sample based on the sampling
+        * frequency, timestamp for last sample and number of samples.
+        *
+        * Note that we can't use the current bandwidth settings to compute the
+        * sample period because the sample rate varies with the device
+        * (e.g. between 31.70ms to 32.20ms for a bandwidth of 15.63HZ). That
+        * small variation adds when we store a large number of samples and
+        * creates significant jitter between the last and first samples in
+        * different batches (e.g. 32ms vs 21ms).
+        *
+        * To avoid this issue we compute the actual sample period ourselves
+        * based on the timestamp delta between the last two flush operations.
+        */
+       sample_period = (data->timestamp - data->old_timestamp);
+       do_div(sample_period, count);
+       tstamp = data->timestamp - (count - 1) * sample_period;
+
+       if (samples && count > samples)
+               count = samples;
+
+       ret = bmc150_accel_fifo_transfer(data->client, (u8 *)buffer, count);
+       if (ret)
+               return ret;
+
+       /*
+        * Ideally we want the IIO core to handle the demux when running in fifo
+        * mode but not when running in triggered buffer mode. Unfortunately
+        * this does not seem to be possible, so stick with driver demux for
+        * now.
+        */
+       for (i = 0; i < count; i++) {
+               u16 sample[8];
+               int j, bit;
+
+               j = 0;
+               for_each_set_bit(bit, indio_dev->active_scan_mask,
+                                indio_dev->masklength)
+                       memcpy(&sample[j++], &buffer[i * 3 + bit], 2);
+
+               iio_push_to_buffers_with_timestamp(indio_dev, sample, tstamp);
+
+               tstamp += sample_period;
+       }
+
+       return count;
+}
+
+static int bmc150_accel_fifo_flush(struct iio_dev *indio_dev, unsigned samples)
+{
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       int ret;
+
+       mutex_lock(&data->mutex);
+       ret = __bmc150_accel_fifo_flush(indio_dev, samples, false);
+       mutex_unlock(&data->mutex);
+
+       return ret;
+}
+
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
                "15.620000 31.260000 62.50000 125 250 500 1000 2000");
 
@@ -978,6 +1187,20 @@ static const struct iio_info bmc150_accel_info = {
        .driver_module          = THIS_MODULE,
 };
 
+static const struct iio_info bmc150_accel_info_fifo = {
+       .attrs                  = &bmc150_accel_attrs_group,
+       .read_raw               = bmc150_accel_read_raw,
+       .write_raw              = bmc150_accel_write_raw,
+       .read_event_value       = bmc150_accel_read_event,
+       .write_event_value      = bmc150_accel_write_event,
+       .write_event_config     = bmc150_accel_write_event_config,
+       .read_event_config      = bmc150_accel_read_event_config,
+       .validate_trigger       = bmc150_accel_validate_trigger,
+       .hwfifo_set_watermark   = bmc150_accel_set_watermark,
+       .hwfifo_flush_to_buffer = bmc150_accel_fifo_flush,
+       .driver_module          = THIS_MODULE,
+};
+
 static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
 {
        struct iio_poll_func *pf = p;
@@ -1008,12 +1231,12 @@ err_read:
 
 static int bmc150_accel_trig_try_reen(struct iio_trigger *trig)
 {
-       struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
-       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig);
+       struct bmc150_accel_data *data = t->data;
        int ret;
 
        /* new data interrupts don't need ack */
-       if (data->dready_trigger_on)
+       if (t == &t->data->triggers[BMC150_ACCEL_TRIGGER_DATA_READY])
                return 0;
 
        mutex_lock(&data->mutex);
@@ -1032,43 +1255,35 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig)
        return 0;
 }
 
-static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
+static int bmc150_accel_trigger_set_state(struct iio_trigger *trig,
                                                   bool state)
 {
-       struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
-       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig);
+       struct bmc150_accel_data *data = t->data;
        int ret;
 
        mutex_lock(&data->mutex);
 
-       if (!state && data->ev_enable_state && data->motion_trigger_on) {
-               data->motion_trigger_on = false;
+       if (t->enabled == state) {
                mutex_unlock(&data->mutex);
                return 0;
        }
 
-       /*
-        * Refer to comment in bmc150_accel_write_event_config for
-        * enable/disable operation order
-        */
-       ret = bmc150_accel_set_power_state(data, state);
-       if (ret < 0) {
-               mutex_unlock(&data->mutex);
-               return ret;
+       if (t->setup) {
+               ret = t->setup(t, state);
+               if (ret < 0) {
+                       mutex_unlock(&data->mutex);
+                       return ret;
+               }
        }
-       if (data->motion_trig == trig)
-               ret =  bmc150_accel_setup_any_motion_interrupt(data, state);
-       else
-               ret = bmc150_accel_setup_new_data_interrupt(data, state);
+
+       ret = bmc150_accel_set_interrupt(data, t->intr, state);
        if (ret < 0) {
-               bmc150_accel_set_power_state(data, false);
                mutex_unlock(&data->mutex);
                return ret;
        }
-       if (data->motion_trig == trig)
-               data->motion_trigger_on = state;
-       else
-               data->dready_trigger_on = state;
+
+       t->enabled = state;
 
        mutex_unlock(&data->mutex);
 
@@ -1076,23 +1291,22 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
 }
 
 static const struct iio_trigger_ops bmc150_accel_trigger_ops = {
-       .set_trigger_state = bmc150_accel_data_rdy_trigger_set_state,
+       .set_trigger_state = bmc150_accel_trigger_set_state,
        .try_reenable = bmc150_accel_trig_try_reen,
        .owner = THIS_MODULE,
 };
 
-static irqreturn_t bmc150_accel_event_handler(int irq, void *private)
+static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev)
 {
-       struct iio_dev *indio_dev = private;
        struct bmc150_accel_data *data = iio_priv(indio_dev);
-       int ret;
        int dir;
+       int ret;
 
        ret = i2c_smbus_read_byte_data(data->client,
                                       BMC150_ACCEL_REG_INT_STATUS_2);
        if (ret < 0) {
                dev_err(&data->client->dev, "Error reading reg_int_status_2\n");
-               goto ack_intr_status;
+               return ret;
        }
 
        if (ret & BMC150_ACCEL_ANY_MOTION_BIT_SIGN)
@@ -1121,32 +1335,73 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)
                                                        IIO_EV_TYPE_ROC,
                                                        dir),
                                                        data->timestamp);
-ack_intr_status:
-       if (!data->dready_trigger_on)
+       return ret;
+}
+
+static irqreturn_t bmc150_accel_irq_thread_handler(int irq, void *private)
+{
+       struct iio_dev *indio_dev = private;
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       bool ack = false;
+       int ret;
+
+       mutex_lock(&data->mutex);
+
+       if (data->fifo_mode) {
+               ret = __bmc150_accel_fifo_flush(indio_dev,
+                                               BMC150_ACCEL_FIFO_LENGTH, true);
+               if (ret > 0)
+                       ack = true;
+       }
+
+       if (data->ev_enable_state) {
+               ret = bmc150_accel_handle_roc_event(indio_dev);
+               if (ret > 0)
+                       ack = true;
+       }
+
+       if (ack) {
                ret = i2c_smbus_write_byte_data(data->client,
                                        BMC150_ACCEL_REG_INT_RST_LATCH,
                                        BMC150_ACCEL_INT_MODE_LATCH_INT |
                                        BMC150_ACCEL_INT_MODE_LATCH_RESET);
+               if (ret)
+                       dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n");
+               ret = IRQ_HANDLED;
+       } else {
+               ret = IRQ_NONE;
+       }
 
-       return IRQ_HANDLED;
+       mutex_unlock(&data->mutex);
+
+       return ret;
 }
 
-static irqreturn_t bmc150_accel_data_rdy_trig_poll(int irq, void *private)
+static irqreturn_t bmc150_accel_irq_handler(int irq, void *private)
 {
        struct iio_dev *indio_dev = private;
        struct bmc150_accel_data *data = iio_priv(indio_dev);
+       bool ack = false;
+       int i;
 
+       data->old_timestamp = data->timestamp;
        data->timestamp = iio_get_time_ns();
 
-       if (data->dready_trigger_on)
-               iio_trigger_poll(data->dready_trig);
-       else if (data->motion_trigger_on)
-               iio_trigger_poll(data->motion_trig);
+       for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) {
+               if (data->triggers[i].enabled) {
+                       iio_trigger_poll(data->triggers[i].indio_trig);
+                       ack = true;
+                       break;
+               }
+       }
 
-       if (data->ev_enable_state)
+       if (data->ev_enable_state || data->fifo_mode)
                return IRQ_WAKE_THREAD;
-       else
+
+       if (ack)
                return IRQ_HANDLED;
+
+       return IRQ_NONE;
 }
 
 static const char *bmc150_accel_match_acpi_device(struct device *dev, int *data)
@@ -1176,23 +1431,171 @@ static int bmc150_accel_gpio_probe(struct i2c_client *client,
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, BMC150_ACCEL_GPIO_NAME, 0);
+       gpio = devm_gpiod_get_index(dev, BMC150_ACCEL_GPIO_NAME, 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "Failed: gpio get index\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
+       ret = gpiod_to_irq(gpio);
+
+       dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+
+       return ret;
+}
+
+static const struct {
+       int intr;
+       const char *name;
+       int (*setup)(struct bmc150_accel_trigger *t, bool state);
+} bmc150_accel_triggers[BMC150_ACCEL_TRIGGERS] = {
+       {
+               .intr = 0,
+               .name = "%s-dev%d",
+       },
+       {
+               .intr = 1,
+               .name = "%s-any-motion-dev%d",
+               .setup = bmc150_accel_any_motion_setup,
+       },
+};
+
+static void bmc150_accel_unregister_triggers(struct bmc150_accel_data *data,
+                                            int from)
+{
+       int i;
+
+       for (i = from; i >= 0; i++) {
+               if (data->triggers[i].indio_trig) {
+                       iio_trigger_unregister(data->triggers[i].indio_trig);
+                       data->triggers[i].indio_trig = NULL;
+               }
+       }
+}
+
+static int bmc150_accel_triggers_setup(struct iio_dev *indio_dev,
+                                      struct bmc150_accel_data *data)
+{
+       int i, ret;
+
+       for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) {
+               struct bmc150_accel_trigger *t = &data->triggers[i];
+
+               t->indio_trig = devm_iio_trigger_alloc(&data->client->dev,
+                                              bmc150_accel_triggers[i].name,
+                                                      indio_dev->name,
+                                                      indio_dev->id);
+               if (!t->indio_trig) {
+                       ret = -ENOMEM;
+                       break;
+               }
+
+               t->indio_trig->dev.parent = &data->client->dev;
+               t->indio_trig->ops = &bmc150_accel_trigger_ops;
+               t->intr = bmc150_accel_triggers[i].intr;
+               t->data = data;
+               t->setup = bmc150_accel_triggers[i].setup;
+               iio_trigger_set_drvdata(t->indio_trig, t);
+
+               ret = iio_trigger_register(t->indio_trig);
+               if (ret)
+                       break;
+       }
+
        if (ret)
+               bmc150_accel_unregister_triggers(data, i - 1);
+
+       return ret;
+}
+
+#define BMC150_ACCEL_FIFO_MODE_STREAM          0x80
+#define BMC150_ACCEL_FIFO_MODE_FIFO            0x40
+#define BMC150_ACCEL_FIFO_MODE_BYPASS          0x00
+
+static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data)
+{
+       u8 reg = BMC150_ACCEL_REG_FIFO_CONFIG1;
+       int ret;
+
+       ret = i2c_smbus_write_byte_data(data->client, reg, data->fifo_mode);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error writing reg_fifo_config1\n");
                return ret;
+       }
 
-       ret = gpiod_to_irq(gpio);
+       if (!data->fifo_mode)
+               return 0;
 
-       dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+       ret = i2c_smbus_write_byte_data(data->client,
+                                       BMC150_ACCEL_REG_FIFO_CONFIG0,
+                                       data->watermark);
+       if (ret < 0)
+               dev_err(&data->client->dev, "Error writing reg_fifo_config0\n");
 
        return ret;
 }
 
+static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev)
+{
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+       int ret = 0;
+
+       if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED)
+               return iio_triggered_buffer_postenable(indio_dev);
+
+       mutex_lock(&data->mutex);
+
+       if (!data->watermark)
+               goto out;
+
+       ret = bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK,
+                                        true);
+       if (ret)
+               goto out;
+
+       data->fifo_mode = BMC150_ACCEL_FIFO_MODE_FIFO;
+
+       ret = bmc150_accel_fifo_set_mode(data);
+       if (ret) {
+               data->fifo_mode = 0;
+               bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK,
+                                          false);
+       }
+
+out:
+       mutex_unlock(&data->mutex);
+
+       return ret;
+}
+
+static int bmc150_accel_buffer_predisable(struct iio_dev *indio_dev)
+{
+       struct bmc150_accel_data *data = iio_priv(indio_dev);
+
+       if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED)
+               return iio_triggered_buffer_predisable(indio_dev);
+
+       mutex_lock(&data->mutex);
+
+       if (!data->fifo_mode)
+               goto out;
+
+       bmc150_accel_set_interrupt(data, BMC150_ACCEL_INT_WATERMARK, false);
+       __bmc150_accel_fifo_flush(indio_dev, BMC150_ACCEL_FIFO_LENGTH, false);
+       data->fifo_mode = 0;
+       bmc150_accel_fifo_set_mode(data);
+
+out:
+       mutex_unlock(&data->mutex);
+
+       return 0;
+}
+
+static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = {
+       .postenable = bmc150_accel_buffer_postenable,
+       .predisable = bmc150_accel_buffer_predisable,
+};
+
 static int bmc150_accel_probe(struct i2c_client *client,
                              const struct i2c_device_id *id)
 {
@@ -1239,53 +1642,51 @@ static int bmc150_accel_probe(struct i2c_client *client,
        if (client->irq >= 0) {
                ret = devm_request_threaded_irq(
                                                &client->dev, client->irq,
-                                               bmc150_accel_data_rdy_trig_poll,
-                                               bmc150_accel_event_handler,
+                                               bmc150_accel_irq_handler,
+                                               bmc150_accel_irq_thread_handler,
                                                IRQF_TRIGGER_RISING,
                                                BMC150_ACCEL_IRQ_NAME,
                                                indio_dev);
                if (ret)
                        return ret;
 
-               data->dready_trig = devm_iio_trigger_alloc(&client->dev,
-                                                          "%s-dev%d",
-                                                          indio_dev->name,
-                                                          indio_dev->id);
-               if (!data->dready_trig)
-                       return -ENOMEM;
-
-               data->motion_trig = devm_iio_trigger_alloc(&client->dev,
-                                                         "%s-any-motion-dev%d",
-                                                         indio_dev->name,
-                                                         indio_dev->id);
-               if (!data->motion_trig)
-                       return -ENOMEM;
-
-               data->dready_trig->dev.parent = &client->dev;
-               data->dready_trig->ops = &bmc150_accel_trigger_ops;
-               iio_trigger_set_drvdata(data->dready_trig, indio_dev);
-               ret = iio_trigger_register(data->dready_trig);
-               if (ret)
+               /*
+                * Set latched mode interrupt. While certain interrupts are
+                * non-latched regardless of this settings (e.g. new data) we
+                * want to use latch mode when we can to prevent interrupt
+                * flooding.
+                */
+               ret = i2c_smbus_write_byte_data(data->client,
+                                               BMC150_ACCEL_REG_INT_RST_LATCH,
+                                            BMC150_ACCEL_INT_MODE_LATCH_RESET);
+               if (ret < 0) {
+                       dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n");
                        return ret;
-
-               data->motion_trig->dev.parent = &client->dev;
-               data->motion_trig->ops = &bmc150_accel_trigger_ops;
-               iio_trigger_set_drvdata(data->motion_trig, indio_dev);
-               ret = iio_trigger_register(data->motion_trig);
-               if (ret) {
-                       data->motion_trig = NULL;
-                       goto err_trigger_unregister;
                }
 
+               bmc150_accel_interrupts_setup(indio_dev, data);
+
+               ret = bmc150_accel_triggers_setup(indio_dev, data);
+               if (ret)
+                       return ret;
+
                ret = iio_triggered_buffer_setup(indio_dev,
                                                 &iio_pollfunc_store_time,
                                                 bmc150_accel_trigger_handler,
-                                                NULL);
+                                                &bmc150_accel_buffer_ops);
                if (ret < 0) {
                        dev_err(&client->dev,
                                "Failed: iio triggered buffer setup\n");
                        goto err_trigger_unregister;
                }
+
+               if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) ||
+                   i2c_check_functionality(client->adapter,
+                                           I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
+                       indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
+                       indio_dev->info = &bmc150_accel_info_fifo;
+                       indio_dev->buffer->attrs = bmc150_accel_fifo_attributes;
+               }
        }
 
        ret = iio_device_register(indio_dev);
@@ -1308,13 +1709,10 @@ static int bmc150_accel_probe(struct i2c_client *client,
 err_iio_unregister:
        iio_device_unregister(indio_dev);
 err_buffer_cleanup:
-       if (data->dready_trig)
+       if (indio_dev->pollfunc)
                iio_triggered_buffer_cleanup(indio_dev);
 err_trigger_unregister:
-       if (data->dready_trig)
-               iio_trigger_unregister(data->dready_trig);
-       if (data->motion_trig)
-               iio_trigger_unregister(data->motion_trig);
+       bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
 
        return ret;
 }
@@ -1330,11 +1728,7 @@ static int bmc150_accel_remove(struct i2c_client *client)
 
        iio_device_unregister(indio_dev);
 
-       if (data->dready_trig) {
-               iio_triggered_buffer_cleanup(indio_dev);
-               iio_trigger_unregister(data->dready_trig);
-               iio_trigger_unregister(data->motion_trig);
-       }
+       bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
 
        mutex_lock(&data->mutex);
        bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0);
@@ -1362,9 +1756,9 @@ static int bmc150_accel_resume(struct device *dev)
        struct bmc150_accel_data *data = iio_priv(indio_dev);
 
        mutex_lock(&data->mutex);
-       if (data->dready_trigger_on || data->motion_trigger_on ||
-                                                       data->ev_enable_state)
+       if (atomic_read(&data->active_intr))
                bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
+       bmc150_accel_fifo_set_mode(data);
        mutex_unlock(&data->mutex);
 
        return 0;
@@ -1396,6 +1790,9 @@ static int bmc150_accel_runtime_resume(struct device *dev)
        dev_dbg(&data->client->dev,  __func__);
 
        ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0);
+       if (ret < 0)
+               return ret;
+       ret = bmc150_accel_fifo_set_mode(data);
        if (ret < 0)
                return ret;
 
index 1a6379525fa47e73497b17866be4276fc88c8065..51da3692d561377f7818584156d1d2700c7ef674 100644 (file)
@@ -1169,16 +1169,12 @@ static int kxcjk1013_gpio_probe(struct i2c_client *client,
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, "kxcjk1013_int", 0);
+       gpio = devm_gpiod_get_index(dev, "kxcjk1013_int", 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "acpi gpio get index failed\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
-       if (ret)
-               return ret;
-
        ret = gpiod_to_irq(gpio);
 
        dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
index 46c38351c6a34644be08ae4ffb309a97259c05d8..7db7cc0bf362fceb3b97c770cc0ef0552dd4c4d3 100644 (file)
@@ -418,17 +418,18 @@ static int mma9551_gpio_probe(struct iio_dev *indio_dev)
        struct device *dev = &data->client->dev;
 
        for (i = 0; i < MMA9551_GPIO_COUNT; i++) {
-               gpio = devm_gpiod_get_index(dev, MMA9551_GPIO_NAME, i);
+               gpio = devm_gpiod_get_index(dev, MMA9551_GPIO_NAME, i,
+                                           GPIOD_IN);
                if (IS_ERR(gpio)) {
                        dev_err(dev, "acpi gpio get index failed\n");
                        return PTR_ERR(gpio);
                }
 
-               ret = gpiod_direction_input(gpio);
-               if (ret)
+               ret = gpiod_to_irq(gpio);
+               if (ret < 0)
                        return ret;
 
-               data->irqs[i] = gpiod_to_irq(gpio);
+               data->irqs[i] = ret;
                ret = devm_request_threaded_irq(dev, data->irqs[i],
                                NULL, mma9551_event_handler,
                                IRQF_TRIGGER_RISING | IRQF_ONESHOT,
index d23ebf192f632ec55f256e128cb1f3a990fc46ff..2df1af7d43fc6df34b87f80373e413152e33a739 100644 (file)
@@ -1109,16 +1109,12 @@ static int mma9553_gpio_probe(struct i2c_client *client)
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, MMA9553_GPIO_NAME, 0);
+       gpio = devm_gpiod_get_index(dev, MMA9553_GPIO_NAME, 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "acpi gpio get index failed\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
-       if (ret)
-               return ret;
-
        ret = gpiod_to_irq(gpio);
 
        dev_dbg(dev, "gpio resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
index fa964603430501b4cb1a4b73003a043fd16a7b34..7ee9724b1428f67ca5273ebd5235db3765d896ee 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+#define LIS3LV02DL_ACCEL_DEV_NAME      "lis3lv02dl_accel"
 #define LSM303DLHC_ACCEL_DEV_NAME      "lsm303dlhc_accel"
 #define LIS3DH_ACCEL_DEV_NAME          "lis3dh"
 #define LSM330D_ACCEL_DEV_NAME         "lsm330d_accel"
index 53f32629283a0d06d3e22d20a91c25b51bd877a2..58d1d13d552ae8cf336061f93603e4dd07b222ac 100644 (file)
 #define ST_ACCEL_3_IG1_EN_MASK                 0x08
 #define ST_ACCEL_3_MULTIREAD_BIT               false
 
+/* CUSTOM VALUES FOR SENSOR 4 */
+#define ST_ACCEL_4_WAI_EXP                     0x3a
+#define ST_ACCEL_4_ODR_ADDR                    0x20
+#define ST_ACCEL_4_ODR_MASK                    0x30 /* DF1 and DF0 */
+#define ST_ACCEL_4_ODR_AVL_40HZ_VAL            0x00
+#define ST_ACCEL_4_ODR_AVL_160HZ_VAL           0x01
+#define ST_ACCEL_4_ODR_AVL_640HZ_VAL           0x02
+#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL          0x03
+#define ST_ACCEL_4_PW_ADDR                     0x20
+#define ST_ACCEL_4_PW_MASK                     0xc0
+#define ST_ACCEL_4_FS_ADDR                     0x21
+#define ST_ACCEL_4_FS_MASK                     0x80
+#define ST_ACCEL_4_FS_AVL_2_VAL                        0X00
+#define ST_ACCEL_4_FS_AVL_6_VAL                        0X01
+#define ST_ACCEL_4_FS_AVL_2_GAIN               IIO_G_TO_M_S_2(1024)
+#define ST_ACCEL_4_FS_AVL_6_GAIN               IIO_G_TO_M_S_2(340)
+#define ST_ACCEL_4_BDU_ADDR                    0x21
+#define ST_ACCEL_4_BDU_MASK                    0x40
+#define ST_ACCEL_4_DRDY_IRQ_ADDR               0x21
+#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK          0x04
+#define ST_ACCEL_4_IG1_EN_ADDR                 0x21
+#define ST_ACCEL_4_IG1_EN_MASK                 0x08
+#define ST_ACCEL_4_MULTIREAD_BIT               true
+
 static const struct iio_chan_spec st_accel_12bit_channels[] = {
        ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
                        BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
                .multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
                .bootime = 2,
        },
+       {
+               .wai = ST_ACCEL_4_WAI_EXP,
+               .sensors_supported = {
+                       [0] = LIS3LV02DL_ACCEL_DEV_NAME,
+               },
+               .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
+               .odr = {
+                       .addr = ST_ACCEL_4_ODR_ADDR,
+                       .mask = ST_ACCEL_4_ODR_MASK,
+                       .odr_avl = {
+                               { 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
+                               { 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
+                               { 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
+                               { 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
+                       },
+               },
+               .pw = {
+                       .addr = ST_ACCEL_4_PW_ADDR,
+                       .mask = ST_ACCEL_4_PW_MASK,
+                       .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+                       .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+               },
+               .enable_axis = {
+                       .addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
+                       .mask = ST_SENSORS_DEFAULT_AXIS_MASK,
+               },
+               .fs = {
+                       .addr = ST_ACCEL_4_FS_ADDR,
+                       .mask = ST_ACCEL_4_FS_MASK,
+                       .fs_avl = {
+                               [0] = {
+                                       .num = ST_ACCEL_FS_AVL_2G,
+                                       .value = ST_ACCEL_4_FS_AVL_2_VAL,
+                                       .gain = ST_ACCEL_4_FS_AVL_2_GAIN,
+                               },
+                               [1] = {
+                                       .num = ST_ACCEL_FS_AVL_6G,
+                                       .value = ST_ACCEL_4_FS_AVL_6_VAL,
+                                       .gain = ST_ACCEL_4_FS_AVL_6_GAIN,
+                               },
+                       },
+               },
+               .bdu = {
+                       .addr = ST_ACCEL_4_BDU_ADDR,
+                       .mask = ST_ACCEL_4_BDU_MASK,
+               },
+               .drdy_irq = {
+                       .addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
+                       .mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
+                       .ig1 = {
+                               .en_addr = ST_ACCEL_4_IG1_EN_ADDR,
+                               .en_mask = ST_ACCEL_4_IG1_EN_MASK,
+                       },
+               },
+               .multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
+               .bootime = 2, /* guess */
+       },
 };
 
 static int st_accel_read_raw(struct iio_dev *indio_dev,
index c7246bdd30b9532b2d4a8eea6910f532666731b5..6b720c190b2d802293e8836af490ff465dae031e 100644 (file)
 
 #ifdef CONFIG_OF
 static const struct of_device_id st_accel_of_match[] = {
+       {
+               .compatible = "st,lis3lv02dl-accel",
+               .data = LIS3LV02DL_ACCEL_DEV_NAME,
+       },
        {
                .compatible = "st,lsm303dlh-accel",
                .data = LSM303DLH_ACCEL_DEV_NAME,
index d82af14986ba44c1fde7498bb378fa9f4fe9513f..e36a73e7c3a857775103bb1f9212d56ac2cba09c 100644 (file)
@@ -196,10 +196,11 @@ config MAX1363
          data via the iio dev interface.
 
 config MCP320X
-       tristate "Microchip Technology MCP3204/08"
+       tristate "Microchip Technology MCP3x01/02/04/08"
        depends on SPI
        help
-         Say yes here to build support for Microchip Technology's MCP3204 or
+         Say yes here to build support for Microchip Technology's
+         MCP3001, MCP3002, MCP3004, MCP3008, MCP3201, MCP3202, MCP3204 or
          MCP3208 analog to digital converter.
 
          This driver can also be built as a module. If so, the module will be
index 4dddeabdfbb02acdd847a79c6a567e8b0e5673b1..b84922a4b32e6bb508c8a5c812a281907102159f 100644 (file)
@@ -861,5 +861,5 @@ static struct spi_driver ad7793_driver = {
 module_spi_driver(ad7793_driver);
 
 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD7793 and simialr ADCs");
+MODULE_DESCRIPTION("Analog Devices AD7793 and similar ADCs");
 MODULE_LICENSE("GPL v2");
index e63b8e76d4c3d54edc25d23561f28a11afeb05e7..56292ae4538db6fb506966b2905064ea14ea4fc2 100644 (file)
@@ -275,7 +275,6 @@ static void vf610_adc_cfg_post_set(struct vf610_adc *info)
 static void vf610_adc_calibration(struct vf610_adc *info)
 {
        int adc_gc, hc_cfg;
-       int timeout;
 
        if (!info->adc_feature.calibration)
                return;
@@ -287,9 +286,7 @@ static void vf610_adc_calibration(struct vf610_adc *info)
        adc_gc = readl(info->regs + VF610_REG_ADC_GC);
        writel(adc_gc | VF610_ADC_CAL, info->regs + VF610_REG_ADC_GC);
 
-       timeout = wait_for_completion_timeout
-                       (&info->completion, VF610_ADC_TIMEOUT);
-       if (timeout == 0)
+       if (!wait_for_completion_timeout(&info->completion, VF610_ADC_TIMEOUT))
                dev_err(info->dev, "Timeout for adc calibration\n");
 
        adc_gc = readl(info->regs + VF610_REG_ADC_GS);
index 55a90082a29bd4846aaea896f8c7f847d96fcb45..9a40097e7cf81439933c892d7bfc205cc43d69d7 100644 (file)
@@ -437,7 +437,7 @@ int ssp_queue_ssp_refresh_task(struct ssp_data *data, unsigned int delay)
 }
 
 #ifdef CONFIG_OF
-static struct of_device_id ssp_of_match[] = {
+static const struct of_device_id ssp_of_match[] = {
        {
                .compatible     = "samsung,sensorhub-rinato",
                .data           = &ssp_rinato_info,
index 2236ea22f98a50532b333c9b126373071da45ccb..13471a76e5bf0b7c99d09572900e7fbc6626baca 100644 (file)
@@ -143,11 +143,16 @@ config AD7303
          ad7303.
 
 config MAX517
-       tristate "Maxim MAX517/518/519 DAC driver"
+       tristate "Maxim MAX517/518/519/520/521 DAC driver"
        depends on I2C
        help
-         If you say yes here you get support for the Maxim chips MAX517,
-         MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
+         If you say yes here you get support for the following Maxim chips
+         (I2C 8-Bit DACs with rail-to-rail outputs):
+         MAX517 - Single channel, single reference
+         MAX518 - Dual channel, ref=Vdd
+         MAX519 - Dual channel, dual reference
+         MAX520 - Quad channel, quad reference
+         MAX521 - Octal channel, independent ref for ch0-3, shared ref for ch4-7
 
          This driver can also be built as a module.  If so, the module
          will be called max517.
index 9a82a7255ebb8d4420e22444f02a4e82a28bd0bb..5507b3970b4bc6afb7b2c45286cf92c6885fa124 100644 (file)
@@ -39,11 +39,13 @@ enum max517_device_ids {
        ID_MAX517,
        ID_MAX518,
        ID_MAX519,
+       ID_MAX520,
+       ID_MAX521,
 };
 
 struct max517_data {
        struct i2c_client       *client;
-       unsigned short          vref_mv[2];
+       unsigned short          vref_mv[8];
 };
 
 /*
@@ -149,7 +151,13 @@ static const struct iio_info max517_info = {
 
 static const struct iio_chan_spec max517_channels[] = {
        MAX517_CHANNEL(0),
-       MAX517_CHANNEL(1)
+       MAX517_CHANNEL(1),
+       MAX517_CHANNEL(2),
+       MAX517_CHANNEL(3),
+       MAX517_CHANNEL(4),
+       MAX517_CHANNEL(5),
+       MAX517_CHANNEL(6),
+       MAX517_CHANNEL(7),
 };
 
 static int max517_probe(struct i2c_client *client,
@@ -158,6 +166,7 @@ static int max517_probe(struct i2c_client *client,
        struct max517_data *data;
        struct iio_dev *indio_dev;
        struct max517_platform_data *platform_data = client->dev.platform_data;
+       int chan;
 
        indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
        if (!indio_dev)
@@ -169,11 +178,21 @@ static int max517_probe(struct i2c_client *client,
        /* establish that the iio_dev is a child of the i2c device */
        indio_dev->dev.parent = &client->dev;
 
-       /* reduced channel set for MAX517 */
-       if (id->driver_data == ID_MAX517)
-               indio_dev->num_channels = 1;
-       else
+       switch (id->driver_data) {
+       case ID_MAX521:
+               indio_dev->num_channels = 8;
+               break;
+       case ID_MAX520:
+               indio_dev->num_channels = 4;
+               break;
+       case ID_MAX519:
+       case ID_MAX518:
                indio_dev->num_channels = 2;
+               break;
+       default:  /* single channel for MAX517 */
+               indio_dev->num_channels = 1;
+               break;
+       }
        indio_dev->channels = max517_channels;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &max517_info;
@@ -182,11 +201,11 @@ static int max517_probe(struct i2c_client *client,
         * Reference voltage on MAX518 and default is 5V, else take vref_mv
         * from platform_data
         */
-       if (id->driver_data == ID_MAX518 || !platform_data) {
-               data->vref_mv[0] = data->vref_mv[1] = 5000; /* mV */
-       } else {
-               data->vref_mv[0] = platform_data->vref_mv[0];
-               data->vref_mv[1] = platform_data->vref_mv[1];
+       for (chan = 0; chan < indio_dev->num_channels; chan++) {
+               if (id->driver_data == ID_MAX518 || !platform_data)
+                       data->vref_mv[chan] = 5000; /* mV */
+               else
+                       data->vref_mv[chan] = platform_data->vref_mv[chan];
        }
 
        return iio_device_register(indio_dev);
@@ -202,6 +221,8 @@ static const struct i2c_device_id max517_id[] = {
        { "max517", ID_MAX517 },
        { "max518", ID_MAX518 },
        { "max519", ID_MAX519 },
+       { "max520", ID_MAX520 },
+       { "max521", ID_MAX521 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, max517_id);
@@ -218,5 +239,5 @@ static struct i2c_driver max517_driver = {
 module_i2c_driver(max517_driver);
 
 MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
-MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
+MODULE_DESCRIPTION("MAX517/518/519/520/521 8-bit DAC");
 MODULE_LICENSE("GPL");
index ccf3ea7e1afa8ca1848937b9a8b92e1f2cefc8be..4415f55d26b6b06944b222c4666c82b759ba3cd7 100644 (file)
@@ -1001,16 +1001,12 @@ static int bmg160_gpio_probe(struct i2c_client *client,
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0);
+       gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "acpi gpio get index failed\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
-       if (ret)
-               return ret;
-
        ret = gpiod_to_irq(gpio);
 
        dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
index 6a8020d4814038b67cbad3b3c51d20d1987bbd77..f0fd94055d8858b722a5572b564edf0de125a90b 100644 (file)
@@ -223,6 +223,10 @@ static int itg3200_initial_setup(struct iio_dev *indio_dev)
        int ret;
        u8 val;
 
+       ret = itg3200_reset(indio_dev);
+       if (ret)
+               goto err_ret;
+
        ret = itg3200_read_reg_8(indio_dev, ITG3200_REG_ADDRESS, &val);
        if (ret)
                goto err_ret;
@@ -233,10 +237,6 @@ static int itg3200_initial_setup(struct iio_dev *indio_dev)
                goto err_ret;
        }
 
-       ret = itg3200_reset(indio_dev);
-       if (ret)
-               goto err_ret;
-
        ret = itg3200_enable_full_scale(indio_dev);
 err_ret:
        return ret;
@@ -351,6 +351,26 @@ static int itg3200_remove(struct i2c_client *client)
        return 0;
 }
 
+static int __maybe_unused itg3200_suspend(struct device *dev)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+       struct itg3200 *st = iio_priv(indio_dev);
+
+       dev_dbg(&st->i2c->dev, "suspend device");
+
+       return itg3200_write_reg_8(indio_dev, ITG3200_REG_POWER_MANAGEMENT,
+                                  ITG3200_SLEEP);
+}
+
+static int __maybe_unused itg3200_resume(struct device *dev)
+{
+       struct iio_dev *indio_dev = dev_get_drvdata(dev);
+
+       return itg3200_initial_setup(indio_dev);
+}
+
+static SIMPLE_DEV_PM_OPS(itg3200_pm_ops, itg3200_suspend, itg3200_resume);
+
 static const struct i2c_device_id itg3200_id[] = {
        { "itg3200", 0 },
        { }
@@ -361,6 +381,7 @@ static struct i2c_driver itg3200_driver = {
        .driver = {
                .owner  = THIS_MODULE,
                .name   = "itg3200",
+               .pm     = &itg3200_pm_ops,
        },
        .id_table       = itg3200_id,
        .probe          = itg3200_probe,
index f07a2336f7dc705d4c328ac5d5caefe310516229..21395f26d2276548567dfd118f37c22087a0d1ce 100644 (file)
 #define ST_GYRO_2_DRDY_IRQ_INT2_MASK           0x08
 #define ST_GYRO_2_MULTIREAD_BIT                        true
 
+/* CUSTOM VALUES FOR SENSOR 3 */
+#define ST_GYRO_3_WAI_EXP                      0xd7
+#define ST_GYRO_3_ODR_ADDR                     0x20
+#define ST_GYRO_3_ODR_MASK                     0xc0
+#define ST_GYRO_3_ODR_AVL_95HZ_VAL             0x00
+#define ST_GYRO_3_ODR_AVL_190HZ_VAL            0x01
+#define ST_GYRO_3_ODR_AVL_380HZ_VAL            0x02
+#define ST_GYRO_3_ODR_AVL_760HZ_VAL            0x03
+#define ST_GYRO_3_PW_ADDR                      0x20
+#define ST_GYRO_3_PW_MASK                      0x08
+#define ST_GYRO_3_FS_ADDR                      0x23
+#define ST_GYRO_3_FS_MASK                      0x30
+#define ST_GYRO_3_FS_AVL_250_VAL               0x00
+#define ST_GYRO_3_FS_AVL_500_VAL               0x01
+#define ST_GYRO_3_FS_AVL_2000_VAL              0x02
+#define ST_GYRO_3_FS_AVL_250_GAIN              IIO_DEGREE_TO_RAD(8750)
+#define ST_GYRO_3_FS_AVL_500_GAIN              IIO_DEGREE_TO_RAD(17500)
+#define ST_GYRO_3_FS_AVL_2000_GAIN             IIO_DEGREE_TO_RAD(70000)
+#define ST_GYRO_3_BDU_ADDR                     0x23
+#define ST_GYRO_3_BDU_MASK                     0x80
+#define ST_GYRO_3_DRDY_IRQ_ADDR                        0x22
+#define ST_GYRO_3_DRDY_IRQ_INT2_MASK           0x08
+#define ST_GYRO_3_MULTIREAD_BIT                        true
+
+
 static const struct iio_chan_spec st_gyro_16bit_channels[] = {
        ST_SENSORS_LSM_CHANNELS(IIO_ANGL_VEL,
                        BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -225,6 +250,64 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
                .multi_read_bit = ST_GYRO_2_MULTIREAD_BIT,
                .bootime = 2,
        },
+       {
+               .wai = ST_GYRO_3_WAI_EXP,
+               .sensors_supported = {
+                       [0] = L3GD20_GYRO_DEV_NAME,
+               },
+               .ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
+               .odr = {
+                       .addr = ST_GYRO_3_ODR_ADDR,
+                       .mask = ST_GYRO_3_ODR_MASK,
+                       .odr_avl = {
+                               { 95, ST_GYRO_3_ODR_AVL_95HZ_VAL, },
+                               { 190, ST_GYRO_3_ODR_AVL_190HZ_VAL, },
+                               { 380, ST_GYRO_3_ODR_AVL_380HZ_VAL, },
+                               { 760, ST_GYRO_3_ODR_AVL_760HZ_VAL, },
+                       },
+               },
+               .pw = {
+                       .addr = ST_GYRO_3_PW_ADDR,
+                       .mask = ST_GYRO_3_PW_MASK,
+                       .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+                       .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+               },
+               .enable_axis = {
+                       .addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
+                       .mask = ST_SENSORS_DEFAULT_AXIS_MASK,
+               },
+               .fs = {
+                       .addr = ST_GYRO_3_FS_ADDR,
+                       .mask = ST_GYRO_3_FS_MASK,
+                       .fs_avl = {
+                               [0] = {
+                                       .num = ST_GYRO_FS_AVL_250DPS,
+                                       .value = ST_GYRO_3_FS_AVL_250_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_250_GAIN,
+                               },
+                               [1] = {
+                                       .num = ST_GYRO_FS_AVL_500DPS,
+                                       .value = ST_GYRO_3_FS_AVL_500_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_500_GAIN,
+                               },
+                               [2] = {
+                                       .num = ST_GYRO_FS_AVL_2000DPS,
+                                       .value = ST_GYRO_3_FS_AVL_2000_VAL,
+                                       .gain = ST_GYRO_3_FS_AVL_2000_GAIN,
+                               },
+                       },
+               },
+               .bdu = {
+                       .addr = ST_GYRO_3_BDU_ADDR,
+                       .mask = ST_GYRO_3_BDU_MASK,
+               },
+               .drdy_irq = {
+                       .addr = ST_GYRO_3_DRDY_IRQ_ADDR,
+                       .mask_int2 = ST_GYRO_3_DRDY_IRQ_INT2_MASK,
+               },
+               .multi_read_bit = ST_GYRO_3_MULTIREAD_BIT,
+               .bootime = 2,
+       },
 };
 
 static int st_gyro_read_raw(struct iio_dev *indio_dev,
index 3a677c778afbaf11088a7cbafff7097b456e8a10..f566f6a7b3a9e91ef714e8db47e38366df9714bc 100644 (file)
@@ -3,4 +3,4 @@
 #
 
 obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o
-inv-mpu6050-objs := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o
+inv-mpu6050-objs := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o inv_mpu_acpi.o
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
new file mode 100644 (file)
index 0000000..1c982a5
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * inv_mpu_acpi: ACPI processing for creating client devices
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifdef CONFIG_ACPI
+
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+#include <linux/dmi.h>
+#include <linux/acpi.h>
+#include "inv_mpu_iio.h"
+
+enum inv_mpu_product_name {
+       INV_MPU_NOT_MATCHED,
+       INV_MPU_ASUS_T100TA,
+};
+
+static enum inv_mpu_product_name matched_product_name;
+
+static int __init asus_t100_matched(const struct dmi_system_id *d)
+{
+       matched_product_name = INV_MPU_ASUS_T100TA;
+
+       return 0;
+}
+
+static const struct dmi_system_id inv_mpu_dev_list[] = {
+       {
+       .callback = asus_t100_matched,
+       .ident = "Asus Transformer Book T100",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "T100TA"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"),
+               },
+       },
+       /* Add more matching tables here..*/
+       {}
+};
+
+static int asus_acpi_get_sensor_info(struct acpi_device *adev,
+                                    struct i2c_client *client,
+                                    struct i2c_board_info *info)
+{
+       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+       int i;
+       acpi_status status;
+       union acpi_object *cpm;
+
+       status = acpi_evaluate_object(adev->handle, "CNF0", NULL, &buffer);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+
+       cpm = buffer.pointer;
+       for (i = 0; i < cpm->package.count; ++i) {
+               union acpi_object *elem;
+               int j;
+
+               elem = &(cpm->package.elements[i]);
+               for (j = 0; j < elem->package.count; ++j) {
+                       union acpi_object *sub_elem;
+
+                       sub_elem = &(elem->package.elements[j]);
+                       if (sub_elem->type == ACPI_TYPE_STRING)
+                               strlcpy(info->type, sub_elem->string.pointer,
+                                       sizeof(info->type));
+                       else if (sub_elem->type == ACPI_TYPE_INTEGER) {
+                               if (sub_elem->integer.value != client->addr) {
+                                       info->addr = sub_elem->integer.value;
+                                       break; /* Not a MPU6500 primary */
+                               }
+                       }
+               }
+       }
+
+       kfree(buffer.pointer);
+
+       return cpm->package.count;
+}
+
+static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
+{
+       u32 *addr = data;
+
+       if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
+               struct acpi_resource_i2c_serialbus *sb;
+
+               sb = &ares->data.i2c_serial_bus;
+               if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+                       if (*addr)
+                               *addr |= (sb->slave_address << 16);
+                       else
+                               *addr = sb->slave_address;
+               }
+       }
+
+       /* Tell the ACPI core that we already copied this address */
+       return 1;
+}
+
+static int inv_mpu_process_acpi_config(struct i2c_client *client,
+                                      unsigned short *primary_addr,
+                                      unsigned short *secondary_addr)
+{
+       const struct acpi_device_id *id;
+       struct acpi_device *adev;
+       u32 i2c_addr = 0;
+       LIST_HEAD(resources);
+       int ret;
+
+       id = acpi_match_device(client->dev.driver->acpi_match_table,
+                              &client->dev);
+       if (!id)
+               return -ENODEV;
+
+       adev = ACPI_COMPANION(&client->dev);
+       if (!adev)
+               return -ENODEV;
+
+       ret = acpi_dev_get_resources(adev, &resources,
+                                    acpi_i2c_check_resource, &i2c_addr);
+       if (ret < 0)
+               return ret;
+
+       acpi_dev_free_resource_list(&resources);
+       *primary_addr = i2c_addr & 0x0000ffff;
+       *secondary_addr = (i2c_addr & 0xffff0000) >> 16;
+
+       return 0;
+}
+
+int inv_mpu_acpi_create_mux_client(struct inv_mpu6050_state *st)
+{
+
+       st->mux_client = NULL;
+       if (ACPI_HANDLE(&st->client->dev)) {
+               struct i2c_board_info info;
+               struct acpi_device *adev;
+               int ret = -1;
+
+               adev = ACPI_COMPANION(&st->client->dev);
+               memset(&info, 0, sizeof(info));
+
+               dmi_check_system(inv_mpu_dev_list);
+               switch (matched_product_name) {
+               case INV_MPU_ASUS_T100TA:
+                       ret = asus_acpi_get_sensor_info(adev, st->client,
+                                                       &info);
+                       break;
+               /* Add more matched product processing here */
+               default:
+                       break;
+               }
+
+               if (ret < 0) {
+                       /* No matching DMI, so create device on INV6XX type */
+                       unsigned short primary, secondary;
+
+                       ret = inv_mpu_process_acpi_config(st->client, &primary,
+                                                         &secondary);
+                       if (!ret && secondary) {
+                               char *name;
+
+                               info.addr = secondary;
+                               strlcpy(info.type, dev_name(&adev->dev),
+                                       sizeof(info.type));
+                               name = strchr(info.type, ':');
+                               if (name)
+                                       *name = '\0';
+                               strlcat(info.type, "-client",
+                                       sizeof(info.type));
+                       } else
+                               return 0; /* no secondary addr, which is OK */
+               }
+               st->mux_client = i2c_new_device(st->mux_adapter, &info);
+               if (!st->mux_client)
+                       return -ENODEV;
+
+       }
+
+       return 0;
+}
+
+void inv_mpu_acpi_delete_mux_client(struct inv_mpu6050_state *st)
+{
+       if (st->mux_client)
+               i2c_unregister_device(st->mux_client);
+}
+#else
+
+#include "inv_mpu_iio.h"
+
+int inv_mpu_acpi_create_mux_client(struct inv_mpu6050_state *st)
+{
+       return 0;
+}
+
+void inv_mpu_acpi_delete_mux_client(struct inv_mpu6050_state *st)
+{
+}
+#endif
index ef76afe2643cb0bebe512124ca8c9326e09229c2..17d4bb15be4d2998681f203b5944c5c82ce606ea 100644 (file)
@@ -829,8 +829,14 @@ static int inv_mpu_probe(struct i2c_client *client,
                goto out_unreg_device;
        }
 
+       result = inv_mpu_acpi_create_mux_client(st);
+       if (result)
+               goto out_del_mux;
+
        return 0;
 
+out_del_mux:
+       i2c_del_mux_adapter(st->mux_adapter);
 out_unreg_device:
        iio_device_unregister(indio_dev);
 out_remove_trigger:
@@ -845,6 +851,7 @@ static int inv_mpu_remove(struct i2c_client *client)
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
        struct inv_mpu6050_state *st = iio_priv(indio_dev);
 
+       inv_mpu_acpi_delete_mux_client(st);
        i2c_del_mux_adapter(st->mux_adapter);
        iio_device_unregister(indio_dev);
        inv_mpu6050_remove_trigger(st);
index aa837de57079ed1a5fa09f13b715995597fa53de..db0a4a2758ab1b5d4bf219aa86e8d4a934b0b0d2 100644 (file)
@@ -121,6 +121,7 @@ struct inv_mpu6050_state {
        spinlock_t time_stamp_lock;
        struct i2c_client *client;
        struct i2c_adapter *mux_adapter;
+       struct i2c_client *mux_client;
        unsigned int powerup_count;
        struct inv_mpu6050_platform_data plat_data;
        DECLARE_KFIFO(timestamps, long long, TIMESTAMP_FIFO_SIZE);
@@ -251,3 +252,5 @@ int inv_reset_fifo(struct iio_dev *indio_dev);
 int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask);
 int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 val);
 int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
+int inv_mpu_acpi_create_mux_client(struct inv_mpu6050_state *st);
+void inv_mpu_acpi_delete_mux_client(struct inv_mpu6050_state *st);
index b3a36376c719317006cf8b9d30e1369f8b6af8fb..462a010628cd52421458ab113f19b45ec58bf4d2 100644 (file)
@@ -169,19 +169,18 @@ static const u16 kmx61_uscale_table[] = {9582, 19163, 38326};
 static const struct {
        int val;
        int val2;
-       u8 odr_bits;
-} kmx61_samp_freq_table[] = { {12, 500000, 0x00},
-                       {25, 0, 0x01},
-                       {50, 0, 0x02},
-                       {100, 0, 0x03},
-                       {200, 0, 0x04},
-                       {400, 0, 0x05},
-                       {800, 0, 0x06},
-                       {1600, 0, 0x07},
-                       {0, 781000, 0x08},
-                       {1, 563000, 0x09},
-                       {3, 125000, 0x0A},
-                       {6, 250000, 0x0B} };
+} kmx61_samp_freq_table[] = { {12, 500000},
+                       {25, 0},
+                       {50, 0},
+                       {100, 0},
+                       {200, 0},
+                       {400, 0},
+                       {800, 0},
+                       {1600, 0},
+                       {0, 781000},
+                       {1, 563000},
+                       {3, 125000},
+                       {6, 250000} };
 
 static const struct {
        int val;
@@ -302,24 +301,10 @@ static int kmx61_convert_freq_to_bit(int val, int val2)
        for (i = 0; i < ARRAY_SIZE(kmx61_samp_freq_table); i++)
                if (val == kmx61_samp_freq_table[i].val &&
                    val2 == kmx61_samp_freq_table[i].val2)
-                       return kmx61_samp_freq_table[i].odr_bits;
+                       return i;
        return -EINVAL;
 }
 
-static int kmx61_convert_bit_to_freq(u8 odr_bits, int *val, int *val2)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(kmx61_samp_freq_table); i++)
-               if (odr_bits == kmx61_samp_freq_table[i].odr_bits) {
-                       *val = kmx61_samp_freq_table[i].val;
-                       *val2 = kmx61_samp_freq_table[i].val2;
-                       return 0;
-               }
-       return -EINVAL;
-}
-
-
 static int kmx61_convert_wake_up_odr_to_bit(int val, int val2)
 {
        int i;
@@ -478,7 +463,7 @@ static int kmx61_set_odr(struct kmx61_data *data, int val, int val2, u8 device)
 
 static int kmx61_get_odr(struct kmx61_data *data, int *val, int *val2,
                         u8 device)
-{      int i;
+{
        u8 lodr_bits;
 
        if (device & KMX61_ACC)
@@ -490,13 +475,13 @@ static int kmx61_get_odr(struct kmx61_data *data, int *val, int *val2,
        else
                return -EINVAL;
 
-       for (i = 0; i < ARRAY_SIZE(kmx61_samp_freq_table); i++)
-               if (lodr_bits == kmx61_samp_freq_table[i].odr_bits) {
-                       *val = kmx61_samp_freq_table[i].val;
-                       *val2 = kmx61_samp_freq_table[i].val2;
-                       return 0;
-               }
-       return -EINVAL;
+       if (lodr_bits >= ARRAY_SIZE(kmx61_samp_freq_table))
+               return -EINVAL;
+
+       *val = kmx61_samp_freq_table[lodr_bits].val;
+       *val2 = kmx61_samp_freq_table[lodr_bits].val2;
+
+       return 0;
 }
 
 static int kmx61_set_range(struct kmx61_data *data, u8 range)
@@ -580,8 +565,11 @@ static int kmx61_chip_init(struct kmx61_data *data)
        }
        data->odr_bits = ret;
 
-       /* set output data rate for wake up (motion detection) function */
-       ret = kmx61_convert_bit_to_freq(data->odr_bits, &val, &val2);
+       /*
+        * set output data rate for wake up (motion detection) function
+        * to match data rate for accelerometer sampling
+        */
+       ret = kmx61_get_odr(data, &val, &val2, KMX61_ACC);
        if (ret < 0)
                return ret;
 
@@ -1267,16 +1255,12 @@ static int kmx61_gpio_probe(struct i2c_client *client, struct kmx61_data *data)
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, KMX61_GPIO_NAME, 0);
+       gpio = devm_gpiod_get_index(dev, KMX61_GPIO_NAME, 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "acpi gpio get index failed\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
-       if (ret)
-               return ret;
-
        ret = gpiod_to_irq(gpio);
 
        dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
index 71333140d42c4815a5b8e336fb54a107c55c92a9..df919f44d513f466a0caa4f870d956273007531f 100644 (file)
@@ -37,11 +37,57 @@ static bool iio_buffer_is_active(struct iio_buffer *buf)
        return !list_empty(&buf->buffer_list);
 }
 
-static bool iio_buffer_data_available(struct iio_buffer *buf)
+static size_t iio_buffer_data_available(struct iio_buffer *buf)
 {
        return buf->access->data_available(buf);
 }
 
+static int iio_buffer_flush_hwfifo(struct iio_dev *indio_dev,
+                                  struct iio_buffer *buf, size_t required)
+{
+       if (!indio_dev->info->hwfifo_flush_to_buffer)
+               return -ENODEV;
+
+       return indio_dev->info->hwfifo_flush_to_buffer(indio_dev, required);
+}
+
+static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf,
+                            size_t to_wait, int to_flush)
+{
+       size_t avail;
+       int flushed = 0;
+
+       /* wakeup if the device was unregistered */
+       if (!indio_dev->info)
+               return true;
+
+       /* drain the buffer if it was disabled */
+       if (!iio_buffer_is_active(buf)) {
+               to_wait = min_t(size_t, to_wait, 1);
+               to_flush = 0;
+       }
+
+       avail = iio_buffer_data_available(buf);
+
+       if (avail >= to_wait) {
+               /* force a flush for non-blocking reads */
+               if (!to_wait && !avail && to_flush)
+                       iio_buffer_flush_hwfifo(indio_dev, buf, to_flush);
+               return true;
+       }
+
+       if (to_flush)
+               flushed = iio_buffer_flush_hwfifo(indio_dev, buf,
+                                                 to_wait - avail);
+       if (flushed <= 0)
+               return false;
+
+       if (avail + flushed >= to_wait)
+               return true;
+
+       return false;
+}
+
 /**
  * iio_buffer_read_first_n_outer() - chrdev read for buffer access
  *
@@ -53,6 +99,9 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
 {
        struct iio_dev *indio_dev = filp->private_data;
        struct iio_buffer *rb = indio_dev->buffer;
+       size_t datum_size;
+       size_t to_wait = 0;
+       size_t to_read;
        int ret;
 
        if (!indio_dev->info)
@@ -61,19 +110,28 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
        if (!rb || !rb->access->read_first_n)
                return -EINVAL;
 
+       datum_size = rb->bytes_per_datum;
+
+       /*
+        * If datum_size is 0 there will never be anything to read from the
+        * buffer, so signal end of file now.
+        */
+       if (!datum_size)
+               return 0;
+
+       to_read = min_t(size_t, n / datum_size, rb->watermark);
+
+       if (!(filp->f_flags & O_NONBLOCK))
+               to_wait = to_read;
+
        do {
-               if (!iio_buffer_data_available(rb)) {
-                       if (filp->f_flags & O_NONBLOCK)
-                               return -EAGAIN;
+               ret = wait_event_interruptible(rb->pollq,
+                       iio_buffer_ready(indio_dev, rb, to_wait, to_read));
+               if (ret)
+                       return ret;
 
-                       ret = wait_event_interruptible(rb->pollq,
-                                       iio_buffer_data_available(rb) ||
-                                       indio_dev->info == NULL);
-                       if (ret)
-                               return ret;
-                       if (indio_dev->info == NULL)
-                               return -ENODEV;
-               }
+               if (!indio_dev->info)
+                       return -ENODEV;
 
                ret = rb->access->read_first_n(rb, n, buf);
                if (ret == 0 && (filp->f_flags & O_NONBLOCK))
@@ -96,9 +154,8 @@ unsigned int iio_buffer_poll(struct file *filp,
                return -ENODEV;
 
        poll_wait(filp, &rb->pollq, wait);
-       if (iio_buffer_data_available(rb))
+       if (iio_buffer_ready(indio_dev, rb, rb->watermark, 0))
                return POLLIN | POLLRDNORM;
-       /* need a way of knowing if there may be enough data... */
        return 0;
 }
 
@@ -123,6 +180,7 @@ void iio_buffer_init(struct iio_buffer *buffer)
        INIT_LIST_HEAD(&buffer->buffer_list);
        init_waitqueue_head(&buffer->pollq);
        kref_init(&buffer->ref);
+       buffer->watermark = 1;
 }
 EXPORT_SYMBOL(iio_buffer_init);
 
@@ -416,6 +474,11 @@ static ssize_t iio_buffer_write_length(struct device *dev,
                buffer->access->set_length(buffer, val);
                ret = 0;
        }
+       if (ret)
+               goto out;
+       if (buffer->length && buffer->length < buffer->watermark)
+               buffer->watermark = buffer->length;
+out:
        mutex_unlock(&indio_dev->mlock);
 
        return ret ? ret : len;
@@ -472,6 +535,7 @@ static void iio_buffer_activate(struct iio_dev *indio_dev,
 static void iio_buffer_deactivate(struct iio_buffer *buffer)
 {
        list_del_init(&buffer->buffer_list);
+       wake_up_interruptible(&buffer->pollq);
        iio_buffer_put(buffer);
 }
 
@@ -629,19 +693,16 @@ static int __iio_update_buffers(struct iio_dev *indio_dev,
                }
        }
        /* Definitely possible for devices to support both of these. */
-       if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) {
-               if (!indio_dev->trig) {
-                       printk(KERN_INFO "Buffer not started: no trigger\n");
-                       ret = -EINVAL;
-                       /* Can only occur on first buffer */
-                       goto error_run_postdisable;
-               }
+       if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
                indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
        } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) {
                indio_dev->currentmode = INDIO_BUFFER_HARDWARE;
        } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) {
                indio_dev->currentmode = INDIO_BUFFER_SOFTWARE;
        } else { /* Should never be reached */
+               /* Can only occur on first buffer */
+               if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
+                       pr_info("Buffer not started: no trigger\n");
                ret = -EINVAL;
                goto error_run_postdisable;
        }
@@ -754,12 +815,68 @@ done:
 
 static const char * const iio_scan_elements_group_name = "scan_elements";
 
+static ssize_t iio_buffer_show_watermark(struct device *dev,
+                                        struct device_attribute *attr,
+                                        char *buf)
+{
+       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+       struct iio_buffer *buffer = indio_dev->buffer;
+
+       return sprintf(buf, "%u\n", buffer->watermark);
+}
+
+static ssize_t iio_buffer_store_watermark(struct device *dev,
+                                         struct device_attribute *attr,
+                                         const char *buf,
+                                         size_t len)
+{
+       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+       struct iio_buffer *buffer = indio_dev->buffer;
+       unsigned int val;
+       int ret;
+
+       ret = kstrtouint(buf, 10, &val);
+       if (ret)
+               return ret;
+       if (!val)
+               return -EINVAL;
+
+       mutex_lock(&indio_dev->mlock);
+
+       if (val > buffer->length) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       if (iio_buffer_is_active(indio_dev->buffer)) {
+               ret = -EBUSY;
+               goto out;
+       }
+
+       buffer->watermark = val;
+
+       if (indio_dev->info->hwfifo_set_watermark)
+               indio_dev->info->hwfifo_set_watermark(indio_dev, val);
+out:
+       mutex_unlock(&indio_dev->mlock);
+
+       return ret ? ret : len;
+}
+
 static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
                   iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
        S_IRUGO, iio_buffer_read_length, NULL);
 static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
                   iio_buffer_show_enable, iio_buffer_store_enable);
+static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+                  iio_buffer_show_watermark, iio_buffer_store_watermark);
+
+static struct attribute *iio_buffer_attrs[] = {
+       &dev_attr_length.attr,
+       &dev_attr_enable.attr,
+       &dev_attr_watermark.attr,
+};
 
 int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
 {
@@ -778,21 +895,23 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
                        attrcount++;
        }
 
-       buffer->buffer_group.name = "buffer";
-       buffer->buffer_group.attrs = kcalloc(attrcount + 3,
-                       sizeof(*buffer->buffer_group.attrs), GFP_KERNEL);
-       if (!buffer->buffer_group.attrs)
+       attr = kcalloc(attrcount + ARRAY_SIZE(iio_buffer_attrs) + 1,
+                      sizeof(struct attribute *), GFP_KERNEL);
+       if (!attr)
                return -ENOMEM;
 
-       if (buffer->access->set_length)
-               buffer->buffer_group.attrs[0] = &dev_attr_length.attr;
-       else
-               buffer->buffer_group.attrs[0] = &dev_attr_length_ro.attr;
-       buffer->buffer_group.attrs[1] = &dev_attr_enable.attr;
+       memcpy(attr, iio_buffer_attrs, sizeof(iio_buffer_attrs));
+       if (!buffer->access->set_length)
+               attr[0] = &dev_attr_length_ro.attr;
+
        if (buffer->attrs)
-               memcpy(&buffer->buffer_group.attrs[2], buffer->attrs,
-                       sizeof(*&buffer->buffer_group.attrs) * attrcount);
-       buffer->buffer_group.attrs[attrcount+2] = NULL;
+               memcpy(&attr[ARRAY_SIZE(iio_buffer_attrs)], buffer->attrs,
+                      sizeof(struct attribute *) * attrcount);
+
+       attr[attrcount + ARRAY_SIZE(iio_buffer_attrs)] = NULL;
+
+       buffer->buffer_group.name = "buffer";
+       buffer->buffer_group.attrs = attr;
 
        indio_dev->groups[indio_dev->groupcounter++] = &buffer->buffer_group;
 
@@ -937,8 +1056,18 @@ static const void *iio_demux(struct iio_buffer *buffer,
 static int iio_push_to_buffer(struct iio_buffer *buffer, const void *data)
 {
        const void *dataout = iio_demux(buffer, data);
+       int ret;
 
-       return buffer->access->store_to(buffer, dataout);
+       ret = buffer->access->store_to(buffer, dataout);
+       if (ret)
+               return ret;
+
+       /*
+        * We can't just test for watermark to decide if we wake the poll queue
+        * because read may request less samples than the watermark.
+        */
+       wake_up_interruptible_poll(&buffer->pollq, POLLIN | POLLRDNORM);
+       return 0;
 }
 
 static void iio_buffer_demux_free(struct iio_buffer *buffer)
index b2beea01c49b3c891683204b5f30d52c87012285..847ca561afe014e83707d04eaef02054f9b2bbfa 100644 (file)
@@ -83,9 +83,6 @@ static int iio_store_to_kfifo(struct iio_buffer *r,
        ret = kfifo_in(&kf->kf, data, 1);
        if (ret != 1)
                return -EBUSY;
-
-       wake_up_interruptible_poll(&r->pollq, POLLIN | POLLRDNORM);
-
        return 0;
 }
 
@@ -109,16 +106,16 @@ static int iio_read_first_n_kfifo(struct iio_buffer *r,
        return copied;
 }
 
-static bool iio_kfifo_buf_data_available(struct iio_buffer *r)
+static size_t iio_kfifo_buf_data_available(struct iio_buffer *r)
 {
        struct iio_kfifo *kf = iio_to_kfifo(r);
-       bool empty;
+       size_t samples;
 
        mutex_lock(&kf->user_lock);
-       empty = kfifo_is_empty(&kf->kf);
+       samples = kfifo_len(&kf->kf);
        mutex_unlock(&kf->user_lock);
 
-       return !empty;
+       return samples;
 }
 
 static void iio_kfifo_buffer_release(struct iio_buffer *buffer)
index a224afd6380c84eff7c76996c7c38eb621493140..01a1a16ab7be8fcc4ae7df6a2782caa377b271a7 100644 (file)
@@ -59,6 +59,16 @@ config CM3232
         To compile this driver as a module, choose M here:
         the module will be called cm3232.
 
+config CM3323
+       depends on I2C
+       tristate "Capella CM3323 color light sensor"
+       help
+        Say Y here if you want to build a driver for Capela CM3323
+        color sensor.
+
+        To compile this driver as a module, choose M here: the module will
+        be called cm3323.
+
 config CM36651
        depends on I2C
        tristate "CM36651 driver"
index b12a5160d9e05de741c6245dc989433217cad554..ad7c30fe443b26f6760bfe607a1a035b760752d3 100644 (file)
@@ -8,6 +8,7 @@ obj-$(CONFIG_AL3320A)           += al3320a.o
 obj-$(CONFIG_APDS9300)         += apds9300.o
 obj-$(CONFIG_CM32181)          += cm32181.o
 obj-$(CONFIG_CM3232)           += cm3232.o
+obj-$(CONFIG_CM3323)           += cm3323.o
 obj-$(CONFIG_CM36651)          += cm36651.o
 obj-$(CONFIG_GP2AP020A00F)     += gp2ap020a00f.o
 obj-$(CONFIG_HID_SENSOR_ALS)   += hid-sensor-als.o
index 90e3519a91de89310175b9073156f19acccd7907..39c8d99cc48ee988a59f17f605372d07258d0e05 100644 (file)
@@ -378,6 +378,39 @@ static const struct i2c_device_id cm3232_id[] = {
        {}
 };
 
+#ifdef CONFIG_PM_SLEEP
+static int cm3232_suspend(struct device *dev)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+       struct cm3232_chip *chip = iio_priv(indio_dev);
+       struct i2c_client *client = chip->client;
+       int ret;
+
+       chip->regs_cmd |= CM3232_CMD_ALS_DISABLE;
+       ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
+                                       chip->regs_cmd);
+
+       return ret;
+}
+
+static int cm3232_resume(struct device *dev)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+       struct cm3232_chip *chip = iio_priv(indio_dev);
+       struct i2c_client *client = chip->client;
+       int ret;
+
+       chip->regs_cmd &= ~CM3232_CMD_ALS_DISABLE;
+       ret = i2c_smbus_write_byte_data(client, CM3232_REG_ADDR_CMD,
+                                       chip->regs_cmd | CM3232_CMD_ALS_RESET);
+
+       return ret;
+}
+
+static const struct dev_pm_ops cm3232_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(cm3232_suspend, cm3232_resume)};
+#endif
+
 MODULE_DEVICE_TABLE(i2c, cm3232_id);
 
 static const struct of_device_id cm3232_of_match[] = {
@@ -390,6 +423,9 @@ static struct i2c_driver cm3232_driver = {
                .name   = "cm3232",
                .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(cm3232_of_match),
+#ifdef CONFIG_PM_SLEEP
+               .pm     = &cm3232_pm_ops,
+#endif
        },
        .id_table       = cm3232_id,
        .probe          = cm3232_probe,
diff --git a/drivers/iio/light/cm3323.c b/drivers/iio/light/cm3323.c
new file mode 100644 (file)
index 0000000..869033e
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * CM3323 - Capella Color Light Sensor
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License.  See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * IIO driver for CM3323 (7-bit I2C slave address 0x10)
+ *
+ * TODO: calibscale to correct the lens factor
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/mutex.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define CM3323_DRV_NAME "cm3323"
+
+#define CM3323_CMD_CONF                0x00
+#define CM3323_CMD_RED_DATA    0x08
+#define CM3323_CMD_GREEN_DATA  0x09
+#define CM3323_CMD_BLUE_DATA   0x0A
+#define CM3323_CMD_CLEAR_DATA  0x0B
+
+#define CM3323_CONF_SD_BIT     BIT(0) /* sensor disable */
+#define CM3323_CONF_AF_BIT     BIT(1) /* auto/manual force mode */
+#define CM3323_CONF_IT_MASK    (BIT(4) | BIT(5) | BIT(6))
+#define CM3323_CONF_IT_SHIFT   4
+
+#define CM3323_INT_TIME_AVAILABLE "0.04 0.08 0.16 0.32 0.64 1.28"
+
+static const struct {
+       int val;
+       int val2;
+} cm3323_int_time[] = {
+       {0, 40000},  /* 40 ms */
+       {0, 80000},  /* 80 ms */
+       {0, 160000}, /* 160 ms */
+       {0, 320000}, /* 320 ms */
+       {0, 640000}, /* 640 ms */
+       {1, 280000}, /* 1280 ms */
+};
+
+struct cm3323_data {
+       struct i2c_client *client;
+       u16 reg_conf;
+       struct mutex mutex;
+};
+
+#define CM3323_COLOR_CHANNEL(_color, _addr) { \
+       .type = IIO_INTENSITY, \
+       .modified = 1, \
+       .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+       .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \
+       .channel2 = IIO_MOD_LIGHT_##_color, \
+       .address = _addr, \
+}
+
+static const struct iio_chan_spec cm3323_channels[] = {
+       CM3323_COLOR_CHANNEL(RED, CM3323_CMD_RED_DATA),
+       CM3323_COLOR_CHANNEL(GREEN, CM3323_CMD_GREEN_DATA),
+       CM3323_COLOR_CHANNEL(BLUE, CM3323_CMD_BLUE_DATA),
+       CM3323_COLOR_CHANNEL(CLEAR, CM3323_CMD_CLEAR_DATA),
+};
+
+static IIO_CONST_ATTR_INT_TIME_AVAIL(CM3323_INT_TIME_AVAILABLE);
+
+static struct attribute *cm3323_attributes[] = {
+       &iio_const_attr_integration_time_available.dev_attr.attr,
+       NULL
+};
+
+static const struct attribute_group cm3323_attribute_group = {
+       .attrs = cm3323_attributes,
+};
+
+static int cm3323_init(struct iio_dev *indio_dev)
+{
+       int ret;
+       struct cm3323_data *data = iio_priv(indio_dev);
+
+       ret = i2c_smbus_read_word_data(data->client, CM3323_CMD_CONF);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error reading reg_conf\n");
+               return ret;
+       }
+
+       /* enable sensor and set auto force mode */
+       ret &= ~(CM3323_CONF_SD_BIT | CM3323_CONF_AF_BIT);
+
+       ret = i2c_smbus_write_word_data(data->client, CM3323_CMD_CONF, ret);
+       if (ret < 0) {
+               dev_err(&data->client->dev, "Error writing reg_conf\n");
+               return ret;
+       }
+
+       data->reg_conf = ret;
+
+       return 0;
+}
+
+static void cm3323_disable(struct iio_dev *indio_dev)
+{
+       int ret;
+       struct cm3323_data *data = iio_priv(indio_dev);
+
+       ret = i2c_smbus_write_word_data(data->client, CM3323_CMD_CONF,
+                                       CM3323_CONF_SD_BIT);
+       if (ret < 0)
+               dev_err(&data->client->dev, "Error writing reg_conf\n");
+}
+
+static int cm3323_set_it_bits(struct cm3323_data *data, int val, int val2)
+{
+       int i, ret;
+       u16 reg_conf;
+
+       for (i = 0; i < ARRAY_SIZE(cm3323_int_time); i++) {
+               if (val == cm3323_int_time[i].val &&
+                   val2 == cm3323_int_time[i].val2) {
+                       reg_conf = data->reg_conf;
+                       reg_conf |= i << CM3323_CONF_IT_SHIFT;
+
+                       ret = i2c_smbus_write_word_data(data->client,
+                                                       CM3323_CMD_CONF,
+                                                       reg_conf);
+                       if (ret < 0)
+                               return ret;
+
+                       data->reg_conf = reg_conf;
+                       return 0;
+               }
+       }
+       return -EINVAL;
+}
+
+static int cm3323_get_it_bits(struct cm3323_data *data)
+{
+       int bits;
+
+       bits = (data->reg_conf & CM3323_CONF_IT_MASK) >>
+               CM3323_CONF_IT_SHIFT;
+
+       if (bits >= ARRAY_SIZE(cm3323_int_time))
+               return -EINVAL;
+       return bits;
+}
+
+static int cm3323_read_raw(struct iio_dev *indio_dev,
+                          struct iio_chan_spec const *chan, int *val,
+                          int *val2, long mask)
+{
+       int i, ret;
+       struct cm3323_data *data = iio_priv(indio_dev);
+
+       switch (mask) {
+       case IIO_CHAN_INFO_RAW:
+               mutex_lock(&data->mutex);
+               ret = i2c_smbus_read_word_data(data->client, chan->address);
+               if (ret < 0) {
+                       mutex_unlock(&data->mutex);
+                       return ret;
+               }
+               *val = ret;
+               mutex_unlock(&data->mutex);
+
+               return IIO_VAL_INT;
+       case IIO_CHAN_INFO_INT_TIME:
+               mutex_lock(&data->mutex);
+               i = cm3323_get_it_bits(data);
+               if (i < 0) {
+                       mutex_unlock(&data->mutex);
+                       return -EINVAL;
+               }
+
+               *val = cm3323_int_time[i].val;
+               *val2 = cm3323_int_time[i].val2;
+               mutex_unlock(&data->mutex);
+
+               return IIO_VAL_INT_PLUS_MICRO;
+       default:
+               return -EINVAL;
+       }
+}
+
+static int cm3323_write_raw(struct iio_dev *indio_dev,
+                           struct iio_chan_spec const *chan, int val,
+                           int val2, long mask)
+{
+       struct cm3323_data *data = iio_priv(indio_dev);
+       int ret;
+
+       switch (mask) {
+       case IIO_CHAN_INFO_INT_TIME:
+               mutex_lock(&data->mutex);
+               ret = cm3323_set_it_bits(data, val, val2);
+               mutex_unlock(&data->mutex);
+
+               return ret;
+       default:
+               return -EINVAL;
+       }
+}
+
+static const struct iio_info cm3323_info = {
+       .driver_module  = THIS_MODULE,
+       .read_raw       = cm3323_read_raw,
+       .write_raw      = cm3323_write_raw,
+       .attrs          = &cm3323_attribute_group,
+};
+
+static int cm3323_probe(struct i2c_client *client,
+                       const struct i2c_device_id *id)
+{
+       struct cm3323_data *data;
+       struct iio_dev *indio_dev;
+       int ret;
+
+       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       data = iio_priv(indio_dev);
+       i2c_set_clientdata(client, indio_dev);
+       data->client = client;
+
+       mutex_init(&data->mutex);
+
+       indio_dev->dev.parent = &client->dev;
+       indio_dev->info = &cm3323_info;
+       indio_dev->name = CM3323_DRV_NAME;
+       indio_dev->channels = cm3323_channels;
+       indio_dev->num_channels = ARRAY_SIZE(cm3323_channels);
+       indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = cm3323_init(indio_dev);
+       if (ret < 0) {
+               dev_err(&client->dev, "cm3323 chip init failed\n");
+               return ret;
+       }
+       ret = iio_device_register(indio_dev);
+       if (ret < 0) {
+               dev_err(&client->dev, "failed to register iio dev\n");
+               goto err_init;
+       }
+       return 0;
+err_init:
+       cm3323_disable(indio_dev);
+       return ret;
+}
+
+static int cm3323_remove(struct i2c_client *client)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+       iio_device_unregister(indio_dev);
+       cm3323_disable(indio_dev);
+
+       return 0;
+}
+
+static const struct i2c_device_id cm3323_id[] = {
+       {"cm3323", 0},
+       {}
+};
+MODULE_DEVICE_TABLE(i2c, cm3323_id);
+
+static struct i2c_driver cm3323_driver = {
+       .driver = {
+               .name = CM3323_DRV_NAME,
+       },
+       .probe          = cm3323_probe,
+       .remove         = cm3323_remove,
+       .id_table       = cm3323_id,
+};
+
+module_i2c_driver(cm3323_driver);
+
+MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
+MODULE_DESCRIPTION("Capella CM3323 Color Light Sensor driver");
+MODULE_LICENSE("GPL v2");
index 221ed16de1f7babd220c81296c5eef7fdb959a0d..32b6449833faf5f6102e8b55edcb6810f2c25678 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
+#include <asm/unaligned.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>
 #include <linux/iio/iio.h>
@@ -966,7 +967,6 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct gp2ap020a00f_data *priv = iio_priv(indio_dev);
        size_t d_size = 0;
-       __le32 light_lux;
        int i, out_val, ret;
 
        for_each_set_bit(i, indio_dev->active_scan_mask,
@@ -981,8 +981,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data)
                    i == GP2AP020A00F_SCAN_MODE_LIGHT_IR) {
                        out_val = le16_to_cpup((__le16 *)&priv->buffer[d_size]);
                        gp2ap020a00f_output_to_lux(priv, &out_val);
-                       light_lux = cpu_to_le32(out_val);
-                       memcpy(&priv->buffer[d_size], (u8 *)&light_lux, 4);
+
+                       put_unaligned_le32(out_val, &priv->buffer[d_size]);
                        d_size += 4;
                } else {
                        d_size += 2;
index 29de7e7d9562421b983fe0f2b4042c684c878ed1..3a3af89beaf962671c9a5e65d0b3dd7fc25ce2c4 100644 (file)
@@ -308,7 +308,7 @@ static bool jsa1212_is_volatile_reg(struct device *dev, unsigned int reg)
        }
 }
 
-static struct regmap_config jsa1212_regmap_config = {
+static const struct regmap_config jsa1212_regmap_config = {
        .name =  JSA1212_REGMAP_NAME,
        .reg_bits = 8,
        .val_bits = 8,
index 62b7072af4de1425f0eb607b2d175a36b61bed09..78b87839c4b95864fffcc40c6aaceaf0b6093ccc 100644 (file)
@@ -333,6 +333,13 @@ static int ltr501_init(struct ltr501_data *data)
                data->ps_contr);
 }
 
+static int ltr501_powerdown(struct ltr501_data *data)
+{
+       return ltr501_write_contr(data->client,
+                                 data->als_contr & ~LTR501_CONTR_ACTIVE,
+                                 data->ps_contr & ~LTR501_CONTR_ACTIVE);
+}
+
 static int ltr501_probe(struct i2c_client *client,
                          const struct i2c_device_id *id)
 {
@@ -370,7 +377,7 @@ static int ltr501_probe(struct i2c_client *client,
        ret = iio_triggered_buffer_setup(indio_dev, NULL,
                ltr501_trigger_handler, NULL);
        if (ret)
-               return ret;
+               goto powerdown_on_error;
 
        ret = iio_device_register(indio_dev);
        if (ret)
@@ -380,16 +387,11 @@ static int ltr501_probe(struct i2c_client *client,
 
 error_unreg_buffer:
        iio_triggered_buffer_cleanup(indio_dev);
+powerdown_on_error:
+       ltr501_powerdown(data);
        return ret;
 }
 
-static int ltr501_powerdown(struct ltr501_data *data)
-{
-       return ltr501_write_contr(data->client,
-               data->als_contr & ~LTR501_CONTR_ACTIVE,
-               data->ps_contr & ~LTR501_CONTR_ACTIVE);
-}
-
 static int ltr501_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
index e3106b43ef488ff69b1108edc18781fcdbd29518..261d517428e475d49b89d9d8567666abe42750a0 100644 (file)
@@ -321,6 +321,12 @@ static const struct iio_info mag3110_info = {
 
 static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0};
 
+static int mag3110_standby(struct mag3110_data *data)
+{
+       return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
+               data->ctrl_reg1 & ~MAG3110_CTRL_AC);
+}
+
 static int mag3110_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
@@ -360,12 +366,12 @@ static int mag3110_probe(struct i2c_client *client,
        ret = i2c_smbus_write_byte_data(client, MAG3110_CTRL_REG2,
                MAG3110_CTRL_AUTO_MRST_EN);
        if (ret < 0)
-               return ret;
+               goto standby_on_error;
 
        ret = iio_triggered_buffer_setup(indio_dev, NULL,
                mag3110_trigger_handler, NULL);
        if (ret < 0)
-               return ret;
+               goto standby_on_error;
 
        ret = iio_device_register(indio_dev);
        if (ret < 0)
@@ -374,15 +380,11 @@ static int mag3110_probe(struct i2c_client *client,
 
 buffer_cleanup:
        iio_triggered_buffer_cleanup(indio_dev);
+standby_on_error:
+       mag3110_standby(iio_priv(indio_dev));
        return ret;
 }
 
-static int mag3110_standby(struct mag3110_data *data)
-{
-       return i2c_smbus_write_byte_data(data->client, MAG3110_CTRL_REG1,
-               data->ctrl_reg1 & ~MAG3110_CTRL_AC);
-}
-
 static int mag3110_remove(struct i2c_client *client)
 {
        struct iio_dev *indio_dev = i2c_get_clientdata(client);
index a3be53792072e454bcdcb38bee764c213d6d0ef6..fa62950419479233a3aecf0f1b3fe03c42e5fe6f 100644 (file)
@@ -52,6 +52,33 @@ config MPL3115
           To compile this driver as a module, choose M here: the module
           will be called mpl3115.
 
+config MS5611
+       tristate "Measurement Specialities MS5611 pressure sensor driver"
+       help
+         Say Y here to build support for the Measurement Specialities
+         MS5611 pressure and temperature sensor.
+
+         To compile this driver as a module, choose M here: the module will
+         be called ms5611_core.
+
+config MS5611_I2C
+       tristate "support I2C bus connection"
+       depends on I2C && MS5611
+       help
+         Say Y here to build I2C bus support for MS5611.
+
+         To compile this driver as a module, choose M here: the module will
+         be called ms5611_i2c.
+
+config MS5611_SPI
+       tristate "support SPI bus connection"
+       depends on SPI_MASTER && MS5611
+       help
+         Say Y here to build SPI bus support for MS5611.
+
+         To compile this driver as a module, choose M here: the module will
+         be called ms5611_spi.
+
 config IIO_ST_PRESS
        tristate "STMicroelectronics pressure sensor Driver"
        depends on (I2C || SPI_MASTER) && SYSFS
index 88011f2ae00e4ca0f0955e97ea7f927ccc8eb4b1..a4f98f8d90ed0c33d9023feb64d7fb8d5cddc389 100644 (file)
@@ -7,6 +7,9 @@ obj-$(CONFIG_BMP280) += bmp280.o
 obj-$(CONFIG_HID_SENSOR_PRESS)   += hid-sensor-press.o
 obj-$(CONFIG_MPL115) += mpl115.o
 obj-$(CONFIG_MPL3115) += mpl3115.o
+obj-$(CONFIG_MS5611) += ms5611_core.o
+obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o
+obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o
 obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o
 st_pressure-y := st_pressure_core.o
 st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o
diff --git a/drivers/iio/pressure/ms5611.h b/drivers/iio/pressure/ms5611.h
new file mode 100644 (file)
index 0000000..099c6cd
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * MS5611 pressure and temperature sensor driver
+ *
+ * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef _MS5611_H
+#define _MS5611_H
+
+#include <linux/device.h>
+#include <linux/iio/iio.h>
+#include <linux/mutex.h>
+
+#define MS5611_RESET                   0x1e
+#define MS5611_READ_ADC                        0x00
+#define MS5611_READ_PROM_WORD          0xA0
+#define MS5611_START_TEMP_CONV         0x58
+#define MS5611_START_PRESSURE_CONV     0x48
+
+#define MS5611_CONV_TIME_MIN           9040
+#define MS5611_CONV_TIME_MAX           10000
+
+#define MS5611_PROM_WORDS_NB           8
+
+struct ms5611_state {
+       void *client;
+       struct mutex lock;
+
+       int (*reset)(struct device *dev);
+       int (*read_prom_word)(struct device *dev, int index, u16 *word);
+       int (*read_adc_temp_and_pressure)(struct device *dev,
+                                         s32 *temp, s32 *pressure);
+
+       u16 prom[MS5611_PROM_WORDS_NB];
+};
+
+int ms5611_probe(struct iio_dev *indio_dev, struct device *dev);
+
+#endif /* _MS5611_H */
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
new file mode 100644 (file)
index 0000000..e42c853
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * MS5611 pressure and temperature sensor driver
+ *
+ * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Data sheet:
+ *  http://www.meas-spec.com/downloads/MS5611-01BA03.pdf
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/iio/iio.h>
+#include <linux/delay.h>
+
+#include "ms5611.h"
+
+static bool ms5611_prom_is_valid(u16 *prom, size_t len)
+{
+       int i, j;
+       uint16_t crc = 0, crc_orig = prom[7] & 0x000F;
+
+       prom[7] &= 0xFF00;
+
+       for (i = 0; i < len * 2; i++) {
+               if (i % 2 == 1)
+                       crc ^= prom[i >> 1] & 0x00FF;
+               else
+                       crc ^= prom[i >> 1] >> 8;
+
+               for (j = 0; j < 8; j++) {
+                       if (crc & 0x8000)
+                               crc = (crc << 1) ^ 0x3000;
+                       else
+                               crc <<= 1;
+               }
+       }
+
+       crc = (crc >> 12) & 0x000F;
+
+       return crc_orig != 0x0000 && crc == crc_orig;
+}
+
+static int ms5611_read_prom(struct iio_dev *indio_dev)
+{
+       int ret, i;
+       struct ms5611_state *st = iio_priv(indio_dev);
+
+       for (i = 0; i < MS5611_PROM_WORDS_NB; i++) {
+               ret = st->read_prom_word(&indio_dev->dev, i, &st->prom[i]);
+               if (ret < 0) {
+                       dev_err(&indio_dev->dev,
+                               "failed to read prom at %d\n", i);
+                       return ret;
+               }
+       }
+
+       if (!ms5611_prom_is_valid(st->prom, MS5611_PROM_WORDS_NB)) {
+               dev_err(&indio_dev->dev, "PROM integrity check failed\n");
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static int ms5611_read_temp_and_pressure(struct iio_dev *indio_dev,
+                                        s32 *temp, s32 *pressure)
+{
+       int ret;
+       s32 t, p;
+       s64 off, sens, dt;
+       struct ms5611_state *st = iio_priv(indio_dev);
+
+       ret = st->read_adc_temp_and_pressure(&indio_dev->dev, &t, &p);
+       if (ret < 0) {
+               dev_err(&indio_dev->dev,
+                       "failed to read temperature and pressure\n");
+               return ret;
+       }
+
+       dt = t - (st->prom[5] << 8);
+       off = ((s64)st->prom[2] << 16) + ((st->prom[4] * dt) >> 7);
+       sens = ((s64)st->prom[1] << 15) + ((st->prom[3] * dt) >> 8);
+
+       t = 2000 + ((st->prom[6] * dt) >> 23);
+       if (t < 2000) {
+               s64 off2, sens2, t2;
+
+               t2 = (dt * dt) >> 31;
+               off2 = (5 * (t - 2000) * (t - 2000)) >> 1;
+               sens2 = off2 >> 1;
+
+               if (t < -1500) {
+                       s64 tmp = (t + 1500) * (t + 1500);
+
+                       off2 += 7 * tmp;
+                       sens2 += (11 * tmp) >> 1;
+               }
+
+               t -= t2;
+               off -= off2;
+               sens -= sens2;
+       }
+
+       *temp = t;
+       *pressure = (((p * sens) >> 21) - off) >> 15;
+
+       return 0;
+}
+
+static int ms5611_reset(struct iio_dev *indio_dev)
+{
+       int ret;
+       struct ms5611_state *st = iio_priv(indio_dev);
+
+       ret = st->reset(&indio_dev->dev);
+       if (ret < 0) {
+               dev_err(&indio_dev->dev, "failed to reset device\n");
+               return ret;
+       }
+
+       usleep_range(3000, 4000);
+
+       return 0;
+}
+
+static int ms5611_read_raw(struct iio_dev *indio_dev,
+                          struct iio_chan_spec const *chan,
+                          int *val, int *val2, long mask)
+{
+       int ret;
+       s32 temp, pressure;
+       struct ms5611_state *st = iio_priv(indio_dev);
+
+       switch (mask) {
+       case IIO_CHAN_INFO_PROCESSED:
+               mutex_lock(&st->lock);
+               ret = ms5611_read_temp_and_pressure(indio_dev,
+                                                   &temp, &pressure);
+               mutex_unlock(&st->lock);
+               if (ret < 0)
+                       return ret;
+
+               switch (chan->type) {
+               case IIO_TEMP:
+                       *val = temp * 10;
+                       return IIO_VAL_INT;
+               case IIO_PRESSURE:
+                       *val = pressure / 1000;
+                       *val2 = (pressure % 1000) * 1000;
+                       return IIO_VAL_INT_PLUS_MICRO;
+               default:
+                       return -EINVAL;
+               }
+       }
+
+       return -EINVAL;
+}
+
+static const struct iio_chan_spec ms5611_channels[] = {
+       {
+               .type = IIO_PRESSURE,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
+                       BIT(IIO_CHAN_INFO_SCALE)
+       },
+       {
+               .type = IIO_TEMP,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
+                       BIT(IIO_CHAN_INFO_SCALE)
+       }
+};
+
+static const struct iio_info ms5611_info = {
+       .read_raw = &ms5611_read_raw,
+       .driver_module = THIS_MODULE,
+};
+
+static int ms5611_init(struct iio_dev *indio_dev)
+{
+       int ret;
+
+       ret = ms5611_reset(indio_dev);
+       if (ret < 0)
+               return ret;
+
+       return ms5611_read_prom(indio_dev);
+}
+
+int ms5611_probe(struct iio_dev *indio_dev, struct device *dev)
+{
+       int ret;
+       struct ms5611_state *st = iio_priv(indio_dev);
+
+       mutex_init(&st->lock);
+       indio_dev->dev.parent = dev;
+       indio_dev->name = dev->driver->name;
+       indio_dev->info = &ms5611_info;
+       indio_dev->channels = ms5611_channels;
+       indio_dev->num_channels = ARRAY_SIZE(ms5611_channels);
+       indio_dev->modes = INDIO_DIRECT_MODE;
+
+       ret = ms5611_init(indio_dev);
+       if (ret < 0)
+               return ret;
+
+       return devm_iio_device_register(dev, indio_dev);
+}
+EXPORT_SYMBOL(ms5611_probe);
+
+MODULE_AUTHOR("Tomasz Duszynski <tduszyns@gmail.com>");
+MODULE_DESCRIPTION("MS5611 core driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/pressure/ms5611_i2c.c b/drivers/iio/pressure/ms5611_i2c.c
new file mode 100644 (file)
index 0000000..748fd9a
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * MS5611 pressure and temperature sensor driver (I2C bus)
+ *
+ * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 7-bit I2C slave addresses:
+ *
+ * 0x77 (CSB pin low)
+ * 0x76 (CSB pin high)
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+
+#include "ms5611.h"
+
+static int ms5611_i2c_reset(struct device *dev)
+{
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       return i2c_smbus_write_byte(st->client, MS5611_RESET);
+}
+
+static int ms5611_i2c_read_prom_word(struct device *dev, int index, u16 *word)
+{
+       int ret;
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       ret = i2c_smbus_read_word_swapped(st->client,
+                       MS5611_READ_PROM_WORD + (index << 1));
+       if (ret < 0)
+               return ret;
+
+       *word = ret;
+
+       return 0;
+}
+
+static int ms5611_i2c_read_adc(struct ms5611_state *st, s32 *val)
+{
+       int ret;
+       u8 buf[3];
+
+       ret = i2c_smbus_read_i2c_block_data(st->client, MS5611_READ_ADC,
+                                           3, buf);
+       if (ret < 0)
+               return ret;
+
+       *val = (buf[0] << 16) | (buf[1] << 8) | buf[2];
+
+       return 0;
+}
+
+static int ms5611_i2c_read_adc_temp_and_pressure(struct device *dev,
+                                                s32 *temp, s32 *pressure)
+{
+       int ret;
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       ret = i2c_smbus_write_byte(st->client, MS5611_START_TEMP_CONV);
+       if (ret < 0)
+               return ret;
+
+       usleep_range(MS5611_CONV_TIME_MIN, MS5611_CONV_TIME_MAX);
+
+       ret = ms5611_i2c_read_adc(st, temp);
+       if (ret < 0)
+               return ret;
+
+       ret = i2c_smbus_write_byte(st->client, MS5611_START_PRESSURE_CONV);
+       if (ret < 0)
+               return ret;
+
+       usleep_range(MS5611_CONV_TIME_MIN, MS5611_CONV_TIME_MAX);
+
+       return ms5611_i2c_read_adc(st, pressure);
+}
+
+static int ms5611_i2c_probe(struct i2c_client *client,
+                           const struct i2c_device_id *id)
+{
+       struct ms5611_state *st;
+       struct iio_dev *indio_dev;
+
+       if (!i2c_check_functionality(client->adapter,
+                                    I2C_FUNC_SMBUS_WRITE_BYTE |
+                                    I2C_FUNC_SMBUS_READ_WORD_DATA |
+                                    I2C_FUNC_SMBUS_READ_I2C_BLOCK))
+               return -ENODEV;
+
+       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       st = iio_priv(indio_dev);
+       st->reset = ms5611_i2c_reset;
+       st->read_prom_word = ms5611_i2c_read_prom_word;
+       st->read_adc_temp_and_pressure = ms5611_i2c_read_adc_temp_and_pressure;
+       st->client = client;
+
+       return ms5611_probe(indio_dev, &client->dev);
+}
+
+static const struct i2c_device_id ms5611_id[] = {
+       { "ms5611", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, ms5611_id);
+
+static struct i2c_driver ms5611_driver = {
+       .driver = {
+               .name = "ms5611",
+               .owner = THIS_MODULE,
+       },
+       .id_table = ms5611_id,
+       .probe = ms5611_i2c_probe,
+};
+module_i2c_driver(ms5611_driver);
+
+MODULE_AUTHOR("Tomasz Duszynski <tduszyns@gmail.com>");
+MODULE_DESCRIPTION("MS5611 i2c driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
new file mode 100644 (file)
index 0000000..976726f
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * MS5611 pressure and temperature sensor driver (SPI bus)
+ *
+ * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+
+#include "ms5611.h"
+
+static int ms5611_spi_reset(struct device *dev)
+{
+       u8 cmd = MS5611_RESET;
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       return spi_write_then_read(st->client, &cmd, 1, NULL, 0);
+}
+
+static int ms5611_spi_read_prom_word(struct device *dev, int index, u16 *word)
+{
+       int ret;
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       ret = spi_w8r16be(st->client, MS5611_READ_PROM_WORD + (index << 1));
+       if (ret < 0)
+               return ret;
+
+       *word = ret;
+
+       return 0;
+}
+
+static int ms5611_spi_read_adc(struct device *dev, s32 *val)
+{
+       int ret;
+       u8 buf[3] = { MS5611_READ_ADC };
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       ret = spi_write_then_read(st->client, buf, 1, buf, 3);
+       if (ret < 0)
+               return ret;
+
+       *val = (buf[0] << 16) | (buf[1] << 8) | buf[2];
+
+       return 0;
+}
+
+static int ms5611_spi_read_adc_temp_and_pressure(struct device *dev,
+                                                s32 *temp, s32 *pressure)
+{
+       u8 cmd;
+       int ret;
+       struct ms5611_state *st = iio_priv(dev_to_iio_dev(dev));
+
+       cmd = MS5611_START_TEMP_CONV;
+       ret = spi_write_then_read(st->client, &cmd, 1, NULL, 0);
+       if (ret < 0)
+               return ret;
+
+       usleep_range(MS5611_CONV_TIME_MIN, MS5611_CONV_TIME_MAX);
+
+       ret = ms5611_spi_read_adc(dev, temp);
+       if (ret < 0)
+               return ret;
+
+       cmd = MS5611_START_PRESSURE_CONV;
+       ret = spi_write_then_read(st->client, &cmd, 1, NULL, 0);
+       if (ret < 0)
+               return ret;
+
+       usleep_range(MS5611_CONV_TIME_MIN, MS5611_CONV_TIME_MAX);
+
+       return ms5611_spi_read_adc(dev, pressure);
+}
+
+static int ms5611_spi_probe(struct spi_device *spi)
+{
+       int ret;
+       struct ms5611_state *st;
+       struct iio_dev *indio_dev;
+
+       indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+       if (!indio_dev)
+               return -ENOMEM;
+
+       spi->mode = SPI_MODE_0;
+       spi->max_speed_hz = 20000000;
+       spi->bits_per_word = 8;
+       ret = spi_setup(spi);
+       if (ret < 0)
+               return ret;
+
+       st = iio_priv(indio_dev);
+       st->reset = ms5611_spi_reset;
+       st->read_prom_word = ms5611_spi_read_prom_word;
+       st->read_adc_temp_and_pressure = ms5611_spi_read_adc_temp_and_pressure;
+       st->client = spi;
+
+       return ms5611_probe(indio_dev, &spi->dev);
+}
+
+static const struct spi_device_id ms5611_id[] = {
+       { "ms5611", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(spi, ms5611_id);
+
+static struct spi_driver ms5611_driver = {
+       .driver = {
+               .name = "ms5611",
+               .owner = THIS_MODULE,
+       },
+       .id_table = ms5611_id,
+       .probe = ms5611_spi_probe,
+};
+module_spi_driver(ms5611_driver);
+
+MODULE_AUTHOR("Tomasz Duszynski <tduszyns@gmail.com>");
+MODULE_DESCRIPTION("MS5611 spi driver");
+MODULE_LICENSE("GPL v2");
index 89fca3a7075039b9b9a0de5514c1b96758d4593b..fa40f6d0ca394f0ae41f6509d6f6c3079062b77e 100644 (file)
@@ -618,16 +618,12 @@ static int sx9500_gpio_probe(struct i2c_client *client,
        dev = &client->dev;
 
        /* data ready gpio interrupt pin */
-       gpio = devm_gpiod_get_index(dev, SX9500_GPIO_NAME, 0);
+       gpio = devm_gpiod_get_index(dev, SX9500_GPIO_NAME, 0, GPIOD_IN);
        if (IS_ERR(gpio)) {
                dev_err(dev, "acpi gpio get index failed\n");
                return PTR_ERR(gpio);
        }
 
-       ret = gpiod_direction_input(gpio);
-       if (ret)
-               return ret;
-
        ret = gpiod_to_irq(gpio);
 
        dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
index c8b6ac8b2d69ad7cbfd834309d263a026b50b2e7..a112fc9abf4346ba0e53b03314fa3781aec9eeac 100644 (file)
@@ -2,6 +2,7 @@
  * mlx90614.c - Support for Melexis MLX90614 contactless IR temperature sensor
  *
  * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
+ * Copyright (c) 2015 Essensium NV
  *
  * This file is subject to the terms and conditions of version 2 of
  * the GNU General Public License.  See the file COPYING in the main
 
 #include <linux/iio/iio.h>
 
-#define MLX90614_OP_RAM 0x00
+#define MLX90614_OP_RAM                0x00
+#define MLX90614_OP_EEPROM     0x20
+#define MLX90614_OP_SLEEP      0xff
 
 /* RAM offsets with 16-bit data, MSB first */
-#define MLX90614_TA 0x06 /* ambient temperature */
-#define MLX90614_TOBJ1 0x07 /* object temperature */
+#define MLX90614_RAW1  (MLX90614_OP_RAM | 0x04) /* raw data IR channel 1 */
+#define MLX90614_RAW2  (MLX90614_OP_RAM | 0x05) /* raw data IR channel 2 */
+#define MLX90614_TA    (MLX90614_OP_RAM | 0x06) /* ambient temperature */
+#define MLX90614_TOBJ1 (MLX90614_OP_RAM | 0x07) /* object 1 temperature */
+#define MLX90614_TOBJ2 (MLX90614_OP_RAM | 0x08) /* object 2 temperature */
+
+/* EEPROM offsets with 16-bit data, MSB first */
+#define MLX90614_EMISSIVITY    (MLX90614_OP_EEPROM | 0x04) /* emissivity correction coefficient */
+#define MLX90614_CONFIG                (MLX90614_OP_EEPROM | 0x05) /* configuration register */
+
+/* Control bits in configuration register */
+#define MLX90614_CONFIG_IIR_SHIFT 0 /* IIR coefficient */
+#define MLX90614_CONFIG_IIR_MASK (0x7 << MLX90614_CONFIG_IIR_SHIFT)
+#define MLX90614_CONFIG_DUAL_SHIFT 6 /* single (0) or dual (1) IR sensor */
+#define MLX90614_CONFIG_DUAL_MASK (1 << MLX90614_CONFIG_DUAL_SHIFT)
+#define MLX90614_CONFIG_FIR_SHIFT 8 /* FIR coefficient */
+#define MLX90614_CONFIG_FIR_MASK (0x7 << MLX90614_CONFIG_FIR_SHIFT)
+#define MLX90614_CONFIG_GAIN_SHIFT 11 /* gain */
+#define MLX90614_CONFIG_GAIN_MASK (0x7 << MLX90614_CONFIG_GAIN_SHIFT)
+
+/* Timings (in ms) */
+#define MLX90614_TIMING_EEPROM 20 /* time for EEPROM write/erase to complete */
+#define MLX90614_TIMING_WAKEUP 34 /* time to hold SDA low for wake-up */
+#define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */
 
 struct mlx90614_data {
        struct i2c_client *client;
@@ -35,26 +60,34 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
                            int *val2, long mask)
 {
        struct mlx90614_data *data = iio_priv(indio_dev);
+       u8 cmd;
        s32 ret;
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW: /* 0.02K / LSB */
                switch (channel->channel2) {
                case IIO_MOD_TEMP_AMBIENT:
-                       ret = i2c_smbus_read_word_data(data->client,
-                           MLX90614_OP_RAM | MLX90614_TA);
-                       if (ret < 0)
-                               return ret;
+                       cmd = MLX90614_TA;
                        break;
                case IIO_MOD_TEMP_OBJECT:
-                       ret = i2c_smbus_read_word_data(data->client,
-                           MLX90614_OP_RAM | MLX90614_TOBJ1);
-                       if (ret < 0)
-                               return ret;
+                       switch (channel->channel) {
+                       case 0:
+                               cmd = MLX90614_TOBJ1;
+                               break;
+                       case 1:
+                               cmd = MLX90614_TOBJ2;
+                               break;
+                       default:
+                               return -EINVAL;
+                       }
                        break;
                default:
                        return -EINVAL;
                }
+
+               ret = i2c_smbus_read_word_data(data->client, cmd);
+               if (ret < 0)
+                       return ret;
                *val = ret;
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_OFFSET:
@@ -86,6 +119,16 @@ static const struct iio_chan_spec mlx90614_channels[] = {
                .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
                    BIT(IIO_CHAN_INFO_SCALE),
        },
+       {
+               .type = IIO_TEMP,
+               .indexed = 1,
+               .modified = 1,
+               .channel = 1,
+               .channel2 = IIO_MOD_TEMP_OBJECT,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+               .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
+                   BIT(IIO_CHAN_INFO_SCALE),
+       },
 };
 
 static const struct iio_info mlx90614_info = {
@@ -93,11 +136,25 @@ static const struct iio_info mlx90614_info = {
        .driver_module = THIS_MODULE,
 };
 
+/* Return 0 for single sensor, 1 for dual sensor, <0 on error. */
+static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
+{
+       s32 ret;
+
+       ret = i2c_smbus_read_word_data(client, MLX90614_CONFIG);
+
+       if (ret < 0)
+               return ret;
+
+       return (ret & MLX90614_CONFIG_DUAL_MASK) ? 1 : 0;
+}
+
 static int mlx90614_probe(struct i2c_client *client,
                         const struct i2c_device_id *id)
 {
        struct iio_dev *indio_dev;
        struct mlx90614_data *data;
+       int ret;
 
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
                return -ENODEV;
@@ -115,8 +172,21 @@ static int mlx90614_probe(struct i2c_client *client,
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->info = &mlx90614_info;
 
-       indio_dev->channels = mlx90614_channels;
-       indio_dev->num_channels = ARRAY_SIZE(mlx90614_channels);
+       ret = mlx90614_probe_num_ir_sensors(client);
+       switch (ret) {
+       case 0:
+               dev_dbg(&client->dev, "Found single sensor");
+               indio_dev->channels = mlx90614_channels;
+               indio_dev->num_channels = 2;
+               break;
+       case 1:
+               dev_dbg(&client->dev, "Found dual sensor");
+               indio_dev->channels = mlx90614_channels;
+               indio_dev->num_channels = 3;
+               break;
+       default:
+               return ret;
+       }
 
        return iio_device_register(indio_dev);
 }
@@ -146,5 +216,6 @@ static struct i2c_driver mlx90614_driver = {
 module_i2c_driver(mlx90614_driver);
 
 MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>");
+MODULE_AUTHOR("Vianney le Clément de Saint-Marcq <vianney.leclement@essensium.com>");
 MODULE_DESCRIPTION("Melexis MLX90614 contactless IR temperature sensor driver");
 MODULE_LICENSE("GPL");
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 654acb5c8eba12f11b53bfb9ab8602aef9830440..3bc461cbbfa3d06fc9f5c2dfc292eef8a34edbd6 100644 (file)
@@ -280,3 +280,4 @@ static void __exit ion_test_exit(void)
 
 module_init(ion_test_init);
 module_exit(ion_test_exit);
+MODULE_LICENSE("GPL v2");
index 7bdb62bf6b4054068094590a861f254f76c8b5c8..f83e00c7805130e1ab6dda8d853c2b642b8a4f92 100644 (file)
@@ -114,7 +114,7 @@ void sync_timeline_signal(struct sync_timeline *obj)
        list_for_each_entry_safe(pt, next, &obj->active_list_head,
                                 active_list) {
                if (fence_is_signaled_locked(&pt->base))
-                       list_del(&pt->active_list);
+                       list_del_init(&pt->active_list);
        }
 
        spin_unlock_irqrestore(&obj->child_list_lock, flags);
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..e78ddbe5a954f9e048d7afca15cbf0171c15e8f1 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;
@@ -601,28 +601,55 @@ static struct attribute *comedi_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(comedi_dev);
 
-static void comedi_set_subdevice_runflags(struct comedi_subdevice *s,
-                                         unsigned mask, unsigned bits)
+static void __comedi_clear_subdevice_runflags(struct comedi_subdevice *s,
+                                             unsigned bits)
+{
+       s->runflags &= ~bits;
+}
+
+static void __comedi_set_subdevice_runflags(struct comedi_subdevice *s,
+                                           unsigned bits)
+{
+       s->runflags |= bits;
+}
+
+static void comedi_update_subdevice_runflags(struct comedi_subdevice *s,
+                                            unsigned mask, unsigned bits)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&s->spin_lock, flags);
-       s->runflags &= ~mask;
-       s->runflags |= (bits & mask);
+       __comedi_clear_subdevice_runflags(s, mask);
+       __comedi_set_subdevice_runflags(s, bits & mask);
        spin_unlock_irqrestore(&s->spin_lock, flags);
 }
 
+static unsigned __comedi_get_subdevice_runflags(struct comedi_subdevice *s)
+{
+       return s->runflags;
+}
+
 static unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s)
 {
        unsigned long flags;
        unsigned runflags;
 
        spin_lock_irqsave(&s->spin_lock, flags);
-       runflags = s->runflags;
+       runflags = __comedi_get_subdevice_runflags(s);
        spin_unlock_irqrestore(&s->spin_lock, flags);
        return runflags;
 }
 
+static bool comedi_is_runflags_running(unsigned runflags)
+{
+       return runflags & COMEDI_SRF_RUNNING;
+}
+
+static bool comedi_is_runflags_in_error(unsigned runflags)
+{
+       return runflags & COMEDI_SRF_ERROR;
+}
+
 /**
  * comedi_is_subdevice_running - check if async command running on subdevice
  * @s: comedi_subdevice struct
@@ -634,22 +661,22 @@ bool comedi_is_subdevice_running(struct comedi_subdevice *s)
 {
        unsigned runflags = comedi_get_subdevice_runflags(s);
 
-       return (runflags & COMEDI_SRF_RUNNING) ? true : false;
+       return comedi_is_runflags_running(runflags);
 }
 EXPORT_SYMBOL_GPL(comedi_is_subdevice_running);
 
-static bool comedi_is_subdevice_in_error(struct comedi_subdevice *s)
+static bool __comedi_is_subdevice_running(struct comedi_subdevice *s)
 {
-       unsigned runflags = comedi_get_subdevice_runflags(s);
+       unsigned runflags = __comedi_get_subdevice_runflags(s);
 
-       return (runflags & COMEDI_SRF_ERROR) ? true : false;
+       return comedi_is_runflags_running(runflags);
 }
 
 static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
 {
        unsigned runflags = comedi_get_subdevice_runflags(s);
 
-       return (runflags & COMEDI_SRF_BUSY_MASK) ? false : true;
+       return !(runflags & COMEDI_SRF_BUSY_MASK);
 }
 
 /**
@@ -677,14 +704,14 @@ static void do_become_nonbusy(struct comedi_device *dev,
 {
        struct comedi_async *async = s->async;
 
-       comedi_set_subdevice_runflags(s, COMEDI_SRF_RUNNING, 0);
+       comedi_update_subdevice_runflags(s, COMEDI_SRF_RUNNING, 0);
        if (async) {
                comedi_buf_reset(s);
                async->inttrig = NULL;
                kfree(async->cmd.chanlist);
                async->cmd.chanlist = NULL;
                s->busy = NULL;
-               wake_up_interruptible_all(&s->async->wait_head);
+               wake_up_interruptible_all(&async->wait_head);
        } else {
                dev_err(dev->class_dev,
                        "BUG: (?) do_become_nonbusy called with async=NULL\n");
@@ -759,7 +786,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) {
@@ -1678,8 +1705,8 @@ static int do_cmd_ioctl(struct comedi_device *dev,
        if (async->cmd.flags & CMDF_WAKE_EOS)
                async->cb_mask |= COMEDI_CB_EOS;
 
-       comedi_set_subdevice_runflags(s, COMEDI_SRF_BUSY_MASK,
-                                     COMEDI_SRF_RUNNING);
+       comedi_update_subdevice_runflags(s, COMEDI_SRF_BUSY_MASK,
+                                        COMEDI_SRF_RUNNING);
 
        /*
         * Set s->busy _after_ setting COMEDI_SRF_RUNNING flag to avoid
@@ -1840,7 +1867,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)
@@ -2282,13 +2309,16 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
        add_wait_queue(&async->wait_head, &wait);
        on_wait_queue = true;
        while (nbytes > 0 && !retval) {
+               unsigned runflags;
+
                set_current_state(TASK_INTERRUPTIBLE);
 
-               if (!comedi_is_subdevice_running(s)) {
+               runflags = comedi_get_subdevice_runflags(s);
+               if (!comedi_is_runflags_running(runflags)) {
                        if (count == 0) {
                                struct comedi_subdevice *new_s;
 
-                               if (comedi_is_subdevice_in_error(s))
+                               if (comedi_is_runflags_in_error(runflags))
                                        retval = -EPIPE;
                                else
                                        retval = 0;
@@ -2435,8 +2465,10 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
                        n = m;
 
                if (n == 0) {
-                       if (!comedi_is_subdevice_running(s)) {
-                               if (comedi_is_subdevice_in_error(s))
+                       unsigned runflags = comedi_get_subdevice_runflags(s);
+
+                       if (!comedi_is_runflags_running(runflags)) {
+                               if (comedi_is_runflags_in_error(runflags))
                                        retval = -EPIPE;
                                else
                                        retval = 0;
@@ -2638,39 +2670,38 @@ static const struct file_operations comedi_fops = {
 void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 {
        struct comedi_async *async = s->async;
-       unsigned runflags = 0;
-       unsigned runflags_mask = 0;
+       unsigned int events;
+       int si_code = 0;
+       unsigned long flags;
 
-       if (!comedi_is_subdevice_running(s))
+       spin_lock_irqsave(&s->spin_lock, flags);
+
+       events = async->events;
+       async->events = 0;
+       if (!__comedi_is_subdevice_running(s)) {
+               spin_unlock_irqrestore(&s->spin_lock, flags);
                return;
+       }
 
-       if (s->async->events & COMEDI_CB_CANCEL_MASK)
-               runflags_mask |= COMEDI_SRF_RUNNING;
+       if (events & COMEDI_CB_CANCEL_MASK)
+               __comedi_clear_subdevice_runflags(s, COMEDI_SRF_RUNNING);
 
        /*
-        * Remember if an error event has occurred, so an error
-        * can be returned the next time the user does a read().
+        * Remember if an error event has occurred, so an error can be
+        * returned the next time the user does a read() or write().
         */
-       if (s->async->events & COMEDI_CB_ERROR_MASK) {
-               runflags_mask |= COMEDI_SRF_ERROR;
-               runflags |= COMEDI_SRF_ERROR;
-       }
-       if (runflags_mask) {
-               /*
-                * Sets COMEDI_SRF_ERROR and COMEDI_SRF_RUNNING together
-                * atomically.
-                */
-               comedi_set_subdevice_runflags(s, runflags_mask, runflags);
-       }
+       if (events & COMEDI_CB_ERROR_MASK)
+               __comedi_set_subdevice_runflags(s, COMEDI_SRF_ERROR);
 
-       if (async->cb_mask & s->async->events) {
+       if (async->cb_mask & events) {
                wake_up_interruptible(&async->wait_head);
-               if (s->subdev_flags & SDF_CMD_READ)
-                       kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
-               if (s->subdev_flags & SDF_CMD_WRITE)
-                       kill_fasync(&dev->async_queue, SIGIO, POLL_OUT);
+               si_code = async->cmd.flags & CMDF_WRITE ? POLL_OUT : POLL_IN;
        }
-       s->async->events = 0;
+
+       spin_unlock_irqrestore(&s->spin_lock, flags);
+
+       if (si_code)
+               kill_fasync(&dev->async_queue, SIGIO, si_code);
 }
 EXPORT_SYMBOL_GPL(comedi_event);
 
@@ -2682,7 +2713,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 +2721,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 +2731,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 +2778,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 +2804,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 d57817c19aea1f17ea60f8f2017154bbbe798235..3b918538847e614a700019e044fa4456a220696f 100644 (file)
@@ -1,11 +1,21 @@
 #ifndef _COMEDI_INTERNAL_H
 #define _COMEDI_INTERNAL_H
 
+#include <linux/compiler.h>
 #include <linux/types.h>
 
 /*
  * various internal comedi stuff
  */
+
+struct comedi_buf_map;
+struct comedi_devconfig;
+struct comedi_device;
+struct comedi_insn;
+struct comedi_rangeinfo;
+struct comedi_subdevice;
+struct device;
+
 int do_rangeinfo_ioctl(struct comedi_device *dev,
                       struct comedi_rangeinfo __user *arg);
 struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device);
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..dfab5a84b011f50215d626a92d2a31ebc877b835 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;
@@ -463,6 +464,84 @@ static inline unsigned int comedi_samples_to_bytes(struct comedi_subdevice *s,
        return nsamples << comedi_sample_shift(s);
 }
 
+/**
+ * comedi_check_trigger_src() - trivially validate a comedi_cmd trigger source
+ * @src: pointer to the trigger source to validate
+ * @flags: bitmask of valid TRIG_* for the trigger
+ *
+ * This is used in "step 1" of the do_cmdtest functions of comedi drivers
+ * to vaildate the comedi_cmd triggers. The mask of the @src against the
+ * @flags allows the userspace comedilib to pass all the comedi_cmd
+ * triggers as TRIG_ANY and get back a bitmask of the valid trigger sources.
+ */
+static inline int comedi_check_trigger_src(unsigned int *src,
+                                          unsigned int flags)
+{
+       unsigned int orig_src = *src;
+
+       *src = orig_src & flags;
+       if (*src == TRIG_INVALID || *src != orig_src)
+               return -EINVAL;
+       return 0;
+}
+
+/**
+ * comedi_check_trigger_is_unique() - make sure a trigger source is unique
+ * @src: the trigger source to check
+ */
+static inline int comedi_check_trigger_is_unique(unsigned int src)
+{
+       /* this test is true if more than one _src bit is set */
+       if ((src & (src - 1)) != 0)
+               return -EINVAL;
+       return 0;
+}
+
+/**
+ * comedi_check_trigger_arg_is() - trivially validate a trigger argument
+ * @arg: pointer to the trigger arg to validate
+ * @val: the value the argument should be
+ */
+static inline int comedi_check_trigger_arg_is(unsigned int *arg,
+                                             unsigned int val)
+{
+       if (*arg != val) {
+               *arg = val;
+               return -EINVAL;
+       }
+       return 0;
+}
+
+/**
+ * comedi_check_trigger_arg_min() - trivially validate a trigger argument
+ * @arg: pointer to the trigger arg to validate
+ * @val: the minimum value the argument should be
+ */
+static inline int comedi_check_trigger_arg_min(unsigned int *arg,
+                                              unsigned int val)
+{
+       if (*arg < val) {
+               *arg = val;
+               return -EINVAL;
+       }
+       return 0;
+}
+
+/**
+ * comedi_check_trigger_arg_max() - trivially validate a trigger argument
+ * @arg: pointer to the trigger arg to validate
+ * @val: the maximum value the argument should be
+ */
+static inline int comedi_check_trigger_arg_max(unsigned int *arg,
+                                              unsigned int val)
+{
+       if (*arg > val) {
+               *arg = val;
+               return -EINVAL;
+       }
+       return 0;
+}
+
 /*
  * Must set dev->hw_dev if you wish to dma directly into comedi's buffer.
  * Also useful for retrieving a previously configured hardware device of
@@ -553,47 +632,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 c2f15de6a547a6a2cca8c44339dfb00067475f5c..ba89321df65d8ef97afad5bf471149e1934fd5ae 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/module.h>
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
 #include "8255.h"
 
 struct subdev_8255_private {
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..b37166d57b64cd277e7484b2be22afe72ba20c54 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 #include "amcc_s5933.h"
 
 /*
@@ -196,11 +194,11 @@ static int apci1032_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -210,11 +208,12 @@ static int apci1032_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..63991c49ff2309e8a00bdd1bf28e4ad16eefcce4 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 #include "amcc_s5933.h"
 #include "z8536.h"
 
@@ -249,8 +247,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)
@@ -386,11 +384,11 @@ static int apci1500_di_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -415,12 +413,13 @@ static int apci1500_di_cmdtest(struct comedi_device *dev,
         *   3  OR mode for Port A (digital inputs 0-7)
         *      OR mode for Port B (digital inputs 8-13 and internal signals)
         */
-       err |= cfc_check_trigger_arg_max(&cmd->start_arg, 3);
+       err |= comedi_check_trigger_arg_max(&cmd->start_arg, 3);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -514,11 +513,11 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
 
                src = pt & 0xff;
                if (src)
-                       ret |= cfc_check_trigger_is_unique(src);
+                       ret |= comedi_check_trigger_is_unique(src);
 
                src = (pt >> 8) & 0xff;
                if (src)
-                       ret |= cfc_check_trigger_is_unique(src);
+                       ret |= comedi_check_trigger_is_unique(src);
 
                if (ret) {
                        dev_dbg(dev->class_dev,
index d8410415cc90e5901771090df02f0dfddefb2881..9c516d1fe896fd351233ca73d24f8a8dbb8f0b00 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 #include "addi_watchdog.h"
-#include "comedi_fc.h"
 
 /*
  * PCI bar 1 I/O Register map - Digital input/output
index 6872b69da5dbf730b981b2cbb8fce95636be50f3..33e58b9a21b296895332fc7df5e0834dffc4f78e 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 #include "addi_tcw.h"
 #include "addi_watchdog.h"
 
 #define APCI1564_COUNTER(x)                    ((x) * 0x20)
 
 struct apci1564_private {
-       unsigned long eeprom;           /* base address of EEPROM register */
-       unsigned long timer;            /* base address of 12-bit timer */
-       unsigned long counters;         /* base address of 32-bit counters */
-       unsigned int mode1;             /* riding-edge/high level channels */
-       unsigned int mode2;             /* falling-edge/low level channels */
-       unsigned int ctrl;              /* interrupt mode OR (edge) . AND (level) */
+       unsigned long eeprom;   /* base address of EEPROM register */
+       unsigned long timer;    /* base address of 12-bit timer */
+       unsigned long counters; /* base address of 32-bit counters */
+       unsigned int mode1;     /* riding-edge/high level channels */
+       unsigned int mode2;     /* falling-edge/low level channels */
+       unsigned int ctrl;      /* interrupt mode OR (edge) . AND (level) */
        struct task_struct *tsk_current;
 };
 
@@ -365,11 +363,11 @@ static int apci1564_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -379,11 +377,12 @@ static int apci1564_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..ad715253bdccdfdbeb04993c5ad9ee264ce5f615 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"
 
 /*
  * PCI bar 1 I/O Register map
@@ -93,17 +91,17 @@ static int apci2032_int_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -112,14 +110,15 @@ static int apci2032_int_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
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..95dc64bfec73b85d2644f9469b1e66ed07686fbf 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 #include "amcc_s5933.h"
 
 /*
@@ -612,21 +610,21 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -635,21 +633,24 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->scan_begin_src == TRIG_TIMER)  /* Test Delay timing */
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 100000);
+       if (cmd->scan_begin_src == TRIG_TIMER) {        /* Test Delay timing */
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   100000);
+       }
 
        /* minimum conversion time per sample is 10us */
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /*  TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -659,7 +660,7 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                /* scan begin must be larger than the scan time */
                arg = cmd->convert_arg * cmd->scan_end_arg;
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
index 5961f195ba0bfaacc811109eba14b3da98100f0e..73786a3f3df98e60fee1b4843ad145a931f22406 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 
-#include "../comedidev.h"
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 #include "amcc_s5933.h"
 
 /*
@@ -203,7 +201,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 +268,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 +280,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..bef6efc84efde1c9a83596a7eaa48fc584e09ea8 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 
 #define CONV_UNIT_NS           (1 << 0)
 #define CONV_UNIT_US           (1 << 1)
@@ -529,18 +526,18 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -549,16 +546,17 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                        board->ai_min_acq_ns);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                           board->ai_min_acq_ns);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -567,7 +565,7 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev,
 
        arg = cmd->convert_arg;
        err |= apci3xxx_ai_ns_to_timer(dev, &arg, cmd->flags);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
        if (err)
                return 4;
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..c9df3afe97f6f60d2309a935771966bcbc75a5f5 100644 (file)
@@ -65,15 +65,13 @@ 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 +135,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 +162,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,19 +261,18 @@ 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;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src,
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src,
                                        TRIG_COUNT | TRIG_NONE);
 
        if (err)
@@ -301,9 +280,9 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -317,26 +296,29 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
                                        PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
-       else    /* TRIG_EXT */
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+       } else {        /* TRIG_EXT */
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       }
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
                                        PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
-       else    /* TRIG_FOLLOW || TRIG_EXT */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       } else {        /* TRIG_FOLLOW || TRIG_EXT */
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -345,11 +327,8 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        /*
@@ -362,7 +341,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
                if (arg < cmd->scan_begin_arg)
                        arg *= (cmd->scan_begin_arg / arg);
 
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -376,7 +355,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 +378,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 +572,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 +646,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 +676,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..fb3043dcfff1e62b9cc318df55e82c3dceea308c 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_fc.h"
+#include "comedi_8254.h"
 
 #define IORANGE_9118   64      /* I hope */
 #define PCI9118_CHANLEN        255     /*
@@ -94,8 +92,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 +236,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 +290,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 +415,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 +552,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 +569,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 +586,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 +631,6 @@ static void pci9118_ai_munge(struct comedi_device *dev,
                        array[i] ^= 0x8000;
                else
                        array[i] = (array[i] >> 4) & 0x0fff;
-
        }
 }
 
@@ -966,7 +933,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 +942,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 +1061,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 +1078,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 +1099,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 +1128,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,25 +1170,24 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src,
+       err |= comedi_check_trigger_src(&cmd->start_src,
                                        TRIG_NOW | TRIG_EXT | TRIG_INT);
 
        flags = TRIG_FOLLOW;
        if (devpriv->master)
                flags |= TRIG_TIMER | TRIG_EXT;
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, flags);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, flags);
 
        flags = TRIG_TIMER | TRIG_EXT;
        if (devpriv->master)
                flags |= TRIG_NOW;
-       err |= cfc_check_trigger_src(&cmd->convert_src, flags);
+       err |= comedi_check_trigger_src(&cmd->convert_src, flags);
 
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src,
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src,
                                        TRIG_COUNT | TRIG_NONE | TRIG_EXT);
 
        if (err)
@@ -1232,10 +1195,10 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -1264,7 +1227,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
        switch (cmd->start_src) {
        case TRIG_NOW:
        case TRIG_EXT:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_INT:
                /* start_arg is the internal trigger (any value) */
@@ -1272,7 +1235,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
        }
 
        if (cmd->scan_begin_src & (TRIG_FOLLOW | TRIG_EXT))
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if ((cmd->scan_begin_src == TRIG_TIMER) &&
            (cmd->convert_src == TRIG_TIMER) && (cmd->scan_end_arg == 1)) {
@@ -1281,34 +1244,37 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
                cmd->scan_begin_arg = 0;
        }
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                devpriv->ai_ns_min);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   devpriv->ai_ns_min);
+       }
 
-       if (cmd->scan_begin_src == TRIG_EXT)
+       if (cmd->scan_begin_src == TRIG_EXT) {
                if (cmd->scan_begin_arg) {
                        cmd->scan_begin_arg = 0;
                        err |= -EINVAL;
-                       err |= cfc_check_trigger_arg_max(&cmd->scan_end_arg,
-                                                        65535);
+                       err |= comedi_check_trigger_arg_max(&cmd->scan_end_arg,
+                                                           65535);
                }
+       }
 
-       if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW))
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                devpriv->ai_ns_min);
+       if (cmd->convert_src & (TRIG_TIMER | TRIG_NOW)) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   devpriv->ai_ns_min);
+       }
 
        if (cmd->convert_src == TRIG_EXT)
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
 
-       err |= cfc_check_trigger_arg_min(&cmd->scan_end_arg,
-                                        cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->scan_end_arg,
+                                           cmd->chanlist_len);
 
        if ((cmd->scan_end_arg % cmd->chanlist_len)) {
                cmd->scan_end_arg =
@@ -1323,18 +1289,14 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER &&
                    cmd->convert_src == TRIG_NOW) {
@@ -1344,8 +1306,9 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
                        } else {
                                arg = cmd->convert_arg * cmd->chanlist_len;
                        }
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        arg);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           arg);
                }
        }
 
@@ -1482,10 +1445,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 +1549,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..0c6aa964c884f274de3cd0e194ffe0f90edc630f 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,11 @@ 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 +65,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 +80,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 +248,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 +485,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 +524,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 +645,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 +664,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 +674,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 +690,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,26 +703,25 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* step 2a: make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* step 2b: and mutually compatible */
 
@@ -856,20 +730,21 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
        else    /* TRIG_FOLLOW */
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -877,12 +752,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -898,19 +771,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 +885,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 +986,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 1c7b325a373cb8141b67a5de47617f2cc6b42c41..35b2f98f0de951a93b069cf450c8cac4e7dfc517 100644 (file)
@@ -42,8 +42,6 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-
 #define AIO_IIRO_16_RELAY_0_7          0x00
 #define AIO_IIRO_16_INPUT_0_7          0x01
 #define AIO_IIRO_16_IRQ                        0x02
@@ -116,11 +114,11 @@ static int aio_iiro_16_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -130,11 +128,12 @@ static int aio_iiro_16_cos_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
index 26aad705aad30d83539dc704d9deacff8ee78b68..d15a3dc1216a0a8bc073c469c4a2e3e01e4f597a 100644 (file)
 #include "../comedidev.h"
 
 #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 +96,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 +162,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,
@@ -366,19 +372,19 @@ static int dio200_subdev_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -387,15 +393,16 @@ static int dio200_subdev_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..245f932a75a8fd60bb0c3fba459b650518fbb89d 100644 (file)
@@ -24,7 +24,6 @@
 #include "../comedidev.h"
 
 #include "amplc_pc236.h"
-#include "comedi_fc.h"
 #include "8255.h"
 
 static void pc236_intr_update(struct comedi_device *dev, bool enable)
@@ -82,11 +81,11 @@ static int pc236_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -96,11 +95,12 @@ static int pc236_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check it arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..08a91854837ab183c307bdfb0c94dab09afcf46e 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 +374,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 +444,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,28 +660,27 @@ 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;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
-                                    TRIG_EXT | TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src,
-                                    TRIG_COUNT | TRIG_EXT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
+                                       TRIG_EXT | TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src,
+                                       TRIG_COUNT | TRIG_EXT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -714,7 +705,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        switch (cmd->start_src) {
        case TRIG_INT:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                /* Force to external trigger 0. */
@@ -734,13 +725,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        switch (cmd->scan_begin_src) {
        case TRIG_TIMER:
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                MAX_SCAN_PERIOD);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   MAX_SCAN_PERIOD);
 
                arg = cmd->chanlist_len * CONVERT_PERIOD;
                if (arg < MIN_SCAN_PERIOD)
                        arg = MIN_SCAN_PERIOD;
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
                break;
        case TRIG_EXT:
                /* Force to external trigger 0. */
@@ -760,12 +751,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                break;
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        switch (cmd->stop_src) {
        case TRIG_COUNT:
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
                break;
        case TRIG_EXT:
                /* Force to external trigger 0. */
@@ -781,7 +773,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                }
                break;
        case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
                break;
        }
 
@@ -793,11 +785,8 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -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..20d592002557a36c49b52937a31df2fa6a3fbd06 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 +495,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 +683,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 +692,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 +748,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 +799,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);
@@ -898,7 +884,7 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT);
 
        tmp = TRIG_TIMER | TRIG_INT;
        if (thisboard->min_hwver > 0 && devpriv->hwver >= 2) {
@@ -918,19 +904,19 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
                 */
                tmp |= TRIG_EXT;
        }
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, tmp);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, tmp);
 
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -939,7 +925,7 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
 #define MAX_SPEED_AO   8000    /* 8000 ns => 125 kHz */
 /*
@@ -950,10 +936,10 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
 
        switch (cmd->scan_begin_src) {
        case TRIG_TIMER:
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                MAX_SPEED_AO);
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                MIN_SPEED_AO);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   MAX_SPEED_AO);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   MIN_SPEED_AO);
                break;
        case TRIG_EXT:
                /*
@@ -978,16 +964,17 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
                }
                break;
        default:
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
                break;
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -1520,7 +1507,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
 
        tmp = TRIG_FOLLOW | TRIG_TIMER | TRIG_INT;
        if (thisboard->have_dio || thisboard->min_hwver > 0) {
@@ -1532,21 +1519,21 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
                 */
                tmp |= TRIG_EXT;
        }
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, tmp);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, tmp);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
                                        TRIG_TIMER | TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -1563,7 +1550,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
 #define MAX_SPEED_AI_SE                3200    /* PCI230 SE:   3200 ns => 312.5 kHz */
 #define MAX_SPEED_AI_DIFF      8000    /* PCI230 DIFF: 8000 ns => 125 kHz */
@@ -1598,10 +1585,10 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
                        max_speed_ai = MAX_SPEED_AI_PLUS;
                }
 
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                max_speed_ai);
-               err |= cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                                MIN_SPEED_AI);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   max_speed_ai);
+               err |= comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                   MIN_SPEED_AI);
        } else if (cmd->convert_src == TRIG_EXT) {
                /*
                 * external trigger
@@ -1636,18 +1623,20 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
                         * convert_arg == 0 => trigger on -ve edge.
                         * convert_arg == 1 => trigger on +ve edge.
                         */
-                       err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 1);
+                       err |= comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                           1);
                }
        } else {
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_EXT) {
                /*
@@ -1672,7 +1661,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
                        err |= -EINVAL;
 
        } else {
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        }
 
        if (err)
@@ -1767,8 +1756,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 +2178,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 +2382,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 +2470,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..ae84f2c0cc9c3bd2569b36e1e29bed9fc9055de5 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>
@@ -40,17 +38,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 +273,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..e3591a5824fe9b7a945913cc07a379261f3c7f2c 100644 (file)
@@ -62,16 +62,14 @@ 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"
 
 #define AI_BUFFER_SIZE         1024    /* max ai fifo size */
 #define AO_BUFFER_SIZE         1024    /* max ao fifo size */
@@ -338,14 +336,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 +349,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 +523,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,29 +771,28 @@ 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;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
                                        TRIG_TIMER | TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -819,7 +811,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
 
        switch (cmd->start_src) {
        case TRIG_NOW:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                /* External trigger, only CR_EDGE and CR_INVERT flags allowed */
@@ -836,20 +828,24 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
                break;
        }
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                               thisboard->ai_speed * cmd->chanlist_len);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   thisboard->ai_speed *
+                                                   cmd->chanlist_len);
+       }
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                thisboard->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   thisboard->ai_speed);
+       }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -858,19 +854,13 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -886,18 +876,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 +911,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,24 +985,23 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -1030,18 +1010,20 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                thisboard->ao_scan_speed);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   thisboard->ao_scan_speed);
+       }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -1049,12 +1031,11 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               unsigned int arg = cmd->scan_begin_arg;
+
+               comedi_8254_cascade_ns_to_timer(devpriv->ao_pacer,
+                                               &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -1139,18 +1120,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 +1149,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 +1379,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 +1512,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 +1533,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..a94c33c3d962d8dd4c48b1273aa7aad40c5dbb47 100644 (file)
@@ -81,16 +81,13 @@ 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"
 
 #define TIMER_BASE 25          /*  40MHz master clock */
 /* 100kHz 'prescaled' clock for slow acquisition,
@@ -1474,9 +1471,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 +1480,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 +1489,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 +1498,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 +1699,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 +1707,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 +1834,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 +1895,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 +1992,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 +2019,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) +
@@ -2094,34 +2085,34 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
 
        triggers = TRIG_TIMER;
        if (thisboard->layout == LAYOUT_4020)
                triggers |= TRIG_OTHER;
        else
                triggers |= TRIG_FOLLOW;
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, triggers);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, triggers);
 
        triggers = TRIG_TIMER;
        if (thisboard->layout == LAYOUT_4020)
                triggers |= TRIG_NOW;
        else
                triggers |= TRIG_EXT;
-       err |= cfc_check_trigger_src(&cmd->convert_src, triggers);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src,
-                                    TRIG_COUNT | TRIG_EXT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, triggers);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src,
+                                       TRIG_COUNT | TRIG_EXT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -2135,7 +2126,7 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        switch (cmd->start_src) {
        case TRIG_NOW:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                /*
@@ -2147,30 +2138,37 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        if (cmd->convert_src == TRIG_TIMER) {
                if (thisboard->layout == LAYOUT_4020) {
-                       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+                       err |= comedi_check_trigger_arg_is(&cmd->convert_arg,
+                                                          0);
                } else {
-                       err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                        thisboard->ai_speed);
-                       /* if scans are timed faster than conversion rate allows */
-                       if (cmd->scan_begin_src == TRIG_TIMER)
-                               err |= cfc_check_trigger_arg_min(
+                       err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                           thisboard->
+                                                           ai_speed);
+                       /*
+                        * if scans are timed faster than conversion rate
+                        * allows
+                        */
+                       if (cmd->scan_begin_src == TRIG_TIMER) {
+                               err |= comedi_check_trigger_arg_min(
                                                &cmd->scan_begin_arg,
                                                cmd->convert_arg *
                                                cmd->chanlist_len);
+                       }
                }
        }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        switch (cmd->stop_src) {
        case TRIG_EXT:
                break;
        case TRIG_COUNT:
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
                break;
        case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
                break;
        default:
                break;
@@ -2637,8 +2635,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 +2826,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 +2978,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;
@@ -3312,20 +3312,20 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
-                                    TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -3340,11 +3340,11 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                thisboard->ao_scan_speed);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   thisboard->ao_scan_speed);
                if (get_ao_divisor(cmd->scan_begin_arg, cmd->flags) >
                    max_counter_value) {
                        cmd->scan_begin_arg = (max_counter_value + 2) *
@@ -3353,8 +3353,9 @@ static int ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                }
        }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (err)
                return 3;
@@ -3817,8 +3818,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 +3831,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 +3861,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 +3902,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 +3914,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..30c9e27d1ed90743c9254a293707cb18a03429fa 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 
-#include "../comedidev.h"
+#include "../comedi_pci.h"
 
-#include "comedi_fc.h"
 #include "8255.h"
 
 #define EEPROM_SIZE    128     /*  number of entries in eeprom */
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;
 }
diff --git a/drivers/staging/comedi/drivers/comedi_fc.h b/drivers/staging/comedi/drivers/comedi_fc.h
deleted file mode 100644 (file)
index 756be93..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * comedi_fc.h
- * This is a place for code driver writers wish to share between
- * two or more drivers. These functions are meant to be used only
- * by drivers, they are NOT part of the kcomedilib API!
- *
- * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
- * Copyright (C) 2002 Frank Mori Hess
- *
- * 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_FC_H
-#define _COMEDI_FC_H
-
-#include "../comedidev.h"
-
-/**
- * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
- * @src: pointer to the trigger source to validate
- * @flags: bitmask of valid TRIG_* for the trigger
- *
- * This is used in "step 1" of the do_cmdtest functions of comedi drivers
- * to vaildate the comedi_cmd triggers. The mask of the @src against the
- * @flags allows the userspace comedilib to pass all the comedi_cmd
- * triggers as TRIG_ANY and get back a bitmask of the valid trigger sources.
- */
-static inline int cfc_check_trigger_src(unsigned int *src, unsigned int flags)
-{
-       unsigned int orig_src = *src;
-
-       *src = orig_src & flags;
-       if (*src == TRIG_INVALID || *src != orig_src)
-               return -EINVAL;
-       return 0;
-}
-
-/**
- * cfc_check_trigger_is_unique() - make sure a trigger source is unique
- * @src: the trigger source to check
- */
-static inline int cfc_check_trigger_is_unique(unsigned int src)
-{
-       /* this test is true if more than one _src bit is set */
-       if ((src & (src - 1)) != 0)
-               return -EINVAL;
-       return 0;
-}
-
-/**
- * cfc_check_trigger_arg_is() - trivially validate a trigger argument
- * @arg: pointer to the trigger arg to validate
- * @val: the value the argument should be
- */
-static inline int cfc_check_trigger_arg_is(unsigned int *arg, unsigned int val)
-{
-       if (*arg != val) {
-               *arg = val;
-               return -EINVAL;
-       }
-       return 0;
-}
-
-/**
- * cfc_check_trigger_arg_min() - trivially validate a trigger argument
- * @arg: pointer to the trigger arg to validate
- * @val: the minimum value the argument should be
- */
-static inline int cfc_check_trigger_arg_min(unsigned int *arg,
-                                           unsigned int val)
-{
-       if (*arg < val) {
-               *arg = val;
-               return -EINVAL;
-       }
-       return 0;
-}
-
-/**
- * cfc_check_trigger_arg_max() - trivially validate a trigger argument
- * @arg: pointer to the trigger arg to validate
- * @val: the maximum value the argument should be
- */
-static inline int cfc_check_trigger_arg_max(unsigned int *arg,
-                                           unsigned int val)
-{
-       if (*arg > val) {
-               *arg = val;
-               return -EINVAL;
-       }
-       return 0;
-}
-
-#endif /* _COMEDI_FC_H */
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 ceef6931edbe019bd52d688a6e5dab6b5de7179b..15a4093efda13869c0be6be98429ff03fdf5cbd4 100644 (file)
@@ -69,8 +69,6 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-
 /*
  * Register map
  */
@@ -161,11 +159,11 @@ static int parport_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -175,11 +173,12 @@ static int parport_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
index e56525a1c8f3bf55571e04ed4caae6ce011f9c5b..80d613c0fbc65b85477460f388bcc337ddafed1c 100644 (file)
@@ -50,7 +50,6 @@ zero volts).
 
 #include <asm/div64.h>
 
-#include "comedi_fc.h"
 #include <linux/timer.h>
 #include <linux/ktime.h>
 
@@ -225,19 +224,20 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW | TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_NOW | TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -246,26 +246,30 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->convert_src == TRIG_NOW)
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                nano_per_micro);
-               if (cmd->convert_src == TRIG_TIMER)
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                       cmd->convert_arg * cmd->chanlist_len);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   nano_per_micro);
+               if (cmd->convert_src == TRIG_TIMER) {
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           cmd->convert_arg *
+                                                           cmd->chanlist_len);
+               }
        }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -277,14 +281,14 @@ static int waveform_ai_cmdtest(struct comedi_device *dev,
                /* round to nearest microsec */
                arg = nano_per_micro *
                      ((arg + (nano_per_micro / 2)) / nano_per_micro);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
                /* round to nearest microsec */
                arg = nano_per_micro *
                      ((arg + (nano_per_micro / 2)) / nano_per_micro);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -420,9 +424,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..d7cf4b153f7c37889efd8032712ee64a33f27426 100644 (file)
@@ -76,8 +76,7 @@
 #include "../comedidev.h"
 
 #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 */
@@ -599,29 +598,29 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
 
        trig_mask = TRIG_FOLLOW;
        if (devpriv->can_burst)
                trig_mask |= TRIG_TIMER | TRIG_EXT;
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, trig_mask);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, trig_mask);
 
        trig_mask = TRIG_TIMER | TRIG_EXT;
        if (devpriv->can_burst)
                trig_mask |= TRIG_NOW;
-       err |= cfc_check_trigger_src(&cmd->convert_src, trig_mask);
+       err |= comedi_check_trigger_src(&cmd->convert_src, trig_mask);
 
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -636,26 +635,30 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        /* check against maximum frequency */
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                       board->ai_speed * cmd->chanlist_len);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   board->ai_speed *
+                                                   cmd->chanlist_len);
+       }
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                board->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   board->ai_speed);
+       }
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -663,19 +666,13 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
        if (err)
                return 4;
@@ -693,17 +690,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 +711,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 +924,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 +938,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 +1026,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 +1066,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..1adf6a71a9f3f00089753f829b069ca47bd82b35 100644 (file)
@@ -53,12 +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_fc.h"
+#include "comedi_8254.h"
 
 #define DAS16M1_SIZE2 8
 
@@ -103,8 +103,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 +122,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 +130,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 +166,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,26 +177,25 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -208,20 +204,21 @@ static int das16m1_cmd_test(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 1000);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 1000);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -229,12 +226,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -250,25 +245,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 +259,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 +286,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 +407,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 +553,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 +609,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 +623,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..53baf37cd21a6ab71e6eea8bb66a524e51f8e24e 100644 (file)
@@ -102,8 +102,7 @@ TODO:
 #include "../comedidev.h"
 
 #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 +421,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 +488,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,18 +726,18 @@ 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;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src,
                                        TRIG_COUNT | TRIG_EXT | TRIG_NONE);
 
        if (err)
@@ -750,10 +745,10 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -766,21 +761,23 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                thisboard->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   thisboard->ai_speed);
+       }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        switch (cmd->stop_src) {
        case TRIG_COUNT:
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
                break;
        case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
                break;
        default:
                break;
@@ -795,35 +792,24 @@ 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 |= comedi_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 |= comedi_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 |= comedi_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 |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg,
+                                                          arg);
                }
        }
 
@@ -910,31 +896,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 +1014,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 +1144,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 +1350,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..1701294b79cdd59eee72612de6ec278c950b0a05 100644 (file)
@@ -35,8 +35,8 @@
 #include <linux/interrupt.h>
 
 #include "../comedidev.h"
-#include "comedi_fc.h"
-#include "8253.h"
+
+#include "comedi_8254.h"
 
 /*
  * Register I/O map
@@ -138,11 +138,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 +167,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 +241,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,24 +297,23 @@ 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;
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -348,30 +322,26 @@ static int das6402_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000);
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        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->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 |= comedi_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..39d304a1259f4fe2e9be0dad8675f1e2af4f21b7 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,15 @@ 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 "comedi_fc.h"
+#include "../comedidev.h"
+
+#include "comedi_8254.h"
 
 #define N_CHAN_AI             8        /*  number of analog input channels */
 
@@ -219,8 +214,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 +265,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,26 +304,25 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -350,19 +331,21 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                thisboard->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   thisboard->ai_speed);
+       }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -370,12 +353,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -426,8 +407,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 +678,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..bb2883c83afaa010b713e51fc96ff346208b824b 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.
  */
@@ -41,7 +41,6 @@
 #include "../comedidev.h"
 
 #include "8255.h"
-#include "comedi_fc.h"
 
 /* Board register addresses */
 #define DMM32AT_AI_START_CONV_REG      0x00
@@ -274,18 +273,18 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -294,10 +293,10 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 1000000);
-       err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000);
+       err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, 1000000);
+       err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000);
 
        if (cmd->convert_arg >= 17500)
                cmd->convert_arg = 20000;
@@ -308,12 +307,13 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
        else
                cmd->convert_arg = 5000;
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -321,7 +321,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
        /* Step 4: fix up any arguments */
 
        arg = cmd->convert_arg * cmd->scan_end_arg;
-       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
+       err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, arg);
 
        if (err)
                return 4;
@@ -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..66705f9a0621f928488f4f450fa1d00ed2df33c5 100644 (file)
@@ -40,8 +40,6 @@ addition, the clock does not seem to be very accurate.
 
 #include <linux/delay.h>
 
-#include "comedi_fc.h"
-
 #define DT2814_CSR 0
 #define DT2814_DATA 1
 
@@ -56,7 +54,6 @@ addition, the clock does not seem to be very accurate.
 #define DT2814_CHANMASK 0x0f
 
 struct dt2814_private {
-
        int ntrig;
        int curadchan;
 };
@@ -130,18 +127,18 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -150,18 +147,19 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000);
-       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                        DT2814_MAX_SPEED);
+       err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 1000000000);
+       err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                           DT2814_MAX_SPEED);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 2);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 2);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -170,7 +168,7 @@ static int dt2814_ai_cmdtest(struct comedi_device *dev,
 
        arg = cmd->scan_begin_arg;
        dt2814_ns_to_timer(&arg, cmd->flags);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 
        if (err)
                return 4;
@@ -193,7 +191,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..5a536a00066f9ff4340813d85b68854044715d3d 100644 (file)
@@ -64,7 +64,6 @@
 #include "../comedidev.h"
 
 #include "comedi_isadma.h"
-#include "comedi_fc.h"
 
 /*
  * Register map
@@ -661,20 +660,20 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -683,21 +682,22 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 4000);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 4000);
 
 #define SLOWEST_TIMER  (250*(1<<15)*255)
-       err |= cfc_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg, board->ai_speed);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_EXT | TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -706,7 +706,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
 
        arg = cmd->convert_arg;
        devpriv->divisor = dt282x_ns_to_timer(&arg, cmd->flags);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
        if (err)
                return 4;
@@ -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);
@@ -831,18 +831,18 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -851,15 +851,16 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg, 5000);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg, 5000);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_EXT | TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -868,13 +869,12 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
 
        arg = cmd->scan_begin_arg;
        devpriv->divisor = dt282x_ns_to_timer(&arg, cmd->flags);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 
        if (err)
                return 4;
 
        return 0;
-
 }
 
 static int dt282x_ao_inttrig(struct comedi_device *dev,
index 0aa51980e32778e267eaf2d2c440c55465ac91f8..031282c82f43a2f1e4826648068ddc7e52fae85b 100644 (file)
@@ -49,13 +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_fc.h"
+#include "../comedi_pci.h"
 
 static const struct comedi_lrange range_dt3000_ai = {
        4, {
@@ -409,11 +406,11 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
 
        if (err)
                return 1;
@@ -423,28 +420,29 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                this_board->ai_speed);
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                100 * 16 * 65535);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   this_board->ai_speed);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   100 * 16 * 65535);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                this_board->ai_speed);
-               err |= cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                                50 * 16 * 65535);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   this_board->ai_speed);
+               err |= comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                   50 * 16 * 65535);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
+               err |= comedi_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -454,18 +452,19 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                dt3k_ns_to_timer(100, &arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
                dt3k_ns_to_timer(50, &arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        arg = cmd->convert_arg * cmd->scan_end_arg;
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        arg);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           arg);
                }
        }
 
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..3cb6409c4f0183e530b43cdb913cf9ab5e2bb49c 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"
 
 /*
  * PCI BAR2 Register map (dev->mmio)
@@ -386,18 +384,18 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -406,18 +404,19 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (!cmd->chanlist_len || !cmd->chanlist) {
                cmd->chanlist_len = 32;
                err |= -EINVAL;
        }
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..7a8c27dd71541b976ca0dafa55df4c0b7ab4c7d7 100644 (file)
@@ -41,14 +41,12 @@ 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 +168,6 @@ broken.
 
 struct me4000_info {
        unsigned long plx_regbase;
-       unsigned long timer_regbase;
 };
 
 enum me4000_boardid {
@@ -424,7 +421,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 +435,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 +606,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 +621,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 +727,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 +767,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 +822,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;
@@ -838,24 +832,25 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src,
                                        TRIG_NONE | TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE | TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE | TRIG_COUNT);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_end_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_end_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -886,7 +881,7 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->chanlist_len < 1) {
                cmd->chanlist_len = 1;
@@ -906,9 +901,9 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
        }
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..e43a0c8323c18e7715df21b875d07191dff702ff 100644 (file)
 #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"
 
 #define TOP_OF_PAGE(x) ((x)|(~(PAGE_MASK)))
@@ -186,10 +184,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..62a817e4cd64582b14e3afe1c101066d89276695 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI BAR1 - Register memory map
@@ -224,11 +221,11 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
 
        if (err)
                return 1;
@@ -238,11 +235,12 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
index 67cb758eb0cd9293e41abbcd7d91e50daafa0b75..800d57426070409b27ebaebed6292cb77135d89b 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/interrupt.h>
 
-#include "../comedidev.h"
-
-#include "comedi_fc.h"
+#include "../comedi_pci.h"
 
 /*
  * PCI BAR1 Register Map
@@ -508,11 +505,11 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_OTHER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT);
 
        if (err)
                return 1;
@@ -522,11 +519,12 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -613,7 +611,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 +674,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..46647c64f3692d6853276aecb933f698d523316c 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"
 #include "ni_tio.h"
 
@@ -195,7 +193,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 +699,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 +858,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 +1104,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..3a972d1538ab6f9d8d3092e123c74ff8d56bba38 100644 (file)
@@ -67,8 +67,7 @@ TRIG_WAKE_EOS
 #include "../comedidev.h"
 
 #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 +109,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;
@@ -422,19 +419,19 @@ static int a2150_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -443,19 +440,21 @@ static int a2150_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                thisboard->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   thisboard->ai_speed);
+       }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -465,7 +464,7 @@ static int a2150_ai_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                a2150_get_timing(dev, &arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -488,7 +487,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 +545,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 +723,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 +749,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..c3eb54622bc37c46a5c37d84e0436757b4a37d30 100644 (file)
@@ -34,7 +34,6 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d)
 #include <linux/interrupt.h>
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
 #include "8255.h"
 
 /* Configuration and Status Registers */
@@ -96,7 +95,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;
 };
@@ -234,20 +232,20 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -256,30 +254,31 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) {
                /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        } else {
 #if 0
                /* external trigger */
                /* should be level/edge, hi/lo specification here */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 #endif
        }
 
-       err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000);
+       err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
 #if 0
-       err |= cfc_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
+       err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
 #endif
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
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..863afb28ee286c8271b260a68958eaba8a9c4a9b 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"
 #include "ni_labpc_regs.h"
 #include "ni_labpc_isadma.h"
@@ -108,32 +108,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 +258,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 +341,81 @@ 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);
+               comedi_check_trigger_arg_min(&pacer->next_div1, 2);
+               comedi_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);
+               comedi_check_trigger_arg_min(&pacer->next_div, 2);
+               comedi_check_trigger_arg_max(&pacer->next_div, I8254_MAX_COUNT);
+               comedi_check_trigger_arg_min(&pacer->next_div2, 2);
+               comedi_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 +429,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 +454,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]);
@@ -543,26 +512,27 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
 
        stop_mask = TRIG_COUNT | TRIG_NONE;
        if (board->is_labpc1200)
                stop_mask |= TRIG_EXT;
-       err |= cfc_check_trigger_src(&cmd->stop_src, stop_mask);
+       err |= comedi_check_trigger_src(&cmd->stop_src, stop_mask);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -577,7 +547,7 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
 
        switch (cmd->start_src) {
        case TRIG_NOW:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                /* start_arg value is ignored */
@@ -586,27 +556,33 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
 
        if (!cmd->chanlist_len)
                err |= -EINVAL;
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                board->ai_speed);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   board->ai_speed);
+       }
 
        /* make sure scan timing is not too fast */
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               if (cmd->convert_src == TRIG_TIMER)
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                       cmd->convert_arg * cmd->chanlist_len);
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                               board->ai_speed * cmd->chanlist_len);
+               if (cmd->convert_src == TRIG_TIMER) {
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           cmd->convert_arg *
+                                                           cmd->chanlist_len);
+               }
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   board->ai_speed *
+                                                   cmd->chanlist_len);
        }
 
        switch (cmd->stop_src) {
        case TRIG_COUNT:
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
                break;
        case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
                break;
                /*
                 * TRIG_EXT doesn't care since it doesn't
@@ -670,11 +646,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 +692,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 +1214,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 +1330,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 6b4ccd86b3d093b7603bfafafede0264c0bdcadb..29dbdf5ec25dfb37d4de072946d8d6d878543af8 100644 (file)
@@ -23,7 +23,6 @@
 #include "../comedidev.h"
 
 #include "comedi_isadma.h"
-#include "comedi_fc.h"
 #include "ni_labpc.h"
 #include "ni_labpc_regs.h"
 #include "ni_labpc_isadma.h"
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..c66affd993aa987b0748bad42c708051804840ce 100644 (file)
@@ -57,7 +57,6 @@
 #include <linux/delay.h>
 #include "8255.h"
 #include "mite.h"
-#include "comedi_fc.h"
 
 /* A timeout count */
 #define NI_TIMEOUT 1000
@@ -670,8 +669,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 +754,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 +775,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 +801,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 +827,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 +1067,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 +1359,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 +1656,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 +1699,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 +1870,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 +1894,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 +2020,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 +2116,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 +2139,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 +2154,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) {
@@ -2227,28 +2224,28 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src,
+       err |= comedi_check_trigger_src(&cmd->start_src,
                                        TRIG_NOW | TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
 
        sources = TRIG_TIMER | TRIG_EXT;
        if (devpriv->is_611x || devpriv->is_6143)
                sources |= TRIG_NOW;
-       err |= cfc_check_trigger_src(&cmd->convert_src, sources);
+       err |= comedi_check_trigger_src(&cmd->convert_src, sources);
 
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -2260,7 +2257,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
        switch (cmd->start_src) {
        case TRIG_NOW:
        case TRIG_INT:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                tmp = CR_CHAN(cmd->start_arg);
@@ -2268,15 +2265,16 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                if (tmp > 16)
                        tmp = 16;
                tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE));
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, tmp);
                break;
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
                        ni_min_ai_scan_period_ns(dev, cmd->chanlist_len));
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                devpriv->clock_ns * 0xffffff);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   devpriv->clock_ns *
+                                                   0xffffff);
        } else if (cmd->scan_begin_src == TRIG_EXT) {
                /* external trigger */
                unsigned int tmp = CR_CHAN(cmd->scan_begin_arg);
@@ -2284,19 +2282,21 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                if (tmp > 16)
                        tmp = 16;
                tmp |= (cmd->scan_begin_arg & (CR_INVERT | CR_EDGE));
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
        } else {                /* TRIG_OTHER */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                if (devpriv->is_611x || devpriv->is_6143) {
-                       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+                       err |= comedi_check_trigger_arg_is(&cmd->convert_arg,
+                                                          0);
                } else {
-                       err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                        board->ai_speed);
-                       err |= cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                               devpriv->clock_ns * 0xffff);
+                       err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                           board->ai_speed);
+                       err |= comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                           devpriv->clock_ns *
+                                                           0xffff);
                }
        } else if (cmd->convert_src == TRIG_EXT) {
                /* external trigger */
@@ -2305,23 +2305,24 @@ static int ni_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                if (tmp > 16)
                        tmp = 16;
                tmp |= (cmd->convert_arg & (CR_ALT_FILTER | CR_INVERT));
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, tmp);
        } else if (cmd->convert_src == TRIG_NOW) {
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT) {
                unsigned int max_count = 0x01000000;
 
                if (devpriv->is_611x)
                        max_count -= num_adc_stages_611x;
-               err |= cfc_check_trigger_arg_max(&cmd->stop_arg, max_count);
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_max(&cmd->stop_arg, max_count);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        } else {
                /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
        }
 
        if (err)
@@ -2529,7 +2530,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 +2573,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 +2808,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 +2820,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)
@@ -3262,21 +3260,21 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -3287,7 +3285,7 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        switch (cmd->start_src) {
        case TRIG_INT:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                tmp = CR_CHAN(cmd->start_arg);
@@ -3295,24 +3293,26 @@ static int ni_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
                if (tmp > 18)
                        tmp = 18;
                tmp |= (cmd->start_arg & (CR_INVERT | CR_EDGE));
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, tmp);
                break;
        }
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                board->ao_speed);
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                devpriv->clock_ns * 0xffffff);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   board->ao_speed);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   devpriv->clock_ns *
+                                                   0xffffff);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
+               err |= comedi_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -3474,11 +3474,11 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -3488,16 +3488,17 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        tmp = cmd->scan_begin_arg;
        tmp &= CR_PACK_FLAGS(CDO_Sample_Source_Select_Mask, 0, 0, CR_INVERT);
        if (tmp != cmd->scan_begin_arg)
                err |= -EINVAL;
 
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -3694,8 +3695,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 +3705,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 +3817,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 +3831,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 +3843,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 +4516,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 +4668,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 +4903,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 +4961,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 +5052,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..ac79099bc23e4d94a09ad99cca01c352a8aacbc9 100644 (file)
@@ -53,9 +53,8 @@ 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"
 
 /* defines for the PCI-DIO-32HS */
@@ -304,7 +303,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 +353,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;
@@ -547,21 +547,21 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -570,13 +570,13 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
 #define MAX_SPEED      (TIMER_BASE)    /* in nanoseconds */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                MAX_SPEED);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   MAX_SPEED);
                /* no minimum speed */
        } else {
                /* TRIG_EXT */
@@ -587,13 +587,14 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
                }
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -603,7 +604,7 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                ni_pcidio_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -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..9b124b09e9140aee5cad69aa9ab75a542acd0436 100644 (file)
@@ -44,7 +44,6 @@ TODO:
 */
 
 #include <linux/module.h>
-#include "comedi_fc.h"
 #include "ni_tio_internal.h"
 #include "mite.h"
 
@@ -201,7 +200,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,
@@ -234,23 +233,23 @@ int ni_tio_cmdtest(struct comedi_device *dev,
        sources = TRIG_NOW | TRIG_INT | TRIG_OTHER;
        if (ni_tio_counting_mode_registers_present(counter->counter_dev))
                sources |= TRIG_EXT;
-       err |= cfc_check_trigger_src(&cmd->start_src, sources);
+       err |= comedi_check_trigger_src(&cmd->start_src, sources);
 
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_EXT | TRIG_OTHER);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
                                        TRIG_NOW | TRIG_EXT | TRIG_OTHER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -266,7 +265,7 @@ int ni_tio_cmdtest(struct comedi_device *dev,
        case TRIG_NOW:
        case TRIG_INT:
        case TRIG_OTHER:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
                /* start_arg is the start_trigger passed to ni_tio_arm() */
@@ -274,13 +273,14 @@ int ni_tio_cmdtest(struct comedi_device *dev,
        }
 
        if (cmd->scan_begin_src != TRIG_EXT)
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->convert_src != TRIG_EXT)
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -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..cfc3a627d0ca3673c35cfd975283e692ceffc41e 100644 (file)
@@ -41,8 +41,7 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * I/O port register map
@@ -153,11 +152,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,26 +281,24 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -315,23 +307,24 @@ static int pcl711_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_EXT) {
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
        } else {
 #define MAX_SPEED 1000
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                MAX_SPEED);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   MAX_SPEED);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -339,12 +332,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               unsigned int arg = cmd->scan_begin_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (err)
@@ -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 40798150cfd8d20d6668742d85ba12860ab0d6bb..256850ccb6fa21d09389ed3ae341171716fb633c 100644 (file)
@@ -62,8 +62,6 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-
 #define PCL726_AO_MSB_REG(x)   (0x00 + ((x) * 2))
 #define PCL726_AO_LSB_REG(x)   (0x01 + ((x) * 2))
 #define PCL726_DO_MSB_REG      0x0c
@@ -173,11 +171,11 @@ static int pcl726_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE);
 
        if (err)
                return 1;
@@ -187,11 +185,12 @@ static int pcl726_intr_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
-       err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
index 3ffb1ea2ecc87ba462d4a472c3bde08ed95d442f..03a3fd6cd918b4e59d42da3b9fe9052172d3686d 100644 (file)
 #include "../comedidev.h"
 
 #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 +512,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 +519,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,28 +632,27 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
 
        if (devpriv->use_ext_trg)
                flags = TRIG_EXT;
        else
                flags = TRIG_TIMER;
-       err |= cfc_check_trigger_src(&cmd->convert_src, flags);
+       err |= comedi_check_trigger_src(&cmd->convert_src, flags);
 
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -680,22 +661,24 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                board->ai_ns_min);
-       else    /* TRIG_EXT */
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   board->ai_ns_min);
+       } else {        /* TRIG_EXT */
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       }
 
-       err |= cfc_check_trigger_arg_min(&cmd->chanlist_len, 1);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_min(&cmd->chanlist_len, 1);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -703,12 +686,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -725,8 +706,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 +739,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 +898,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 +990,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 +1138,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..1ccb2f19f4be6876d00824ad6fdb57811aa9a902 100644 (file)
@@ -41,8 +41,7 @@ Configuration Options:
 #include "../comedidev.h"
 
 #include "comedi_isadma.h"
-#include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /*
  * Register I/O map
@@ -116,31 +115,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,67 +345,62 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_EXT | TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_EXT | TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
        if (err)
                return 2;
 
-
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 10000);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
        else    /* TRIG_EXT */
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
                return 4;
 
-
        /* step 5: complain about special chanlist considerations */
 
        if (cmd->chanlist) {
@@ -450,8 +423,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 +437,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 +500,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 +567,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 +626,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..e1bdde9773023466ab6624fefa190baf302e1b1f 100644 (file)
 #include "../comedidev.h"
 
 #include "comedi_isadma.h"
-#include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 
 /* boards constants */
 
@@ -299,33 +298,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,25 +644,24 @@ 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 */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -690,21 +670,23 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                board->ns_min);
-       else    /* TRIG_EXT */
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   board->ns_min);
+       } else {        /* TRIG_EXT */
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -712,12 +694,10 @@ 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);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               unsigned int arg = cmd->convert_arg;
+
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
@@ -746,8 +726,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 +757,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 +792,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 +886,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 +903,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 +992,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 +1020,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 +1113,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 2c0e7ecbf494c1b2cc6bc56f414e2cc85dbb8a04..10472e6dd002e1c03e4b3919de551829c4233480 100644 (file)
@@ -78,8 +78,6 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-
 /*
  * Register I/O map
  */
@@ -483,19 +481,19 @@ static int pcmmio_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -504,15 +502,16 @@ static int pcmmio_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
index a1641d98181245eee97662f7f20d1054ac3df567..7ea813022ff6f86513f85fc7e8ca54bc5fe77c65 100644 (file)
@@ -77,8 +77,6 @@
 
 #include "../comedidev.h"
 
-#include "comedi_fc.h"
-
 /*
  * Register I/O map
  *
@@ -486,19 +484,19 @@ static int pcmuio_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -507,15 +505,16 @@ static int pcmuio_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->convert_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -568,7 +567,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 +587,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..152cb146fc161fa62cfdd9b194bf9d0cc7edb08a 100644 (file)
@@ -52,7 +52,6 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
 #include <linux/completion.h>
 
 #include "../comedi_pcmcia.h"
-#include "comedi_fc.h"
 
 struct daqp_private {
        int stop;
@@ -315,7 +314,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);
@@ -366,22 +364,22 @@ static int daqp_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
+       err |= comedi_check_trigger_src(&cmd->convert_src,
                                        TRIG_TIMER | TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -390,13 +388,14 @@ static int daqp_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
 #define MAX_SPEED      10000   /* 100 kHz - in nanoseconds */
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                MAX_SPEED);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   MAX_SPEED);
+       }
 
        /* If both scan_begin and convert are both timer values, the only
         * way that can make sense is if the scan time is the number of
@@ -408,15 +407,18 @@ static int daqp_ai_cmdtest(struct comedi_device *dev,
                err |= -EINVAL;
        }
 
-       if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, MAX_SPEED);
+       if (cmd->convert_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   MAX_SPEED);
+       }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
+               err |= comedi_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -426,13 +428,13 @@ static int daqp_ai_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                daqp_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
                daqp_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
 
        if (err)
index c94ad12ed446bea7250ccb4c0772076681406f4a..4c13f5eb0c842ec692dbfc580e6820fbeded8ca4 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 +577,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 +614,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))
@@ -734,21 +732,22 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -757,32 +756,32 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                /* Note: these are time periods, not actual rates */
                if (1 == cmd->chanlist_len) {   /* no scanning */
-                       if (cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                     RTD_MAX_SPEED_1)) {
+                       if (comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                        RTD_MAX_SPEED_1)) {
                                rtd_ns_to_timer(&cmd->scan_begin_arg,
                                                CMDF_ROUND_UP);
                                err |= -EINVAL;
                        }
-                       if (cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                     RTD_MIN_SPEED_1)) {
+                       if (comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                        RTD_MIN_SPEED_1)) {
                                rtd_ns_to_timer(&cmd->scan_begin_arg,
                                                CMDF_ROUND_DOWN);
                                err |= -EINVAL;
                        }
                } else {
-                       if (cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                     RTD_MAX_SPEED)) {
+                       if (comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                        RTD_MAX_SPEED)) {
                                rtd_ns_to_timer(&cmd->scan_begin_arg,
                                                CMDF_ROUND_UP);
                                err |= -EINVAL;
                        }
-                       if (cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                     RTD_MIN_SPEED)) {
+                       if (comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                        RTD_MIN_SPEED)) {
                                rtd_ns_to_timer(&cmd->scan_begin_arg,
                                                CMDF_ROUND_DOWN);
                                err |= -EINVAL;
@@ -792,32 +791,32 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
                /* external trigger */
                /* should be level/edge, hi/lo specification here */
                /* should specify multiple external triggers */
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                if (1 == cmd->chanlist_len) {   /* no scanning */
-                       if (cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                     RTD_MAX_SPEED_1)) {
+                       if (comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                        RTD_MAX_SPEED_1)) {
                                rtd_ns_to_timer(&cmd->convert_arg,
                                                CMDF_ROUND_UP);
                                err |= -EINVAL;
                        }
-                       if (cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                                     RTD_MIN_SPEED_1)) {
+                       if (comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                        RTD_MIN_SPEED_1)) {
                                rtd_ns_to_timer(&cmd->convert_arg,
                                                CMDF_ROUND_DOWN);
                                err |= -EINVAL;
                        }
                } else {
-                       if (cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                     RTD_MAX_SPEED)) {
+                       if (comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                        RTD_MAX_SPEED)) {
                                rtd_ns_to_timer(&cmd->convert_arg,
                                                CMDF_ROUND_UP);
                                err |= -EINVAL;
                        }
-                       if (cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                                     RTD_MIN_SPEED)) {
+                       if (comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                        RTD_MIN_SPEED)) {
                                rtd_ns_to_timer(&cmd->convert_arg,
                                                CMDF_ROUND_DOWN);
                                err |= -EINVAL;
@@ -826,37 +825,38 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
        } else {
                /* external trigger */
                /* see above */
-               err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 9);
+               err |= comedi_check_trigger_arg_max(&cmd->convert_arg, 9);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
 
-
        /* step 4: fix up any arguments */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                rtd_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
                rtd_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        arg = cmd->convert_arg * cmd->scan_end_arg;
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        arg);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           arg);
                }
        }
 
@@ -1181,8 +1181,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 +1299,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..781918d8d85f5452ad9d61fb28b2c95a9b4da13d 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"
 
 struct s626_buffer_dma {
@@ -231,9 +229,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 +292,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 +515,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 +581,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 +639,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 +1574,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 +1663,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 +2032,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;
@@ -2120,24 +2114,24 @@ static int s626_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src,
-                                    TRIG_NOW | TRIG_INT | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
-                                    TRIG_TIMER | TRIG_EXT | TRIG_FOLLOW);
-       err |= cfc_check_trigger_src(&cmd->convert_src,
-                                    TRIG_TIMER | TRIG_EXT | TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src,
+                                       TRIG_NOW | TRIG_INT | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
+                                       TRIG_TIMER | TRIG_EXT | TRIG_FOLLOW);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT | TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -2149,49 +2143,53 @@ static int s626_ai_cmdtest(struct comedi_device *dev,
        switch (cmd->start_src) {
        case TRIG_NOW:
        case TRIG_INT:
-               err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
                break;
        case TRIG_EXT:
-               err |= cfc_check_trigger_arg_max(&cmd->start_arg, 39);
+               err |= comedi_check_trigger_arg_max(&cmd->start_arg, 39);
                break;
        }
 
        if (cmd->scan_begin_src == TRIG_EXT)
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 39);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 39);
        if (cmd->convert_src == TRIG_EXT)
-               err |= cfc_check_trigger_arg_max(&cmd->convert_arg, 39);
+               err |= comedi_check_trigger_arg_max(&cmd->convert_arg, 39);
 
 #define S626_MAX_SPEED 200000  /* in nanoseconds */
 #define S626_MIN_SPEED 2000000000      /* in nanoseconds */
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                S626_MAX_SPEED);
-               err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg,
-                                                S626_MIN_SPEED);
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   S626_MAX_SPEED);
+               err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg,
+                                                   S626_MIN_SPEED);
        } else {
-               /* external trigger */
-               /* should be level/edge, hi/lo specification here */
-               /* should specify multiple external triggers */
-               /* err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9); */
+               /*
+                * external trigger
+                * should be level/edge, hi/lo specification here
+                * should specify multiple external triggers
+                * err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
+                */
        }
        if (cmd->convert_src == TRIG_TIMER) {
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
-                                                S626_MAX_SPEED);
-               err |= cfc_check_trigger_arg_max(&cmd->convert_arg,
-                                                S626_MIN_SPEED);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
+                                                   S626_MAX_SPEED);
+               err |= comedi_check_trigger_arg_max(&cmd->convert_arg,
+                                                   S626_MIN_SPEED);
        } else {
-               /* external trigger */
-               /* see above */
-               /* err |= cfc_check_trigger_arg_max(&cmd->scan_begin_arg, 9); */
+               /*
+                * external trigger - see above
+                * err |= comedi_check_trigger_arg_max(&cmd->scan_begin_arg, 9);
+                */
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -2201,18 +2199,19 @@ static int s626_ai_cmdtest(struct comedi_device *dev,
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
                s626_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
 
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
                s626_ns_to_timer(&arg, cmd->flags);
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
 
                if (cmd->scan_begin_src == TRIG_TIMER) {
                        arg = cmd->convert_arg * cmd->scan_end_arg;
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        arg);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           arg);
                }
        }
 
@@ -2733,7 +2732,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..ced05e581620997646d021005f7cf8629f2131c9 100644 (file)
@@ -85,8 +85,6 @@
 
 #include "../comedi_usb.h"
 
-#include "comedi_fc.h"
-
 /* constants for firmware upload and download */
 #define USBDUX_FIRMWARE                "usbdux_firmware.bin"
 #define USBDUX_FIRMWARE_MAX_LEN        0x2000
@@ -524,19 +522,19 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -545,10 +543,10 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                if (this_usbduxsub->high_speed) {
@@ -563,8 +561,9 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev,
                        while (i < (cmd->chanlist_len))
                                i = i * 2;
 
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        1000000 / 8 * i);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           1000000 / 8 * i);
                        /* now calc the real sampling rate with all the
                         * rounding errors */
                        tmp_timer =
@@ -573,24 +572,26 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev,
                } else {
                        /* full speed */
                        /* 1kHz scans every USB frame */
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        1000000);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           1000000);
                        /*
                         * calc the real sampling rate with the rounding errors
                         */
                        tmp_timer = ((unsigned int)(cmd->scan_begin_arg /
                                                   1000000)) * 1000000;
                }
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg,
-                                               tmp_timer);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg,
+                                                  tmp_timer);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -633,8 +634,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)
@@ -895,7 +896,7 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
 
        if (0) {                /* (this_usbduxsub->high_speed) */
                /* the sampling rate is set by the coversion rate */
@@ -904,7 +905,7 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev,
                /* start a new scan (output at once) with a timer */
                flags = TRIG_TIMER;
        }
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, flags);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, flags);
 
        if (0) {                /* (this_usbduxsub->high_speed) */
                /*
@@ -919,18 +920,18 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev,
                 */
                flags = TRIG_NOW;
        }
-       err |= cfc_check_trigger_src(&cmd->convert_src, flags);
+       err |= comedi_check_trigger_src(&cmd->convert_src, flags);
 
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -939,25 +940,27 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                1000000);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   1000000);
+       }
 
        /* not used now, is for later use */
        if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 125000);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 125000);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -1041,7 +1044,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..d90dc59982be6e146d412ac07fa369fcc42f9de1 100644 (file)
@@ -48,7 +48,6 @@
 #include <linux/input.h>
 #include <linux/fcntl.h>
 #include <linux/compiler.h>
-#include "comedi_fc.h"
 #include "../comedi_usb.h"
 
 /*
@@ -343,23 +342,24 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src,
+       err |= comedi_check_trigger_src(&cmd->start_src,
                                        TRIG_NOW | TRIG_EXT | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src,
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src,
                                        TRIG_FOLLOW | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_TIMER | TRIG_EXT);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src,
+                                       TRIG_TIMER | TRIG_EXT);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
-       err |= cfc_check_trigger_is_unique(cmd->convert_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
+       err |= comedi_check_trigger_is_unique(cmd->convert_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -372,12 +372,13 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (!cmd->chanlist_len)
                err |= -EINVAL;
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->chanlist_len == 1)
                min_sample_period = 1;
@@ -394,16 +395,16 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
                /* calc arg again */
                tmp = steps / 30;
-               err |= cfc_check_trigger_arg_is(&cmd->convert_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->convert_arg, tmp);
        }
 
        /* stop source */
        switch (cmd->stop_src) {
        case TRIG_COUNT:
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
                break;
        case TRIG_NONE:
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
                break;
                /*
                 * TRIG_EXT doesn't care since it doesn't trigger
@@ -419,7 +420,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..eaa9add491df7cbade63ee3786f36540aac71606 100644 (file)
@@ -49,7 +49,6 @@
 #include <linux/compiler.h>
 #include <asm/unaligned.h>
 
-#include "comedi_fc.h"
 #include "../comedi_usb.h"
 
 /* timeout for the USB-transfer in ms*/
@@ -243,9 +242,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 +290,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 +384,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 +420,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;
        }
@@ -488,19 +485,19 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_TIMER);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err)
                return 1;
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -509,10 +506,10 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_TIMER) {
                unsigned int tmp;
@@ -524,27 +521,31 @@ static int usbduxsigma_ai_cmdtest(struct comedi_device *dev,
                         * sample two channels. Thus, the more channels
                         * are in the channel list the more time we need.
                         */
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                               (1000000 / 8 * interval));
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           (1000000 / 8 *
+                                                            interval));
 
                        tmp = (cmd->scan_begin_arg / 125000) * 125000;
                } else {
                        /* full speed */
                        /* 1kHz scans every USB frame */
-                       err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                        1000000);
+                       err |= comedi_check_trigger_arg_min(&cmd->
+                                                           scan_begin_arg,
+                                                           1000000);
 
                        tmp = (cmd->scan_begin_arg / 1000000) * 1000000;
                }
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, tmp);
        }
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -856,7 +857,7 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 1 : check if triggers are trivially valid */
 
-       err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
+       err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT);
 
        if (high_speed) {
                /*
@@ -868,11 +869,11 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
                /* start a new scan (output at once) with a timer */
                flags = TRIG_TIMER;
        }
-       err |= cfc_check_trigger_src(&cmd->scan_begin_src, flags);
+       err |= comedi_check_trigger_src(&cmd->scan_begin_src, flags);
 
-       err |= cfc_check_trigger_src(&cmd->convert_src, TRIG_NOW);
-       err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
-       err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
+       err |= comedi_check_trigger_src(&cmd->convert_src, TRIG_NOW);
+       err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
+       err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 
        if (err) {
                up(&devpriv->sem);
@@ -881,8 +882,8 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 2a : make sure trigger sources are unique */
 
-       err |= cfc_check_trigger_is_unique(cmd->start_src);
-       err |= cfc_check_trigger_is_unique(cmd->stop_src);
+       err |= comedi_check_trigger_is_unique(cmd->start_src);
+       err |= comedi_check_trigger_is_unique(cmd->stop_src);
 
        /* Step 2b : and mutually compatible */
 
@@ -891,25 +892,27 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
 
        /* Step 3: check if arguments are trivially valid */
 
-       err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
+       err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
 
        if (cmd->scan_begin_src == TRIG_FOLLOW) /* internal trigger */
-               err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
 
-       if (cmd->scan_begin_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
-                                                1000000);
+       if (cmd->scan_begin_src == TRIG_TIMER) {
+               err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
+                                                   1000000);
+       }
 
        /* not used now, is for later use */
        if (cmd->convert_src == TRIG_TIMER)
-               err |= cfc_check_trigger_arg_min(&cmd->convert_arg, 125000);
+               err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 125000);
 
-       err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
+       err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
+                                          cmd->chanlist_len);
 
        if (cmd->stop_src == TRIG_COUNT)
-               err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
+               err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
        else    /* TRIG_NONE */
-               err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
+               err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
 
        if (err)
                return 3;
@@ -1071,9 +1074,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 +1089,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..e3564d278d917d71613bce0d85fd999768c42590 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)
 {
@@ -406,7 +375,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
         * verified in the interrupt routine.
         */
 
-       if (port > brd->nasync)
+       if (port >= brd->nasync)
                return;
 
        ch = brd->channels[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..2597e36d38c47798999bd8c4bbaa0e1b53a0f3b5 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
 #define __DGNC_CLS_H
 
-#include "dgnc_types.h"
-
-
 /************************************************************************
  * Per channel/port Classic UART structure                             *
  ************************************************************************
  *                     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) */
@@ -51,18 +51,15 @@ struct cls_uart_struct {
 
 #define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF
 
-#define UART_16654_FCR_TXTRIGGER_8     0x0
 #define UART_16654_FCR_TXTRIGGER_16    0x10
-#define UART_16654_FCR_TXTRIGGER_32    0x20
-#define UART_16654_FCR_TXTRIGGER_56    0x30
-
-#define UART_16654_FCR_RXTRIGGER_8     0x0
 #define UART_16654_FCR_RXTRIGGER_16    0x40
 #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
@@ -73,10 +70,6 @@ struct cls_uart_struct {
 #define UART_EXAR654_EFR_IXOFF    0x8     /* Transmit Xon1/Xoff1 */
 #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 */
-
 #define UART_EXAR654_IER_XOFF     0x20    /* Xoff Interrupt Enable */
 #define UART_EXAR654_IER_RTSDTR   0x40    /* Output Interrupt Enable */
 #define UART_EXAR654_IER_CTSDSR   0x80    /* Input Interrupt Enable */
index f177d3a258c2cf8bce2c2f18182b19167e6155f7..805dc617e3a787b86a38142d2760fa8cdc2e4ed5 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.
- *
  */
 
 
@@ -37,7 +21,6 @@
 #include <linux/sched.h>
 #include "dgnc_driver.h"
 #include "dgnc_pci.h"
-#include "dpacompat.h"
 #include "dgnc_mgmt.h"
 #include "dgnc_tty.h"
 #include "dgnc_cls.h"
@@ -60,7 +43,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 +76,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 +123,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 +190,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 +227,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 +261,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 +338,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 +384,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 +527,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 +548,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 +570,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 +594,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 +677,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 +698,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..f77fed57b873623745bb5818536b31f257aa22a8 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
@@ -31,9 +25,7 @@
 #include <linux/tty.h>   /* To pick up the various tty structs/defines */
 #include <linux/interrupt.h>   /* For irqreturn_t type */
 
-#include "dgnc_types.h"                /* Additional types needed by the Digi header files */
 #include "digi.h"              /* Digi specific ioctl header */
-#include "dgnc_kcompat.h"      /* Kernel 2.4/2.6 compat includes */
 #include "dgnc_sysfs.h"                /* Support for SYSFS */
 
 /*************************************************************************
@@ -46,6 +38,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
 
@@ -211,8 +204,8 @@ struct dgnc_board {
        struct tty_driver       PrintDriver;
        char            PrintName[200];
 
-       uint            dgnc_Major_Serial_Registered;
-       uint            dgnc_Major_TransparentPrint_Registered;
+       bool            dgnc_Major_Serial_Registered;
+       bool            dgnc_Major_TransparentPrint_Registered;
 
        uint            dgnc_Serial_Major;
        uint            dgnc_TransparentPrint_Major;
@@ -398,11 +391,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
diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h
deleted file mode 100644 (file)
index 566cad0..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2004 Digi International (www.digi.com)
- *      Scott H Kilau <Scott_Kilau at digi dot com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * 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!!!
- *
- *************************************************************************
- *
- * This file is intended to contain all the kernel "differences" between the
- * various kernels that we support.
- *
- *************************************************************************/
-
-#ifndef __DGNC_KCOMPAT_H
-#define __DGNC_KCOMPAT_H
-
-#if !defined(TTY_FLIPBUF_SIZE)
-# define TTY_FLIPBUF_SIZE 512
-#endif
-
-
-/* Sparse stuff */
-# ifndef __user
-#  define __user
-#  define __kernel
-#  define __safe
-#  define __force
-#  define __chk_user_ptr(x) (void)0
-# endif
-
-
-#endif /* ! __DGNC_KCOMPAT_H */
index 5544a8e7f4bc405195130417f31927f72cf42a59..b13318a82fe1970fa64fb8d1856fc65db39539ec 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.
- *
  */
 
 /************************************************************************
@@ -46,9 +30,7 @@
 
 #include "dgnc_driver.h"
 #include "dgnc_pci.h"
-#include "dgnc_kcompat.h"      /* Kernel 2.4/2.6 compat includes */
 #include "dgnc_mgmt.h"
-#include "dpacompat.h"
 
 
 /* Our "in use" variables, to enforce 1 open only */
@@ -153,8 +135,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));
@@ -196,11 +177,11 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                channel = ni.channel;
 
                /* Verify boundaries on board */
-               if ((board > dgnc_NumBoards) || (dgnc_NumBoards == 0))
+               if (board >= dgnc_NumBoards)
                        return -ENODEV;
 
                /* Verify boundaries on channel */
-               if ((channel < 0) || (channel > dgnc_Board[board]->nasync))
+               if (channel >= dgnc_Board[board]->nasync)
                        return -ENODEV;
 
                ch = dgnc_Board[board]->channels[channel];
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..f5a4d365115fdcb85b6d5dc3c4d70a2067845c58 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);
 
@@ -407,7 +391,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
        if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return;
 
-       if (port > brd->maxports)
+       if (port >= brd->maxports)
                return;
 
        ch = brd->channels[port];
@@ -537,7 +521,7 @@ static inline void neo_parse_lsr(struct dgnc_board *brd, uint port)
        if (!brd || brd->magic != DGNC_BOARD_MAGIC)
                return;
 
-       if (port > brd->maxports)
+       if (port >= brd->maxports)
                return;
 
        ch = brd->channels[port];
@@ -1019,7 +1003,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
                         */
 
                        /* Verify the port is in range. */
-                       if (port > brd->nasync)
+                       if (port >= brd->nasync)
                                continue;
 
                        ch = brd->channels[port];
@@ -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..c528df5a0e5af10a315da11b643d565bf87615e7 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
 #define __DGNC_NEO_H
 
-#include "dgnc_types.h"
 #include "dgnc_driver.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..65551d19051529fc669f1aab29cb1f68bf31e601 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.
- *
  */
 
 
@@ -91,7 +75,7 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver)
        rc |= driver_create_file(driverfs, &driver_attr_maxboards);
        rc |= driver_create_file(driverfs, &driver_attr_pollrate);
        if (rc)
-               printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n");
+               pr_err("DGNC: sysfs driver_create_file failed!\n");
 }
 
 
@@ -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..be0f90a6768b0b822f94a8cb548c42e0041d5bd9 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
 #define __DGNC_SYSFS_H
 
-#include "dgnc_driver.h"
-
 #include <linux/device.h>
+#include "dgnc_driver.h"
 
 struct dgnc_board;
 struct channel_t;
@@ -44,6 +37,4 @@ extern int dgnc_tty_class_destroy(void);
 extern void dgnc_create_tty_sysfs(struct un_t *un, struct device *c);
 extern void dgnc_remove_tty_sysfs(struct device *c);
 
-
-
 #endif
index f81a375f8bc17e87cf23d6ffe793bb782edb019c..ce4187f60cb457f70ca9f141e5a9f240e758b7e3 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.
  */
 
 /************************************************************************
@@ -44,6 +29,7 @@
 #include <linux/ctype.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
+#include <linux/types.h>
 #include <linux/serial_reg.h>
 #include <linux/slab.h>
 #include <linux/delay.h>       /* For udelay */
 #include <linux/pci.h>
 #include "dgnc_driver.h"
 #include "dgnc_tty.h"
-#include "dgnc_types.h"
 #include "dgnc_neo.h"
 #include "dgnc_cls.h"
-#include "dpacompat.h"
 #include "dgnc_sysfs.h"
 #include "dgnc_utils.h"
 
@@ -236,7 +220,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
                                "Can't register tty device (%d)\n", rc);
                        return rc;
                }
-               brd->dgnc_Major_Serial_Registered = TRUE;
+               brd->dgnc_Major_Serial_Registered = true;
        }
 
        /*
@@ -286,7 +270,7 @@ int dgnc_tty_register(struct dgnc_board *brd)
                                rc);
                        return rc;
                }
-               brd->dgnc_Major_TransparentPrint_Registered = TRUE;
+               brd->dgnc_Major_TransparentPrint_Registered = true;
        }
 
        dgnc_BoardsByMajor[brd->SerialDriver.major] = brd;
@@ -424,7 +408,7 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
                        tty_unregister_device(&brd->SerialDriver, i);
                }
                tty_unregister_driver(&brd->SerialDriver);
-               brd->dgnc_Major_Serial_Registered = FALSE;
+               brd->dgnc_Major_Serial_Registered = false;
        }
 
        if (brd->dgnc_Major_TransparentPrint_Registered) {
@@ -435,7 +419,7 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
                        tty_unregister_device(&brd->PrintDriver, i);
                }
                tty_unregister_driver(&brd->PrintDriver);
-               brd->dgnc_Major_TransparentPrint_Registered = FALSE;
+               brd->dgnc_Major_TransparentPrint_Registered = false;
        }
 
        kfree(brd->SerialDriver.ttys);
@@ -507,7 +491,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 +523,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 +538,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 +583,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 +650,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 +867,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... */
-               }
        }
 
        /*
@@ -1064,7 +1041,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file)
        spin_lock_irqsave(&brd->bd_lock, flags);
 
        /* If opened device is greater than our number of ports, bail. */
-       if (PORT_NUM(minor) > brd->nasync) {
+       if (PORT_NUM(minor) >= brd->nasync) {
                spin_unlock_irqrestore(&brd->bd_lock, flags);
                return -ENXIO;
        }
@@ -1777,10 +1754,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 +1782,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 +1869,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
diff --git a/drivers/staging/dgnc/dgnc_types.h b/drivers/staging/dgnc/dgnc_types.h
deleted file mode 100644 (file)
index 3aafced..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2003 Digi International (www.digi.com)
- *     Scott H Kilau <Scott_Kilau at digi dot com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * 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
-#define __DGNC_TYPES_H
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#endif
index 80b51332292cfe6bebf5198d21a6cf14c9b051d1..f76de82908d3d536af9550f8dae19517a7ce70cb 100644 (file)
@@ -16,55 +16,3 @@ int dgnc_ms_sleep(ulong ms)
        schedule_timeout((ms * HZ) / 1000);
        return signal_pending(current);
 }
-
-/*
- *      dgnc_ioctl_name() : Returns a text version of each ioctl value.
- */
-char *dgnc_ioctl_name(int cmd)
-{
-       switch (cmd) {
-
-       case TCGETA:            return "TCGETA";
-       case TCGETS:            return "TCGETS";
-       case TCSETA:            return "TCSETA";
-       case TCSETS:            return "TCSETS";
-       case TCSETAW:           return "TCSETAW";
-       case TCSETSW:           return "TCSETSW";
-       case TCSETAF:           return "TCSETAF";
-       case TCSETSF:           return "TCSETSF";
-       case TCSBRK:            return "TCSBRK";
-       case TCXONC:            return "TCXONC";
-       case TCFLSH:            return "TCFLSH";
-       case TIOCGSID:          return "TIOCGSID";
-
-       case TIOCGETD:          return "TIOCGETD";
-       case TIOCSETD:          return "TIOCSETD";
-       case TIOCGWINSZ:        return "TIOCGWINSZ";
-       case TIOCSWINSZ:        return "TIOCSWINSZ";
-
-       case TIOCMGET:          return "TIOCMGET";
-       case TIOCMSET:          return "TIOCMSET";
-       case TIOCMBIS:          return "TIOCMBIS";
-       case TIOCMBIC:          return "TIOCMBIC";
-
-       /* from digi.h */
-       case DIGI_SETA:         return "DIGI_SETA";
-       case DIGI_SETAW:        return "DIGI_SETAW";
-       case DIGI_SETAF:        return "DIGI_SETAF";
-       case DIGI_SETFLOW:      return "DIGI_SETFLOW";
-       case DIGI_SETAFLOW:     return "DIGI_SETAFLOW";
-       case DIGI_GETFLOW:      return "DIGI_GETFLOW";
-       case DIGI_GETAFLOW:     return "DIGI_GETAFLOW";
-       case DIGI_GETA:         return "DIGI_GETA";
-       case DIGI_GEDELAY:      return "DIGI_GEDELAY";
-       case DIGI_SEDELAY:      return "DIGI_SEDELAY";
-       case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD";
-       case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD";
-       case TIOCMODG:          return "TIOCMODG";
-       case TIOCMODS:          return "TIOCMODS";
-       case TIOCSDTR:          return "TIOCSDTR";
-       case TIOCCDTR:          return "TIOCCDTR";
-
-       default:                return "unknown";
-       }
-}
index cebf60163a2674b6ab601847a1e816bac209d683..1164c3a09c6bed0b1e6d34225f5e26410e1a2917 100644 (file)
@@ -2,6 +2,5 @@
 #define __DGNC_UTILS_H
 
 int dgnc_ms_sleep(ulong ms);
-char *dgnc_ioctl_name(int cmd);
 
 #endif
index d6e0b9f6b24a3896811556d91f110f011654c8a5..d637a7802168e163187911c277c2778bc7464521 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
 #define __DIGI_H
 
-/************************************************************************
- ***   Definitions for Digi ditty(1) command.
- ************************************************************************/
-
-
-/*
- * Copyright (c) 1988-96 Digi International Inc., All Rights Reserved.
- */
-
-/************************************************************************
- * This module provides application access to special Digi
- * serial line enhancements which are not standard UNIX(tm) features.
- ************************************************************************/
-
-#if !defined(TIOCMODG)
-
-#define        TIOCMODG        (('d'<<8) | 250)        /* get modem ctrl state */
-#define        TIOCMODS        (('d'<<8) | 251)        /* set modem ctrl state */
-
 #ifndef TIOCM_LE
 #define                TIOCM_LE        0x01            /* line enable          */
 #define                TIOCM_DTR       0x02            /* data terminal ready  */
@@ -55,8 +30,6 @@
 #define                TIOCM_CD        TIOCM_CAR       /* carrier detect (alt) */
 #endif
 
-#endif
-
 #if !defined(TIOCMSET)
 #define        TIOCMSET        (('d'<<8) | 252)        /* set modem ctrl state */
 #define        TIOCMGET        (('d'<<8) | 253)        /* set modem ctrl state */
 #define        TIOCMBIS        (('d'<<8) | 255)        /* set modem ctrl state */
 #endif
 
-
-#if !defined(TIOCSDTR)
-#define        TIOCSDTR        (('e'<<8) | 0)          /* set DTR              */
-#define        TIOCCDTR        (('e'<<8) | 1)          /* clear DTR            */
-#endif
-
-/************************************************************************
- * Ioctl command arguments for DIGI parameters.
- ************************************************************************/
 #define DIGI_GETA      (('e'<<8) | 94)         /* Read params          */
-
 #define DIGI_SETA      (('e'<<8) | 95)         /* Set params           */
 #define DIGI_SETAW     (('e'<<8) | 96)         /* Drain & set params   */
 #define DIGI_SETAF     (('e'<<8) | 97)         /* Drain, flush & set params */
-
-#define DIGI_KME       (('e'<<8) | 98)         /* Read/Write Host      */
-                                               /* Adapter Memory       */
-
-#define        DIGI_GETFLOW    (('e'<<8) | 99)         /* Get startc/stopc flow */
-                                               /* control characters    */
-#define        DIGI_SETFLOW    (('e'<<8) | 100)        /* Set startc/stopc flow */
-                                               /* control characters    */
-#define        DIGI_GETAFLOW   (('e'<<8) | 101)        /* Get Aux. startc/stopc */
-                                               /* flow control chars    */
-#define        DIGI_SETAFLOW   (('e'<<8) | 102)        /* Set Aux. startc/stopc */
-                                               /* flow control chars    */
-
-#define DIGI_GEDELAY   (('d'<<8) | 246)        /* Get edelay */
-#define DIGI_SEDELAY   (('d'<<8) | 247)        /* Set edelay */
-
-struct digiflow_t {
-       unsigned char   startc;                         /* flow cntl start char */
-       unsigned char   stopc;                          /* flow cntl stop char  */
-};
-
-
-#ifdef FLOW_2200
-#define        F2200_GETA      (('e'<<8) | 104)        /* Get 2x36 flow cntl flags */
-#define        F2200_SETAW     (('e'<<8) | 105)        /* Set 2x36 flow cntl flags */
-#define                F2200_MASK      0x03            /* 2200 flow cntl bit mask  */
-#define                FCNTL_2200      0x01            /* 2x36 terminal flow cntl  */
-#define                PCNTL_2200      0x02            /* 2x36 printer flow cntl   */
-#define        F2200_XON       0xf8
-#define        P2200_XON       0xf9
-#define        F2200_XOFF      0xfa
-#define        P2200_XOFF      0xfb
-
-#define        FXOFF_MASK      0x03                    /* 2200 flow status mask    */
-#define        RCVD_FXOFF      0x01                    /* 2x36 Terminal XOFF rcvd  */
-#define        RCVD_PXOFF      0x02                    /* 2x36 Printer XOFF rcvd   */
-#endif
-
-/************************************************************************
- * Values for digi_flags
- ************************************************************************/
-#define DIGI_IXON      0x0001          /* Handle IXON in the FEP       */
+#define DIGI_GET_NI_INFO (('d'<<8) | 250) /* Non-intelligent state info */
+#define DIGI_LOOPBACK (('d'<<8) | 252) /*
+                                       * Enable/disable UART
+                                       * internal loopback
+                                       */
 #define DIGI_FAST      0x0002          /* Fast baud rates              */
 #define RTSPACE                0x0004          /* RTS input flow control       */
 #define CTSPACE                0x0008          /* CTS output flow control      */
-#define DSRPACE                0x0010          /* DSR output flow control      */
-#define DCDPACE                0x0020          /* DCD output flow control      */
-#define DTRPACE                0x0040          /* DTR input flow control       */
 #define DIGI_COOK      0x0080          /* Cooked processing done in FEP */
 #define DIGI_FORCEDCD  0x0100          /* Force carrier                */
 #define        DIGI_ALTPIN     0x0200          /* Alternate RJ-45 pin config   */
-#define        DIGI_AIXON      0x0400          /* Aux flow control in fep      */
 #define        DIGI_PRINTER    0x0800          /* Hold port open for flow cntrl*/
-#define DIGI_PP_INPUT  0x1000          /* Change parallel port to input*/
 #define DIGI_DTR_TOGGLE        0x2000          /* Support DTR Toggle           */
-#define DIGI_422       0x4000          /* for 422/232 selectable panel */
 #define DIGI_RTS_TOGGLE        0x8000          /* Support RTS Toggle           */
-
-/************************************************************************
- * These options are not supported on the comxi.
- ************************************************************************/
-#define        DIGI_COMXI      (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE)
-
 #define DIGI_PLEN      28              /* String length                */
 #define        DIGI_TSIZ       10              /* Terminal string len          */
 
@@ -162,76 +76,6 @@ struct digi_t {
        char            digi_term[DIGI_TSIZ];   /* terminal string      */
 };
 
-/************************************************************************
- * KME definitions and structures.
- ************************************************************************/
-#define        RW_IDLE         0       /* Operation complete                   */
-#define        RW_READ         1       /* Read Concentrator Memory             */
-#define        RW_WRITE        2       /* Write Concentrator Memory            */
-
-struct rw_t {
-       unsigned char   rw_req;         /* Request type                 */
-       unsigned char   rw_board;       /* Host Adapter board number    */
-       unsigned char   rw_conc;        /* Concentrator number          */
-       unsigned char   rw_reserved;    /* Reserved for expansion       */
-       unsigned int    rw_addr;        /* Address in concentrator      */
-       unsigned short  rw_size;        /* Read/write request length    */
-       unsigned char   rw_data[128];   /* Data to read/write           */
-};
-
-/***********************************************************************
- * Shrink Buffer and Board Information definitions and structures.
-
- ************************************************************************/
-                       /* Board type return codes */
-#define        PCXI_TYPE 1     /* Board type at the designated port is a PC/Xi */
-#define PCXM_TYPE 2     /* Board type at the designated port is a PC/Xm */
-#define        PCXE_TYPE 3     /* Board type at the designated port is a PC/Xe */
-#define        MCXI_TYPE 4     /* Board type at the designated port is a MC/Xi */
-#define COMXI_TYPE 5     /* Board type at the designated port is a COM/Xi */
-
-                        /* Non-Zero Result codes. */
-#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */
-#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
-#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
-#define RESULT_TOOSML  4 /* Too small an area to shrink.  */
-#define RESULT_NOCHAN  5 /* Channel structure for the board was not found */
-
-struct shrink_buf_struct {
-       unsigned int    shrink_buf_vaddr;       /* Virtual address of board */
-       unsigned int    shrink_buf_phys;        /* Physical address of board */
-       unsigned int    shrink_buf_bseg;        /* Amount of board memory */
-       unsigned int    shrink_buf_hseg;        /* '186 Beginning of Dual-Port */
-
-       unsigned int    shrink_buf_lseg;        /* '186 Beginning of freed memory */
-       unsigned int    shrink_buf_mseg;        /* Linear address from start of
-                                                  dual-port were freed memory
-                                                  begins, host viewpoint. */
-
-       unsigned int    shrink_buf_bdparam;     /* Parameter for xxmemon and
-                                                  xxmemoff */
-
-       unsigned int    shrink_buf_reserva;     /* Reserved */
-       unsigned int    shrink_buf_reservb;     /* Reserved */
-       unsigned int    shrink_buf_reservc;     /* Reserved */
-       unsigned int    shrink_buf_reservd;     /* Reserved */
-
-       unsigned char   shrink_buf_result;      /* Reason for call failing
-                                                  Zero is Good return */
-       unsigned char   shrink_buf_init;        /* Non-Zero if it caused an
-                                                  xxinit call. */
-
-       unsigned char   shrink_buf_anports;     /* Number of async ports  */
-       unsigned char   shrink_buf_snports;     /* Number of sync  ports */
-       unsigned char   shrink_buf_type;        /* Board type 1 = PC/Xi,
-                                                             2 = PC/Xm,
-                                                             3 = PC/Xe
-                                                             4 = MC/Xi
-                                                             5 = COMX/i */
-       unsigned char   shrink_buf_card;        /* Card number */
-
-};
-
 /************************************************************************
  * Structure to get driver status information
  ************************************************************************/
@@ -263,52 +107,6 @@ struct digi_info {
 
 #define        DIGI_GETBD      (('d'<<8) | 249)        /* get board info          */
 
-struct digi_stat {
-       unsigned int    info_chan;              /* Channel number (0 based)  */
-       unsigned int    info_brd;               /* Board number (0 based)  */
-       unsigned int    info_cflag;             /* cflag for channel       */
-       unsigned int    info_iflag;             /* iflag for channel       */
-       unsigned int    info_oflag;             /* oflag for channel       */
-       unsigned int    info_mstat;             /* mstat for channel       */
-       unsigned int    info_tx_data;           /* tx_data for channel       */
-       unsigned int    info_rx_data;           /* rx_data for channel       */
-       unsigned int    info_hflow;             /* hflow for channel       */
-       unsigned int    info_reserved[8];       /* for future expansion    */
-};
-
-#define        DIGI_GETSTAT    (('d'<<8) | 244)        /* get board info          */
-/************************************************************************
- *
- * Structure used with ioctl commands for per-channel information
- *
- ************************************************************************/
-struct digi_ch {
-       unsigned int    info_bdnum;             /* Board number (0 based)  */
-       unsigned int    info_channel;           /* Channel index number    */
-       unsigned int    info_ch_cflag;          /* Channel cflag           */
-       unsigned int    info_ch_iflag;          /* Channel iflag           */
-       unsigned int    info_ch_oflag;          /* Channel oflag           */
-       unsigned int    info_chsize;            /* Channel structure size  */
-       unsigned int    info_sleep_stat;        /* sleep status            */
-       dev_t           info_dev;               /* device number           */
-       unsigned char   info_initstate;         /* Channel init state      */
-       unsigned char   info_running;           /* Channel running state   */
-       int             reserved[8];            /* reserved for future use */
-};
-
-/*
-* This structure is used with the DIGI_FEPCMD ioctl to
-* tell the driver which port to send the command for.
-*/
-struct digi_cmd {
-       int     cmd;
-       int     word;
-       int     ncmds;
-       int     chan; /* channel index (zero based) */
-       int     bdid; /* board index (zero based) */
-};
-
-
 struct digi_getbuffer /* Struct for holding buffer use counts */
 {
        unsigned long tIn;
@@ -328,63 +126,9 @@ struct digi_getcounter {
        unsigned long tbytes;           /* number of bytes transmitted fully */
 };
 
-/*
-*  info_sleep_stat defines
-*/
-#define INFO_RUNWAIT   0x0001
-#define INFO_WOPEN     0x0002
-#define INFO_TTIOW     0x0004
-#define INFO_CH_RWAIT  0x0008
-#define INFO_CH_WEMPTY 0x0010
-#define INFO_CH_WLOW   0x0020
-#define INFO_XXBUF_BUSY 0x0040
-
-#define        DIGI_GETCH      (('d'<<8) | 245)        /* get board info          */
-
-/* Board type definitions */
-
-#define        SUBTYPE         0007
-#define        T_PCXI          0000
-#define T_PCXM         0001
-#define T_PCXE         0002
-#define T_PCXR         0003
-#define T_SP           0004
-#define T_SP_PLUS      0005
-#      define T_HERC   0000
-#      define T_HOU    0001
-#      define T_LON    0002
-#      define T_CHA    0003
-#define FAMILY         0070
-#define T_COMXI                0000
-#define T_PCXX         0010
-#define T_CX           0020
-#define T_EPC          0030
-#define        T_PCLITE        0040
-#define        T_SPXX          0050
-#define        T_AVXX          0060
-#define T_DXB          0070
-#define T_A2K_4_8      0070
-#define BUSTYPE                0700
-#define T_ISABUS       0000
-#define T_MCBUS                0100
-#define        T_EISABUS       0200
-#define        T_PCIBUS        0400
-
 /* Board State Definitions */
-
 #define        BD_RUNNING      0x0
-#define        BD_REASON       0x7f
-#define        BD_NOTFOUND     0x1
-#define        BD_NOIOPORT     0x2
-#define        BD_NOMEM        0x3
-#define        BD_NOBIOS       0x4
 #define        BD_NOFEP        0x5
-#define        BD_FAILED       0x6
-#define BD_ALLOCATED   0x7
-#define BD_TRIBOOT     0x8
-#define        BD_BADKME       0x80
-
-#define DIGI_SPOLL            (('d'<<8) | 254)  /* change poller rate   */
 
 #define DIGI_SETCUSTOMBAUD     _IOW('e', 106, int)     /* Set integer baud rate */
 #define DIGI_GETCUSTOMBAUD     _IOR('e', 107, int)     /* Get integer baud rate */
@@ -396,20 +140,40 @@ struct digi_getcounter {
 
 #define EV_OPU         0x0001          /* !<Output paused by client */
 #define EV_OPS         0x0002          /* !<Output paused by reqular sw flowctrl */
-#define EV_OPX         0x0004          /* !<Output paused by extra sw flowctrl */
-#define EV_OPH         0x0008          /* !<Output paused by hw flowctrl */
-#define EV_OPT         0x0800          /* !<Output paused for RTS Toggle predelay */
-
 #define EV_IPU         0x0010          /* !<Input paused unconditionally by user */
 #define EV_IPS         0x0020          /* !<Input paused by high/low water marks */
-#define EV_IPA         0x0400          /* !<Input paused by pattern alarm module */
-
 #define EV_TXB         0x0040          /* !<Transmit break pending */
-#define EV_TXI         0x0080          /* !<Transmit immediate pending */
-#define EV_TXF         0x0100          /* !<Transmit flowctrl char pending */
-#define EV_RXB         0x0200          /* !<Break received */
 
-#define EV_OPALL       0x080f          /* !<Output pause flags */
-#define EV_IPALL       0x0430          /* !<Input pause flags */
+/*
+ * This structure holds data needed for the intelligent <--> nonintelligent
+ * DPA translation
+ */
+struct ni_info {
+       int board;
+       int channel;
+       int dtr;
+       int rts;
+       int cts;
+       int dsr;
+       int ri;
+       int dcd;
+       int curtx;
+       int currx;
+       unsigned short iflag;
+       unsigned short oflag;
+       unsigned short cflag;
+       unsigned short lflag;
+       unsigned int mstat;
+       unsigned char hflow;
+       unsigned char xmit_stopped;
+       unsigned char recv_stopped;
+       unsigned int baud;
+};
+
+#define T_CLASSIC 0002
+#define T_PCIBUS 0400
+#define T_NEO_EXPRESS 0001
+#define T_NEO 0000
 
+#define TTY_FLIPBUF_SIZE 512
 #endif /* DIGI_H */
diff --git a/drivers/staging/dgnc/dpacompat.h b/drivers/staging/dgnc/dpacompat.h
deleted file mode 100644 (file)
index 33cb394..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2003 Digi International (www.digi.com)
- *      Scott H Kilau <Scott_Kilau at digi dot com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * 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!!!
- */
-
-
-/*
- * This structure holds data needed for the intelligent <--> nonintelligent
- * DPA translation
- */
-struct ni_info {
-       int board;
-       int channel;
-       int dtr;
-       int rts;
-       int cts;
-       int dsr;
-       int ri;
-       int dcd;
-       int curtx;
-       int currx;
-       unsigned short iflag;
-       unsigned short oflag;
-       unsigned short cflag;
-       unsigned short lflag;
-
-       unsigned int mstat;
-       unsigned char hflow;
-
-       unsigned char xmit_stopped;
-       unsigned char recv_stopped;
-
-       unsigned int baud;
-};
-
-#define RW_READ                1
-#define RW_WRITE        2
-#define DIGI_KME        (('e'<<8) | 98)         /* Read/Write Host */
-
-#define SUBTYPE         0007
-#define T_PCXI          0000
-#define T_PCXEM         0001
-#define T_PCXE          0002
-#define T_PCXR          0003
-#define T_SP            0004
-#define T_SP_PLUS       0005
-
-#define T_HERC   0000
-#define T_HOU    0001
-#define T_LON    0002
-#define T_CHA    0003
-
-#define T_NEO   0000
-#define T_NEO_EXPRESS  0001
-#define T_CLASSIC 0002
-
-#define FAMILY          0070
-#define T_COMXI         0000
-#define        T_NI            0000
-#define T_PCXX          0010
-#define T_CX            0020
-#define T_EPC           0030
-#define T_PCLITE        0040
-#define T_SPXX          0050
-#define T_AVXX          0060
-#define T_DXB           0070
-#define T_A2K_4_8       0070
-
-#define BUSTYPE         0700
-#define T_ISABUS        0000
-#define T_MCBUS         0100
-#define T_EISABUS       0200
-#define T_PCIBUS        0400
-
-/* Board State Definitions */
-
-#define BD_RUNNING      0x0
-#define BD_REASON       0x7f
-#define BD_NOTFOUND     0x1
-#define BD_NOIOPORT     0x2
-#define BD_NOMEM        0x3
-#define BD_NOBIOS       0x4
-#define BD_NOFEP        0x5
-#define BD_FAILED       0x6
-#define BD_ALLOCATED    0x7
-#define BD_TRIBOOT      0x8
-#define BD_BADKME       0x80
-
-#define DIGI_AIXON      0x0400          /* Aux flow control in fep */
-
-/* Ioctls needed for dpa operation */
-
-#define DIGI_GETDD      (('d'<<8) | 248)       /* get driver info      */
-#define DIGI_GETBD      (('d'<<8) | 249)       /* get board info       */
-#define DIGI_GET_NI_INFO (('d'<<8) | 250)      /* nonintelligent state snfo */
-
-/* Other special ioctls */
-#define DIGI_TIMERIRQ (('d'<<8) | 251)         /* Enable/disable RS_TIMER use */
-#define DIGI_LOOPBACK (('d'<<8) | 252)         /* Enable/disable UART internal loopback */
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 995a9101a080829b456d38a10f4b6a9cd9da1ca8..6cf0c58f538bc7a3848042f8a67b48fac1540b69 100644 (file)
@@ -38,6 +38,12 @@ config FB_TFT_HX8353D
        help
          Generic Framebuffer support for HX8353D
 
+config FB_TFT_ILI9163
+       tristate "FB driver for the ILI9163 LCD Controller"
+       depends on FB_TFT
+       help
+         Generic Framebuffer support for ILI9163
+
 config FB_TFT_ILI9320
        tristate "FB driver for the ILI9320 LCD Controller"
        depends on FB_TFT
index e773f0fdcfe81e3a15933358d20b0c430b9da940..9e73beee23f4bd7e114a6ce8860054c113d64b7b 100644 (file)
@@ -8,6 +8,7 @@ obj-$(CONFIG_FB_TFT_BD663474)    += fb_bd663474.o
 obj-$(CONFIG_FB_TFT_HX8340BN)    += fb_hx8340bn.o
 obj-$(CONFIG_FB_TFT_HX8347D)     += fb_hx8347d.o
 obj-$(CONFIG_FB_TFT_HX8353D)     += fb_hx8353d.o
+obj-$(CONFIG_FB_TFT_ILI9163)     += fb_ili9163.o
 obj-$(CONFIG_FB_TFT_ILI9320)     += fb_ili9320.o
 obj-$(CONFIG_FB_TFT_ILI9325)     += fb_ili9325.o
 obj-$(CONFIG_FB_TFT_ILI9340)     += fb_ili9340.o
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..8f5af1db852c2dfcdc05f4701a59c659164b40f1 100644 (file)
@@ -174,7 +174,7 @@ request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio)
 
 /* This function oses to enter commands
  * first byte - destination controller 0 or 1
- * folowing - commands
+ * following - commands
  */
 static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 {
@@ -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 select 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;
                }
        }
@@ -278,10 +278,13 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
        int x, y;
        int ret = 0;
 
-       /* buffer to convert RGB565 -> grayscale16 -> Ditherd image 1bpp */
+       /* buffer to convert RGB565 -> grayscale16 -> Dithered image 1bpp */
        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..54528aa0c0efe2f5ed130c5869e291cb743eb626 100644 (file)
@@ -4,7 +4,7 @@
  * This display uses 9-bit SPI: Data/Command bit + 8 data bits
  * For platforms that doesn't support 9-bit, the driver is capable
  * of emulating this using 8-bit transfer.
- * This is done by transfering eight 9-bit words in 9 bytes.
+ * This is done by transferring eight 9-bit words in 9 bytes.
  *
  * Copyright (C) 2013 Noralf Tronnes
  *
@@ -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));
@@ -156,14 +149,12 @@ static int set_var(struct fbtft_par *par)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b1111, 0b1111, 0b11111, 0b1111, 0b1111, 0b1111, 0b11111,
-               0b111, 0b111, 0b111, 0b111, 0b111, 0b111, 0b11, 0b11,
-               0b1111, 0b1111, 0b11111, 0b1111, 0b1111, 0b1111, 0b11111,
-               0b111, 0b111, 0b111, 0b111, 0b111, 0b111, 0b0, 0b0 };
+               0x0f, 0x0f, 0x1f, 0x0f, 0x0f, 0x0f, 0x1f, 0x07, 0x07, 0x07,
+               0x07, 0x07, 0x07, 0x03, 0x03, 0x0f, 0x0f, 0x1f, 0x0f, 0x0f,
+               0x0f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00,
+       };
        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 8139a8f587b75549d4c1297883f109d6f41e07d7..03ae95b4f79e80e174ee4a2c9c733e97fd783be6 100644 (file)
@@ -115,10 +115,9 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
-               0b1111111, 0b1111111,
-               0b11111, 0b11111, 0b11111, 0b11111, 0b11111,
-               0b1111};
+               0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x7f, 0x7f, 0x1f, 0x1f,
+               0x1f, 0x1f, 0x1f, 0x0f,
+       };
        int i, j;
        int acc = 0;
 
index c9512dc5f4d349478cac23ead77286a9351904b9..d7f4308e124985a5eaaa0622600bc2ad5d07bdbf 100644 (file)
@@ -84,7 +84,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* column address */
        write_reg(par, 0x2a, xs >> 8, xs & 0xff, xe >> 8, xe & 0xff);
 
-       /* row adress */
+       /* Row address */
        write_reg(par, 0x2b, ys >> 8, ys & 0xff, ye >> 8, ye & 0xff);
 
        /* memory write */
@@ -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));
diff --git a/drivers/staging/fbtft/fb_ili9163.c b/drivers/staging/fbtft/fb_ili9163.c
new file mode 100644 (file)
index 0000000..ed92a64
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ * FB driver for the ILI9163 LCD Controller
+ *
+ * Copyright (C) 2015 Kozhevnikov Anatoly
+ *
+ * Based on ili9325.c by Noralf Tronnes and
+ * .S.U.M.O.T.O.Y. by Max MC Costa (https://github.com/sumotoy/TFT_ILI9163C).
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/gpio.h>
+#include <linux/delay.h>
+
+#include "fbtft.h"
+
+#define DRVNAME                "fb_ili9163"
+#define WIDTH          128
+#define HEIGHT         128
+#define BPP            16
+#define FPS            30
+
+#ifdef GAMMA_ADJ
+#define GAMMA_LEN      15
+#define GAMMA_NUM      1
+#define DEFAULT_GAMMA  "36 29 12 22 1C 15 42 B7 2F 13 12 0A 11 0B 06\n"
+#endif
+
+/* ILI9163C commands */
+#define CMD_NOP                0x00 /* Non operation*/
+#define CMD_SWRESET    0x01 /* Soft Reset */
+#define CMD_SLPIN      0x10 /* Sleep ON */
+#define CMD_SLPOUT     0x11 /* Sleep OFF */
+#define CMD_PTLON      0x12 /* Partial Mode ON */
+#define CMD_NORML      0x13 /* Normal Display ON */
+#define CMD_DINVOF     0x20 /* Display Inversion OFF */
+#define CMD_DINVON     0x21 /* Display Inversion ON */
+#define CMD_GAMMASET   0x26 /* Gamma Set (0x01[1],0x02[2],0x04[3],0x08[4]) */
+#define CMD_DISPOFF    0x28 /* Display OFF */
+#define CMD_DISPON     0x29 /* Display ON */
+#define CMD_IDLEON     0x39 /* Idle Mode ON */
+#define CMD_IDLEOF     0x38 /* Idle Mode OFF */
+#define CMD_CLMADRS    0x2A /* Column Address Set */
+#define CMD_PGEADRS    0x2B /* Page Address Set */
+
+#define CMD_RAMWR      0x2C /* Memory Write */
+#define CMD_RAMRD      0x2E /* Memory Read */
+#define CMD_CLRSPACE   0x2D /* Color Space : 4K/65K/262K */
+#define CMD_PARTAREA   0x30 /* Partial Area */
+#define CMD_VSCLLDEF   0x33 /* Vertical Scroll Definition */
+#define CMD_TEFXLON    0x34 /* Tearing Effect Line ON */
+#define CMD_TEFXLOF    0x35 /* Tearing Effect Line OFF */
+#define CMD_MADCTL     0x36 /* Memory Access Control */
+
+#define CMD_PIXFMT     0x3A /* Interface Pixel Format */
+#define CMD_FRMCTR1    0xB1 /* Frame Rate Control
+                               (In normal mode/Full colors) */
+#define CMD_FRMCTR2    0xB2 /* Frame Rate Control (In Idle mode/8-colors) */
+#define CMD_FRMCTR3    0xB3 /* Frame Rate Control
+                               (In Partial mode/full colors) */
+#define CMD_DINVCTR    0xB4 /* Display Inversion Control */
+#define CMD_RGBBLK     0xB5 /* RGB Interface Blanking Porch setting */
+#define CMD_DFUNCTR    0xB6 /* Display Function set 5 */
+#define CMD_SDRVDIR    0xB7 /* Source Driver Direction Control */
+#define CMD_GDRVDIR    0xB8 /* Gate Driver Direction Control  */
+
+#define CMD_PWCTR1     0xC0 /* Power_Control1 */
+#define CMD_PWCTR2     0xC1 /* Power_Control2 */
+#define CMD_PWCTR3     0xC2 /* Power_Control3 */
+#define CMD_PWCTR4     0xC3 /* Power_Control4 */
+#define CMD_PWCTR5     0xC4 /* Power_Control5 */
+#define CMD_VCOMCTR1   0xC5 /* VCOM_Control 1 */
+#define CMD_VCOMCTR2   0xC6 /* VCOM_Control 2 */
+#define CMD_VCOMOFFS   0xC7 /* VCOM Offset Control */
+#define CMD_PGAMMAC    0xE0 /* Positive Gamma Correction Setting */
+#define CMD_NGAMMAC    0xE1 /* Negative Gamma Correction Setting */
+#define CMD_GAMRSEL    0xF2 /* GAM_R_SEL */
+
+/*
+This display:
+http://www.ebay.com/itm/Replace-Nokia-5110-LCD-1-44-Red-Serial-128X128-SPI-Color-TFT-LCD-Display-Module-/271422122271
+This particular display has a design error! The controller has 3 pins to
+configure to constrain the memory and resolution to a fixed dimension (in
+that case 128x128) but they leaved those pins configured for 128x160 so
+there was several pixel memory addressing problems.
+I solved by setup several parameters that dinamically fix the resolution as
+needit so below the parameters for this display. If you have a strain or a
+correct display (can happen with chinese) you can copy those parameters and
+create setup for different displays.
+*/
+
+#ifdef RED
+#define __OFFSET               32 /*see note 2 - this is the red version */
+#else
+#define __OFFSET               0  /*see note 2 - this is the black version */
+#endif
+
+static int init_display(struct fbtft_par *par)
+{
+       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+       par->fbtftops.reset(par);
+
+       if (par->gpio.cs != -1)
+               gpio_set_value(par->gpio.cs, 0);  /* Activate chip */
+
+       write_reg(par, CMD_SWRESET); /* software reset */
+       mdelay(500);
+       write_reg(par, CMD_SLPOUT); /* exit sleep */
+       mdelay(5);
+       write_reg(par, CMD_PIXFMT, 0x05); /* Set Color Format 16bit */
+       write_reg(par, CMD_GAMMASET, 0x02); /* default gamma curve 3 */
+#ifdef GAMMA_ADJ
+       write_reg(par, CMD_GAMRSEL, 0x01); /* Enable Gamma adj */
+#endif
+       write_reg(par, CMD_NORML);
+       write_reg(par, CMD_DFUNCTR, 0xff, 0x06);
+       /* Frame Rate Control (In normal mode/Full colors) */
+       write_reg(par, CMD_FRMCTR1, 0x08, 0x02);
+       write_reg(par, CMD_DINVCTR, 0x07); /* display inversion  */
+       /* Set VRH1[4:0] & VC[2:0] for VCI1 & GVDD */
+       write_reg(par, CMD_PWCTR1, 0x0A, 0x02);
+       /* Set BT[2:0] for AVDD & VCL & VGH & VGL  */
+       write_reg(par, CMD_PWCTR2, 0x02);
+       /* Set VMH[6:0] & VML[6:0] for VOMH & VCOML */
+       write_reg(par, CMD_VCOMCTR1, 0x50, 0x63);
+       write_reg(par, CMD_VCOMOFFS, 0);
+
+       write_reg(par, CMD_CLMADRS, 0, 0, 0, WIDTH); /* Set Column Address */
+       write_reg(par, CMD_PGEADRS, 0, 0, 0, HEIGHT); /* Set Page Address */
+
+       write_reg(par, CMD_DISPON); /* display ON */
+       write_reg(par, CMD_RAMWR); /* Memory Write */
+
+       return 0;
+}
+
+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);
+
+       switch (par->info->var.rotate) {
+       case 0:
+               write_reg(par, CMD_CLMADRS, xs >> 8, xs & 0xff, xe >> 8,
+                               xe & 0xff);
+               write_reg(par, CMD_PGEADRS,
+                               (ys + __OFFSET) >> 8, (ys + __OFFSET) & 0xff,
+                               (ye + __OFFSET) >> 8, (ye + __OFFSET) & 0xff);
+               break;
+       case 90:
+               write_reg(par, CMD_CLMADRS,
+                               (xs + __OFFSET) >> 8, (xs + __OFFSET) & 0xff,
+                               (xe + __OFFSET) >> 8, (xe + __OFFSET) & 0xff);
+               write_reg(par, CMD_PGEADRS, ys >> 8, ys & 0xff, ye >> 8,
+                               ye & 0xff);
+               break;
+       case 180:
+       case 270:
+               write_reg(par, CMD_CLMADRS, xs >> 8, xs & 0xff, xe >> 8,
+                               xe & 0xff);
+               write_reg(par, CMD_PGEADRS, ys >> 8, ys & 0xff, ye >> 8,
+                               ye & 0xff);
+               break;
+       default:
+               par->info->var.rotate = 0; /* Fix incorrect setting */
+       }
+       write_reg(par, CMD_RAMWR); /* Write Data to GRAM mode */
+}
+
+/*
+7) MY:  1(bottom to top),      0(top to bottom)    Row Address Order
+6) MX:  1(R to L),             0(L to R)           Column Address Order
+5) MV:  1(Exchanged),          0(normal)           Row/Column exchange
+4) ML:  1(bottom to top),      0(top to bottom)    Vertical Refresh Order
+3) RGB: 1(BGR),                        0(RGB)              Color Space
+2) MH:  1(R to L),             0(L to R)           Horizontal Refresh Order
+1)
+0)
+
+       MY, MX, MV, ML,RGB, MH, D1, D0
+       0 | 0 | 0 | 0 | 1 | 0 | 0 | 0   //normal
+       1 | 0 | 0 | 0 | 1 | 0 | 0 | 0   //Y-Mirror
+       0 | 1 | 0 | 0 | 1 | 0 | 0 | 0   //X-Mirror
+       1 | 1 | 0 | 0 | 1 | 0 | 0 | 0   //X-Y-Mirror
+       0 | 0 | 1 | 0 | 1 | 0 | 0 | 0   //X-Y Exchange
+       1 | 0 | 1 | 0 | 1 | 0 | 0 | 0   //X-Y Exchange, Y-Mirror
+       0 | 1 | 1 | 0 | 1 | 0 | 0 | 0   //XY exchange
+       1 | 1 | 1 | 0 | 1 | 0 | 0 | 0
+*/
+static int set_var(struct fbtft_par *par)
+{
+       u8 mactrl_data = 0; /* Avoid compiler warning */
+
+       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+       switch (par->info->var.rotate) {
+       case 0:
+               mactrl_data = 0x08;
+               break;
+       case 180:
+               mactrl_data = 0xC8;
+               break;
+       case 270:
+               mactrl_data = 0xA8;
+               break;
+       case 90:
+               mactrl_data = 0x68;
+               break;
+       }
+
+       /* Colorspcae */
+       if (par->bgr)
+               mactrl_data |= (1 << 2);
+       write_reg(par, CMD_MADCTL, mactrl_data);
+       write_reg(par, CMD_RAMWR); /* Write Data to GRAM mode */
+       return 0;
+}
+
+#ifdef GAMMA_ADJ
+#define CURVE(num, idx)  curves[num*par->gamma.num_values + idx]
+static int gamma_adj(struct fbtft_par *par, unsigned long *curves)
+{
+       unsigned long mask[] = {
+               0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+               0x1f, 0x3f, 0x0f, 0x0f, 0x7f, 0x1f,
+               0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
+       int i, j;
+
+       fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+       for (i = 0; i < GAMMA_NUM; i++)
+               for (j = 0; j < GAMMA_LEN; j++)
+                       CURVE(i, j) &= mask[i*par->gamma.num_values + j];
+
+       write_reg(par, CMD_PGAMMAC,
+                               CURVE(0, 0),
+                               CURVE(0, 1),
+                               CURVE(0, 2),
+                               CURVE(0, 3),
+                               CURVE(0, 4),
+                               CURVE(0, 5),
+                               CURVE(0, 6),
+                               (CURVE(0, 7) << 4) | CURVE(0, 8),
+                               CURVE(0, 9),
+                               CURVE(0, 10),
+                               CURVE(0, 11),
+                               CURVE(0, 12),
+                               CURVE(0, 13),
+                               CURVE(0, 14),
+                               CURVE(0, 15)
+                               );
+
+       write_reg(par, CMD_RAMWR); /* Write Data to GRAM mode */
+
+       return 0;
+}
+#undef CURVE
+#endif
+
+static struct fbtft_display display = {
+       .regwidth = 8,
+       .width = WIDTH,
+       .height = HEIGHT,
+       .bpp = BPP,
+       .fps = FPS,
+#ifdef GAMMA_ADJ
+       .gamma_num = GAMMA_NUM,
+       .gamma_len = GAMMA_LEN,
+       .gamma = DEFAULT_GAMMA,
+#endif
+       .fbtftops = {
+               .init_display = init_display,
+               .set_addr_win = set_addr_win,
+               .set_var = set_var,
+#ifdef GAMMA_ADJ
+               .set_gamma = gamma_adj,
+#endif
+       },
+};
+
+FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9163", &display);
+
+MODULE_ALIAS("spi:" DRVNAME);
+MODULE_ALIAS("platform:" DRVNAME);
+MODULE_ALIAS("spi:ili9163");
+MODULE_ALIAS("platform:ili9163");
+
+MODULE_DESCRIPTION("FB driver for the ILI9163 LCD Controller");
+MODULE_AUTHOR("Kozhevnikov Anatoly");
+MODULE_LICENSE("GPL");
index b26d89368da7ca831192e7c322d5de8cc8424e4c..3a02edd447d4908b585f5e58ad24bd54e47b5a66 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);
@@ -178,10 +179,9 @@ static int set_var(struct fbtft_par *par)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111,
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111 };
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+       };
        int i, j;
 
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
index 5f88145fac9be568702a0c7d24ad26141cf1c190..19d254e9a4206c729a777cff079318f6ee7cc7e8 100644 (file)
@@ -41,22 +41,22 @@ static unsigned bt = 6; /* VGL=Vci*4 , VGH=Vci*4 */
 module_param(bt, uint, 0);
 MODULE_PARM_DESC(bt, "Sets the factor used in the step-up circuits");
 
-static unsigned vc = 0b011; /* Vci1=Vci*0.80 */
+static unsigned vc = 0x03; /* Vci1=Vci*0.80 */
 module_param(vc, uint, 0);
 MODULE_PARM_DESC(vc,
 "Sets the ratio factor of Vci to generate the reference voltages Vci1");
 
-static unsigned vrh = 0b1101; /* VREG1OUT=Vci*1.85 */
+static unsigned vrh = 0x0d; /* VREG1OUT=Vci*1.85 */
 module_param(vrh, uint, 0);
 MODULE_PARM_DESC(vrh,
 "Set the amplifying rate (1.6 ~ 1.9) of Vci applied to output the VREG1OUT");
 
-static unsigned vdv = 0b10010; /* VCOMH amplitude=VREG1OUT*0.98 */
+static unsigned vdv = 0x12; /* VCOMH amplitude=VREG1OUT*0.98 */
 module_param(vdv, uint, 0);
 MODULE_PARM_DESC(vdv,
 "Select the factor of VREG1OUT to set the amplitude of Vcom");
 
-static unsigned vcm = 0b001010; /* VCOMH=VREG1OUT*0.735 */
+static unsigned vcm = 0x0a; /* VCOMH=VREG1OUT*0.735 */
 module_param(vcm, uint, 0);
 MODULE_PARM_DESC(vcm, "Set the internal VcomH voltage");
 
@@ -108,11 +108,11 @@ static int init_display(struct fbtft_par *par)
        if (par->gpio.cs != -1)
                gpio_set_value(par->gpio.cs, 0);  /* Activate chip */
 
-       bt &= 0b111;
-       vc &= 0b111;
-       vrh &= 0b1111;
-       vdv &= 0b11111;
-       vcm &= 0b111111;
+       bt &= 0x07;
+       vc &= 0x07;
+       vrh &= 0x0f;
+       vdv &= 0x1f;
+       vcm &= 0x3f;
 
        /* Initialization sequence from ILI9325 Application Notes */
 
@@ -137,7 +137,7 @@ static int init_display(struct fbtft_par *par)
        write_reg(par, 0x0013, 0x0000); /* VDV[4:0] for VCOM amplitude */
        mdelay(200); /* Dis-charge capacitor power voltage */
        write_reg(par, 0x0010, /* SAP, BT[3:0], AP, DSTB, SLP, STB */
-               (1 << 12) | (bt << 8) | (1 << 7) | (0b001 << 4));
+               (1 << 12) | (bt << 8) | (1 << 7) | (0x01 << 4));
        write_reg(par, 0x0011, 0x220 | vc); /* DC1[2:0], DC0[2:0], VC[2:0] */
        mdelay(50); /* Delay 50ms */
        write_reg(par, 0x0012, vrh); /* Internal reference voltage= Vci; */
@@ -233,10 +233,9 @@ static int set_var(struct fbtft_par *par)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111,
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111 };
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+       };
        int i, j;
 
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
index 985687d94ec238622a29ce78d41051550a4e53b6..0f4a42f89e5e2cfb0ba5a94331d3f582fb2352d7 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);
@@ -104,7 +104,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* Column address */
        write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
 
-       /* Row adress */
+       /* Row address */
        write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
 
        /* Memory write */
index 225b2d84371fbcbc0caf05721a9dc5b4215213f4..709492e560b61b64a52502e360d0fdbcebd05ee2 100644 (file)
@@ -4,7 +4,7 @@
  * This display uses 9-bit SPI: Data/Command bit + 8 data bits
  * For platforms that doesn't support 9-bit, the driver is capable
  * of emulating this using 8-bit transfer.
- * This is done by transfering eight 9-bit words in 9 bytes.
+ * This is done by transferring eight 9-bit words in 9 bytes.
  *
  * Copyright (C) 2013 Christian Vogelgsang
  * Based on adafruit22fb.c by Noralf Tronnes
@@ -89,7 +89,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        write_reg(par, 0x2A,
                (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF);
 
-       /* Row adress set */
+       /* Row address set */
        write_reg(par, 0x2B,
                (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF);
 
index 725157a1ac4194a6b0469ca658910ca124fc53ce..8bae09c2d5cecdb1bcf2a8d3f84f3bf4512885c3 100644 (file)
@@ -63,7 +63,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* column address */
        write_reg(par, 0x2a, xs >> 8, xs & 0xff, xe >> 8, xe & 0xff);
 
-       /* row adress */
+       /* Row address */
        write_reg(par, 0x2b, ys >> 8, ys & 0xff, ye >> 8, ye & 0xff);
 
        /* memory write */
index 95b89999d32a840b3a4235dfc2427926975c0167..dd4ddca384ad75dd208ec315e374c54b1865603c 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 */
@@ -67,7 +67,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* Column address */
        write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
 
-       /* Row adress */
+       /* Row address */
        write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
 
        /* Memory write */
index 8b9ebfb49ef8e733c5d1030e9db54f314a68c6b0..15da0ec77513a464b348c1123a7e57629cc7b0a4 100644 (file)
@@ -34,7 +34,7 @@
 #define WIDTH          84
 #define HEIGHT         48
 #define TXBUFLEN       (84*6)
-#define DEFAULT_GAMMA  "40" /* gamma is used to control contrast in this driver */
+#define DEFAULT_GAMMA  "40" /* gamma controls the contrast in this driver */
 
 static unsigned tc;
 module_param(tc, uint, 0);
@@ -51,61 +51,73 @@ static int init_display(struct fbtft_par *par)
 
        par->fbtftops.reset(par);
 
-       /* Function set */
-       write_reg(par, 0x21); /* 5:1  1
-                                2:0  PD - Powerdown control: chip is active
-                                                        1:0  V  - Entry mode: horizontal addressing
-                                                        0:1  H  - Extended instruction set control: extended
-                                                 */
-
-       /* H=1 Temperature control */
-       write_reg(par, 0x04 | (tc & 0x3)); /*
-                                2:1  1
-                                1:x  TC1 - Temperature Coefficient: 0x10
-                                                        0:x  TC0
-                                                 */
-
-       /* H=1 Bias system */
-       write_reg(par, 0x10 | (bs & 0x7)); /*
-                                4:1  1
-                                3:0  0
-                                                        2:x  BS2 - Bias System
-                                                        1:x  BS1
-                                                        0:x  BS0
-                             */
-
-       /* Function set */
-       write_reg(par, 0x22); /* 5:1  1
-                                2:0  PD - Powerdown control: chip is active
-                                                        1:1  V  - Entry mode: vertical addressing
-                                                        0:0  H  - Extended instruction set control: basic
-                                                 */
-
-       /* H=0 Display control */
-       write_reg(par, 0x08 | 4); /*
-                                3:1  1
-                                2:1  D  - DE: 10=normal mode
-                                                        1:0  0
-                                                        0:0  E
-                                                 */
+       /* Function set
+        *
+        * 5:1  1
+        * 2:0  PD - Powerdown control: chip is active
+        * 1:0  V  - Entry mode: horizontal addressing
+        * 0:1  H  - Extended instruction set control: extended
+        */
+       write_reg(par, 0x21);
+
+       /* H=1 Temperature control
+        *
+        * 2:1  1
+        * 1:x  TC1 - Temperature Coefficient: 0x10
+        * 0:x  TC0
+        */
+       write_reg(par, 0x04 | (tc & 0x3));
+
+       /* H=1 Bias system
+        *
+        * 4:1  1
+        * 3:0  0
+        * 2:x  BS2 - Bias System
+        * 1:x  BS1
+        * 0:x  BS0
+        */
+       write_reg(par, 0x10 | (bs & 0x7));
+
+       /* Function set
+        *
+        * 5:1  1
+        * 2:0  PD - Powerdown control: chip is active
+        * 1:1  V  - Entry mode: vertical addressing
+        * 0:0  H  - Extended instruction set control: basic
+        */
+       write_reg(par, 0x22);
+
+       /* H=0 Display control
+        *
+        * 3:1  1
+        * 2:1  D  - DE: 10=normal mode
+        * 1:0  0
+        * 0:0  E
+        */
+       write_reg(par, 0x08 | 4);
 
        return 0;
 }
 
 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);
-
-       /* H=0 Set X address of RAM */
-       write_reg(par, 0x80); /* 7:1  1
-                                6-0: X[6:0] - 0x00
-                             */
-
-       /* H=0 Set Y address of RAM */
-       write_reg(par, 0x40); /* 7:0  0
-                                6:1  1
-                                2-0: Y[2:0] - 0x0
-                             */
+       fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n",
+                     __func__, xs, ys, xe, ye);
+
+       /* H=0 Set X address of RAM
+        *
+        * 7:1  1
+        * 6-0: X[6:0] - 0x00
+        */
+       write_reg(par, 0x80);
+
+       /* H=0 Set Y address of RAM
+        *
+        * 7:0  0
+        * 6:1  1
+        * 2-0: Y[2:0] - 0x0
+        */
+       write_reg(par, 0x40);
 }
 
 static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
@@ -120,9 +132,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 +142,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..2c4d4dc70c51e5d941f5a0e9d03741bdfb11aa54 100644 (file)
@@ -11,7 +11,7 @@
                                                  *****      *   *
   Date    : 10.06.2014                                      *   *
   Version : V1.13                                          *****
-  Revison : 5
+  Revision : 5
 
 *******************************************************************************
  * This program is free software; you can redistribute it and/or modify
@@ -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..f3302525ec0092992e2dc872de7cd143890f0f74 100644 (file)
@@ -108,7 +108,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* Column address */
        write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
 
-       /* Row adress */
+       /* Row address */
        write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
 
        /* Memory write */
@@ -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..2e1b72ad54aa95e408136002442ac3584052df1a 100644 (file)
@@ -143,12 +143,10 @@ 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,
-               0b11111, 0b11111,
-               0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
-               0b111111, 0b111111, 0b111111, 0b111111, 0b111111, 0b111111,
-               0b11111, 0b11111 };
+               0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
+               0x3f, 0x3f, 0x1f, 0x1f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
+               0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x1f, 0x1f,
+       };
        int i, j;
 
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
index ef46fbca27004c89b03f4e8a3f5ea5938dd48a4e..17a77e0614987d5ad021dbedab11dce48d6e258b 100644 (file)
@@ -126,16 +126,16 @@ static int set_var(struct fbtft_par *par)
 
        switch (par->info->var.rotate) {
        case 0:
-               write_reg(par, 0x11, reg11 | 0b110000);
+               write_reg(par, 0x11, reg11 | 0x30);
                break;
        case 270:
-               write_reg(par, 0x11, reg11 | 0b101000);
+               write_reg(par, 0x11, reg11 | 0x28);
                break;
        case 180:
-               write_reg(par, 0x11, reg11 | 0b000000);
+               write_reg(par, 0x11, reg11 | 0x00);
                break;
        case 90:
-               write_reg(par, 0x11, reg11 | 0b011000);
+               write_reg(par, 0x11, reg11 | 0x18);
                break;
        }
 
@@ -151,10 +151,9 @@ static int set_var(struct fbtft_par *par)
 static int set_gamma(struct fbtft_par *par, unsigned long *curves)
 {
        unsigned long mask[] = {
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111,
-               0b11111, 0b11111, 0b111, 0b111, 0b111,
-               0b111, 0b111, 0b111, 0b111, 0b111 };
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+               0x1f, 0x1f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+       };
        int i, j;
 
        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
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..9bcd7a0aeed4b035caac6d00a0e2dc195fc4c834 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) {
@@ -86,16 +87,16 @@ static int set_var(struct fbtft_par *par)
 
        switch (par->info->var.rotate) {
        case 0:
-               write_reg(par, 0xA0, remap | 0b00 | 1<<4);
+               write_reg(par, 0xA0, remap | 0x00 | 1<<4);
                break;
        case 270:
-               write_reg(par, 0xA0, remap | 0b11 | 1<<4);
+               write_reg(par, 0xA0, remap | 0x03 | 1<<4);
                break;
        case 180:
-               write_reg(par, 0xA0, remap | 0b10);
+               write_reg(par, 0xA0, remap | 0x02);
                break;
        case 90:
-               write_reg(par, 0xA0, remap | 0b01);
+               write_reg(par, 0xA0, remap | 0x01);
                break;
        }
 
@@ -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..9d874308447e05b0c9f15fa4b34d903c170cf859 100644 (file)
 
 static int default_init_sequence[] = {
        /* SWRESET - Software reset */
-       -1, 0x01,                                
+       -1, 0x01,
        -2, 150,                               /* delay */
 
        /* SLPOUT - Sleep out & booster on */
-       -1, 0x11,                          
+       -1, 0x11,
        -2, 500,                               /* delay */
 
        /* FRMCTR1 - frame rate control: normal mode
             frame rate = fosc / (1 x 2 + 40) * (LINE + 2C + 2D) */
-       -1, 0xB1, 0x01, 0x2C, 0x2D, 
+       -1, 0xB1, 0x01, 0x2C, 0x2D,
 
        /* FRMCTR2 - frame rate control: idle mode
             frame rate = fosc / (1 x 2 + 40) * (LINE + 2C + 2D) */
-       -1, 0xB2, 0x01, 0x2C, 0x2D, 
+       -1, 0xB2, 0x01, 0x2C, 0x2D,
 
        /* FRMCTR3 - frame rate control - partial mode
             dot inversion mode, line inversion mode */
@@ -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,
@@ -91,7 +91,7 @@ static int default_init_sequence[] = {
        -2, 10,                               /* delay */
 
        /* end marker */
-       -3                                  
+       -3
 };
 
 static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
@@ -102,7 +102,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* Column address */
        write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
 
-       /* Row adress */
+       /* Row address */
        write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
 
        /* Memory write */
@@ -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) &= 0x3f;
 
        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 ca98bfb5c7df907454c75ad443ba29c37c377097..c0b1a337fafdb525938dcb47d78441665752b6b9 100644 (file)
@@ -70,7 +70,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
        /* Column address */
        write_reg(par, 0x2A, xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
 
-       /* Row adress */
+       /* Row address */
        write_reg(par, 0x2B, ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
 
        /* Memory write */
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..53b748be2712479368e20c75d0c188f6b6630d5b 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;
@@ -347,7 +338,7 @@ static void fbtft_set_addr_win(struct fbtft_par *par, int xs, int ys, int xe,
        write_reg(par, 0x2A,
                (xs >> 8) & 0xFF, xs & 0xFF, (xe >> 8) & 0xFF, xe & 0xFF);
 
-       /* Row adress set */
+       /* Row address set */
        write_reg(par, 0x2B,
                (ys >> 8) & 0xFF, ys & 0xFF, (ye >> 8) & 0xFF, ye & 0xFF);
 
@@ -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..c4cc452f9f2bf654ba019a71072e65a9ec3cdb28 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;
@@ -153,7 +152,7 @@ static struct device_attribute gamma_device_attrs[] = {
 
 void fbtft_expand_debug_value(unsigned long *debug)
 {
-       switch (*debug & 0b111) {
+       switch (*debug & 0x7) {
        case 1:
                *debug |= DEBUG_LEVEL_1;
                break;
index 0dbf3f95fe786ce50a9206cd754c4e78b58c45ee..9fd98cb534186776f25a289bc07b90bbb65e22f3 100644 (file)
@@ -147,7 +147,7 @@ struct fbtft_display {
 /**
  * struct fbtft_platform_data - Passes display specific data to the driver
  * @display: Display properties
- * @gpios: Pointer to an array of piname to gpio mappings
+ * @gpios: Pointer to an array of pinname to gpio mappings
  * @rotate: Display rotation angle
  * @bgr: LCD Controller BGR bit
  * @fps: Frames per second (this will go away, use @fps in @fbtft_display)
@@ -200,7 +200,7 @@ struct fbtft_platform_data {
  * @gpio.cs: LCD Chip Select with parallel interface bus
  * @gpio.db[16]: Parallel databus
  * @gpio.led[16]: Led control signals
- * @gpio.aux[16]: Auxillary signals, not used by core
+ * @gpio.aux[16]: Auxiliary signals, not used by core
  * @init_sequence: Pointer to LCD initialization array
  * @gamma.lock: Mutex for Gamma curve locking
  * @gamma.curves: Pointer to Gamma curve array
@@ -259,9 +259,7 @@ struct fbtft_par {
 #define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))
 
 #define write_reg(par, ...)                                              \
-do {                                                                     \
-       par->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__); \
-} while (0)
+       par->fbtftops.write_register(par, NUMARGS(__VA_ARGS__), __VA_ARGS__)
 
 /* fbtft-core.c */
 extern void fbtft_dbg_hex(const struct device *dev,
@@ -326,8 +324,8 @@ static int fbtft_driver_remove_pdev(struct platform_device *pdev)          \
 }                                                                          \
                                                                           \
 static const struct of_device_id dt_ids[] = {                              \
-        { .compatible = _compatible },                                     \
-        {},                                                                \
+       { .compatible = _compatible },                                     \
+       {},                                                                \
 };                                                                         \
                                                                           \
 MODULE_DEVICE_TABLE(of, dt_ids);                                           \
@@ -337,7 +335,7 @@ static struct spi_driver fbtft_driver_spi_driver = {                       \
        .driver = {                                                        \
                .name   = _name,                                           \
                .owner  = THIS_MODULE,                                     \
-                .of_match_table = of_match_ptr(dt_ids),                    \
+               .of_match_table = of_match_ptr(dt_ids),                    \
        },                                                                 \
        .probe  = fbtft_driver_probe_spi,                                  \
        .remove = fbtft_driver_remove_spi,                                 \
@@ -347,7 +345,7 @@ static struct platform_driver fbtft_driver_platform_driver = {             \
        .driver = {                                                        \
                .name   = _name,                                           \
                .owner  = THIS_MODULE,                                     \
-                .of_match_table = of_match_ptr(dt_ids),                    \
+               .of_match_table = of_match_ptr(dt_ids),                    \
        },                                                                 \
        .probe  = fbtft_driver_probe_pdev,                                 \
        .remove = fbtft_driver_remove_pdev,                                \
index b9f4c30e39c6a3a91882c07078fd948a66390d70..df6cd775ac1eb5eabebf19c782df3488e9ad192c 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[] = {
@@ -463,7 +489,7 @@ static struct fbtft_device_display displays[] = {
                                        .buswidth = 8,
                                        .backlight = 1,
                                },
-                               .startbyte = 0b01110000,
+                               .startbyte = 0x70,
                                .bgr = true,
                                .gpios = (const struct fbtft_gpio []) {
                                        { "reset", 25 },
@@ -484,9 +510,9 @@ static struct fbtft_device_display displays[] = {
                                        .backlight = 1,
                                        .init_sequence = hy28b_init_sequence,
                                },
-                               .startbyte = 0b01110000,
+                               .startbyte = 0x70,
                                .bgr = true,
-                               .fps= 50,
+                               .fps = 50,
                                .gpios = (const struct fbtft_gpio []) {
                                        { "reset", 25 },
                                        { "led", 18 },
@@ -597,7 +623,7 @@ static struct fbtft_device_display displays[] = {
                                        .buswidth = 8,
                                        .backlight = 1,
                                },
-                               .startbyte = 0b01110000,
+                               .startbyte = 0x70,
                                .bgr = true,
                                .gpios = (const struct fbtft_gpio []) {
                                        { "reset", 25 },
@@ -676,6 +702,24 @@ static struct fbtft_device_display displays[] = {
                        }
                }
        }, {
+               .name = "nokia5110",
+               .spi = &(struct spi_board_info) {
+                       .modalias = "fb_ili9163",
+                       .max_speed_hz = 12000000,
+                       .mode = SPI_MODE_0,
+                       .platform_data = &(struct fbtft_platform_data) {
+                               .display = {
+                                       .buswidth = 8,
+                                       .backlight = 1,
+                               },
+                               .bgr = true,
+                               .gpios = (const struct fbtft_gpio []) {
+                                       {},
+                               },
+                       }
+               }
+       }, {
+
                .name = "piscreen",
                .spi = &(struct spi_board_info) {
                        .modalias = "fb_ili9486",
@@ -1100,14 +1144,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
index 90832c36e557e7e122001547344310549c426fd9..ca39fe90d1b8b2d3a9981d64ec0ae4c657b275f4 100644 (file)
@@ -423,7 +423,7 @@ static int flexfb_probe_common(struct spi_device *sdev, struct platform_device *
                        }
                        par->fbtftops.write_register = fbtft_write_reg8_bus9;
                        par->fbtftops.write_vmem = fbtft_write_vmem16_bus9;
-                       sdev->bits_per_word=9;
+                       sdev->bits_per_word = 9;
                        ret = sdev->master->setup(sdev);
                        if (ret) {
                                dev_warn(dev,
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..25433a9
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# 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-bus-driver-objs := mc-bus.o \
+                     mc-sys.o \
+                     dprc.o \
+                     dpmng.o \
+                     dprc-driver.o \
+                     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..35c06cf
--- /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;
+}
+
+/**
+ * check_plugged_state_change - Check change in an MC object's plugged state
+ *
+ * @mc_dev: pointer to the fsl-mc device for a given MC object
+ * @obj_desc: pointer to the MC object's descriptor in the MC
+ *
+ * If the plugged state has changed from unplugged to plugged, the fsl-mc
+ * device is bound to the corresponding device driver.
+ * If the plugged state has changed from plugged to unplugged, the fsl-mc
+ * device is unbound from the corresponding device driver.
+ */
+static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
+                                      struct dprc_obj_desc *obj_desc)
+{
+       int error;
+       uint32_t plugged_flag_at_mc =
+                       (obj_desc->state & DPRC_OBJ_STATE_PLUGGED);
+
+       if (plugged_flag_at_mc !=
+           (mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED)) {
+               if (plugged_flag_at_mc) {
+                       mc_dev->obj_desc.state |= DPRC_OBJ_STATE_PLUGGED;
+                       error = device_attach(&mc_dev->dev);
+                       if (error < 0) {
+                               dev_err(&mc_dev->dev,
+                                       "device_attach() failed: %d\n",
+                                       error);
+                       }
+               } else {
+                       mc_dev->obj_desc.state &= ~DPRC_OBJ_STATE_PLUGGED;
+                       device_release_driver(&mc_dev->dev);
+               }
+       }
+}
+
+/**
+ * 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 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) {
+                       check_plugged_state_change(child_dev, obj_desc);
+                       continue;
+               }
+
+               error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
+                                         &child_dev);
+               if (error < 0)
+                       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);
+}
+
+/**
+ * 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);
+               }
+       }
+
+       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..e36235d
--- /dev/null
@@ -0,0 +1,573 @@
+/*
+ * 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,
+};
+
+int __init fsl_mc_allocator_driver_init(void)
+{
+       return fsl_mc_driver_register(&fsl_mc_allocator_driver);
+}
+
+void __exit fsl_mc_allocator_driver_exit(void)
+{
+       fsl_mc_driver_unregister(&fsl_mc_allocator_driver);
+}
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..23512d0
--- /dev/null
@@ -0,0 +1,793 @@
+/*
+ * 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;
+       bool major_version_mismatch = false;
+       bool minor_version_mismatch = 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) {
+                       if (id->ver_major == mc_dev->obj_desc.ver_major) {
+                               found = true;
+                               if (id->ver_minor != mc_dev->obj_desc.ver_minor)
+                                       minor_version_mismatch = true;
+                       } else {
+                               major_version_mismatch = true;
+                       }
+
+                       break;
+               }
+       }
+
+       if (major_version_mismatch) {
+               dev_warn(dev,
+                        "Major version mismatch: driver version %u.%u, MC object version %u.%u\n",
+                        id->ver_major, id->ver_minor,
+                        mc_dev->obj_desc.ver_major,
+                        mc_dev->obj_desc.ver_minor);
+       } else if (minor_version_mismatch) {
+               dev_warn(dev,
+                        "Minor version mismatch: driver version %u.%u, MC object version %u.%u\n",
+                        id->ver_major, id->ver_minor,
+                        mc_dev->obj_desc.ver_major,
+                        mc_dev->obj_desc.ver_minor);
+       }
+
+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.%d", 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) {
+               mc_bus = to_fsl_mc_bus(mc_dev);
+               if (mc_dev->mc_io) {
+                       fsl_destroy_mc_io(mc_dev->mc_io);
+                       mc_dev->mc_io = NULL;
+               }
+
+               if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
+                       fsl_mc_bus_type.dev_root = 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;
+
+       error = fsl_mc_allocator_driver_init();
+       if (error < 0)
+               goto error_cleanup_dprc_driver;
+
+       return 0;
+
+error_cleanup_dprc_driver:
+       dprc_driver_exit();
+
+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;
+
+       fsl_mc_allocator_driver_exit();
+       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..1b052b8
--- /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 6
+#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..c045f49
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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 __init fsl_mc_allocator_driver_init(void);
+
+void __exit fsl_mc_allocator_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..83683e9a145137cf625549d0926426e0a4b8d229 100644 (file)
@@ -116,7 +116,7 @@ struct dsp_image_info {
 
 void card_bootload(struct net_device *dev)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        unsigned long flags;
        u32 *pdata;
        u32 size;
@@ -148,7 +148,7 @@ void card_bootload(struct net_device *dev)
 
 u16 get_handshake(struct net_device *dev, u16 expected_value)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        u16 handshake;
        u32 tempx;
        int loopcnt;
@@ -182,7 +182,7 @@ u16 get_handshake(struct net_device *dev, u16 expected_value)
 
 void put_handshake(struct net_device *dev, u16 handshake_value)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        u32 tempx;
 
        if (info->AsicID == ELECTRABUZZ_ID) {
@@ -198,7 +198,7 @@ void put_handshake(struct net_device *dev, u16 handshake_value)
 
 u16 get_request_type(struct net_device *dev)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        u16 request_type;
        u32 tempx;
 
@@ -217,7 +217,7 @@ u16 get_request_type(struct net_device *dev)
 
 long get_request_value(struct net_device *dev)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        long value;
        u16 w_val;
 
@@ -246,7 +246,7 @@ long get_request_value(struct net_device *dev)
 
 void put_request_value(struct net_device *dev, long lvalue)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        u16 size;
        u32 tempx;
 
@@ -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;
 }
@@ -285,7 +285,7 @@ u16 hdr_checksum(struct pseudo_hdr *pHdr)
 int card_download(struct net_device *dev, const u8 *pFileStart,
                  size_t FileLength)
 {
-       struct ft1000_info *info = (struct ft1000_info *)netdev_priv(dev);
+       struct ft1000_info *info = netdev_priv(dev);
        int Status = SUCCESS;
        u32 uiState;
        u16 handshake;
@@ -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..eecfa377054dcc88fe50009c9041dd9200db1616 100644 (file)
@@ -28,8 +28,8 @@
 #include <linux/timer.h>
 #include <linux/interrupt.h>
 #include <linux/in.h>
-#include <asm/io.h>
-#include <asm/bitops.h>
+#include <linux/io.h>
+#include <linux/bitops.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -67,8 +67,7 @@ static void ft1000_disable_interrupts(struct net_device *dev);
 
 /* new kernel */
 MODULE_AUTHOR("");
-MODULE_DESCRIPTION
-("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs.");
+MODULE_DESCRIPTION("Support for Flarion Flash OFDM NIC Device. Support for PCMCIA when used with ft1000_cs.");
 MODULE_LICENSE("GPL");
 MODULE_SUPPORTED_DEVICE("FT1000");
 
@@ -267,7 +266,8 @@ void ft1000_write_dpram_mag_32(struct net_device *dev, int offset, u32 value)
 /*---------------------------------------------------------------------------
 
   Function:   ft1000_enable_interrupts
-  Description: This function will enable interrupts base on the current interrupt mask.
+  Description: This function will enable interrupts base on the current
+              interrupt mask.
   Input:
   dev    - device structure
   Output:
@@ -302,6 +302,41 @@ static void ft1000_disable_interrupts(struct net_device *dev)
        pr_debug("current interrupt enable mask = 0x%x\n", tempword);
 }
 
+/*---------------------------------------------------------------------------
+  Function:    ft1000_read_dsp_timer
+  Description: This function reads the DSP timer and stores its value in the
+               DSP_TIME field of the ft1000_info struct passed as argument
+  Input:
+  dev    - device structure
+  info   - ft1000_info structure
+  Output:
+  None.
+
+  -------------------------------------------------------------------------*/
+static void ft1000_read_dsp_timer(struct net_device *dev,
+                                 struct ft1000_info *info)
+{
+       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);
+       }
+}
+
 /*---------------------------------------------------------------------------
 
   Function:   ft1000_reset_asic
@@ -327,7 +362,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 +399,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 +409,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 +422,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 */
@@ -406,7 +441,8 @@ static int ft1000_reset_card(struct net_device *dev)
                                         FT1000_DPRAM_MAG_RX_BASE);
                        for (i = 0; i < MAX_DSP_SESS_REC / 2; i++) {
                                info->DSPSess.MagRec[i] =
-                                       inl(dev->base_addr + FT1000_REG_MAG_DPDATA);
+                                       inl(dev->base_addr
+                                               + FT1000_REG_MAG_DPDATA);
                        }
                }
                spin_unlock_irqrestore(&info->dpram_lock, flags);
@@ -435,11 +471,14 @@ static int ft1000_reset_card(struct net_device *dev)
                mdelay(10);
                pr_debug("Take DSP out of reset\n");
 
-               /* Wait for 0xfefe indicating dsp ready before starting download */
+               /*
+                * Wait for 0xfefe indicating dsp ready before starting
+                * download
+                */
                for (i = 0; i < 50; i++) {
-                       tempword =
-                               ft1000_read_dpram_mag_16(dev, FT1000_MAG_DPRAM_FEFE,
-                                                        FT1000_MAG_DPRAM_FEFE_INDX);
+                       tempword = ft1000_read_dpram_mag_16(dev,
+                                               FT1000_MAG_DPRAM_FEFE,
+                                               FT1000_MAG_DPRAM_FEFE_INDX);
                        if (tempword == 0xfefe)
                                break;
                        mdelay(20);
@@ -459,16 +498,15 @@ 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);
 
        if (info->AsicID == ELECTRABUZZ_ID) {
                /*
-                * Need to initialize the FIFO length counter to zero in order to sync up
-                * with the DSP
+                * Need to initialize the FIFO length counter to zero in order
+                * to sync up with the DSP
                 */
                info->fifo_cnt = 0;
                ft1000_write_dpram(dev, FT1000_FIFO_LEN, info->fifo_cnt);
@@ -578,33 +616,7 @@ static void ft1000_hbchk(u_long data)
                }
                if (tempword != ho) {
                        pr_info("heartbeat failed - no ho detected\n");
-                       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);
-                       }
+                       ft1000_read_dsp_timer(dev, info);
                        info->DrvErrNum = DSP_HB_INFO;
                        if (ft1000_reset_card(dev) == 0) {
                                pr_info("Hardware Failure Detected - PC Card disabled\n");
@@ -625,33 +637,7 @@ static void ft1000_hbchk(u_long data)
 
                if (tempword & FT1000_DB_HB) {
                        pr_info("heartbeat doorbell not clear by firmware\n");
-                       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);
-                       }
+                       ft1000_read_dsp_timer(dev, info);
                        info->DrvErrNum = DSP_HB_INFO;
                        if (ft1000_reset_card(dev) == 0) {
                                pr_info("Hardware Failure Detected - PC Card disabled\n");
@@ -665,8 +651,8 @@ static void ft1000_hbchk(u_long data)
                        return;
                }
                /*
-                * Set dedicated area to hi and ring appropriate doorbell according
-                * to hi/ho heartbeat protocol
+                * Set dedicated area to hi and ring appropriate doorbell
+                * according to hi/ho heartbeat protocol
                 */
                if (info->AsicID == ELECTRABUZZ_ID) {
                        ft1000_write_dpram(dev, FT1000_HI_HO, hi);
@@ -688,44 +674,20 @@ static void ft1000_hbchk(u_long data)
                        if (info->AsicID == ELECTRABUZZ_ID)
                                ft1000_write_dpram(dev, FT1000_HI_HO, hi);
                        else
-                               ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO, hi_mag, FT1000_MAG_HI_HO_INDX);
+                               ft1000_write_dpram_mag_16(dev, FT1000_MAG_HI_HO,
+                                               hi_mag, FT1000_MAG_HI_HO_INDX);
 
                        if (info->AsicID == ELECTRABUZZ_ID)
                                tempword = ft1000_read_dpram(dev, FT1000_HI_HO);
                        else
-                               tempword = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_HI_HO, FT1000_MAG_HI_HO_INDX));
-
+                               tempword = ntohs(ft1000_read_dpram_mag_16(dev,
+                                                       FT1000_MAG_HI_HO,
+                                                       FT1000_MAG_HI_HO_INDX));
                }
 
                if (tempword != hi) {
                        pr_info("heartbeat failed - cannot write hi into DPRAM\n");
-                       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);
-                       }
+                       ft1000_read_dsp_timer(dev, info);
                        info->DrvErrNum = DSP_HB_INFO;
                        if (ft1000_reset_card(dev) == 0) {
                                pr_info("Hardware Failure Detected - PC Card disabled\n");
@@ -756,7 +718,8 @@ static void ft1000_hbchk(u_long data)
   Output:
 
   -------------------------------------------------------------------------*/
-static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size, u16 qtype)
+static void ft1000_send_cmd(struct net_device *dev, u16 *ptempbuffer, int size,
+                           u16 qtype)
 {
        struct ft1000_info *info = netdev_priv(dev);
        int i;
@@ -850,74 +813,73 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer,
        unsigned long flags;
 
        if (info->AsicID == ELECTRABUZZ_ID) {
-               size = (ft1000_read_dpram(dev, *pnxtph)) + sizeof(struct pseudo_hdr);
+               size = ft1000_read_dpram(dev, *pnxtph)
+                       + sizeof(struct pseudo_hdr);
        } else {
-               size =
-                       ntohs(ft1000_read_dpram_mag_16
-                             (dev, FT1000_MAG_PH_LEN,
-                              FT1000_MAG_PH_LEN_INDX)) + sizeof(struct pseudo_hdr);
+               size = ntohs(ft1000_read_dpram_mag_16(dev, FT1000_MAG_PH_LEN,
+                                                     FT1000_MAG_PH_LEN_INDX))
+                               + sizeof(struct pseudo_hdr);
        }
        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;
 }
 
 /*---------------------------------------------------------------------------
@@ -957,7 +919,10 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
 
        if (ft1000_receive_cmd(dev, &cmdbuffer[0], MAX_CMD_SQSIZE, &tempword)) {
 
-               /* Get the message type which is total_len + PSEUDO header + msgtype + message body */
+               /*
+                * Get the message type which is total_len + PSEUDO header
+                * + msgtype + message body
+                */
                pdrvmsg = (struct drv_msg *)&cmdbuffer[0];
                msgtype = ntohs(pdrvmsg->type);
                pr_debug("Command message type = 0x%x\n", msgtype);
@@ -968,8 +933,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                        while (list_empty(&info->prov_list) == 0) {
                                pr_debug("Sending a provisioning message\n");
                                /* Make sure SLOWQ doorbell is clear */
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DOORBELL);
+                               tempword = ft1000_read_reg(dev,
+                                                          FT1000_REG_DOORBELL);
                                i = 0;
                                while (tempword & FT1000_DB_DPRAM_TX) {
                                        mdelay(5);
@@ -977,9 +942,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                                        if (i == 10)
                                                break;
                                }
-                               ptr =
-                                       list_entry(info->prov_list.next,
-                                                  struct prov_record, list);
+                               ptr = list_entry(info->prov_list.next,
+                                                struct prov_record, list);
                                len = *(u16 *)ptr->pprov_data;
                                len = htons(len);
 
@@ -998,14 +962,15 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                                                 ppseudo_hdr->checksum);
                                }
 
-                               ft1000_send_cmd(dev, (u16 *)ptr->pprov_data, len, SLOWQ_TYPE);
+                               ft1000_send_cmd(dev, (u16 *)ptr->pprov_data,
+                                               len, SLOWQ_TYPE);
                                list_del(&ptr->list);
                                kfree(ptr->pprov_data);
                                kfree(ptr);
                        }
                        /*
-                        * Indicate adapter is ready to take application messages after all
-                        * provisioning messages are sent
+                        * Indicate adapter is ready to take application
+                        * messages after all provisioning messages are sent
                         */
                        info->CardReady = 1;
                        break;
@@ -1093,8 +1058,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                        tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
                        if (tempword & FT1000_DB_DPRAM_TX) {
                                mdelay(10);
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DOORBELL);
+                               tempword = ft1000_read_reg(dev,
+                                                          FT1000_REG_DOORBELL);
                                if (tempword & FT1000_DB_DPRAM_TX)
                                        mdelay(10);
                        }
@@ -1129,7 +1094,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;
@@ -1143,8 +1110,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                        tempword = ft1000_read_reg(dev, FT1000_REG_DOORBELL);
                        if (tempword & FT1000_DB_DPRAM_TX) {
                                mdelay(10);
-                               tempword =
-                                       ft1000_read_reg(dev, FT1000_REG_DOORBELL);
+                               tempword = ft1000_read_reg(dev,
+                                                          FT1000_REG_DOORBELL);
                                if (tempword & FT1000_DB_DPRAM_TX)
                                        mdelay(10);
                        }
@@ -1190,7 +1157,8 @@ static void ft1000_proc_drvmsg(struct net_device *dev)
                                *pmsg++ = convert.wrd;
                                *pmsg++ = htons(info->DrvErrNum);
 
-                               ft1000_send_cmd(dev, (u16 *)&tempbuffer[0], (u16)(0x0012), 0);
+                               ft1000_send_cmd(dev, (u16 *)&tempbuffer[0],
+                                               (u16)(0x0012), 0);
                                info->DrvErrNum = 0;
                        }
 
@@ -1281,28 +1249,30 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
                                       FT1000_MAG_TOTAL_LEN_INDX));
                }
                pr_debug("total length = %d\n", total_len);
-               if ((total_len < MAX_CMD_SQSIZE) && (total_len > sizeof(struct pseudo_hdr))) {
+               if ((total_len < MAX_CMD_SQSIZE)
+                               && (total_len > sizeof(struct pseudo_hdr))) {
                        total_len += nxtph;
                        /*
-                        * ft1000_read_reg will return a value that needs to be byteswap
-                        * in order to get DSP_QID_OFFSET.
+                        * ft1000_read_reg will return a value that needs to be
+                        * byteswap in order to get DSP_QID_OFFSET.
                         */
                        if (info->AsicID == ELECTRABUZZ_ID) {
-                               portid =
-                                       (ft1000_read_dpram
-                                        (dev,
-                                         DSP_QID_OFFSET + FT1000_DPRAM_RX_BASE +
-                                         2) >> 8) & 0xff;
+                               portid = (ft1000_read_dpram(dev, DSP_QID_OFFSET
+                                               + FT1000_DPRAM_RX_BASE + 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);
 
                        if (portid == DRIVERID) {
-                               /* We are assumming one driver message from the DSP at a time. */
+                               /*
+                                * We are assumming one driver message from the
+                                * DSP at a time.
+                                */
                                ft1000_proc_drvmsg(dev);
                        }
                }
@@ -1311,29 +1281,7 @@ static int ft1000_parse_dpram_msg(struct net_device *dev)
 
        if (doorbell & FT1000_DB_COND_RESET) {
                /* Reset ASIC and DSP */
-               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);
-               }
+               ft1000_read_dsp_timer(dev, info);
                info->DrvErrNum = DSP_CONDRESET_INFO;
                pr_debug("DSP conditional reset requested\n");
                ft1000_reset_card(dev);
@@ -1374,131 +1322,84 @@ static void ft1000_flush_fifo(struct net_device *dev, u16 DrvErrNum)
        u16 tempword;
 
        if (pcmcia->PktIntfErr > MAX_PH_ERR) {
-               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);
-               }
+               ft1000_read_dsp_timer(dev, info);
                info->DrvErrNum = DrvErrNum;
                ft1000_reset_card(dev);
                return;
-       } else {
-               /* 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);
+       }
+       /* 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)) {
+                       ft1000_read_dsp_timer(dev, info);
+                       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_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) {
-                                       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);
-                               }
+                                       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.
+                                        * This indicates that we can not
+                                        * communicate with the ASIC
                                         */
-                                       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;
-                                       }
+                                       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++;
 }
 
 /*---------------------------------------------------------------------------
@@ -1552,7 +1453,6 @@ static int ft1000_copy_up_pkt(struct net_device *dev)
        skb = dev_alloc_skb(len + 12 + 2);
 
        if (skb == NULL) {
-               pr_debug("No Network buffers available\n");
                /* Read High word to complete 32 bit access */
                if (info->AsicID == MAGNEMITE_ID)
                        tempword = ft1000_read_reg(dev, FT1000_REG_MAG_DFRH);
@@ -1673,7 +1573,8 @@ static int ft1000_copy_up_pkt(struct net_device *dev)
        info->stats.rx_bytes += (len + 12);
 
        if (info->AsicID == ELECTRABUZZ_ID) {
-               /* track how many bytes have been read from FIFO - round up to 16 bit word */
+               /* track how many bytes have been read from FIFO - round up to
+                * 16 bit word */
                tempword = len + 16;
                if (tempword & 0x01)
                        tempword++;
@@ -1737,9 +1638,11 @@ static int ft1000_copy_down_pkt(struct net_device *dev, u16 *packet, u16 len)
        else
                pseudo.blk.length = ntohs(len);
 
-       pseudo.blk.source = DSPID;      /* Need to swap to get in correct order */
+       pseudo.blk.source = DSPID;      /* Need to swap to get in correct
+                                          order */
        pseudo.blk.destination = HOSTID;
-       pseudo.blk.portdest = NETWORKID;        /* Need to swap to get in correct order */
+       pseudo.blk.portdest = NETWORKID;        /* Need to swap to get in
+                                                  correct order */
        pseudo.blk.portsrc = DSPAIRID;
        pseudo.blk.sh_str_id = 0;
        pseudo.blk.control = 0;
@@ -1843,7 +1746,8 @@ static int ft1000_open(struct net_device *dev)
 {
        ft1000_reset_card(dev);
 
-       /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP and ASIC */
+       /* schedule ft1000_hbchk to perform periodic heartbeat checks on DSP
+        * and ASIC */
        init_timer(&poll_timer);
        poll_timer.expires = jiffies + (2 * HZ);
        poll_timer.data = (u_long)dev;
@@ -1928,7 +1832,8 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
        /* Read interrupt type */
        inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
 
-       /* Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type */
+       /* Make sure we process all interrupt before leaving the ISR due to the
+        * edge trigger interrupt type */
        while (inttype) {
                if (inttype & ISR_DOORBELL_PEND)
                        ft1000_parse_dpram_msg(dev);
@@ -1938,21 +1843,18 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
 
                        cnt = 0;
                        do {
-                               /* Check if we have packets in the Downlink FIFO */
+                               /* Check if we have packets in the Downlink
+                                * FIFO */
                                if (info->AsicID == ELECTRABUZZ_ID) {
-                                       tempword =
-                                               ft1000_read_reg(dev,
-                                                               FT1000_REG_DFIFO_STAT);
+                                       tempword = ft1000_read_reg(dev,
+                                                       FT1000_REG_DFIFO_STAT);
                                } else {
-                                       tempword =
-                                               ft1000_read_reg(dev,
-                                                               FT1000_REG_MAG_DFSR);
+                                       tempword = ft1000_read_reg(dev,
+                                                       FT1000_REG_MAG_DFSR);
                                }
-                               if (tempword & 0x1f) {
-                                       ft1000_copy_up_pkt(dev);
-                               } else {
+                               if (!(tempword & 0x1f))
                                        break;
-                               }
+                               ft1000_copy_up_pkt(dev);
                                cnt++;
                        } while (cnt < MAX_RCV_LOOP);
 
@@ -1975,6 +1877,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 +1886,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 +1910,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));
@@ -2038,8 +1941,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
        struct ft1000_pcmcia *pcmcia;
        struct net_device *dev;
 
-       static const struct net_device_ops ft1000ops =          /* Slavius 21.10.2009 due to kernel changes */
-               {
+       static const struct net_device_ops ft1000ops = {
                        .ndo_open = &ft1000_open,
                        .ndo_stop = &ft1000_close,
                        .ndo_start_xmit = &ft1000_start_xmit,
@@ -2102,7 +2004,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
        /* dev->open = &ft1000_open; */
        /* dev->stop = &ft1000_close; */
 
-       dev->netdev_ops = &ft1000ops;           /* Slavius 21.10.2009 due to kernel changes */
+       dev->netdev_ops = &ft1000ops;
 
        pr_debug("device name = %s\n", dev->name);
 
@@ -2113,7 +2015,8 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
                goto err_dev;
        }
 
-       if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
+       if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name,
+                       dev)) {
                netdev_err(dev, "Could not request_irq\n");
                goto err_dev;
        }
@@ -2123,7 +2026,7 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
                goto err_irq;
        }
 
-       if (register_netdev(dev) != 0) {
+       if (register_netdev(dev)) {
                pr_debug("Could not register netdev\n");
                goto err_reg;
        }
@@ -2131,13 +2034,15 @@ struct net_device *init_ft1000_card(struct pcmcia_device *link,
        info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
        if (info->AsicID == ELECTRABUZZ_ID) {
                pr_debug("ELECTRABUZZ ASIC\n");
-               if (request_firmware(&fw_entry, "ft1000.img", &link->dev) != 0) {
+               if (request_firmware(&fw_entry, "ft1000.img",
+                                    &link->dev) != 0) {
                        pr_info("Could not open ft1000.img\n");
                        goto err_unreg;
                }
        } else {
                pr_debug("MAGNEMITE ASIC\n");
-               if (request_firmware(&fw_entry, "ft2000.img", &link->dev) != 0) {
+               if (request_firmware(&fw_entry, "ft2000.img",
+                                    &link->dev) != 0) {
                        pr_info("Could not open ft2000.img\n");
                        goto err_unreg;
                }
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..406758f755ee43ba59231b11c2a618e7e27c19a0 100644 (file)
@@ -871,13 +871,13 @@ static int i2o_block_transfer(struct request *req)
 
        return 0;
 
-      context_remove:
+context_remove:
        i2o_cntxt_list_remove(c, req);
 
-      nop_msg:
+nop_msg:
        i2o_msg_nop(c, msg);
 
-      exit:
+exit:
        return rc;
 };
 
@@ -1002,13 +1002,13 @@ static struct i2o_block_device *i2o_block_device_alloc(void)
 
        return dev;
 
-      cleanup_queue:
+cleanup_queue:
        put_disk(gd);
 
-      cleanup_dev:
+cleanup_dev:
        kfree(dev);
 
-      exit:
+exit:
        return ERR_PTR(rc);
 };
 
@@ -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;
@@ -1115,10 +1115,10 @@ static int i2o_block_probe(struct device *dev)
 
        return 0;
 
-      claim_release:
+claim_release:
        i2o_device_claim_release(i2o_dev);
 
-      exit:
+exit:
        return rc;
 };
 
@@ -1187,16 +1187,16 @@ static int __init i2o_block_init(void)
 
        return 0;
 
-      unregister_blkdev:
+unregister_blkdev:
        unregister_blkdev(I2O_MAJOR, "i2o_block");
 
-      free_mempool:
+free_mempool:
        mempool_destroy(i2o_blk_req_pool.pool);
 
-      free_slab:
+free_slab:
        kmem_cache_destroy(i2o_blk_req_pool.slab);
 
-      exit:
+exit:
        return rc;
 };
 
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)
diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
deleted file mode 100644 (file)
index de4647e..0000000
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Industrialio buffer test code.
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is primarily intended as an example application.
- * Reads the current buffer setup from sysfs and starts a short capture
- * from the specified device, pretty printing the result after appropriate
- * conversion.
- *
- * Command line parameters
- * generic_buffer -n <device_name> -t <trigger_name>
- * If trigger name is not specified the program assumes you want a dataready
- * trigger associated with the device and goes looking for it.
- *
- */
-
-#define _GNU_SOURCE
-
-#include <unistd.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include <linux/types.h>
-#include <string.h>
-#include <poll.h>
-#include <endian.h>
-#include <getopt.h>
-#include <inttypes.h>
-#include "iio_utils.h"
-
-/**
- * size_from_channelarray() - calculate the storage size of a scan
- * @channels:          the channel info array
- * @num_channels:      number of channels
- *
- * Has the side effect of filling the channels[i].location values used
- * in processing the buffer output.
- **/
-int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
-{
-       int bytes = 0;
-       int i = 0;
-
-       while (i < num_channels) {
-               if (bytes % channels[i].bytes == 0)
-                       channels[i].location = bytes;
-               else
-                       channels[i].location = bytes - bytes%channels[i].bytes
-                               + channels[i].bytes;
-               bytes = channels[i].location + channels[i].bytes;
-               i++;
-       }
-       return bytes;
-}
-
-void print2byte(int input, struct iio_channel_info *info)
-{
-       /* First swap if incorrect endian */
-       if (info->be)
-               input = be16toh((uint16_t)input);
-       else
-               input = le16toh((uint16_t)input);
-
-       /*
-        * Shift before conversion to avoid sign extension
-        * of left aligned data
-        */
-       input = input >> info->shift;
-       if (info->is_signed) {
-               int16_t val = input;
-
-               val &= (1 << info->bits_used) - 1;
-               val = (int16_t)(val << (16 - info->bits_used)) >>
-                       (16 - info->bits_used);
-               printf("%05f ", ((float)val + info->offset)*info->scale);
-       } else {
-               uint16_t val = input;
-
-               val &= (1 << info->bits_used) - 1;
-               printf("%05f ", ((float)val + info->offset)*info->scale);
-       }
-}
-/**
- * process_scan() - print out the values in SI units
- * @data:              pointer to the start of the scan
- * @channels:          information about the channels. Note
- *  size_from_channelarray must have been called first to fill the
- *  location offsets.
- * @num_channels:      number of channels
- **/
-void process_scan(char *data,
-                 struct iio_channel_info *channels,
-                 int num_channels)
-{
-       int k;
-
-       for (k = 0; k < num_channels; k++)
-               switch (channels[k].bytes) {
-                       /* only a few cases implemented so far */
-               case 2:
-                       print2byte(*(uint16_t *)(data + channels[k].location),
-                                  &channels[k]);
-                       break;
-               case 4:
-                       if (!channels[k].is_signed) {
-                               uint32_t val = *(uint32_t *)
-                                       (data + channels[k].location);
-                               printf("%05f ", ((float)val +
-                                                channels[k].offset)*
-                                      channels[k].scale);
-
-                       }
-                       break;
-               case 8:
-                       if (channels[k].is_signed) {
-                               int64_t val = *(int64_t *)
-                                       (data +
-                                        channels[k].location);
-                               if ((val >> channels[k].bits_used) & 1)
-                                       val = (val & channels[k].mask) |
-                                               ~channels[k].mask;
-                               /* special case for timestamp */
-                               if (channels[k].scale == 1.0f &&
-                                   channels[k].offset == 0.0f)
-                                       printf("%" PRId64 " ", val);
-                               else
-                                       printf("%05f ", ((float)val +
-                                                        channels[k].offset)*
-                                              channels[k].scale);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       printf("\n");
-}
-
-int main(int argc, char **argv)
-{
-       unsigned long num_loops = 2;
-       unsigned long timedelay = 1000000;
-       unsigned long buf_len = 128;
-
-       int ret, c, i, j, toread;
-       int fp;
-
-       int num_channels;
-       char *trigger_name = NULL, *device_name = NULL;
-       char *dev_dir_name, *buf_dir_name;
-
-       int datardytrigger = 1;
-       char *data;
-       ssize_t read_size;
-       int dev_num, trig_num;
-       char *buffer_access;
-       int scan_size;
-       int noevents = 0;
-       int notrigger = 0;
-       char *dummy;
-
-       struct iio_channel_info *channels;
-
-       while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
-               switch (c) {
-               case 'n':
-                       device_name = optarg;
-                       break;
-               case 't':
-                       trigger_name = optarg;
-                       datardytrigger = 0;
-                       break;
-               case 'e':
-                       noevents = 1;
-                       break;
-               case 'c':
-                       num_loops = strtoul(optarg, &dummy, 10);
-                       break;
-               case 'w':
-                       timedelay = strtoul(optarg, &dummy, 10);
-                       break;
-               case 'l':
-                       buf_len = strtoul(optarg, &dummy, 10);
-                       break;
-               case 'g':
-                       notrigger = 1;
-                       break;
-               case '?':
-                       return -1;
-               }
-       }
-
-       if (device_name == NULL)
-               return -1;
-
-       /* Find the device requested */
-       dev_num = find_type_by_name(device_name, "iio:device");
-       if (dev_num < 0) {
-               printf("Failed to find the %s\n", device_name);
-               ret = -ENODEV;
-               goto error_ret;
-       }
-       printf("iio device number being used is %d\n", dev_num);
-
-       asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
-
-       if (!notrigger) {
-               if (trigger_name == NULL) {
-                       /*
-                        * Build the trigger name. If it is device associated
-                        * its name is <device_name>_dev[n] where n matches
-                        * the device number found above.
-                        */
-                       ret = asprintf(&trigger_name,
-                                      "%s-dev%d", device_name, dev_num);
-                       if (ret < 0) {
-                               ret = -ENOMEM;
-                               goto error_ret;
-                       }
-               }
-
-               /* Verify the trigger exists */
-               trig_num = find_type_by_name(trigger_name, "trigger");
-               if (trig_num < 0) {
-                       printf("Failed to find the trigger %s\n", trigger_name);
-                       ret = -ENODEV;
-                       goto error_free_triggername;
-               }
-               printf("iio trigger number being used is %d\n", trig_num);
-       } else
-               printf("trigger-less mode selected\n");
-
-       /*
-        * Parse the files in scan_elements to identify what channels are
-        * present
-        */
-       ret = build_channel_array(dev_dir_name, &channels, &num_channels);
-       if (ret) {
-               printf("Problem reading scan element information\n");
-               printf("diag %s\n", dev_dir_name);
-               goto error_free_triggername;
-       }
-
-       /*
-        * Construct the directory name for the associated buffer.
-        * As we know that the lis3l02dq has only one buffer this may
-        * be built rather than found.
-        */
-       ret = asprintf(&buf_dir_name,
-                      "%siio:device%d/buffer", iio_dir, dev_num);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_triggername;
-       }
-
-       if (!notrigger) {
-               printf("%s %s\n", dev_dir_name, trigger_name);
-               /* Set the device trigger to be the data ready trigger found
-                * above */
-               ret = write_sysfs_string_and_verify("trigger/current_trigger",
-                                                   dev_dir_name,
-                                                   trigger_name);
-               if (ret < 0) {
-                       printf("Failed to write current_trigger file\n");
-                       goto error_free_buf_dir_name;
-               }
-       }
-
-       /* Setup ring buffer parameters */
-       ret = write_sysfs_int("length", buf_dir_name, buf_len);
-       if (ret < 0)
-               goto error_free_buf_dir_name;
-
-       /* Enable the buffer */
-       ret = write_sysfs_int("enable", buf_dir_name, 1);
-       if (ret < 0)
-               goto error_free_buf_dir_name;
-       scan_size = size_from_channelarray(channels, num_channels);
-       data = malloc(scan_size*buf_len);
-       if (!data) {
-               ret = -ENOMEM;
-               goto error_free_buf_dir_name;
-       }
-
-       ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_data;
-       }
-
-       /* Attempt to open non blocking the access dev */
-       fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
-       if (fp == -1) { /* If it isn't there make the node */
-               printf("Failed to open %s\n", buffer_access);
-               ret = -errno;
-               goto error_free_buffer_access;
-       }
-
-       /* Wait for events 10 times */
-       for (j = 0; j < num_loops; j++) {
-               if (!noevents) {
-                       struct pollfd pfd = {
-                               .fd = fp,
-                               .events = POLLIN,
-                       };
-
-                       poll(&pfd, 1, -1);
-                       toread = buf_len;
-
-               } else {
-                       usleep(timedelay);
-                       toread = 64;
-               }
-
-               read_size = read(fp,
-                                data,
-                                toread*scan_size);
-               if (read_size < 0) {
-                       if (errno == -EAGAIN) {
-                               printf("nothing available\n");
-                               continue;
-                       } else
-                               break;
-               }
-               for (i = 0; i < read_size/scan_size; i++)
-                       process_scan(data + scan_size*i,
-                                    channels,
-                                    num_channels);
-       }
-
-       /* Stop the buffer */
-       ret = write_sysfs_int("enable", buf_dir_name, 0);
-       if (ret < 0)
-               goto error_close_buffer_access;
-
-       if (!notrigger)
-               /* Disconnect the trigger - just write a dummy name. */
-               write_sysfs_string("trigger/current_trigger",
-                                  dev_dir_name, "NULL");
-
-error_close_buffer_access:
-       close(fp);
-error_free_data:
-       free(data);
-error_free_buffer_access:
-       free(buffer_access);
-error_free_buf_dir_name:
-       free(buf_dir_name);
-error_free_triggername:
-       if (datardytrigger)
-               free(trigger_name);
-error_ret:
-       return ret;
-}
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
deleted file mode 100644 (file)
index 72c96aa..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/* Industrialio event test code.
- *
- * Copyright (c) 2011-2012 Lars-Peter Clausen <lars@metafoo.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is primarily intended as an example application.
- * Reads the current buffer setup from sysfs and starts a short capture
- * from the specified device, pretty printing the result after appropriate
- * conversion.
- *
- * Usage:
- *     iio_event_monitor <device_name>
- *
- */
-
-#define _GNU_SOURCE
-
-#include <unistd.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <poll.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include "iio_utils.h"
-#include <linux/iio/events.h>
-
-static const char * const iio_chan_type_name_spec[] = {
-       [IIO_VOLTAGE] = "voltage",
-       [IIO_CURRENT] = "current",
-       [IIO_POWER] = "power",
-       [IIO_ACCEL] = "accel",
-       [IIO_ANGL_VEL] = "anglvel",
-       [IIO_MAGN] = "magn",
-       [IIO_LIGHT] = "illuminance",
-       [IIO_INTENSITY] = "intensity",
-       [IIO_PROXIMITY] = "proximity",
-       [IIO_TEMP] = "temp",
-       [IIO_INCLI] = "incli",
-       [IIO_ROT] = "rot",
-       [IIO_ANGL] = "angl",
-       [IIO_TIMESTAMP] = "timestamp",
-       [IIO_CAPACITANCE] = "capacitance",
-       [IIO_ALTVOLTAGE] = "altvoltage",
-       [IIO_CCT] = "cct",
-       [IIO_PRESSURE] = "pressure",
-       [IIO_HUMIDITYRELATIVE] = "humidityrelative",
-       [IIO_ACTIVITY] = "activity",
-       [IIO_STEPS] = "steps",
-};
-
-static const char * const iio_ev_type_text[] = {
-       [IIO_EV_TYPE_THRESH] = "thresh",
-       [IIO_EV_TYPE_MAG] = "mag",
-       [IIO_EV_TYPE_ROC] = "roc",
-       [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
-       [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
-       [IIO_EV_TYPE_CHANGE] = "change",
-};
-
-static const char * const iio_ev_dir_text[] = {
-       [IIO_EV_DIR_EITHER] = "either",
-       [IIO_EV_DIR_RISING] = "rising",
-       [IIO_EV_DIR_FALLING] = "falling"
-};
-
-static const char * const iio_modifier_names[] = {
-       [IIO_MOD_X] = "x",
-       [IIO_MOD_Y] = "y",
-       [IIO_MOD_Z] = "z",
-       [IIO_MOD_X_AND_Y] = "x&y",
-       [IIO_MOD_X_AND_Z] = "x&z",
-       [IIO_MOD_Y_AND_Z] = "y&z",
-       [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z",
-       [IIO_MOD_X_OR_Y] = "x|y",
-       [IIO_MOD_X_OR_Z] = "x|z",
-       [IIO_MOD_Y_OR_Z] = "y|z",
-       [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z",
-       [IIO_MOD_LIGHT_BOTH] = "both",
-       [IIO_MOD_LIGHT_IR] = "ir",
-       [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
-       [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
-       [IIO_MOD_LIGHT_CLEAR] = "clear",
-       [IIO_MOD_LIGHT_RED] = "red",
-       [IIO_MOD_LIGHT_GREEN] = "green",
-       [IIO_MOD_LIGHT_BLUE] = "blue",
-       [IIO_MOD_QUATERNION] = "quaternion",
-       [IIO_MOD_TEMP_AMBIENT] = "ambient",
-       [IIO_MOD_TEMP_OBJECT] = "object",
-       [IIO_MOD_NORTH_MAGN] = "from_north_magnetic",
-       [IIO_MOD_NORTH_TRUE] = "from_north_true",
-       [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
-       [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
-       [IIO_MOD_RUNNING] = "running",
-       [IIO_MOD_JOGGING] = "jogging",
-       [IIO_MOD_WALKING] = "walking",
-       [IIO_MOD_STILL] = "still",
-};
-
-static bool event_is_known(struct iio_event_data *event)
-{
-       enum iio_chan_type type = IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event->id);
-       enum iio_modifier mod = IIO_EVENT_CODE_EXTRACT_MODIFIER(event->id);
-       enum iio_event_type ev_type = IIO_EVENT_CODE_EXTRACT_TYPE(event->id);
-       enum iio_event_direction dir = IIO_EVENT_CODE_EXTRACT_DIR(event->id);
-
-       switch (type) {
-       case IIO_VOLTAGE:
-       case IIO_CURRENT:
-       case IIO_POWER:
-       case IIO_ACCEL:
-       case IIO_ANGL_VEL:
-       case IIO_MAGN:
-       case IIO_LIGHT:
-       case IIO_INTENSITY:
-       case IIO_PROXIMITY:
-       case IIO_TEMP:
-       case IIO_INCLI:
-       case IIO_ROT:
-       case IIO_ANGL:
-       case IIO_TIMESTAMP:
-       case IIO_CAPACITANCE:
-       case IIO_ALTVOLTAGE:
-       case IIO_CCT:
-       case IIO_PRESSURE:
-       case IIO_HUMIDITYRELATIVE:
-       case IIO_ACTIVITY:
-       case IIO_STEPS:
-               break;
-       default:
-               return false;
-       }
-
-       switch (mod) {
-       case IIO_NO_MOD:
-       case IIO_MOD_X:
-       case IIO_MOD_Y:
-       case IIO_MOD_Z:
-       case IIO_MOD_X_AND_Y:
-       case IIO_MOD_X_AND_Z:
-       case IIO_MOD_Y_AND_Z:
-       case IIO_MOD_X_AND_Y_AND_Z:
-       case IIO_MOD_X_OR_Y:
-       case IIO_MOD_X_OR_Z:
-       case IIO_MOD_Y_OR_Z:
-       case IIO_MOD_X_OR_Y_OR_Z:
-       case IIO_MOD_LIGHT_BOTH:
-       case IIO_MOD_LIGHT_IR:
-       case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
-       case IIO_MOD_SUM_SQUARED_X_Y_Z:
-       case IIO_MOD_LIGHT_CLEAR:
-       case IIO_MOD_LIGHT_RED:
-       case IIO_MOD_LIGHT_GREEN:
-       case IIO_MOD_LIGHT_BLUE:
-       case IIO_MOD_QUATERNION:
-       case IIO_MOD_TEMP_AMBIENT:
-       case IIO_MOD_TEMP_OBJECT:
-       case IIO_MOD_NORTH_MAGN:
-       case IIO_MOD_NORTH_TRUE:
-       case IIO_MOD_NORTH_MAGN_TILT_COMP:
-       case IIO_MOD_NORTH_TRUE_TILT_COMP:
-       case IIO_MOD_RUNNING:
-       case IIO_MOD_JOGGING:
-       case IIO_MOD_WALKING:
-       case IIO_MOD_STILL:
-               break;
-       default:
-               return false;
-       }
-
-       switch (ev_type) {
-       case IIO_EV_TYPE_THRESH:
-       case IIO_EV_TYPE_MAG:
-       case IIO_EV_TYPE_ROC:
-       case IIO_EV_TYPE_THRESH_ADAPTIVE:
-       case IIO_EV_TYPE_MAG_ADAPTIVE:
-       case IIO_EV_TYPE_CHANGE:
-               break;
-       default:
-               return false;
-       }
-
-       switch (dir) {
-       case IIO_EV_DIR_EITHER:
-       case IIO_EV_DIR_RISING:
-       case IIO_EV_DIR_FALLING:
-       case IIO_EV_DIR_NONE:
-               break;
-       default:
-               return false;
-       }
-
-       return true;
-}
-
-static void print_event(struct iio_event_data *event)
-{
-       enum iio_chan_type type = IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event->id);
-       enum iio_modifier mod = IIO_EVENT_CODE_EXTRACT_MODIFIER(event->id);
-       enum iio_event_type ev_type = IIO_EVENT_CODE_EXTRACT_TYPE(event->id);
-       enum iio_event_direction dir = IIO_EVENT_CODE_EXTRACT_DIR(event->id);
-       int chan = IIO_EVENT_CODE_EXTRACT_CHAN(event->id);
-       int chan2 = IIO_EVENT_CODE_EXTRACT_CHAN2(event->id);
-       bool diff = IIO_EVENT_CODE_EXTRACT_DIFF(event->id);
-
-       if (!event_is_known(event)) {
-               printf("Unknown event: time: %lld, id: %llx\n",
-                               event->timestamp, event->id);
-               return;
-       }
-
-       printf("Event: time: %lld, ", event->timestamp);
-
-       if (mod != IIO_NO_MOD) {
-               printf("type: %s(%s), ",
-                       iio_chan_type_name_spec[type],
-                       iio_modifier_names[mod]);
-       } else {
-               printf("type: %s, ",
-                       iio_chan_type_name_spec[type]);
-       }
-
-       if (diff && chan >= 0 && chan2 >= 0)
-               printf("channel: %d-%d, ", chan, chan2);
-       else if (chan >= 0)
-               printf("channel: %d, ", chan);
-
-       printf("evtype: %s", iio_ev_type_text[ev_type]);
-
-       if (dir != IIO_EV_DIR_NONE)
-               printf(", direction: %s", iio_ev_dir_text[dir]);
-       printf("\n");
-}
-
-int main(int argc, char **argv)
-{
-       struct iio_event_data event;
-       const char *device_name;
-       char *chrdev_name;
-       int ret;
-       int dev_num;
-       int fd, event_fd;
-
-       if (argc <= 1) {
-               printf("Usage: %s <device_name>\n", argv[0]);
-               return -1;
-       }
-
-       device_name = argv[1];
-
-       dev_num = find_type_by_name(device_name, "iio:device");
-       if (dev_num >= 0) {
-               printf("Found IIO device with name %s with device number %d\n",
-                       device_name, dev_num);
-               ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num);
-               if (ret < 0) {
-                       ret = -ENOMEM;
-                       goto error_ret;
-               }
-       } else {
-               /* If we can't find a IIO device by name assume device_name is a
-                  IIO chrdev */
-               chrdev_name = strdup(device_name);
-       }
-
-       fd = open(chrdev_name, 0);
-       if (fd == -1) {
-               fprintf(stdout, "Failed to open %s\n", chrdev_name);
-               ret = -errno;
-               goto error_free_chrdev_name;
-       }
-
-       ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
-
-       close(fd);
-
-       if (ret == -1 || event_fd == -1) {
-               fprintf(stdout, "Failed to retrieve event fd\n");
-               ret = -errno;
-               goto error_free_chrdev_name;
-       }
-
-       while (true) {
-               ret = read(event_fd, &event, sizeof(event));
-               if (ret == -1) {
-                       if (errno == EAGAIN) {
-                               printf("nothing available\n");
-                               continue;
-                       } else {
-                               perror("Failed to read event from device");
-                               ret = -errno;
-                               break;
-                       }
-               }
-
-               print_event(&event);
-       }
-
-       close(event_fd);
-error_free_chrdev_name:
-       free(chrdev_name);
-error_ret:
-       return ret;
-}
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
deleted file mode 100644 (file)
index 568eff0..0000000
+++ /dev/null
@@ -1,683 +0,0 @@
-/* IIO - useful set of util functionality
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <dirent.h>
-#include <errno.h>
-
-/* Made up value to limit allocation sizes */
-#define IIO_MAX_NAME_LENGTH 30
-
-#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
-#define FORMAT_TYPE_FILE "%s_type"
-
-const char *iio_dir = "/sys/bus/iio/devices/";
-
-/**
- * iioutils_break_up_name() - extract generic name from full channel name
- * @full_name: the full channel name
- * @generic_name: the output generic channel name
- **/
-inline int iioutils_break_up_name(const char *full_name,
-                                 char **generic_name)
-{
-       char *current;
-       char *w, *r;
-       char *working;
-
-       current = strdup(full_name);
-       working = strtok(current, "_\0");
-       w = working;
-       r = working;
-
-       while (*r != '\0') {
-               if (!isdigit(*r)) {
-                       *w = *r;
-                       w++;
-               }
-               r++;
-       }
-       *w = '\0';
-       *generic_name = strdup(working);
-       free(current);
-
-       return 0;
-}
-
-/**
- * struct iio_channel_info - information about a given channel
- * @name: channel name
- * @generic_name: general name for channel type
- * @scale: scale factor to be applied for conversion to si units
- * @offset: offset to be applied for conversion to si units
- * @index: the channel index in the buffer output
- * @bytes: number of bytes occupied in buffer output
- * @mask: a bit mask for the raw output
- * @is_signed: is the raw value stored signed
- * @enabled: is this channel enabled
- **/
-struct iio_channel_info {
-       char *name;
-       char *generic_name;
-       float scale;
-       float offset;
-       unsigned index;
-       unsigned bytes;
-       unsigned bits_used;
-       unsigned shift;
-       uint64_t mask;
-       unsigned be;
-       unsigned is_signed;
-       unsigned location;
-};
-
-/**
- * iioutils_get_type() - find and process _type attribute data
- * @is_signed: output whether channel is signed
- * @bytes: output how many bytes the channel storage occupies
- * @mask: output a bit mask for the raw data
- * @be: big endian
- * @device_dir: the iio device directory
- * @name: the channel name
- * @generic_name: the channel type name
- **/
-inline int iioutils_get_type(unsigned *is_signed,
-                            unsigned *bytes,
-                            unsigned *bits_used,
-                            unsigned *shift,
-                            uint64_t *mask,
-                            unsigned *be,
-                            const char *device_dir,
-                            const char *name,
-                            const char *generic_name)
-{
-       FILE *sysfsfp;
-       int ret;
-       DIR *dp;
-       char *scan_el_dir, *builtname, *builtname_generic, *filename = 0;
-       char signchar, endianchar;
-       unsigned padint;
-       const struct dirent *ent;
-
-       ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-       ret = asprintf(&builtname, FORMAT_TYPE_FILE, name);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_scan_el_dir;
-       }
-       ret = asprintf(&builtname_generic, FORMAT_TYPE_FILE, generic_name);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_builtname;
-       }
-
-       dp = opendir(scan_el_dir);
-       if (dp == NULL) {
-               ret = -errno;
-               goto error_free_builtname_generic;
-       }
-       while (ent = readdir(dp), ent != NULL)
-               /*
-                * Do we allow devices to override a generic name with
-                * a specific one?
-                */
-               if ((strcmp(builtname, ent->d_name) == 0) ||
-                   (strcmp(builtname_generic, ent->d_name) == 0)) {
-                       ret = asprintf(&filename,
-                                      "%s/%s", scan_el_dir, ent->d_name);
-                       if (ret < 0) {
-                               ret = -ENOMEM;
-                               goto error_closedir;
-                       }
-                       sysfsfp = fopen(filename, "r");
-                       if (sysfsfp == NULL) {
-                               printf("failed to open %s\n", filename);
-                               ret = -errno;
-                               goto error_free_filename;
-                       }
-
-                       ret = fscanf(sysfsfp,
-                                    "%ce:%c%u/%u>>%u",
-                                    &endianchar,
-                                    &signchar,
-                                    bits_used,
-                                    &padint, shift);
-                       if (ret < 0) {
-                               printf("failed to pass scan type description\n");
-                               ret = -errno;
-                               goto error_close_sysfsfp;
-                       }
-                       *be = (endianchar == 'b');
-                       *bytes = padint / 8;
-                       if (*bits_used == 64)
-                               *mask = ~0;
-                       else
-                               *mask = (1 << *bits_used) - 1;
-                       if (signchar == 's')
-                               *is_signed = 1;
-                       else
-                               *is_signed = 0;
-                       fclose(sysfsfp);
-                       free(filename);
-
-                       filename = 0;
-                       sysfsfp = 0;
-               }
-error_close_sysfsfp:
-       if (sysfsfp)
-               fclose(sysfsfp);
-error_free_filename:
-       if (filename)
-               free(filename);
-error_closedir:
-       closedir(dp);
-error_free_builtname_generic:
-       free(builtname_generic);
-error_free_builtname:
-       free(builtname);
-error_free_scan_el_dir:
-       free(scan_el_dir);
-error_ret:
-       return ret;
-}
-
-inline int iioutils_get_param_float(float *output,
-                                   const char *param_name,
-                                   const char *device_dir,
-                                   const char *name,
-                                   const char *generic_name)
-{
-       FILE *sysfsfp;
-       int ret;
-       DIR *dp;
-       char *builtname, *builtname_generic;
-       char *filename = NULL;
-       const struct dirent *ent;
-
-       ret = asprintf(&builtname, "%s_%s", name, param_name);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-       ret = asprintf(&builtname_generic,
-                      "%s_%s", generic_name, param_name);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_free_builtname;
-       }
-       dp = opendir(device_dir);
-       if (dp == NULL) {
-               ret = -errno;
-               goto error_free_builtname_generic;
-       }
-       while (ent = readdir(dp), ent != NULL)
-               if ((strcmp(builtname, ent->d_name) == 0) ||
-                   (strcmp(builtname_generic, ent->d_name) == 0)) {
-                       ret = asprintf(&filename,
-                                      "%s/%s", device_dir, ent->d_name);
-                       if (ret < 0) {
-                               ret = -ENOMEM;
-                               goto error_closedir;
-                       }
-                       sysfsfp = fopen(filename, "r");
-                       if (!sysfsfp) {
-                               ret = -errno;
-                               goto error_free_filename;
-                       }
-                       fscanf(sysfsfp, "%f", output);
-                       break;
-               }
-error_free_filename:
-       if (filename)
-               free(filename);
-error_closedir:
-       closedir(dp);
-error_free_builtname_generic:
-       free(builtname_generic);
-error_free_builtname:
-       free(builtname);
-error_ret:
-       return ret;
-}
-
-/**
- * bsort_channel_array_by_index() - reorder so that the array is in index order
- *
- **/
-
-inline void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
-                                        int cnt)
-{
-
-       struct iio_channel_info temp;
-       int x, y;
-
-       for (x = 0; x < cnt; x++)
-               for (y = 0; y < (cnt - 1); y++)
-                       if ((*ci_array)[y].index > (*ci_array)[y+1].index) {
-                               temp = (*ci_array)[y + 1];
-                               (*ci_array)[y + 1] = (*ci_array)[y];
-                               (*ci_array)[y] = temp;
-                       }
-}
-
-/**
- * build_channel_array() - function to figure out what channels are present
- * @device_dir: the IIO device directory in sysfs
- * @
- **/
-inline int build_channel_array(const char *device_dir,
-                             struct iio_channel_info **ci_array,
-                             int *counter)
-{
-       DIR *dp;
-       FILE *sysfsfp;
-       int count, i;
-       struct iio_channel_info *current;
-       int ret;
-       const struct dirent *ent;
-       char *scan_el_dir;
-       char *filename;
-
-       *counter = 0;
-       ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
-       if (ret < 0) {
-               ret = -ENOMEM;
-               goto error_ret;
-       }
-       dp = opendir(scan_el_dir);
-       if (dp == NULL) {
-               ret = -errno;
-               goto error_free_name;
-       }
-       while (ent = readdir(dp), ent != NULL)
-               if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
-                          "_en") == 0) {
-                       ret = asprintf(&filename,
-                                      "%s/%s", scan_el_dir, ent->d_name);
-                       if (ret < 0) {
-                               ret = -ENOMEM;
-                               goto error_close_dir;
-                       }
-                       sysfsfp = fopen(filename, "r");
-                       if (sysfsfp == NULL) {
-                               ret = -errno;
-                               free(filename);
-                               goto error_close_dir;
-                       }
-                       fscanf(sysfsfp, "%i", &ret);
-                       if (ret == 1)
-                               (*counter)++;
-                       fclose(sysfsfp);
-                       free(filename);
-               }
-       *ci_array = malloc(sizeof(**ci_array) * (*counter));
-       if (*ci_array == NULL) {
-               ret = -ENOMEM;
-               goto error_close_dir;
-       }
-       seekdir(dp, 0);
-       count = 0;
-       while (ent = readdir(dp), ent != NULL) {
-               if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
-                          "_en") == 0) {
-                       int current_enabled = 0;
-
-                       current = &(*ci_array)[count++];
-                       ret = asprintf(&filename,
-                                      "%s/%s", scan_el_dir, ent->d_name);
-                       if (ret < 0) {
-                               ret = -ENOMEM;
-                               /* decrement count to avoid freeing name */
-                               count--;
-                               goto error_cleanup_array;
-                       }
-                       sysfsfp = fopen(filename, "r");
-                       if (sysfsfp == NULL) {
-                               free(filename);
-                               ret = -errno;
-                               goto error_cleanup_array;
-                       }
-                       fscanf(sysfsfp, "%i", &current_enabled);
-                       fclose(sysfsfp);
-
-                       if (!current_enabled) {
-                               free(filename);
-                               count--;
-                               continue;
-                       }
-
-                       current->scale = 1.0;
-                       current->offset = 0;
-                       current->name = strndup(ent->d_name,
-                                               strlen(ent->d_name) -
-                                               strlen("_en"));
-                       if (current->name == NULL) {
-                               free(filename);
-                               ret = -ENOMEM;
-                               goto error_cleanup_array;
-                       }
-                       /* Get the generic and specific name elements */
-                       ret = iioutils_break_up_name(current->name,
-                                                    &current->generic_name);
-                       if (ret) {
-                               free(filename);
-                               goto error_cleanup_array;
-                       }
-                       ret = asprintf(&filename,
-                                      "%s/%s_index",
-                                      scan_el_dir,
-                                      current->name);
-                       if (ret < 0) {
-                               free(filename);
-                               ret = -ENOMEM;
-                               goto error_cleanup_array;
-                       }
-                       sysfsfp = fopen(filename, "r");
-                       fscanf(sysfsfp, "%u", &current->index);
-                       fclose(sysfsfp);
-                       free(filename);
-                       /* Find the scale */
-                       ret = iioutils_get_param_float(&current->scale,
-                                                      "scale",
-                                                      device_dir,
-                                                      current->name,
-                                                      current->generic_name);
-                       if (ret < 0)
-                               goto error_cleanup_array;
-                       ret = iioutils_get_param_float(&current->offset,
-                                                      "offset",
-                                                      device_dir,
-                                                      current->name,
-                                                      current->generic_name);
-                       if (ret < 0)
-                               goto error_cleanup_array;
-                       ret = iioutils_get_type(&current->is_signed,
-                                               &current->bytes,
-                                               &current->bits_used,
-                                               &current->shift,
-                                               &current->mask,
-                                               &current->be,
-                                               device_dir,
-                                               current->name,
-                                               current->generic_name);
-               }
-       }
-
-       closedir(dp);
-       /* reorder so that the array is in index order */
-       bsort_channel_array_by_index(ci_array, *counter);
-
-       return 0;
-
-error_cleanup_array:
-       for (i = count - 1;  i >= 0; i--)
-               free((*ci_array)[i].name);
-       free(*ci_array);
-error_close_dir:
-       closedir(dp);
-error_free_name:
-       free(scan_el_dir);
-error_ret:
-       return ret;
-}
-
-/**
- * find_type_by_name() - function to match top level types by name
- * @name: top level type instance name
- * @type: the type of top level instance being sort
- *
- * Typical types this is used for are device and trigger.
- **/
-inline int find_type_by_name(const char *name, const char *type)
-{
-       const struct dirent *ent;
-       int number, numstrlen;
-
-       FILE *nameFile;
-       DIR *dp;
-       char thisname[IIO_MAX_NAME_LENGTH];
-       char *filename;
-
-       dp = opendir(iio_dir);
-       if (dp == NULL) {
-               printf("No industrialio devices available\n");
-               return -ENODEV;
-       }
-
-       while (ent = readdir(dp), ent != NULL) {
-               if (strcmp(ent->d_name, ".") != 0 &&
-                       strcmp(ent->d_name, "..") != 0 &&
-                       strlen(ent->d_name) > strlen(type) &&
-                       strncmp(ent->d_name, type, strlen(type)) == 0) {
-                       numstrlen = sscanf(ent->d_name + strlen(type),
-                                          "%d",
-                                          &number);
-                       /* verify the next character is not a colon */
-                       if (strncmp(ent->d_name + strlen(type) + numstrlen,
-                                       ":",
-                                       1) != 0) {
-                               filename = malloc(strlen(iio_dir)
-                                               + strlen(type)
-                                               + numstrlen
-                                               + 6);
-                               if (filename == NULL) {
-                                       closedir(dp);
-                                       return -ENOMEM;
-                               }
-                               sprintf(filename, "%s%s%d/name",
-                                       iio_dir,
-                                       type,
-                                       number);
-                               nameFile = fopen(filename, "r");
-                               if (!nameFile) {
-                                       free(filename);
-                                       continue;
-                               }
-                               free(filename);
-                               fscanf(nameFile, "%s", thisname);
-                               fclose(nameFile);
-                               if (strcmp(name, thisname) == 0) {
-                                       closedir(dp);
-                                       return number;
-                               }
-                       }
-               }
-       }
-       closedir(dp);
-       return -ENODEV;
-}
-
-inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
-{
-       int ret = 0;
-       FILE *sysfsfp;
-       int test;
-       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
-
-       if (temp == NULL)
-               return -ENOMEM;
-       sprintf(temp, "%s/%s", basedir, filename);
-       sysfsfp = fopen(temp, "w");
-       if (sysfsfp == NULL) {
-               printf("failed to open %s\n", temp);
-               ret = -errno;
-               goto error_free;
-       }
-       fprintf(sysfsfp, "%d", val);
-       fclose(sysfsfp);
-       if (verify) {
-               sysfsfp = fopen(temp, "r");
-               if (sysfsfp == NULL) {
-                       printf("failed to open %s\n", temp);
-                       ret = -errno;
-                       goto error_free;
-               }
-               fscanf(sysfsfp, "%d", &test);
-               fclose(sysfsfp);
-               if (test != val) {
-                       printf("Possible failure in int write %d to %s%s\n",
-                               val,
-                               basedir,
-                               filename);
-                       ret = -1;
-               }
-       }
-error_free:
-       free(temp);
-       return ret;
-}
-
-int write_sysfs_int(char *filename, char *basedir, int val)
-{
-       return _write_sysfs_int(filename, basedir, val, 0);
-}
-
-int write_sysfs_int_and_verify(char *filename, char *basedir, int val)
-{
-       return _write_sysfs_int(filename, basedir, val, 1);
-}
-
-int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
-{
-       int ret = 0;
-       FILE  *sysfsfp;
-       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
-
-       if (temp == NULL) {
-               printf("Memory allocation failed\n");
-               return -ENOMEM;
-       }
-       sprintf(temp, "%s/%s", basedir, filename);
-       sysfsfp = fopen(temp, "w");
-       if (sysfsfp == NULL) {
-               printf("Could not open %s\n", temp);
-               ret = -errno;
-               goto error_free;
-       }
-       fprintf(sysfsfp, "%s", val);
-       fclose(sysfsfp);
-       if (verify) {
-               sysfsfp = fopen(temp, "r");
-               if (sysfsfp == NULL) {
-                       printf("could not open file to verify\n");
-                       ret = -errno;
-                       goto error_free;
-               }
-               fscanf(sysfsfp, "%s", temp);
-               fclose(sysfsfp);
-               if (strcmp(temp, val) != 0) {
-                       printf("Possible failure in string write of %s "
-                               "Should be %s "
-                               "written to %s\%s\n",
-                               temp,
-                               val,
-                               basedir,
-                               filename);
-                       ret = -1;
-               }
-       }
-error_free:
-       free(temp);
-
-       return ret;
-}
-
-/**
- * write_sysfs_string_and_verify() - string write, readback and verify
- * @filename: name of file to write to
- * @basedir: the sysfs directory in which the file is to be found
- * @val: the string to write
- **/
-int write_sysfs_string_and_verify(char *filename, char *basedir, char *val)
-{
-       return _write_sysfs_string(filename, basedir, val, 1);
-}
-
-int write_sysfs_string(char *filename, char *basedir, char *val)
-{
-       return _write_sysfs_string(filename, basedir, val, 0);
-}
-
-int read_sysfs_posint(char *filename, char *basedir)
-{
-       int ret;
-       FILE  *sysfsfp;
-       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
-
-       if (temp == NULL) {
-               printf("Memory allocation failed");
-               return -ENOMEM;
-       }
-       sprintf(temp, "%s/%s", basedir, filename);
-       sysfsfp = fopen(temp, "r");
-       if (sysfsfp == NULL) {
-               ret = -errno;
-               goto error_free;
-       }
-       fscanf(sysfsfp, "%d\n", &ret);
-       fclose(sysfsfp);
-error_free:
-       free(temp);
-       return ret;
-}
-
-int read_sysfs_float(char *filename, char *basedir, float *val)
-{
-       int ret = 0;
-       FILE  *sysfsfp;
-       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
-
-       if (temp == NULL) {
-               printf("Memory allocation failed");
-               return -ENOMEM;
-       }
-       sprintf(temp, "%s/%s", basedir, filename);
-       sysfsfp = fopen(temp, "r");
-       if (sysfsfp == NULL) {
-               ret = -errno;
-               goto error_free;
-       }
-       fscanf(sysfsfp, "%f\n", val);
-       fclose(sysfsfp);
-error_free:
-       free(temp);
-       return ret;
-}
-
-int read_sysfs_string(const char *filename, const char *basedir, char *str)
-{
-       int ret = 0;
-       FILE  *sysfsfp;
-       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
-
-       if (temp == NULL) {
-               printf("Memory allocation failed");
-               return -ENOMEM;
-       }
-       sprintf(temp, "%s/%s", basedir, filename);
-       sysfsfp = fopen(temp, "r");
-       if (sysfsfp == NULL) {
-               ret = -errno;
-               goto error_free;
-       }
-       fscanf(sysfsfp, "%s\n", str);
-       fclose(sysfsfp);
-error_free:
-       free(temp);
-       return ret;
-}
diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c
deleted file mode 100644 (file)
index 98a0de0..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Industrial I/O utilities - lsiio.c
- *
- * Copyright (c) 2010 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#include <string.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include "iio_utils.h"
-
-
-static enum verbosity {
-       VERBLEVEL_DEFAULT,      /* 0 gives lspci behaviour */
-       VERBLEVEL_SENSORS,      /* 1 lists sensors */
-} verblevel = VERBLEVEL_DEFAULT;
-
-const char *type_device = "iio:device";
-const char *type_trigger = "trigger";
-
-
-static inline int check_prefix(const char *str, const char *prefix)
-{
-       return strlen(str) > strlen(prefix) &&
-               strncmp(str, prefix, strlen(prefix)) == 0;
-}
-
-static inline int check_postfix(const char *str, const char *postfix)
-{
-       return strlen(str) > strlen(postfix) &&
-               strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
-}
-
-static int dump_channels(const char *dev_dir_name)
-{
-       DIR *dp;
-       const struct dirent *ent;
-
-       dp = opendir(dev_dir_name);
-       if (dp == NULL)
-               return -errno;
-       while (ent = readdir(dp), ent != NULL)
-               if (check_prefix(ent->d_name, "in_") &&
-                   check_postfix(ent->d_name, "_raw")) {
-                       printf("   %-10s\n", ent->d_name);
-               }
-
-       return 0;
-}
-
-static int dump_one_device(const char *dev_dir_name)
-{
-       char name[IIO_MAX_NAME_LENGTH];
-       int dev_idx;
-       int retval;
-
-       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device),
-                       "%i", &dev_idx);
-       if (retval != 1)
-               return -EINVAL;
-       read_sysfs_string("name", dev_dir_name, name);
-       printf("Device %03d: %s\n", dev_idx, name);
-
-       if (verblevel >= VERBLEVEL_SENSORS)
-               return dump_channels(dev_dir_name);
-       return 0;
-}
-
-static int dump_one_trigger(const char *dev_dir_name)
-{
-       char name[IIO_MAX_NAME_LENGTH];
-       int dev_idx;
-       int retval;
-
-       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
-                       "%i", &dev_idx);
-       if (retval != 1)
-               return -EINVAL;
-       read_sysfs_string("name", dev_dir_name, name);
-       printf("Trigger %03d: %s\n", dev_idx, name);
-       return 0;
-}
-
-static void dump_devices(void)
-{
-       const struct dirent *ent;
-       int number, numstrlen;
-
-       FILE *nameFile;
-       DIR *dp;
-       char thisname[IIO_MAX_NAME_LENGTH];
-       char *filename;
-
-       dp = opendir(iio_dir);
-       if (dp == NULL) {
-               printf("No industrial I/O devices available\n");
-               return;
-       }
-
-       while (ent = readdir(dp), ent != NULL) {
-               if (check_prefix(ent->d_name, type_device)) {
-                       char *dev_dir_name;
-
-                       asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
-                       dump_one_device(dev_dir_name);
-                       free(dev_dir_name);
-                       if (verblevel >= VERBLEVEL_SENSORS)
-                               printf("\n");
-               }
-       }
-       rewinddir(dp);
-       while (ent = readdir(dp), ent != NULL) {
-               if (check_prefix(ent->d_name, type_trigger)) {
-                       char *dev_dir_name;
-
-                       asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
-                       dump_one_trigger(dev_dir_name);
-                       free(dev_dir_name);
-               }
-       }
-       closedir(dp);
-}
-
-int main(int argc, char **argv)
-{
-       int c, err = 0;
-
-       while ((c = getopt(argc, argv, "d:D:v")) != EOF) {
-               switch (c) {
-               case 'v':
-                       verblevel++;
-                       break;
-
-               case '?':
-               default:
-                       err++;
-                       break;
-               }
-       }
-       if (err || argc > optind) {
-               fprintf(stderr, "Usage: lsiio [options]...\n"
-                       "List industrial I/O devices\n"
-                       "  -v, --verbose\n"
-                       "      Increase verbosity (may be given multiple times)\n"
-                       );
-               exit(1);
-       }
-
-       dump_devices();
-
-       return 0;
-}
index 8747de5a98055b9bba8fdda9b18146bfd51beea1..e6b8c9af6e222007dea910a5d34f9bb71ad5a59e 100644 (file)
 #define ADIS16201_GLOB_CMD       0x3E /* Operation, system command register */
 
 /* MSC_CTRL */
-#define ADIS16201_MSC_CTRL_SELF_TEST_EN                (1 << 8)  /* Self-test enable */
-#define ADIS16201_MSC_CTRL_DATA_RDY_EN         (1 << 2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16201_MSC_CTRL_ACTIVE_HIGH         (1 << 1)  /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1       (1 << 0)  /* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
+#define ADIS16201_MSC_CTRL_SELF_TEST_EN                BIT(8)  /* Self-test enable */
+#define ADIS16201_MSC_CTRL_DATA_RDY_EN         BIT(2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16201_MSC_CTRL_ACTIVE_HIGH         BIT(1)  /* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1       BIT(0)  /* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
 
 /* DIAG_STAT */
-#define ADIS16201_DIAG_STAT_ALARM2        (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16201_DIAG_STAT_ALARM1        (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16201_DIAG_STAT_ALARM2        BIT(9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16201_DIAG_STAT_ALARM1        BIT(8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
 #define ADIS16201_DIAG_STAT_SPI_FAIL_BIT   3 /* SPI communications failure */
 #define ADIS16201_DIAG_STAT_FLASH_UPT_BIT  2 /* Flash update failure */
 #define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1 /* Power supply above 3.625 V */
 #define ADIS16201_DIAG_STAT_POWER_LOW_BIT  0 /* Power supply below 3.15 V */
 
 /* GLOB_CMD */
-#define ADIS16201_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16201_GLOB_CMD_FACTORY_CAL (1<<1)
+#define ADIS16201_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1)
 
-#define ADIS16201_ERROR_ACTIVE          (1<<14)
+#define ADIS16201_ERROR_ACTIVE          BIT(14)
 
 enum adis16201_scan {
        ADIS16201_SCAN_ACC_X,
index 7eae5fd0f39339c139c68e5f7cfb39ad8904d034..10db685813c9b839a9f837726eeab1ed56fae13c 100644 (file)
@@ -135,14 +135,14 @@ static const struct iio_chan_spec adis16201_channels[] = {
        ADIS_SUPPLY_CHAN(ADIS16201_SUPPLY_OUT, ADIS16201_SCAN_SUPPLY, 0, 12),
        ADIS_TEMP_CHAN(ADIS16201_TEMP_OUT, ADIS16201_SCAN_TEMP, 0, 12),
        ADIS_ACCEL_CHAN(X, ADIS16201_XACCL_OUT, ADIS16201_SCAN_ACC_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        ADIS_ACCEL_CHAN(Y, ADIS16201_YACCL_OUT, ADIS16201_SCAN_ACC_Y,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC, ADIS16201_SCAN_AUX_ADC, 0, 12),
        ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT, ADIS16201_SCAN_INCLI_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        ADIS_INCLI_CHAN(X, ADIS16201_YINCL_OUT, ADIS16201_SCAN_INCLI_Y,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        IIO_CHAN_SOFT_TIMESTAMP(7)
 };
 
index acc688d7ea9eda68a72a33f1d032a46fe05ffd13..6426e38bf00680171858e957735e5703dc4ee104 100644 (file)
 #define ADIS16203_GLOB_CMD       0x3E /* Operation, system command register */
 
 /* MSC_CTRL */
-#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST     (1 << 10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
-#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN      (1 << 9)  /* Reverses rotation of both inclination outputs */
-#define ADIS16203_MSC_CTRL_SELF_TEST_EN                (1 << 8)  /* Self-test enable */
-#define ADIS16203_MSC_CTRL_DATA_RDY_EN         (1 << 2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16203_MSC_CTRL_ACTIVE_HIGH         (1 << 1)  /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1       (1 << 0)  /* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
+#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST     BIT(10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
+#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN      BIT(9)  /* Reverses rotation of both inclination outputs */
+#define ADIS16203_MSC_CTRL_SELF_TEST_EN                BIT(8)  /* Self-test enable */
+#define ADIS16203_MSC_CTRL_DATA_RDY_EN         BIT(2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16203_MSC_CTRL_ACTIVE_HIGH         BIT(1)  /* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1       BIT(0)  /* Data-ready line selection: 1 = DIO1, 0 = DIO0 */
 
 /* DIAG_STAT */
-#define ADIS16203_DIAG_STAT_ALARM2        (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16203_DIAG_STAT_ALARM1        (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16203_DIAG_STAT_ALARM2        BIT(9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16203_DIAG_STAT_ALARM1        BIT(8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
 #define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5 /* Self-test diagnostic error flag */
 #define ADIS16203_DIAG_STAT_SPI_FAIL_BIT      3 /* SPI communications failure */
 #define ADIS16203_DIAG_STAT_FLASH_UPT_BIT     2 /* Flash update failure */
 #define ADIS16203_DIAG_STAT_POWER_LOW_BIT     0 /* Power supply below 3.15 V */
 
 /* GLOB_CMD */
-#define ADIS16203_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16203_GLOB_CMD_CLEAR_STAT  (1<<4)
-#define ADIS16203_GLOB_CMD_FACTORY_CAL (1<<1)
+#define ADIS16203_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16203_GLOB_CMD_CLEAR_STAT  BIT(4)
+#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1)
 
-#define ADIS16203_ERROR_ACTIVE          (1<<14)
+#define ADIS16203_ERROR_ACTIVE          BIT(14)
 
 enum adis16203_scan {
        ADIS16203_SCAN_INCLI_X,
index fbbe93f26bbe6c074d9110fa4433755a5e95a201..fb593d23d5bcbccb6e9084145e04adc7b9360f9e 100644 (file)
@@ -104,10 +104,10 @@ static const struct iio_chan_spec adis16203_channels[] = {
        ADIS_SUPPLY_CHAN(ADIS16203_SUPPLY_OUT, ADIS16203_SCAN_SUPPLY, 0, 12),
        ADIS_AUX_ADC_CHAN(ADIS16203_AUX_ADC, ADIS16203_SCAN_AUX_ADC, 0, 12),
        ADIS_INCLI_CHAN(X, ADIS16203_XINCL_OUT, ADIS16203_SCAN_INCLI_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        /* Fixme: Not what it appears to be - see data sheet */
        ADIS_INCLI_CHAN(Y, ADIS16203_YINCL_OUT, ADIS16203_SCAN_INCLI_Y,
-               0, 0, 14),
+                       0, 0, 14),
        ADIS_TEMP_CHAN(ADIS16203_TEMP_OUT, ADIS16203_SCAN_TEMP, 0, 12),
        IIO_CHAN_SOFT_TIMESTAMP(5),
 };
index 9ff950c1e8dbff21a5400892db375ea45a8e4463..0b23f0b5c52ffed194d0aa71133a5c4dfa4302ae 100644 (file)
 #define ADIS16204_GLOB_CMD       0x3E /* Operation, system command register */
 
 /* MSC_CTRL */
-#define ADIS16204_MSC_CTRL_PWRUP_SELF_TEST     (1 << 10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
-#define ADIS16204_MSC_CTRL_SELF_TEST_EN                (1 << 8)  /* Self-test enable */
-#define ADIS16204_MSC_CTRL_DATA_RDY_EN         (1 << 2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16204_MSC_CTRL_ACTIVE_HIGH         (1 << 1)  /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16204_MSC_CTRL_DATA_RDY_DIO2       (1 << 0)  /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
+#define ADIS16204_MSC_CTRL_PWRUP_SELF_TEST     BIT(10) /* Self-test at power-on: 1 = disabled, 0 = enabled */
+#define ADIS16204_MSC_CTRL_SELF_TEST_EN                BIT(8)  /* Self-test enable */
+#define ADIS16204_MSC_CTRL_DATA_RDY_EN         BIT(2)  /* Data-ready enable: 1 = enabled, 0 = disabled */
+#define ADIS16204_MSC_CTRL_ACTIVE_HIGH         BIT(1)  /* Data-ready polarity: 1 = active high, 0 = active low */
+#define ADIS16204_MSC_CTRL_DATA_RDY_DIO2       BIT(0)  /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
 
 /* DIAG_STAT */
-#define ADIS16204_DIAG_STAT_ALARM2        (1<<9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16204_DIAG_STAT_ALARM1        (1<<8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16204_DIAG_STAT_ALARM2        BIT(9) /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
+#define ADIS16204_DIAG_STAT_ALARM1        BIT(8) /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
 #define ADIS16204_DIAG_STAT_SELFTEST_FAIL_BIT 5 /* Self-test diagnostic error flag: 1 = error condition,
                                                0 = normal operation */
 #define ADIS16204_DIAG_STAT_SPI_FAIL_BIT      3 /* SPI communications failure */
 #define ADIS16204_DIAG_STAT_POWER_LOW_BIT     0 /* Power supply below 2.975 V */
 
 /* GLOB_CMD */
-#define ADIS16204_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16204_GLOB_CMD_CLEAR_STAT  (1<<4)
-#define ADIS16204_GLOB_CMD_FACTORY_CAL (1<<1)
+#define ADIS16204_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16204_GLOB_CMD_CLEAR_STAT  BIT(4)
+#define ADIS16204_GLOB_CMD_FACTORY_CAL BIT(1)
 
-#define ADIS16204_ERROR_ACTIVE          (1<<14)
+#define ADIS16204_ERROR_ACTIVE          BIT(14)
 
 enum adis16204_scan {
        ADIS16204_SCAN_ACC_X,
index 4c8acbc2e44ea722429b2d27060395cb575a4640..ea0ac2467ac2d1c28a029d3891685c183e4f397f 100644 (file)
@@ -141,11 +141,13 @@ static const struct iio_chan_spec adis16204_channels[] = {
        ADIS_AUX_ADC_CHAN(ADIS16204_AUX_ADC, ADIS16204_SCAN_AUX_ADC, 0, 12),
        ADIS_TEMP_CHAN(ADIS16204_TEMP_OUT, ADIS16204_SCAN_TEMP, 0, 12),
        ADIS_ACCEL_CHAN(X, ADIS16204_XACCL_OUT, ADIS16204_SCAN_ACC_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK),
+                       0, 14),
        ADIS_ACCEL_CHAN(Y, ADIS16204_YACCL_OUT, ADIS16204_SCAN_ACC_Y,
-               BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK),
+                       0, 14),
        ADIS_ACCEL_CHAN(ROOT_SUM_SQUARED_X_Y, ADIS16204_XY_RSS_OUT,
-               ADIS16204_SCAN_ACC_XY, BIT(IIO_CHAN_INFO_PEAK), 0, 14),
+                       ADIS16204_SCAN_ACC_XY, BIT(IIO_CHAN_INFO_PEAK), 0, 14),
        IIO_CHAN_SOFT_TIMESTAMP(5),
 };
 
index ad3945a06292f98259943e0bc83f9d56a3e06212..813698d18ec8ecd395bbf258cae701dbd9f8e985 100644 (file)
 
 /* MSC_CTRL */
 /* Self-test at power-on: 1 = disabled, 0 = enabled */
-#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST     (1 << 10)
+#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST     BIT(10)
 /* Self-test enable */
-#define ADIS16209_MSC_CTRL_SELF_TEST_EN                (1 << 8)
+#define ADIS16209_MSC_CTRL_SELF_TEST_EN                BIT(8)
 /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16209_MSC_CTRL_DATA_RDY_EN         (1 << 2)
+#define ADIS16209_MSC_CTRL_DATA_RDY_EN         BIT(2)
 /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16209_MSC_CTRL_ACTIVE_HIGH         (1 << 1)
+#define ADIS16209_MSC_CTRL_ACTIVE_HIGH         BIT(1)
 /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
-#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2       (1 << 0)
+#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2       BIT(0)
 
 /* DIAG_STAT */
 /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16209_DIAG_STAT_ALARM2        (1<<9)
+#define ADIS16209_DIAG_STAT_ALARM2        BIT(9)
 /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16209_DIAG_STAT_ALARM1        (1<<8)
+#define ADIS16209_DIAG_STAT_ALARM1        BIT(8)
 /* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */
 #define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT  5
 /* SPI communications failure */
 #define ADIS16209_DIAG_STAT_POWER_LOW_BIT      0
 
 /* GLOB_CMD */
-#define ADIS16209_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16209_GLOB_CMD_CLEAR_STAT  (1<<4)
-#define ADIS16209_GLOB_CMD_FACTORY_CAL (1<<1)
+#define ADIS16209_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16209_GLOB_CMD_CLEAR_STAT  BIT(4)
+#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1)
 
-#define ADIS16209_ERROR_ACTIVE          (1<<14)
+#define ADIS16209_ERROR_ACTIVE          BIT(14)
 
 #define ADIS16209_SCAN_SUPPLY  0
 #define ADIS16209_SCAN_ACC_X   1
index b2c7aeda75f04b2f58b0372bed51443e97cf5d70..d1dc1a3cb3ce64e82b74ff2bba256838edba1bb1 100644 (file)
@@ -134,14 +134,14 @@ static const struct iio_chan_spec adis16209_channels[] = {
        ADIS_SUPPLY_CHAN(ADIS16209_SUPPLY_OUT, ADIS16209_SCAN_SUPPLY, 0, 14),
        ADIS_TEMP_CHAN(ADIS16209_TEMP_OUT, ADIS16209_SCAN_TEMP, 0, 12),
        ADIS_ACCEL_CHAN(X, ADIS16209_XACCL_OUT, ADIS16209_SCAN_ACC_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        ADIS_ACCEL_CHAN(Y, ADIS16209_YACCL_OUT, ADIS16209_SCAN_ACC_Y,
-               BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14),
        ADIS_AUX_ADC_CHAN(ADIS16209_AUX_ADC, ADIS16209_SCAN_AUX_ADC, 0, 12),
        ADIS_INCLI_CHAN(X, ADIS16209_XINCL_OUT, ADIS16209_SCAN_INCLI_X,
-               0, 0, 14),
+                       0, 0, 14),
        ADIS_INCLI_CHAN(Y, ADIS16209_YINCL_OUT, ADIS16209_SCAN_INCLI_Y,
-               0, 0, 14),
+                       0, 0, 14),
        ADIS_ROT_CHAN(X, ADIS16209_ROT_OUT, ADIS16209_SCAN_ROT, 0, 0, 14),
        IIO_CHAN_SOFT_TIMESTAMP(8)
 };
@@ -178,7 +178,6 @@ static const struct adis_data adis16209_data = {
                BIT(ADIS16209_DIAG_STAT_POWER_LOW_BIT),
 };
 
-
 static int adis16209_probe(struct spi_device *spi)
 {
        int ret;
index a894ad7fb26dc7d21ad6278969855f9ec19028ad..eab86331124fd87e1c47e379601690f741a2df67 100644 (file)
 #define ADIS16220_CAPTURE_SIZE  2048
 
 /* MSC_CTRL */
-#define ADIS16220_MSC_CTRL_SELF_TEST_EN                (1 << 8)
-#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN1  (1 << 1)
-#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN2  (1 << 0)
+#define ADIS16220_MSC_CTRL_SELF_TEST_EN                BIT(8)
+#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN1  BIT(1)
+#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN2  BIT(0)
 
 /* DIO_CTRL */
-#define ADIS16220_MSC_CTRL_DIO2_BUSY_IND     (3<<4)
-#define ADIS16220_MSC_CTRL_DIO1_BUSY_IND     (3<<2)
-#define ADIS16220_MSC_CTRL_DIO2_ACT_HIGH     (1<<1)
-#define ADIS16220_MSC_CTRL_DIO1_ACT_HIGH     (1<<0)
+#define ADIS16220_MSC_CTRL_DIO2_BUSY_IND     (BIT(5) | BIT(4))
+#define ADIS16220_MSC_CTRL_DIO1_BUSY_IND     (BIT(3) | BIT(2))
+#define ADIS16220_MSC_CTRL_DIO2_ACT_HIGH     BIT(1)
+#define ADIS16220_MSC_CTRL_DIO1_ACT_HIGH     BIT(0)
 
 /* DIAG_STAT */
 /* AIN2 sample > ALM_MAG2 */
-#define ADIS16220_DIAG_STAT_ALM_MAG2    (1<<14)
+#define ADIS16220_DIAG_STAT_ALM_MAG2    BIT(14)
 /* AIN1 sample > ALM_MAG1 */
-#define ADIS16220_DIAG_STAT_ALM_MAG1    (1<<13)
+#define ADIS16220_DIAG_STAT_ALM_MAG1    BIT(13)
 /* Acceleration sample > ALM_MAGA */
-#define ADIS16220_DIAG_STAT_ALM_MAGA    (1<<12)
+#define ADIS16220_DIAG_STAT_ALM_MAGA    BIT(12)
 /* Error condition programmed into ALM_MAGS[11:0] and ALM_CTRL[5:4] is true */
-#define ADIS16220_DIAG_STAT_ALM_MAGS    (1<<11)
+#define ADIS16220_DIAG_STAT_ALM_MAGS    BIT(11)
 /* |Peak value in AIN2 data capture| > ALM_MAG2 */
-#define ADIS16220_DIAG_STAT_PEAK_AIN2   (1<<10)
+#define ADIS16220_DIAG_STAT_PEAK_AIN2   BIT(10)
 /* |Peak value in AIN1 data capture| > ALM_MAG1 */
-#define ADIS16220_DIAG_STAT_PEAK_AIN1   (1<<9)
+#define ADIS16220_DIAG_STAT_PEAK_AIN1   BIT(9)
 /* |Peak value in acceleration data capture| > ALM_MAGA */
-#define ADIS16220_DIAG_STAT_PEAK_ACCEL  (1<<8)
+#define ADIS16220_DIAG_STAT_PEAK_ACCEL  BIT(8)
 /* Data ready, capture complete */
-#define ADIS16220_DIAG_STAT_DATA_RDY    (1<<7)
-#define ADIS16220_DIAG_STAT_FLASH_CHK  (1<<6)
-#define ADIS16220_DIAG_STAT_SELF_TEST  (1<<5)
+#define ADIS16220_DIAG_STAT_DATA_RDY    BIT(7)
+#define ADIS16220_DIAG_STAT_FLASH_CHK  BIT(6)
+#define ADIS16220_DIAG_STAT_SELF_TEST  BIT(5)
 /* Capture period violation/interruption */
 #define ADIS16220_DIAG_STAT_VIOLATION_BIT      4
 /* SPI communications failure */
 #define ADIS16220_DIAG_STAT_POWER_LOW_BIT      0
 
 /* GLOB_CMD */
-#define ADIS16220_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16220_GLOB_CMD_SELF_TEST   (1<<2)
-#define ADIS16220_GLOB_CMD_PWR_DOWN    (1<<1)
+#define ADIS16220_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16220_GLOB_CMD_SELF_TEST   BIT(2)
+#define ADIS16220_GLOB_CMD_PWR_DOWN    BIT(1)
 
 #define ADIS16220_MAX_TX 2048
 #define ADIS16220_MAX_RX 2048
index d478f5130a0fb461ff039a72cb48a75f79e7beff..e46a91c69a3170a5f42d3eb867492541d2fbdc85 100644 (file)
 #include "adis16220.h"
 
 static ssize_t adis16220_read_16bit(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
+                                   struct device_attribute *attr,
+                                   char *buf)
 {
        struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
        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,
-               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 iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -76,8 +75,8 @@ static int adis16220_capture(struct iio_dev *indio_dev)
 }
 
 static ssize_t adis16220_write_capture(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);
        bool val;
@@ -96,10 +95,10 @@ static ssize_t adis16220_write_capture(struct device *dev,
 }
 
 static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
-                                       char *buf,
-                                       loff_t off,
-                                       size_t count,
-                                       int addr)
+                                            char *buf,
+                                            loff_t off,
+                                            size_t count,
+                                            int addr)
 {
        struct adis16220_state *st = iio_priv(indio_dev);
        struct spi_transfer xfers[] = {
@@ -131,15 +130,14 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
 
        /* write the begin position of capture buffer */
        ret = adis_write_reg_16(&st->adis,
-                                       ADIS16220_CAPT_PNTR,
-                                       off > 1);
+                               ADIS16220_CAPT_PNTR,
+                               off > 1);
        if (ret)
                return -EIO;
 
        /* read count/2 values from capture buffer */
        mutex_lock(&st->buf_lock);
 
-
        for (i = 0; i < count; i += 2) {
                st->tx[i] = ADIS_READ_REG(addr);
                st->tx[i + 1] = 0;
@@ -148,7 +146,6 @@ static ssize_t adis16220_capture_buffer_read(struct iio_dev *indio_dev,
 
        ret = spi_sync_transfer(st->adis.spi, xfers, ARRAY_SIZE(xfers));
        if (ret) {
-
                mutex_unlock(&st->buf_lock);
                return -EIO;
        }
@@ -182,9 +179,9 @@ static struct bin_attribute accel_bin = {
 };
 
 static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj,
-                               struct bin_attribute *attr,
-                               char *buf, loff_t off,
-                               size_t count)
+                                      struct bin_attribute *attr,
+                                      char *buf, loff_t off,
+                                      size_t count)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj));
 
@@ -203,9 +200,9 @@ static struct bin_attribute adc1_bin = {
 };
 
 static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj,
-                               struct bin_attribute *attr,
-                               char *buf, loff_t off,
-                               size_t count)
+                                      struct bin_attribute *attr,
+                                      char *buf, loff_t off,
+                                      size_t count)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(kobj_to_dev(kobj));
 
@@ -214,7 +211,6 @@ static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj,
                                        ADIS16220_CAPT_BUF2);
 }
 
-
 static struct bin_attribute adc2_bin = {
        .attr = {
                .name = "in1_bin",
index d442d49f51f4a5a1280a3b5d66eb5cb5aa19c8be..66b5ad2f42c5043d93fb192974e6919e0d2df4af 100644 (file)
 
 /* MSC_CTRL */
 /* Enables sum-of-squares output (XYZPEAK_OUT) */
-#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN      (1 << 15)
+#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN      BIT(15)
 /* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */
-#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN    (1 << 14)
+#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN    BIT(14)
 /* Self-test enable: 1 = apply electrostatic force, 0 = disabled */
-#define ADIS16240_MSC_CTRL_SELF_TEST_EN                (1 << 8)
+#define ADIS16240_MSC_CTRL_SELF_TEST_EN                BIT(8)
 /* Data-ready enable: 1 = enabled, 0 = disabled */
-#define ADIS16240_MSC_CTRL_DATA_RDY_EN         (1 << 2)
+#define ADIS16240_MSC_CTRL_DATA_RDY_EN         BIT(2)
 /* Data-ready polarity: 1 = active high, 0 = active low */
-#define ADIS16240_MSC_CTRL_ACTIVE_HIGH         (1 << 1)
+#define ADIS16240_MSC_CTRL_ACTIVE_HIGH         BIT(1)
 /* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
-#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2       (1 << 0)
+#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2       BIT(0)
 
 /* DIAG_STAT */
 /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16240_DIAG_STAT_ALARM2      (1<<9)
+#define ADIS16240_DIAG_STAT_ALARM2      BIT(9)
 /* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
-#define ADIS16240_DIAG_STAT_ALARM1      (1<<8)
+#define ADIS16240_DIAG_STAT_ALARM1      BIT(8)
 /* Capture buffer full: 1 = capture buffer is full */
-#define ADIS16240_DIAG_STAT_CPT_BUF_FUL (1<<7)
+#define ADIS16240_DIAG_STAT_CPT_BUF_FUL BIT(7)
 /* Flash test, checksum flag: 1 = mismatch, 0 = match */
-#define ADIS16240_DIAG_STAT_CHKSUM      (1<<6)
+#define ADIS16240_DIAG_STAT_CHKSUM      BIT(6)
 /* Power-on, self-test flag: 1 = failure, 0 = pass */
 #define ADIS16240_DIAG_STAT_PWRON_FAIL_BIT  5
 /* Power-on self-test: 1 = in-progress, 0 = complete */
-#define ADIS16240_DIAG_STAT_PWRON_BUSY  (1<<4)
+#define ADIS16240_DIAG_STAT_PWRON_BUSY  BIT(4)
 /* SPI communications failure */
 #define ADIS16240_DIAG_STAT_SPI_FAIL_BIT       3
 /* Flash update failure */
 #define ADIS16240_DIAG_STAT_POWER_LOW_BIT      0
 
 /* GLOB_CMD */
-#define ADIS16240_GLOB_CMD_RESUME      (1<<8)
-#define ADIS16240_GLOB_CMD_SW_RESET    (1<<7)
-#define ADIS16240_GLOB_CMD_STANDBY     (1<<2)
+#define ADIS16240_GLOB_CMD_RESUME      BIT(8)
+#define ADIS16240_GLOB_CMD_SW_RESET    BIT(7)
+#define ADIS16240_GLOB_CMD_STANDBY     BIT(2)
 
-#define ADIS16240_ERROR_ACTIVE          (1<<14)
+#define ADIS16240_ERROR_ACTIVE          BIT(14)
 
 /* At the moment triggers are only used for ring buffer
  * filling. This may change!
index 3f46086eab3a30d86c464d2016255e7edb46f91c..cb074e864408abc1ff33f4fc4b4725526b49e836 100644 (file)
@@ -27,9 +27,9 @@
 #include "adis16240.h"
 
 static ssize_t adis16240_spi_read_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf,
-               unsigned bits)
+                                        struct device_attribute *attr,
+                                        char *buf,
+                                        unsigned bits)
 {
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct adis *st = iio_priv(indio_dev);
@@ -39,20 +39,20 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
        struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 
        ret = adis_read_reg_16(st,
-                                       this_attr->address, (u16 *)&val);
+                              this_attr->address, (u16 *)&val);
        if (ret)
                return ret;
 
        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);
 }
 
 static ssize_t adis16240_read_12bit_signed(struct device *dev,
-               struct device_attribute *attr,
-               char *buf)
+                                          struct device_attribute *attr,
+                                          char *buf)
 {
        ssize_t ret;
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
@@ -176,11 +176,14 @@ static const struct iio_chan_spec adis16240_channels[] = {
        ADIS_SUPPLY_CHAN(ADIS16240_SUPPLY_OUT, ADIS16240_SCAN_SUPPLY, 0, 10),
        ADIS_AUX_ADC_CHAN(ADIS16240_AUX_ADC, ADIS16240_SCAN_AUX_ADC, 0, 10),
        ADIS_ACCEL_CHAN(X, ADIS16240_XACCL_OUT, ADIS16240_SCAN_ACC_X,
-               BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK), 0, 10),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK),
+                       0, 10),
        ADIS_ACCEL_CHAN(Y, ADIS16240_YACCL_OUT, ADIS16240_SCAN_ACC_Y,
-               BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK), 0, 10),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK),
+                       0, 10),
        ADIS_ACCEL_CHAN(Z, ADIS16240_ZACCL_OUT, ADIS16240_SCAN_ACC_Z,
-               BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK), 0, 10),
+                       BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_PEAK),
+                       0, 10),
        ADIS_TEMP_CHAN(ADIS16240_TEMP_OUT, ADIS16240_SCAN_TEMP, 0, 10),
        IIO_CHAN_SOFT_TIMESTAMP(6)
 };
index 0a8ea827086647fb36543271593c34f3bdbc5356..3f24c629be6f4f98208890739577ac6d21bd4ef3 100644 (file)
@@ -194,6 +194,7 @@ irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private);
 static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
 {
 }
+
 static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
 {
        return 0;
@@ -203,6 +204,7 @@ static int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
 {
        return 0;
 }
+
 static inline void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev)
 {
 }
index b78c9c5d55886d08f015021bc8f954475dcce1c3..ebcab56c81b9c641bbfa1de413ec0dfa1ec2ad99 100644 (file)
@@ -558,13 +558,11 @@ static const struct iio_chan_spec lis3l02dq_channels[] = {
        IIO_CHAN_SOFT_TIMESTAMP(3)
 };
 
-
 static int lis3l02dq_read_event_config(struct iio_dev *indio_dev,
                                       const struct iio_chan_spec *chan,
                                       enum iio_event_type type,
                                       enum iio_event_direction dir)
 {
-
        u8 val;
        int ret;
        u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING)));
@@ -656,8 +654,8 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
                        (control | LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT) :
                        (control & ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT);
                ret = lis3l02dq_spi_write_reg_8(indio_dev,
-                                              LIS3L02DQ_REG_CTRL_2_ADDR,
-                                              control);
+                                               LIS3L02DQ_REG_CTRL_2_ADDR,
+                                               control);
                if (ret)
                        goto error_ret;
        }
index 1fd90090a633580dbc2dbbd1cd985ffc06d49f8e..b892f2cf5f9ef1bd2ed7acf8197c4ceece3ec4c3 100644 (file)
@@ -110,7 +110,7 @@ static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array)
 }
 
 static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev,
-                               u8 *buf)
+                                       u8 *buf)
 {
        int ret, i;
        u8 *rx_array;
@@ -118,8 +118,8 @@ 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);
-       if (rx_array == NULL)
+       rx_array = kcalloc(4, scan_count, GFP_KERNEL);
+       if (!rx_array)
                return -ENOMEM;
        ret = lis3l02dq_read_all(indio_dev, rx_array);
        if (ret < 0) {
@@ -142,7 +142,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
        char *data;
 
        data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
-       if (data == NULL)
+       if (!data)
                goto done;
 
        if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
@@ -330,19 +330,21 @@ static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev)
        if (test_bit(0, indio_dev->active_scan_mask)) {
                t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
                oneenabled = true;
-       } else
+       } else {
                t &= ~LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE;
+       }
        if (test_bit(1, indio_dev->active_scan_mask)) {
                t |= LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
                oneenabled = true;
-       } else
+       } else {
                t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE;
+       }
        if (test_bit(2, indio_dev->active_scan_mask)) {
                t |= LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
                oneenabled = true;
-       } else
+       } else {
                t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE;
-
+       }
        if (!oneenabled) /* what happens in this case is unknown */
                return -EINVAL;
        ret = lis3l02dq_spi_write_reg_8(indio_dev,
@@ -410,7 +412,7 @@ int lis3l02dq_configure_buffer(struct iio_dev *indio_dev)
                                                 "lis3l02dq_consumer%d",
                                                 indio_dev->id);
 
-       if (indio_dev->pollfunc == NULL) {
+       if (!indio_dev->pollfunc) {
                ret = -ENOMEM;
                goto error_iio_sw_rb_free;
        }
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 f76a268858080163bdd5a745997a5cae81ed64d3..8589eade1057efd56eb31a0a10555d5be63e25b0 100644 (file)
@@ -129,9 +129,9 @@ error_ret:
        return ret ? ret : num_read;
 }
 
-static bool sca3000_ring_buf_data_available(struct iio_buffer *r)
+static size_t sca3000_ring_buf_data_available(struct iio_buffer *r)
 {
-       return r->stufftoread;
+       return r->stufftoread ? r->watermark : 0;
 }
 
 /**
index 6f8ce6c6574babed56e1b7277cb04c76849be73a..fe56fb6c7d3030979a3070c38411d8b132a53ddd 100644 (file)
                                   * (RW, 16-bit (AD7792)/24-bit (AD7192)) */
 
 /* Communications Register Bit Designations (AD7192_REG_COMM) */
-#define AD7192_COMM_WEN                (1 << 7) /* Write Enable */
-#define AD7192_COMM_WRITE      (0 << 6) /* Write Operation */
-#define AD7192_COMM_READ       (1 << 6) /* Read Operation */
+#define AD7192_COMM_WEN                BIT(7) /* Write Enable */
+#define AD7192_COMM_WRITE      0 /* Write Operation */
+#define AD7192_COMM_READ       BIT(6) /* Read Operation */
 #define AD7192_COMM_ADDR(x)    (((x) & 0x7) << 3) /* Register Address */
-#define AD7192_COMM_CREAD      (1 << 2) /* Continuous Read of Data Register */
+#define AD7192_COMM_CREAD      BIT(2) /* Continuous Read of Data Register */
 
 /* Status Register Bit Designations (AD7192_REG_STAT) */
-#define AD7192_STAT_RDY                (1 << 7) /* Ready */
-#define AD7192_STAT_ERR                (1 << 6) /* Error (Overrange, Underrange) */
-#define AD7192_STAT_NOREF      (1 << 5) /* Error no external reference */
-#define AD7192_STAT_PARITY     (1 << 4) /* Parity */
-#define AD7192_STAT_CH3                (1 << 2) /* Channel 3 */
-#define AD7192_STAT_CH2                (1 << 1) /* Channel 2 */
-#define AD7192_STAT_CH1                (1 << 0) /* Channel 1 */
+#define AD7192_STAT_RDY                BIT(7) /* Ready */
+#define AD7192_STAT_ERR                BIT(6) /* Error (Overrange, Underrange) */
+#define AD7192_STAT_NOREF      BIT(5) /* Error no external reference */
+#define AD7192_STAT_PARITY     BIT(4) /* Parity */
+#define AD7192_STAT_CH3                BIT(2) /* Channel 3 */
+#define AD7192_STAT_CH2                BIT(1) /* Channel 2 */
+#define AD7192_STAT_CH1                BIT(0) /* Channel 1 */
 
 /* Mode Register Bit Designations (AD7192_REG_MODE) */
 #define AD7192_MODE_SEL(x)     (((x) & 0x7) << 21) /* Operation Mode Select */
 #define AD7192_MODE_SEL_MASK   (0x7 << 21) /* Operation Mode Select Mask */
-#define AD7192_MODE_DAT_STA    (1 << 20) /* Status Register transmission */
+#define AD7192_MODE_DAT_STA    BIT(20) /* Status Register transmission */
 #define AD7192_MODE_CLKSRC(x)  (((x) & 0x3) << 18) /* Clock Source Select */
-#define AD7192_MODE_SINC3      (1 << 15) /* SINC3 Filter Select */
-#define AD7192_MODE_ACX                (1 << 14) /* AC excitation enable(AD7195 only)*/
-#define AD7192_MODE_ENPAR      (1 << 13) /* Parity Enable */
-#define AD7192_MODE_CLKDIV     (1 << 12) /* Clock divide by 2 (AD7190/2 only)*/
-#define AD7192_MODE_SCYCLE     (1 << 11) /* Single cycle conversion */
-#define AD7192_MODE_REJ60      (1 << 10) /* 50/60Hz notch filter */
+#define AD7192_MODE_SINC3      BIT(15) /* SINC3 Filter Select */
+#define AD7192_MODE_ACX                BIT(14) /* AC excitation enable(AD7195 only)*/
+#define AD7192_MODE_ENPAR      BIT(13) /* Parity Enable */
+#define AD7192_MODE_CLKDIV     BIT(12) /* Clock divide by 2 (AD7190/2 only)*/
+#define AD7192_MODE_SCYCLE     BIT(11) /* Single cycle conversion */
+#define AD7192_MODE_REJ60      BIT(10) /* 50/60Hz notch filter */
 #define AD7192_MODE_RATE(x)    ((x) & 0x3FF) /* Filter Update Rate Select */
 
 /* Mode Register: AD7192_MODE_SEL options */
 
 /* Configuration Register Bit Designations (AD7192_REG_CONF) */
 
-#define AD7192_CONF_CHOP       (1 << 23) /* CHOP enable */
-#define AD7192_CONF_REFSEL     (1 << 20) /* REFIN1/REFIN2 Reference Select */
+#define AD7192_CONF_CHOP       BIT(23) /* CHOP enable */
+#define AD7192_CONF_REFSEL     BIT(20) /* REFIN1/REFIN2 Reference Select */
 #define AD7192_CONF_CHAN(x)    (((1 << (x)) & 0xFF) << 8) /* Channel select */
 #define AD7192_CONF_CHAN_MASK  (0xFF << 8) /* Channel select mask */
-#define AD7192_CONF_BURN       (1 << 7) /* Burnout current enable */
-#define AD7192_CONF_REFDET     (1 << 6) /* Reference detect enable */
-#define AD7192_CONF_BUF                (1 << 4) /* Buffered Mode Enable */
-#define AD7192_CONF_UNIPOLAR   (1 << 3) /* Unipolar/Bipolar Enable */
+#define AD7192_CONF_BURN       BIT(7) /* Burnout current enable */
+#define AD7192_CONF_REFDET     BIT(6) /* Reference detect enable */
+#define AD7192_CONF_BUF                BIT(4) /* Buffered Mode Enable */
+#define AD7192_CONF_UNIPOLAR   BIT(3) /* Unipolar/Bipolar Enable */
 #define AD7192_CONF_GAIN(x)    ((x) & 0x7) /* Gain Select */
 
 #define AD7192_CH_AIN1P_AIN2M  0 /* AIN1(+) - AIN2(-) */
 #define AD7192_ID_MASK         0x0F
 
 /* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */
-#define AD7192_GPOCON_BPDSW    (1 << 6) /* Bridge power-down switch enable */
-#define AD7192_GPOCON_GP32EN   (1 << 5) /* Digital Output P3 and P2 enable */
-#define AD7192_GPOCON_GP10EN   (1 << 4) /* Digital Output P1 and P0 enable */
-#define AD7192_GPOCON_P3DAT    (1 << 3) /* P3 state */
-#define AD7192_GPOCON_P2DAT    (1 << 2) /* P2 state */
-#define AD7192_GPOCON_P1DAT    (1 << 1) /* P1 state */
-#define AD7192_GPOCON_P0DAT    (1 << 0) /* P0 state */
+#define AD7192_GPOCON_BPDSW    BIT(6) /* Bridge power-down switch enable */
+#define AD7192_GPOCON_GP32EN   BIT(5) /* Digital Output P3 and P2 enable */
+#define AD7192_GPOCON_GP10EN   BIT(4) /* Digital Output P1 and P0 enable */
+#define AD7192_GPOCON_P3DAT    BIT(3) /* P3 state */
+#define AD7192_GPOCON_P2DAT    BIT(2) /* P2 state */
+#define AD7192_GPOCON_P1DAT    BIT(1) /* P1 state */
+#define AD7192_GPOCON_P0DAT    BIT(0) /* P0 state */
 
 #define AD7192_INT_FREQ_MHz    4915200
 
index 4d4870787eede59fd6a73d23ba4ca29df48bbe2e..d98e229c46bfd4047e2799457e62aa1528acec4e 100644 (file)
 #define AD7280A_CNVST_CONTROL          0x1D /* D7 to D0, Read/write */
 
 /* Bits and Masks */
-#define AD7280A_CTRL_HB_CONV_INPUT_ALL                 (0 << 6)
-#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4      (1 << 6)
-#define AD7280A_CTRL_HB_CONV_INPUT_6CELL               (2 << 6)
-#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST           (3 << 6)
-#define AD7280A_CTRL_HB_CONV_RES_READ_ALL              (0 << 4)
-#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   (1 << 4)
-#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL            (2 << 4)
-#define AD7280A_CTRL_HB_CONV_RES_READ_NO               (3 << 4)
-#define AD7280A_CTRL_HB_CONV_START_CNVST               (0 << 3)
-#define AD7280A_CTRL_HB_CONV_START_CS                  (1 << 3)
-#define AD7280A_CTRL_HB_CONV_AVG_DIS                   (0 << 1)
-#define AD7280A_CTRL_HB_CONV_AVG_2                     (1 << 1)
-#define AD7280A_CTRL_HB_CONV_AVG_4                     (2 << 1)
-#define AD7280A_CTRL_HB_CONV_AVG_8                     (3 << 1)
+#define AD7280A_CTRL_HB_CONV_INPUT_ALL                 0
+#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4      BIT(6)
+#define AD7280A_CTRL_HB_CONV_INPUT_6CELL               BIT(7)
+#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST           (BIT(7) | BIT(6))
+#define AD7280A_CTRL_HB_CONV_RES_READ_ALL              0
+#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   BIT(4)
+#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL            BIT(5)
+#define AD7280A_CTRL_HB_CONV_RES_READ_NO               (BIT(5) | BIT(4))
+#define AD7280A_CTRL_HB_CONV_START_CNVST               0
+#define AD7280A_CTRL_HB_CONV_START_CS                  BIT(3)
+#define AD7280A_CTRL_HB_CONV_AVG_DIS                   0
+#define AD7280A_CTRL_HB_CONV_AVG_2                     BIT(1)
+#define AD7280A_CTRL_HB_CONV_AVG_4                     BIT(2)
+#define AD7280A_CTRL_HB_CONV_AVG_8                     (BIT(2) | BIT(1))
 #define AD7280A_CTRL_HB_CONV_AVG(x)                    ((x) << 1)
-#define AD7280A_CTRL_HB_PWRDN_SW                       (1 << 0)
+#define AD7280A_CTRL_HB_PWRDN_SW                       BIT(0)
 
-#define AD7280A_CTRL_LB_SWRST                          (1 << 7)
-#define AD7280A_CTRL_LB_ACQ_TIME_400ns                 (0 << 5)
-#define AD7280A_CTRL_LB_ACQ_TIME_800ns                 (1 << 5)
-#define AD7280A_CTRL_LB_ACQ_TIME_1200ns                        (2 << 5)
-#define AD7280A_CTRL_LB_ACQ_TIME_1600ns                        (3 << 5)
+#define AD7280A_CTRL_LB_SWRST                          BIT(7)
+#define AD7280A_CTRL_LB_ACQ_TIME_400ns                 0
+#define AD7280A_CTRL_LB_ACQ_TIME_800ns                 BIT(5)
+#define AD7280A_CTRL_LB_ACQ_TIME_1200ns                        BIT(6)
+#define AD7280A_CTRL_LB_ACQ_TIME_1600ns                        (BIT(6) | BIT(5))
 #define AD7280A_CTRL_LB_ACQ_TIME(x)                    ((x) << 5)
-#define AD7280A_CTRL_LB_MUST_SET                       (1 << 4)
-#define AD7280A_CTRL_LB_THERMISTOR_EN                  (1 << 3)
-#define AD7280A_CTRL_LB_LOCK_DEV_ADDR                  (1 << 2)
-#define AD7280A_CTRL_LB_INC_DEV_ADDR                   (1 << 1)
-#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN              (1 << 0)
+#define AD7280A_CTRL_LB_MUST_SET                       BIT(4)
+#define AD7280A_CTRL_LB_THERMISTOR_EN                  BIT(3)
+#define AD7280A_CTRL_LB_LOCK_DEV_ADDR                  BIT(2)
+#define AD7280A_CTRL_LB_INC_DEV_ADDR                   BIT(1)
+#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN              BIT(0)
 
-#define AD7280A_ALERT_GEN_STATIC_HIGH                  (1 << 6)
-#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN             (3 << 6)
+#define AD7280A_ALERT_GEN_STATIC_HIGH                  BIT(6)
+#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN             (BIT(7) | BIT(6))
 
 #define AD7280A_ALL_CELLS                              (0xAD << 16)
 
@@ -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 20400b0045e5819600e8553fa42057b932ad7a2d..732347a9bce4f68fe7c22e9f8a64f25bb370f946 100644 (file)
 #define AD7280A_CONV_AVG_4                     2
 #define AD7280A_CONV_AVG_8                     3
 
-#define AD7280A_ALERT_REMOVE_VIN5              (1 << 2)
-#define AD7280A_ALERT_REMOVE_VIN4_VIN5         (2 << 2)
-#define AD7280A_ALERT_REMOVE_AUX5              (1 << 0)
-#define AD7280A_ALERT_REMOVE_AUX4_AUX5         (2 << 0)
+#define AD7280A_ALERT_REMOVE_VIN5              BIT(2)
+#define AD7280A_ALERT_REMOVE_VIN4_VIN5         BIT(3)
+#define AD7280A_ALERT_REMOVE_AUX5              BIT(0)
+#define AD7280A_ALERT_REMOVE_AUX4_AUX5         BIT(1)
 
 struct ad7280_platform_data {
        unsigned acquisition_time;
index 3bf174cb19b1ef3573482896fef1848a3f7941ff..a6f8eb11242c124cc292e74594e16320bf092f9f 100644 (file)
@@ -50,7 +50,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
        int ret;
 
        buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
-       if (buf == NULL)
+       if (!buf)
                return;
 
        if (gpio_is_valid(st->pdata->gpio_frstdata)) {
index 273add3ed63fd8e80532110a1f793b218175caf0..9f03fe3ee3d93ee34c78ca23be867fdc59d7f706 100644 (file)
 
 #include "ad7780.h"
 
-#define AD7780_RDY     (1 << 7)
-#define AD7780_FILTER  (1 << 6)
-#define AD7780_ERR     (1 << 5)
-#define AD7780_ID1     (1 << 4)
-#define AD7780_ID0     (1 << 3)
-#define AD7780_GAIN    (1 << 2)
-#define AD7780_PAT1    (1 << 1)
-#define AD7780_PAT0    (1 << 0)
+#define AD7780_RDY     BIT(7)
+#define AD7780_FILTER  BIT(6)
+#define AD7780_ERR     BIT(5)
+#define AD7780_ID1     BIT(4)
+#define AD7780_ID0     BIT(3)
+#define AD7780_GAIN    BIT(2)
+#define AD7780_PAT1    BIT(1)
+#define AD7780_PAT0    BIT(0)
 
 struct ad7780_chip_info {
        struct iio_chan_spec    channel;
@@ -169,7 +169,7 @@ static int ad7780_probe(struct spi_device *spi)
        int ret, voltage_uv = 0;
 
        indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-       if (indio_dev == NULL)
+       if (!indio_dev)
                return -ENOMEM;
 
        st = iio_priv(indio_dev);
index 816174388f13347447c495700e3dad85e7c269db..d7c5223f1c3e78abfe759cca374873bda0b70068 100644 (file)
@@ -243,7 +243,7 @@ struct mxs_lradc {
         * be sampled as regular LRADC channels. The driver will refuse any
         * attempt to sample these channels.
         */
-#define CHAN_MASK_TOUCHBUTTON          (0x3 << 0)
+#define CHAN_MASK_TOUCHBUTTON          (BIT(1) | BIT(0))
 #define CHAN_MASK_TOUCHSCREEN_4WIRE    (0xf << 2)
 #define CHAN_MASK_TOUCHSCREEN_5WIRE    (0x1f << 2)
        enum mxs_lradc_ts       use_touchscreen;
@@ -268,20 +268,20 @@ struct mxs_lradc {
 };
 
 #define        LRADC_CTRL0                             0x00
-# define LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE  (1 << 23)
-# define LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE    (1 << 22)
-# define LRADC_CTRL0_MX28_YNNSW        /* YM */        (1 << 21)
-# define LRADC_CTRL0_MX28_YPNSW        /* YP */        (1 << 20)
-# define LRADC_CTRL0_MX28_YPPSW        /* YP */        (1 << 19)
-# define LRADC_CTRL0_MX28_XNNSW        /* XM */        (1 << 18)
-# define LRADC_CTRL0_MX28_XNPSW        /* XM */        (1 << 17)
-# define LRADC_CTRL0_MX28_XPPSW        /* XP */        (1 << 16)
-
-# define LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE  (1 << 20)
-# define LRADC_CTRL0_MX23_YM                   (1 << 19)
-# define LRADC_CTRL0_MX23_XM                   (1 << 18)
-# define LRADC_CTRL0_MX23_YP                   (1 << 17)
-# define LRADC_CTRL0_MX23_XP                   (1 << 16)
+# define LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE  BIT(23)
+# define LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE    BIT(22)
+# define LRADC_CTRL0_MX28_YNNSW        /* YM */        BIT(21)
+# define LRADC_CTRL0_MX28_YPNSW        /* YP */        BIT(20)
+# define LRADC_CTRL0_MX28_YPPSW        /* YP */        BIT(19)
+# define LRADC_CTRL0_MX28_XNNSW        /* XM */        BIT(18)
+# define LRADC_CTRL0_MX28_XNPSW        /* XM */        BIT(17)
+# define LRADC_CTRL0_MX28_XPPSW        /* XP */        BIT(16)
+
+# define LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE  BIT(20)
+# define LRADC_CTRL0_MX23_YM                   BIT(19)
+# define LRADC_CTRL0_MX23_XM                   BIT(18)
+# define LRADC_CTRL0_MX23_YP                   BIT(17)
+# define LRADC_CTRL0_MX23_XP                   BIT(16)
 
 # define LRADC_CTRL0_MX28_PLATE_MASK \
                (LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE | \
@@ -295,12 +295,12 @@ struct mxs_lradc {
                LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XP)
 
 #define        LRADC_CTRL1                             0x10
-#define        LRADC_CTRL1_TOUCH_DETECT_IRQ_EN         (1 << 24)
+#define        LRADC_CTRL1_TOUCH_DETECT_IRQ_EN         BIT(24)
 #define        LRADC_CTRL1_LRADC_IRQ_EN(n)             (1 << ((n) + 16))
 #define        LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK      (0x1fff << 16)
 #define        LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK      (0x01ff << 16)
 #define        LRADC_CTRL1_LRADC_IRQ_EN_OFFSET         16
-#define        LRADC_CTRL1_TOUCH_DETECT_IRQ            (1 << 8)
+#define        LRADC_CTRL1_TOUCH_DETECT_IRQ            BIT(8)
 #define        LRADC_CTRL1_LRADC_IRQ(n)                (1 << (n))
 #define        LRADC_CTRL1_MX28_LRADC_IRQ_MASK         0x1fff
 #define        LRADC_CTRL1_MX23_LRADC_IRQ_MASK         0x01ff
@@ -308,13 +308,13 @@ struct mxs_lradc {
 
 #define        LRADC_CTRL2                             0x20
 #define        LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET        24
-#define        LRADC_CTRL2_TEMPSENSE_PWD               (1 << 15)
+#define        LRADC_CTRL2_TEMPSENSE_PWD               BIT(15)
 
 #define        LRADC_STATUS                            0x40
-#define        LRADC_STATUS_TOUCH_DETECT_RAW           (1 << 0)
+#define        LRADC_STATUS_TOUCH_DETECT_RAW           BIT(0)
 
 #define        LRADC_CH(n)                             (0x50 + (0x10 * (n)))
-#define        LRADC_CH_ACCUMULATE                     (1 << 29)
+#define        LRADC_CH_ACCUMULATE                     BIT(29)
 #define        LRADC_CH_NUM_SAMPLES_MASK               (0x1f << 24)
 #define        LRADC_CH_NUM_SAMPLES_OFFSET             24
 #define        LRADC_CH_NUM_SAMPLES(x) \
@@ -477,7 +477,7 @@ static void mxs_lradc_setup_ts_channel(struct mxs_lradc *lradc, unsigned ch)
         */
        mxs_lradc_reg_wrt(lradc,
                LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
-               LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */
+               LRADC_DELAY_TRIGGER_DELAYS(BIT(3)) | /* trigger DELAY unit#3 */
                LRADC_DELAY_KICK |
                LRADC_DELAY_DELAY(lradc->settling_delay),
                        LRADC_DELAY(2));
@@ -532,7 +532,7 @@ static void mxs_lradc_setup_ts_pressure(struct mxs_lradc *lradc, unsigned ch1,
         */
        mxs_lradc_reg_wrt(lradc,
                LRADC_DELAY_TRIGGER(0) | /* don't trigger ADC */
-               LRADC_DELAY_TRIGGER_DELAYS(1 << 3) | /* trigger DELAY unit#3 */
+               LRADC_DELAY_TRIGGER_DELAYS(BIT(3)) | /* trigger DELAY unit#3 */
                LRADC_DELAY_KICK |
                LRADC_DELAY_DELAY(lradc->settling_delay), LRADC_DELAY(2));
 }
@@ -850,7 +850,7 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val)
 
        /* Enable the IRQ and start sampling the channel. */
        mxs_lradc_reg_set(lradc, LRADC_CTRL1_LRADC_IRQ_EN(0), LRADC_CTRL1);
-       mxs_lradc_reg_set(lradc, 1 << 0, LRADC_CTRL0);
+       mxs_lradc_reg_set(lradc, BIT(0), LRADC_CTRL0);
 
        /* Wait for completion on the channel, 1 second max. */
        ret = wait_for_completion_killable_timeout(&lradc->completion, HZ);
@@ -993,7 +993,7 @@ static ssize_t mxs_lradc_show_scale_available_ch(struct device *dev,
        int i, len = 0;
 
        for (i = 0; i < ARRAY_SIZE(lradc->scale_avail[ch]); i++)
-               len += sprintf(buf + len, "%d.%09u ",
+               len += sprintf(buf + len, "%u.%09u ",
                               lradc->scale_avail[ch][i].integer,
                               lradc->scale_avail[ch][i].nano);
 
index 8ad71691fc090cf183f158291f8a352810a17075..c5382374ddf6903f37d248e2f69d8f4b4da4dbcd 100644 (file)
 #define SPEAR_ADC_CLK_HIGH(x)          (((x) & 0xf) << 4)
 
 /* Bit definitions for SPEAR_ADC_STATUS */
-#define SPEAR_ADC_STATUS_START_CONVERSION      (1 << 0)
+#define SPEAR_ADC_STATUS_START_CONVERSION      BIT(0)
 #define SPEAR_ADC_STATUS_CHANNEL_NUM(x)                ((x) << 1)
-#define SPEAR_ADC_STATUS_ADC_ENABLE            (1 << 4)
+#define SPEAR_ADC_STATUS_ADC_ENABLE            BIT(4)
 #define SPEAR_ADC_STATUS_AVG_SAMPLE(x)         ((x) << 5)
-#define SPEAR_ADC_STATUS_VREF_INTERNAL         (1 << 9)
+#define SPEAR_ADC_STATUS_VREF_INTERNAL         BIT(9)
 
 #define SPEAR_ADC_DATA_MASK            0x03ff
 #define SPEAR_ADC_DATA_BITS            10
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 59ad5a3efe9cb3cf1a7a1f2e8fcab693421d64c4..0c9c86d7b5095b96a6248aff0d045bd3f3206008 100644 (file)
@@ -72,7 +72,7 @@ static int iio_dummy_evgen_create(void)
        int ret, i;
 
        iio_evgen = kzalloc(sizeof(*iio_evgen), GFP_KERNEL);
-       if (iio_evgen == NULL)
+       if (!iio_evgen)
                return -ENOMEM;
 
        iio_evgen->base = irq_alloc_descs(-1, 0, IIO_EVENTGEN_NO, 0);
@@ -105,7 +105,7 @@ int iio_dummy_evgen_get_irq(void)
 {
        int i, ret = 0;
 
-       if (iio_evgen == NULL)
+       if (!iio_evgen)
                return -ENODEV;
 
        mutex_lock(&iio_evgen->lock);
index e4520213f627fe431597817ac8c4099bde40f1c4..b47bf9fb64be02fd2ad7cf4b3f8b428e52cf4999 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>
@@ -589,7 +588,7 @@ static int iio_dummy_probe(int index)
         * for chip specific state information.
         */
        indio_dev = iio_device_alloc(sizeof(*st));
-       if (indio_dev == NULL) {
+       if (!indio_dev) {
                ret = -ENOMEM;
                goto error_ret;
        }
index 360a4c980722267d8dc2dba1f7288fbbd7666376..a651b8922d0a93039eb8ef6c71a35e7dd9ea0f48 100644 (file)
@@ -50,7 +50,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
        u16 *data;
 
        data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
-       if (data == NULL)
+       if (!data)
                goto done;
 
        if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
@@ -122,7 +122,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
 
        /* Allocate a buffer to use - here a kfifo */
        buffer = iio_kfifo_allocate();
-       if (buffer == NULL) {
+       if (!buffer) {
                ret = -ENOMEM;
                goto error_ret;
        }
@@ -161,7 +161,7 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
                                                 "iio_simple_dummy_consumer%d",
                                                 indio_dev->id);
 
-       if (indio_dev->pollfunc == NULL) {
+       if (!indio_dev->pollfunc) {
                ret = -ENOMEM;
                goto error_free_buffer;
        }
index 79194399e0404fae6a4e3ea7dee42dd78f5918d6..c18109c55497087076df8f780fe81c1270524676 100644 (file)
@@ -703,7 +703,7 @@ static int ad5933_probe(struct i2c_client *client,
        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);
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..f3d0da2fe4589c29c9ff318cb64555f05ab46e1a 100644 (file)
@@ -10,7 +10,6 @@
  *
  * */
 
-
 #ifndef HMC5843_CORE_H
 #define HMC5843_CORE_H
 
@@ -32,16 +31,24 @@ enum hmc5843_ids {
        HMC5983_ID,
 };
 
+/**
+ * struct hcm5843_data - device specific data
+ * @dev:               actual device
+ * @lock:              update and read regmap data
+ * @regmap:            hardware access register maps
+ * @variant:           describe chip variants
+ * @buffer:            3x 16-bit channels + padding + 64-bit timestamp
+ **/
 struct hmc5843_data {
        struct device *dev;
        struct mutex lock;
        struct regmap *regmap;
        const struct hmc5843_chip_info *variant;
-       __be16 buffer[8]; /* 3x 16-bit channels + padding + 64-bit timestamp */
+       __be16 buffer[8];
 };
 
 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 90cc18b703cf67ae6c089c36d51d8ebde6f28106..fffca3a9f637b868b00ec57126b84f4c72c64d7e 100644 (file)
@@ -1,25 +1,25 @@
-/*  Copyright (C) 2010 Texas Instruments
-    Author: Shubhrajyoti Datta <shubhrajyoti@ti.com>
   Acknowledgement: Jonathan Cameron <jic23@kernel.org> for valuable inputs.
-
-    Support for HMC5883 and HMC5883L by Peter Meerwald <pmeerw@pmeerw.net>.
-
-    Split to multiple files by Josef Gajdusek <atx@atx.name> - 2014
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
   You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+/*
+ * Device driver for the the HMC5843 multi-chip module designed
* for low field magnetic sensing.
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * Author: Shubhrajyoti Datta <shubhrajyoti@ti.com>
+ * Acknowledgment: Jonathan Cameron <jic23@kernel.org> for valuable inputs.
+ * Support for HMC5883 and HMC5883L by Peter Meerwald <pmeerw@pmeerw.net>.
+ * Split to multiple files by Josef Gajdusek <atx@atx.name> - 2014
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
 
 #include <linux/module.h>
 #include <linux/regmap.h>
@@ -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);
@@ -604,9 +609,9 @@ 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;
+               goto buffer_setup_err;
 
        ret = iio_device_register(indio_dev);
        if (ret < 0)
@@ -616,6 +621,8 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 
 buffer_cleanup:
        iio_triggered_buffer_cleanup(indio_dev);
+buffer_setup_err:
+       hmc5843_set_mode(iio_priv(indio_dev), HMC5843_MODE_SLEEP);
        return ret;
 }
 EXPORT_SYMBOL(hmc5843_common_probe);
index 6acd614cdbc6529ae22d4df7c53548f1e3852455..ff08667fa2f60071ab6a5dd800830db2ae03b224 100644 (file)
 #include "hmc5843.h"
 
 static const struct regmap_range hmc5843_readable_ranges[] = {
-               regmap_reg_range(0, HMC5843_ID_END),
+       regmap_reg_range(0, HMC5843_ID_END),
 };
 
-static struct regmap_access_table hmc5843_readable_table = {
-               .yes_ranges = hmc5843_readable_ranges,
-               .n_yes_ranges = ARRAY_SIZE(hmc5843_readable_ranges),
+static const struct regmap_access_table hmc5843_readable_table = {
+       .yes_ranges = hmc5843_readable_ranges,
+       .n_yes_ranges = ARRAY_SIZE(hmc5843_readable_ranges),
 };
 
 static const struct regmap_range hmc5843_writable_ranges[] = {
-               regmap_reg_range(0, HMC5843_MODE_REG),
+       regmap_reg_range(0, HMC5843_MODE_REG),
 };
 
-static struct regmap_access_table hmc5843_writable_table = {
-               .yes_ranges = hmc5843_writable_ranges,
-               .n_yes_ranges = ARRAY_SIZE(hmc5843_writable_ranges),
+static const struct regmap_access_table hmc5843_writable_table = {
+       .yes_ranges = hmc5843_writable_ranges,
+       .n_yes_ranges = ARRAY_SIZE(hmc5843_writable_ranges),
 };
 
 static const struct regmap_range hmc5843_volatile_ranges[] = {
-               regmap_reg_range(HMC5843_DATA_OUT_MSB_REGS, HMC5843_STATUS_REG),
+       regmap_reg_range(HMC5843_DATA_OUT_MSB_REGS, HMC5843_STATUS_REG),
 };
 
-static struct regmap_access_table hmc5843_volatile_table = {
-               .yes_ranges = hmc5843_volatile_ranges,
-               .n_yes_ranges = ARRAY_SIZE(hmc5843_volatile_ranges),
+static const struct regmap_access_table hmc5843_volatile_table = {
+       .yes_ranges = hmc5843_volatile_ranges,
+       .n_yes_ranges = ARRAY_SIZE(hmc5843_volatile_ranges),
 };
 
-static struct regmap_config hmc5843_i2c_regmap_config = {
-               .reg_bits = 8,
-               .val_bits = 8,
+static const struct regmap_config hmc5843_i2c_regmap_config = {
+       .reg_bits = 8,
+       .val_bits = 8,
 
-               .rd_table = &hmc5843_readable_table,
-               .wr_table = &hmc5843_writable_table,
-               .volatile_table = &hmc5843_volatile_table,
+       .rd_table = &hmc5843_readable_table,
+       .wr_table = &hmc5843_writable_table,
+       .volatile_table = &hmc5843_volatile_table,
 
-               .cache_type = REGCACHE_RBTREE,
+       .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 98c4b57101c9d91bc494fb209a416d3dd37d5fc8..8e658f736e1f6278d33eb13ec3ae256e1ad2c1d7 100644 (file)
@@ -19,7 +19,7 @@ static const struct regmap_range hmc5843_readable_ranges[] = {
                regmap_reg_range(0, HMC5843_ID_END),
 };
 
-static struct regmap_access_table hmc5843_readable_table = {
+static const struct regmap_access_table hmc5843_readable_table = {
                .yes_ranges = hmc5843_readable_ranges,
                .n_yes_ranges = ARRAY_SIZE(hmc5843_readable_ranges),
 };
@@ -28,7 +28,7 @@ static const struct regmap_range hmc5843_writable_ranges[] = {
                regmap_reg_range(0, HMC5843_MODE_REG),
 };
 
-static struct regmap_access_table hmc5843_writable_table = {
+static const struct regmap_access_table hmc5843_writable_table = {
                .yes_ranges = hmc5843_writable_ranges,
                .n_yes_ranges = ARRAY_SIZE(hmc5843_writable_ranges),
 };
@@ -37,12 +37,12 @@ static const struct regmap_range hmc5843_volatile_ranges[] = {
                regmap_reg_range(HMC5843_DATA_OUT_MSB_REGS, HMC5843_STATUS_REG),
 };
 
-static struct regmap_access_table hmc5843_volatile_table = {
+static const struct regmap_access_table hmc5843_volatile_table = {
                .yes_ranges = hmc5843_volatile_ranges,
                .n_yes_ranges = ARRAY_SIZE(hmc5843_volatile_ranges),
 };
 
-static struct regmap_config hmc5843_spi_regmap_config = {
+static const struct regmap_config hmc5843_spi_regmap_config = {
                .reg_bits = 8,
                .val_bits = 8,
 
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..f12b2e50329b6a209af4e95cebaa10a8722ad74b 100644 (file)
@@ -216,9 +216,13 @@ error_ret:
 
 static int ade7754_reset(struct device *dev)
 {
+       int ret;
        u8 val;
 
-       ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       if (ret < 0)
+               return ret;
+
        val |= 1 << 6; /* Software Chip Reset */
        return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
 }
@@ -362,9 +366,16 @@ error_ret:
 /* Power down the device */
 static int ade7754_stop_device(struct device *dev)
 {
+       int ret;
        u8 val;
 
-       ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       ret = ade7754_spi_read_reg_8(dev, ADE7754_OPMODE, &val);
+       if (ret < 0) {
+               dev_err(dev, "unable to power down the device, error: %d",
+                       ret);
+               return ret;
+       }
+
        val |= 7 << 3;  /* ADE7754 powered down */
        return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val);
 }
@@ -432,7 +443,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--;
 
@@ -539,12 +550,15 @@ static int ade7754_probe(struct spi_device *spi)
        /* Get the device into a sane initial state */
        ret = ade7754_initial_setup(indio_dev);
        if (ret)
-               return ret;
+               goto powerdown_on_error;
        ret = iio_device_register(indio_dev);
        if (ret)
-               return ret;
+               goto powerdown_on_error;
+       return ret;
 
-       return 0;
+powerdown_on_error:
+       ade7754_stop_device(&indio_dev->dev);
+       return ret;
 }
 
 /* fixme, confirm ordering in this function */
index 70e96b20c2ebfbc8f57e6f280ddc4a9989bffce3..77141ae1349dfdb9e359d1976254ddc351b110a6 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,
@@ -832,7 +833,7 @@ static int ade7758_probe(struct spi_device *spi)
        if (!st->rx)
                return -ENOMEM;
        st->tx = kcalloc(ADE7758_MAX_TX, sizeof(*st->tx), GFP_KERNEL);
-       if (st->tx == NULL) {
+       if (!st->tx) {
                ret = -ENOMEM;
                goto error_free_rx;
        }
index 3792b57616456c99c55ac6a35cb7b8adc97671dc..9a24e0226f8baba43153801fae7df9292b266a1d 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);
 
@@ -134,7 +132,7 @@ int ade7758_configure_ring(struct iio_dev *indio_dev)
                                                 indio_dev,
                                                 "ade7759_consumer%d",
                                                 indio_dev->id);
-       if (indio_dev->pollfunc == NULL) {
+       if (!indio_dev->pollfunc) {
                ret = -ENOMEM;
                goto error_iio_kfifo_free;
        }
index 6f45ce0478d760bd80aee3f2551ee12a7af2be76..5b35a7f08f4f7588803b1255d4c7748a11b6ed84 100644 (file)
@@ -66,7 +66,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
        st->trig = iio_trigger_alloc("%s-dev%d",
                                        spi_get_device_id(st->us)->name,
                                        indio_dev->id);
-       if (st->trig == NULL) {
+       if (!st->trig) {
                ret = -ENOMEM;
                goto error_ret;
        }
index b0c7dbc8a4283c88de229bc2332676a82412e9a5..dbceda1e67eaba530687b131bdfddb014d86181d 100644 (file)
@@ -218,15 +218,16 @@ static int ade7759_reset(struct device *dev)
        int ret;
        u16 val;
 
-       ade7759_spi_read_reg_16(dev,
+       ret = ade7759_spi_read_reg_16(dev,
                        ADE7759_MODE,
                        &val);
+       if (ret < 0)
+               return ret;
+
        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);
@@ -301,11 +302,18 @@ error_ret:
 /* Power down the device */
 static int ade7759_stop_device(struct device *dev)
 {
+       int ret;
        u16 val;
 
-       ade7759_spi_read_reg_16(dev,
+       ret = ade7759_spi_read_reg_16(dev,
                        ADE7759_MODE,
                        &val);
+       if (ret < 0) {
+               dev_err(dev, "unable to power down the device, error: %d\n",
+                       ret);
+               return ret;
+       }
+
        val |= 1 << 4;  /* AD converters can be turned off */
 
        return ade7759_spi_write_reg_16(dev, ADE7759_MODE, val);
@@ -374,7 +382,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 +473,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..7bc3e4a73834d5e305b47d93f83e8d2e96e95f4f 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;
        }
 
@@ -198,7 +198,7 @@ static ssize_t ad2s1210_show_fclkin(struct device *dev,
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
 
-       return sprintf(buf, "%d\n", st->fclkin);
+       return sprintf(buf, "%u\n", st->fclkin);
 }
 
 static ssize_t ad2s1210_store_fclkin(struct device *dev,
@@ -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;
        }
 
@@ -237,7 +237,7 @@ static ssize_t ad2s1210_show_fexcit(struct device *dev,
 {
        struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
 
-       return sprintf(buf, "%d\n", st->fexcit);
+       return sprintf(buf, "%u\n", st->fexcit);
 }
 
 static ssize_t ad2s1210_store_fexcit(struct device *dev,
@@ -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 a24caf73ae0b97aec156bc97be60b21d939800a9..0c1976ddee7489c6d4165e3e4e01990e0b7952e3 100644 (file)
@@ -24,7 +24,7 @@ static DEFINE_MUTEX(iio_prtc_trigger_list_lock);
 
 struct iio_prtc_trigger_info {
        struct rtc_device *rtc;
-       int frequency;
+       unsigned int frequency;
        struct rtc_task task;
        bool state;
 };
@@ -36,7 +36,7 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
 
        if (trig_info->frequency == 0 && state)
                return -EINVAL;
-       dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
+       dev_dbg(&trig_info->rtc->dev, "trigger frequency is %u\n",
                        trig_info->frequency);
        ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
        if (ret == 0)
@@ -62,10 +62,10 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
 {
        struct iio_trigger *trig = to_iio_trigger(dev);
        struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
-       int val;
+       unsigned int val;
        int ret;
 
-       ret = kstrtoint(buf, 10, &val);
+       ret = kstrtouint(buf, 10, &val);
        if (ret)
                goto error_ret;
 
@@ -74,10 +74,8 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
                if (ret == 0 && trig_info->state && trig_info->frequency == 0)
                        ret = rtc_irq_set_state(trig_info->rtc,
                                                &trig_info->task, 1);
-       } else if (val == 0) {
-               ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
        } else
-               ret = -EINVAL;
+               ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
        if (ret)
                goto error_ret;
 
@@ -126,7 +124,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
        int i, ret;
 
        for (i = 0;; i++) {
-               if (pdata[i] == NULL)
+               if (!pdata[i])
                        break;
                trig = iio_trigger_alloc("periodic%s", pdata[i]);
                if (!trig) {
@@ -144,7 +142,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
                trig->ops = &iio_prtc_trigger_ops;
                /* RTC access */
                trig_info->rtc = rtc_class_open(pdata[i]);
-               if (trig_info->rtc == NULL) {
+               if (!trig_info->rtc) {
                        ret = -EINVAL;
                        goto error_free_trig_info;
                }
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..3bad441de8dc90df646caecb64e40e54b83c15bc 100644 (file)
@@ -53,8 +53,7 @@ static lnd_t the_o2iblnd = {
 
 kib_data_t           kiblnd_data;
 
-static __u32
-kiblnd_cksum(void *ptr, int nob)
+static __u32 kiblnd_cksum(void *ptr, int nob)
 {
        char  *c  = ptr;
        __u32  sum = 0;
@@ -66,8 +65,7 @@ kiblnd_cksum(void *ptr, int nob)
        return (sum == 0) ? 1 : sum;
 }
 
-static char *
-kiblnd_msgtype2str(int type)
+static char *kiblnd_msgtype2str(int type)
 {
        switch (type) {
        case IBLND_MSG_CONNREQ:
@@ -105,8 +103,7 @@ kiblnd_msgtype2str(int type)
        }
 }
 
-static int
-kiblnd_msgtype2size(int type)
+static int kiblnd_msgtype2size(int type)
 {
        const int hdr_size = offsetof(kib_msg_t, ibm_u);
 
@@ -139,15 +136,14 @@ kiblnd_msgtype2size(int type)
        }
 }
 
-static int
-kiblnd_unpack_rd(kib_msg_t *msg, int flip)
+static int kiblnd_unpack_rd(kib_msg_t *msg, int flip)
 {
        kib_rdma_desc_t   *rd;
        int             nob;
        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 +163,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) {
@@ -187,9 +183,8 @@ kiblnd_unpack_rd(kib_msg_t *msg, int flip)
        return 0;
 }
 
-void
-kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
-                int credits, lnet_nid_t dstnid, __u64 dststamp)
+void 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;
 
@@ -212,8 +207,7 @@ kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
        }
 }
 
-int
-kiblnd_unpack_msg(kib_msg_t *msg, int nob)
+int kiblnd_unpack_msg(kib_msg_t *msg, int nob)
 {
        const int hdr_size = offsetof(kib_msg_t, ibm_u);
        __u32     msg_cksum;
@@ -269,8 +263,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);
@@ -324,8 +318,7 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
        return 0;
 }
 
-int
-kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
+int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
 {
        kib_peer_t      *peer;
        kib_net_t       *net = ni->ni_data;
@@ -356,7 +349,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);
@@ -367,18 +360,17 @@ kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
        return 0;
 }
 
-void
-kiblnd_destroy_peer (kib_peer_t *peer)
+void 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));
 
@@ -389,8 +381,7 @@ kiblnd_destroy_peer (kib_peer_t *peer)
        atomic_dec(&net->ibn_npeers);
 }
 
-kib_peer_t *
-kiblnd_find_peer_locked (lnet_nid_t nid)
+kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid)
 {
        /* the caller is responsible for accounting the additional reference
         * that this creates */
@@ -398,11 +389,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 */
 
@@ -418,20 +409,18 @@ kiblnd_find_peer_locked (lnet_nid_t nid)
        return NULL;
 }
 
-void
-kiblnd_unlink_peer_locked (kib_peer_t *peer)
+void 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);
 }
 
-static int
-kiblnd_get_peer_info(lnet_ni_t *ni, int index,
-                     lnet_nid_t *nidp, int *count)
+static int kiblnd_get_peer_info(lnet_ni_t *ni, int index,
+                               lnet_nid_t *nidp, int *count)
 {
        kib_peer_t          *peer;
        struct list_head            *ptmp;
@@ -442,10 +431,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));
 
@@ -468,8 +457,7 @@ kiblnd_get_peer_info(lnet_ni_t *ni, int index,
        return -ENOENT;
 }
 
-static void
-kiblnd_del_peer_locked(kib_peer_t *peer)
+static void kiblnd_del_peer_locked(kib_peer_t *peer)
 {
        struct list_head           *ctmp;
        struct list_head           *cnxt;
@@ -478,7 +466,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);
@@ -489,10 +477,9 @@ kiblnd_del_peer_locked(kib_peer_t *peer)
         * last ref on it. */
 }
 
-static int
-kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
+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 +499,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 +512,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);
@@ -543,8 +530,7 @@ kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
        return rc;
 }
 
-static kib_conn_t *
-kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
+static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
 {
        kib_peer_t          *peer;
        struct list_head            *ptmp;
@@ -556,25 +542,26 @@ 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;
 
                                conn = list_entry(ctmp, kib_conn_t,
                                                      ibc_list);
                                kiblnd_conn_addref(conn);
-                               read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
-                                                      flags);
+                               read_unlock_irqrestore(
+                                       &kiblnd_data.kib_global_lock,
+                                       flags);
                                return conn;
                        }
                }
@@ -584,8 +571,7 @@ kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
        return NULL;
 }
 
-int
-kiblnd_translate_mtu(int value)
+int kiblnd_translate_mtu(int value)
 {
        switch (value) {
        default:
@@ -605,8 +591,7 @@ kiblnd_translate_mtu(int value)
        }
 }
 
-static void
-kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
+static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
 {
        int        mtu;
 
@@ -615,13 +600,12 @@ 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;
 }
 
-static int
-kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
+static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
 {
        cpumask_t       *mask;
        int             vectors;
@@ -638,8 +622,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;
        }
@@ -648,9 +632,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
        return 1;
 }
 
-kib_conn_t *
-kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
-                  int state, int version)
+kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
+                               int state, int version)
 {
        /* CAVEAT EMPTOR:
         * If the new conn is created successfully it takes over the caller's
@@ -835,7 +818,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;
 
@@ -851,23 +834,22 @@ kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
        return NULL;
 }
 
-void
-kiblnd_destroy_conn (kib_conn_t *conn)
+void 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 +858,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:
@@ -898,7 +880,8 @@ kiblnd_destroy_conn (kib_conn_t *conn)
 
        if (conn->ibc_rxs != NULL) {
                LIBCFS_FREE(conn->ibc_rxs,
-                           IBLND_RX_MSGS(conn->ibc_version) * sizeof(kib_rx_t));
+                           IBLND_RX_MSGS(conn->ibc_version)
+                             * sizeof(kib_rx_t));
        }
 
        if (conn->ibc_connvars != NULL)
@@ -919,15 +902,14 @@ kiblnd_destroy_conn (kib_conn_t *conn)
        LIBCFS_FREE(conn, sizeof(*conn));
 }
 
-int
-kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
+int 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",
@@ -941,23 +923,23 @@ kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
        return count;
 }
 
-int
-kiblnd_close_stale_conns_locked (kib_peer_t *peer,
-                                int version, __u64 incarnation)
+int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
+                                    int version, __u64 incarnation)
 {
        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);
 
                if (conn->ibc_version     == version &&
                    conn->ibc_incarnation == incarnation)
                        continue;
 
-               CDEBUG(D_NET, "Closing stale conn -> %s version: %x, incarnation:%#llx(%x, %#llx)\n",
+               CDEBUG(D_NET,
+                      "Closing stale conn -> %s version: %x, incarnation:%#llx(%x, %#llx)\n",
                       libcfs_nid2str(peer->ibp_nid),
                       conn->ibc_version, conn->ibc_incarnation,
                       version, incarnation);
@@ -969,8 +951,7 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer,
        return count;
 }
 
-static int
-kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
+static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
 {
        kib_peer_t           *peer;
        struct list_head             *ptmp;
@@ -991,10 +972,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));
 
@@ -1017,8 +998,7 @@ kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
        return (count == 0) ? -ENOENT : 0;
 }
 
-int
-kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
+int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
 {
        struct libcfs_ioctl_data *data = arg;
        int                    rc = -EINVAL;
@@ -1049,7 +1029,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 */
@@ -1071,8 +1051,7 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
        return rc;
 }
 
-void
-kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
+void 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 +1063,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,11 +1082,9 @@ 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
-kiblnd_free_pages(kib_pages_t *p)
+void kiblnd_free_pages(kib_pages_t *p)
 {
        int     npages = p->ibp_npages;
        int     i;
@@ -1120,8 +1097,7 @@ kiblnd_free_pages(kib_pages_t *p)
        LIBCFS_FREE(p, offsetof(kib_pages_t, ibp_pages[npages]));
 }
 
-int
-kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
+int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
 {
        kib_pages_t     *p;
        int             i;
@@ -1151,19 +1127,18 @@ kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
        return 0;
 }
 
-void
-kiblnd_unmap_rx_descs(kib_conn_t *conn)
+void 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,
@@ -1176,8 +1151,7 @@ kiblnd_unmap_rx_descs(kib_conn_t *conn)
        conn->ibc_rx_pages = NULL;
 }
 
-void
-kiblnd_map_rx_descs(kib_conn_t *conn)
+void kiblnd_map_rx_descs(kib_conn_t *conn)
 {
        kib_rx_t       *rx;
        struct page    *pg;
@@ -1194,9 +1168,10 @@ kiblnd_map_rx_descs(kib_conn_t *conn)
                rx->rx_msg = (kib_msg_t *)(((char *)page_address(pg)) + pg_off);
 
                rx->rx_msgaddr = kiblnd_dma_map_single(conn->ibc_hdev->ibh_ibdev,
-                                                      rx->rx_msg, IBLND_MSG_SIZE,
+                                                      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,24 +1180,23 @@ 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));
                }
        }
 }
 
-static void
-kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
+static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
 {
        kib_hca_dev_t  *hdev = tpo->tpo_hdev;
        kib_tx_t       *tx;
        int          i;
 
-       LASSERT (tpo->tpo_pool.po_allocated == 0);
+       LASSERT(tpo->tpo_pool.po_allocated == 0);
 
        if (hdev == NULL)
                return;
@@ -1239,8 +1213,7 @@ kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
        tpo->tpo_hdev = NULL;
 }
 
-static kib_hca_dev_t *
-kiblnd_current_hdev(kib_dev_t *dev)
+static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev)
 {
        kib_hca_dev_t *hdev;
        unsigned long  flags;
@@ -1265,8 +1238,7 @@ kiblnd_current_hdev(kib_dev_t *dev)
        return hdev;
 }
 
-static void
-kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
+static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
 {
        kib_pages_t    *txpgs = tpo->tpo_tx_pages;
        kib_pool_t     *pool  = &tpo->tpo_pool;
@@ -1278,15 +1250,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,29 +1272,28 @@ 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);
                }
        }
 }
 
-struct ib_mr *
-kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size)
+struct ib_mr *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];
@@ -1336,14 +1307,13 @@ kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size)
        return NULL;
 }
 
-struct ib_mr *
-kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
+struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
 {
        struct ib_mr *prev_mr;
        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)
@@ -1370,10 +1340,9 @@ kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
        return mr;
 }
 
-static void
-kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
+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);
@@ -1384,8 +1353,7 @@ kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
        LIBCFS_FREE(pool, sizeof(kib_fmr_pool_t));
 }
 
-static void
-kiblnd_destroy_fmr_pool_list(struct list_head *head)
+static void kiblnd_destroy_fmr_pool_list(struct list_head *head)
 {
        kib_fmr_pool_t *pool;
 
@@ -1410,8 +1378,8 @@ static int kiblnd_fmr_flush_trigger(int ncpts)
        return max(IBLND_FMR_POOL_FLUSH, size);
 }
 
-static int
-kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo)
+static int kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps,
+                                 kib_fmr_pool_t **pp_fpo)
 {
        /* FMR pool for RDMA */
        kib_dev_t              *dev = fps->fps_net->ibn_dev;
@@ -1451,8 +1419,8 @@ kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo)
        return 0;
 }
 
-static void
-kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, struct list_head *zombies)
+static void kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps,
+                                   struct list_head *zombies)
 {
        if (fps->fps_net == NULL) /* intialized? */
                return;
@@ -1473,8 +1441,7 @@ kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, struct list_head *zombies)
        spin_unlock(&fps->fps_lock);
 }
 
-static void
-kiblnd_fini_fmr_poolset(kib_fmr_poolset_t *fps)
+static void kiblnd_fini_fmr_poolset(kib_fmr_poolset_t *fps)
 {
        if (fps->fps_net != NULL) { /* initialized? */
                kiblnd_destroy_fmr_pool_list(&fps->fps_failed_pool_list);
@@ -1482,9 +1449,9 @@ kiblnd_fini_fmr_poolset(kib_fmr_poolset_t *fps)
        }
 }
 
-static int
-kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, kib_net_t *net,
-                       int pool_size, int flush_trigger)
+static int kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt,
+                                  kib_net_t *net, int pool_size,
+                                  int flush_trigger)
 {
        kib_fmr_pool_t *fpo;
        int          rc;
@@ -1506,8 +1473,7 @@ kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, kib_net_t *net,
        return rc;
 }
 
-static int
-kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
+static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
 {
        if (fpo->fpo_map_count != 0) /* still in use */
                return 0;
@@ -1516,10 +1482,9 @@ kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
        return cfs_time_aftereq(now, fpo->fpo_deadline);
 }
 
-void
-kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
+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 +1492,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;
@@ -1556,9 +1521,8 @@ kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
                kiblnd_destroy_fmr_pool_list(&zombies);
 }
 
-int
-kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
-                   __u64 iov, kib_fmr_t *fmr)
+int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
+                       __u64 iov, kib_fmr_t *fmr)
 {
        struct ib_pool_fmr *pfmr;
        kib_fmr_pool_t     *fpo;
@@ -1597,7 +1561,8 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
 
        if (fps->fps_increasing) {
                spin_unlock(&fps->fps_lock);
-               CDEBUG(D_NET, "Another thread is allocating new FMR pool, waiting for her to complete\n");
+               CDEBUG(D_NET,
+                       "Another thread is allocating new FMR pool, waiting for her to complete\n");
                schedule();
                goto again;
 
@@ -1627,17 +1592,15 @@ kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
        goto again;
 }
 
-static void
-kiblnd_fini_pool(kib_pool_t *pool)
+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);
 }
 
-static void
-kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size)
+static void kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size)
 {
        CDEBUG(D_NET, "Initialize %s pool\n", ps->ps_name);
 
@@ -1648,8 +1611,7 @@ kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size)
        pool->po_size     = size;
 }
 
-static void
-kiblnd_destroy_pool_list(struct list_head *head)
+static void kiblnd_destroy_pool_list(struct list_head *head)
 {
        kib_pool_t *pool;
 
@@ -1657,13 +1619,12 @@ 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);
        }
 }
 
-static void
-kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies)
+static void kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies)
 {
        if (ps->ps_net == NULL) /* intialized? */
                return;
@@ -1682,8 +1643,7 @@ kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies)
        spin_unlock(&ps->ps_lock);
 }
 
-static void
-kiblnd_fini_poolset(kib_poolset_t *ps)
+static void kiblnd_fini_poolset(kib_poolset_t *ps)
 {
        if (ps->ps_net != NULL) { /* initialized? */
                kiblnd_destroy_pool_list(&ps->ps_failed_pool_list);
@@ -1691,13 +1651,12 @@ kiblnd_fini_poolset(kib_poolset_t *ps)
        }
 }
 
-static int
-kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
-                   kib_net_t *net, char *name, int size,
-                   kib_ps_pool_create_t po_create,
-                   kib_ps_pool_destroy_t po_destroy,
-                   kib_ps_node_init_t nd_init,
-                   kib_ps_node_fini_t nd_fini)
+static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
+                              kib_net_t *net, char *name, int size,
+                              kib_ps_pool_create_t po_create,
+                              kib_ps_pool_destroy_t po_destroy,
+                              kib_ps_node_init_t nd_init,
+                              kib_ps_node_fini_t nd_fini)
 {
        kib_pool_t      *pool;
        int             rc;
@@ -1727,8 +1686,7 @@ kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
        return rc;
 }
 
-static int
-kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
+static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
 {
        if (pool->po_allocated != 0) /* still in use */
                return 0;
@@ -1737,10 +1695,9 @@ kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
        return cfs_time_aftereq(now, pool->po_deadline);
 }
 
-void
-kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
+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 +1707,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--;
 
@@ -1768,8 +1725,7 @@ kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
                kiblnd_destroy_pool_list(&zombies);
 }
 
-struct list_head *
-kiblnd_pool_alloc_node(kib_poolset_t *ps)
+struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps)
 {
        struct list_head            *node;
        kib_pool_t          *pool;
@@ -1831,8 +1787,7 @@ kiblnd_pool_alloc_node(kib_poolset_t *ps)
        goto again;
 }
 
-void
-kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
+void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
 {
        kib_pmr_pool_t      *ppo = pmr->pmr_pool;
        struct ib_mr    *mr  = pmr->pmr_mr;
@@ -1843,8 +1798,7 @@ kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
                ib_dereg_mr(mr);
 }
 
-int
-kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
+int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
                    kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr)
 {
        kib_phys_mr_t *pmr;
@@ -1889,19 +1843,16 @@ kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
        return rc;
 }
 
-static void
-kiblnd_destroy_pmr_pool(kib_pool_t *pool)
+static void 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);
-
-       while (!list_empty(&pool->po_free_list)) {
-               pmr = list_entry(pool->po_free_list.next,
-                                    kib_phys_mr_t, pmr_list);
+       LASSERT(pool->po_allocated == 0);
 
-               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) {
@@ -1927,8 +1878,8 @@ static inline int kiblnd_pmr_pool_size(int ncpts)
        return max(IBLND_PMR_POOL, size);
 }
 
-static int
-kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
+static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size,
+                                 kib_pool_t **pp_po)
 {
        struct kib_pmr_pool     *ppo;
        struct kib_pool         *pool;
@@ -1970,13 +1921,12 @@ kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
        return 0;
 }
 
-static void
-kiblnd_destroy_tx_pool(kib_pool_t *pool)
+static void 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);
@@ -2026,8 +1976,8 @@ static int kiblnd_tx_pool_size(int ncpts)
        return max(IBLND_TX_POOL, ntx);
 }
 
-static int
-kiblnd_create_tx_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
+static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size,
+                                kib_pool_t **pp_po)
 {
        int         i;
        int         npg;
@@ -2110,8 +2060,7 @@ kiblnd_create_tx_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
        return -ENOMEM;
 }
 
-static void
-kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
+static void kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
 {
        kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t,
                                             tps_poolset);
@@ -2120,8 +2069,7 @@ kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
        tx->tx_cookie = tps->tps_next_tx_cookie++;
 }
 
-static void
-kiblnd_net_fini_pools(kib_net_t *net)
+static void kiblnd_net_fini_pools(kib_net_t *net)
 {
        int     i;
 
@@ -2162,8 +2110,7 @@ kiblnd_net_fini_pools(kib_net_t *net)
        }
 }
 
-static int
-kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
+static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
 {
        unsigned long   flags;
        int             cpt;
@@ -2291,8 +2238,7 @@ kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
        return rc;
 }
 
-static int
-kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
+static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
 {
        struct ib_device_attr *attr;
        int                 rc;
@@ -2336,8 +2282,7 @@ kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
        return -EINVAL;
 }
 
-static void
-kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
+static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
 {
        int     i;
 
@@ -2356,8 +2301,7 @@ kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
        hdev->ibh_nmrs = 0;
 }
 
-void
-kiblnd_hdev_destroy(kib_hca_dev_t *hdev)
+void kiblnd_hdev_destroy(kib_hca_dev_t *hdev)
 {
        kiblnd_hdev_cleanup_mrs(hdev);
 
@@ -2370,8 +2314,7 @@ kiblnd_hdev_destroy(kib_hca_dev_t *hdev)
        LIBCFS_FREE(hdev, sizeof(*hdev));
 }
 
-static int
-kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
+static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
 {
        struct ib_mr *mr;
        int        i;
@@ -2442,7 +2385,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;
        }
@@ -2454,14 +2397,14 @@ out:
        return 0;
 }
 
-static int
-kiblnd_dummy_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
-{       /* DUMMY */
+/* DUMMY */
+static int kiblnd_dummy_callback(struct rdma_cm_id *cmid,
+                                struct rdma_cm_event *event)
+{
        return 0;
 }
 
-static int
-kiblnd_dev_need_failover(kib_dev_t *dev)
+static int kiblnd_dev_need_failover(kib_dev_t *dev)
 {
        struct rdma_cm_id  *cmid;
        struct sockaddr_in  srcaddr;
@@ -2516,12 +2459,11 @@ kiblnd_dev_need_failover(kib_dev_t *dev)
        return 1;
 }
 
-int
-kiblnd_dev_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 +2474,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);
 
@@ -2655,11 +2597,10 @@ kiblnd_dev_failover(kib_dev_t *dev)
        return rc;
 }
 
-void
-kiblnd_destroy_dev (kib_dev_t *dev)
+void 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);
@@ -2670,8 +2611,7 @@ kiblnd_destroy_dev (kib_dev_t *dev)
        LIBCFS_FREE(dev, sizeof(*dev));
 }
 
-static kib_dev_t *
-kiblnd_create_dev(char *ifname)
+static kib_dev_t *kiblnd_create_dev(char *ifname)
 {
        struct net_device *netdev;
        kib_dev_t        *dev;
@@ -2723,13 +2663,12 @@ kiblnd_create_dev(char *ifname)
        return dev;
 }
 
-static void
-kiblnd_base_shutdown(void)
+static void 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 +2679,11 @@ kiblnd_base_shutdown(void)
 
        case IBLND_INIT_ALL:
        case IBLND_INIT_DATA:
-               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_connd_zombies));
-               LASSERT (list_empty(&kiblnd_data.kib_connd_conns));
+               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_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;
@@ -2762,7 +2700,8 @@ kiblnd_base_shutdown(void)
                i = 2;
                while (atomic_read(&kiblnd_data.kib_nthreads) != 0) {
                        i++;
-                       CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET, /* power of 2? */
+                       /* power of 2 ? */
+                       CDEBUG(((i & (-i)) == i) ? D_WARNING : D_NET,
                               "Waiting for %d threads to terminate\n",
                               atomic_read(&kiblnd_data.kib_nthreads));
                        set_current_state(TASK_UNINTERRUPTIBLE);
@@ -2791,8 +2730,7 @@ kiblnd_base_shutdown(void)
        module_put(THIS_MODULE);
 }
 
-void
-kiblnd_shutdown (lnet_ni_t *ni)
+void kiblnd_shutdown(lnet_ni_t *ni)
 {
        kib_net_t       *net = ni->ni_data;
        rwlock_t     *g_lock = &kiblnd_data.kib_global_lock;
@@ -2842,7 +2780,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,20 +2800,19 @@ kiblnd_shutdown (lnet_ni_t *ni)
 out:
        if (list_empty(&kiblnd_data.kib_devs))
                kiblnd_base_shutdown();
-       return;
 }
 
-static int
-kiblnd_base_startup(void)
+static int kiblnd_base_startup(void)
 {
        struct kib_sched_info   *sched;
        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 */
+       /* zero pointers, flags etc */
+       memset(&kiblnd_data, 0, sizeof(kiblnd_data));
 
        rwlock_init(&kiblnd_data.kib_global_lock);
 
@@ -2886,9 +2823,8 @@ kiblnd_base_startup(void)
        LIBCFS_ALLOC(kiblnd_data.kib_peers,
                     sizeof(struct list_head) *
                            kiblnd_data.kib_peer_hash_size);
-       if (kiblnd_data.kib_peers == NULL) {
+       if (kiblnd_data.kib_peers == NULL)
                goto failed;
-       }
        for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
                INIT_LIST_HEAD(&kiblnd_data.kib_peers[i]);
 
@@ -2955,8 +2891,7 @@ kiblnd_base_startup(void)
        return -ENETDOWN;
 }
 
-static int
-kiblnd_start_schedulers(struct kib_sched_info *sched)
+static int kiblnd_start_schedulers(struct kib_sched_info *sched)
 {
        int     rc = 0;
        int     nthrs;
@@ -2974,12 +2909,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));
@@ -2996,8 +2932,8 @@ kiblnd_start_schedulers(struct kib_sched_info *sched)
        return rc;
 }
 
-static int
-kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, int ncpts)
+static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts,
+                                   int ncpts)
 {
        int     cpt;
        int     rc;
@@ -3022,8 +2958,7 @@ kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, int ncpts)
        return 0;
 }
 
-static kib_dev_t *
-kiblnd_dev_search(char *ifname)
+static kib_dev_t *kiblnd_dev_search(char *ifname)
 {
        kib_dev_t       *alias = NULL;
        kib_dev_t       *dev;
@@ -3055,8 +2990,7 @@ kiblnd_dev_search(char *ifname)
        return alias;
 }
 
-int
-kiblnd_startup (lnet_ni_t *ni)
+int kiblnd_startup(lnet_ni_t *ni)
 {
        char                 *ifname;
        kib_dev_t               *ibdev = NULL;
@@ -3066,7 +3000,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 +3024,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;
@@ -3150,22 +3084,22 @@ net_failed:
        return -ENETDOWN;
 }
 
-static void __exit
-kiblnd_module_fini (void)
+static void __exit kiblnd_module_fini(void)
 {
        lnet_unregister_lnd(&the_o2iblnd);
 }
 
-static int __init
-kiblnd_module_init (void)
+static int __init 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])
-                 <= IBLND_MSG_SIZE);
-       CLASSERT (offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
-                 <= IBLND_MSG_SIZE);
+       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])
+               <= IBLND_MSG_SIZE);
 
        rc = kiblnd_tunables_init();
        if (rc != 0)
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..dbf3749831f9c5993c44e25c6b5f7908347f227f 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 ||
-                credit == IBLND_POSTRX_PEER_CREDIT ||
-                credit == IBLND_POSTRX_RSRVD_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,11 +304,11 @@ 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",
-               msg->ibm_type, credits,
-               libcfs_nid2str(conn->ibc_peer->ibp_nid));
+       CDEBUG(D_NET, "Received %x[%d] from %s\n",
+              msg->ibm_type, credits,
+              libcfs_nid2str(conn->ibc_peer->ibp_nid));
 
        if (credits != 0) {
                /* Have I received credits that will let me send? */
@@ -377,8 +377,8 @@ kiblnd_handle_rx (kib_rx_t *rx)
                break;
 
        case IBLND_MSG_PUT_NAK:
-               CWARN ("PUT_NACK from %s\n",
-                      libcfs_nid2str(conn->ibc_peer->ibp_nid));
+               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,
                                         msg->ibm_u.completion.ibcm_status,
@@ -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;
 }
 
@@ -567,7 +567,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
        for (i = 0, npages = 0; i < rd->rd_nfrags; i++) {
                for (size = 0; size <  rd->rd_frags[i].rf_nob;
                               size += hdev->ibh_page_size) {
-                       pages[npages ++] = (rd->rd_frags[i].rf_addr &
+                       pages[npages++] = (rd->rd_frags[i].rf_addr &
                                            hdev->ibh_page_mask) + size;
                }
        }
@@ -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);
 
@@ -2504,20 +2503,20 @@ kiblnd_reconnect (kib_conn_t *conn, int version,
        CNETERR("%s: retrying (%s), %x, %x, queue_dep: %d, max_frag: %d, msg_size: %d\n",
                libcfs_nid2str(peer->ibp_nid),
                reason, IBLND_MSG_VERSION, version,
-               cp != NULL? cp->ibcp_queue_depth :IBLND_MSG_QUEUE_SIZE(version),
-               cp != NULL? cp->ibcp_max_frags   : IBLND_RDMA_FRAGS(version),
-               cp != NULL? cp->ibcp_max_msg_size: IBLND_MSG_SIZE);
+               cp != NULL ? cp->ibcp_queue_depth  : IBLND_MSG_QUEUE_SIZE(version),
+               cp != NULL ? cp->ibcp_max_frags    : IBLND_RDMA_FRAGS(version),
+               cp != NULL ? cp->ibcp_max_msg_size : IBLND_MSG_SIZE);
 
        kiblnd_connect_peer(peer);
 }
 
 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 faceb9505d84919630675a37f374077fb126b51a..4a14e5109821784374c2d2bc75a430abab826687 100644 (file)
@@ -650,15 +650,19 @@ lnet_prepare(lnet_pid_t requested_pid)
 
        recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES,
                                          sizeof(lnet_me_t));
-       if (recs == NULL)
+       if (recs == NULL) {
+               rc = -ENOMEM;
                goto failed;
+       }
 
        the_lnet.ln_me_containers = recs;
 
        recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
                                          sizeof(lnet_libmd_t));
-       if (recs == NULL)
+       if (recs == NULL) {
+               rc = -ENOMEM;
                goto failed;
+       }
 
        the_lnet.ln_md_containers = recs;
 
index af171e25a5ecdfcd5fb24813adfc648b07b9443c..2dc4c4a1afd0cf1d97d9ab2d50bdbff3f550d8ab 100644 (file)
 #define DEBUG_SUBSYSTEM S_LNET
 #include "../../include/linux/lnet/lib-lnet.h"
 
-typedef struct {                           /* tmp struct for parsing routes */
+struct lnet_text_buf_t {           /* tmp struct for parsing routes */
        struct list_head         ltb_list;      /* stash on lists */
        int             ltb_size;       /* allocated size */
        char           ltb_text[0];     /* text buffer */
-} lnet_text_buf_t;
+};
 
 static int lnet_tbnob;                 /* track text buf allocation */
 #define LNET_MAX_TEXTBUF_NOB     (64<<10)      /* bound allocation */
@@ -365,14 +365,14 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
        return -EINVAL;
 }
 
-static lnet_text_buf_t *
+static struct lnet_text_buf_t *
 lnet_new_text_buf(int str_len)
 {
-       lnet_text_buf_t *ltb;
+       struct lnet_text_buf_t *ltb;
        int           nob;
 
        /* NB allocate space for the terminating 0 */
-       nob = offsetof(lnet_text_buf_t, ltb_text[str_len + 1]);
+       nob = offsetof(struct lnet_text_buf_t, ltb_text[str_len + 1]);
        if (nob > LNET_SINGLE_TEXTBUF_NOB) {
                /* _way_ conservative for "route net gateway..." */
                CERROR("text buffer too big\n");
@@ -395,7 +395,7 @@ lnet_new_text_buf(int str_len)
 }
 
 static void
-lnet_free_text_buf(lnet_text_buf_t *ltb)
+lnet_free_text_buf(struct lnet_text_buf_t *ltb)
 {
        lnet_tbnob -= ltb->ltb_size;
        LIBCFS_FREE(ltb, ltb->ltb_size);
@@ -404,10 +404,10 @@ lnet_free_text_buf(lnet_text_buf_t *ltb)
 static void
 lnet_free_text_bufs(struct list_head *tbs)
 {
-       lnet_text_buf_t  *ltb;
+       struct lnet_text_buf_t  *ltb;
 
        while (!list_empty(tbs)) {
-               ltb = list_entry(tbs->next, lnet_text_buf_t, ltb_list);
+               ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
 
                list_del(&ltb->ltb_list);
                lnet_free_text_buf(ltb);
@@ -421,7 +421,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str)
        char         *sep;
        int            nob;
        int            i;
-       lnet_text_buf_t  *ltb;
+       struct lnet_text_buf_t  *ltb;
 
        INIT_LIST_HEAD(&pending);
 
@@ -479,7 +479,7 @@ lnet_expand1tb(struct list_head *list,
 {
        int           len1 = (int)(sep1 - str);
        int           len2 = strlen(sep2 + 1);
-       lnet_text_buf_t *ltb;
+       struct lnet_text_buf_t *ltb;
 
        LASSERT(*sep1 == '[');
        LASSERT(*sep2 == ']');
@@ -532,14 +532,18 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
                if (enditem == parsed)          /* no empty items */
                        goto failed;
 
-               if (sscanf(parsed, "%d-%d/%d%n", &lo, &hi, &stride, &scanned) < 3) {
+               if (sscanf(parsed, "%d-%d/%d%n", &lo, &hi,
+                          &stride, &scanned) < 3) {
 
                        if (sscanf(parsed, "%d-%d%n", &lo, &hi, &scanned) < 2) {
 
                                /* simple string enumeration */
-                               if (lnet_expand1tb(&pending, str, sep, sep2,
-                                                  parsed, (int)(enditem - parsed)) != 0)
+                               if (lnet_expand1tb(
+                                    &pending, str, sep, sep2,
+                                    parsed,
+                                    (int)(enditem - parsed)) != 0) {
                                        goto failed;
+                               }
 
                                continue;
                        }
@@ -632,7 +636,7 @@ lnet_parse_route(char *str, int *im_a_router)
        struct list_head       *tmp2;
        __u32        net;
        lnet_nid_t      nid;
-       lnet_text_buf_t  *ltb;
+       struct lnet_text_buf_t  *ltb;
        int            rc;
        char         *sep;
        char         *token = str;
@@ -688,7 +692,8 @@ lnet_parse_route(char *str, int *im_a_router)
                list_add_tail(tmp1, tmp2);
 
                while (tmp1 != tmp2) {
-                       ltb = list_entry(tmp1, lnet_text_buf_t, ltb_list);
+                       ltb = list_entry(tmp1, struct lnet_text_buf_t,
+                                        ltb_list);
 
                        rc = lnet_str2tbs_expand(tmp1->next, ltb->ltb_text);
                        if (rc < 0)
@@ -728,12 +733,13 @@ lnet_parse_route(char *str, int *im_a_router)
        LASSERT(!list_empty(&gateways));
 
        list_for_each(tmp1, &nets) {
-               ltb = list_entry(tmp1, lnet_text_buf_t, ltb_list);
+               ltb = list_entry(tmp1, struct lnet_text_buf_t, ltb_list);
                net = libcfs_str2net(ltb->ltb_text);
                LASSERT(net != LNET_NIDNET(LNET_NID_ANY));
 
                list_for_each(tmp2, &gateways) {
-                       ltb = list_entry(tmp2, lnet_text_buf_t, ltb_list);
+                       ltb = list_entry(tmp2, struct lnet_text_buf_t,
+                                        ltb_list);
                        nid = libcfs_str2nid(ltb->ltb_text);
                        LASSERT(nid != LNET_NID_ANY);
 
@@ -766,10 +772,10 @@ lnet_parse_route(char *str, int *im_a_router)
 static int
 lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
 {
-       lnet_text_buf_t   *ltb;
+       struct lnet_text_buf_t   *ltb;
 
        while (!list_empty(tbs)) {
-               ltb = list_entry(tbs->next, lnet_text_buf_t, ltb_list);
+               ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
 
                if (lnet_parse_route(ltb->ltb_text, im_a_router) < 0) {
                        lnet_free_text_bufs(tbs);
@@ -903,8 +909,8 @@ lnet_splitnets(char *source, struct list_head *nets)
        int            offset = 0;
        int            offset2;
        int            len;
-       lnet_text_buf_t  *tb;
-       lnet_text_buf_t  *tb2;
+       struct lnet_text_buf_t  *tb;
+       struct lnet_text_buf_t  *tb2;
        struct list_head       *t;
        char         *sep;
        char         *bracket;
@@ -913,7 +919,7 @@ lnet_splitnets(char *source, struct list_head *nets)
        LASSERT(!list_empty(nets));
        LASSERT(nets->next == nets->prev);     /* single entry */
 
-       tb = list_entry(nets->next, lnet_text_buf_t, ltb_list);
+       tb = list_entry(nets->next, struct lnet_text_buf_t, ltb_list);
 
        for (;;) {
                sep = strchr(tb->ltb_text, ',');
@@ -949,7 +955,7 @@ lnet_splitnets(char *source, struct list_head *nets)
                }
 
                list_for_each(t, nets) {
-                       tb2 = list_entry(t, lnet_text_buf_t, ltb_list);
+                       tb2 = list_entry(t, struct lnet_text_buf_t, ltb_list);
 
                        if (tb2 == tb)
                                continue;
@@ -988,8 +994,8 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
        struct list_head          current_nets;
        struct list_head         *t;
        struct list_head         *t2;
-       lnet_text_buf_t    *tb;
-       lnet_text_buf_t    *tb2;
+       struct lnet_text_buf_t    *tb;
+       struct lnet_text_buf_t    *tb2;
        __u32          net1;
        __u32          net2;
        int              len;
@@ -1012,7 +1018,7 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
        rc = 0;
 
        while (!list_empty(&raw_entries)) {
-               tb = list_entry(raw_entries.next, lnet_text_buf_t,
+               tb = list_entry(raw_entries.next, struct lnet_text_buf_t,
                                    ltb_list);
 
                strncpy(source, tb->ltb_text, sizeof(source)-1);
@@ -1039,12 +1045,12 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
 
                dup = 0;
                list_for_each(t, &current_nets) {
-                       tb = list_entry(t, lnet_text_buf_t, ltb_list);
+                       tb = list_entry(t, struct lnet_text_buf_t, ltb_list);
                        net1 = lnet_netspec2net(tb->ltb_text);
                        LASSERT(net1 != LNET_NIDNET(LNET_NID_ANY));
 
                        list_for_each(t2, &matched_nets) {
-                               tb2 = list_entry(t2, lnet_text_buf_t,
+                               tb2 = list_entry(t2, struct lnet_text_buf_t,
                                                     ltb_list);
                                net2 = lnet_netspec2net(tb2->ltb_text);
                                LASSERT(net2 != LNET_NIDNET(LNET_NID_ANY));
@@ -1065,7 +1071,7 @@ lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
                }
 
                list_for_each_safe(t, t2, &current_nets) {
-                       tb = list_entry(t, lnet_text_buf_t, ltb_list);
+                       tb = list_entry(t, struct lnet_text_buf_t, ltb_list);
 
                        list_del(&tb->ltb_list);
                        list_add_tail(&tb->ltb_list, &matched_nets);
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 3225c069637dc767f09759110792029eb5649799..89d660fefd4896be1331972caae5f22f92bcc9f9 100644 (file)
@@ -123,7 +123,7 @@ lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink)
 
                lmd->md_length = total_length;
 
-               if ((umd->options & LNET_MD_MAX_SIZE) != 0 && /* max size used */
+               if ((umd->options & LNET_MD_MAX_SIZE) != 0 && /* use max size */
                    (umd->max_size < 0 ||
                     umd->max_size > total_length)) /* illegal max_size */
                        return -EINVAL;
index 0f53c761f1a99285bf46e3b9f52128c11058b553..c2fb70e5fc4e08545e0c22056b0f4f3114d40279 100644 (file)
@@ -1530,7 +1530,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
        LASSERT(md->md_offset == 0);
 
        rlength = hdr->payload_length;
-       mlength = min_t(int, rlength, md->md_length);
+       mlength = min_t(uint, rlength, md->md_length);
 
        if (mlength < rlength &&
            (md->md_options & LNET_MD_TRUNCATE) == 0) {
index c93ae8510530b218ed89d3c0fde72d3ff0933e7a..45b5742f1bd270db5ca2ff5c428e874b771025da 100644 (file)
@@ -87,7 +87,7 @@ lnet_peer_tables_destroy(void)
 
        cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
                hash = ptable->pt_hash;
-               if (hash == NULL) /* not intialized */
+               if (hash == NULL) /* not initialized */
                        break;
 
                LASSERT(list_empty(&ptable->pt_deathrow));
@@ -132,7 +132,7 @@ lnet_peer_tables_cleanup(void)
        }
 
        cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
-               LIST_HEAD       (deathrow);
+               LIST_HEAD(deathrow);
                lnet_peer_t     *lp;
 
                lnet_net_lock(i);
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 463da076fa703ca04c7311d47f06f12b5ff596b7..658f4584fff868252b8c8d128b0039f23c96f2ab 100644 (file)
@@ -175,7 +175,6 @@ brw_fill_page(struct page *pg, int pattern, __u64 magic)
        }
 
        LBUG();
-       return;
 }
 
 static int
index fbff84cea52fc65774b2548c5c22ca220922d012..045fe295ad5409a181cbbb21844a0bbdf6a0939e 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;
@@ -857,62 +857,62 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
        memset(&console_session.ses_trans_stat, 0, sizeof(lstcon_trans_stat_t));
 
        switch (opc) {
-               case LSTIO_SESSION_NEW:
-                       rc = lst_session_new_ioctl((lstio_session_new_args_t *)buf);
-                       break;
-               case LSTIO_SESSION_END:
-                       rc = lst_session_end_ioctl((lstio_session_end_args_t *)buf);
-                       break;
-               case LSTIO_SESSION_INFO:
-                       rc = lst_session_info_ioctl((lstio_session_info_args_t *)buf);
-                       break;
-               case LSTIO_DEBUG:
-                       rc = lst_debug_ioctl((lstio_debug_args_t *)buf);
-                       break;
-               case LSTIO_GROUP_ADD:
-                       rc = lst_group_add_ioctl((lstio_group_add_args_t *)buf);
-                       break;
-               case LSTIO_GROUP_DEL:
-                       rc = lst_group_del_ioctl((lstio_group_del_args_t *)buf);
-                       break;
-               case LSTIO_GROUP_UPDATE:
-                       rc = lst_group_update_ioctl((lstio_group_update_args_t *)buf);
-                       break;
-               case LSTIO_NODES_ADD:
-                       rc = lst_nodes_add_ioctl((lstio_group_nodes_args_t *)buf);
-                       break;
-               case LSTIO_GROUP_LIST:
-                       rc = lst_group_list_ioctl((lstio_group_list_args_t *)buf);
-                       break;
-               case LSTIO_GROUP_INFO:
-                       rc = lst_group_info_ioctl((lstio_group_info_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_ADD:
-                       rc = lst_batch_add_ioctl((lstio_batch_add_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_START:
-                       rc = lst_batch_run_ioctl((lstio_batch_run_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_STOP:
-                       rc = lst_batch_stop_ioctl((lstio_batch_stop_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_QUERY:
-                       rc = lst_batch_query_ioctl((lstio_batch_query_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_LIST:
-                       rc = lst_batch_list_ioctl((lstio_batch_list_args_t *)buf);
-                       break;
-               case LSTIO_BATCH_INFO:
-                       rc = lst_batch_info_ioctl((lstio_batch_info_args_t *)buf);
-                       break;
-               case LSTIO_TEST_ADD:
-                       rc = lst_test_add_ioctl((lstio_test_args_t *)buf);
-                       break;
-               case LSTIO_STAT_QUERY:
-                       rc = lst_stat_query_ioctl((lstio_stat_args_t *)buf);
-                       break;
-               default:
-                       rc = -EINVAL;
+       case LSTIO_SESSION_NEW:
+               rc = lst_session_new_ioctl((lstio_session_new_args_t *)buf);
+               break;
+       case LSTIO_SESSION_END:
+               rc = lst_session_end_ioctl((lstio_session_end_args_t *)buf);
+               break;
+       case LSTIO_SESSION_INFO:
+               rc = lst_session_info_ioctl((lstio_session_info_args_t *)buf);
+               break;
+       case LSTIO_DEBUG:
+               rc = lst_debug_ioctl((lstio_debug_args_t *)buf);
+               break;
+       case LSTIO_GROUP_ADD:
+               rc = lst_group_add_ioctl((lstio_group_add_args_t *)buf);
+               break;
+       case LSTIO_GROUP_DEL:
+               rc = lst_group_del_ioctl((lstio_group_del_args_t *)buf);
+               break;
+       case LSTIO_GROUP_UPDATE:
+               rc = lst_group_update_ioctl((lstio_group_update_args_t *)buf);
+               break;
+       case LSTIO_NODES_ADD:
+               rc = lst_nodes_add_ioctl((lstio_group_nodes_args_t *)buf);
+               break;
+       case LSTIO_GROUP_LIST:
+               rc = lst_group_list_ioctl((lstio_group_list_args_t *)buf);
+               break;
+       case LSTIO_GROUP_INFO:
+               rc = lst_group_info_ioctl((lstio_group_info_args_t *)buf);
+               break;
+       case LSTIO_BATCH_ADD:
+               rc = lst_batch_add_ioctl((lstio_batch_add_args_t *)buf);
+               break;
+       case LSTIO_BATCH_START:
+               rc = lst_batch_run_ioctl((lstio_batch_run_args_t *)buf);
+               break;
+       case LSTIO_BATCH_STOP:
+               rc = lst_batch_stop_ioctl((lstio_batch_stop_args_t *)buf);
+               break;
+       case LSTIO_BATCH_QUERY:
+               rc = lst_batch_query_ioctl((lstio_batch_query_args_t *)buf);
+               break;
+       case LSTIO_BATCH_LIST:
+               rc = lst_batch_list_ioctl((lstio_batch_list_args_t *)buf);
+               break;
+       case LSTIO_BATCH_INFO:
+               rc = lst_batch_info_ioctl((lstio_batch_info_args_t *)buf);
+               break;
+       case LSTIO_TEST_ADD:
+               rc = lst_test_add_ioctl((lstio_test_args_t *)buf);
+               break;
+       case LSTIO_STAT_QUERY:
+               rc = lst_stat_query_ioctl((lstio_stat_args_t *)buf);
+               break;
+       default:
+               rc = -EINVAL;
        }
 
        if (copy_to_user(data->ioc_pbuf2, &console_session.ses_trans_stat,
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 f960174ceff8069d9ee9d64a1b61111921645787..e41ca89f10ba0cf817fdfe03e4a9ce2a5452f401 100644 (file)
@@ -182,6 +182,9 @@ lstcon_id2hash (lnet_process_id_t id, struct list_head *hash)
        return &hash[idx];
 }
 
+int lstcon_console_init(void);
+int lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data);
+int lstcon_console_fini(void);
 extern int lstcon_session_match(lst_sid_t sid);
 extern int lstcon_session_new(char *name, int key, unsigned version,
                              int timeout, int flags, lst_sid_t *sid_up);
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 faf4098023726a073f959f06887fe35ccb4b778c..7ad62f167ceaa0fae63b3c9caa93aa6c9dbdbe99 100644 (file)
@@ -87,7 +87,6 @@ lnet_selftest_fini(void)
        default:
                LBUG();
        }
-       return;
 }
 
 static int
index d8c0df6e68528e8ad998ebd688370106495aebf1..644069a9fe4e93b5144361e012f2a2e1c43a3ef0 100644 (file)
@@ -70,19 +70,19 @@ ping_client_init(sfw_test_instance_t *tsi)
 }
 
 static void
-ping_client_fini (sfw_test_instance_t *tsi)
+ping_client_fini(sfw_test_instance_t *tsi)
 {
        sfw_session_t *sn = tsi->tsi_batch->bat_session;
        int         errors;
 
-       LASSERT (sn != NULL);
-       LASSERT (tsi->tsi_is_client);
+       LASSERT(sn != NULL);
+       LASSERT(tsi->tsi_is_client);
 
        errors = atomic_read(&sn->sn_ping_errors);
        if (errors)
-               CWARN ("%d pings have failed.\n", errors);
+               CWARN("%d pings have failed.\n", errors);
        else
-               CDEBUG (D_NET, "Ping test finished OK.\n");
+               CDEBUG(D_NET, "Ping test finished OK.\n");
 }
 
 static int
@@ -118,7 +118,7 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu,
 }
 
 static void
-ping_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
+ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
 {
        sfw_test_instance_t *tsi = tsu->tsu_instance;
        sfw_session_t       *sn = tsi->tsi_batch->bat_session;
@@ -126,12 +126,12 @@ ping_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
        srpc_ping_reply_t   *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
        struct timeval       tv;
 
-       LASSERT (sn != NULL);
+       LASSERT(sn != NULL);
 
        if (rpc->crpc_status != 0) {
                if (!tsi->tsi_stopping) /* rpc could have been aborted */
                        atomic_inc(&sn->sn_ping_errors);
-               CERROR ("Unable to ping %s (%d): %d\n",
+               CERROR("Unable to ping %s (%d): %d\n",
                        libcfs_id2str(rpc->crpc_dest),
                        reqst->pnr_seq, rpc->crpc_status);
                return;
@@ -146,7 +146,7 @@ ping_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
        if (reply->pnr_magic != LST_PING_TEST_MAGIC) {
                rpc->crpc_status = -EBADMSG;
                atomic_inc(&sn->sn_ping_errors);
-               CERROR ("Bad magic %u from %s, %u expected.\n",
+               CERROR("Bad magic %u from %s, %u expected.\n",
                        reply->pnr_magic, libcfs_id2str(rpc->crpc_dest),
                        LST_PING_TEST_MAGIC);
                return;
@@ -155,14 +155,14 @@ ping_client_done_rpc (sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
        if (reply->pnr_seq != reqst->pnr_seq) {
                rpc->crpc_status = -EBADMSG;
                atomic_inc(&sn->sn_ping_errors);
-               CERROR ("Bad seq %u from %s, %u expected.\n",
+               CERROR("Bad seq %u from %s, %u expected.\n",
                        reply->pnr_seq, libcfs_id2str(rpc->crpc_dest),
                        reqst->pnr_seq);
                return;
        }
 
        cfs_fs_timeval(&tv);
-       CDEBUG (D_NET, "%d reply in %u usec\n", reply->pnr_seq,
+       CDEBUG(D_NET, "%d reply in %u usec\n", reply->pnr_seq,
                (unsigned)((tv.tv_sec - (unsigned)reqst->pnr_time_sec) * 1000000
                           + (tv.tv_usec - reqst->pnr_time_usec)));
        return;
@@ -177,20 +177,20 @@ ping_server_handle(struct srpc_server_rpc *rpc)
        srpc_ping_reqst_t *req = &reqstmsg->msg_body.ping_reqst;
        srpc_ping_reply_t *rep = &rpc->srpc_replymsg.msg_body.ping_reply;
 
-       LASSERT (sv->sv_id == SRPC_SERVICE_PING);
+       LASSERT(sv->sv_id == SRPC_SERVICE_PING);
 
        if (reqstmsg->msg_magic != SRPC_MSG_MAGIC) {
-               LASSERT (reqstmsg->msg_magic == __swab32(SRPC_MSG_MAGIC));
+               LASSERT(reqstmsg->msg_magic == __swab32(SRPC_MSG_MAGIC));
 
                __swab32s(&req->pnr_seq);
                __swab32s(&req->pnr_magic);
                __swab64s(&req->pnr_time_sec);
                __swab64s(&req->pnr_time_usec);
        }
-       LASSERT (reqstmsg->msg_type == srpc_service2request(sv->sv_id));
+       LASSERT(reqstmsg->msg_type == srpc_service2request(sv->sv_id));
 
        if (req->pnr_magic != LST_PING_TEST_MAGIC) {
-               CERROR ("Unexpected magic %08x from %s\n",
+               CERROR("Unexpected magic %08x from %s\n",
                        req->pnr_magic, libcfs_id2str(rpc->srpc_peer));
                return -EINVAL;
        }
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 51f3e98f94e288be73c2f8bb22729dbc2d4aa28a..dcc807676c490ec44e09467795e3c3f2c3aed863 100644 (file)
@@ -218,6 +218,8 @@ struct obd_import {
        atomic_t              imp_timeouts;
        /** Current import state */
        enum lustre_imp_state     imp_state;
+       /** Last replay state */
+       enum lustre_imp_state     imp_replay_state;
        /** History of import states */
        struct import_state_hist  imp_state_hist[IMP_STATE_HIST_LEN];
        int                    imp_state_hist_idx;
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 4a29261c514d9e61210419a7691be1d13d354197..34b5fa3f081ce3c2641a0b217b2d7b6fd10b1ca8 100644 (file)
@@ -72,6 +72,7 @@ extern int lustre_get_jobid(char *jobid);
 struct lu_device_type;
 
 /* genops.c */
+extern struct list_head obd_types;
 struct obd_export *class_conn2export(struct lustre_handle *);
 int class_register_type(struct obd_ops *, struct md_ops *,
                        struct lprocfs_vars *, const char *nm,
@@ -222,20 +223,20 @@ extern void (*class_export_dump_hook)(struct obd_export *);
 
 #endif
 
-#define class_export_rpc_inc(exp)                                     \
-({                                                                   \
-       atomic_inc(&(exp)->exp_rpc_count);                        \
-       CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n",    \
-              (exp), atomic_read(&(exp)->exp_rpc_count));        \
-})
+static inline void class_export_rpc_inc(struct obd_export *exp)
+{
+       atomic_inc(&(exp)->exp_rpc_count);
+       CDEBUG(D_INFO, "RPC GETting export %p : new rpc_count %d\n",
+              (exp), atomic_read(&(exp)->exp_rpc_count));
+}
 
-#define class_export_rpc_dec(exp)                                     \
-({                                                                   \
-       LASSERT_ATOMIC_POS(&exp->exp_rpc_count);                        \
-       atomic_dec(&(exp)->exp_rpc_count);                        \
-       CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n",    \
-              (exp), atomic_read(&(exp)->exp_rpc_count));        \
-})
+static inline void class_export_rpc_dec(struct obd_export *exp)
+{
+       LASSERT_ATOMIC_POS(&exp->exp_rpc_count);
+       atomic_dec(&(exp)->exp_rpc_count);
+       CDEBUG(D_INFO, "RPC PUTting export %p : new rpc_count %d\n",
+              (exp), atomic_read(&(exp)->exp_rpc_count));
+}
 
 #define class_export_lock_get(exp, lock)                               \
 ({                                                                   \
@@ -332,25 +333,29 @@ void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo);
 
 /* Ensure obd_setup: used for cleanup which must be called
    while obd is stopping */
-#define OBD_CHECK_DEV(obd)                                   \
-do {                                                       \
-       if (!(obd)) {                                      \
-               CERROR("NULL device\n");                        \
-               return -ENODEV;                         \
-       }                                                      \
-} while (0)
+static inline int obd_check_dev(struct obd_device *obd)
+{
+       if (!obd) {
+               CERROR("NULL device\n");
+               return -ENODEV;
+       }
+       return 0;
+}
 
 /* ensure obd_setup and !obd_stopping */
-#define OBD_CHECK_DEV_ACTIVE(obd)                             \
-do {                                                       \
-       OBD_CHECK_DEV(obd);                                  \
-       if (!(obd)->obd_set_up || (obd)->obd_stopping) {        \
-               CERROR("Device %d not setup\n",          \
-                      (obd)->obd_minor);                      \
-               return -ENODEV;                         \
-       }                                                      \
-} while (0)
+static inline int obd_check_dev_active(struct obd_device *obd)
+{
+       int rc;
 
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
+       if (!obd->obd_set_up || obd->obd_stopping) {
+               CERROR("Device %d not setup\n", obd->obd_minor);
+               return -ENODEV;
+       }
+       return rc;
+}
 
 #if defined (CONFIG_PROC_FS)
 #define OBD_COUNTER_OFFSET(op)                           \
@@ -593,7 +598,9 @@ static inline int obd_precleanup(struct obd_device *obd,
        int rc;
        DECLARE_LU_VARS(ldt, d);
 
-       OBD_CHECK_DEV(obd);
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
        ldt = obd->obd_type->typ_lu;
        d = obd->obd_lu_dev;
        if (ldt != NULL && d != NULL) {
@@ -619,7 +626,9 @@ static inline int obd_cleanup(struct obd_device *obd)
        int rc;
        DECLARE_LU_VARS(ldt, d);
 
-       OBD_CHECK_DEV(obd);
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
 
        ldt = obd->obd_type->typ_lu;
        d = obd->obd_lu_dev;
@@ -667,7 +676,9 @@ obd_process_config(struct obd_device *obd, int datalen, void *data)
        int rc;
        DECLARE_LU_VARS(ldt, d);
 
-       OBD_CHECK_DEV(obd);
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
 
        obd->obd_process_conf = 1;
        ldt = obd->obd_type->typ_lu;
@@ -885,7 +896,9 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid,
        struct obd_device *obd = imp->imp_obd;
        int rc;
 
-       OBD_CHECK_DEV_ACTIVE(obd);
+       rc = obd_check_dev_active(obd);
+       if (rc)
+               return rc;
        OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP);
        OBD_COUNTER_INCREMENT(obd, add_conn);
 
@@ -898,7 +911,9 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
        struct obd_device *obd = imp->imp_obd;
        int rc;
 
-       OBD_CHECK_DEV_ACTIVE(obd);
+       rc = obd_check_dev_active(obd);
+       if (rc)
+               return rc;
        OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP);
        OBD_COUNTER_INCREMENT(obd, del_conn);
 
@@ -932,7 +947,9 @@ static inline int obd_connect(const struct lu_env *env,
        __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition
                                                   * check */
 
-       OBD_CHECK_DEV_ACTIVE(obd);
+       rc = obd_check_dev_active(obd);
+       if (rc)
+               return rc;
        OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP);
        OBD_COUNTER_INCREMENT(obd, connect);
 
@@ -954,7 +971,9 @@ static inline int obd_reconnect(const struct lu_env *env,
        __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition
                                                   * check */
 
-       OBD_CHECK_DEV_ACTIVE(obd);
+       rc = obd_check_dev_active(obd);
+       if (rc)
+               return rc;
        OBD_CHECK_DT_OP(obd, reconnect, 0);
        OBD_COUNTER_INCREMENT(obd, reconnect);
 
@@ -1279,7 +1298,9 @@ static inline int obd_notify(struct obd_device *obd,
 {
        int rc;
 
-       OBD_CHECK_DEV(obd);
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
 
        /* the check for async_recov is a complete hack - I'm hereby
           overloading the meaning to also mean "this was called from
@@ -1380,7 +1401,11 @@ static inline int obd_health_check(const struct lu_env *env,
 static inline int obd_register_observer(struct obd_device *obd,
                                        struct obd_device *observer)
 {
-       OBD_CHECK_DEV(obd);
+       int rc;
+
+       rc = obd_check_dev(obd);
+       if (rc)
+               return rc;
        down_write(&obd->obd_observer_link_sem);
        if (obd->obd_observer && observer) {
                up_write(&obd->obd_observer_link_sem);
@@ -1895,6 +1920,8 @@ void class_exit_uuidlist(void);
 
 /* class_obd.c */
 extern char obd_jobid_node[];
+extern struct miscdevice obd_psdev;
+extern spinlock_t obd_types_lock;
 
 /* prng.c */
 #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t))
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..70b909f55861a8b6fdca9215d5dceda5f0a3351a 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);
@@ -207,9 +211,9 @@ struct ldlm_state {
 /* interval tree, for LDLM_EXTENT. */
 extern struct kmem_cache *ldlm_interval_slab; /* slab cache for ldlm_interval */
 extern void ldlm_interval_attach(struct ldlm_interval *n, struct ldlm_lock *l);
-extern struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l);
-extern struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock);
-extern void ldlm_interval_free(struct ldlm_interval *node);
+struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l);
+struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock);
+void ldlm_interval_free(struct ldlm_interval *node);
 /* this function must be called with res lock held */
 static inline struct ldlm_extent *
 ldlm_interval_extent(struct ldlm_interval *node)
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..a9f4833e03e5f623d3666e81c012fb86cbaff8d4 100644 (file)
  */
 #define LDLM_POOL_SLV_SHIFT (10)
 
-extern struct proc_dir_entry *ldlm_ns_proc_dir;
-
 static inline __u64 dru(__u64 val, __u32 shift, int round_up)
 {
        return (val + (round_up ? (1 << shift) - 1 : 0)) >> shift;
@@ -689,8 +687,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 c6f62a91b233f280a8bb6956315b0185a1adf4fa..f750d42a7ad5558a19de8db0a53956f982c35b48 100644 (file)
@@ -62,7 +62,7 @@ LIST_HEAD(ldlm_cli_active_namespace_list);
 LIST_HEAD(ldlm_cli_inactive_namespace_list);
 
 struct proc_dir_entry *ldlm_type_proc_dir = NULL;
-struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
+static struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
 struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
 
 extern unsigned int ldlm_cancel_unused_locks_before_replay;
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 a5effcd9c6794b6197cd4260b561e7308a794614..e962f89683a60cdb68ee67b3070bc185d783027e 100644 (file)
@@ -57,7 +57,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg)
                return -EINVAL;
        }
 
-       if (hdr->ioc_len + buf >= end) {
+       if (hdr->ioc_len >= end - buf) {
                CERROR("PORTALS: user buffer exceeds kernel buffer\n");
                return -EINVAL;
        }
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..85e74d18d1c70bdeae1e639d6cd3b4ecdbd1782b 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)--;
                }
@@ -1711,6 +1712,12 @@ static int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
        fm_key.oa.o_oi = lsm->lsm_oi;
        fm_key.oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
+       if (i_size_read(inode) == 0) {
+               rc = ll_glimpse_size(inode);
+               if (rc)
+                       goto out;
+       }
+
        obdo_from_inode(&fm_key.oa, inode, OBD_MD_FLSIZE);
        obdo_set_parent_fid(&fm_key.oa, &ll_i2info(inode)->lli_fid);
        /* If filesize is 0, then there would be no objects for mapping */
@@ -2821,7 +2828,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 +3240,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 +3265,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..69ea92adf4f1ffbdbc1e1607d1aee25cdc93c07e 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);
 
@@ -299,13 +295,18 @@ static int ll_xattr_find_get_lock(struct inode *inode,
 
 
        mutex_lock(&lli->lli_xattrs_enq_lock);
-       /* Try matching first. */
-       mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, LCK_PR);
-       if (mode != 0) {
-               /* fake oit in mdc_revalidate_lock() manner */
-               oit->d.lustre.it_lock_handle = lockh.cookie;
-               oit->d.lustre.it_lock_mode = mode;
-               goto out;
+       /* inode may have been shrunk and recreated, so data is gone, match lock
+        * only when data exists. */
+       if (ll_xattr_cache_valid(lli)) {
+               /* Try matching first. */
+               mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0,
+                                      LCK_PR);
+               if (mode != 0) {
+                       /* fake oit in mdc_revalidate_lock() manner */
+                       oit->d.lustre.it_lock_handle = lockh.cookie;
+                       oit->d.lustre.it_lock_mode = mode;
+                       goto out;
+               }
        }
 
        /* Enqueue if the lock isn't cached locally. */
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..22e5c315faa42de69bf3cea27bc11c3546c7c262 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/statfs.h>
 #include "../include/lprocfs_status.h"
 #include "../include/obd_class.h"
+#include "lmv_internal.h"
 
 static int lmv_numobd_seq_show(struct seq_file *m, void *v)
 {
@@ -48,7 +49,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 +84,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 +133,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 +145,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 +176,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..2bcfaeaff6fa586efe924ed1edf182d0c980177b 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;
@@ -227,6 +227,9 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
                loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
                loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
                        CERROR("OST index %d more than OST count %d\n",
                               loi->loi_ost_idx, lov->desc.ld_tgt_count);
@@ -287,8 +290,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;
@@ -314,6 +317,9 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
                loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
                loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
                        CERROR("OST index %d more than OST count %d\n",
                               loi->loi_ost_idx, lov->desc.ld_tgt_count);
index 8c8508bbbb808750b36411841683f0583cc0de8e..b644acc9b034c0c36cf726aecfbd65e33f8d995e 100644 (file)
@@ -304,4 +304,16 @@ static inline struct lov_stripe_md *lsm_addref(struct lov_stripe_md *lsm)
        return lsm;
 }
 
+static inline bool lov_oinfo_is_dummy(const struct lov_oinfo *loi)
+{
+       if (unlikely(loi->loi_oi.oi.oi_id == 0 &&
+                    loi->loi_oi.oi.oi_seq == 0 &&
+                    loi->loi_ost_idx == 0 &&
+                    loi->loi_ost_gen == 0))
+               return true;
+
+       return false;
+}
+
+
 #endif
index f1f6db3f664a06952f73992f23c0bc62ce335aa3..cf96e0d01e22d5d000304d46a24cc75ff2596a8e 100644 (file)
@@ -148,6 +148,9 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
        LASSERT(sub->sub_env == NULL);
        LASSERT(sub->sub_stripe < lio->lis_stripe_count);
 
+       if (unlikely(lov_r0(lov)->lo_sub[stripe] == NULL))
+               return -EIO;
+
        result = 0;
        sub->sub_io_initialized = 0;
        sub->sub_borrowed = 0;
@@ -391,7 +394,16 @@ static int lov_io_iter_init(const struct lu_env *env,
                                           endpos, &start, &end))
                        continue;
 
-               end = lov_offset_mod(end, +1);
+               if (unlikely(lov_r0(lio->lis_object)->lo_sub[stripe] == NULL)) {
+                       if (ios->cis_io->ci_type == CIT_READ ||
+                           ios->cis_io->ci_type == CIT_WRITE ||
+                           ios->cis_io->ci_type == CIT_FAULT)
+                               return -EIO;
+
+                       continue;
+               }
+
+               end = lov_offset_mod(end, 1);
                sub = lov_sub_get(env, lio, stripe);
                if (!IS_ERR(sub)) {
                        lov_io_sub_inherit(sub->sub_io, lio, stripe,
@@ -913,7 +925,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
                break;
        case CIT_FSYNC:
        case CIT_SETATTR:
-               result = +1;
+               result = 1;
                break;
        case CIT_WRITE:
                result = -EBADF;
index 49e694222ac839416327779de74d25de31b9e38c..f2eca565bddab0130ea80f470458e71c349b8245 100644 (file)
@@ -308,7 +308,8 @@ static int lov_lock_sub_init(const struct lu_env *env,
                 * XXX for wide striping smarter algorithm is desirable,
                 * breaking out of the loop, early.
                 */
-               if (lov_stripe_intersects(loo->lo_lsm, i,
+               if (likely(r0->lo_sub[i] != NULL) &&
+                   lov_stripe_intersects(loo->lo_lsm, i,
                                          file_start, file_end, &start, &end))
                        nr++;
        }
@@ -326,7 +327,8 @@ static int lov_lock_sub_init(const struct lu_env *env,
         * top-lock.
         */
        for (i = 0, nr = 0; i < r0->lo_nr; ++i) {
-               if (lov_stripe_intersects(loo->lo_lsm, i,
+               if (likely(r0->lo_sub[i] != NULL) &&
+                   lov_stripe_intersects(loo->lo_lsm, i,
                                          file_start, file_end, &start, &end)) {
                        struct cl_lock_descr *descr;
 
@@ -914,10 +916,22 @@ static int lov_lock_stripe_is_matching(const struct lu_env *env,
         */
        start = cl_offset(&lov->lo_cl, descr->cld_start);
        end   = cl_offset(&lov->lo_cl, descr->cld_end + 1) - 1;
-       result = end - start <= lsm->lsm_stripe_size &&
-                stripe == lov_stripe_number(lsm, start) &&
-                stripe == lov_stripe_number(lsm, end);
-       if (result) {
+       result = 0;
+       /* glimpse should work on the object with LOV EA hole. */
+       if (end - start <= lsm->lsm_stripe_size) {
+               int idx;
+
+               idx = lov_stripe_number(lsm, start);
+               if (idx == stripe ||
+                   unlikely(lov_r0(lov)->lo_sub[idx] == NULL)) {
+                       idx = lov_stripe_number(lsm, end);
+                       if (idx == stripe ||
+                           unlikely(lov_r0(lov)->lo_sub[idx] == NULL))
+                               result = 1;
+               }
+       }
+
+       if (result != 0) {
                struct cl_lock_descr *subd = &lov_env_info(env)->lti_ldescr;
                u64 sub_start;
                u64 sub_end;
index ea503d2a19f8bc90d2d54844279c10631109cf6b..02781576637edd64657486d548fc8364a75550d5 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);
@@ -1011,9 +1011,13 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
        }
 
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               if (lsm->lsm_oinfo[i]->loi_ost_idx == ost_idx) {
-                       if (ostid_id(&lsm->lsm_oinfo[i]->loi_oi) !=
-                                       ostid_id(&src_oa->o_oi)) {
+               struct lov_oinfo *loi = lsm->lsm_oinfo[i];
+
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
+               if (loi->loi_ost_idx == ost_idx) {
+                       if (ostid_id(&loi->loi_oi) != ostid_id(&src_oa->o_oi)) {
                                rc = -EINVAL;
                                goto out;
                        }
@@ -1305,10 +1309,14 @@ static int lov_find_cbdata(struct obd_export *exp,
                struct lov_stripe_md submd;
                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
 
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (!lov->lov_tgts[loi->loi_ost_idx]) {
-                       CDEBUG(D_HA, "lov idx %d NULL \n", loi->loi_ost_idx);
+                       CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx);
                        continue;
                }
+
                submd.lsm_oi = loi->loi_oi;
                submd.lsm_stripe_count = 0;
                rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
@@ -1601,9 +1609,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;
@@ -1616,8 +1624,12 @@ u64 fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap,
 
        /* Find out stripe_no from ost_index saved in the fe_device */
        for (i = 0; i < lsm->lsm_stripe_count; i++) {
-               if (lsm->lsm_oinfo[i]->loi_ost_idx ==
-                                       fiemap->fm_extents[0].fe_device) {
+               struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
+
+               if (lov_oinfo_is_dummy(oinfo))
+                       continue;
+
+               if (oinfo->loi_ost_idx == fiemap->fm_extents[0].fe_device) {
                        stripe_no = i;
                        break;
                }
@@ -1658,17 +1670,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 +1706,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;
@@ -1795,6 +1807,11 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
                                           &lun_start, &obd_object_end)) == 0)
                        continue;
 
+               if (lov_oinfo_is_dummy(lsm->lsm_oinfo[cur_stripe])) {
+                       rc = -EIO;
+                       goto out;
+               }
+
                /* If this is a continuation FIEMAP call and we are on
                 * starting stripe then lun_start needs to be set to
                 * fm_end_offset */
@@ -1985,6 +2002,9 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp,
                 * be NULL and won't match the lock's export. */
                for (i = 0; i < lsm->lsm_stripe_count; i++) {
                        loi = lsm->lsm_oinfo[i];
+                       if (lov_oinfo_is_dummy(loi))
+                               continue;
+
                        if (!lov->lov_tgts[loi->loi_ost_idx])
                                continue;
                        if (lov->lov_tgts[loi->loi_ost_idx]->ltd_exp ==
@@ -2290,7 +2310,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 +2344,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..a22342fa792d010d12f8fea811c9d05a44b41639 100644 (file)
@@ -42,6 +42,7 @@
 #define DEBUG_SUBSYSTEM S_LOV
 
 #include "lov_cl_internal.h"
+#include "../include/lclient.h"
 
 /** \addtogroup lov
  *  @{
@@ -230,6 +231,9 @@ static int lov_init_raid0(const struct lu_env *env,
                        struct lov_oinfo *oinfo = lsm->lsm_oinfo[i];
                        int ost_idx = oinfo->loi_ost_idx;
 
+                       if (lov_oinfo_is_dummy(oinfo))
+                               continue;
+
                        result = ostid_to_fid(ofid, &oinfo->loi_oi,
                                              oinfo->loi_ost_idx);
                        if (result != 0)
@@ -563,7 +567,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;
@@ -973,6 +977,10 @@ int lov_read_and_clear_async_rc(struct cl_object *clob)
                        LASSERT(lsm != NULL);
                        for (i = 0; i < lsm->lsm_stripe_count; i++) {
                                struct lov_oinfo *loi = lsm->lsm_oinfo[i];
+
+                               if (lov_oinfo_is_dummy(loi))
+                                       continue;
+
                                if (loi->loi_ar.ar_rc && !rc)
                                        rc = loi->loi_ar.ar_rc;
                                loi->loi_ar.ar_rc = 0;
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 7358b9d29103c89dbff7719e69c92186c4bde1db..933e2d1f8127e13a37c116b3737a61bd188635e1 100644 (file)
@@ -299,6 +299,9 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
                struct lov_request *req;
 
                loi = oinfo->oi_md->lsm_oinfo[i];
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (!lov_check_and_wait_active(lov, loi->loi_ost_idx)) {
                        CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                        if (oinfo->oi_oa->o_valid & OBD_MD_FLEPOCH) {
@@ -384,6 +387,9 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
                struct lov_request *req;
 
                loi = lsm->lsm_oinfo[i];
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (!lov_check_and_wait_active(lov, loi->loi_ost_idx)) {
                        CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                        continue;
@@ -497,6 +503,9 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
                struct lov_oinfo *loi = oinfo->oi_md->lsm_oinfo[i];
                struct lov_request *req;
 
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (!lov_check_and_wait_active(lov, loi->loi_ost_idx)) {
                        CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                        continue;
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..acfe08e459c0c5bfb84a610ba6144f2faaec2379 100644 (file)
 #include <linux/vfs.h>
 #include "../include/obd_class.h"
 #include "../include/lprocfs_status.h"
+#include "mdc_internal.h"
 
 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..f8ef5fe5e771d091f49e53026f61f36a6e2823f8 100644 (file)
@@ -481,6 +481,9 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
                return -EPROTO;
 
        acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize);
+       if (acl == NULL)
+               return 0;
+
        if (IS_ERR(acl)) {
                rc = PTR_ERR(acl);
                CERROR("convert xattr to acl: %d\n", rc);
@@ -2707,14 +2710,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..7947aec5c847ca2c9d65e02667d8b79105459175 100644 (file)
@@ -95,7 +95,7 @@ int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type)
 }
 EXPORT_SYMBOL(mgc_fsname2resid);
 
-int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type)
+static int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type)
 {
        char *name_end;
        int len;
@@ -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);
 
@@ -452,10 +452,14 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
 int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
 {
        struct obd_device       *obd = data;
-       struct obd_import       *imp = obd->u.cli.cl_import;
-       struct obd_connect_data *ocd = &imp->imp_connect_data;
+       struct obd_import       *imp;
+       struct obd_connect_data *ocd;
        struct config_llog_data *cld;
 
+       LPROCFS_CLIMP_CHECK(obd);
+       imp = obd->u.cli.cl_import;
+       ocd = &imp->imp_connect_data;
+
        seq_printf(m, "imperative_recovery: %s\n",
                      OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED");
        seq_printf(m, "client_state:\n");
@@ -470,6 +474,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
        }
        spin_unlock(&config_list_lock);
 
+       LPROCFS_CLIMP_EXIT(obd);
        return 0;
 }
 #endif
@@ -479,9 +484,11 @@ 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;
+#define RQ_PRECLEANUP  0x10
+static int rq_state;
 static wait_queue_head_t           rq_waitq;
 static DECLARE_COMPLETION(rq_exit);
+static DECLARE_COMPLETION(rq_start);
 
 static void do_requeue(struct config_llog_data *cld)
 {
@@ -510,6 +517,8 @@ static void do_requeue(struct config_llog_data *cld)
 
 static int mgc_requeue_thread(void *data)
 {
+       bool first = true;
+
        CDEBUG(D_MGC, "Starting requeue thread\n");
 
        /* Keep trying failed locks periodically */
@@ -526,13 +535,19 @@ static int mgc_requeue_thread(void *data)
                rq_state &= ~(RQ_NOW | RQ_LATER);
                spin_unlock(&config_list_lock);
 
+               if (first) {
+                       first = false;
+                       complete(&rq_start);
+               }
+
                /* Always wait a few seconds to allow the server who
                   caused the lock revocation to finish its setup, plus some
                   random so everyone doesn't try to reconnect at once. */
                to = MGC_TIMEOUT_MIN_SECONDS * HZ;
                to += rand * HZ / 100; /* rand is centi-seconds */
                lwi = LWI_TIMEOUT(to, NULL, NULL);
-               l_wait_event(rq_waitq, rq_state & RQ_STOP, &lwi);
+               l_wait_event(rq_waitq, rq_state & (RQ_STOP | RQ_PRECLEANUP),
+                            &lwi);
 
                /*
                 * iterate & processing through the list. for each cld, process
@@ -545,6 +560,7 @@ static int mgc_requeue_thread(void *data)
                cld_prev = NULL;
 
                spin_lock(&config_list_lock);
+               rq_state &= ~RQ_PRECLEANUP;
                list_for_each_entry(cld, &config_llog_list,
                                        cld_list_chain) {
                        if (!cld->cld_lostlock)
@@ -661,24 +677,26 @@ static atomic_t mgc_count = ATOMIC_INIT(0);
 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 {
        int rc = 0;
+       int temp;
 
        switch (stage) {
        case OBD_CLEANUP_EARLY:
                break;
        case OBD_CLEANUP_EXPORTS:
                if (atomic_dec_and_test(&mgc_count)) {
-                       int running;
+                       LASSERT(rq_state & RQ_RUNNING);
                        /* stop requeue thread */
-                       spin_lock(&config_list_lock);
-                       running = rq_state & RQ_RUNNING;
-                       if (running)
-                               rq_state |= RQ_STOP;
-                       spin_unlock(&config_list_lock);
-                       if (running) {
-                               wake_up(&rq_waitq);
-                               wait_for_completion(&rq_exit);
-                       }
+                       temp = RQ_STOP;
+               } else {
+                       /* wakeup requeue thread to clean our cld */
+                       temp = RQ_NOW | RQ_PRECLEANUP;
                }
+               spin_lock(&config_list_lock);
+               rq_state |= temp;
+               spin_unlock(&config_list_lock);
+               wake_up(&rq_waitq);
+               if (temp & RQ_STOP)
+                       wait_for_completion(&rq_exit);
                obd_cleanup_client_import(obd);
                rc = mgc_llog_fini(NULL, obd);
                if (rc != 0)
@@ -690,8 +708,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 +717,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)
@@ -740,6 +755,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                }
                /* rc is the task_struct pointer of mgc_requeue_thread. */
                rc = 0;
+               wait_for_completion(&rq_start);
        }
 
        return rc;
@@ -951,7 +967,7 @@ static int mgc_target_register(struct obd_export *exp,
        return rc;
 }
 
-int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
+static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
                       u32 keylen, void *key, u32 vallen,
                       void *val, struct ptlrpc_request_set *set)
 {
@@ -1727,7 +1743,7 @@ struct obd_ops mgc_obd_ops = {
        .o_process_config = mgc_process_config,
 };
 
-int __init mgc_init(void)
+static int __init mgc_init(void)
 {
        return class_register_type(&mgc_obd_ops, NULL, NULL,
                                   LUSTRE_MGC_NAME, NULL);
index 29456e1ad2250d4e47c6d37a189033a7f3da52c5..d4b74b670c43df281f6161c17df9d4f15b11e058 100644 (file)
@@ -437,8 +437,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
        return err;
 } /* class_handle_ioctl */
 
-extern struct miscdevice obd_psdev;
-
 #define OBD_INIT_CHECK
 int obd_init_checks(void)
 {
@@ -508,7 +506,6 @@ int obd_init_checks(void)
        return ret;
 }
 
-extern spinlock_t obd_types_lock;
 #if defined (CONFIG_PROC_FS)
 extern int class_procfs_init(void);
 extern int class_procfs_clean(void);
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..66b56784f674e21c049e499bd2d03b8e3d38e6ca 100644 (file)
 #include "../include/obd_class.h"
 #include "../include/lprocfs_status.h"
 
-extern struct list_head obd_types;
 spinlock_t obd_types_lock;
 
 struct kmem_cache *obd_device_cachep;
 struct kmem_cache *obdo_cachep;
 EXPORT_SYMBOL(obdo_cachep);
-struct kmem_cache *import_cachep;
+static struct kmem_cache *import_cachep;
 
-struct list_head      obd_zombie_imports;
-struct list_head      obd_zombie_exports;
-spinlock_t  obd_zombie_impexp_lock;
+static struct list_head      obd_zombie_imports;
+static struct list_head      obd_zombie_exports;
+static spinlock_t  obd_zombie_impexp_lock;
 static void obd_zombie_impexp_notify(void);
 static void obd_zombie_export_add(struct obd_export *exp);
 static void obd_zombie_import_add(struct obd_import *imp);
@@ -930,7 +929,7 @@ void class_unlink_export(struct obd_export *exp)
 EXPORT_SYMBOL(class_unlink_export);
 
 /* Import management functions */
-void class_import_destroy(struct obd_import *imp)
+static void class_import_destroy(struct obd_import *imp)
 {
        CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp,
                imp->imp_obd->obd_name);
@@ -1127,7 +1126,7 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
 EXPORT_SYMBOL(class_connect);
 
 /* if export is involved in recovery then clean up related things */
-void class_export_recovery_cleanup(struct obd_export *exp)
+static void class_export_recovery_cleanup(struct obd_export *exp)
 {
        struct obd_device *obd = exp->exp_obd;
 
@@ -1221,7 +1220,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 +1558,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..06944b863d16ec08c9f7a065e2a7f00218774dd7 100644 (file)
@@ -217,23 +217,25 @@ struct miscdevice obd_psdev = {
 
 
 #if defined (CONFIG_PROC_FS)
-int obd_proc_version_seq_show(struct seq_file *m, void *v)
+static 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..c8f6ab006124f742f933fdc661b5a272c2e86c8e 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;
@@ -691,7 +692,7 @@ int llog_cat_reverse_process(const struct lu_env *env,
 }
 EXPORT_SYMBOL(llog_cat_reverse_process);
 
-int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
+static int llog_cat_set_first_idx(struct llog_handle *cathandle, int index)
 {
        struct llog_log_hdr *llh = cathandle->lgh_hdr;
        int i, bitmap_size, idx;
@@ -750,7 +751,7 @@ int llog_cat_cleanup(const struct lu_env *env, struct llog_handle *cathandle,
        return rc;
 }
 
-int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
+static int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
                  struct llog_rec_hdr *rec, void *data)
 {
        struct llog_logid_rec   *lir = (struct llog_logid_rec *)rec;
@@ -794,7 +795,6 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle,
 
        return rc;
 }
-EXPORT_SYMBOL(cat_cancel_cb);
 
 /* helper to initialize catalog llog and process it to cancel */
 int llog_cat_init_and_process(const struct lu_env *env,
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..3437b2ecfc02873937ad9ee4eb1ffcb57b4fdf0e 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
  */
@@ -1286,7 +1286,7 @@ struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
        return mount_nodev(fs_type, flags, &lmd2, lustre_fill_super);
 }
 
-void lustre_kill_super(struct super_block *sb)
+static void lustre_kill_super(struct super_block *sb)
 {
        struct lustre_sb_info *lsi = s2lsi(sb);
 
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 7022ed42d2d124104530a343c456a833bb6ceaa9..d44b3d4ffe4d152ff2e32b3740a3d2aa9790ddd8 100644 (file)
@@ -2613,7 +2613,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj,
        }
        osc_object_unlock(obj);
 
-       osc_io_unplug(env, cli, obj, PDL_POLICY_ROUND);
+       osc_io_unplug_async(env, cli, obj);
        return 0;
 }
 
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..d7a9b650df09cefa2044b010b5f2abc6bed1b3e9 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 */
@@ -1880,6 +1880,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
        int                             page_count = 0;
        int                             i;
        int                             rc;
+       struct ost_body                 *body;
        LIST_HEAD(rpc_list);
 
        LASSERT(!list_empty(ext_list));
@@ -1981,6 +1982,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
         * later setattr before earlier BRW (as determined by the request xid),
         * the OST will not use BRW timestamps.  Sadly, there is no obvious
         * way to do this in a single call.  bug 10150 */
+       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
+       crattr->cra_oa = &body->oa;
        cl_req_attr_set(env, clerq, crattr,
                        OBD_MD_FLMTIME|OBD_MD_FLCTIME|OBD_MD_FLATIME);
 
index 4882dd0a448378fdadf536ef0edd3b2afc5d8a84..0357f1d4532f3763b5601ccbdad857a9ba6392af 100644 (file)
@@ -285,14 +285,27 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req,
        time_t now = get_seconds();
 
        LASSERT(req->rq_import);
-       at = &req->rq_import->imp_at;
+
+       if (service_time > now - req->rq_sent + 3) {
+               /* bz16408, however, this can also happen if early reply
+                * is lost and client RPC is expired and resent, early reply
+                * or reply of original RPC can still be fit in reply buffer
+                * of resent RPC, now client is measuring time from the
+                * resent time, but server sent back service time of original
+                * RPC.
+                */
+               CDEBUG((lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT) ?
+                      D_ADAPTTO : D_WARNING,
+                      "Reported service time %u > total measured time "
+                      CFS_DURATION_T"\n", service_time,
+                      cfs_time_sub(now, req->rq_sent));
+               return;
+       }
 
        /* Network latency is total time less server processing time */
-       nl = max_t(int, now - req->rq_sent - service_time, 0) + 1/*st rounding*/;
-       if (service_time > now - req->rq_sent + 3 /* bz16408 */)
-               CWARN("Reported service time %u > total measured time "
-                     CFS_DURATION_T"\n", service_time,
-                     cfs_time_sub(now, req->rq_sent));
+       nl = max_t(int, now - req->rq_sent -
+                       service_time, 0) + 1; /* st rounding */
+       at = &req->rq_import->imp_at;
 
        oldnl = at_measured(&at->iat_net_latency, nl);
        if (oldnl != 0)
@@ -468,7 +481,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 +1451,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 +2203,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 4ceb90db02a3f3f84cbfcabdf0f7f175b3aa6515..d5fc689c008b55cc474d7924e4ccb6f1c4c539c5 100644 (file)
@@ -63,6 +63,19 @@ struct ptlrpc_connect_async_args {
 static void __import_set_state(struct obd_import *imp,
                               enum lustre_imp_state state)
 {
+       switch (state) {
+       case LUSTRE_IMP_CLOSED:
+       case LUSTRE_IMP_NEW:
+       case LUSTRE_IMP_DISCON:
+       case LUSTRE_IMP_CONNECTING:
+               break;
+       case LUSTRE_IMP_REPLAY_WAIT:
+               imp->imp_replay_state = LUSTRE_IMP_REPLAY_LOCKS;
+               break;
+       default:
+               imp->imp_replay_state = LUSTRE_IMP_REPLAY;
+       }
+
        imp->imp_state = state;
        imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state;
        imp->imp_state_hist[imp->imp_state_hist_idx].ish_time =
@@ -966,7 +979,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
                        imp->imp_resend_replay = 1;
                        spin_unlock(&imp->imp_lock);
 
-                       IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
+                       IMPORT_SET_STATE(imp, imp->imp_replay_state);
                } else {
                        IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
                }
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..9e5674341abe7368e5ec228f737e4c2d766f7d80 100644 (file)
@@ -170,9 +170,6 @@ static void delete_context(struct sasem_context *context)
        kfree(context->driver->rbuf);
        kfree(context->driver);
        kfree(context);
-
-       if (debug)
-               pr_info("%s: context deleted\n", __func__);
 }
 
 static void deregister_from_lirc(struct sasem_context *context)
@@ -182,10 +179,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 +213,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 +330,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 +346,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 +386,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 +441,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 +505,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 30b66c3c9b731910ba1ce20863cd9128c4c04849..04a7402ae2df4531fee978a24c1fc82e3e712095 100644 (file)
@@ -378,7 +378,7 @@ static int nvec_power_probe(struct platform_device *pdev)
        struct power_supply_config psy_cfg = {};
 
        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..9e5476e352b4b3ca3c0f8175883324c769c7a664 100644 (file)
@@ -214,15 +214,14 @@ enum cvmx_usb_initialize_flags {
 /**
  * enum cvmx_usb_pipe_flags - internal flags for a pipe.
  *
- * @__CVMX_USB_PIPE_FLAGS_SCHEDULED: Used internally to determine if a pipe is
- *                                  actively using hardware. Do not use.
- * @__CVMX_USB_PIPE_FLAGS_NEED_PING: Used internally to determine if a high
- *                                  speed pipe is in the ping state. Do not
- *                                  use.
+ * @CVMX_USB_PIPE_FLAGS_SCHEDULED: Used internally to determine if a pipe is
+ *                                actively using hardware.
+ * @CVMX_USB_PIPE_FLAGS_NEED_PING: Used internally to determine if a high speed
+ *                                pipe is in the ping state.
  */
 enum cvmx_usb_pipe_flags {
-       __CVMX_USB_PIPE_FLAGS_SCHEDULED = 1 << 17,
-       __CVMX_USB_PIPE_FLAGS_NEED_PING = 1 << 18,
+       CVMX_USB_PIPE_FLAGS_SCHEDULED   = 1 << 17,
+       CVMX_USB_PIPE_FLAGS_NEED_PING   = 1 << 18,
 };
 
 /* Maximum number of times to retry failed transactions */
@@ -231,15 +230,6 @@ enum cvmx_usb_pipe_flags {
 /* Maximum number of hardware channels supported by the USB block */
 #define MAX_CHANNELS           8
 
-/* The highest valid USB device address */
-#define MAX_USB_ADDRESS                127
-
-/* The highest valid USB endpoint number */
-#define MAX_USB_ENDPOINT       15
-
-/* The highest valid port number on a hub */
-#define MAX_USB_HUB_PORT       15
-
 /*
  * The low level hardware can transfer a maximum of this number of bytes in each
  * transfer. The field is 19 bits wide
@@ -403,16 +393,18 @@ struct octeon_hcd {
        struct cvmx_usb_state usb;
 };
 
-/* This macro spins on a field waiting for it to reach a value */
-#define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
+/* This macro spins on a register waiting for it to reach a condition. */
+#define CVMX_WAIT_FOR_FIELD32(address, _union, cond, timeout_usec)         \
        ({int result;                                                       \
        do {                                                                \
                uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
                        octeon_get_clock_rate() / 1000000;                  \
-               type c;                                                     \
+               union _union c;                                             \
+                                                                           \
                while (1) {                                                 \
-                       c.u32 = __cvmx_usb_read_csr32(usb, address);        \
-                       if (c.s.field op (value)) {                         \
+                       c.u32 = cvmx_usb_read_csr32(usb, address);          \
+                                                                           \
+                       if (cond) {                                         \
                                result = 0;                                 \
                                break;                                      \
                        } else if (cvmx_get_cycle() > done) {               \
@@ -428,12 +420,13 @@ struct octeon_hcd {
  * This macro logically sets a single field in a CSR. It does the sequence
  * read, modify, and write
  */
-#define USB_SET_FIELD32(address, type, field, value)           \
+#define USB_SET_FIELD32(address, _union, field, value)         \
        do {                                                    \
-               type c;                                         \
-               c.u32 = __cvmx_usb_read_csr32(usb, address);    \
+               union _union c;                                 \
+                                                               \
+               c.u32 = cvmx_usb_read_csr32(usb, address);      \
                c.s.field = value;                              \
-               __cvmx_usb_write_csr32(usb, address, c.u32);    \
+               cvmx_usb_write_csr32(usb, address, c.u32);      \
        } while (0)
 
 /* Returns the IO address to push/pop stuff data from the FIFOs */
@@ -442,7 +435,6 @@ struct octeon_hcd {
 
 /**
  * struct octeon_temp_buffer - a bounce buffer for USB transfers
- * @temp_buffer: the newly allocated temporary buffer (including meta-data)
  * @orig_buffer: the original buffer passed by the USB stack
  * @data:       the newly allocated temporary buffer (excluding meta-data)
  *
@@ -451,7 +443,6 @@ struct octeon_hcd {
  * represents it.
  */
 struct octeon_temp_buffer {
-       void *temp_buffer;
        void *orig_buffer;
        u8 data[0];
 };
@@ -489,7 +480,6 @@ static int octeon_alloc_temp_buffer(struct urb *urb, gfp_t mem_flags)
        if (!temp)
                return -ENOMEM;
 
-       temp->temp_buffer = temp;
        temp->orig_buffer = urb->transfer_buffer;
        if (usb_urb_dir_out(urb))
                memcpy(temp->data, urb->transfer_buffer,
@@ -520,7 +510,7 @@ static void octeon_free_temp_buffer(struct urb *urb)
                       urb->actual_length);
        urb->transfer_buffer = temp->orig_buffer;
        urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
-       kfree(temp->temp_buffer);
+       kfree(temp);
 }
 
 /**
@@ -566,8 +556,8 @@ static void octeon_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
  *
  * Returns: Result of the read
  */
-static inline uint32_t __cvmx_usb_read_csr32(struct cvmx_usb_state *usb,
-                                            uint64_t address)
+static inline uint32_t cvmx_usb_read_csr32(struct cvmx_usb_state *usb,
+                                          uint64_t address)
 {
        uint32_t result = cvmx_read64_uint32(address ^ 4);
        return result;
@@ -583,45 +573,13 @@ static inline uint32_t __cvmx_usb_read_csr32(struct cvmx_usb_state *usb,
  * @address: 64bit address to write
  * @value:   Value to write
  */
-static inline void __cvmx_usb_write_csr32(struct cvmx_usb_state *usb,
-                                         uint64_t address, uint32_t value)
+static inline void cvmx_usb_write_csr32(struct cvmx_usb_state *usb,
+                                       uint64_t address, uint32_t value)
 {
        cvmx_write64_uint32(address ^ 4, value);
        cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index));
 }
 
-
-/**
- * Read a USB 64bit CSR. It logs the value in a readable format if
- * debugging is on.
- *
- * @usb:     USB block this access is for
- * @address: 64bit address to read
- *
- * Returns: Result of the read
- */
-static inline uint64_t __cvmx_usb_read_csr64(struct cvmx_usb_state *usb,
-                                            uint64_t address)
-{
-       uint64_t result = cvmx_read64_uint64(address);
-       return result;
-}
-
-
-/**
- * Write a USB 64bit CSR. It logs the value in a readable format
- * if debugging is on.
- *
- * @usb:     USB block this access is for
- * @address: 64bit address to write
- * @value:   Value to write
- */
-static inline void __cvmx_usb_write_csr64(struct cvmx_usb_state *usb,
-                                         uint64_t address, uint64_t value)
-{
-       cvmx_write64_uint64(address, value);
-}
-
 /**
  * Return non zero if this pipe connects to a non HIGH speed
  * device through a high speed hub.
@@ -631,8 +589,8 @@ static inline void __cvmx_usb_write_csr64(struct cvmx_usb_state *usb,
  *
  * Returns: Non zero if we need to do split transactions
  */
-static inline int __cvmx_usb_pipe_needs_split(struct cvmx_usb_state *usb,
-                                             struct cvmx_usb_pipe *pipe)
+static inline int cvmx_usb_pipe_needs_split(struct cvmx_usb_state *usb,
+                                           struct cvmx_usb_pipe *pipe)
 {
        return pipe->device_speed != CVMX_USB_SPEED_HIGH &&
               usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH;
@@ -646,48 +604,119 @@ static inline int __cvmx_usb_pipe_needs_split(struct cvmx_usb_state *usb,
  *
  * Returns: PID for pipe
  */
-static inline int __cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe)
+static inline int cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe)
 {
        if (pipe->pid_toggle)
                return 2; /* Data1 */
        return 0; /* Data0 */
 }
 
+static void cvmx_fifo_setup(struct cvmx_usb_state *usb)
+{
+       union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3;
+       union cvmx_usbcx_gnptxfsiz npsiz;
+       union cvmx_usbcx_hptxfsiz psiz;
+
+       usbcx_ghwcfg3.u32 = cvmx_usb_read_csr32(usb,
+                                               CVMX_USBCX_GHWCFG3(usb->index));
+
+       /*
+        * Program the USBC_GRXFSIZ register to select the size of the receive
+        * FIFO (25%).
+        */
+       USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), cvmx_usbcx_grxfsiz,
+                       rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4);
+
+       /*
+        * Program the USBC_GNPTXFSIZ register to select the size and the start
+        * address of the non-periodic transmit FIFO for nonperiodic
+        * transactions (50%).
+        */
+       npsiz.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index));
+       npsiz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2;
+       npsiz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), npsiz.u32);
+
+       /*
+        * Program the USBC_HPTXFSIZ register to select the size and start
+        * address of the periodic transmit FIFO for periodic transactions
+        * (25%).
+        */
+       psiz.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index));
+       psiz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4;
+       psiz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), psiz.u32);
+
+       /* Flush all FIFOs */
+       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
+                       cvmx_usbcx_grstctl, txfnum, 0x10);
+       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
+                       cvmx_usbcx_grstctl, txfflsh, 1);
+       CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
+                             cvmx_usbcx_grstctl, c.s.txfflsh == 0, 100);
+       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
+                       cvmx_usbcx_grstctl, rxfflsh, 1);
+       CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
+                             cvmx_usbcx_grstctl, c.s.rxfflsh == 0, 100);
+}
+
+/**
+ * Shutdown a USB port after a call to cvmx_usb_initialize().
+ * The port should be disabled with all pipes closed when this
+ * function is called.
+ *
+ * @usb: USB device state populated by cvmx_usb_initialize().
+ *
+ * Returns: 0 or a negative error code.
+ */
+static int cvmx_usb_shutdown(struct cvmx_usb_state *usb)
+{
+       union cvmx_usbnx_clk_ctl usbn_clk_ctl;
+
+       /* Make sure all pipes are closed */
+       if (!list_empty(&usb->idle_pipes) ||
+           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS]) ||
+           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT]) ||
+           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_CONTROL]) ||
+           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_BULK]))
+               return -EBUSY;
+
+       /* Disable the clocks and put them in power on reset */
+       usbn_clk_ctl.u64 = cvmx_read64_uint64(CVMX_USBNX_CLK_CTL(usb->index));
+       usbn_clk_ctl.s.enable = 1;
+       usbn_clk_ctl.s.por = 1;
+       usbn_clk_ctl.s.hclk_rst = 1;
+       usbn_clk_ctl.s.prst = 0;
+       usbn_clk_ctl.s.hrst = 0;
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
+       return 0;
+}
+
 /**
  * Initialize a USB port for use. This must be called before any
  * other access to the Octeon USB port is made. The port starts
  * off in the disabled state.
  *
- * @usb:        Pointer to an empty struct cvmx_usb_state
- *              that will be populated by the initialize call.
- *              This structure is then passed to all other USB
- *              functions.
- * @usb_port_number:
- *              Which Octeon USB port to initialize.
+ * @dev:        Pointer to struct device for logging purposes.
+ * @usb:        Pointer to struct cvmx_usb_state.
  *
  * Returns: 0 or a negative error code.
  */
-static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
-                              int usb_port_number,
-                              enum cvmx_usb_initialize_flags flags)
+static int cvmx_usb_initialize(struct device *dev,
+                              struct cvmx_usb_state *usb)
 {
+       int channel;
+       int divisor;
+       int retries = 0;
+       union cvmx_usbcx_hcfg usbcx_hcfg;
        union cvmx_usbnx_clk_ctl usbn_clk_ctl;
+       union cvmx_usbcx_gintsts usbc_gintsts;
+       union cvmx_usbcx_gahbcfg usbcx_gahbcfg;
+       union cvmx_usbcx_gintmsk usbcx_gintmsk;
+       union cvmx_usbcx_gusbcfg usbcx_gusbcfg;
        union cvmx_usbnx_usbp_ctl_status usbn_usbp_ctl_status;
-       int i;
-
-       /* At first allow 0-1 for the usb port number */
-       if ((usb_port_number < 0) || (usb_port_number > 1))
-               return -EINVAL;
-
-       memset(usb, 0, sizeof(*usb));
-       usb->init_flags = flags;
-
-       /* Initialize the USB state structure */
-       usb->index = usb_port_number;
-       INIT_LIST_HEAD(&usb->idle_pipes);
-       for (i = 0; i < ARRAY_SIZE(usb->active_pipes); i++)
-               INIT_LIST_HEAD(&usb->active_pipes[i]);
 
+retry:
        /*
         * Power On Reset and PHY Initialization
         *
@@ -696,8 +725,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         * 2a. Write USBN0/1_CLK_CTL[POR] = 1 and
         *     USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0
         */
-       usbn_clk_ctl.u64 =
-               __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index));
+       usbn_clk_ctl.u64 = cvmx_read64_uint64(CVMX_USBNX_CLK_CTL(usb->index));
        usbn_clk_ctl.s.por = 1;
        usbn_clk_ctl.s.hrst = 0;
        usbn_clk_ctl.s.prst = 0;
@@ -722,7 +750,8 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
                        /* From CN52XX manual */
                        usbn_clk_ctl.s.p_rtype = 1;
 
-               switch (flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK) {
+               switch (usb->init_flags &
+                       CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK) {
                case CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ:
                        usbn_clk_ctl.s.p_c_sel = 0;
                        break;
@@ -752,20 +781,17 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *     setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide the core clock down
         *     such that USB is as close as possible to 125Mhz
         */
-       {
-               int divisor = DIV_ROUND_UP(octeon_get_clock_rate(), 125000000);
-               /* Lower than 4 doesn't seem to work properly */
-               if (divisor < 4)
-                       divisor = 4;
-               usbn_clk_ctl.s.divide = divisor;
-               usbn_clk_ctl.s.divide2 = 0;
-       }
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       divisor = DIV_ROUND_UP(octeon_get_clock_rate(), 125000000);
+       /* Lower than 4 doesn't seem to work properly */
+       if (divisor < 4)
+               divisor = 4;
+       usbn_clk_ctl.s.divide = divisor;
+       usbn_clk_ctl.s.divide2 = 0;
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
+
        /* 2d. Write USBN0/1_CLK_CTL[HCLK_RST] = 1 */
        usbn_clk_ctl.s.hclk_rst = 1;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
        /* 2e.  Wait 64 core-clock cycles for HCLK to stabilize */
        cvmx_wait(64);
        /*
@@ -774,8 +800,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *    USBN_CLK_CTL[POR] = 0
         */
        usbn_clk_ctl.s.por = 0;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
        /* 4. Wait 1 ms for PHY clock to start */
        mdelay(1);
        /*
@@ -783,11 +808,11 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *    USBP control and status register:
         *    USBN_USBP_CTL_STATUS[ATE_RESET] = 1
         */
-       usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb,
-                       CVMX_USBNX_USBP_CTL_STATUS(usb->index));
+       usbn_usbp_ctl_status.u64 =
+               cvmx_read64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index));
        usbn_usbp_ctl_status.s.ate_reset = 1;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index),
-                              usbn_usbp_ctl_status.u64);
+       cvmx_write64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index),
+                           usbn_usbp_ctl_status.u64);
        /* 6. Wait 10 cycles */
        cvmx_wait(10);
        /*
@@ -795,23 +820,22 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *    USBN_USBP_CTL_STATUS[ATE_RESET] = 0
         */
        usbn_usbp_ctl_status.s.ate_reset = 0;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index),
-                              usbn_usbp_ctl_status.u64);
+       cvmx_write64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index),
+                           usbn_usbp_ctl_status.u64);
        /*
         * 8. Program the PHY reset field in the USBN clock-control register:
         *    USBN_CLK_CTL[PRST] = 1
         */
        usbn_clk_ctl.s.prst = 1;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
        /*
         * 9. Program the USBP control and status register to select host or
         *    device mode. USBN_USBP_CTL_STATUS[HST_MODE] = 0 for host, = 1 for
         *    device
         */
        usbn_usbp_ctl_status.s.hst_mode = 0;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index),
-                              usbn_usbp_ctl_status.u64);
+       cvmx_write64_uint64(CVMX_USBNX_USBP_CTL_STATUS(usb->index),
+                           usbn_usbp_ctl_status.u64);
        /* 10. Wait 1 us */
        udelay(1);
        /*
@@ -819,12 +843,10 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *     USBN_CLK_CTL[HRST] = 1
         */
        usbn_clk_ctl.s.hrst = 1;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
        /* 12. Proceed to USB core initialization */
        usbn_clk_ctl.s.enable = 1;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
+       cvmx_write64_uint64(CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64);
        udelay(1);
 
        /*
@@ -845,29 +867,16 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *    USBC_GAHBCFG[PTXFEMPLVL]
         *    Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1
         */
-       {
-               union cvmx_usbcx_gahbcfg usbcx_gahbcfg;
-               /* Due to an errata, CN31XX doesn't support DMA */
-               if (OCTEON_IS_MODEL(OCTEON_CN31XX))
-                       usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA;
-               usbcx_gahbcfg.u32 = 0;
-               usbcx_gahbcfg.s.dmaen = !(usb->init_flags &
-                                         CVMX_USB_INITIALIZE_FLAGS_NO_DMA);
-               if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
-                       /* Only use one channel with non DMA */
-                       usb->idle_hardware_channels = 0x1;
-               else if (OCTEON_IS_MODEL(OCTEON_CN5XXX))
-                       /* CN5XXX have an errata with channel 3 */
-                       usb->idle_hardware_channels = 0xf7;
-               else
-                       usb->idle_hardware_channels = 0xff;
-               usbcx_gahbcfg.s.hbstlen = 0;
-               usbcx_gahbcfg.s.nptxfemplvl = 1;
-               usbcx_gahbcfg.s.ptxfemplvl = 1;
-               usbcx_gahbcfg.s.glblintrmsk = 1;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_GAHBCFG(usb->index),
-                                      usbcx_gahbcfg.u32);
-       }
+       usbcx_gahbcfg.u32 = 0;
+       usbcx_gahbcfg.s.dmaen = !(usb->init_flags &
+                                 CVMX_USB_INITIALIZE_FLAGS_NO_DMA);
+       usbcx_gahbcfg.s.hbstlen = 0;
+       usbcx_gahbcfg.s.nptxfemplvl = 1;
+       usbcx_gahbcfg.s.ptxfemplvl = 1;
+       usbcx_gahbcfg.s.glblintrmsk = 1;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GAHBCFG(usb->index),
+                            usbcx_gahbcfg.u32);
+
        /*
         * 3. Program the following fields in USBC_GUSBCFG register.
         *    HS/FS timeout calibration, USBC_GUSBCFG[TOUTCAL] = 0
@@ -875,154 +884,98 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb,
         *    USB turnaround time, USBC_GUSBCFG[USBTRDTIM] = 0x5
         *    PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0
         */
-       {
-               union cvmx_usbcx_gusbcfg usbcx_gusbcfg;
-
-               usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_GUSBCFG(usb->index));
-               usbcx_gusbcfg.s.toutcal = 0;
-               usbcx_gusbcfg.s.ddrsel = 0;
-               usbcx_gusbcfg.s.usbtrdtim = 0x5;
-               usbcx_gusbcfg.s.phylpwrclksel = 0;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index),
-                                      usbcx_gusbcfg.u32);
-       }
+       usbcx_gusbcfg.u32 = cvmx_usb_read_csr32(usb,
+                                               CVMX_USBCX_GUSBCFG(usb->index));
+       usbcx_gusbcfg.s.toutcal = 0;
+       usbcx_gusbcfg.s.ddrsel = 0;
+       usbcx_gusbcfg.s.usbtrdtim = 0x5;
+       usbcx_gusbcfg.s.phylpwrclksel = 0;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index),
+                            usbcx_gusbcfg.u32);
+
        /*
         * 4. The software must unmask the following bits in the USBC_GINTMSK
         *    register.
         *    OTG interrupt mask, USBC_GINTMSK[OTGINTMSK] = 1
         *    Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1
         */
-       {
-               union cvmx_usbcx_gintmsk usbcx_gintmsk;
-               int channel;
-
-               usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_GINTMSK(usb->index));
-               usbcx_gintmsk.s.otgintmsk = 1;
-               usbcx_gintmsk.s.modemismsk = 1;
-               usbcx_gintmsk.s.hchintmsk = 1;
-               usbcx_gintmsk.s.sofmsk = 0;
-               /* We need RX FIFO interrupts if we don't have DMA */
-               if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
-                       usbcx_gintmsk.s.rxflvlmsk = 1;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTMSK(usb->index),
-                                      usbcx_gintmsk.u32);
-
-               /*
-                * Disable all channel interrupts. We'll enable them per channel
-                * later.
-                */
-               for (channel = 0; channel < 8; channel++)
-                       __cvmx_usb_write_csr32(usb,
-                               CVMX_USBCX_HCINTMSKX(channel, usb->index), 0);
-       }
-
-       {
-               /*
-                * Host Port Initialization
-                *
-                * 1. Program the host-port interrupt-mask field to unmask,
-                *    USBC_GINTMSK[PRTINT] = 1
-                */
-               USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                               union cvmx_usbcx_gintmsk, prtintmsk, 1);
-               USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                               union cvmx_usbcx_gintmsk, disconnintmsk, 1);
-               /*
-                * 2. Program the USBC_HCFG register to select full-speed host
-                *    or high-speed host.
-                */
-               {
-                       union cvmx_usbcx_hcfg usbcx_hcfg;
-
-                       usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb,
-                                       CVMX_USBCX_HCFG(usb->index));
-                       usbcx_hcfg.s.fslssupp = 0;
-                       usbcx_hcfg.s.fslspclksel = 0;
-                       __cvmx_usb_write_csr32(usb,
-                                       CVMX_USBCX_HCFG(usb->index),
-                                       usbcx_hcfg.u32);
-               }
-               /*
-                * 3. Program the port power bit to drive VBUS on the USB,
-                *    USBC_HPRT[PRTPWR] = 1
-                */
-               USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index),
-                               union cvmx_usbcx_hprt, prtpwr, 1);
-
-               /*
-                * Steps 4-15 from the manual are done later in the port enable
-                */
-       }
+       usbcx_gintmsk.u32 = cvmx_usb_read_csr32(usb,
+                                               CVMX_USBCX_GINTMSK(usb->index));
+       usbcx_gintmsk.s.otgintmsk = 1;
+       usbcx_gintmsk.s.modemismsk = 1;
+       usbcx_gintmsk.s.hchintmsk = 1;
+       usbcx_gintmsk.s.sofmsk = 0;
+       /* We need RX FIFO interrupts if we don't have DMA */
+       if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
+               usbcx_gintmsk.s.rxflvlmsk = 1;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTMSK(usb->index),
+                            usbcx_gintmsk.u32);
 
-       return 0;
-}
+       /*
+        * Disable all channel interrupts. We'll enable them per channel later.
+        */
+       for (channel = 0; channel < 8; channel++)
+               cvmx_usb_write_csr32(usb,
+                                    CVMX_USBCX_HCINTMSKX(channel, usb->index),
+                                    0);
 
+       /*
+        * Host Port Initialization
+        *
+        * 1. Program the host-port interrupt-mask field to unmask,
+        *    USBC_GINTMSK[PRTINT] = 1
+        */
+       USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
+                       cvmx_usbcx_gintmsk, prtintmsk, 1);
+       USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
+                       cvmx_usbcx_gintmsk, disconnintmsk, 1);
 
-/**
- * Shutdown a USB port after a call to cvmx_usb_initialize().
- * The port should be disabled with all pipes closed when this
- * function is called.
- *
- * @usb: USB device state populated by cvmx_usb_initialize().
- *
- * Returns: 0 or a negative error code.
- */
-static int cvmx_usb_shutdown(struct cvmx_usb_state *usb)
-{
-       union cvmx_usbnx_clk_ctl usbn_clk_ctl;
+       /*
+        * 2. Program the USBC_HCFG register to select full-speed host
+        *    or high-speed host.
+        */
+       usbcx_hcfg.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index));
+       usbcx_hcfg.s.fslssupp = 0;
+       usbcx_hcfg.s.fslspclksel = 0;
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_HCFG(usb->index), usbcx_hcfg.u32);
 
-       /* Make sure all pipes are closed */
-       if (!list_empty(&usb->idle_pipes) ||
-           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS]) ||
-           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT]) ||
-           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_CONTROL]) ||
-           !list_empty(&usb->active_pipes[CVMX_USB_TRANSFER_BULK]))
-               return -EBUSY;
+       cvmx_fifo_setup(usb);
 
-       /* Disable the clocks and put them in power on reset */
-       usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb,
-                       CVMX_USBNX_CLK_CTL(usb->index));
-       usbn_clk_ctl.s.enable = 1;
-       usbn_clk_ctl.s.por = 1;
-       usbn_clk_ctl.s.hclk_rst = 1;
-       usbn_clk_ctl.s.prst = 0;
-       usbn_clk_ctl.s.hrst = 0;
-       __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index),
-                              usbn_clk_ctl.u64);
-       return 0;
+       /*
+        * If the controller is getting port events right after the reset, it
+        * means the initialization failed. Try resetting the controller again
+        * in such case. This is seen to happen after cold boot on DSR-1000N.
+        */
+       usbc_gintsts.u32 = cvmx_usb_read_csr32(usb,
+                                              CVMX_USBCX_GINTSTS(usb->index));
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index),
+                            usbc_gintsts.u32);
+       dev_dbg(dev, "gintsts after reset: 0x%x\n", (int)usbc_gintsts.u32);
+       if (!usbc_gintsts.s.disconnint && !usbc_gintsts.s.prtint)
+               return 0;
+       if (retries++ >= 5)
+               return -EAGAIN;
+       dev_info(dev, "controller reset failed (gintsts=0x%x) - retrying\n",
+                (int)usbc_gintsts.u32);
+       msleep(50);
+       cvmx_usb_shutdown(usb);
+       msleep(50);
+       goto retry;
 }
 
-
 /**
- * Enable a USB port. After this call succeeds, the USB port is
+ * Reset a USB port. After this call succeeds, the USB port is
  * online and servicing requests.
  *
  * @usb: USB device state populated by cvmx_usb_initialize().
- *
- * Returns: 0 or a negative error code.
  */
-static int cvmx_usb_enable(struct cvmx_usb_state *usb)
+static void cvmx_usb_reset_port(struct cvmx_usb_state *usb)
 {
-       union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3;
-
-       usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HPRT(usb->index));
-
-       /*
-        * If the port is already enabled the just return. We don't need to do
-        * anything
-        */
-       if (usb->usbcx_hprt.s.prtena)
-               return 0;
-
-       /* If there is nothing plugged into the port then fail immediately */
-       if (!usb->usbcx_hprt.s.prtconnsts)
-               return -ETIMEDOUT;
+       usb->usbcx_hprt.u32 = cvmx_usb_read_csr32(usb,
+                                                 CVMX_USBCX_HPRT(usb->index));
 
        /* Program the port reset bit to start the reset process */
-       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt,
+       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt,
                        prtrst, 1);
 
        /*
@@ -1032,75 +985,15 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb)
        mdelay(50);
 
        /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */
-       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt,
+       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt,
                        prtrst, 0);
 
-       /* Wait for the USBC_HPRT[PRTENA]. */
-       if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index),
-                               union cvmx_usbcx_hprt, prtena, ==, 1, 100000))
-               return -ETIMEDOUT;
-
        /*
         * Read the port speed field to get the enumerated speed,
         * USBC_HPRT[PRTSPD].
         */
-       usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HPRT(usb->index));
-       usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_GHWCFG3(usb->index));
-
-       /*
-        * 13. Program the USBC_GRXFSIZ register to select the size of the
-        *     receive FIFO (25%).
-        */
-       USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index),
-                       union cvmx_usbcx_grxfsiz, rxfdep,
-                       usbcx_ghwcfg3.s.dfifodepth / 4);
-       /*
-        * 14. Program the USBC_GNPTXFSIZ register to select the size and the
-        *     start address of the non- periodic transmit FIFO for nonperiodic
-        *     transactions (50%).
-        */
-       {
-               union cvmx_usbcx_gnptxfsiz siz;
-
-               siz.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_GNPTXFSIZ(usb->index));
-               siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2;
-               siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index),
-                                      siz.u32);
-       }
-       /*
-        * 15. Program the USBC_HPTXFSIZ register to select the size and start
-        *     address of the periodic transmit FIFO for periodic transactions
-        *     (25%).
-        */
-       {
-               union cvmx_usbcx_hptxfsiz siz;
-
-               siz.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HPTXFSIZ(usb->index));
-               siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4;
-               siz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index),
-                                      siz.u32);
-       }
-       /* Flush all FIFOs */
-       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
-                       union cvmx_usbcx_grstctl, txfnum, 0x10);
-       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
-                       union cvmx_usbcx_grstctl, txfflsh, 1);
-       CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
-                             union cvmx_usbcx_grstctl,
-                             txfflsh, ==, 0, 100);
-       USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
-                       union cvmx_usbcx_grstctl, rxfflsh, 1);
-       CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index),
-                             union cvmx_usbcx_grstctl,
-                             rxfflsh, ==, 0, 100);
-
-       return 0;
+       usb->usbcx_hprt.u32 = cvmx_usb_read_csr32(usb,
+                                                 CVMX_USBCX_HPRT(usb->index));
 }
 
 
@@ -1117,7 +1010,7 @@ static int cvmx_usb_enable(struct cvmx_usb_state *usb)
 static int cvmx_usb_disable(struct cvmx_usb_state *usb)
 {
        /* Disable the port */
-       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt,
+       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt,
                        prtena, 1);
        return 0;
 }
@@ -1142,8 +1035,7 @@ static struct cvmx_usb_port_status cvmx_usb_get_status(
 
        memset(&result, 0, sizeof(result));
 
-       usbc_hprt.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HPRT(usb->index));
+       usbc_hprt.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index));
        result.port_enabled = usbc_hprt.s.prtena;
        result.port_over_current = usbc_hprt.s.prtovrcurract;
        result.port_powered = usbc_hprt.s.prtpwr;
@@ -1223,41 +1115,13 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb,
 {
        struct cvmx_usb_pipe *pipe;
 
-       if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS)))
-               return NULL;
-       if (unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT)))
-               return NULL;
-       if (unlikely(device_speed > CVMX_USB_SPEED_LOW))
-               return NULL;
-       if (unlikely((max_packet <= 0) || (max_packet > 1024)))
-               return NULL;
-       if (unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT))
-               return NULL;
-       if (unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) &&
-               (transfer_dir != CVMX_USB_DIRECTION_IN)))
-               return NULL;
-       if (unlikely(interval < 0))
-               return NULL;
-       if (unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval))
-               return NULL;
-       if (unlikely(multi_count < 0))
-               return NULL;
-       if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) &&
-               (multi_count != 0)))
-               return NULL;
-       if (unlikely((hub_device_addr < 0) ||
-               (hub_device_addr > MAX_USB_ADDRESS)))
-               return NULL;
-       if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT)))
-               return NULL;
-
        pipe = kzalloc(sizeof(*pipe), GFP_ATOMIC);
        if (!pipe)
                return NULL;
        if ((device_speed == CVMX_USB_SPEED_HIGH) &&
                (transfer_dir == CVMX_USB_DIRECTION_OUT) &&
                (transfer_type == CVMX_USB_TRANSFER_BULK))
-               pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING;
+               pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING;
        pipe->device_addr = device_addr;
        pipe->endpoint_num = endpoint_num;
        pipe->device_speed = device_speed;
@@ -1272,7 +1136,7 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb,
         */
        if (!interval)
                interval = 1;
-       if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+       if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                pipe->interval = interval*8;
                /* Force start splits to be schedule on uFrame 0 */
                pipe->next_tx_frame = ((usb->frame_number+7)&~7) +
@@ -1304,7 +1168,7 @@ static struct cvmx_usb_pipe *cvmx_usb_open_pipe(struct cvmx_usb_state *usb,
  *
  * @usb:       USB device state populated by cvmx_usb_initialize().
  */
-static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
+static void cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
 {
        union cvmx_usbcx_grxstsph rx_status;
        int channel;
@@ -1312,8 +1176,8 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
        uint64_t address;
        uint32_t *ptr;
 
-       rx_status.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_GRXSTSPH(usb->index));
+       rx_status.u32 = cvmx_usb_read_csr32(usb,
+                                           CVMX_USBCX_GRXSTSPH(usb->index));
        /* Only read data if IN data is there */
        if (rx_status.s.pktsts != 2)
                return;
@@ -1327,18 +1191,17 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
                return;
 
        /* Get where the DMA engine would have written this data */
-       address = __cvmx_usb_read_csr64(usb,
-                       CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8);
+       address = cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index) +
+                                    channel * 8);
 
        ptr = cvmx_phys_to_ptr(address);
-       __cvmx_usb_write_csr64(usb,
-                              CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8,
-                              address + bytes);
+       cvmx_write64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel * 8,
+                           address + bytes);
 
        /* Loop writing the FIFO data for this packet into memory */
        while (bytes > 0) {
-               *ptr++ = __cvmx_usb_read_csr32(usb,
-                               USB_FIFO_ADDRESS(channel, usb->index));
+               *ptr++ = cvmx_usb_read_csr32(usb,
+                                       USB_FIFO_ADDRESS(channel, usb->index));
                bytes -= 4;
        }
        CVMX_SYNCW;
@@ -1356,8 +1219,8 @@ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_state *usb)
  * Returns: Non zero if the hardware fifo was too small and needs
  *         to be serviced again.
  */
-static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb,
-                                struct cvmx_usb_tx_fifo *fifo, int available)
+static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb,
+                              struct cvmx_usb_tx_fifo *fifo, int available)
 {
        /*
         * We're done either when there isn't anymore space or the software FIFO
@@ -1412,38 +1275,34 @@ static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb,
  *
  * @usb:       USB device state populated by cvmx_usb_initialize().
  */
-static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb)
+static void cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb)
 {
        if (usb->periodic.head != usb->periodic.tail) {
                union cvmx_usbcx_hptxsts tx_status;
 
-               tx_status.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HPTXSTS(usb->index));
-               if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic,
-                                         tx_status.s.ptxfspcavail))
+               tx_status.u32 = cvmx_usb_read_csr32(usb,
+                                       CVMX_USBCX_HPTXSTS(usb->index));
+               if (cvmx_usb_fill_tx_hw(usb, &usb->periodic,
+                                       tx_status.s.ptxfspcavail))
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                                       union cvmx_usbcx_gintmsk,
-                                       ptxfempmsk, 1);
+                                       cvmx_usbcx_gintmsk, ptxfempmsk, 1);
                else
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                                       union cvmx_usbcx_gintmsk,
-                                       ptxfempmsk, 0);
+                                       cvmx_usbcx_gintmsk, ptxfempmsk, 0);
        }
 
        if (usb->nonperiodic.head != usb->nonperiodic.tail) {
                union cvmx_usbcx_gnptxsts tx_status;
 
-               tx_status.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_GNPTXSTS(usb->index));
-               if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic,
-                                         tx_status.s.nptxfspcavail))
+               tx_status.u32 = cvmx_usb_read_csr32(usb,
+                                       CVMX_USBCX_GNPTXSTS(usb->index));
+               if (cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic,
+                                       tx_status.s.nptxfspcavail))
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                                       union cvmx_usbcx_gintmsk,
-                                       nptxfempmsk, 1);
+                                       cvmx_usbcx_gintmsk, nptxfempmsk, 1);
                else
                        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                                       union cvmx_usbcx_gintmsk,
-                                       nptxfempmsk, 0);
+                                       cvmx_usbcx_gintmsk, nptxfempmsk, 0);
        }
 }
 
@@ -1454,7 +1313,7 @@ static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_state *usb)
  * @usb:         USB device state populated by cvmx_usb_initialize().
  * @channel:     Channel number to get packet from
  */
-static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
+static void cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
 {
        union cvmx_usbcx_hccharx hcchar;
        union cvmx_usbcx_hcspltx usbc_hcsplt;
@@ -1462,14 +1321,14 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
        struct cvmx_usb_tx_fifo *fifo;
 
        /* We only need to fill data on outbound channels */
-       hcchar.u32 = __cvmx_usb_read_csr32(usb,
+       hcchar.u32 = cvmx_usb_read_csr32(usb,
                        CVMX_USBCX_HCCHARX(channel, usb->index));
        if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT)
                return;
 
        /* OUT Splits only have data on the start and not the complete */
-       usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCSPLTX(channel, usb->index));
+       usbc_hcsplt.u32 = cvmx_usb_read_csr32(usb,
+                               CVMX_USBCX_HCSPLTX(channel, usb->index));
        if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt)
                return;
 
@@ -1477,8 +1336,8 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
         * Find out how many bytes we need to fill and convert it into 32bit
         * words.
         */
-       usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCTSIZX(channel, usb->index));
+       usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
+                               CVMX_USBCX_HCTSIZX(channel, usb->index));
        if (!usbc_hctsiz.s.xfersize)
                return;
 
@@ -1489,28 +1348,28 @@ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_state *usb, int channel)
                fifo = &usb->nonperiodic;
 
        fifo->entry[fifo->head].channel = channel;
-       fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb,
-                       CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8);
+       fifo->entry[fifo->head].address =
+               cvmx_read64_uint64(CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) +
+                                  channel * 8);
        fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2;
        fifo->head++;
        if (fifo->head > MAX_CHANNELS)
                fifo->head = 0;
 
-       __cvmx_usb_poll_tx_fifo(usb);
+       cvmx_usb_poll_tx_fifo(usb);
 }
 
 /**
  * Perform channel specific setup for Control transactions. All
- * the generic stuff will already have been done in
- * __cvmx_usb_start_channel()
+ * the generic stuff will already have been done in cvmx_usb_start_channel().
  *
  * @usb:         USB device state populated by cvmx_usb_initialize().
  * @channel:     Channel to setup
  * @pipe:        Pipe for control transaction
  */
-static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
-                                            int channel,
-                                            struct cvmx_usb_pipe *pipe)
+static void cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
+                                          int channel,
+                                          struct cvmx_usb_pipe *pipe)
 {
        struct octeon_hcd *priv = cvmx_usb_to_octeon(usb);
        struct usb_hcd *hcd = octeon_to_hcd(priv);
@@ -1525,8 +1384,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
        int packets_to_transfer;
        union cvmx_usbcx_hctsizx usbc_hctsiz;
 
-       usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCTSIZX(channel, usb->index));
+       usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
+                               CVMX_USBCX_HCTSIZX(channel, usb->index));
 
        switch (transaction->stage) {
        case CVMX_USB_STAGE_NON_CONTROL:
@@ -1538,72 +1397,72 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
                bytes_to_transfer = sizeof(*header);
                /* All Control operations start with a setup going OUT */
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                CVMX_USB_DIRECTION_OUT);
                /*
                 * Setup send the control header instead of the buffer data. The
                 * buffer data will be used in the next stage
                 */
-               __cvmx_usb_write_csr64(usb,
-                       CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8,
-                       transaction->control_header);
+               cvmx_write64_uint64(CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) +
+                                       channel * 8,
+                                   transaction->control_header);
                break;
        case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE:
                usbc_hctsiz.s.pid = 3; /* Setup */
                bytes_to_transfer = 0;
                /* All Control operations start with a setup going OUT */
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                CVMX_USB_DIRECTION_OUT);
 
                USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index),
-                               union cvmx_usbcx_hcspltx, compsplt, 1);
+                               cvmx_usbcx_hcspltx, compsplt, 1);
                break;
        case CVMX_USB_STAGE_DATA:
-               usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe);
-               if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+               usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
+               if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                        if (header->bRequestType & USB_DIR_IN)
                                bytes_to_transfer = 0;
                        else if (bytes_to_transfer > pipe->max_packet)
                                bytes_to_transfer = pipe->max_packet;
                }
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                ((header->bRequestType & USB_DIR_IN) ?
                                        CVMX_USB_DIRECTION_IN :
                                        CVMX_USB_DIRECTION_OUT));
                break;
        case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE:
-               usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe);
+               usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
                if (!(header->bRequestType & USB_DIR_IN))
                        bytes_to_transfer = 0;
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                ((header->bRequestType & USB_DIR_IN) ?
                                        CVMX_USB_DIRECTION_IN :
                                        CVMX_USB_DIRECTION_OUT));
                USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index),
-                               union cvmx_usbcx_hcspltx, compsplt, 1);
+                               cvmx_usbcx_hcspltx, compsplt, 1);
                break;
        case CVMX_USB_STAGE_STATUS:
-               usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe);
+               usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
                bytes_to_transfer = 0;
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                ((header->bRequestType & USB_DIR_IN) ?
                                        CVMX_USB_DIRECTION_OUT :
                                        CVMX_USB_DIRECTION_IN));
                break;
        case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE:
-               usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe);
+               usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
                bytes_to_transfer = 0;
                USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                               union cvmx_usbcx_hccharx, epdir,
+                               cvmx_usbcx_hccharx, epdir,
                                ((header->bRequestType & USB_DIR_IN) ?
                                        CVMX_USB_DIRECTION_OUT :
                                        CVMX_USB_DIRECTION_IN));
                USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index),
-                               union cvmx_usbcx_hcspltx, compsplt, 1);
+                               cvmx_usbcx_hcspltx, compsplt, 1);
                break;
        }
 
@@ -1646,8 +1505,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
        usbc_hctsiz.s.xfersize = bytes_to_transfer;
        usbc_hctsiz.s.pktcnt = packets_to_transfer;
 
-       __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index),
-                              usbc_hctsiz.u32);
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index),
+                            usbc_hctsiz.u32);
 }
 
 
@@ -1658,9 +1517,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb,
  * @channel:     Channel to setup
  * @pipe:        Pipe to start
  */
-static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
-                                    int channel,
-                                    struct cvmx_usb_pipe *pipe)
+static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel,
+                                  struct cvmx_usb_pipe *pipe)
 {
        struct cvmx_usb_transaction *transaction =
                list_first_entry(&pipe->transactions, typeof(*transaction),
@@ -1672,7 +1530,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
        /* Attach the channel to the pipe */
        usb->pipe_for_channel[channel] = pipe;
        pipe->channel = channel;
-       pipe->flags |= __CVMX_USB_PIPE_FLAGS_SCHEDULED;
+       pipe->flags |= CVMX_USB_PIPE_FLAGS_SCHEDULED;
 
        /* Mark this channel as in use */
        usb->idle_hardware_channels &= ~(1<<channel);
@@ -1684,12 +1542,12 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                union cvmx_usbcx_haintmsk usbc_haintmsk;
 
                /* Clear all channel status bits */
-               usbc_hcint.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HCINTX(channel, usb->index));
+               usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
+                                       CVMX_USBCX_HCINTX(channel, usb->index));
 
-               __cvmx_usb_write_csr32(usb,
-                                      CVMX_USBCX_HCINTX(channel, usb->index),
-                                      usbc_hcint.u32);
+               cvmx_usb_write_csr32(usb,
+                                    CVMX_USBCX_HCINTX(channel, usb->index),
+                                    usbc_hcint.u32);
 
                usbc_hcintmsk.u32 = 0;
                usbc_hcintmsk.s.chhltdmsk = 1;
@@ -1702,7 +1560,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                        usbc_hcintmsk.s.frmovrunmsk = 1;
                        usbc_hcintmsk.s.bblerrmsk = 1;
                        usbc_hcintmsk.s.xacterrmsk = 1;
-                       if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+                       if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                                /*
                                 * Splits don't generate xfercompl, so we need
                                 * ACK and NYET.
@@ -1714,21 +1572,21 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                        usbc_hcintmsk.s.stallmsk = 1;
                        usbc_hcintmsk.s.xfercomplmsk = 1;
                }
-               __cvmx_usb_write_csr32(usb,
+               cvmx_usb_write_csr32(usb,
                                CVMX_USBCX_HCINTMSKX(channel, usb->index),
                                usbc_hcintmsk.u32);
 
                /* Enable the channel interrupt to propagate */
-               usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb,
+               usbc_haintmsk.u32 = cvmx_usb_read_csr32(usb,
                                        CVMX_USBCX_HAINTMSK(usb->index));
                usbc_haintmsk.s.haintmsk |= 1<<channel;
-               __cvmx_usb_write_csr32(usb,
-                                       CVMX_USBCX_HAINTMSK(usb->index),
-                                       usbc_haintmsk.u32);
+               cvmx_usb_write_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index),
+                                    usbc_haintmsk.u32);
        }
 
-       /* Setup the locations the DMA engines use  */
+       /* Setup the location the DMA engine uses. */
        {
+               uint64_t reg;
                uint64_t dma_address = transaction->buffer +
                                        transaction->actual_bytes;
 
@@ -1737,13 +1595,11 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                                        transaction->iso_packets[0].offset +
                                        transaction->actual_bytes;
 
-               __cvmx_usb_write_csr64(usb,
-                       CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8,
-                       dma_address);
-
-               __cvmx_usb_write_csr64(usb,
-                       CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8,
-                       dma_address);
+               if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)
+                       reg = CVMX_USBNX_DMA0_OUTB_CHN0(usb->index);
+               else
+                       reg = CVMX_USBNX_DMA0_INB_CHN0(usb->index);
+               cvmx_write64_uint64(reg + channel * 8, dma_address);
        }
 
        /* Setup both the size of the transfer and the SPLIT characteristics */
@@ -1767,7 +1623,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                 * We need to do split transactions when we are talking to non
                 * high speed devices that are behind a high speed hub
                 */
-               if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+               if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                        /*
                         * On the start split phase (stage is even) record the
                         * frame number we will need to send the split complete.
@@ -1898,18 +1754,19 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                usbc_hctsiz.s.pktcnt = packets_to_transfer;
 
                /* Update the DATA0/DATA1 toggle */
-               usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe);
+               usbc_hctsiz.s.pid = cvmx_usb_get_data_pid(pipe);
                /*
                 * High speed pipes may need a hardware ping before they start
                 */
-               if (pipe->flags & __CVMX_USB_PIPE_FLAGS_NEED_PING)
+               if (pipe->flags & CVMX_USB_PIPE_FLAGS_NEED_PING)
                        usbc_hctsiz.s.dopng = 1;
 
-               __cvmx_usb_write_csr32(usb,
-                                      CVMX_USBCX_HCSPLTX(channel, usb->index),
-                                      usbc_hcsplt.u32);
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel,
-                                       usb->index), usbc_hctsiz.u32);
+               cvmx_usb_write_csr32(usb,
+                                    CVMX_USBCX_HCSPLTX(channel, usb->index),
+                                    usbc_hcsplt.u32);
+               cvmx_usb_write_csr32(usb,
+                                    CVMX_USBCX_HCTSIZX(channel, usb->index),
+                                    usbc_hctsiz.u32);
        }
 
        /* Setup the Host Channel Characteristics Register */
@@ -1928,7 +1785,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                 * immediate retries of failure. These retries happen too
                 * quickly, so we disable these entirely for splits
                 */
-               if (__cvmx_usb_pipe_needs_split(usb, pipe))
+               if (cvmx_usb_pipe_needs_split(usb, pipe))
                        usbc_hcchar.s.ec = 1;
                else if (pipe->multi_count < 1)
                        usbc_hcchar.s.ec = 1;
@@ -1945,21 +1802,21 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                usbc_hcchar.s.epdir = pipe->transfer_dir;
                usbc_hcchar.s.epnum = pipe->endpoint_num;
                usbc_hcchar.s.mps = pipe->max_packet;
-               __cvmx_usb_write_csr32(usb,
-                                      CVMX_USBCX_HCCHARX(channel, usb->index),
-                                      usbc_hcchar.u32);
+               cvmx_usb_write_csr32(usb,
+                                    CVMX_USBCX_HCCHARX(channel, usb->index),
+                                    usbc_hcchar.u32);
        }
 
        /* Do transaction type specific fixups as needed */
        switch (transaction->type) {
        case CVMX_USB_TRANSFER_CONTROL:
-               __cvmx_usb_start_channel_control(usb, channel, pipe);
+               cvmx_usb_start_channel_control(usb, channel, pipe);
                break;
        case CVMX_USB_TRANSFER_BULK:
        case CVMX_USB_TRANSFER_INTERRUPT:
                break;
        case CVMX_USB_TRANSFER_ISOCHRONOUS:
-               if (!__cvmx_usb_pipe_needs_split(usb, pipe)) {
+               if (!cvmx_usb_pipe_needs_split(usb, pipe)) {
                        /*
                         * ISO transactions require different PIDs depending on
                         * direction and how many packets are needed
@@ -1969,32 +1826,30 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
                                        USB_SET_FIELD32(
                                                CVMX_USBCX_HCTSIZX(channel,
                                                                   usb->index),
-                                               union cvmx_usbcx_hctsizx,
-                                               pid, 0);
+                                               cvmx_usbcx_hctsizx, pid, 0);
                                else /* Need MDATA */
                                        USB_SET_FIELD32(
                                                CVMX_USBCX_HCTSIZX(channel,
                                                                   usb->index),
-                                               union cvmx_usbcx_hctsizx,
-                                               pid, 3);
+                                               cvmx_usbcx_hctsizx, pid, 3);
                        }
                }
                break;
        }
        {
                union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 =
-                       __cvmx_usb_read_csr32(usb,
+                       cvmx_usb_read_csr32(usb,
                                CVMX_USBCX_HCTSIZX(channel, usb->index))};
                transaction->xfersize = usbc_hctsiz.s.xfersize;
                transaction->pktcnt = usbc_hctsiz.s.pktcnt;
        }
        /* Remeber when we start a split transaction */
-       if (__cvmx_usb_pipe_needs_split(usb, pipe))
+       if (cvmx_usb_pipe_needs_split(usb, pipe))
                usb->active_split = transaction;
        USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
-                       union cvmx_usbcx_hccharx, chena, 1);
+                       cvmx_usbcx_hccharx, chena, 1);
        if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
-               __cvmx_usb_fill_tx_fifo(usb, channel);
+               cvmx_usb_fill_tx_fifo(usb, channel);
 }
 
 
@@ -2007,7 +1862,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb,
  *
  * Returns: Pipe or NULL if none are ready
  */
-static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(
+static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe(
                struct cvmx_usb_state *usb,
                struct list_head *list,
                uint64_t current_frame)
@@ -2018,7 +1873,7 @@ static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(
                struct cvmx_usb_transaction *t =
                        list_first_entry(&pipe->transactions, typeof(*t),
                                         node);
-               if (!(pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED) && t &&
+               if (!(pipe->flags & CVMX_USB_PIPE_FLAGS_SCHEDULED) && t &&
                        (pipe->next_tx_frame <= current_frame) &&
                        ((pipe->split_sc_frame == -1) ||
                         ((((int)current_frame - (int)pipe->split_sc_frame)
@@ -2039,7 +1894,7 @@ static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(
  * @usb:        USB device state populated by cvmx_usb_initialize().
  * @is_sof:     True if this schedule was called on a SOF interrupt.
  */
-static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof)
+static void cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof)
 {
        int channel;
        struct cvmx_usb_pipe *pipe;
@@ -2052,12 +1907,12 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof)
                 * at the end of a frame and cause an overrun.
                 */
                union cvmx_usbcx_hfnum hfnum = {
-                       .u32 = __cvmx_usb_read_csr32(usb,
+                       .u32 = cvmx_usb_read_csr32(usb,
                                                CVMX_USBCX_HFNUM(usb->index))
                };
 
                union cvmx_usbcx_hfir hfir = {
-                       .u32 = __cvmx_usb_read_csr32(usb,
+                       .u32 = cvmx_usb_read_csr32(usb,
                                                CVMX_USBCX_HFIR(usb->index))
                };
 
@@ -2079,23 +1934,23 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof)
                         * way we are sure that the periodic data is sent in the
                         * beginning of the frame
                         */
-                       pipe = __cvmx_usb_find_ready_pipe(usb,
+                       pipe = cvmx_usb_find_ready_pipe(usb,
                                        usb->active_pipes +
                                        CVMX_USB_TRANSFER_ISOCHRONOUS,
                                        usb->frame_number);
                        if (likely(!pipe))
-                               pipe = __cvmx_usb_find_ready_pipe(usb,
+                               pipe = cvmx_usb_find_ready_pipe(usb,
                                                usb->active_pipes +
                                                CVMX_USB_TRANSFER_INTERRUPT,
                                                usb->frame_number);
                }
                if (likely(!pipe)) {
-                       pipe = __cvmx_usb_find_ready_pipe(usb,
+                       pipe = cvmx_usb_find_ready_pipe(usb,
                                        usb->active_pipes +
                                        CVMX_USB_TRANSFER_CONTROL,
                                        usb->frame_number);
                        if (likely(!pipe))
-                               pipe = __cvmx_usb_find_ready_pipe(usb,
+                               pipe = cvmx_usb_find_ready_pipe(usb,
                                                usb->active_pipes +
                                                CVMX_USB_TRANSFER_BULK,
                                                usb->frame_number);
@@ -2103,7 +1958,7 @@ static void __cvmx_usb_schedule(struct cvmx_usb_state *usb, int is_sof)
                if (!pipe)
                        break;
 
-               __cvmx_usb_start_channel(usb, channel, pipe);
+               cvmx_usb_start_channel(usb, channel, pipe);
        }
 
 done:
@@ -2122,7 +1977,7 @@ done:
                }
        }
        USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index),
-                       union cvmx_usbcx_gintmsk, sofmsk, need_sof);
+                       cvmx_usbcx_gintmsk, sofmsk, need_sof);
 }
 
 static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb,
@@ -2226,11 +2081,10 @@ static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb,
  * @complete_code:
  *              Completion code
  */
-static void __cvmx_usb_perform_complete(
-                               struct cvmx_usb_state *usb,
-                               struct cvmx_usb_pipe *pipe,
-                               struct cvmx_usb_transaction *transaction,
-                               enum cvmx_usb_complete complete_code)
+static void cvmx_usb_perform_complete(struct cvmx_usb_state *usb,
+                                     struct cvmx_usb_pipe *pipe,
+                                     struct cvmx_usb_transaction *transaction,
+                                     enum cvmx_usb_complete complete_code)
 {
        /* If this was a split then clear our split in progress marker */
        if (usb->active_split == transaction)
@@ -2296,7 +2150,7 @@ static void __cvmx_usb_perform_complete(
  *
  * Returns: Transaction or NULL on failure.
  */
-static struct cvmx_usb_transaction *__cvmx_usb_submit_transaction(
+static struct cvmx_usb_transaction *cvmx_usb_submit_transaction(
                                struct cvmx_usb_state *usb,
                                struct cvmx_usb_pipe *pipe,
                                enum cvmx_usb_transfer type,
@@ -2342,7 +2196,7 @@ static struct cvmx_usb_transaction *__cvmx_usb_submit_transaction(
                 * We may need to schedule the pipe if this was the head of the
                 * pipe.
                 */
-               __cvmx_usb_schedule(usb, 0);
+               cvmx_usb_schedule(usb, 0);
        }
 
        return transaction;
@@ -2363,14 +2217,14 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_bulk(
                                                struct cvmx_usb_pipe *pipe,
                                                struct urb *urb)
 {
-       return __cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_BULK,
-                                            urb->transfer_dma,
-                                            urb->transfer_buffer_length,
-                                            0, /* control_header */
-                                            0, /* iso_start_frame */
-                                            0, /* iso_number_packets */
-                                            NULL, /* iso_packets */
-                                            urb);
+       return cvmx_usb_submit_transaction(usb, pipe, CVMX_USB_TRANSFER_BULK,
+                                          urb->transfer_dma,
+                                          urb->transfer_buffer_length,
+                                          0, /* control_header */
+                                          0, /* iso_start_frame */
+                                          0, /* iso_number_packets */
+                                          NULL, /* iso_packets */
+                                          urb);
 }
 
 
@@ -2388,15 +2242,15 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_interrupt(
                                                struct cvmx_usb_pipe *pipe,
                                                struct urb *urb)
 {
-       return __cvmx_usb_submit_transaction(usb, pipe,
-                                            CVMX_USB_TRANSFER_INTERRUPT,
-                                            urb->transfer_dma,
-                                            urb->transfer_buffer_length,
-                                            0, /* control_header */
-                                            0, /* iso_start_frame */
-                                            0, /* iso_number_packets */
-                                            NULL, /* iso_packets */
-                                            urb);
+       return cvmx_usb_submit_transaction(usb, pipe,
+                                          CVMX_USB_TRANSFER_INTERRUPT,
+                                          urb->transfer_dma,
+                                          urb->transfer_buffer_length,
+                                          0, /* control_header */
+                                          0, /* iso_start_frame */
+                                          0, /* iso_number_packets */
+                                          NULL, /* iso_packets */
+                                          urb);
 }
 
 
@@ -2421,14 +2275,14 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_control(
        if ((header->bRequestType & USB_DIR_IN) == 0)
                buffer_length = le16_to_cpu(header->wLength);
 
-       return __cvmx_usb_submit_transaction(usb, pipe,
-                                            CVMX_USB_TRANSFER_CONTROL,
-                                            urb->transfer_dma, buffer_length,
-                                            control_header,
-                                            0, /* iso_start_frame */
-                                            0, /* iso_number_packets */
-                                            NULL, /* iso_packets */
-                                            urb);
+       return cvmx_usb_submit_transaction(usb, pipe,
+                                          CVMX_USB_TRANSFER_CONTROL,
+                                          urb->transfer_dma, buffer_length,
+                                          control_header,
+                                          0, /* iso_start_frame */
+                                          0, /* iso_number_packets */
+                                          NULL, /* iso_packets */
+                                          urb);
 }
 
 
@@ -2449,14 +2303,14 @@ static struct cvmx_usb_transaction *cvmx_usb_submit_isochronous(
        struct cvmx_usb_iso_packet *packets;
 
        packets = (struct cvmx_usb_iso_packet *) urb->setup_packet;
-       return __cvmx_usb_submit_transaction(usb, pipe,
-                                            CVMX_USB_TRANSFER_ISOCHRONOUS,
-                                            urb->transfer_dma,
-                                            urb->transfer_buffer_length,
-                                            0, /* control_header */
-                                            urb->start_frame,
-                                            urb->number_of_packets,
-                                            packets, urb);
+       return cvmx_usb_submit_transaction(usb, pipe,
+                                          CVMX_USB_TRANSFER_ISOCHRONOUS,
+                                          urb->transfer_dma,
+                                          urb->transfer_buffer_length,
+                                          0, /* control_header */
+                                          urb->start_frame,
+                                          urb->number_of_packets,
+                                          packets, urb);
 }
 
 
@@ -2482,15 +2336,15 @@ static int cvmx_usb_cancel(struct cvmx_usb_state *usb,
         * treat it special
         */
        if (list_first_entry(&pipe->transactions, typeof(*transaction), node) ==
-           transaction && (pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED)) {
+           transaction && (pipe->flags & CVMX_USB_PIPE_FLAGS_SCHEDULED)) {
                union cvmx_usbcx_hccharx usbc_hcchar;
 
                usb->pipe_for_channel[pipe->channel] = NULL;
-               pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED;
+               pipe->flags &= ~CVMX_USB_PIPE_FLAGS_SCHEDULED;
 
                CVMX_SYNCW;
 
-               usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb,
+               usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
                                CVMX_USBCX_HCCHARX(pipe->channel, usb->index));
                /*
                 * If the channel isn't enabled then the transaction already
@@ -2498,14 +2352,14 @@ static int cvmx_usb_cancel(struct cvmx_usb_state *usb,
                 */
                if (usbc_hcchar.s.chena) {
                        usbc_hcchar.s.chdis = 1;
-                       __cvmx_usb_write_csr32(usb,
+                       cvmx_usb_write_csr32(usb,
                                        CVMX_USBCX_HCCHARX(pipe->channel,
                                                usb->index),
                                        usbc_hcchar.u32);
                }
        }
-       __cvmx_usb_perform_complete(usb, pipe, transaction,
-                                   CVMX_USB_COMPLETE_CANCEL);
+       cvmx_usb_perform_complete(usb, pipe, transaction,
+                                 CVMX_USB_COMPLETE_CANCEL);
        return 0;
 }
 
@@ -2570,8 +2424,7 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb)
        int frame_number;
        union cvmx_usbcx_hfnum usbc_hfnum;
 
-       usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HFNUM(usb->index));
+       usbc_hfnum.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index));
        frame_number = usbc_hfnum.s.frnum;
 
        return frame_number;
@@ -2586,7 +2439,7 @@ static int cvmx_usb_get_frame_number(struct cvmx_usb_state *usb)
  *
  * Returns: Zero on success
  */
-static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
+static int cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
 {
        struct octeon_hcd *priv = cvmx_usb_to_octeon(usb);
        struct usb_hcd *hcd = octeon_to_hcd(priv);
@@ -2602,11 +2455,11 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
        int buffer_space_left;
 
        /* Read the interrupt status bits for the channel */
-       usbc_hcint.u32 = __cvmx_usb_read_csr32(usb,
-                       CVMX_USBCX_HCINTX(channel, usb->index));
+       usbc_hcint.u32 = cvmx_usb_read_csr32(usb,
+                               CVMX_USBCX_HCINTX(channel, usb->index));
 
        if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) {
-               usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb,
+               usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
                                CVMX_USBCX_HCCHARX(channel, usb->index));
 
                if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) {
@@ -2615,7 +2468,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                         * interrupt IN transfers to get stuck until we do a
                         * write of HCCHARX without changing things
                         */
-                       __cvmx_usb_write_csr32(usb,
+                       cvmx_usb_write_csr32(usb,
                                        CVMX_USBCX_HCCHARX(channel,
                                                           usb->index),
                                        usbc_hcchar.u32);
@@ -2632,12 +2485,12 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                /* Disable all interrupts except CHHLTD */
                                hcintmsk.u32 = 0;
                                hcintmsk.s.chhltdmsk = 1;
-                               __cvmx_usb_write_csr32(usb,
+                               cvmx_usb_write_csr32(usb,
                                                CVMX_USBCX_HCINTMSKX(channel,
                                                        usb->index),
                                                hcintmsk.u32);
                                usbc_hcchar.s.chdis = 1;
-                               __cvmx_usb_write_csr32(usb,
+                               cvmx_usb_write_csr32(usb,
                                                CVMX_USBCX_HCCHARX(channel,
                                                        usb->index),
                                                usbc_hcchar.u32);
@@ -2663,9 +2516,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
        }
 
        /* Disable the channel interrupts now that it is done */
-       __cvmx_usb_write_csr32(usb,
-                               CVMX_USBCX_HCINTMSKX(channel, usb->index),
-                               0);
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0);
        usb->idle_hardware_channels |= (1<<channel);
 
        /* Make sure this channel is tied to a valid pipe */
@@ -2683,15 +2534,15 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
         * function will figure out which pipe needs to go
         */
        usb->pipe_for_channel[channel] = NULL;
-       pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED;
+       pipe->flags &= ~CVMX_USB_PIPE_FLAGS_SCHEDULED;
 
        /*
         * Read the channel config info so we can figure out how much data
         * transferred
         */
-       usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb,
+       usbc_hcchar.u32 = cvmx_usb_read_csr32(usb,
                        CVMX_USBCX_HCCHARX(channel, usb->index));
-       usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb,
+       usbc_hctsiz.u32 = cvmx_usb_read_csr32(usb,
                        CVMX_USBCX_HCTSIZX(channel, usb->index));
 
        /*
@@ -2766,7 +2617,18 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
        if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) &&
                (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) &&
                (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT))
-               pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING;
+               pipe->flags |= CVMX_USB_PIPE_FLAGS_NEED_PING;
+
+       if (unlikely(WARN_ON_ONCE(bytes_this_transfer < 0))) {
+               /*
+                * In some rare cases the DMA engine seems to get stuck and
+                * keeps substracting same byte count over and over again. In
+                * such case we just need to fail every transaction.
+                */
+               cvmx_usb_perform_complete(usb, pipe, transaction,
+                                         CVMX_USB_COMPLETE_ERROR);
+               return 0;
+       }
 
        if (usbc_hcint.s.stall) {
                /*
@@ -2776,52 +2638,24 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                 * the actual bytes transferred
                 */
                pipe->pid_toggle = 0;
-               __cvmx_usb_perform_complete(usb, pipe, transaction,
-                                           CVMX_USB_COMPLETE_STALL);
+               cvmx_usb_perform_complete(usb, pipe, transaction,
+                                         CVMX_USB_COMPLETE_STALL);
        } else if (usbc_hcint.s.xacterr) {
                /*
-                * We know at least one packet worked if we get a ACK or NAK.
-                * Reset the retry counter
+                * XactErr as a response means the device signaled
+                * something wrong with the transfer. For example, PID
+                * toggle errors cause these.
                 */
-               if (usbc_hcint.s.nak || usbc_hcint.s.ack)
-                       transaction->retries = 0;
-               transaction->retries++;
-               if (transaction->retries > MAX_RETRIES) {
-                       /*
-                        * XactErr as a response means the device signaled
-                        * something wrong with the transfer. For example, PID
-                        * toggle errors cause these
-                        */
-                       __cvmx_usb_perform_complete(usb, pipe, transaction,
-                                                   CVMX_USB_COMPLETE_XACTERR);
-               } else {
-                       /*
-                        * If this was a split then clear our split in progress
-                        * marker
-                        */
-                       if (usb->active_split == transaction)
-                               usb->active_split = NULL;
-                       /*
-                        * Rewind to the beginning of the transaction by anding
-                        * off the split complete bit
-                        */
-                       transaction->stage &= ~1;
-                       pipe->split_sc_frame = -1;
-                       pipe->next_tx_frame += pipe->interval;
-                       if (pipe->next_tx_frame < usb->frame_number)
-                               pipe->next_tx_frame =
-                                       usb->frame_number + pipe->interval -
-                                       (usb->frame_number -
-                                        pipe->next_tx_frame) % pipe->interval;
-               }
+               cvmx_usb_perform_complete(usb, pipe, transaction,
+                                         CVMX_USB_COMPLETE_XACTERR);
        } else if (usbc_hcint.s.bblerr) {
                /* Babble Error (BblErr) */
-               __cvmx_usb_perform_complete(usb, pipe, transaction,
-                                           CVMX_USB_COMPLETE_BABBLEERR);
+               cvmx_usb_perform_complete(usb, pipe, transaction,
+                                         CVMX_USB_COMPLETE_BABBLEERR);
        } else if (usbc_hcint.s.datatglerr) {
                /* Data toggle error */
-               __cvmx_usb_perform_complete(usb, pipe, transaction,
-                                           CVMX_USB_COMPLETE_DATATGLERR);
+               cvmx_usb_perform_complete(usb, pipe, transaction,
+                                         CVMX_USB_COMPLETE_DATATGLERR);
        } else if (usbc_hcint.s.nyet) {
                /*
                 * NYET as a response is only allowed in three cases: as a
@@ -2829,7 +2663,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                 * as a response to a bulk out. The ping case is handled by
                 * hardware, so we only have splits and bulk out
                 */
-               if (!__cvmx_usb_pipe_needs_split(usb, pipe)) {
+               if (!cvmx_usb_pipe_needs_split(usb, pipe)) {
                        transaction->retries = 0;
                        /*
                         * If there is more data to go then we need to try
@@ -2837,7 +2671,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                         */
                        if ((buffer_space_left == 0) ||
                                (bytes_in_last_packet < pipe->max_packet))
-                               __cvmx_usb_perform_complete(usb, pipe,
+                               cvmx_usb_perform_complete(usb, pipe,
                                                transaction,
                                                CVMX_USB_COMPLETE_SUCCESS);
                } else {
@@ -2869,7 +2703,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                 * Since we got an ACK, we know we don't need to do a ping on
                 * this pipe
                 */
-               pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING;
+               pipe->flags &= ~CVMX_USB_PIPE_FLAGS_NEED_PING;
 
                switch (transaction->type) {
                case CVMX_USB_TRANSFER_CONTROL:
@@ -2877,12 +2711,12 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                        case CVMX_USB_STAGE_NON_CONTROL:
                        case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE:
                                /* This should be impossible */
-                               __cvmx_usb_perform_complete(usb, pipe,
+                               cvmx_usb_perform_complete(usb, pipe,
                                        transaction, CVMX_USB_COMPLETE_ERROR);
                                break;
                        case CVMX_USB_STAGE_SETUP:
                                pipe->pid_toggle = 1;
-                               if (__cvmx_usb_pipe_needs_split(usb, pipe))
+                               if (cvmx_usb_pipe_needs_split(usb, pipe))
                                        transaction->stage =
                                                CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE;
                                else {
@@ -2909,7 +2743,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                }
                                break;
                        case CVMX_USB_STAGE_DATA:
-                               if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+                               if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                                        transaction->stage =
                                                CVMX_USB_STAGE_DATA_SPLIT_COMPLETE;
                                        /*
@@ -2947,16 +2781,16 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                }
                                break;
                        case CVMX_USB_STAGE_STATUS:
-                               if (__cvmx_usb_pipe_needs_split(usb, pipe))
+                               if (cvmx_usb_pipe_needs_split(usb, pipe))
                                        transaction->stage =
                                                CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE;
                                else
-                                       __cvmx_usb_perform_complete(usb, pipe,
+                                       cvmx_usb_perform_complete(usb, pipe,
                                                transaction,
                                                CVMX_USB_COMPLETE_SUCCESS);
                                break;
                        case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE:
-                               __cvmx_usb_perform_complete(usb, pipe,
+                               cvmx_usb_perform_complete(usb, pipe,
                                                transaction,
                                                CVMX_USB_COMPLETE_SUCCESS);
                                break;
@@ -2970,7 +2804,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                         * For splits we need to continue the transfer if more
                         * data is needed
                         */
-                       if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+                       if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                                if (transaction->stage ==
                                                CVMX_USB_STAGE_NON_CONTROL)
                                        transaction->stage =
@@ -2986,7 +2820,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                                        CVMX_USB_TRANSFER_INTERRUPT)
                                                        pipe->next_tx_frame +=
                                                                pipe->interval;
-                                                       __cvmx_usb_perform_complete(
+                                                       cvmx_usb_perform_complete(
                                                                usb,
                                                                pipe,
                                                                transaction,
@@ -3002,7 +2836,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                     CVMX_USB_DIRECTION_OUT) &&
                                    (usbc_hcint.s.nak))
                                        pipe->flags |=
-                                               __CVMX_USB_PIPE_FLAGS_NEED_PING;
+                                               CVMX_USB_PIPE_FLAGS_NEED_PING;
                                if (!buffer_space_left ||
                                        (bytes_in_last_packet <
                                         pipe->max_packet)) {
@@ -3010,15 +2844,14 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                                CVMX_USB_TRANSFER_INTERRUPT)
                                                pipe->next_tx_frame +=
                                                        pipe->interval;
-                                       __cvmx_usb_perform_complete(usb,
-                                               pipe,
+                                       cvmx_usb_perform_complete(usb, pipe,
                                                transaction,
                                                CVMX_USB_COMPLETE_SUCCESS);
                                }
                        }
                        break;
                case CVMX_USB_TRANSFER_ISOCHRONOUS:
-                       if (__cvmx_usb_pipe_needs_split(usb, pipe)) {
+                       if (cvmx_usb_pipe_needs_split(usb, pipe)) {
                                /*
                                 * ISOCHRONOUS OUT splits don't require a
                                 * complete split stage. Instead they use a
@@ -3039,10 +2872,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                                (bytes_this_transfer < 188)) {
                                                pipe->next_tx_frame +=
                                                        pipe->interval;
-                                               __cvmx_usb_perform_complete(
-                                                       usb,
-                                                       pipe,
-                                                       transaction,
+                                               cvmx_usb_perform_complete(usb,
+                                                       pipe, transaction,
                                                        CVMX_USB_COMPLETE_SUCCESS);
                                        }
                                } else {
@@ -3059,7 +2890,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                                         pipe->max_packet)) {
                                                        pipe->next_tx_frame +=
                                                                pipe->interval;
-                                                       __cvmx_usb_perform_complete(
+                                                       cvmx_usb_perform_complete(
                                                                usb,
                                                                pipe,
                                                                transaction,
@@ -3071,8 +2902,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                                }
                        } else {
                                pipe->next_tx_frame += pipe->interval;
-                               __cvmx_usb_perform_complete(usb,
-                                               pipe,
+                               cvmx_usb_perform_complete(usb, pipe,
                                                transaction,
                                                CVMX_USB_COMPLETE_SUCCESS);
                        }
@@ -3110,7 +2940,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_state *usb, int channel)
                         * We get channel halted interrupts with no result bits
                         * sets when the cable is unplugged
                         */
-                       __cvmx_usb_perform_complete(usb, pipe, transaction,
+                       cvmx_usb_perform_complete(usb, pipe, transaction,
                                        CVMX_USB_COMPLETE_ERROR);
                }
        }
@@ -3144,21 +2974,19 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb)
        prefetch_range(usb, sizeof(*usb));
 
        /* Update the frame counter */
-       usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb,
-                                               CVMX_USBCX_HFNUM(usb->index));
+       usbc_hfnum.u32 = cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index));
        if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum)
                usb->frame_number += 0x4000;
        usb->frame_number &= ~0x3fffull;
        usb->frame_number |= usbc_hfnum.s.frnum;
 
        /* Read the pending interrupts */
-       usbc_gintsts.u32 = __cvmx_usb_read_csr32(usb,
-                                               CVMX_USBCX_GINTSTS(usb->index));
+       usbc_gintsts.u32 = cvmx_usb_read_csr32(usb,
+                                              CVMX_USBCX_GINTSTS(usb->index));
 
        /* Clear the interrupts now that we know about them */
-       __cvmx_usb_write_csr32(usb,
-                               CVMX_USBCX_GINTSTS(usb->index),
-                               usbc_gintsts.u32);
+       cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index),
+                            usbc_gintsts.u32);
 
        if (usbc_gintsts.s.rxflvl) {
                /*
@@ -3169,12 +2997,12 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb)
                 * In DMA mode this is handled by hardware
                 */
                if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
-                       __cvmx_usb_poll_rx_fifo(usb);
+                       cvmx_usb_poll_rx_fifo(usb);
        }
        if (usbc_gintsts.s.ptxfemp || usbc_gintsts.s.nptxfemp) {
                /* Fill the Tx FIFOs when not in DMA mode */
                if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)
-                       __cvmx_usb_poll_tx_fifo(usb);
+                       cvmx_usb_poll_tx_fifo(usb);
        }
        if (usbc_gintsts.s.disconnint || usbc_gintsts.s.prtint) {
                union cvmx_usbcx_hprt usbc_hprt;
@@ -3194,11 +3022,11 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb)
                 */
                octeon_usb_port_callback(usb);
                /* Clear the port change bits */
-               usbc_hprt.u32 = __cvmx_usb_read_csr32(usb,
-                               CVMX_USBCX_HPRT(usb->index));
+               usbc_hprt.u32 = cvmx_usb_read_csr32(usb,
+                                       CVMX_USBCX_HPRT(usb->index));
                usbc_hprt.s.prtena = 0;
-               __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index),
-                                      usbc_hprt.u32);
+               cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index),
+                                    usbc_hprt.u32);
        }
        if (usbc_gintsts.s.hchint) {
                /*
@@ -3215,18 +3043,18 @@ static int cvmx_usb_poll(struct cvmx_usb_state *usb)
                 */
                union cvmx_usbcx_haint usbc_haint;
 
-               usbc_haint.u32 = __cvmx_usb_read_csr32(usb,
+               usbc_haint.u32 = cvmx_usb_read_csr32(usb,
                                        CVMX_USBCX_HAINT(usb->index));
                while (usbc_haint.u32) {
                        int channel;
 
                        channel = __fls(usbc_haint.u32);
-                       __cvmx_usb_poll_channel(usb, channel);
+                       cvmx_usb_poll_channel(usb, channel);
                        usbc_haint.u32 ^= 1<<channel;
                }
        }
 
-       __cvmx_usb_schedule(usb, usbc_gintsts.s.sof);
+       cvmx_usb_schedule(usb, usbc_gintsts.s.sof);
 
        return 0;
 }
@@ -3510,6 +3338,7 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        struct octeon_hcd *priv = hcd_to_octeon(hcd);
        struct device *dev = hcd->self.controller;
        struct cvmx_usb_port_status usb_port_status;
+       struct cvmx_usb_state *usb = &priv->usb;
        int port_status;
        struct usb_hub_descriptor *desc;
        unsigned long flags;
@@ -3687,13 +3516,18 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        return -EINVAL;
                case USB_PORT_FEAT_POWER:
                        dev_dbg(dev, " POWER\n");
-                       return -EINVAL;
+                       /*
+                        * Program the port power bit to drive VBUS on the USB.
+                        */
+                       spin_lock_irqsave(&priv->lock, flags);
+                       USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index),
+                                       cvmx_usbcx_hprt, prtpwr, 1);
+                       spin_unlock_irqrestore(&priv->lock, flags);
+                       return 0;
                case USB_PORT_FEAT_RESET:
                        dev_dbg(dev, " RESET\n");
                        spin_lock_irqsave(&priv->lock, flags);
-                       cvmx_usb_disable(&priv->usb);
-                       if (cvmx_usb_enable(&priv->usb))
-                               dev_dbg(dev, "Failed to enable the port\n");
+                       cvmx_usb_reset_port(&priv->usb);
                        spin_unlock_irqrestore(&priv->lock, flags);
                        return 0;
                case USB_PORT_FEAT_INDICATOR:
@@ -3741,7 +3575,6 @@ static int octeon_usb_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct octeon_hcd *priv;
        struct usb_hcd *hcd;
-       unsigned long flags;
        u32 clock_rate = 48000000;
        bool is_crystal_clock = false;
        const char *clock_type;
@@ -3838,20 +3671,33 @@ static int octeon_usb_probe(struct platform_device *pdev)
 
        spin_lock_init(&priv->lock);
 
-       status = cvmx_usb_initialize(&priv->usb, usb_num, initialize_flags);
+       priv->usb.init_flags = initialize_flags;
+
+       /* Initialize the USB state structure */
+       priv->usb.index = usb_num;
+       INIT_LIST_HEAD(&priv->usb.idle_pipes);
+       for (i = 0; i < ARRAY_SIZE(priv->usb.active_pipes); i++)
+               INIT_LIST_HEAD(&priv->usb.active_pipes[i]);
+
+       /* Due to an errata, CN31XX doesn't support DMA */
+       if (OCTEON_IS_MODEL(OCTEON_CN31XX)) {
+               priv->usb.init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA;
+               /* Only use one channel with non DMA */
+               priv->usb.idle_hardware_channels = 0x1;
+       } else if (OCTEON_IS_MODEL(OCTEON_CN5XXX)) {
+               /* CN5XXX have an errata with channel 3 */
+               priv->usb.idle_hardware_channels = 0xf7;
+       } else {
+               priv->usb.idle_hardware_channels = 0xff;
+       }
+
+       status = cvmx_usb_initialize(dev, &priv->usb);
        if (status) {
                dev_dbg(dev, "USB initialization failed with %d\n", status);
                kfree(hcd);
                return -1;
        }
 
-       /* This delay is needed for CN3010, but I don't know why... */
-       mdelay(10);
-
-       spin_lock_irqsave(&priv->lock, flags);
-       cvmx_usb_poll(&priv->usb);
-       spin_unlock_irqrestore(&priv->lock, flags);
-
        status = usb_add_hcd(hcd, irq, 0);
        if (status) {
                dev_dbg(dev, "USB add HCD failed with %d\n", status);
@@ -3885,7 +3731,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 42fe4fec7d5d842e697283d86a97289a63513605..3e351ab7465acef075cf0861debc952ef4897371 100644 (file)
@@ -47,6 +47,8 @@
 #ifndef __OCTEON_HCD_H__
 #define __OCTEON_HCD_H__
 
+#include <asm/bitfield.h>
+
 #define CVMX_USBCXBASE 0x00016F0010000000ull
 #define CVMX_USBCXREG1(reg, bid) \
        (CVMX_ADD_IO_SEG(CVMX_USBCXBASE | reg) + \
@@ -143,13 +145,14 @@ union cvmx_usbcx_gahbcfg {
         *      * 1'b1: Unmask the interrupt assertion to the application.
         */
        struct cvmx_usbcx_gahbcfg_s {
-               uint32_t reserved_9_31  : 23;
-               uint32_t ptxfemplvl     : 1;
-               uint32_t nptxfemplvl    : 1;
-               uint32_t reserved_6_6   : 1;
-               uint32_t dmaen          : 1;
-               uint32_t hbstlen        : 4;
-               uint32_t glblintrmsk    : 1;
+               __BITFIELD_FIELD(uint32_t reserved_9_31 : 23,
+               __BITFIELD_FIELD(uint32_t ptxfemplvl    : 1,
+               __BITFIELD_FIELD(uint32_t nptxfemplvl   : 1,
+               __BITFIELD_FIELD(uint32_t reserved_6_6  : 1,
+               __BITFIELD_FIELD(uint32_t dmaen         : 1,
+               __BITFIELD_FIELD(uint32_t hbstlen       : 4,
+               __BITFIELD_FIELD(uint32_t glblintrmsk   : 1,
+               ;)))))))
        } s;
 };
 
@@ -209,16 +212,17 @@ union cvmx_usbcx_ghwcfg3 {
         *      * Others: Reserved
         */
        struct cvmx_usbcx_ghwcfg3_s {
-               uint32_t dfifodepth                             : 16;
-               uint32_t reserved_13_15                         : 3;
-               uint32_t ahbphysync                             : 1;
-               uint32_t rsttype                                : 1;
-               uint32_t optfeature                             : 1;
-               uint32_t vendor_control_interface_support       : 1;
-               uint32_t i2c_selection                          : 1;
-               uint32_t otgen                                  : 1;
-               uint32_t pktsizewidth                           : 3;
-               uint32_t xfersizewidth                          : 4;
+               __BITFIELD_FIELD(uint32_t dfifodepth                    : 16,
+               __BITFIELD_FIELD(uint32_t reserved_13_15                : 3,
+               __BITFIELD_FIELD(uint32_t ahbphysync                    : 1,
+               __BITFIELD_FIELD(uint32_t rsttype                       : 1,
+               __BITFIELD_FIELD(uint32_t optfeature                    : 1,
+               __BITFIELD_FIELD(uint32_t vendor_control_interface_support : 1,
+               __BITFIELD_FIELD(uint32_t i2c_selection                 : 1,
+               __BITFIELD_FIELD(uint32_t otgen                         : 1,
+               __BITFIELD_FIELD(uint32_t pktsizewidth                  : 3,
+               __BITFIELD_FIELD(uint32_t xfersizewidth                 : 4,
+               ;))))))))))
        } s;
 };
 
@@ -275,38 +279,39 @@ union cvmx_usbcx_gintmsk {
         * @modemismsk: Mode Mismatch Interrupt Mask (ModeMisMsk)
         */
        struct cvmx_usbcx_gintmsk_s {
-               uint32_t wkupintmsk             : 1;
-               uint32_t sessreqintmsk          : 1;
-               uint32_t disconnintmsk          : 1;
-               uint32_t conidstschngmsk        : 1;
-               uint32_t reserved_27_27         : 1;
-               uint32_t ptxfempmsk             : 1;
-               uint32_t hchintmsk              : 1;
-               uint32_t prtintmsk              : 1;
-               uint32_t reserved_23_23         : 1;
-               uint32_t fetsuspmsk             : 1;
-               uint32_t incomplpmsk            : 1;
-               uint32_t incompisoinmsk         : 1;
-               uint32_t oepintmsk              : 1;
-               uint32_t inepintmsk             : 1;
-               uint32_t epmismsk               : 1;
-               uint32_t reserved_16_16         : 1;
-               uint32_t eopfmsk                : 1;
-               uint32_t isooutdropmsk          : 1;
-               uint32_t enumdonemsk            : 1;
-               uint32_t usbrstmsk              : 1;
-               uint32_t usbsuspmsk             : 1;
-               uint32_t erlysuspmsk            : 1;
-               uint32_t i2cint                 : 1;
-               uint32_t ulpickintmsk           : 1;
-               uint32_t goutnakeffmsk          : 1;
-               uint32_t ginnakeffmsk           : 1;
-               uint32_t nptxfempmsk            : 1;
-               uint32_t rxflvlmsk              : 1;
-               uint32_t sofmsk                 : 1;
-               uint32_t otgintmsk              : 1;
-               uint32_t modemismsk             : 1;
-               uint32_t reserved_0_0           : 1;
+               __BITFIELD_FIELD(uint32_t wkupintmsk            : 1,
+               __BITFIELD_FIELD(uint32_t sessreqintmsk         : 1,
+               __BITFIELD_FIELD(uint32_t disconnintmsk         : 1,
+               __BITFIELD_FIELD(uint32_t conidstschngmsk       : 1,
+               __BITFIELD_FIELD(uint32_t reserved_27_27        : 1,
+               __BITFIELD_FIELD(uint32_t ptxfempmsk            : 1,
+               __BITFIELD_FIELD(uint32_t hchintmsk             : 1,
+               __BITFIELD_FIELD(uint32_t prtintmsk             : 1,
+               __BITFIELD_FIELD(uint32_t reserved_23_23        : 1,
+               __BITFIELD_FIELD(uint32_t fetsuspmsk            : 1,
+               __BITFIELD_FIELD(uint32_t incomplpmsk           : 1,
+               __BITFIELD_FIELD(uint32_t incompisoinmsk        : 1,
+               __BITFIELD_FIELD(uint32_t oepintmsk             : 1,
+               __BITFIELD_FIELD(uint32_t inepintmsk            : 1,
+               __BITFIELD_FIELD(uint32_t epmismsk              : 1,
+               __BITFIELD_FIELD(uint32_t reserved_16_16        : 1,
+               __BITFIELD_FIELD(uint32_t eopfmsk               : 1,
+               __BITFIELD_FIELD(uint32_t isooutdropmsk         : 1,
+               __BITFIELD_FIELD(uint32_t enumdonemsk           : 1,
+               __BITFIELD_FIELD(uint32_t usbrstmsk             : 1,
+               __BITFIELD_FIELD(uint32_t usbsuspmsk            : 1,
+               __BITFIELD_FIELD(uint32_t erlysuspmsk           : 1,
+               __BITFIELD_FIELD(uint32_t i2cint                : 1,
+               __BITFIELD_FIELD(uint32_t ulpickintmsk          : 1,
+               __BITFIELD_FIELD(uint32_t goutnakeffmsk         : 1,
+               __BITFIELD_FIELD(uint32_t ginnakeffmsk          : 1,
+               __BITFIELD_FIELD(uint32_t nptxfempmsk           : 1,
+               __BITFIELD_FIELD(uint32_t rxflvlmsk             : 1,
+               __BITFIELD_FIELD(uint32_t sofmsk                : 1,
+               __BITFIELD_FIELD(uint32_t otgintmsk             : 1,
+               __BITFIELD_FIELD(uint32_t modemismsk            : 1,
+               __BITFIELD_FIELD(uint32_t reserved_0_0          : 1,
+               ;))))))))))))))))))))))))))))))))
        } s;
 };
 
@@ -504,38 +509,39 @@ union cvmx_usbcx_gintsts {
         *      * 1'b1: Host mode
         */
        struct cvmx_usbcx_gintsts_s {
-               uint32_t wkupint        : 1;
-               uint32_t sessreqint     : 1;
-               uint32_t disconnint     : 1;
-               uint32_t conidstschng   : 1;
-               uint32_t reserved_27_27 : 1;
-               uint32_t ptxfemp        : 1;
-               uint32_t hchint         : 1;
-               uint32_t prtint         : 1;
-               uint32_t reserved_23_23 : 1;
-               uint32_t fetsusp        : 1;
-               uint32_t incomplp       : 1;
-               uint32_t incompisoin    : 1;
-               uint32_t oepint         : 1;
-               uint32_t iepint         : 1;
-               uint32_t epmis          : 1;
-               uint32_t reserved_16_16 : 1;
-               uint32_t eopf           : 1;
-               uint32_t isooutdrop     : 1;
-               uint32_t enumdone       : 1;
-               uint32_t usbrst         : 1;
-               uint32_t usbsusp        : 1;
-               uint32_t erlysusp       : 1;
-               uint32_t i2cint         : 1;
-               uint32_t ulpickint      : 1;
-               uint32_t goutnakeff     : 1;
-               uint32_t ginnakeff      : 1;
-               uint32_t nptxfemp       : 1;
-               uint32_t rxflvl         : 1;
-               uint32_t sof            : 1;
-               uint32_t otgint         : 1;
-               uint32_t modemis        : 1;
-               uint32_t curmod         : 1;
+               __BITFIELD_FIELD(uint32_t wkupint               : 1,
+               __BITFIELD_FIELD(uint32_t sessreqint            : 1,
+               __BITFIELD_FIELD(uint32_t disconnint            : 1,
+               __BITFIELD_FIELD(uint32_t conidstschng          : 1,
+               __BITFIELD_FIELD(uint32_t reserved_27_27        : 1,
+               __BITFIELD_FIELD(uint32_t ptxfemp               : 1,
+               __BITFIELD_FIELD(uint32_t hchint                : 1,
+               __BITFIELD_FIELD(uint32_t prtint                : 1,
+               __BITFIELD_FIELD(uint32_t reserved_23_23        : 1,
+               __BITFIELD_FIELD(uint32_t fetsusp               : 1,
+               __BITFIELD_FIELD(uint32_t incomplp              : 1,
+               __BITFIELD_FIELD(uint32_t incompisoin           : 1,
+               __BITFIELD_FIELD(uint32_t oepint                : 1,
+               __BITFIELD_FIELD(uint32_t iepint                : 1,
+               __BITFIELD_FIELD(uint32_t epmis                 : 1,
+               __BITFIELD_FIELD(uint32_t reserved_16_16        : 1,
+               __BITFIELD_FIELD(uint32_t eopf                  : 1,
+               __BITFIELD_FIELD(uint32_t isooutdrop            : 1,
+               __BITFIELD_FIELD(uint32_t enumdone              : 1,
+               __BITFIELD_FIELD(uint32_t usbrst                : 1,
+               __BITFIELD_FIELD(uint32_t usbsusp               : 1,
+               __BITFIELD_FIELD(uint32_t erlysusp              : 1,
+               __BITFIELD_FIELD(uint32_t i2cint                : 1,
+               __BITFIELD_FIELD(uint32_t ulpickint             : 1,
+               __BITFIELD_FIELD(uint32_t goutnakeff            : 1,
+               __BITFIELD_FIELD(uint32_t ginnakeff             : 1,
+               __BITFIELD_FIELD(uint32_t nptxfemp              : 1,
+               __BITFIELD_FIELD(uint32_t rxflvl                : 1,
+               __BITFIELD_FIELD(uint32_t sof                   : 1,
+               __BITFIELD_FIELD(uint32_t otgint                : 1,
+               __BITFIELD_FIELD(uint32_t modemis               : 1,
+               __BITFIELD_FIELD(uint32_t curmod                : 1,
+               ;))))))))))))))))))))))))))))))))
        } s;
 };
 
@@ -560,8 +566,9 @@ union cvmx_usbcx_gnptxfsiz {
         *      Transmit FIFO RAM.
         */
        struct cvmx_usbcx_gnptxfsiz_s {
-               uint32_t nptxfdep       : 16;
-               uint32_t nptxfstaddr    : 16;
+               __BITFIELD_FIELD(uint32_t nptxfdep      : 16,
+               __BITFIELD_FIELD(uint32_t nptxfstaddr   : 16,
+               ;))
        } s;
 };
 
@@ -610,10 +617,11 @@ union cvmx_usbcx_gnptxsts {
         *      * Others: Reserved
         */
        struct cvmx_usbcx_gnptxsts_s {
-               uint32_t reserved_31_31 : 1;
-               uint32_t nptxqtop       : 7;
-               uint32_t nptxqspcavail  : 8;
-               uint32_t nptxfspcavail  : 16;
+               __BITFIELD_FIELD(uint32_t reserved_31_31        : 1,
+               __BITFIELD_FIELD(uint32_t nptxqtop              : 7,
+               __BITFIELD_FIELD(uint32_t nptxqspcavail         : 8,
+               __BITFIELD_FIELD(uint32_t nptxfspcavail         : 16,
+               ;))))
        } s;
 };
 
@@ -731,16 +739,17 @@ union cvmx_usbcx_grstctl {
         *      selected, the PHY domain has to be reset for proper operation.
         */
        struct cvmx_usbcx_grstctl_s {
-               uint32_t ahbidle        : 1;
-               uint32_t dmareq         : 1;
-               uint32_t reserved_11_29 : 19;
-               uint32_t txfnum         : 5;
-               uint32_t txfflsh        : 1;
-               uint32_t rxfflsh        : 1;
-               uint32_t intknqflsh     : 1;
-               uint32_t frmcntrrst     : 1;
-               uint32_t hsftrst        : 1;
-               uint32_t csftrst        : 1;
+               __BITFIELD_FIELD(uint32_t ahbidle               : 1,
+               __BITFIELD_FIELD(uint32_t dmareq                : 1,
+               __BITFIELD_FIELD(uint32_t reserved_11_29        : 19,
+               __BITFIELD_FIELD(uint32_t txfnum                : 5,
+               __BITFIELD_FIELD(uint32_t txfflsh               : 1,
+               __BITFIELD_FIELD(uint32_t rxfflsh               : 1,
+               __BITFIELD_FIELD(uint32_t intknqflsh            : 1,
+               __BITFIELD_FIELD(uint32_t frmcntrrst            : 1,
+               __BITFIELD_FIELD(uint32_t hsftrst               : 1,
+               __BITFIELD_FIELD(uint32_t csftrst               : 1,
+               ;))))))))))
        } s;
 };
 
@@ -762,8 +771,9 @@ union cvmx_usbcx_grxfsiz {
         *      * Maximum value is 32768
         */
        struct cvmx_usbcx_grxfsiz_s {
-               uint32_t reserved_16_31 : 16;
-               uint32_t rxfdep         : 16;
+               __BITFIELD_FIELD(uint32_t reserved_16_31        : 16,
+               __BITFIELD_FIELD(uint32_t rxfdep                : 16,
+               ;))
        } s;
 };
 
@@ -804,11 +814,12 @@ union cvmx_usbcx_grxstsph {
         *      packet belongs.
         */
        struct cvmx_usbcx_grxstsph_s {
-               uint32_t reserved_21_31 : 11;
-               uint32_t pktsts         : 4;
-               uint32_t dpid           : 2;
-               uint32_t bcnt           : 11;
-               uint32_t chnum          : 4;
+               __BITFIELD_FIELD(uint32_t reserved_21_31        : 11,
+               __BITFIELD_FIELD(uint32_t pktsts                : 4,
+               __BITFIELD_FIELD(uint32_t dpid                  : 2,
+               __BITFIELD_FIELD(uint32_t bcnt                  : 11,
+               __BITFIELD_FIELD(uint32_t chnum                 : 4,
+               ;)))))
        } s;
 };
 
@@ -884,19 +895,20 @@ union cvmx_usbcx_gusbcfg {
         *      * One 48-MHz PHY clock = 0.25 bit times
         */
        struct cvmx_usbcx_gusbcfg_s {
-               uint32_t reserved_17_31 : 15;
-               uint32_t otgi2csel      : 1;
-               uint32_t phylpwrclksel  : 1;
-               uint32_t reserved_14_14 : 1;
-               uint32_t usbtrdtim      : 4;
-               uint32_t hnpcap         : 1;
-               uint32_t srpcap         : 1;
-               uint32_t ddrsel         : 1;
-               uint32_t physel         : 1;
-               uint32_t fsintf         : 1;
-               uint32_t ulpi_utmi_sel  : 1;
-               uint32_t phyif          : 1;
-               uint32_t toutcal        : 3;
+               __BITFIELD_FIELD(uint32_t reserved_17_31        : 15,
+               __BITFIELD_FIELD(uint32_t otgi2csel             : 1,
+               __BITFIELD_FIELD(uint32_t phylpwrclksel         : 1,
+               __BITFIELD_FIELD(uint32_t reserved_14_14        : 1,
+               __BITFIELD_FIELD(uint32_t usbtrdtim             : 4,
+               __BITFIELD_FIELD(uint32_t hnpcap                : 1,
+               __BITFIELD_FIELD(uint32_t srpcap                : 1,
+               __BITFIELD_FIELD(uint32_t ddrsel                : 1,
+               __BITFIELD_FIELD(uint32_t physel                : 1,
+               __BITFIELD_FIELD(uint32_t fsintf                : 1,
+               __BITFIELD_FIELD(uint32_t ulpi_utmi_sel         : 1,
+               __BITFIELD_FIELD(uint32_t phyif                 : 1,
+               __BITFIELD_FIELD(uint32_t toutcal               : 3,
+               ;)))))))))))))
        } s;
 };
 
@@ -920,8 +932,9 @@ union cvmx_usbcx_haint {
         *      One bit per channel: Bit 0 for Channel 0, bit 15 for Channel 15
         */
        struct cvmx_usbcx_haint_s {
-               uint32_t reserved_16_31 : 16;
-               uint32_t haint          : 16;
+               __BITFIELD_FIELD(uint32_t reserved_16_31        : 16,
+               __BITFIELD_FIELD(uint32_t haint                 : 16,
+               ;))
        } s;
 };
 
@@ -944,8 +957,9 @@ union cvmx_usbcx_haintmsk {
         *      One bit per channel: Bit 0 for channel 0, bit 15 for channel 15
         */
        struct cvmx_usbcx_haintmsk_s {
-               uint32_t reserved_16_31 : 16;
-               uint32_t haintmsk       : 16;
+               __BITFIELD_FIELD(uint32_t reserved_16_31        : 16,
+               __BITFIELD_FIELD(uint32_t haintmsk              : 16,
+               ;))
        } s;
 };
 
@@ -1014,17 +1028,18 @@ union cvmx_usbcx_hccharx {
         *      Indicates the maximum packet size of the associated endpoint.
         */
        struct cvmx_usbcx_hccharx_s {
-               uint32_t chena          : 1;
-               uint32_t chdis          : 1;
-               uint32_t oddfrm         : 1;
-               uint32_t devaddr        : 7;
-               uint32_t ec             : 2;
-               uint32_t eptype         : 2;
-               uint32_t lspddev        : 1;
-               uint32_t reserved_16_16 : 1;
-               uint32_t epdir          : 1;
-               uint32_t epnum          : 4;
-               uint32_t mps            : 11;
+               __BITFIELD_FIELD(uint32_t chena                 : 1,
+               __BITFIELD_FIELD(uint32_t chdis                 : 1,
+               __BITFIELD_FIELD(uint32_t oddfrm                : 1,
+               __BITFIELD_FIELD(uint32_t devaddr               : 7,
+               __BITFIELD_FIELD(uint32_t ec                    : 2,
+               __BITFIELD_FIELD(uint32_t eptype                : 2,
+               __BITFIELD_FIELD(uint32_t lspddev               : 1,
+               __BITFIELD_FIELD(uint32_t reserved_16_16        : 1,
+               __BITFIELD_FIELD(uint32_t epdir                 : 1,
+               __BITFIELD_FIELD(uint32_t epnum                 : 4,
+               __BITFIELD_FIELD(uint32_t mps                   : 11,
+               ;)))))))))))
        } s;
 };
 
@@ -1069,9 +1084,10 @@ union cvmx_usbcx_hcfg {
         *      * 2'b11: Reserved
         */
        struct cvmx_usbcx_hcfg_s {
-               uint32_t reserved_3_31  : 29;
-               uint32_t fslssupp       : 1;
-               uint32_t fslspclksel    : 2;
+               __BITFIELD_FIELD(uint32_t reserved_3_31 : 29,
+               __BITFIELD_FIELD(uint32_t fslssupp      : 1,
+               __BITFIELD_FIELD(uint32_t fslspclksel   : 2,
+               ;)))
        } s;
 };
 
@@ -1110,18 +1126,19 @@ union cvmx_usbcx_hcintx {
         *      Transfer completed normally without any errors.
         */
        struct cvmx_usbcx_hcintx_s {
-               uint32_t reserved_11_31 : 21;
-               uint32_t datatglerr     : 1;
-               uint32_t frmovrun       : 1;
-               uint32_t bblerr         : 1;
-               uint32_t xacterr        : 1;
-               uint32_t nyet           : 1;
-               uint32_t ack            : 1;
-               uint32_t nak            : 1;
-               uint32_t stall          : 1;
-               uint32_t ahberr         : 1;
-               uint32_t chhltd         : 1;
-               uint32_t xfercompl      : 1;
+               __BITFIELD_FIELD(uint32_t reserved_11_31        : 21,
+               __BITFIELD_FIELD(uint32_t datatglerr            : 1,
+               __BITFIELD_FIELD(uint32_t frmovrun              : 1,
+               __BITFIELD_FIELD(uint32_t bblerr                : 1,
+               __BITFIELD_FIELD(uint32_t xacterr               : 1,
+               __BITFIELD_FIELD(uint32_t nyet                  : 1,
+               __BITFIELD_FIELD(uint32_t ack                   : 1,
+               __BITFIELD_FIELD(uint32_t nak                   : 1,
+               __BITFIELD_FIELD(uint32_t stall                 : 1,
+               __BITFIELD_FIELD(uint32_t ahberr                : 1,
+               __BITFIELD_FIELD(uint32_t chhltd                : 1,
+               __BITFIELD_FIELD(uint32_t xfercompl             : 1,
+               ;))))))))))))
        } s;
 };
 
@@ -1151,18 +1168,19 @@ union cvmx_usbcx_hcintmskx {
         * @xfercomplmsk: Transfer Completed Mask (XferComplMsk)
         */
        struct cvmx_usbcx_hcintmskx_s {
-               uint32_t reserved_11_31 : 21;
-               uint32_t datatglerrmsk  : 1;
-               uint32_t frmovrunmsk    : 1;
-               uint32_t bblerrmsk      : 1;
-               uint32_t xacterrmsk     : 1;
-               uint32_t nyetmsk        : 1;
-               uint32_t ackmsk         : 1;
-               uint32_t nakmsk         : 1;
-               uint32_t stallmsk       : 1;
-               uint32_t ahberrmsk      : 1;
-               uint32_t chhltdmsk      : 1;
-               uint32_t xfercomplmsk   : 1;
+               __BITFIELD_FIELD(uint32_t reserved_11_31                : 21,
+               __BITFIELD_FIELD(uint32_t datatglerrmsk                 : 1,
+               __BITFIELD_FIELD(uint32_t frmovrunmsk                   : 1,
+               __BITFIELD_FIELD(uint32_t bblerrmsk                     : 1,
+               __BITFIELD_FIELD(uint32_t xacterrmsk                    : 1,
+               __BITFIELD_FIELD(uint32_t nyetmsk                       : 1,
+               __BITFIELD_FIELD(uint32_t ackmsk                        : 1,
+               __BITFIELD_FIELD(uint32_t nakmsk                        : 1,
+               __BITFIELD_FIELD(uint32_t stallmsk                      : 1,
+               __BITFIELD_FIELD(uint32_t ahberrmsk                     : 1,
+               __BITFIELD_FIELD(uint32_t chhltdmsk                     : 1,
+               __BITFIELD_FIELD(uint32_t xfercomplmsk                  : 1,
+               ;))))))))))))
        } s;
 };
 
@@ -1201,12 +1219,13 @@ union cvmx_usbcx_hcspltx {
         *      translator.
         */
        struct cvmx_usbcx_hcspltx_s {
-               uint32_t spltena        : 1;
-               uint32_t reserved_17_30 : 14;
-               uint32_t compsplt       : 1;
-               uint32_t xactpos        : 2;
-               uint32_t hubaddr        : 7;
-               uint32_t prtaddr        : 7;
+               __BITFIELD_FIELD(uint32_t spltena                       : 1,
+               __BITFIELD_FIELD(uint32_t reserved_17_30                : 14,
+               __BITFIELD_FIELD(uint32_t compsplt                      : 1,
+               __BITFIELD_FIELD(uint32_t xactpos                       : 2,
+               __BITFIELD_FIELD(uint32_t hubaddr                       : 7,
+               __BITFIELD_FIELD(uint32_t prtaddr                       : 7,
+               ;))))))
        } s;
 };
 
@@ -1246,10 +1265,11 @@ union cvmx_usbcx_hctsizx {
         *      size for IN transactions (periodic and non-periodic).
         */
        struct cvmx_usbcx_hctsizx_s {
-               uint32_t dopng          : 1;
-               uint32_t pid            : 2;
-               uint32_t pktcnt         : 10;
-               uint32_t xfersize       : 19;
+               __BITFIELD_FIELD(uint32_t dopng                 : 1,
+               __BITFIELD_FIELD(uint32_t pid                   : 2,
+               __BITFIELD_FIELD(uint32_t pktcnt                : 10,
+               __BITFIELD_FIELD(uint32_t xfersize              : 19,
+               ;))))
        } s;
 };
 
@@ -1283,8 +1303,9 @@ union cvmx_usbcx_hfir {
         *      * 1 ms (PHY clock frequency for FS/LS)
         */
        struct cvmx_usbcx_hfir_s {
-               uint32_t reserved_16_31 : 16;
-               uint32_t frint          : 16;
+               __BITFIELD_FIELD(uint32_t reserved_16_31                : 16,
+               __BITFIELD_FIELD(uint32_t frint                         : 16,
+               ;))
        } s;
 };
 
@@ -1312,8 +1333,9 @@ union cvmx_usbcx_hfnum {
         *      USB, and is reset to 0 when it reaches 16'h3FFF.
         */
        struct cvmx_usbcx_hfnum_s {
-               uint32_t frrem  : 16;
-               uint32_t frnum  : 16;
+               __BITFIELD_FIELD(uint32_t frrem         : 16,
+               __BITFIELD_FIELD(uint32_t frnum         : 16,
+               ;))
        } s;
 };
 
@@ -1439,21 +1461,22 @@ union cvmx_usbcx_hprt {
         *      * 1: A device is attached to the port.
         */
        struct cvmx_usbcx_hprt_s {
-               uint32_t reserved_19_31 : 13;
-               uint32_t prtspd         : 2;
-               uint32_t prttstctl      : 4;
-               uint32_t prtpwr         : 1;
-               uint32_t prtlnsts       : 2;
-               uint32_t reserved_9_9   : 1;
-               uint32_t prtrst         : 1;
-               uint32_t prtsusp        : 1;
-               uint32_t prtres         : 1;
-               uint32_t prtovrcurrchng : 1;
-               uint32_t prtovrcurract  : 1;
-               uint32_t prtenchng      : 1;
-               uint32_t prtena         : 1;
-               uint32_t prtconndet     : 1;
-               uint32_t prtconnsts     : 1;
+               __BITFIELD_FIELD(uint32_t reserved_19_31        : 13,
+               __BITFIELD_FIELD(uint32_t prtspd                : 2,
+               __BITFIELD_FIELD(uint32_t prttstctl             : 4,
+               __BITFIELD_FIELD(uint32_t prtpwr                : 1,
+               __BITFIELD_FIELD(uint32_t prtlnsts              : 2,
+               __BITFIELD_FIELD(uint32_t reserved_9_9          : 1,
+               __BITFIELD_FIELD(uint32_t prtrst                : 1,
+               __BITFIELD_FIELD(uint32_t prtsusp               : 1,
+               __BITFIELD_FIELD(uint32_t prtres                : 1,
+               __BITFIELD_FIELD(uint32_t prtovrcurrchng        : 1,
+               __BITFIELD_FIELD(uint32_t prtovrcurract         : 1,
+               __BITFIELD_FIELD(uint32_t prtenchng             : 1,
+               __BITFIELD_FIELD(uint32_t prtena                : 1,
+               __BITFIELD_FIELD(uint32_t prtconndet            : 1,
+               __BITFIELD_FIELD(uint32_t prtconnsts            : 1,
+               ;)))))))))))))))
        } s;
 };
 
@@ -1476,8 +1499,9 @@ union cvmx_usbcx_hptxfsiz {
         * @ptxfstaddr: Host Periodic TxFIFO Start Address (PTxFStAddr)
         */
        struct cvmx_usbcx_hptxfsiz_s {
-               uint32_t ptxfsize       : 16;
-               uint32_t ptxfstaddr     : 16;
+               __BITFIELD_FIELD(uint32_t ptxfsize      : 16,
+               __BITFIELD_FIELD(uint32_t ptxfstaddr    : 16,
+               ;))
        } s;
 };
 
@@ -1531,9 +1555,10 @@ union cvmx_usbcx_hptxsts {
         *      * Others: Reserved
         */
        struct cvmx_usbcx_hptxsts_s {
-               uint32_t ptxqtop        : 8;
-               uint32_t ptxqspcavail   : 8;
-               uint32_t ptxfspcavail   : 16;
+               __BITFIELD_FIELD(uint32_t ptxqtop       : 8,
+               __BITFIELD_FIELD(uint32_t ptxqspcavail  : 8,
+               __BITFIELD_FIELD(uint32_t ptxfspcavail  : 16,
+               ;)))
        } s;
 };
 
@@ -1636,21 +1661,22 @@ union cvmx_usbnx_clk_ctl {
         *      until AFTER this field is set and then read.
         */
        struct cvmx_usbnx_clk_ctl_s {
-               uint64_t reserved_20_63 : 44;
-               uint64_t divide2        : 2;
-               uint64_t hclk_rst       : 1;
-               uint64_t p_x_on         : 1;
-               uint64_t p_rtype        : 2;
-               uint64_t p_com_on       : 1;
-               uint64_t p_c_sel        : 2;
-               uint64_t cdiv_byp       : 1;
-               uint64_t sd_mode        : 2;
-               uint64_t s_bist         : 1;
-               uint64_t por            : 1;
-               uint64_t enable         : 1;
-               uint64_t prst           : 1;
-               uint64_t hrst           : 1;
-               uint64_t divide         : 3;
+               __BITFIELD_FIELD(uint64_t reserved_20_63        : 44,
+               __BITFIELD_FIELD(uint64_t divide2               : 2,
+               __BITFIELD_FIELD(uint64_t hclk_rst              : 1,
+               __BITFIELD_FIELD(uint64_t p_x_on                : 1,
+               __BITFIELD_FIELD(uint64_t p_rtype               : 2,
+               __BITFIELD_FIELD(uint64_t p_com_on              : 1,
+               __BITFIELD_FIELD(uint64_t p_c_sel               : 2,
+               __BITFIELD_FIELD(uint64_t cdiv_byp              : 1,
+               __BITFIELD_FIELD(uint64_t sd_mode               : 2,
+               __BITFIELD_FIELD(uint64_t s_bist                : 1,
+               __BITFIELD_FIELD(uint64_t por                   : 1,
+               __BITFIELD_FIELD(uint64_t enable                : 1,
+               __BITFIELD_FIELD(uint64_t prst                  : 1,
+               __BITFIELD_FIELD(uint64_t hrst                  : 1,
+               __BITFIELD_FIELD(uint64_t divide                : 3,
+               ;)))))))))))))))
        } s;
 };
 
@@ -1778,41 +1804,42 @@ union cvmx_usbnx_usbp_ctl_status {
         *      de-assertion.
         */
        struct cvmx_usbnx_usbp_ctl_status_s {
-               uint64_t txrisetune             : 1;
-               uint64_t txvreftune             : 4;
-               uint64_t txfslstune             : 4;
-               uint64_t txhsxvtune             : 2;
-               uint64_t sqrxtune               : 3;
-               uint64_t compdistune            : 3;
-               uint64_t otgtune                : 3;
-               uint64_t otgdisable             : 1;
-               uint64_t portreset              : 1;
-               uint64_t drvvbus                : 1;
-               uint64_t lsbist                 : 1;
-               uint64_t fsbist                 : 1;
-               uint64_t hsbist                 : 1;
-               uint64_t bist_done              : 1;
-               uint64_t bist_err               : 1;
-               uint64_t tdata_out              : 4;
-               uint64_t siddq                  : 1;
-               uint64_t txpreemphasistune      : 1;
-               uint64_t dma_bmode              : 1;
-               uint64_t usbc_end               : 1;
-               uint64_t usbp_bist              : 1;
-               uint64_t tclk                   : 1;
-               uint64_t dp_pulld               : 1;
-               uint64_t dm_pulld               : 1;
-               uint64_t hst_mode               : 1;
-               uint64_t tuning                 : 4;
-               uint64_t tx_bs_enh              : 1;
-               uint64_t tx_bs_en               : 1;
-               uint64_t loop_enb               : 1;
-               uint64_t vtest_enb              : 1;
-               uint64_t bist_enb               : 1;
-               uint64_t tdata_sel              : 1;
-               uint64_t taddr_in               : 4;
-               uint64_t tdata_in               : 8;
-               uint64_t ate_reset              : 1;
+               __BITFIELD_FIELD(uint64_t txrisetune            : 1,
+               __BITFIELD_FIELD(uint64_t txvreftune            : 4,
+               __BITFIELD_FIELD(uint64_t txfslstune            : 4,
+               __BITFIELD_FIELD(uint64_t txhsxvtune            : 2,
+               __BITFIELD_FIELD(uint64_t sqrxtune              : 3,
+               __BITFIELD_FIELD(uint64_t compdistune           : 3,
+               __BITFIELD_FIELD(uint64_t otgtune               : 3,
+               __BITFIELD_FIELD(uint64_t otgdisable            : 1,
+               __BITFIELD_FIELD(uint64_t portreset             : 1,
+               __BITFIELD_FIELD(uint64_t drvvbus               : 1,
+               __BITFIELD_FIELD(uint64_t lsbist                : 1,
+               __BITFIELD_FIELD(uint64_t fsbist                : 1,
+               __BITFIELD_FIELD(uint64_t hsbist                : 1,
+               __BITFIELD_FIELD(uint64_t bist_done             : 1,
+               __BITFIELD_FIELD(uint64_t bist_err              : 1,
+               __BITFIELD_FIELD(uint64_t tdata_out             : 4,
+               __BITFIELD_FIELD(uint64_t siddq                 : 1,
+               __BITFIELD_FIELD(uint64_t txpreemphasistune     : 1,
+               __BITFIELD_FIELD(uint64_t dma_bmode             : 1,
+               __BITFIELD_FIELD(uint64_t usbc_end              : 1,
+               __BITFIELD_FIELD(uint64_t usbp_bist             : 1,
+               __BITFIELD_FIELD(uint64_t tclk                  : 1,
+               __BITFIELD_FIELD(uint64_t dp_pulld              : 1,
+               __BITFIELD_FIELD(uint64_t dm_pulld              : 1,
+               __BITFIELD_FIELD(uint64_t hst_mode              : 1,
+               __BITFIELD_FIELD(uint64_t tuning                : 4,
+               __BITFIELD_FIELD(uint64_t tx_bs_enh             : 1,
+               __BITFIELD_FIELD(uint64_t tx_bs_en              : 1,
+               __BITFIELD_FIELD(uint64_t loop_enb              : 1,
+               __BITFIELD_FIELD(uint64_t vtest_enb             : 1,
+               __BITFIELD_FIELD(uint64_t bist_enb              : 1,
+               __BITFIELD_FIELD(uint64_t tdata_sel             : 1,
+               __BITFIELD_FIELD(uint64_t taddr_in              : 4,
+               __BITFIELD_FIELD(uint64_t tdata_in              : 8,
+               __BITFIELD_FIELD(uint64_t ate_reset             : 1,
+               ;)))))))))))))))))))))))))))))))))))
        } s;
 };
 
index ebfa9c9e71b1580e629ab00e09475db1f3b47b00..40dab11e5333829092d32e5988ccae3d686ac5e3 100644 (file)
@@ -130,19 +130,6 @@ static void cvm_oct_note_carrier(struct octeon_ethernet *priv,
        }
 }
 
-void cvm_oct_set_carrier(struct octeon_ethernet *priv,
-                        cvmx_helper_link_info_t link_info)
-{
-       cvm_oct_note_carrier(priv, link_info);
-       if (link_info.s.link_up) {
-               if (!netif_carrier_ok(priv->netdev))
-                       netif_carrier_on(priv->netdev);
-       } else {
-               if (netif_carrier_ok(priv->netdev))
-                       netif_carrier_off(priv->netdev);
-       }
-}
-
 void cvm_oct_adjust_link(struct net_device *dev)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
index eccfcc54cea8e907c74c117903e982c7067c4691..6191b0850646062e47c205734e0b884277da42c6 100644 (file)
@@ -40,5 +40,8 @@
 #endif /* CONFIG_XFRM */
 
 extern const struct ethtool_ops cvm_oct_ethtool_ops;
+
+extern void octeon_mdiobus_force_mod_depencency(void);
+
 int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 int cvm_oct_phy_setup_device(struct net_device *dev);
index 460e8545904fe174dc21cb68e81f9b22b0cd5e75..f539d82f2f111683c76c0ed0c0e18a9dc58bfdec 100644 (file)
@@ -573,8 +573,6 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
 #endif
 };
 
-extern void octeon_mdiobus_force_mod_depencency(void);
-
 static struct device_node *cvm_oct_of_get_child(
                                const struct device_node *parent, int reg_val)
 {
@@ -859,7 +857,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 bc7e664cc8a7fffdeb761bf6e2dce41ca7201807..d115f5c0e3415dcb8f6084fdcc0636522550501c 100644 (file)
@@ -18,8 +18,6 @@
 #include <linux/console.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
-#include <linux/pci.h>
-#include <linux/pci_ids.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/module.h>
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 7d6ef4cadf1a5f6f03465ae4cca73b6ce0e0bc9f..74ef34815b985df4d3650c0eabfce1dfe6d4794f 100644 (file)
@@ -34,11 +34,21 @@ MODULE_PARM_DESC(g_net_dev, "The device(s) to bind to; "
  */
 static int __init ozwpan_init(void)
 {
-       oz_cdev_register();
-       oz_protocol_init(g_net_dev);
+       int err;
+
+       err = oz_cdev_register();
+       if (err)
+               return err;
+       err = oz_protocol_init(g_net_dev);
+       if (err)
+               goto err_protocol;
        oz_app_enable(OZ_APPID_USB, 1);
        oz_apps_init();
        return 0;
+
+err_protocol:
+       oz_cdev_deregister();
+       return err;
 }
 
 /*
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..ea54fb4ec837ea737653fc77fff786d2d38e7d2a 100644 (file)
@@ -335,11 +335,11 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES];
  * LCD types
  */
 #define LCD_TYPE_NONE          0
-#define LCD_TYPE_OLD           1
-#define LCD_TYPE_KS0074                2
-#define LCD_TYPE_HANTRONIX     3
-#define LCD_TYPE_NEXCOM                4
-#define LCD_TYPE_CUSTOM                5
+#define LCD_TYPE_CUSTOM                1
+#define LCD_TYPE_OLD           2
+#define LCD_TYPE_KS0074                3
+#define LCD_TYPE_HANTRONIX     4
+#define LCD_TYPE_NEXCOM                5
 
 /*
  * keypad types
@@ -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);
@@ -502,7 +500,7 @@ MODULE_PARM_DESC(keypad_type,
 static int lcd_type = NOT_SET;
 module_param(lcd_type, int, 0000);
 MODULE_PARM_DESC(lcd_type,
-                "LCD type: 0=none, 1=old //, 2=serial ks0074, 3=hantronix //, 4=nexcom //, 5=compiled-in");
+                "LCD type: 0=none, 1=compiled-in, 2=old, 3=serial ks0074, 4=hantronix, 5=nexcom");
 
 static int lcd_height = NOT_SET;
 module_param(lcd_height, int, 0000);
@@ -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..11b780d6c4ab6bbea68e8ccdb60ba1ba800840b2 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;
 
@@ -789,7 +788,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
  *
  * Returns: the address of the specific WPS attribute found, or NULL
  */
-u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr)
+u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr)
 {
        u8 *attr_ptr = NULL;
        u8 *target_attr_ptr = NULL;
@@ -799,7 +798,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at
                *len_attr = 0;
 
        if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) ||
-           (memcmp(wps_ie + 2, wps_oui , 4)))
+           (memcmp(wps_ie + 2, wps_oui, 4)))
                return attr_ptr;
 
        /*  6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */
@@ -835,7 +834,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at
  *
  * Returns: the address of the specific WPS attribute content found, or NULL
  */
-u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content)
+u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content)
 {
        u8 *attr_ptr;
        u32 attr_len;
@@ -1239,7 +1238,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
        } else {
                pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS;
        }
-       rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len);
+       rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len);
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid));
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len));
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid));
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..be9e34a0daef836baa7330fe92c2a8379052dc19 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);
        }
@@ -5430,15 +5431,14 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
                goto exit;
        }
 
-       ptxBeacon_parm = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL);
+       ptxBeacon_parm = kmemdup(&(pmlmeinfo->network),
+                               sizeof(struct wlan_bssid_ex), GFP_KERNEL);
        if (ptxBeacon_parm == NULL) {
                kfree(ph2c);
                res = _FAIL;
                goto exit;
        }
 
-       memcpy(ptxBeacon_parm, &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex));
-
        len_diff = update_hidden_ssid(ptxBeacon_parm->IEs+_BEACON_IE_OFFSET_,
                                      ptxBeacon_parm->IELength-_BEACON_IE_OFFSET_,
                                      pmlmeinfo->hidden_ssid_mode);
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..fda169d377714e52eac42b470387c286d97063de 100644 (file)
@@ -1634,23 +1634,15 @@ 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;
 
-       if (pxmitpriv->hwxmit_entry == 5) {
-               hwxmits[0] .sta_queue = &pxmitpriv->bm_pending;
-               hwxmits[1] .sta_queue = &pxmitpriv->vo_pending;
-               hwxmits[2] .sta_queue = &pxmitpriv->vi_pending;
-               hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
-               hwxmits[4] .sta_queue = &pxmitpriv->be_pending;
-       } else if (pxmitpriv->hwxmit_entry == 4) {
-               hwxmits[0] .sta_queue = &pxmitpriv->vo_pending;
-               hwxmits[1] .sta_queue = &pxmitpriv->vi_pending;
-               hwxmits[2] .sta_queue = &pxmitpriv->be_pending;
-               hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
-       } else {
-       }
+       hwxmits[0] .sta_queue = &pxmitpriv->vo_pending;
+       hwxmits[1] .sta_queue = &pxmitpriv->vi_pending;
+       hwxmits[2] .sta_queue = &pxmitpriv->be_pending;
+       hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
 }
 
 void rtw_free_hwxmits(struct adapter *padapter)
index 3c651d5c6824e19799f656a2add99b73a1dca9d7..082f0ca198ef6d1e81f2765554cd903da72b2bc0 100644 (file)
@@ -115,17 +115,21 @@ static void odm_SetTxRPTTiming_8188E(
        }
        pRaInfo->RptTime = DynamicTxRPTTiming[idx];
 
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                       ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime));
 }
 
-static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo)
+static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm,
+                               struct odm_ra_info *pRaInfo)
 {
        u8 RateID, LowestRate, HighestRate;
        u8 i;
 
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE,
+                       ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n"));
        if (NULL == pRaInfo) {
-               ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n"));
+               ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                               ("odm_RateDown_8188E(): pRaInfo is NULL\n"));
                return -1;
        }
        RateID = pRaInfo->PreRate;
@@ -167,10 +171,15 @@ RateDownFinish:
 
        pRaInfo->DecisionRate = RateID;
        odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2);
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n"));
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter));
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI));
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDown_8188E()\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE,
+                       ODM_DBG_LOUD, ("Rate down, RPT Timing default\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
+                       ("RAWaitingCounter %d, RAPendingCounter %d",
+                        pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                       ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
+                       ("<===== odm_RateDown_8188E()\n"));
        return 0;
 }
 
@@ -182,9 +191,11 @@ static int odm_RateUp_8188E(
        u8 RateID, HighestRate;
        u8 i;
 
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE,
+                       ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n"));
        if (NULL == pRaInfo) {
-               ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n"));
+               ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                               ("odm_RateUp_8188E(): pRaInfo is NULL\n"));
                return -1;
        }
        RateID = pRaInfo->PreRate;
@@ -200,7 +211,8 @@ static int odm_RateUp_8188E(
                goto RateUpfinish;
        }
        odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0);
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                       ("odm_RateUp_8188E():Decrease RPT Timing\n"));
 
        if (RateID < HighestRate) {
                for (i = RateID+1; i <= HighestRate; i++) {
@@ -218,15 +230,20 @@ static int odm_RateUp_8188E(
                RateID = HighestRate;
        }
 RateUpfinish:
-       if (pRaInfo->RAWaitingCounter == (4+PendingForRateUpFail[pRaInfo->RAPendingCounter]))
+       if (pRaInfo->RAWaitingCounter ==
+               (4+PendingForRateUpFail[pRaInfo->RAPendingCounter]))
                pRaInfo->RAWaitingCounter = 0;
        else
                pRaInfo->RAWaitingCounter++;
 
        pRaInfo->DecisionRate = RateID;
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID));
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter));
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD,
+                       ("Rate up to RateID %d\n", RateID));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
+                       ("RAWaitingCounter %d, RAPendingCounter %d",
+                        pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE,
+                       ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n"));
        return 0;
 }
 
@@ -243,11 +260,12 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm,
                struct odm_ra_info *pRaInfo
        )
 {
-       u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0;
+       u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0, i = 0;
        /* u32 pool_retry; */
        static u8 DynamicTxRPTTimingCounter;
 
-       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n"));
+       ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
+                       ("=====>odm_RateDecision_8188E()\n"));
 
        if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /*  STA used and data packet exits */
                if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) ||
@@ -268,14 +286,14 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm,
 
                ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
                             (" NscDown init is %d\n", pRaInfo->NscDown));
-               pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0];
-               pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1];
-               pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2];
-               pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3];
-               pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4];
+
+               for (i = 0 ; i <= 4 ; i++)
+                       pRaInfo->NscDown += pRaInfo->RTY[i] * RETRY_PENALTY[PenaltyID1][i];
+
                ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
-                            (" NscDown is %d, total*penalty[5] is %d\n",
-                            pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])));
+                            (" NscDown is %d, total*penalty[5] is %d\n", pRaInfo->NscDown,
+                             (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])));
+
                if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))
                        pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5];
                else
@@ -285,14 +303,14 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm,
                PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID];
                ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
                             (" NscUp init is %d\n", pRaInfo->NscUp));
-               pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0];
-               pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1];
-               pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2];
-               pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3];
-               pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4];
+
+               for (i = 0 ; i <= 4 ; i++)
+                       pRaInfo->NscUp += pRaInfo->RTY[i] * RETRY_PENALTY[PenaltyID2][i];
+
                ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE,
                             ("NscUp is %d, total*up[5] is %d\n",
                             pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])));
+
                if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))
                        pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5];
                else
@@ -487,7 +505,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 +556,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 +637,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 +649,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..8eb2b39a0b6737008867f2032cd8371ced743fee 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);
        }
 }
@@ -591,84 +600,90 @@ static bool config_bb_with_pgheader(struct adapter *adapt)
 static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *Adapter)
 {
        struct hal_data_8188e           *hal_data = GET_HAL_DATA(Adapter);
-
-       hal_data->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW;
-       hal_data->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW;
-       hal_data->PHYRegDef[RF_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;
-       hal_data->PHYRegDef[RF_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB;
-       hal_data->PHYRegDef[RF_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;
-       hal_data->PHYRegDef[RF_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;
-       hal_data->PHYRegDef[RF_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE;
-       hal_data->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE;
-       hal_data->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE;
-
-       hal_data->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter;
-       hal_data->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter;
-       hal_data->PHYRegDef[RF_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter;
-       hal_data->PHYRegDef[RF_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter;
-       hal_data->PHYRegDef[RF_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfTxGainStage = rFPGA0_TxGainStage;
-       hal_data->PHYRegDef[RF_PATH_B].rfTxGainStage = rFPGA0_TxGainStage;
-       hal_data->PHYRegDef[RF_PATH_C].rfTxGainStage = rFPGA0_TxGainStage;
-       hal_data->PHYRegDef[RF_PATH_D].rfTxGainStage = rFPGA0_TxGainStage;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1;
-       hal_data->PHYRegDef[RF_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2;
-       hal_data->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl;
-       hal_data->PHYRegDef[RF_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl;
-       hal_data->PHYRegDef[RF_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl;
-       hal_data->PHYRegDef[RF_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1;
-       hal_data->PHYRegDef[RF_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1;
-       hal_data->PHYRegDef[RF_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1;
-       hal_data->PHYRegDef[RF_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2;
-       hal_data->PHYRegDef[RF_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2;
-       hal_data->PHYRegDef[RF_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2;
-       hal_data->PHYRegDef[RF_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfRxAFE = rOFDM0_XARxAFE;
-       hal_data->PHYRegDef[RF_PATH_B].rfRxAFE = rOFDM0_XBRxAFE;
-       hal_data->PHYRegDef[RF_PATH_C].rfRxAFE = rOFDM0_XCRxAFE;
-       hal_data->PHYRegDef[RF_PATH_D].rfRxAFE = rOFDM0_XDRxAFE;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance;
-       hal_data->PHYRegDef[RF_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfTxAFE = rOFDM0_XATxAFE;
-       hal_data->PHYRegDef[RF_PATH_B].rfTxAFE = rOFDM0_XBTxAFE;
-       hal_data->PHYRegDef[RF_PATH_C].rfTxAFE = rOFDM0_XCTxAFE;
-       hal_data->PHYRegDef[RF_PATH_D].rfTxAFE = rOFDM0_XDTxAFE;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
-       hal_data->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack;
-       hal_data->PHYRegDef[RF_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack;
-       hal_data->PHYRegDef[RF_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack;
-
-       hal_data->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback;
-       hal_data->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback;
+       struct bb_reg_def               *reg[4];
+
+       reg[RF_PATH_A] = &(hal_data->PHYRegDef[RF_PATH_A]);
+       reg[RF_PATH_B] = &(hal_data->PHYRegDef[RF_PATH_B]);
+       reg[RF_PATH_C] = &(hal_data->PHYRegDef[RF_PATH_C]);
+       reg[RF_PATH_D] = &(hal_data->PHYRegDef[RF_PATH_D]);
+
+       reg[RF_PATH_A]->rfintfs = rFPGA0_XAB_RFInterfaceSW;
+       reg[RF_PATH_B]->rfintfs = rFPGA0_XAB_RFInterfaceSW;
+       reg[RF_PATH_C]->rfintfs = rFPGA0_XCD_RFInterfaceSW;
+       reg[RF_PATH_D]->rfintfs = rFPGA0_XCD_RFInterfaceSW;
+
+       reg[RF_PATH_A]->rfintfi = rFPGA0_XAB_RFInterfaceRB;
+       reg[RF_PATH_B]->rfintfi = rFPGA0_XAB_RFInterfaceRB;
+       reg[RF_PATH_C]->rfintfi = rFPGA0_XCD_RFInterfaceRB;
+       reg[RF_PATH_D]->rfintfi = rFPGA0_XCD_RFInterfaceRB;
+
+       reg[RF_PATH_A]->rfintfo = rFPGA0_XA_RFInterfaceOE;
+       reg[RF_PATH_B]->rfintfo = rFPGA0_XB_RFInterfaceOE;
+
+       reg[RF_PATH_A]->rfintfe = rFPGA0_XA_RFInterfaceOE;
+       reg[RF_PATH_B]->rfintfe = rFPGA0_XB_RFInterfaceOE;
+
+       reg[RF_PATH_A]->rf3wireOffset = rFPGA0_XA_LSSIParameter;
+       reg[RF_PATH_B]->rf3wireOffset = rFPGA0_XB_LSSIParameter;
+
+       reg[RF_PATH_A]->rfLSSI_Select = rFPGA0_XAB_RFParameter;
+       reg[RF_PATH_B]->rfLSSI_Select = rFPGA0_XAB_RFParameter;
+       reg[RF_PATH_C]->rfLSSI_Select = rFPGA0_XCD_RFParameter;
+       reg[RF_PATH_D]->rfLSSI_Select = rFPGA0_XCD_RFParameter;
+
+       reg[RF_PATH_A]->rfTxGainStage = rFPGA0_TxGainStage;
+       reg[RF_PATH_B]->rfTxGainStage = rFPGA0_TxGainStage;
+       reg[RF_PATH_C]->rfTxGainStage = rFPGA0_TxGainStage;
+       reg[RF_PATH_D]->rfTxGainStage = rFPGA0_TxGainStage;
+
+       reg[RF_PATH_A]->rfHSSIPara1 = rFPGA0_XA_HSSIParameter1;
+       reg[RF_PATH_B]->rfHSSIPara1 = rFPGA0_XB_HSSIParameter1;
+
+       reg[RF_PATH_A]->rfHSSIPara2 = rFPGA0_XA_HSSIParameter2;
+       reg[RF_PATH_B]->rfHSSIPara2 = rFPGA0_XB_HSSIParameter2;
+
+       reg[RF_PATH_A]->rfSwitchControl = rFPGA0_XAB_SwitchControl;
+       reg[RF_PATH_B]->rfSwitchControl = rFPGA0_XAB_SwitchControl;
+       reg[RF_PATH_C]->rfSwitchControl = rFPGA0_XCD_SwitchControl;
+       reg[RF_PATH_D]->rfSwitchControl = rFPGA0_XCD_SwitchControl;
+
+       reg[RF_PATH_A]->rfAGCControl1 = rOFDM0_XAAGCCore1;
+       reg[RF_PATH_B]->rfAGCControl1 = rOFDM0_XBAGCCore1;
+       reg[RF_PATH_C]->rfAGCControl1 = rOFDM0_XCAGCCore1;
+       reg[RF_PATH_D]->rfAGCControl1 = rOFDM0_XDAGCCore1;
+
+       reg[RF_PATH_A]->rfAGCControl2 = rOFDM0_XAAGCCore2;
+       reg[RF_PATH_B]->rfAGCControl2 = rOFDM0_XBAGCCore2;
+       reg[RF_PATH_C]->rfAGCControl2 = rOFDM0_XCAGCCore2;
+       reg[RF_PATH_D]->rfAGCControl2 = rOFDM0_XDAGCCore2;
+
+       reg[RF_PATH_A]->rfRxIQImbalance = rOFDM0_XARxIQImbalance;
+       reg[RF_PATH_B]->rfRxIQImbalance = rOFDM0_XBRxIQImbalance;
+       reg[RF_PATH_C]->rfRxIQImbalance = rOFDM0_XCRxIQImbalance;
+       reg[RF_PATH_D]->rfRxIQImbalance = rOFDM0_XDRxIQImbalance;
+
+       reg[RF_PATH_A]->rfRxAFE = rOFDM0_XARxAFE;
+       reg[RF_PATH_B]->rfRxAFE = rOFDM0_XBRxAFE;
+       reg[RF_PATH_C]->rfRxAFE = rOFDM0_XCRxAFE;
+       reg[RF_PATH_D]->rfRxAFE = rOFDM0_XDRxAFE;
+
+       reg[RF_PATH_A]->rfTxIQImbalance = rOFDM0_XATxIQImbalance;
+       reg[RF_PATH_B]->rfTxIQImbalance = rOFDM0_XBTxIQImbalance;
+       reg[RF_PATH_C]->rfTxIQImbalance = rOFDM0_XCTxIQImbalance;
+       reg[RF_PATH_D]->rfTxIQImbalance = rOFDM0_XDTxIQImbalance;
+
+       reg[RF_PATH_A]->rfTxAFE = rOFDM0_XATxAFE;
+       reg[RF_PATH_B]->rfTxAFE = rOFDM0_XBTxAFE;
+       reg[RF_PATH_C]->rfTxAFE = rOFDM0_XCTxAFE;
+       reg[RF_PATH_D]->rfTxAFE = rOFDM0_XDTxAFE;
+
+       reg[RF_PATH_A]->rfLSSIReadBack = rFPGA0_XA_LSSIReadBack;
+       reg[RF_PATH_B]->rfLSSIReadBack = rFPGA0_XB_LSSIReadBack;
+       reg[RF_PATH_C]->rfLSSIReadBack = rFPGA0_XC_LSSIReadBack;
+       reg[RF_PATH_D]->rfLSSIReadBack = rFPGA0_XD_LSSIReadBack;
+
+       reg[RF_PATH_A]->rfLSSIReadBackPi = TransceiverA_HSPI_Readback;
+       reg[RF_PATH_B]->rfLSSIReadBackPi = TransceiverB_HSPI_Readback;
 }
 
 static bool config_parafile(struct adapter *adapt)
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..ecdd2e5c6baccbf0aae4b3c1eb53fdae2546cf61 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 {
@@ -165,7 +165,7 @@ static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev)
 
 static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg)
 {
-       struct cmpk_intr_sta rx_intr_status;    /* */
+       struct cmpk_intr_sta rx_intr_status;
        struct r8192_priv *priv = rtllib_priv(dev);
 
        DMESG("---> cmpk_Handle_Interrupt_Status()\n");
@@ -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 23219e17e5a192ad0b6a91ed39da863401142613..2693682644df87a2de57dfa73b6adbd461d81855 100644 (file)
 struct cmpk_txfb {
        u8      element_id;
        u8      length;
-       u8      TID:4;                          /* */
-       u8      fail_reason:3;          /* */
+       u8      TID:4;
+       u8      fail_reason:3;
        u8      tok:1;
-       u8      reserve1:4;                     /* */
-       u8      pkt_type:2;             /* */
-       u8      bandwidth:1;            /* */
-       u8      qos_pkt:1;                      /* */
+       u8      reserve1:4;
+       u8      pkt_type:2;
+       u8      bandwidth:1;
+       u8      qos_pkt:1;
 
-       u8      reserve2;                       /* */
-       u8      retry_cnt;                      /* */
-       u16     pkt_id;                         /* */
+       u8      reserve2;
+       u8      retry_cnt;
+       u16     pkt_id;
 
-       u16     seq_num;                        /* */
+       u16     seq_num;
        u8      s_rate;
        u8      f_rate;
 
-       u8      s_rts_rate;                     /* */
-       u8      f_rts_rate;                     /* */
-       u16     pkt_length;                     /* */
+       u8      s_rts_rate;
+       u8      f_rts_rate;
+       u16     pkt_length;
 
-       u16     reserve3;                       /* */
-       u16     duration;                       /* */
+       u16     reserve3;
+       u16     duration;
 };
 
 struct cmpk_intr_sta {
index 552d943b1761c459a86dd25a6b6c33a6ee1abfa8..2869602436ef15a7dd58c8d5b1625c6cd5a83996 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]);
                }
        }
@@ -2019,6 +2025,7 @@ bool rtl8192_rx_query_status_desc(struct net_device *dev,
                                  struct sk_buff *skb)
 {
        struct r8192_priv *priv = rtllib_priv(dev);
+       struct rx_fwinfo *pDrvInfo = NULL;
 
        stats->bICV = pdesc->ICV;
        stats->bCRC = pdesc->CRC32;
@@ -2040,51 +2047,49 @@ bool rtl8192_rx_query_status_desc(struct net_device *dev,
                                priv->stats.rxcrcerrmid++;
                }
                return false;
-       } else {
-               struct rx_fwinfo *pDrvInfo = NULL;
+       }
 
-               stats->RxDrvInfoSize = pdesc->RxDrvInfoSize;
-               stats->RxBufShift = ((pdesc->Shift)&0x03);
-               stats->Decrypted = !pdesc->SWDec;
+       stats->RxDrvInfoSize = pdesc->RxDrvInfoSize;
+       stats->RxBufShift = ((pdesc->Shift)&0x03);
+       stats->Decrypted = !pdesc->SWDec;
 
-               pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift);
+       pDrvInfo = (struct rx_fwinfo *)(skb->data + stats->RxBufShift);
 
-               stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT,
-                                            (u8)pDrvInfo->RxRate);
-               stats->bShortPreamble = pDrvInfo->SPLCP;
+       stats->rate = HwRateToMRate90((bool)pDrvInfo->RxHT,
+                                    (u8)pDrvInfo->RxRate);
+       stats->bShortPreamble = pDrvInfo->SPLCP;
 
-               rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats);
+       rtl8192_UpdateReceivedRateHistogramStatistics(dev, stats);
 
-               stats->bIsAMPDU = (pDrvInfo->PartAggr == 1);
-               stats->bFirstMPDU = (pDrvInfo->PartAggr == 1) &&
-                                   (pDrvInfo->FirstAGGR == 1);
+       stats->bIsAMPDU = (pDrvInfo->PartAggr == 1);
+       stats->bFirstMPDU = (pDrvInfo->PartAggr == 1) &&
+                           (pDrvInfo->FirstAGGR == 1);
 
-               stats->TimeStampLow = pDrvInfo->TSFL;
-               stats->TimeStampHigh = read_nic_dword(dev, TSFR+4);
+       stats->TimeStampLow = pDrvInfo->TSFL;
+       stats->TimeStampHigh = read_nic_dword(dev, TSFR+4);
 
-               rtl819x_UpdateRxPktTimeStamp(dev, stats);
+       rtl819x_UpdateRxPktTimeStamp(dev, stats);
 
-               if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0)
-                       stats->bShift = 1;
+       if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0)
+               stats->bShift = 1;
 
-               stats->RxIs40MHzPacket = pDrvInfo->BW;
+       stats->RxIs40MHzPacket = pDrvInfo->BW;
 
-               rtl8192_TranslateRxSignalStuff(dev, skb, stats, pdesc,
-                                              pDrvInfo);
+       rtl8192_TranslateRxSignalStuff(dev, skb, stats, pdesc,
+                                      pDrvInfo);
 
-               if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1)
-                       RT_TRACE(COMP_RXDESC, "pDrvInfo->FirstAGGR = %d,"
-                                " pDrvInfo->PartAggr = %d\n",
-                                pDrvInfo->FirstAGGR, pDrvInfo->PartAggr);
-               skb_trim(skb, skb->len - 4/*sCrcLng*/);
+       if (pDrvInfo->FirstAGGR == 1 || pDrvInfo->PartAggr == 1)
+               RT_TRACE(COMP_RXDESC,
+                        "pDrvInfo->FirstAGGR = %d, pDrvInfo->PartAggr = %d\n",
+                        pDrvInfo->FirstAGGR, pDrvInfo->PartAggr);
+       skb_trim(skb, skb->len - 4/*sCrcLng*/);
 
 
-               stats->packetlength = stats->Length-4;
-               stats->fraglength = stats->packetlength;
-               stats->fragoffset = 0;
-               stats->ntotalfrag = 1;
-               return true;
-       }
+       stats->packetlength = stats->Length-4;
+       stats->fraglength = stats->packetlength;
+       stats->fragoffset = 0;
+       stats->ntotalfrag = 1;
+       return true;
 }
 
 void rtl8192_halt_adapter(struct net_device *dev, bool reset)
@@ -2132,7 +2137,6 @@ void rtl8192_halt_adapter(struct net_device *dev, bool reset)
                skb_queue_purge(&priv->rtllib->skb_aggQ[i]);
 
        skb_queue_purge(&priv->skb_queue);
-       return;
 }
 
 void rtl8192_update_ratr_table(struct net_device *dev)
@@ -2191,8 +2195,7 @@ rtl8192_InitializeVariables(struct net_device  *dev)
 
        priv->rtllib->softmac_features  = IEEE_SOFTMAC_SCAN |
                IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
-               IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE /* |
-               IEEE_SOFTMAC_BEACONS*/;
+               IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE;
 
        priv->rtllib->tx_headroom = sizeof(struct tx_fwinfo_8190pci);
 
@@ -2308,8 +2311,7 @@ bool rtl8192_HalRxCheckStuck(struct net_device *dev)
          (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M)))) {
                if (rx_chk_cnt < 2)
                        return bStuck;
-               else
-                       rx_chk_cnt = 0;
+               rx_chk_cnt = 0;
        } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) &&
                  (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) ||
                ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) &&
@@ -2317,13 +2319,11 @@ bool rtl8192_HalRxCheckStuck(struct net_device *dev)
                priv->undecorated_smoothed_pwdb >= VeryLowRSSI) {
                if (rx_chk_cnt < 4)
                        return bStuck;
-               else
-                       rx_chk_cnt = 0;
+               rx_chk_cnt = 0;
        } else {
                if (rx_chk_cnt < 8)
                        return bStuck;
-               else
-                       rx_chk_cnt = 0;
+               rx_chk_cnt = 0;
        }
 
 
@@ -2413,5 +2413,4 @@ void ActUpdateChannelAccessSetting(struct net_device *dev,
        enum wireless_mode WirelessMode,
        struct channel_access_setting *ChnlAccessSetting)
 {
-       return;
 }
index 2e28744b9aab630ec5120512cbfa4d0ecad79ebb..c465f8749acda2781d64d54e6d785efef4064c0c 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;
                                }
 
@@ -301,13 +301,11 @@ bool init_firmware(struct net_device *dev)
                file_length = pfirmware->firmware_buf_size[init_step];
 
                rt_status = fw_download_code(dev, mapped_file, file_length);
-               if (!rt_status) {
+               if (!rt_status)
                        goto download_firmware_fail;
-               }
 
-               if (!firmware_check_ready(dev, init_step)) {
+               if (!firmware_check_ready(dev, init_step))
                        goto download_firmware_fail;
-               }
        }
 
        RT_TRACE(COMP_FIRMWARE, "Firmware Download Success\n");
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..4664a4fd1e48cd8b9cfa1c894ed481c1b8cc2612 100644 (file)
@@ -94,7 +94,6 @@ void rtl8192_setBBreg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
                write_nic_dword(dev, dwRegAddr, NewValue);
        } else
                write_nic_dword(dev, dwRegAddr, dwData);
-       return;
 }
 
 u32 rtl8192_QueryBBReg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask)
@@ -136,8 +135,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 +191,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;
        }
 
@@ -215,7 +214,6 @@ static void rtl8192_phy_RFSerialWrite(struct net_device *dev,
                }
                rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3);
        }
-       return;
 }
 
 void rtl8192_phy_SetRFReg(struct net_device *dev, enum rf90_radio_path eRFPath,
@@ -256,7 +254,6 @@ void rtl8192_phy_SetRFReg(struct net_device *dev, enum rf90_radio_path eRFPath,
                } else
                        rtl8192_phy_RFSerialWrite(dev, eRFPath, RegAddr, Data);
        }
-       return;
 }
 
 u32 rtl8192_phy_QueryRFReg(struct net_device *dev, enum rf90_radio_path eRFPath,
@@ -307,7 +304,7 @@ static u32 phy_FwRFSerialRead(struct net_device *dev,
        }
        return read_nic_dword(dev, RF_DATA);
 
-}      /* phy_FwRFSerialRead */
+}
 
 static void phy_FwRFSerialWrite(struct net_device *dev,
                                enum rf90_radio_path eRFPath,
@@ -328,7 +325,7 @@ static void phy_FwRFSerialWrite(struct net_device *dev,
        }
        write_nic_dword(dev, QPNR, Data);
 
-}      /* phy_FwRFSerialWrite */
+}
 
 
 void rtl8192_phy_configmac(struct net_device *dev)
@@ -348,8 +345,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 +380,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,13 +390,12 @@ 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]);
                }
        }
-       return;
 }
 
 static void rtl8192_InitBBRFRegDef(struct net_device *dev)
@@ -511,8 +507,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 +537,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 +567,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 +626,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]);
 
@@ -638,7 +636,6 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
        RT_TRACE(COMP_INIT, "Default framesync (0x%x) = 0x%x\n",
                rOFDM0_RxDetector3, priv->framesync);
        priv->SifsTime = read_nic_word(dev, SIFS);
-       return;
 }
 
 void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
@@ -692,7 +689,6 @@ void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
                         __func__);
                break;
        }
-       return;
 }
 
 bool rtl8192_phy_RFConfig(struct net_device *dev)
@@ -721,7 +717,6 @@ bool rtl8192_phy_RFConfig(struct net_device *dev)
 
 void rtl8192_phy_updateInitGain(struct net_device *dev)
 {
-       return;
 }
 
 u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev,
@@ -807,11 +802,10 @@ 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;
 }
 
 static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable,
@@ -822,15 +816,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 +876,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 +892,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 +915,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;
                }
 
 
@@ -938,13 +932,11 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
                        }
 
                        if (CurrentCmd && CurrentCmd->CmdID == CmdID_End) {
-                               if ((*stage) == 2) {
+                               if ((*stage) == 2)
                                        return true;
-                               } else {
-                                       (*stage)++;
-                                       (*step) = 0;
-                                       continue;
-                               }
+                               (*stage)++;
+                               (*step) = 0;
+                               continue;
                        }
 
                        if (!CurrentCmd)
@@ -996,7 +988,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 +1012,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 +1052,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 +1075,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 +1097,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 +1138,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 +1169,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 +1197,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 +1239,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 +1304,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 +1330,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 +1357,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 +1376,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 +1452,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 +1497,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 +1516,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 +1526,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 +1555,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 +1576,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 +1599,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 970298b07af7f5b39159bfb543ae72133796dcb9..03eee3d059c6f6b01e8b4e2169e21be2edd559f8 100644 (file)
 #define bOFDMPHY0_End             0xcff
 #define bOFDMPHY1_End             0xdff
 
-/*#define max debug item in each debug page
-#define bMaxItem_FPGA_PHY0        0x9
-#define bMaxItem_FPGA_PHY1        0x3
-#define bMaxItem_PHY_11B          0x16
-#define bMaxItem_OFDM_PHY0        0x29
-#define bMaxItem_OFDM_PHY1        0x0 */
-
 #define bPMACControl              0x0
 #define bWMACControl              0x1
 #define bWNICControl              0x2
index 89ea70b0d3aadd1e23ac130ff7fc7e80c85622f2..41b025e250fed6314835d6f097e421f120f39189 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,21 +115,20 @@ 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 ;
-                       } else {
-                               down(&priv->rtllib->ips_sem);
-                               IPSLeave(dev);
-                               up(&priv->rtllib->ips_sem);
+                               return;
                        }
+                       down(&priv->rtllib->ips_sem);
+                       IPSLeave(dev);
+                       up(&priv->rtllib->ips_sem);
                }
        }
        priv->rtllib->is_set_key = true;
        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 +191,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 +243,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 +253,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 +262,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..352d381b7c4ae56297aaeddfccc193e224b2480b 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,24 +199,23 @@ 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;
 
-       if (u4bPage == 0) {
+       if (u4bPage == 0)
                return 0xff&inb(dev->base_addr + x);
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                                                       &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
 
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       Data = read_nic_io_byte(dev, (x & 0xff));
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-               }
+       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
+                                                            &u1PageMask);
+       if (bIsLegalPage) {
+               u8 u1bPsr = read_nic_io_byte(dev, PSR);
+
+               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
+                                 (u8)u4bPage));
+               Data = read_nic_io_byte(dev, (x & 0xff));
+               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
        }
 
        return Data;
@@ -224,25 +223,22 @@ 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;
 
-       if (u4bPage == 0) {
+       if (u4bPage == 0)
                return inw(dev->base_addr + x);
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                              &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
+       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
+                                                            &u1PageMask);
+       if (bIsLegalPage) {
+               u8 u1bPsr = read_nic_io_byte(dev, PSR);
 
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       Data = read_nic_io_word(dev, (x & 0xff));
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
-
-               }
+               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
+                                 (u8)u4bPage));
+               Data = read_nic_io_word(dev, (x & 0xff));
+               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
        }
 
        return Data;
@@ -250,25 +246,22 @@ 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;
 
-       if (u4bPage == 0) {
+       if (u4bPage == 0)
                return inl(dev->base_addr + x);
-       } else {
-               bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
-                              &u1PageMask);
-               if (bIsLegalPage) {
-                       u8 u1bPsr = read_nic_io_byte(dev, PSR);
-
-                       write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
-                                         (u8)u4bPage));
-                       Data = read_nic_io_dword(dev, (x & 0xff));
-                       write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
+       bIsLegalPage = PlatformIOCheckPageLegalAndGetRegMask(u4bPage,
+                      &u1PageMask);
+       if (bIsLegalPage) {
+               u8 u1bPsr = read_nic_io_byte(dev, PSR);
 
-               }
+               write_nic_io_byte(dev, PSR, ((u1bPsr & u1PageMask) |
+                                 (u8)u4bPage));
+               Data = read_nic_io_dword(dev, (x & 0xff));
+               write_nic_io_byte(dev, PSR, (u1bPsr & u1PageMask));
        }
 
        return Data;
@@ -326,8 +319,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 +331,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 +373,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 +410,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 +423,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 +448,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 +469,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 +514,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 +524,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 +587,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));
@@ -618,7 +608,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
        if (priv->rtllib->state != RTLLIB_LINKED)
                return ret;
 
-       if ((priv->rtllib->iw_mode != IW_MODE_INFRA))
+       if (priv->rtllib->iw_mode != IW_MODE_INFRA)
                return ret;
 
        if (network->flags & NETWORK_HAS_QOS_MASK) {
@@ -634,8 +624,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 +633,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;
@@ -679,7 +669,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv,
        if (priv->rtllib->state != RTLLIB_LINKED)
                return 0;
 
-       if ((priv->rtllib->iw_mode != IW_MODE_INFRA))
+       if (priv->rtllib->iw_mode != IW_MODE_INFRA)
                return 0;
 
        spin_lock_irqsave(&priv->rtllib->lock, flags);
@@ -751,8 +741,6 @@ static void rtl8192_prepare_beacon(struct r8192_priv *priv)
        priv->ops->tx_fill_descriptor(dev, pdesc, tcb_desc, pnewskb);
        __skb_queue_tail(&ring->queue, pnewskb);
        pdesc->OWN = 1;
-
-       return;
 }
 
 static void rtl8192_stop_beacon(struct net_device *dev)
@@ -866,7 +854,6 @@ static void rtl8192_refresh_supportrate(struct r8192_priv *priv)
        } else {
                memset(ieee->Regdot11HTOperationalRateSet, 0, 16);
        }
-       return;
 }
 
 static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev)
@@ -909,8 +896,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 +1013,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 +1201,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 +1267,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,15 +1319,15 @@ 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;
-               RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq);
        }
 
+       priv->irq = dev->irq;
+       RT_TRACE(COMP_INIT, "IRQ %d\n", dev->irq);
+
        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 +1347,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 +1396,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 +1446,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 +1497,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 +1509,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 +1524,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 +1532,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 +1645,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 +1665,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 +1731,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 +1789,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 +1878,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;
@@ -1902,8 +1898,6 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
                                                 priv->rtllib->tx_headroom);
                priv->rtllib->stats.tx_packets++;
        }
-
-       return;
 }
 
 int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -1916,7 +1910,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;
                }
@@ -1926,17 +1920,16 @@ int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (queue_index == TXCMD_QUEUE) {
                rtl8192_tx_cmd(dev, skb);
                return 0;
-       } else {
-               tcb_desc->RATRIndex = 7;
-               tcb_desc->bTxDisableRateFallBack = 1;
-               tcb_desc->bTxUseDriverAssingedRate = 1;
-               tcb_desc->bTxEnableFwCalcDur = 1;
-               skb_push(skb, priv->rtllib->tx_headroom);
-               ret = rtl8192_tx(dev, skb);
-               if (ret != 0)
-                       kfree_skb(skb);
        }
 
+       tcb_desc->RATRIndex = 7;
+       tcb_desc->bTxDisableRateFallBack = 1;
+       tcb_desc->bTxUseDriverAssingedRate = 1;
+       tcb_desc->bTxEnableFwCalcDur = 1;
+       skb_push(skb, priv->rtllib->tx_headroom);
+       ret = rtl8192_tx(dev, skb);
+       if (ret != 0)
+               kfree_skb(skb);
        return ret;
 }
 
@@ -1987,8 +1980,6 @@ void rtl8192_tx_cmd(struct net_device *dev, struct sk_buff *skb)
 
        __skb_queue_tail(&ring->queue, skb);
        spin_unlock_irqrestore(&priv->irq_th_lock, flags);
-
-       return;
 }
 
 short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
@@ -2007,9 +1998,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 +2037,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);
@@ -2332,76 +2323,74 @@ static void rtl8192_rx_normal(struct net_device *dev)
                                        [priv->rx_idx[rx_queue_idx]];
                struct sk_buff *skb = priv->rx_buf[rx_queue_idx]
                                      [priv->rx_idx[rx_queue_idx]];
+               struct sk_buff *new_skb;
 
-               if (pdesc->OWN) {
+               if (pdesc->OWN)
                        return;
-               } else {
-                       struct sk_buff *new_skb;
-
-                       if (!priv->ops->rx_query_status_descriptor(dev, &stats,
-                       pdesc, skb))
-                               goto done;
-                       new_skb = dev_alloc_skb(priv->rxbuffersize);
-                       /* if allocation of new skb failed - drop current packet
-                       * and reuse skb */
-                       if (unlikely(!new_skb))
-                               goto done;
-
-                       pci_unmap_single(priv->pdev,
-                                       *((dma_addr_t *)skb->cb),
-                                       priv->rxbuffersize,
-                                       PCI_DMA_FROMDEVICE);
-
-                       skb_put(skb, pdesc->Length);
-                       skb_reserve(skb, stats.RxDrvInfoSize +
-                               stats.RxBufShift);
-                       skb_trim(skb, skb->len - 4/*sCrcLng*/);
-                       rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data;
-                       if (!is_multicast_ether_addr(rtllib_hdr->addr1)) {
-                               /* unicast packet */
-                               unicast_packet = true;
-                       }
-                       fc = le16_to_cpu(rtllib_hdr->frame_ctl);
-                       type = WLAN_FC_GET_TYPE(fc);
-                       if (type == RTLLIB_FTYPE_MGMT)
-                               bLedBlinking = false;
-
-                       if (bLedBlinking)
-                               if (priv->rtllib->LedControlHandler)
-                                       priv->rtllib->LedControlHandler(dev,
-                                                               LED_CTL_RX);
-
-                       if (stats.bCRC) {
-                               if (type != RTLLIB_FTYPE_MGMT)
-                                       priv->stats.rxdatacrcerr++;
-                               else
-                                       priv->stats.rxmgmtcrcerr++;
-                       }
-
-                       skb_len = skb->len;
+               if (!priv->ops->rx_query_status_descriptor(dev, &stats,
+               pdesc, skb))
+                       goto done;
+               new_skb = dev_alloc_skb(priv->rxbuffersize);
+               /* if allocation of new skb failed - drop current packet
+                * and reuse skb
+                */
+               if (unlikely(!new_skb))
+                       goto done;
+
+               pci_unmap_single(priv->pdev,
+                               *((dma_addr_t *)skb->cb),
+                               priv->rxbuffersize,
+                               PCI_DMA_FROMDEVICE);
+
+               skb_put(skb, pdesc->Length);
+               skb_reserve(skb, stats.RxDrvInfoSize +
+                       stats.RxBufShift);
+               skb_trim(skb, skb->len - 4/*sCrcLng*/);
+               rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data;
+               if (!is_multicast_ether_addr(rtllib_hdr->addr1)) {
+                       /* unicast packet */
+                       unicast_packet = true;
+               }
+               fc = le16_to_cpu(rtllib_hdr->frame_ctl);
+               type = WLAN_FC_GET_TYPE(fc);
+               if (type == RTLLIB_FTYPE_MGMT)
+                       bLedBlinking = false;
+
+               if (bLedBlinking)
+                       if (priv->rtllib->LedControlHandler)
+                               priv->rtllib->LedControlHandler(dev,
+                                                       LED_CTL_RX);
+
+               if (stats.bCRC) {
+                       if (type != RTLLIB_FTYPE_MGMT)
+                               priv->stats.rxdatacrcerr++;
+                       else
+                               priv->stats.rxmgmtcrcerr++;
+               }
 
-                       if (!rtllib_rx(priv->rtllib, skb, &stats)) {
-                               dev_kfree_skb_any(skb);
-                       } else {
-                               priv->stats.rxok++;
-                               if (unicast_packet)
-                                       priv->stats.rxbytesunicast += skb_len;
-                       }
+               skb_len = skb->len;
 
-                       skb = new_skb;
-                       skb->dev = dev;
+               if (!rtllib_rx(priv->rtllib, skb, &stats)) {
+                       dev_kfree_skb_any(skb);
+               } else {
+                       priv->stats.rxok++;
+                       if (unicast_packet)
+                               priv->stats.rxbytesunicast += skb_len;
+               }
 
-                       priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] =
-                                                                        skb;
-                       *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev,
-                                                   skb_tail_pointer_rsl(skb),
-                                                   priv->rxbuffersize,
-                                                   PCI_DMA_FROMDEVICE);
-                       if (pci_dma_mapping_error(priv->pdev,
-                                                 *((dma_addr_t *)skb->cb))) {
-                               dev_kfree_skb_any(skb);
-                               return;
-                       }
+               skb = new_skb;
+               skb->dev = dev;
+
+               priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] =
+                                                                skb;
+               *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev,
+                                           skb_tail_pointer_rsl(skb),
+                                           priv->rxbuffersize,
+                                           PCI_DMA_FROMDEVICE);
+               if (pci_dma_mapping_error(priv->pdev,
+                                         *((dma_addr_t *)skb->cb))) {
+                       dev_kfree_skb_any(skb);
+                       return;
                }
 done:
                pdesc->BufferAddress = *((dma_addr_t *)skb->cb);
@@ -2567,7 +2556,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 +2858,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 +2892,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 +2931,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 +2972,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 +2995,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 +3023,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 +3050,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 +3064,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 +3096,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..df4bbcf38bae90c975cd96f8d1cc0b41d705b6aa 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;
        }
@@ -378,19 +378,16 @@ static void dm_bandwidth_autoswitch(struct net_device *dev)
        struct r8192_priv *priv = rtllib_priv(dev);
 
        if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ||
-          !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) {
+          !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable)
                return;
+       if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) {
+               if (priv->undecorated_smoothed_pwdb <=
+                   priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
+                       priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true;
        } else {
-               if (priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz == false) {
-                       if (priv->undecorated_smoothed_pwdb <=
-                           priv->rtllib->bandwidth_auto_switch.threshold_40Mhzto20Mhz)
-                               priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = true;
-               } else {
-                       if (priv->undecorated_smoothed_pwdb >=
-                           priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
-                               priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false;
-
-               }
+               if (priv->undecorated_smoothed_pwdb >=
+                   priv->rtllib->bandwidth_auto_switch.threshold_20Mhzto40Mhz)
+                       priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz = false;
        }
 }
 
@@ -501,7 +498,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                                        write_nic_byte(dev, FW_Busy_Flag, 0);
                                        return;
                                }
-                               if ((priv->rtllib->eRFPowerState != eRfOn)) {
+                               if (priv->rtllib->eRFPowerState != eRfOn) {
                                        RT_TRACE(COMP_POWER_TRACKING,
                                                 "we are in power save, so return\n");
                                        write_nic_byte(dev, Pw_Track_Flag, 0);
@@ -581,148 +578,148 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
                                         "priv->CCKPresentAttentuation = %d\n",
                                         priv->CCKPresentAttentuation);
                                return;
-                       } else {
-                               if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) {
-                                       if (RF_Type == RF_2T4R) {
-
-                                               if ((priv->rfa_txpowertrackingindex > 0) &&
-                                                   (priv->rfc_txpowertrackingindex > 0)) {
-                                                       priv->rfa_txpowertrackingindex--;
-                                                       if (priv->rfa_txpowertrackingindex_real > 4) {
-                                                               priv->rfa_txpowertrackingindex_real--;
-                                                               rtl8192_setBBreg(dev,
-                                                                        rOFDM0_XATxIQImbalance,
-                                                                        bMaskDWord,
-                                                                        priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
-                                                       }
-
-                                                       priv->rfc_txpowertrackingindex--;
-                                                       if (priv->rfc_txpowertrackingindex_real > 4) {
-                                                               priv->rfc_txpowertrackingindex_real--;
-                                                               rtl8192_setBBreg(dev,
-                                                                        rOFDM0_XCTxIQImbalance,
-                                                                        bMaskDWord,
-                                                                        priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
-                                                       }
-                                               } else {
-                                                       rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
-                                                                        bMaskDWord,
-                                                                        priv->txbbgain_table[4].txbbgain_value);
-                                                       rtl8192_setBBreg(dev,
-                                                                        rOFDM0_XCTxIQImbalance,
-                                                                        bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
-                                               }
-                                       } else {
-                                               if (priv->rfa_txpowertrackingindex > 0) {
-                                                       priv->rfa_txpowertrackingindex--;
-                                                       if (priv->rfa_txpowertrackingindex_real > 4) {
-                                                               priv->rfa_txpowertrackingindex_real--;
-                                                               rtl8192_setBBreg(dev,
-                                                                                rOFDM0_XATxIQImbalance,
-                                                                                bMaskDWord,
-                                                                                priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
-                                                       }
-                                               } else
-                                                       rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
-                                                                        bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
+                       }
+                       if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) {
+                               if (RF_Type == RF_2T4R) {
 
-                                       }
-                               } else {
-                                       if (RF_Type == RF_2T4R) {
-                                               if ((priv->rfa_txpowertrackingindex <
-                                                   TxBBGainTableLength - 1) &&
-                                                   (priv->rfc_txpowertrackingindex <
-                                                   TxBBGainTableLength - 1)) {
-                                                       priv->rfa_txpowertrackingindex++;
-                                                       priv->rfa_txpowertrackingindex_real++;
+                                       if ((priv->rfa_txpowertrackingindex > 0) &&
+                                           (priv->rfc_txpowertrackingindex > 0)) {
+                                               priv->rfa_txpowertrackingindex--;
+                                               if (priv->rfa_txpowertrackingindex_real > 4) {
+                                                       priv->rfa_txpowertrackingindex_real--;
                                                        rtl8192_setBBreg(dev,
                                                                 rOFDM0_XATxIQImbalance,
                                                                 bMaskDWord,
-                                                                priv->txbbgain_table
-                                                                [priv->rfa_txpowertrackingindex_real].txbbgain_value);
-                                                       priv->rfc_txpowertrackingindex++;
-                                                       priv->rfc_txpowertrackingindex_real++;
+                                                                priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
+                                               }
+
+                                               priv->rfc_txpowertrackingindex--;
+                                               if (priv->rfc_txpowertrackingindex_real > 4) {
+                                                       priv->rfc_txpowertrackingindex_real--;
                                                        rtl8192_setBBreg(dev,
                                                                 rOFDM0_XCTxIQImbalance,
                                                                 bMaskDWord,
                                                                 priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
-                                               } else {
-                                                       rtl8192_setBBreg(dev,
-                                                                rOFDM0_XATxIQImbalance,
-                                                                bMaskDWord,
-                                                                priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
-                                                       rtl8192_setBBreg(dev,
-                                                                rOFDM0_XCTxIQImbalance,
-                                                                bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
                                                }
                                        } else {
-                                               if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
-                                                       priv->rfa_txpowertrackingindex++;
-                                                       priv->rfa_txpowertrackingindex_real++;
-                                                       rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+                                               rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+                                                                bMaskDWord,
+                                                                priv->txbbgain_table[4].txbbgain_value);
+                                               rtl8192_setBBreg(dev,
+                                                                rOFDM0_XCTxIQImbalance,
+                                                                bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
+                                       }
+                               } else {
+                                       if (priv->rfa_txpowertrackingindex > 0) {
+                                               priv->rfa_txpowertrackingindex--;
+                                               if (priv->rfa_txpowertrackingindex_real > 4) {
+                                                       priv->rfa_txpowertrackingindex_real--;
+                                                       rtl8192_setBBreg(dev,
+                                                                        rOFDM0_XATxIQImbalance,
                                                                         bMaskDWord,
                                                                         priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
-                                               } else
-                                                       rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
-                                                                        bMaskDWord,
-                                                                        priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
-                                       }
+                                               }
+                                       } else
+                                               rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+                                                                bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
+
                                }
+                       } else {
                                if (RF_Type == RF_2T4R) {
-                                       priv->CCKPresentAttentuation_difference
-                                               = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
+                                       if ((priv->rfa_txpowertrackingindex <
+                                           TxBBGainTableLength - 1) &&
+                                           (priv->rfc_txpowertrackingindex <
+                                           TxBBGainTableLength - 1)) {
+                                               priv->rfa_txpowertrackingindex++;
+                                               priv->rfa_txpowertrackingindex_real++;
+                                               rtl8192_setBBreg(dev,
+                                                        rOFDM0_XATxIQImbalance,
+                                                        bMaskDWord,
+                                                        priv->txbbgain_table
+                                                        [priv->rfa_txpowertrackingindex_real].txbbgain_value);
+                                               priv->rfc_txpowertrackingindex++;
+                                               priv->rfc_txpowertrackingindex_real++;
+                                               rtl8192_setBBreg(dev,
+                                                        rOFDM0_XCTxIQImbalance,
+                                                        bMaskDWord,
+                                                        priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
+                                       } else {
+                                               rtl8192_setBBreg(dev,
+                                                        rOFDM0_XATxIQImbalance,
+                                                        bMaskDWord,
+                                                        priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
+                                               rtl8192_setBBreg(dev,
+                                                        rOFDM0_XCTxIQImbalance,
+                                                        bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
+                                       }
                                } else {
-                                       priv->CCKPresentAttentuation_difference
-                                               = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default;
-                               }
-
-                               if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
-                                       priv->CCKPresentAttentuation =
-                                                priv->CCKPresentAttentuation_20Mdefault +
-                                                priv->CCKPresentAttentuation_difference;
-                               else
-                                       priv->CCKPresentAttentuation =
-                                                priv->CCKPresentAttentuation_40Mdefault +
-                                                priv->CCKPresentAttentuation_difference;
-
-                               if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1))
-                                       priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1;
-                               if (priv->CCKPresentAttentuation < 0)
-                                       priv->CCKPresentAttentuation = 0;
-
-                               if (priv->CCKPresentAttentuation > -1 &&
-                                   priv->CCKPresentAttentuation < CCKTxBBGainTableLength) {
-                                       if (priv->rtllib->current_network.channel == 14 &&
-                                           !priv->bcck_in_ch14) {
-                                               priv->bcck_in_ch14 = true;
-                                               dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
-                                       } else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) {
-                                               priv->bcck_in_ch14 = false;
-                                               dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+                                       if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
+                                               priv->rfa_txpowertrackingindex++;
+                                               priv->rfa_txpowertrackingindex_real++;
+                                               rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+                                                                bMaskDWord,
+                                                                priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
                                        } else
-                                               dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+                                               rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+                                                                bMaskDWord,
+                                                                priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
                                }
-                               RT_TRACE(COMP_POWER_TRACKING,
-                                        "priv->rfa_txpowertrackingindex = %d\n",
-                                        priv->rfa_txpowertrackingindex);
-                               RT_TRACE(COMP_POWER_TRACKING,
-                                        "priv->rfa_txpowertrackingindex_real = %d\n",
-                                        priv->rfa_txpowertrackingindex_real);
-                               RT_TRACE(COMP_POWER_TRACKING,
-                                        "priv->CCKPresentAttentuation_difference = %d\n",
-                                        priv->CCKPresentAttentuation_difference);
-                               RT_TRACE(COMP_POWER_TRACKING,
-                                        "priv->CCKPresentAttentuation = %d\n",
-                                        priv->CCKPresentAttentuation);
+                       }
+                       if (RF_Type == RF_2T4R) {
+                               priv->CCKPresentAttentuation_difference
+                                       = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
+                       } else {
+                               priv->CCKPresentAttentuation_difference
+                                       = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default;
+                       }
 
-                               if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) {
-                                       priv->rtllib->bdynamic_txpower_enable = true;
-                                       write_nic_byte(dev, Pw_Track_Flag, 0);
-                                       write_nic_byte(dev, FW_Busy_Flag, 0);
-                                       RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
-                                       return;
-                               }
+                       if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20)
+                               priv->CCKPresentAttentuation =
+                                        priv->CCKPresentAttentuation_20Mdefault +
+                                        priv->CCKPresentAttentuation_difference;
+                       else
+                               priv->CCKPresentAttentuation =
+                                        priv->CCKPresentAttentuation_40Mdefault +
+                                        priv->CCKPresentAttentuation_difference;
+
+                       if (priv->CCKPresentAttentuation > (CCKTxBBGainTableLength-1))
+                               priv->CCKPresentAttentuation = CCKTxBBGainTableLength-1;
+                       if (priv->CCKPresentAttentuation < 0)
+                               priv->CCKPresentAttentuation = 0;
+
+                       if (priv->CCKPresentAttentuation > -1 &&
+                           priv->CCKPresentAttentuation < CCKTxBBGainTableLength) {
+                               if (priv->rtllib->current_network.channel == 14 &&
+                                   !priv->bcck_in_ch14) {
+                                       priv->bcck_in_ch14 = true;
+                                       dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+                               } else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) {
+                                       priv->bcck_in_ch14 = false;
+                                       dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+                               } else
+                                       dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+                       }
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->rfa_txpowertrackingindex = %d\n",
+                                priv->rfa_txpowertrackingindex);
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->rfa_txpowertrackingindex_real = %d\n",
+                                priv->rfa_txpowertrackingindex_real);
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->CCKPresentAttentuation_difference = %d\n",
+                                priv->CCKPresentAttentuation_difference);
+                       RT_TRACE(COMP_POWER_TRACKING,
+                                "priv->CCKPresentAttentuation = %d\n",
+                                priv->CCKPresentAttentuation);
+
+                       if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) {
+                               priv->rtllib->bdynamic_txpower_enable = true;
+                               write_nic_byte(dev, Pw_Track_Flag, 0);
+                               write_nic_byte(dev, FW_Busy_Flag, 0);
+                               RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
+                               return;
                        }
+
                        write_nic_byte(dev, Pw_Track_Flag, 0);
                        Avg_TSSI_Meas_from_driver = 0;
                        for (k = 0; k < 5; k++)
@@ -757,8 +754,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 +800,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 &&
@@ -1401,13 +1398,12 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
                TxPowerCheckCnt = 5;
        else
                TxPowerCheckCnt = 2;
-       if (!priv->btxpower_tracking) {
+       if (!priv->btxpower_tracking)
+               return;
+
+       if (priv->txpower_count  <= TxPowerCheckCnt) {
+               priv->txpower_count++;
                return;
-       } else {
-               if (priv->txpower_count  <= TxPowerCheckCnt) {
-                       priv->txpower_count++;
-                       return;
-               }
        }
 
        if (!TM_Trigger) {
@@ -1419,14 +1415,12 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
                }
                TM_Trigger = 1;
                return;
-       } else {
-           printk(KERN_INFO "===============>Schedule TxPowerTrackingWorkItem\n");
-
-               queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0);
-               TM_Trigger = 0;
-               }
-
        }
+       netdev_info(dev, "===============>Schedule TxPowerTrackingWorkItem\n");
+       queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0);
+       TM_Trigger = 0;
+
+}
 
 static void dm_check_txpower_tracking(struct net_device *dev)
 {
@@ -1446,7 +1440,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 +1449,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 +1463,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 +1479,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 +1491,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 +1511,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 +1563,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;
        }
@@ -1830,12 +1824,11 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
        if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_low_thresh) &&
                (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_thresh))
                return;
-       if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh)) {
+       if (priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh) {
                if (dm_digtable.dig_state == DM_STA_DIG_OFF &&
                        (priv->reset_count == reset_cnt))
                        return;
-               else
-                       reset_cnt = priv->reset_count;
+               reset_cnt = priv->reset_count;
 
                dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
                dm_digtable.dig_state = DM_STA_DIG_OFF;
@@ -1857,19 +1850,18 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
                return;
        }
 
-       if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)) {
+       if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) {
                u8 reset_flag = 0;
 
                if (dm_digtable.dig_state == DM_STA_DIG_ON &&
                    (priv->reset_count == reset_cnt)) {
                        dm_ctrl_initgain_byrssi_highpwr(dev);
                        return;
-               } else {
-                       if (priv->reset_count != reset_cnt)
-                               reset_flag = 1;
-
-                       reset_cnt = priv->reset_count;
                }
+               if (priv->reset_count != reset_cnt)
+                       reset_flag = 1;
+
+               reset_cnt = priv->reset_count;
 
                dm_digtable.dig_state = DM_STA_DIG_ON;
 
@@ -1911,8 +1903,7 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev)
                if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON &&
                        (priv->reset_count == reset_cnt_highpwr))
                        return;
-               else
-                       dm_digtable.dig_highpwr_state = DM_STA_DIG_ON;
+               dm_digtable.dig_highpwr_state = DM_STA_DIG_ON;
 
                if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
                                write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x10);
@@ -1922,8 +1913,7 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev)
                if (dm_digtable.dig_highpwr_state == DM_STA_DIG_OFF &&
                        (priv->reset_count == reset_cnt_highpwr))
                        return;
-               else
-                       dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF;
+               dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF;
 
                if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh &&
                         priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) {
@@ -2008,7 +1998,7 @@ static void dm_pd_th(struct net_device *dev)
                if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) {
                        if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh)
                                dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER;
-                       else if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
+                       else if (dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)
                                dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
                        else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) &&
                                        (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh))
@@ -2065,9 +2055,9 @@ static    void dm_cs_ratio(struct net_device *dev)
 
        if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) {
                if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) {
-                       if ((dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh))
+                       if (dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)
                                dm_digtable.curcs_ratio_state = DIG_CS_RATIO_LOWER;
-                       else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh))
+                       else if (dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh)
                                dm_digtable.curcs_ratio_state = DIG_CS_RATIO_HIGHER;
                        else
                                dm_digtable.curcs_ratio_state = dm_digtable.precs_ratio_state;
@@ -2131,10 +2121,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 +2628,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 +2656,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 +2676,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 +2754,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 +2770,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..0bbffec0c2ae2eca8f49c05fa21d8cc4f1a8adbd 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;
        }
@@ -201,12 +202,11 @@ void rtllib_ips_leave_wq(struct net_device *dev)
                                RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
                                         __func__);
                                return;
-                       } else {
-                               printk(KERN_INFO "=========>%s(): IPSLeave\n",
-                                      __func__);
-                               queue_work_rsl(priv->rtllib->wq,
-                                              &priv->rtllib->ips_leave_wq);
                        }
+                       netdev_info(dev, "=========>%s(): IPSLeave\n",
+                                   __func__);
+                       queue_work_rsl(priv->rtllib->wq,
+                                      &priv->rtllib->ips_leave_wq);
                }
        }
 }
@@ -239,8 +239,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 +255,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 +271,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 +301,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..8d6a109e023bd8d82e8a5239f113c89ee0722b6d 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);
@@ -343,13 +346,12 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
                                                 __func__);
                                        up(&priv->wx_sem);
                                        return -1;
-                               } else {
-                                       printk(KERN_INFO "=========>%s(): "
-                                              "IPSLeave\n", __func__);
-                                       down(&priv->rtllib->ips_sem);
-                                       IPSLeave(dev);
-                                       up(&priv->rtllib->ips_sem);
                                }
+                               netdev_info(dev,  "=========>%s(): IPSLeave\n",
+                                           __func__);
+                               down(&priv->rtllib->ips_sem);
+                               IPSLeave(dev);
+                               up(&priv->rtllib->ips_sem);
                        }
                }
        }
@@ -470,9 +472,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,17 +502,17 @@ 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__);
-                                       down(&priv->rtllib->ips_sem);
-                                       IPSLeave(dev);
-                                       up(&priv->rtllib->ips_sem);
                                }
+                               RT_TRACE(COMP_PS, "=========>%s(): IPSLeave\n",
+                                        __func__);
+                               down(&priv->rtllib->ips_sem);
+                               IPSLeave(dev);
+                               up(&priv->rtllib->ips_sem);
                        }
                }
                rtllib_stop_scan(priv->rtllib);
@@ -552,7 +554,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 +574,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 +641,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 +668,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 +707,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 +757,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 +829,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 +847,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 +865,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 +948,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 +975,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 +1056,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 +1074,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 +1091,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 +1152,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;
        }
@@ -1227,11 +1221,10 @@ static iw_handler r8192_wx_handlers[] = {
        IW_IOCTL(SIOCSIWENCODEEXT) = r8192_wx_set_enc_ext,
 };
 
-/*
- * the following rule need to be following,
+/* the following rule need to be following,
  * Odd : get (world access),
  * even : set (root access)
- * */
+ */
 static const struct iw_priv_args r8192_private_args[] = {
        {
                SIOCIWFIRSTPRIV + 0x0,
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..7f103114d5d2a3dddc220074b464ced812dec360 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;
@@ -289,25 +135,22 @@ u16  TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate)
        u8      is40MHz = 0;
        u8      isShortGI = 0;
 
-       if (nDataRate < 12) {
+       if (nDataRate < 12)
                return CCKOFDMRate[nDataRate];
-       } else {
-               if (nDataRate >= 0x10 && nDataRate <= 0x1f) {
-                       is40MHz = 0;
-                       isShortGI = 0;
-               } else if (nDataRate >= 0x20  && nDataRate <= 0x2f) {
-                       is40MHz = 1;
-                       isShortGI = 0;
-
-               } else if (nDataRate >= 0x30  && nDataRate <= 0x3f) {
-                       is40MHz = 0;
-                       isShortGI = 1;
-               } else if (nDataRate >= 0x40  && nDataRate <= 0x4f) {
-                       is40MHz = 1;
-                       isShortGI = 1;
-               }
-               return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
+       if (nDataRate >= 0x10 && nDataRate <= 0x1f) {
+               is40MHz = 0;
+               isShortGI = 0;
+       } else if (nDataRate >= 0x20  && nDataRate <= 0x2f) {
+               is40MHz = 1;
+               isShortGI = 0;
+       } else if (nDataRate >= 0x30  && nDataRate <= 0x3f) {
+               is40MHz = 0;
+               isShortGI = 1;
+       } else if (nDataRate >= 0x40  && nDataRate <= 0x4f) {
+               is40MHz = 1;
+               isShortGI = 1;
        }
+       return MCS_DATA_RATE[is40MHz][isShortGI][nDataRate&0xf];
 }
 
 bool IsHTHalfNmodeAPs(struct rtllib_device *ieee)
@@ -386,9 +229,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 +291,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 +328,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 +373,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 +413,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 +437,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 +472,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 +495,7 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
                                            HTMcsToDataRate(ieee, mcsRate))
                                                mcsRate = (8*i+j);
                                }
-                               bitMap = bitMap>>1;
+                               bitMap >>= 1;
                        }
                }
        }
@@ -697,8 +538,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");
@@ -878,7 +719,8 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
 
        RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__);
        /* unmark bEnableHT flag here is the same reason why unmarked in
-        * function rtllib_softmac_new_net. WB 2008.09.10*/
+        * function rtllib_softmac_new_net. WB 2008.09.10
+        */
        if (pNetwork->bssht.bdSupportHT) {
                pHTInfo->bCurrentHTSupport = true;
                pHTInfo->ePeerHTSpecVer = pNetwork->bssht.bdHTSpecVer;
@@ -999,8 +841,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..7d77d056228d35fa3690421ac1cd37119ccf11a3 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,
@@ -311,18 +311,24 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
           u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs)
 {
        u8      UP = 0;
+       union tspec_body TSpec;
+       union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo;
+       struct list_head *pUnusedList;
+       struct list_head *pAddmitList;
+       enum direction_value Dir;
 
        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;
                }
 
@@ -347,77 +353,70 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
        }
 
        *ppTS = SearchAdmitTRStream(ieee, Addr, UP, TxRxSelect);
-       if (*ppTS != NULL) {
+       if (*ppTS != NULL)
                return true;
-       } else {
-               if (!bAddNewTs) {
-                       RTLLIB_DEBUG(RTLLIB_DL_TS, "add new TS failed"
-                                    "(tid:%d)\n", UP);
-                       return false;
-               } else {
-                       union tspec_body TSpec;
-                       union qos_tsinfo *pTSInfo = &TSpec.f.TSInfo;
-                       struct list_head *pUnusedList =
-                               (TxRxSelect == TX_DIR) ?
+
+       if (!bAddNewTs) {
+               RTLLIB_DEBUG(RTLLIB_DL_TS,
+                            "add new TS failed(tid:%d)\n", UP);
+               return false;
+       }
+
+       pUnusedList = (TxRxSelect == TX_DIR) ?
                                (&ieee->Tx_TS_Unused_List) :
                                (&ieee->Rx_TS_Unused_List);
 
-                       struct list_head *pAddmitList =
-                               (TxRxSelect == TX_DIR) ?
+       pAddmitList = (TxRxSelect == TX_DIR) ?
                                (&ieee->Tx_TS_Admit_List) :
                                (&ieee->Rx_TS_Admit_List);
 
-                       enum direction_value Dir =
-                                (ieee->iw_mode == IW_MODE_MASTER) ?
-                                ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) :
-                                ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN);
-                       RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n");
-                       if (!list_empty(pUnusedList)) {
-                               (*ppTS) = list_entry(pUnusedList->next,
-                                         struct ts_common_info, List);
-                               list_del_init(&(*ppTS)->List);
-                               if (TxRxSelect == TX_DIR) {
-                                       struct tx_ts_record *tmp =
-                                               container_of(*ppTS,
-                                               struct tx_ts_record,
-                                               TsCommonInfo);
-                                       ResetTxTsEntry(tmp);
-                               } else {
-                                       struct rx_ts_record *tmp =
-                                                container_of(*ppTS,
-                                                struct rx_ts_record,
-                                                TsCommonInfo);
-                                       ResetRxTsEntry(tmp);
-                               }
-
-                               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;
-                               pTSInfo->field.ucAccessPolicy = 1;
-                               pTSInfo->field.ucAggregation = 0;
-                               pTSInfo->field.ucPSB = 0;
-                               pTSInfo->field.ucUP = UP;
-                               pTSInfo->field.ucTSInfoAckPolicy = 0;
-                               pTSInfo->field.ucSchedule = 0;
-
-                               MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
-                               AdmitTS(ieee, *ppTS, 0);
-                               list_add_tail(&((*ppTS)->List), pAddmitList);
-
-                               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);
-                               return false;
-                       }
+       Dir = (ieee->iw_mode == IW_MODE_MASTER) ?
+                               ((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) :
+                               ((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN);
+
+       RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n");
+       if (!list_empty(pUnusedList)) {
+               (*ppTS) = list_entry(pUnusedList->next,
+                         struct ts_common_info, List);
+               list_del_init(&(*ppTS)->List);
+               if (TxRxSelect == TX_DIR) {
+                       struct tx_ts_record *tmp =
+                               container_of(*ppTS,
+                               struct tx_ts_record,
+                               TsCommonInfo);
+                       ResetTxTsEntry(tmp);
+               } else {
+                       struct rx_ts_record *tmp =
+                                container_of(*ppTS,
+                                struct rx_ts_record,
+                                TsCommonInfo);
+                       ResetRxTsEntry(tmp);
                }
+
+               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;
+               pTSInfo->field.ucAccessPolicy = 1;
+               pTSInfo->field.ucAggregation = 0;
+               pTSInfo->field.ucPSB = 0;
+               pTSInfo->field.ucUP = UP;
+               pTSInfo->field.ucTSInfoAckPolicy = 0;
+               pTSInfo->field.ucSchedule = 0;
+
+               MakeTSEntry(*ppTS, Addr, &TSpec, NULL, 0, 0);
+               AdmitTS(ieee, *ppTS, 0);
+               list_add_tail(&((*ppTS)->List), pAddmitList);
+
+               return true;
        }
+
+       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;
 }
 
 static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs,
@@ -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..3c8b708df5c37a975a9238874d800f90afecab38 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)
-
-
 #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
 #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
 
@@ -482,9 +465,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,17 +505,17 @@ 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
 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
-   6.2.1.1.2.
-
-   The figure in section 7.1.2 suggests a body size of up to 2312
-   bytes is allowed, which is a bit confusing, I suspect this
-   represents the 2304 bytes of real data, plus a possible 8 bytes of
-   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
+ * 6.2.1.1.2.
+ *
+ * The figure in section 7.1.2 suggests a body size of up to 2312
+ * bytes is allowed, which is a bit confusing, I suspect this
+ * represents the 2304 bytes of real data, plus a possible 8 bytes of
+ * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro)
+ */
 #define RTLLIB_1ADDR_LEN 10
 #define RTLLIB_2ADDR_LEN 16
 #define RTLLIB_3ADDR_LEN 24
@@ -711,20 +691,13 @@ do {                                                              \
 #define RTLLIB_DEBUG_DATA(level, data, datalen)        \
        do {                                                    \
                if ((rtllib_debug_level & (level)) == (level)) {        \
-                       int i;                                  \
-                       u8 *pdata = (u8 *)data;                 \
                        printk(KERN_DEBUG "rtllib: %s()\n", __func__);  \
-                       for (i = 0; i < (int)(datalen); i++)    {       \
-                               printk("%2.2x ", pdata[i]);             \
-                               if ((i+1)%16 == 0)                      \
-                                       printk("\n");   \
-                       }                               \
-                       printk("\n");                   \
+                       print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \
+                                            data, datalen); \
                }                                       \
        } while (0)
 
-/*
- * To use the debug system;
+/* To use the debug system;
  *
  * If you are defining a new debug classification, simply add it to the #define
  * list here in the form of:
@@ -743,8 +716,6 @@ do {                                                                \
  * % cat /proc/net/ipw/debug_level
  *
  * you simply need to add your entry to the ipw_debug_levels array.
- *
- *
  */
 
 #define RTLLIB_DL_INFO   (1<<0)
@@ -769,8 +740,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 +755,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     */
@@ -1022,7 +973,8 @@ struct rtllib_rx_stats {
 /* IEEE 802.11 requires that STA supports concurrent reception of at least
  * three fragmented frames. This define can be increased to support more
  * concurrent frames, but it should be noted that each entry can consume about
- * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
+ * 2 kB of RAM and increasing cache size will slow down frame reassembly.
+ */
 #define RTLLIB_FRAG_CACHE_LEN 4
 
 struct rtllib_frag_entry {
@@ -1100,16 +1052,15 @@ struct rtllib_security {
 } __packed;
 
 
-/*
- 802.11 data frame from AP
-      ,-------------------------------------------------------------------.
-Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
-      |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
-      |      | tion | (BSSID) |         |       | ence |  data   |      |
-      `-------------------------------------------------------------------'
-Total: 28-2340 bytes
-*/
+/* 802.11 data frame from AP
+ *       ,-------------------------------------------------------------------.
+ * Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
+ *       |------|------|---------|---------|---------|------|---------|------|
+ * Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  frame  |  fcs |
+ *       |      | tion | (BSSID) |         |         | ence |  data   |      |
+ *       `-------------------------------------------------------------------'
+ * Total: 28-2340 bytes
+ */
 
 /* Management Frame Information Element Types */
 enum rtllib_mfie {
@@ -1147,7 +1098,8 @@ enum rtllib_mfie {
 
 /* Minimal header; can be used for passing 802.11 frames with sufficient
  * information to determine what type of underlying data type is actually
- * stored in the data. */
+ * stored in the data.
+ */
 struct rtllib_pspoll_hdr {
        __le16 frame_ctl;
        __le16 aid;
@@ -1257,7 +1209,8 @@ struct rtllib_probe_response {
        __le16 beacon_interval;
        __le16 capability;
        /* SSID, supported rates, FH params, DS params,
-        * CF params, IBSS params, TIM (if beacon), RSN */
+        * CF params, IBSS params, TIM (if beacon), RSN
+        */
        struct rtllib_info_element info_element[0];
 } __packed;
 
@@ -1332,7 +1285,8 @@ union frameqos {
 /* MAX_RATES_LENGTH needs to be 12.  The spec says 8, and many APs
  * only use 8, and then use extended rates for the remaining supported
  * rates.  Other APs, however, stick all of their supported rates on the
- * main rates information element... */
+ * main rates information element...
+ */
 #define MAX_RATES_LENGTH                 ((u8)12)
 #define MAX_RATES_EX_LENGTH           ((u8)16)
 #define MAX_NETWORK_COUNT                96
@@ -1519,22 +1473,21 @@ struct rtllib_info_element_hdr {
        u8 len;
 } __packed;
 
-/*
- * These are the data types that can make up management packets
+/* These are the data types that can make up management packets
  *
      u16 auth_algorithm;
      u16 auth_sequence;
      u16 beacon_interval;
      u16 capability;
      u8 current_ap[ETH_ALEN];
      u16 listen_interval;
      struct {
              u16 association_id:14, reserved:2;
      } __packed;
      u32 time_stamp[2];
      u16 reason;
      u16 status;
-*/
* u16 auth_algorithm;
* u16 auth_sequence;
* u16 beacon_interval;
* u16 capability;
* u8 current_ap[ETH_ALEN];
* u16 listen_interval;
* struct {
*   u16 association_id:14, reserved:2;
* } __packed;
* u32 time_stamp[2];
* u16 reason;
* u16 status;
+ */
 
 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
 #define RTLLIB_DEFAULT_BASIC_RATE 2
@@ -1670,7 +1623,6 @@ struct rtllib_network {
        struct list_head list;
 };
 
-#if 1
 enum rtllib_state {
 
        /* the card is not linked at all */
@@ -1708,17 +1660,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 +1677,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;
@@ -2149,14 +2085,16 @@ struct rtllib_device {
        spinlock_t wpax_suitlist_lock;
 
        int tx_headroom; /* Set to size of any additional room needed at front
-                         * of allocated Tx SKBs */
+                         * of allocated Tx SKBs
+                         */
        u32 config;
 
        /* WEP and other encryption related settings at the device level */
        int open_wep; /* Set to 1 to allow unencrypted frames */
        int auth_mode;
        int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
-                                * WEP key changes */
+                                * WEP key changes
+                                */
 
        /* If the host performs {en,de}cryption, then set to 1 */
        int host_encrypt;
@@ -2276,7 +2214,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;
 
@@ -2426,7 +2364,7 @@ struct rtllib_device {
        /* OK this is complementing to data_poll_hard_stop */
        void (*data_hard_resume)(struct net_device *dev);
 
-       /* ask to the driver to retune the radio .
+       /* ask to the driver to retune the radio.
         * This function can sleep. the driver should ensure
         * the radio has been switched before return.
         */
@@ -2520,7 +2458,8 @@ struct rtllib_device {
        void (*rtllib_rfkill_poll)(struct net_device *dev);
 
        /* This must be the last item so that it points to the data
-        * allocated beyond this structure by alloc_rtllib */
+        * allocated beyond this structure by alloc_rtllib
+        */
        u8 priv[0];
 };
 
@@ -2549,7 +2488,8 @@ struct rtllib_device {
 
 /* The ieee802.11 stack will manage the netif queue
  * wake/stop for the driver, taking care of 802.11
- * fragmentation. See softmac.c for details. */
+ * fragmentation. See softmac.c for details.
+ */
 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
 
 /* Uses only the softmac_data_hard_start_xmit
@@ -2586,11 +2526,9 @@ static inline int rtllib_is_empty_essid(const char *essid, int essid_len)
 
 static inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
 {
-       /*
-        * It is possible for both access points and our device to support
+       /* It is possible for both access points and our device to support
         * combinations of modes, so as long as there is one valid combination
         * of ap/device supported modes, then return success
-        *
         */
        if ((mode & IEEE_A) &&
            (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
@@ -2882,8 +2820,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 +2842,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..1e6ae9bead23318c79f30078fa9f295580acd880 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);
        }
@@ -86,7 +87,8 @@ void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info,
 
        /* must not run ops->deinit() while there may be pending encrypt or
         * decrypt operations. Use a list of delayed deinits to avoid needing
-        * locking. */
+        * locking.
+        */
 
        spin_lock_irqsave(info->lock, flags);
        list_add(&tmp->list, &info->crypt_deinit_list);
@@ -145,8 +147,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 +239,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 e177c9287b44e59284272ad5d1a7f25b502824e5..b8cf59f39a6093e6104776cc8c866064bf29456e 100644 (file)
@@ -17,8 +17,7 @@
  * more details.
  */
 
-/*
- * This file defines the interface to the rtllib crypto module.
+/* This file defines the interface to the rtllib crypto module.
  */
 #ifndef RTLLIB_CRYPT_H
 #define RTLLIB_CRYPT_H
index 01f85db98e0d2091702c8af3d6a0a38be4f1d3bc..7d486e8887f84cd8c3bf8b9538b29195999e07a2 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;
        }
@@ -121,10 +120,7 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
        fc = le16_to_cpu(hdr->frame_ctl);
        a4_included = ((fc & (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS)) ==
                       (RTLLIB_FCTL_TODS | RTLLIB_FCTL_FROMDS));
-       /*
-       qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) &&
-                      (WLAN_FC_GET_STYPE(fc) & 0x08));
-       */
+
        qc_included = ((WLAN_FC_GET_TYPE(fc) == RTLLIB_FTYPE_DATA) &&
                       (WLAN_FC_GET_STYPE(fc) & 0x80));
        aad_len = 22;
@@ -141,7 +137,8 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm,
         * Flag (Include authentication header, M=3 (8-octet MIC),
         *       L=1 (2-octet Dlen))
         * Nonce: 0x00 | A2 | PN
-        * Dlen */
+        * Dlen
+        */
        b0[0] = 0x59;
        b0[1] = qc;
        memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
@@ -278,23 +275,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 +337,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 +415,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..656b4b359c50479098879528c8dd0d1477f5be11 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;
        }
@@ -249,7 +249,8 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
                               u16 IV16)
 {
        /* Make temporary area overlap WEP seed so that the final copy can be
-        * avoided on little endian hosts. */
+        * avoided on little endian hosts.
+        */
        u16 *PPK = (u16 *) &WEPSeed[4];
 
        /* Step 1 - make copy of TTAK and bring in TSC */
@@ -276,7 +277,8 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
        PPK[5] += RotR1(PPK[4]);
 
        /* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value
-        * WEPSeed[0..2] is transmitted as WEP IV */
+        * WEPSeed[0..2] is transmitted as WEP IV
+        */
        WEPSeed[0] = Hi8(IV16);
        WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
        WEPSeed[2] = Lo8(IV16);
@@ -399,22 +401,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 +431,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 +455,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;
@@ -468,12 +472,14 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
                        if (iv32 != tkey->rx_iv32) {
                                /* Previously cached Phase1 result was already
                                 * lost, so it needs to be recalculated for the
-                                * next packet. */
+                                * next packet.
+                                */
                                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;
@@ -482,7 +488,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
        }
 
        /* Update real counters only after Michael MIC verification has
-        * completed */
+        * completed
+        */
        tkey->rx_iv32_new = iv32;
        tkey->rx_iv16_new = iv16;
 
@@ -502,7 +509,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 +564,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 +628,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++;
@@ -636,7 +643,8 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
        }
 
        /* Update TSC counters for RX now that the packet verification has
-        * completed. */
+        * completed.
+        */
        tkey->rx_iv32 = tkey->rx_iv32_new;
        tkey->rx_iv16 = tkey->rx_iv16_new;
 
@@ -717,10 +725,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..21d7eee4c9a92303b480a50c8b715b146bc618b4 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;
@@ -124,7 +121,8 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
        /* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
         * scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
-        * can be used to speedup attacks, so avoid using them. */
+        * can be used to speedup attacks, so avoid using them.
+        */
        if ((wep->iv & 0xff00) == 0xff00) {
                u8 B = (wep->iv >> 16) & 0xff;
 
index 7537dae89a75ac3096970b0d506dcb35aa1e6797..119729d31c74705c0dd5ef8de04e84bb8c016f91 100644 (file)
@@ -80,9 +80,9 @@ 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);
+} while (0)
 
 #endif
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..fe3e7e1273ff82f7e70a367f0b9be22a6bd45833 100644 (file)
@@ -143,7 +143,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
                memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
        } else {
                /* received a fragment of a frame for which the head fragment
-                * should have already been received */
+                * should have already been received
+                */
                entry = rtllib_frag_cache_find(ieee, seq, frag, tid, hdr->addr2,
                                                  hdr->addr1);
                if (entry != NULL) {
@@ -199,7 +200,8 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
  *
  * Responsible for handling management control frames
  *
- * Called by rtllib_rx */
+ * Called by rtllib_rx
+ */
 static inline int
 rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb,
                        struct rtllib_rx_stats *rx_stats, u16 type,
@@ -224,8 +226,9 @@ rtllib_rx_frame_mgmt(struct rtllib_device *ieee, struct sk_buff *skb,
        return 0;
 }
 
-/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
-/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
+/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation
+ * Ethernet-II snap header (RFC1042 for most EtherTypes)
+ */
 static unsigned char rfc1042_header[] = {
        0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00
 };
@@ -394,10 +397,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;
@@ -483,7 +485,8 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
                            ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
                            memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
                                /* remove RFC1042 or Bridge-Tunnel encapsulation
-                                * and replace EtherType */
+                                * and replace EtherType
+                                */
                                skb_pull(sub_skb, SNAP_SIZE);
                                memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
                                memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
@@ -524,7 +527,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;
                }
 
@@ -581,8 +586,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                return;
        }
 
-       /*
-        * Sliding window manipulation. Conditions includes:
+       /* Sliding window manipulation. Conditions includes:
         * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
         * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
         */
@@ -597,13 +601,12 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum);
        }
 
-       /*
-        * Indication process.
+       /* Indication process.
         * After Packet dropping and Sliding Window shifting as above, we can
         * now just indicate the packets with the SeqNum smaller than latest
         * WinStart and struct buffer other packets.
-        */
-       /* For Rx Reorder condition:
+        *
+        * For Rx Reorder condition:
         * 1. All packets with SeqNum smaller than WinStart => Indicate
         * 2. All packets with SeqNum larger than or equal to
         *       WinStart => Buffer it.
@@ -646,8 +649,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                                         pTS->RxIndicateSeq, SeqNum);
                        }
                } else {
-                       /*
-                        * Packets are dropped if there are not enough reorder
+                       /* Packets are dropped if there are not enough reorder
                         * entries. This part should be modified!! We can just
                         * indicate all the packets in struct buffer and get
                         * reorder entries.
@@ -697,7 +699,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
        }
 
        /* Handling pending timer. Set this timer to prevent from long time
-        * Rx buffering.*/
+        * Rx buffering.
+        */
        if (index > 0) {
                if (timer_pending(&pTS->RxPktPendingTimer))
                        del_timer_sync(&pTS->RxPktPendingTimer);
@@ -718,7 +721,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);
 }
@@ -782,69 +785,74 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
                memcpy(rxb->dst, dst, ETH_ALEN);
                rxb->subframes[0]->dev = ieee->dev;
                return 1;
-       } else {
-               rxb->nr_subframes = 0;
-               memcpy(rxb->src, src, ETH_ALEN);
-               memcpy(rxb->dst, dst, ETH_ALEN);
-               while (skb->len > ETHERNET_HEADER_SIZE) {
-                       /* Offset 12 denote 2 mac address */
-                       nSubframe_Length = *((u16 *)(skb->data + 12));
-                       nSubframe_Length = (nSubframe_Length >> 8) +
-                                          (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);
-                               return 0;
-                       }
+       }
 
-                       /* move the data point to data content */
-                       skb_pull(skb, ETHERNET_HEADER_SIZE);
+       rxb->nr_subframes = 0;
+       memcpy(rxb->src, src, ETH_ALEN);
+       memcpy(rxb->dst, dst, ETH_ALEN);
+       while (skb->len > ETHERNET_HEADER_SIZE) {
+               /* Offset 12 denote 2 mac address */
+               nSubframe_Length = *((u16 *)(skb->data + 12));
+               nSubframe_Length = (nSubframe_Length >> 8) +
+                                  (nSubframe_Length << 8);
+
+               if (skb->len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) {
+                       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;
+               }
 
-                       /* altered by clark 3/30/2010
-                        * The struct buffer size of the skb indicated to upper layer
-                        * must be less than 5000, or the defraged IP datagram
-                        * in the IP layer will exceed "ipfrag_high_tresh" and be
-                        * discarded. so there must not use the function
-                        * "skb_copy" and "skb_clone" for "skb".
-                        */
+               /* move the data point to data content */
+               skb_pull(skb, ETHERNET_HEADER_SIZE);
 
-                       /* Allocate new skb for releasing to upper layer */
-                       sub_skb = dev_alloc_skb(nSubframe_Length + 12);
-                       if (!sub_skb)
-                               return 0;
-                       skb_reserve(sub_skb, 12);
-                       data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
-                       memcpy(data_ptr, skb->data, nSubframe_Length);
-
-                       sub_skb->dev = ieee->dev;
-                       rxb->subframes[rxb->nr_subframes++] = sub_skb;
-                       if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
-                               RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
-                               break;
-                       }
-                       skb_pull(skb, nSubframe_Length);
-
-                       if (skb->len != 0) {
-                               nPadding_Length = 4 - ((nSubframe_Length +
-                                                 ETHERNET_HEADER_SIZE) % 4);
-                               if (nPadding_Length == 4)
-                                       nPadding_Length = 0;
+               /* altered by clark 3/30/2010
+                * The struct buffer size of the skb indicated to upper layer
+                * must be less than 5000, or the defraged IP datagram
+                * in the IP layer will exceed "ipfrag_high_tresh" and be
+                * discarded. so there must not use the function
+                * "skb_copy" and "skb_clone" for "skb".
+                */
 
-                               if (skb->len < nPadding_Length)
-                                       return 0;
+               /* Allocate new skb for releasing to upper layer */
+               sub_skb = dev_alloc_skb(nSubframe_Length + 12);
+               if (!sub_skb)
+                       return 0;
+               skb_reserve(sub_skb, 12);
+               data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
+               memcpy(data_ptr, skb->data, nSubframe_Length);
 
-                               skb_pull(skb, nPadding_Length);
-                       }
+               sub_skb->dev = ieee->dev;
+               rxb->subframes[rxb->nr_subframes++] = sub_skb;
+               if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
+                       RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
+                       break;
                }
+               skb_pull(skb, nSubframe_Length);
 
-               return rxb->nr_subframes;
+               if (skb->len != 0) {
+                       nPadding_Length = 4 - ((nSubframe_Length +
+                                         ETHERNET_HEADER_SIZE) % 4);
+                       if (nPadding_Length == 4)
+                               nPadding_Length = 0;
+
+                       if (skb->len < nPadding_Length)
+                               return 0;
+
+                       skb_pull(skb, nPadding_Length);
+               }
        }
+
+       return rxb->nr_subframes;
 }
 
 
@@ -859,7 +867,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;
        }
@@ -966,7 +975,8 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
        }
 
        /* Nullfunc frames may have PS-bit set, so they must be passed to
-        * hostap_handle_sta_rx() before being dropped here. */
+        * hostap_handle_sta_rx() before being dropped here.
+        */
        if (!ieee->IntelPromiscuousModeInfo.bPromiscuousOn) {
                if (stype != RTLLIB_STYPE_DATA &&
                    stype != RTLLIB_STYPE_DATA_CFACK &&
@@ -1008,7 +1018,8 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
 
                *crypt = ieee->crypt_info.crypt[idx];
                /* allow NULL decrypt to indicate an station specific override
-                * for default encryption */
+                * for default encryption
+                */
                if (*crypt && ((*crypt)->ops == NULL ||
                              (*crypt)->ops->decrypt_mpdu == NULL))
                        *crypt = NULL;
@@ -1017,7 +1028,8 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
                        /* This seems to be triggered by some (multicast?)
                         * frames from other than current BSS, so just drop the
                         * frames silently instead of filling system log with
-                        * these reports. */
+                        * these reports.
+                        */
                        RTLLIB_DEBUG_DROP("Decryption failed (not set) (SA= %pM)\n",
                                             hdr->addr2);
                        ieee->ieee_stats.rx_discards_undecryptable++;
@@ -1049,7 +1061,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,19 +1084,22 @@ 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;
                }
 
                if (frag == 0) {
                        /* copy first fragment (including full headers) into
-                        * beginning of the fragment cache skb */
+                        * beginning of the fragment cache skb
+                        */
                        memcpy(skb_put(frag_skb, flen), skb->data, flen);
                } else {
                        /* append frame payload to the end of the fragment
-                        * cache skb */
+                        * cache skb
+                        */
                        memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
                               flen);
                }
@@ -1094,22 +1109,25 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
                if (fc & RTLLIB_FCTL_MOREFRAGS) {
                        /* more fragments expected - leave the skb in fragment
                         * cache for now; it will be delivered to upper layers
-                        * after all fragments have been received */
+                        * after all fragments have been received
+                        */
                        return -2;
                }
 
                /* this was the last fragment and the frame will be
-                * delivered, so remove skb from fragment cache */
+                * delivered, so remove skb from fragment cache
+                */
                skb = frag_skb;
                hdr = (struct rtllib_hdr_4addr *) skb->data;
                rtllib_frag_cache_invalidate(ieee, hdr);
        }
 
        /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
-        * encrypted/authenticated */
+        * 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;
        }
 
@@ -1119,7 +1137,8 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
                    rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
 
                        /* pass unencrypted EAPOL frames even if encryption is
-                        * configured */
+                        * configured
+                        */
                        struct eapol *eap = (struct eapol *)(skb->data +
                                24);
                        RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
@@ -1149,7 +1168,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;
 }
@@ -1158,7 +1177,7 @@ static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8
 {
        if (unicast) {
 
-               if ((ieee->state == RTLLIB_LINKED)) {
+               if (ieee->state == RTLLIB_LINKED) {
                        if (((ieee->LinkDetectInfo.NumRxUnicastOkInPeriod +
                            ieee->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
                            (ieee->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) {
@@ -1181,8 +1200,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++) {
@@ -1196,7 +1215,8 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
                                ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
                                memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
                                /* remove RFC1042 or Bridge-Tunnel encapsulation and
-                                * replace EtherType */
+                                * replace EtherType
+                                */
                                skb_pull(sub_skb, SNAP_SIZE);
                                memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
                                memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
@@ -1226,7 +1246,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 +1282,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 +1365,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) {
@@ -1390,7 +1408,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
 
        /* Returning 0 indicates to caller that we have not handled the SKB--
         * so it is still allocated and can be used again by underlying
-        * hardware as a DMA target */
+        * hardware as a DMA target
+        */
        return 0;
 }
 
@@ -1408,13 +1427,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;
        }
 
@@ -1433,18 +1455,19 @@ static int rtllib_rx_Mesh(struct rtllib_device *ieee, struct sk_buff *skb,
 
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
- * This function is called only as a tasklet (software IRQ). */
+ * This function is called only as a tasklet (software IRQ).
+ */
 int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
                 struct rtllib_rx_stats *rx_stats)
 {
        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 +1487,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;
        }
 
@@ -1479,10 +1502,7 @@ EXPORT_SYMBOL(rtllib_rx);
 
 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
 
-/*
-* Make ther structure we read from the beacon packet has
-* the right values
-*/
+/* Make ther structure we read from the beacon packet has the right values */
 static int rtllib_verify_qos_info(struct rtllib_qos_information_element
                                     *info_element, int sub_type)
 {
@@ -1500,9 +1520,7 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element
 }
 
 
-/*
- * Parse a QoS parameter element
- */
+/* Parse a QoS parameter element */
 static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
                                            *element_param, struct rtllib_info_element
                                            *info_element)
@@ -1526,9 +1544,7 @@ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
        return ret;
 }
 
-/*
- * Parse a QoS information element
- */
+/* Parse a QoS information element */
 static int rtllib_read_qos_info_element(struct
                                           rtllib_qos_information_element
                                           *element_info, struct rtllib_info_element
@@ -1557,9 +1573,7 @@ static int rtllib_read_qos_info_element(struct
 }
 
 
-/*
- * Write QoS parameters from the ac parameters.
- */
+/* Write QoS parameters from the ac parameters. */
 static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm,
                struct rtllib_qos_data *qos_data)
 {
@@ -1618,8 +1632,7 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info
        return 0;
 }
 
-/*
- * we have a generic data element which it may contain QoS information or
+/* we have a generic data element which it may contain QoS information or
  * parameters element. check the information element length to decide
  * which type to read
  */
@@ -1705,7 +1718,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);
                        }
                }
@@ -1739,7 +1754,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                                             length, info_element->id);
                        /* We stop processing but don't return an error here
                         * because some misbehaviour APs break this rule. ie.
-                        * Orinoco AP1000. */
+                        * Orinoco AP1000.
+                        */
                        break;
                }
 
@@ -1908,7 +1924,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 +1948,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 +1969,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 +2099,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 +2126,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 +2158,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:
@@ -2192,13 +2208,6 @@ static inline int rtllib_network_init(
        struct rtllib_network *network,
        struct rtllib_rx_stats *stats)
 {
-
-       /*
-       network->qos_data.active = 0;
-       network->qos_data.supported = 0;
-       network->qos_data.param_count = 0;
-       network->qos_data.old_param_count = 0;
-       */
        memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data));
 
        /* Pull out fixed field data */
@@ -2291,7 +2300,8 @@ static inline int is_same_network(struct rtllib_network *src,
        /* A network is only a duplicate if the channel, BSSID, ESSID
         * and the capability field (in particular IBSS and BSS) all match.
         * We treat all <hidden> with the same BSSID and channel
-        * as one network */
+        * as one network
+        */
        return (((src->ssid_len == dst->ssid_len) || (!ssidbroad)) &&
                (src->channel == dst->channel) &&
                !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
@@ -2422,7 +2432,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 +2445,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 +2511,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;
                }
        }
@@ -2512,10 +2523,12 @@ static inline void rtllib_process_probe_response(
         *
         * NOTE:  This search is definitely not optimized.  Once its doing
         *      the "right thing" we'll optimize it for efficiency if
-        *      necessary */
+        *      necessary
+        */
 
        /* Search for this entry in the list and update it if it is
-        * already there. */
+        * already there.
+        */
 
        spin_lock_irqsave(&ieee->lock, flags);
        if (is_same_network(&ieee->current_network, network,
@@ -2544,7 +2557,8 @@ static inline void rtllib_process_probe_response(
        }
 
        /* If we didn't find a match, then get a new network slot to initialize
-        * with this beacon's information */
+        * with this beacon's information
+        */
        if (&target->list == &ieee->network_list) {
                if (list_empty(&ieee->network_free_list)) {
                        /* If there are no more slots, expire the oldest */
@@ -2611,7 +2625,6 @@ static inline void rtllib_process_probe_response(
        }
 free_network:
        kfree(network);
-       return;
 }
 
 void rtllib_rx_mgt(struct rtllib_device *ieee,
index d992a754e72db17ec15061cec212e902349845d6..23b7a4c3b6993a91de02a08a46dd72e1ac43dc20 100644 (file)
@@ -68,7 +68,8 @@ static void rtllib_MFIE_Brate(struct rtllib_device *ieee, u8 **tag_p)
        }
 
        /* We may add an option for custom rates that specific HW
-        * might support */
+        * might support
+        */
        *tag_p = tag;
 }
 
@@ -89,7 +90,8 @@ static void rtllib_MFIE_Grate(struct rtllib_device *ieee, u8 **tag_p)
                *tag++ = RTLLIB_BASIC_RATE_MASK | RTLLIB_OFDM_RATE_54MB;
        }
        /* We may add an option for custom rates that specific HW might
-        * support */
+        * support
+        */
        *tag_p = tag;
 }
 
@@ -124,7 +126,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)
@@ -133,8 +135,7 @@ static void enqueue_mgmt(struct rtllib_device *ieee, struct sk_buff *skb)
 
        nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM;
 
-/*
- * if the queue is full but we have newer frames then
+/* if the queue is full but we have newer frames then
  * just overwrites the oldest.
  *
  * if (nh == ieee->mgmt_queue_tail)
@@ -188,7 +189,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;
 }
@@ -273,12 +274,14 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
                if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||
                    (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||
                    (ieee->queue_stop)) {
-                       /* insert the skb packet to the management queue */
-                       /* as for the completion function, it does not need
+                       /* insert the skb packet to the management queue
+                        *
+                        * 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 +404,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)));
 }
 
 
@@ -416,40 +419,33 @@ static void rtllib_send_beacon_cb(unsigned long _ieee)
        spin_unlock_irqrestore(&ieee->beacon_lock, flags);
 }
 
-/*
- * Description:
- *           Enable network monitor mode, all rx packets will be received.
- */
+/* Enables network monitor mode, all rx packets will be received. */
 void rtllib_EnableNetMonitorMode(struct net_device *dev,
                bool bInitState)
 {
        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);
 }
 
 
-/*
- *      Description:
- *           Disable network network monitor mode, only packets destinated to
- *           us will be received.
+/* Disables network monitor mode. Only packets destinated to
+ * us will be received.
  */
 void rtllib_DisableNetMonitorMode(struct net_device *dev,
                bool bInitState)
 {
        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);
 }
 
 
-/*
- * Description:
- * This enables the specialized promiscuous mode required by Intel.
+/* Enables the specialized promiscuous mode required by Intel.
  * In this mode, Intel intends to hear traffics from/to other STAs in the
  * same BSS. Therefore we don't have to disable checking BSSID and we only need
  * to allow all dest. BUT: if we enable checking BSSID then we can't recv
@@ -462,7 +458,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,
@@ -473,10 +469,8 @@ void rtllib_EnableIntelPromiscuousMode(struct net_device *dev,
 EXPORT_SYMBOL(rtllib_EnableIntelPromiscuousMode);
 
 
-/*
- * Description:
- *           This disables the specialized promiscuous mode required by Intel.
- *           See MgntEnableIntelPromiscuousMode for detail.
+/* Disables the specialized promiscuous mode required by Intel.
+ * See MgntEnableIntelPromiscuousMode for detail.
  */
 void rtllib_DisableIntelPromiscuousMode(struct net_device *dev,
                bool bInitState)
@@ -485,7 +479,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 +563,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 +609,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 +635,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 +1234,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 +1414,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 +1471,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 +1500,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 +1539,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 +1550,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 +1578,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 +1619,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);
@@ -1705,8 +1702,8 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
                   (!apset && ssidset && ssidbroad && ssidmatch) ||
                   (ieee->is_roaming && ssidset && ssidbroad && ssidmatch)) {
                        /* if the essid is hidden replace it with the
-                       * essid provided by the user.
-                       */
+                        * essid provided by the user.
+                        */
                        if (!ssidbroad) {
                                strncpy(tmp_ssid, ieee->current_network.ssid,
                                        IW_ESSID_MAX_SIZE);
@@ -1719,15 +1716,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 +1755,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 +1962,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)
@@ -2004,13 +2001,16 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
        timeout = ieee->current_network.beacon_interval;
        ieee->current_network.dtim_data = RTLLIB_DTIM_INVALID;
        /* there's no need to nofity AP that I find you buffered
-        * with broadcast packet */
+        * with broadcast packet
+        */
        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 +2060,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 +2081,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 +2198,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;
        }
 
@@ -2223,7 +2222,6 @@ static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *sk
        default:
                break;
        }
-       return;
 }
 
 inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
@@ -2285,16 +2283,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);
@@ -2308,72 +2308,71 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
        return 0;
 }
 
-inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
-                         struct rtllib_rx_stats *rx_stats)
+static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb)
 {
        u16 errcode;
        u8 *challenge;
        int chlen = 0;
        bool bSupportNmode = true, bHalfSupportNmode = false;
 
-       if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) {
-               if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING &&
-                   (ieee->iw_mode == IW_MODE_INFRA)) {
-                       RTLLIB_DEBUG_MGMT("Received authentication response");
+       errcode = auth_parse(skb, &challenge, &chlen);
 
-                       errcode = auth_parse(skb, &challenge, &chlen);
-                       if (0 == errcode) {
-                               if (ieee->open_wep || !challenge) {
-                                       ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED;
-                                       ieee->softmac_stats.rx_auth_rs_ok++;
-                                       if (!(ieee->pHTInfo->IOTAction &
-                                           HT_IOT_ACT_PURE_N_MODE)) {
-                                               if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
-                                                       if (IsHTHalfNmodeAPs(ieee)) {
-                                                               bSupportNmode = true;
-                                                               bHalfSupportNmode = true;
-                                                       } else {
-                                                               bSupportNmode = false;
-                                                               bHalfSupportNmode = false;
-                                                       }
-                                               }
-                                       }
-                                       /* Dummy wirless mode setting to avoid
-                                        * encryption issue */
-                                       if (bSupportNmode) {
-                                               ieee->SetWirelessMode(ieee->dev,
-                                                  ieee->current_network.mode);
-                                       } else {
-                                               /*TODO*/
-                                               ieee->SetWirelessMode(ieee->dev,
-                                                                     IEEE_G);
-                                       }
-
-                                       if (ieee->current_network.mode ==
-                                           IEEE_N_24G && bHalfSupportNmode) {
-                                               printk(KERN_INFO "======>enter "
-                                                      "half N mode\n");
-                                               ieee->bHalfWirelessN24GMode =
-                                                                        true;
-                                       } else
-                                               ieee->bHalfWirelessN24GMode =
-                                                                        false;
-
-                                       rtllib_associate_step2(ieee);
+       if (errcode) {
+               ieee->softmac_stats.rx_auth_rs_err++;
+               RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",
+                                 errcode);
+
+               netdev_info(ieee->dev,
+                           "Authentication respose status code 0x%x", errcode);
+               rtllib_associate_abort(ieee);
+               return;
+       }
+
+       if (ieee->open_wep || !challenge) {
+               ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATED;
+               ieee->softmac_stats.rx_auth_rs_ok++;
+               if (!(ieee->pHTInfo->IOTAction & HT_IOT_ACT_PURE_N_MODE)) {
+                       if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) {
+                               if (IsHTHalfNmodeAPs(ieee)) {
+                                       bSupportNmode = true;
+                                       bHalfSupportNmode = true;
                                } else {
-                                       rtllib_auth_challenge(ieee, challenge,
-                                                             chlen);
+                                       bSupportNmode = false;
+                                       bHalfSupportNmode = false;
                                }
-                       } else {
-                               ieee->softmac_stats.rx_auth_rs_err++;
-                               RTLLIB_DEBUG_MGMT("Authentication respose"
-                                                 " status code 0x%x", errcode);
-
-                               printk(KERN_INFO "Authentication respose "
-                                      "status code 0x%x", errcode);
-                               rtllib_associate_abort(ieee);
                        }
+               }
+               /* Dummy wirless mode setting to avoid encryption issue */
+               if (bSupportNmode) {
+                       ieee->SetWirelessMode(ieee->dev,
+                                             ieee->current_network.mode);
+               } else {
+                       /*TODO*/
+                       ieee->SetWirelessMode(ieee->dev, IEEE_G);
+               }
 
+               if ((ieee->current_network.mode == IEEE_N_24G) &&
+                   bHalfSupportNmode) {
+                       netdev_info(ieee->dev, "======>enter half N mode\n");
+                       ieee->bHalfWirelessN24GMode = true;
+               } else {
+                       ieee->bHalfWirelessN24GMode = false;
+               }
+               rtllib_associate_step2(ieee);
+       } else {
+               rtllib_auth_challenge(ieee, challenge,  chlen);
+       }
+}
+
+inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
+                         struct rtllib_rx_stats *rx_stats)
+{
+
+       if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) {
+               if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING &&
+                   (ieee->iw_mode == IW_MODE_INFRA)) {
+                       RTLLIB_DEBUG_MGMT("Received authentication response");
+                       rtllib_rx_auth_resp(ieee, skb);
                } else if (ieee->iw_mode == IW_MODE_MASTER) {
                        rtllib_rx_auth_rq(ieee, skb);
                }
@@ -2389,15 +2388,15 @@ inline int rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb)
                return 0;
 
        /* FIXME for now repeat all the association procedure
-       * both for disassociation and deauthentication
-       */
+        * both for disassociation and deauthentication
+        */
        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 +2449,6 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
                break;
        default:
                return -1;
-               break;
        }
        return 0;
 }
@@ -2494,16 +2492,17 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee)
                ieee->stats.multicast++;
 
        /* if xmit available, just xmit it immediately, else just insert it to
-        * the wait queue */
+        * the wait queue
+        */
        for (i = 0; i < txb->nr_frags; i++) {
                queue_len = skb_queue_len(&ieee->skb_waitQ[queue_index]);
-               if ((queue_len  != 0) ||\
+               if ((queue_len  != 0) ||
                    (!ieee->check_nic_enough_desc(ieee->dev, queue_index)) ||
                    (ieee->queue_stop)) {
-                       /* insert the skb packet to the wait queue */
-                       /* as for the completion function, it does not need
+                       /* insert the skb packet to the wait queue
+                        * as for the completion function, it does not need
                         * to check it any more.
-                        * */
+                        */
                        if (queue_len < 200)
                                skb_queue_tail(&ieee->skb_waitQ[queue_index],
                                               txb->fragments[i]);
@@ -2533,13 +2532,12 @@ static void rtllib_resume_tx(struct rtllib_device *ieee)
                if (ieee->queue_stop) {
                        ieee->tx_pending.frag = i;
                        return;
-               } else {
-
-                       ieee->softmac_data_hard_start_xmit(
-                               ieee->tx_pending.txb->fragments[i],
-                               ieee->dev, ieee->rate);
-                       ieee->stats.tx_packets++;
                }
+
+               ieee->softmac_data_hard_start_xmit(
+                       ieee->tx_pending.txb->fragments[i],
+                       ieee->dev, ieee->rate);
+               ieee->stats.tx_packets++;
        }
 
        rtllib_txb_free(ieee->tx_pending.txb);
@@ -2688,7 +2686,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 +2722,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 +2776,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 +2806,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 */
@@ -2881,18 +2880,18 @@ static void rtllib_associate_retry_wq(void *data)
                goto exit;
 
        /* until we do not set the state to RTLLIB_NOLINK
-       * there are no possibility to have someone else trying
-       * to start an association procedure (we get here with
-       * ieee->state = RTLLIB_ASSOCIATING).
-       * When we set the state to RTLLIB_NOLINK it is possible
-       * that the RX path run an attempt to associate, but
-       * both rtllib_softmac_check_all_nets and the
-       * RX path works with ieee->lock held so there are no
-       * problems. If we are still disassociated then start a scan.
-       * the lock here is necessary to ensure no one try to start
-       * an association procedure when we have just checked the
-       * state and we are going to start the scan.
-       */
+        * there are no possibility to have someone else trying
+        * to start an association procedure (we get here with
+        * ieee->state = RTLLIB_ASSOCIATING).
+        * When we set the state to RTLLIB_NOLINK it is possible
+        * that the RX path run an attempt to associate, but
+        * both rtllib_softmac_check_all_nets and the
+        * RX path works with ieee->lock held so there are no
+        * problems. If we are still disassociated then start a scan.
+        * the lock here is necessary to ensure no one try to start
+        * an association procedure when we have just checked the
+        * state and we are going to start the scan.
+        */
        ieee->beinretry = true;
        ieee->state = RTLLIB_NOLINK;
 
@@ -3180,8 +3179,9 @@ void rtllib_softmac_free(struct rtllib_device *ieee)
 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");
+        * interface.
+        */
+       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 +3212,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 +3343,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 +3369,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 +3410,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 +3421,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 +3445,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;
@@ -3486,12 +3485,13 @@ static int rtllib_wpa_set_encryption(struct rtllib_device *ieee,
         * generate new IEEE 802.11 authentication which may end up in looping
         * with IEEE 802.1X.  If your hardware requires a reset after WEP
         * configuration (for example... Prism2), implement the reset_port in
-        * the callbacks structures used to initialize the 802.11 stack. */
+        * the callbacks structures used to initialize the 802.11 stack.
+        */
        if (ieee->reset_on_keychange &&
            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 +3634,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 +3749,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..3b159638bba2adb6d97e0146e024c2dc79d1001a 100644 (file)
 
 #include "rtllib.h"
 
-/*
-
-
-802.11 Data Frame
-
-
-802.11 frame_control for data frames - 2 bytes
-     ,-----------------------------------------------------------------------------------------.
-bits | 0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  a  |  b  |  c  |  d  |  e   |
-     |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
-val  | 0  |  0  |  0  |  1  |  x  |  0  |  0  |  0  |  1  |  0  |  x  |  x  |  x  |  x  |  x   |
-     |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
-desc | ^-ver-^  |  ^type-^  |  ^-----subtype-----^  | to  |from |more |retry| pwr |more |wep   |
-     |   |        | x=0 data,x=1 data+ack | DS  | DS  |frag |     | mgm |data |      |
-     '-----------------------------------------------------------------------------------------'
-                                                   /\
-                                                   |
-802.11 Data Frame                                 |
-          ,--------- 'ctrl' expands to >-----------'
-         |
-      ,--'---,-------------------------------------------------------------.
-Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
-      |------|------|---------|---------|---------|------|---------|------|
-Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  Frame  |  fcs |
-      |      | tion | (BSSID) |         |       | ence |  data   |      |
-      `--------------------------------------------------|      |------'
-Total: 28 non-data bytes                                `----.----'
-                                                             |
-       .- 'Frame data' expands to <---------------------------'
-       |
-       V
-      ,---------------------------------------------------.
-Bytes |  1   |  1   |    1    |    3     |  2   |  0-2304 |
-      |------|------|---------|----------|------|---------|
-Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP      |
-      | DSAP | SSAP |   |        |      | Packet  |
-      | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8|      |       |
-      `-----------------------------------------|       |
-Total: 8 non-data bytes                         `----.----'
-                                                    |
-       .- 'IP Packet' expands, if WEP enabled, to <--'
-       |
-       V
-      ,-----------------------.
-Bytes |  4  |   0-2296  |  4  |
-      |-----|-----------|-----|
-Desc. | IV  | Encrypted | ICV |
-      |     | IP Packet |     |
-      `-----------------------'
-Total: 8 non-data bytes
-
-
-802.3 Ethernet Data Frame
-
-      ,-----------------------------------------.
-Bytes |   6   |   6   |  2   |  Variable |   4  |
-      |-------|-------|------|-----------|------|
-Desc. | Dest. | Source| Type | IP Packet |  fcs |
-      |  MAC  |  MAC  |      |    |      |
-      `-----------------------------------------'
-Total: 18 non-data bytes
-
-In the event that fragmentation is required, the incoming payload is split into
-N parts of size ieee->fts.  The first fragment contains the SNAP header and the
-remaining packets are just data.
-
-If encryption is enabled, each fragment payload size is reduced by enough space
-to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
-So if you have 1500 bytes of payload with ieee->fts set to 500 without
-encryption it will take 3 frames.  With WEP it will take 4 frames as the
-payload of each frame is reduced to 492 bytes.
-
-* SKB visualization
-*
-*  ,- skb->data
-* |
-* |    ETHERNET HEADER ,-<-- PAYLOAD
-* |                       |     14 bytes from skb->data
-* |  2 bytes for Type --> ,T. |     (sizeof ethhdr)
-* |                   | | |
-* |,-Dest.--. ,--Src.---. | | |
-* |  6 bytes| | 6 bytes | | | |
-* v     | |     | | | |
-* 0     | v       1 | v | v       2
-* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-*     ^     | ^         | ^ |
-*     |     | |         | | |
-*     |     | |         | `T' <---- 2 bytes for Type
-*     |     | |         |
-*     |     | '---SNAP--' <-------- 6 bytes for SNAP
-*     |     |
-*     `-IV--' <-------------------- 4 bytes for IV (WEP)
-*
-*      SNAP HEADER
-*
-*/
+/* 802.11 Data Frame
+ *
+ *
+ * 802.11 frame_control for data frames - 2 bytes
+ *      ,-----------------------------------------------------------------------------------------.
+ * bits | 0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  a  |  b  |  c  |  d  |  e   |
+ *      |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
+ * val  | 0  |  0  |  0  |  1  |  x  |  0  |  0  |  0  |  1  |  0  |  x  |  x  |  x  |  x  |  x   |
+ *      |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
+ * desc | ^-ver-^  |  ^type-^  |  ^-----subtype-----^  | to  |from |more |retry| pwr |more |wep   |
+ *      |          |           | x=0 data,x=1 data+ack | DS  | DS  |frag |     | mgm |data |      |
+ *      '-----------------------------------------------------------------------------------------'
+ *                                                   /\
+ *                                                   |
+ * 802.11 Data Frame                                 |
+ *          ,--------- 'ctrl' expands to >-----------'
+ *          |
+ *       ,--'---,-------------------------------------------------------------.
+ * Bytes |  2   |  2   |    6    |    6    |    6    |  2   | 0..2312 |   4  |
+ *       |------|------|---------|---------|---------|------|---------|------|
+ * Desc. | ctrl | dura |  DA/RA  |   TA    |    SA   | Sequ |  Frame  |  fcs |
+ *       |      | tion | (BSSID) |         |         | ence |  data   |      |
+ *       `--------------------------------------------------|         |------'
+ * Total: 28 non-data bytes                                 `----.----'
+ *                                                               |
+ *        .- 'Frame data' expands to <---------------------------'
+ *        |
+ *        V
+ *       ,---------------------------------------------------.
+ * Bytes |  1   |  1   |    1    |    3     |  2   |  0-2304 |
+ *       |------|------|---------|----------|------|---------|
+ * Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP      |
+ *       | DSAP | SSAP |         |          |      | Packet  |
+ *       | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8|      |         |
+ *       `-----------------------------------------|         |
+ * Total: 8 non-data bytes                         `----.----'
+ *                                                      |
+ *        .- 'IP Packet' expands, if WEP enabled, to <--'
+ *        |
+ *        V
+ *       ,-----------------------.
+ * Bytes |  4  |   0-2296  |  4  |
+ *       |-----|-----------|-----|
+ * Desc. | IV  | Encrypted | ICV |
+ *       |     | IP Packet |     |
+ *       `-----------------------'
+ * Total: 8 non-data bytes
+ *
+ *
+ * 802.3 Ethernet Data Frame
+ *
+ *       ,-----------------------------------------.
+ * Bytes |   6   |   6   |  2   |  Variable |   4  |
+ *       |-------|-------|------|-----------|------|
+ * Desc. | Dest. | Source| Type | IP Packet |  fcs |
+ *       |  MAC  |  MAC  |      |         |      |
+ *       `-----------------------------------------'
+ * Total: 18 non-data bytes
+ *
+ * In the event that fragmentation is required, the incoming payload is split into
+ * N parts of size ieee->fts.  The first fragment contains the SNAP header and the
+ * remaining packets are just data.
+ *
+ * If encryption is enabled, each fragment payload size is reduced by enough space
+ * to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
+ * So if you have 1500 bytes of payload with ieee->fts set to 500 without
+ * encryption it will take 3 frames.  With WEP it will take 4 frames as the
+ * payload of each frame is reduced to 492 bytes.
+ *
+ * SKB visualization
+ *
+ * ,- skb->data
+ * |
+ * |    ETHERNET HEADER        ,-<-- PAYLOAD
+ * |                           |     14 bytes from skb->data
+ * |  2 bytes for Type --> ,T. |     (sizeof ethhdr)
+ * |                       | | |
+ * |,-Dest.--. ,--Src.---. | | |
+ * |  6 bytes| | 6 bytes | | | |
+ * v         | |         | | | |
+ * 0         | v       1 | v | v           2
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ *     ^     | ^         | ^ |
+ *     |     | |         | | |
+ *     |     | |         | `T' <---- 2 bytes for Type
+ *     |     | |         |
+ *     |     | '---SNAP--' <-------- 6 bytes for SNAP
+ *     |     |
+ *     `-IV--' <-------------------- 4 bytes for IV (WEP)
+ *
+ *      SNAP HEADER
+ *
+ */
 
 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
@@ -185,14 +182,17 @@ 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:
-        * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
+        * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes)
+        */
 
        /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
-        * call both MSDU and MPDU encryption functions from here. */
+        * call both MSDU and MPDU encryption functions from here.
+        */
        atomic_inc(&crypt->refcnt);
        res = 0;
        if (crypt->ops->encrypt_msdu)
@@ -202,8 +202,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 +311,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) {
@@ -412,6 +412,8 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee,
                                        struct cb_desc *tcb_desc,
                                        struct sk_buff *skb)
 {
+       struct rt_hi_throughput *pHTInfo;
+
        tcb_desc->bRTSSTBC                      = false;
        tcb_desc->bRTSUseShortGI                = false;
        tcb_desc->bCTSEnable                    = false;
@@ -434,50 +436,50 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee,
                        tcb_desc->rts_rate = MGN_24M;
                }
                return;
-       } else {
-               struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
+       }
 
-               while (true) {
-                       if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) {
-                               tcb_desc->bCTSEnable    = true;
-                               tcb_desc->rts_rate  =   MGN_24M;
-                               tcb_desc->bRTSEnable = true;
-                               break;
-                       } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS |
-                                  HT_IOT_ACT_PURE_N_MODE)) {
-                               tcb_desc->bRTSEnable = true;
-                               tcb_desc->rts_rate  =   MGN_24M;
-                               break;
-                       }
-                       if (ieee->current_network.buseprotection) {
-                               tcb_desc->bRTSEnable = true;
-                               tcb_desc->bCTSEnable = true;
-                               tcb_desc->rts_rate = MGN_24M;
-                               break;
-                       }
-                       if (pHTInfo->bCurrentHTSupport  && pHTInfo->bEnableHT) {
-                               u8 HTOpMode = pHTInfo->CurrentOpMode;
-
-                               if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 ||
-                                    HTOpMode == 3)) ||
-                                    (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) {
-                                       tcb_desc->rts_rate = MGN_24M;
-                                       tcb_desc->bRTSEnable = true;
-                                       break;
-                               }
-                       }
-                       if (skb->len > ieee->rts) {
+       pHTInfo = ieee->pHTInfo;
+
+       while (true) {
+               if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) {
+                       tcb_desc->bCTSEnable    = true;
+                       tcb_desc->rts_rate  =   MGN_24M;
+                       tcb_desc->bRTSEnable = true;
+                       break;
+               } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS |
+                          HT_IOT_ACT_PURE_N_MODE)) {
+                       tcb_desc->bRTSEnable = true;
+                       tcb_desc->rts_rate  =   MGN_24M;
+                       break;
+               }
+               if (ieee->current_network.buseprotection) {
+                       tcb_desc->bRTSEnable = true;
+                       tcb_desc->bCTSEnable = true;
+                       tcb_desc->rts_rate = MGN_24M;
+                       break;
+               }
+               if (pHTInfo->bCurrentHTSupport  && pHTInfo->bEnableHT) {
+                       u8 HTOpMode = pHTInfo->CurrentOpMode;
+
+                       if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 ||
+                            HTOpMode == 3)) ||
+                            (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) {
                                tcb_desc->rts_rate = MGN_24M;
                                tcb_desc->bRTSEnable = true;
                                break;
                        }
-                       if (tcb_desc->bAMPDUEnable) {
-                               tcb_desc->rts_rate = MGN_24M;
-                               tcb_desc->bRTSEnable = false;
-                               break;
-                       }
-                       goto NO_PROTECTION;
                }
+               if (skb->len > ieee->rts) {
+                       tcb_desc->rts_rate = MGN_24M;
+                       tcb_desc->bRTSEnable = true;
+                       break;
+               }
+               if (tcb_desc->bAMPDUEnable) {
+                       tcb_desc->rts_rate = MGN_24M;
+                       tcb_desc->bRTSEnable = false;
+                       break;
+               }
+               goto NO_PROTECTION;
        }
        if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
                tcb_desc->bUseShortPreamble = true;
@@ -549,6 +551,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 *)
@@ -577,21 +590,21 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
        spin_lock_irqsave(&ieee->lock, flags);
 
        /* If there is no driver handler to take the TXB, don't bother
-        * creating it... */
+        * creating it...
+        */
        if ((!ieee->hard_start_xmit && !(ieee->softmac_features &
           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 +617,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 +648,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;
@@ -680,7 +692,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                if (ieee->iw_mode == IW_MODE_INFRA) {
                        fc |= RTLLIB_FCTL_TODS;
                        /* To DS: Addr1 = BSSID, Addr2 = SA,
-                       Addr3 = DA */
+                        * Addr3 = DA
+                        */
                        memcpy(&header.addr1, ieee->current_network.bssid,
                               ETH_ALEN);
                        memcpy(&header.addr2, &src, ETH_ALEN);
@@ -691,7 +704,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                                memcpy(&header.addr3, &dest, ETH_ALEN);
                } else if (ieee->iw_mode == IW_MODE_ADHOC) {
                        /* not From/To DS: Addr1 = DA, Addr2 = SA,
-                       Addr3 = BSSID */
+                        * Addr3 = BSSID
+                        */
                        memcpy(&header.addr1, dest, ETH_ALEN);
                        memcpy(&header.addr2, src, ETH_ALEN);
                        memcpy(&header.addr3, ieee->current_network.bssid,
@@ -703,7 +717,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                header.frame_ctl = cpu_to_le16(fc);
 
                /* Determine fragmentation size based on destination (multicast
-               * and broadcast are not fragmented) */
+                * and broadcast are not fragmented)
+                */
                if (bIsMulticast) {
                        frag_size = MAX_FRAG_THRESHOLD;
                        qos_ctl |= QOS_CTL_NOTCONTAIN_ACK;
@@ -717,10 +732,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;
@@ -731,14 +747,16 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                /* Determine amount of payload per fragment.  Regardless of if
                 * this stack is providing the full 802.11 header, one will
                 * eventually be affixed to this fragment -- so we must account
-                * for it when determining the amount of payload space. */
+                * for it when determining the amount of payload space.
+                */
                bytes_per_frag = frag_size - hdr_len;
                if (ieee->config &
                   (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS))
                        bytes_per_frag -= RTLLIB_FCS_LEN;
 
                /* Each fragment may need to have room for encrypting
-                * pre/postfix */
+                * pre/postfix
+                */
                if (encrypt) {
                        bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len +
                                crypt->ops->extra_mpdu_postfix_len +
@@ -746,7 +764,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                                crypt->ops->extra_msdu_postfix_len;
                }
                /* Number of fragments is the total bytes_per_frag /
-               * payload_per_fragment */
+                * payload_per_fragment
+                */
                nr_frags = bytes / bytes_per_frag;
                bytes_last_frag = bytes % bytes_per_frag;
                if (bytes_last_frag)
@@ -756,12 +775,12 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 
                /* When we allocate the TXB we allocate enough space for the
                 * reserve and full fragment bytes (bytes_per_frag doesn't
-                * include prefix, postfix, header, FCS, etc.) */
+                * include prefix, postfix, header, FCS, etc.)
+                */
                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;
@@ -801,7 +820,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
                        memcpy(frag_hdr, &header, hdr_len);
 
                        /* If this is not the last fragment, then add the
-                        * MOREFRAGS bit to the frame control */
+                        * MOREFRAGS bit to the frame control
+                        */
                        if (i != nr_frags - 1) {
                                frag_hdr->frame_ctl = cpu_to_le16(
                                        fc | RTLLIB_FCTL_MOREFRAGS);
@@ -836,7 +856,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
 
                        /* Encryption routine will move the header forward in
                         * order to insert the IV between the header and the
-                        * payload */
+                        * payload
+                        */
                        if (encrypt)
                                rtllib_encrypt_fragment(ieee, skb_frag,
                                                        hdr_len);
@@ -858,15 +879,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 +926,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..6234aae5b069ea4715cce087e86634586f9041d8 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);
        }
@@ -113,8 +113,6 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
 
        /* Add frequency/channel */
        iwe.cmd = SIOCGIWFREQ;
-/*     iwe.u.freq.m = rtllib_frequency(network->channel, network->mode);
-       iwe.u.freq.e = 3; */
        iwe.u.freq.m = network->channel;
        iwe.u.freq.e = 0;
        iwe.u.freq.i = 0;
@@ -241,7 +239,8 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
        }
 
        /* Add EXTRA: Age to display seconds since last beacon/probe response
-        * for given network. */
+        * for given network.
+        */
        iwe.cmd = IWEVCUSTOM;
        p = custom;
        p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
@@ -282,8 +281,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,
@@ -338,13 +336,14 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                        RTLLIB_DEBUG_WX("Disabling encryption.\n");
 
                /* Check all the keys to see if any are still configured,
-                * and if no key index was provided, de-init them all */
+                * and if no key index was provided, de-init them all
+                */
                for (i = 0; i < NUM_WEP_KEYS; i++) {
                        if (ieee->crypt_info.crypt[i] != NULL) {
                                if (key_provided)
                                        break;
                                lib80211_crypt_delayed_deinit(&ieee->crypt_info,
-                                                           &ieee->crypt_info.crypt[i]);
+                                                   &ieee->crypt_info.crypt[i]);
                        }
                }
 
@@ -365,7 +364,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
        if (*crypt != NULL && (*crypt)->ops != NULL &&
            strcmp((*crypt)->ops->name, "R-WEP") != 0) {
                /* changing to use WEP; deinit previously used algorithm
-                * on this key */
+                * on this key
+                */
                lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
        }
 
@@ -390,9 +390,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;
@@ -413,7 +413,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                                       (*crypt)->priv);
                sec.flags |= (1 << key);
                /* This ensures a key will be activated if no key is
-                * explicitly set */
+                * explicitly set
+                */
                if (key == sec.active_key)
                        sec.flags |= SEC_ACTIVE_KEY;
                ieee->crypt_info.tx_keyidx = key;
@@ -423,11 +424,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 +436,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;
@@ -454,7 +453,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
                           "OPEN" : "SHARED KEY");
 
        /* For now we just support WEP, so only set that security level...
-        * TODO: When WPA is added this is one place that needs to change */
+        * TODO: When WPA is added this is one place that needs to change
+        */
        sec.flags |= SEC_LEVEL;
        sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
 
@@ -465,11 +465,12 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
         * generate new IEEE 802.11 authentication which may end up in looping
         * with IEEE 802.1X.  If your hardware requires a reset after WEP
         * configuration (for example... Prism2), implement the reset_port in
-        * the callbacks structures used to initialize the 802.11 stack. */
+        * the callbacks structures used to initialize the 802.11 stack.
+        */
        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 +597,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 +609,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 +640,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 +757,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;
 
@@ -797,8 +795,7 @@ int rtllib_wx_set_auth(struct rtllib_device *ieee,
        case IW_AUTH_CIPHER_PAIRWISE:
        case IW_AUTH_CIPHER_GROUP:
        case IW_AUTH_KEY_MGMT:
-               /*
-                * Host AP driver does not use these parameters and allows
+               /* Host AP driver does not use these parameters and allows
                 * wpa_supplicant to control them internally.
                 */
                break;
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..9fbb53d8c6bfb8ab3869c28c37861c806db9d7bb 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;
@@ -609,12 +608,12 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
        bool                    bMatchWinStart = false, bPktInBuf = false;
        IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize);
        /* Rx Reorder initialize condition.*/
-       if(pTS->RxIndicateSeq == 0xffff) {
+       if (pTS->RxIndicateSeq == 0xffff) {
                pTS->RxIndicateSeq = SeqNum;
        }
 
        /* Drop out the packet which SeqNum is smaller than WinStart */
-       if(SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
+       if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
                IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
                                 pTS->RxIndicateSeq, SeqNum);
                pHTInfo->RxReorderDropCounter++;
@@ -717,7 +716,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                    SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
                {
                        /* This protect buffer from overflow. */
-                       if(index >= REORDER_WIN_SIZE) {
+                       if (index >= REORDER_WIN_SIZE) {
                                IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n");
                                bPktInBuf = true;
                                break;
@@ -741,7 +740,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
        }
 
        /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
-       if(index>0) {
+       if (index>0) {
                // Cancel previous pending timer.
        //      del_timer_sync(&pTS->RxPktPendingTimer);
                pTS->RxTimeoutIndicateSeq = 0xffff;
@@ -754,7 +753,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
                ieee80211_indicate_packets(ieee, prxbIndicateArray, index);
        }
 
-       if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
+       if (bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
                // Set new pending timer.
                IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __func__);
                pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
@@ -784,16 +783,16 @@ static u8 parse_subframe(struct sk_buff *skb,
        /* just for debug purpose */
        SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl));
 
-       if((IEEE80211_QOS_HAS_SEQ(fc))&&\
+       if ((IEEE80211_QOS_HAS_SEQ(fc))&&\
                        (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) {
                bIsAggregateFrame = true;
        }
 
-       if(IEEE80211_QOS_HAS_SEQ(fc)) {
+       if (IEEE80211_QOS_HAS_SEQ(fc)) {
                LLCOffset += 2;
        }
 
-       if(rx_stats->bContainHTC) {
+       if (rx_stats->bContainHTC) {
                LLCOffset += sHTCLng;
        }
        //printk("ChkLength = %d\n", LLCOffset);
@@ -827,7 +826,7 @@ static u8 parse_subframe(struct sk_buff *skb,
                        //==m==>change the length order
                        nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8);
 
-                       if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
+                       if (skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
                                printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
                                                __func__, rxb->nr_subframes);
                                printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__, nSubframe_Length);
@@ -853,19 +852,19 @@ static u8 parse_subframe(struct sk_buff *skb,
                        memcpy(data_ptr, skb->data, nSubframe_Length);
 #endif
                        rxb->subframes[rxb->nr_subframes++] = sub_skb;
-                       if(rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
+                       if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
                                IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
                                break;
                        }
                        skb_pull(skb, nSubframe_Length);
 
-                       if(skb->len != 0) {
+                       if (skb->len != 0) {
                                nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4);
-                               if(nPadding_Length == 4) {
+                               if (nPadding_Length == 4) {
                                        nPadding_Length = 0;
                                }
 
-                               if(skb->len < nPadding_Length) {
+                               if (skb->len < nPadding_Length) {
                                        return 0;
                                }
 
@@ -939,12 +938,12 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        frag = WLAN_GET_SEQ_FRAG(sc);
        hdrlen = ieee80211_get_hdrlen(fc);
 
-       if(HTCCheck(ieee, skb->data))
+       if (HTCCheck(ieee, skb->data))
        {
                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);
@@ -1274,13 +1273,13 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        }
 */
 //added by amy for reorder
-       if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
+       if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
                && !is_multicast_ether_addr(hdr->addr1))
        {
                TID = Frame_QoSTID(skb->data);
                SeqNum = WLAN_GET_SEQ_SEQ(sc);
                GetTs(ieee,(PTS_COMMON_INFO *) &pTS,hdr->addr2,TID,RX_DIR,true);
-               if(TID !=0 && TID !=3)
+               if (TID !=0 && TID !=3)
                {
                        ieee->bis_any_nonbepkts = true;
                }
@@ -1290,7 +1289,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
        payload = skb->data + hdrlen;
        //ethertype = (payload[6] << 8) | payload[7];
        rxb = kmalloc(sizeof(struct ieee80211_rxb), GFP_ATOMIC);
-       if(rxb == NULL)
+       if (rxb == NULL)
        {
                IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__func__);
                goto rx_dropped;
@@ -1336,7 +1335,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 
                                stats->rx_packets++;
                                stats->rx_bytes += sub_skb->len;
-                               if(is_multicast_ether_addr(dst)) {
+                               if (is_multicast_ether_addr(dst)) {
                                        stats->multicast++;
                                }
 
@@ -1590,14 +1589,14 @@ static inline void ieee80211_extract_country_ie(
        u8 *addr2
 )
 {
-       if(IS_DOT11D_ENABLE(ieee))
+       if (IS_DOT11D_ENABLE(ieee))
        {
-               if(info_element->len!= 0)
+               if (info_element->len!= 0)
                {
                        memcpy(network->CountryIeBuf, info_element->data, info_element->len);
                        network->CountryIeLen = info_element->len;
 
-                       if(!IS_COUNTRY_IE_VALID(ieee))
+                       if (!IS_COUNTRY_IE_VALID(ieee))
                        {
                                Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
                        }
@@ -1608,7 +1607,7 @@ static inline void ieee80211_extract_country_ie(
                // some AP (e.g. Cisco 1242) don't include country IE in their
                // probe response frame.
                //
-               if(IS_EQUAL_CIE_SRC(ieee, addr2) )
+               if (IS_EQUAL_CIE_SRC(ieee, addr2) )
                {
                        UPDATE_CIE_WATCHDOG(ieee);
                }
@@ -1705,7 +1704,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 #ifdef CONFIG_IEEE80211_DEBUG
                                p += snprintf(p, sizeof(rates_str) -
                                              (p - rates_str), "%02X ",
-                                             network->rates[i]);
+                                             network->rates_ex[i]);
 #endif
                                if (ieee80211_is_ofdm_rate
                                    (info_element->data[i])) {
@@ -1888,7 +1887,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
 
                        //if(tmp_htcap_len !=0  ||  tmp_htinfo_len != 0)
                        {
-                               if((info_element->len >= 3 &&
+                               if ((info_element->len >= 3 &&
                                         info_element->data[0] == 0x00 &&
                                         info_element->data[1] == 0x05 &&
                                         info_element->data[2] == 0xb5) ||
@@ -1940,7 +1939,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                        else
                                network->cisco_cap_exist = false;
                        //added by amy for LEAP of cisco
-                       if(info_element->len > 4 &&
+                       if (info_element->len > 4 &&
                                info_element->data[0] == 0x00 &&
                                info_element->data[1] == 0x40 &&
                                info_element->data[2] == 0x96 &&
@@ -1976,7 +1975,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,
                                        network->bCcxRmEnable = false;
                                }
                        }
-                       if(info_element->len > 4  &&
+                       if (info_element->len > 4  &&
                                info_element->data[0] == 0x00 &&
                                info_element->data[1] == 0x40 &&
                                info_element->data[2] == 0x96 &&
@@ -2296,7 +2295,7 @@ static inline void update_network(struct ieee80211_network *dst,
        dst->rates_len = src->rates_len;
        memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
        dst->rates_ex_len = src->rates_ex_len;
-       if(src->ssid_len > 0)
+       if (src->ssid_len > 0)
        {
                memset(dst->ssid, 0, dst->ssid_len);
                dst->ssid_len = src->ssid_len;
@@ -2352,7 +2351,7 @@ static inline void update_network(struct ieee80211_network *dst,
                dst->qos_data.param_count = src->qos_data.param_count;
        }
 
-       if(dst->qos_data.supported == 1) {
+       if (dst->qos_data.supported == 1) {
                dst->QoS_Enable = 1;
                if(dst->ssid_len)
                        IEEE80211_DEBUG_QOS
@@ -2367,7 +2366,7 @@ static inline void update_network(struct ieee80211_network *dst,
 
        /* dst->last_associate is not overwritten */
        dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
-       if(src->wmm_param[0].ac_aci_acm_aifsn|| \
+       if (src->wmm_param[0].ac_aci_acm_aifsn|| \
           src->wmm_param[1].ac_aci_acm_aifsn|| \
           src->wmm_param[2].ac_aci_acm_aifsn|| \
           src->wmm_param[3].ac_aci_acm_aifsn) {
@@ -2456,7 +2455,7 @@ static inline void ieee80211_process_probe_response(
 
        if (!IsLegalChannel(ieee, network.channel))
                return;
-       if(ieee->bGlobalDomain)
+       if (ieee->bGlobalDomain)
        {
                if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP)
                {
@@ -2472,7 +2471,7 @@ static inline void ieee80211_process_probe_response(
                        else
                        {
                                // Filter over channel ch12~14
-                               if(network.channel > 11)
+                               if (network.channel > 11)
                                {
                                        printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network.channel);
                                        return;
@@ -2493,7 +2492,7 @@ static inline void ieee80211_process_probe_response(
                        else
                        {
                                // Filter over channel ch12~14
-                               if(network.channel > 14)
+                               if (network.channel > 14)
                                {
                                        printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network.channel);
                                        return;
@@ -2514,9 +2513,9 @@ static inline void ieee80211_process_probe_response(
 
        spin_lock_irqsave(&ieee->lock, flags);
 
-       if(is_same_network(&ieee->current_network, &network, ieee)) {
+       if (is_same_network(&ieee->current_network, &network, ieee)) {
                update_network(&ieee->current_network, &network);
-               if((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G)
+               if ((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G)
                && ieee->current_network.berp_info_valid){
                if(ieee->current_network.erp_value& ERP_UseProtection)
                        ieee->current_network.buseprotection = true;
@@ -2606,7 +2605,7 @@ static inline void ieee80211_process_probe_response(
        spin_unlock_irqrestore(&ieee->lock, flags);
        if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, &network, ieee)&&\
                (ieee->state == IEEE80211_LINKED)) {
-               if(ieee->handle_beacon != NULL) {
+               if (ieee->handle_beacon != NULL) {
                        ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
                }
        }
index d1471877e19d6e0b8ee127d7317f41124921ad7a..c2388812d4fd71d15015accb08c728f450b5a3d8 100644 (file)
@@ -62,7 +62,7 @@ static void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
 {
        u8 *tag = *tag_p;
 
-       if (ieee->modulation & IEEE80211_CCK_MODULATION){
+       if (ieee->modulation & IEEE80211_CCK_MODULATION) {
                *tag++ = MFIE_TYPE_RATES;
                *tag++ = 4;
                *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
@@ -79,7 +79,7 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
 {
        u8 *tag = *tag_p;
 
-               if (ieee->modulation & IEEE80211_OFDM_MODULATION){
+               if (ieee->modulation & IEEE80211_OFDM_MODULATION) {
 
                *tag++ = MFIE_TYPE_RATES_EX;
                *tag++ = 8;
@@ -192,7 +192,7 @@ static u8 MgntQuery_MgntFrameTxRate(struct ieee80211_device *ieee)
        else
                rate = ieee->basic_rate & 0x7f;
 
-       if(rate == 0){
+       if (rate == 0) {
                // 2005.01.26, by rcnjko.
                if(ieee->mode == IEEE_A||
                   ieee->mode== IEEE_N_5G||
@@ -369,7 +369,7 @@ static void ieee80211_send_beacon(struct ieee80211_device *ieee)
        //unsigned long flags;
        skb = ieee80211_get_beacon_(ieee);
 
-       if (skb){
+       if (skb) {
                softmac_mgmt_xmit(skb, ieee);
                ieee->softmac_stats.tx_beacons++;
                //dev_kfree_skb_any(skb);//edit by thomas
@@ -378,7 +378,7 @@ static void ieee80211_send_beacon(struct ieee80211_device *ieee)
 //             (MSECS( ieee->current_network.beacon_interval -5));
 
        //spin_lock_irqsave(&ieee->beacon_lock,flags);
-       if(ieee->beacon_txing && ieee->ieee_up){
+       if (ieee->beacon_txing && ieee->ieee_up) {
 //             if(!timer_pending(&ieee->beacon_timer))
 //                     add_timer(&ieee->beacon_timer);
                mod_timer(&ieee->beacon_timer,jiffies+(MSECS(ieee->current_network.beacon_interval-5)));
@@ -404,7 +404,7 @@ static void ieee80211_send_probe(struct ieee80211_device *ieee)
        struct sk_buff *skb;
 
        skb = ieee80211_probe_req(ieee);
-       if (skb){
+       if (skb) {
                softmac_mgmt_xmit(skb, ieee);
                ieee->softmac_stats.tx_probe_rq++;
                //dev_kfree_skb_any(skb);//edit by thomas
@@ -413,7 +413,7 @@ static void ieee80211_send_probe(struct ieee80211_device *ieee)
 
 static void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
 {
-       if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
+       if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)) {
                ieee80211_send_probe(ieee);
                ieee80211_send_probe(ieee);
        }
@@ -587,7 +587,7 @@ static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
        down(&ieee->scan_sem);
 //     spin_lock_irqsave(&ieee->lock, flags);
 
-       if (ieee->scanning == 1){
+       if (ieee->scanning == 1) {
                ieee->scanning = 0;
 
                cancel_delayed_work(&ieee->softmac_scan_wq);
@@ -609,15 +609,15 @@ EXPORT_SYMBOL(ieee80211_stop_scan);
 /* called with ieee->lock held */
 static void ieee80211_start_scan(struct ieee80211_device *ieee)
 {
-       if(IS_DOT11D_ENABLE(ieee) )
+       if (IS_DOT11D_ENABLE(ieee) )
        {
-               if(IS_COUNTRY_IE_VALID(ieee))
+               if (IS_COUNTRY_IE_VALID(ieee))
                {
                        RESET_CIE_WATCHDOG(ieee);
                }
        }
        if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
-               if (ieee->scanning == 0){
+               if (ieee->scanning == 0) {
                        ieee->scanning = 1;
                        queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
                }
@@ -629,9 +629,9 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee)
 /* called with wx_sem held */
 void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
 {
-       if(IS_DOT11D_ENABLE(ieee) )
+       if (IS_DOT11D_ENABLE(ieee) )
        {
-               if(IS_COUNTRY_IE_VALID(ieee))
+               if (IS_COUNTRY_IE_VALID(ieee))
                {
                        RESET_CIE_WATCHDOG(ieee);
                }
@@ -739,7 +739,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
        HTConstructInfoElement(ieee,tmp_ht_info_buf,&tmp_ht_info_len, encrypt);
 
 
-       if(pHTInfo->bRegRT2RTAggregation)
+       if (pHTInfo->bRegRT2RTAggregation)
        {
                tmp_generic_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
                tmp_generic_ie_len = sizeof(ieee->pHTInfo->szRT2RTAggBuffer);
@@ -803,7 +803,7 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
        *(tag++) = 1;
        *(tag++) = ieee->current_network.channel;
 
-       if(atim_len){
+       if (atim_len) {
                *(tag++) = MFIE_TYPE_IBSS_SET;
                *(tag++) = 2;
 
@@ -812,12 +812,12 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *d
                tag+=2;
        }
 
-       if(erp_len){
+       if (erp_len) {
                *(tag++) = MFIE_TYPE_ERP;
                *(tag++) = 1;
                *(tag++) = erpinfo_content;
        }
-       if(rate_ex_len){
+       if (rate_ex_len) {
                *(tag++) = MFIE_TYPE_RATES_EX;
                *(tag++) = rate_ex_len-2;
                memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2);
@@ -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);
@@ -1016,12 +1016,12 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
        encrypt = ieee->host_encrypt && crypt && crypt->ops && ((0 == strcmp(crypt->ops->name,"WEP") || wpa_ie_len));
 
        //Include High Throuput capability && Realtek proprietary
-       if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
+       if (ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT)
        {
                ht_cap_buf = (u8 *)&(ieee->pHTInfo->SelfHTCap);
                ht_cap_len = sizeof(ieee->pHTInfo->SelfHTCap);
                HTConstructCapabilityElement(ieee, ht_cap_buf, &ht_cap_len, encrypt);
-               if(ieee->pHTInfo->bCurrentRT2RTAggregation)
+               if (ieee->pHTInfo->bCurrentRT2RTAggregation)
                {
                        realtek_ie_buf = ieee->pHTInfo->szRT2RTAggBuffer;
                        realtek_ie_len = sizeof( ieee->pHTInfo->szRT2RTAggBuffer);
@@ -1029,16 +1029,16 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
 
                }
        }
-       if(ieee->qos_support){
+       if (ieee->qos_support) {
                wmm_info_len = beacon->qos_data.supported?9:0;
        }
 
 
-       if(beacon->bCkipSupported)
+       if (beacon->bCkipSupported)
        {
                ckip_ie_len = 30+2;
        }
-       if(beacon->bCcxRmEnable)
+       if (beacon->bCcxRmEnable)
        {
                ccxrm_ie_len = 6+2;
        }
@@ -1141,7 +1141,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                tag += osCcxAironetIE.Length;
        }
 
-       if(beacon->bCcxRmEnable)
+       if (beacon->bCcxRmEnable)
        {
                static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
                OCTET_STRING osCcxRmCap;
@@ -1168,8 +1168,8 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                tag += osCcxVerNum.Length;
        }
        //HT cap element
-       if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
-               if(ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC)
+       if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
+               if (ieee->pHTInfo->ePeerHTSpecVer != HT_SPEC_VER_EWC)
                {
                        tag = skb_put(skb, ht_cap_len);
                        *tag++ = MFIE_TYPE_HT_CAP;
@@ -1182,22 +1182,22 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
 
        //choose what wpa_supplicant gives to associate.
        tag = skb_put(skb, wpa_ie_len);
-       if (wpa_ie_len){
+       if (wpa_ie_len) {
                memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len);
        }
 
        tag = skb_put(skb, wmm_info_len);
-       if(wmm_info_len) {
+       if (wmm_info_len) {
          ieee80211_WMM_Info(ieee, &tag);
        }
 #ifdef THOMAS_TURBO
        tag = skb_put(skb, turbo_info_len);
-       if(turbo_info_len) {
+       if (turbo_info_len) {
                ieee80211_TURBO_Info(ieee, &tag);
        }
 #endif
 
-       if(ieee->pHTInfo->bCurrentHTSupport&&ieee->pHTInfo->bEnableHT){
+       if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
                if(ieee->pHTInfo->ePeerHTSpecVer == HT_SPEC_VER_EWC)
                {
                        tag = skb_put(skb, ht_cap_len);
@@ -1207,7 +1207,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco
                        tag += ht_cap_len -2;
                }
 
-               if(ieee->pHTInfo->bCurrentRT2RTAggregation){
+               if (ieee->pHTInfo->bCurrentRT2RTAggregation) {
                        tag = skb_put(skb, realtek_ie_len);
                        *tag++ = MFIE_TYPE_GENERIC;
                        *tag++ = realtek_ie_len - 2;
@@ -1273,7 +1273,7 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee)
                //printk(KERN_WARNING "Sending authentication request\n");
                softmac_mgmt_xmit(skb, ieee);
                //BUGON when you try to add_timer twice, using mod_timer may be better, john0709
-               if(!timer_pending(&ieee->associate_timer)){
+               if (!timer_pending(&ieee->associate_timer)) {
                        ieee->associate_timer.expires = jiffies + (HZ / 2);
                        add_timer(&ieee->associate_timer);
                }
@@ -1358,7 +1358,7 @@ static void ieee80211_associate_complete_wq(struct work_struct *work)
        }
        ieee->LinkDetectInfo.SlotNum = 2 * (1 + ieee->current_network.beacon_interval/500);
        // To prevent the immediately calling watch_dog after association.
-       if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
+       if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
        {
                ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
                ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
@@ -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)
@@ -1430,7 +1430,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee
                return;
 
 
-       if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
+       if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) {
                /* if the user specified the AP MAC, we need also the essid
                 * This could be obtained by beacons or, if the network does not
                 * broadcast it, it can be put manually.
@@ -1458,13 +1458,13 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee
                                /* if the essid is hidden replace it with the
                                * essid provided by the user.
                                */
-                               if (!ssidbroad){
+                               if (!ssidbroad) {
                                        strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
                                        tmp_ssid_len = ieee->current_network.ssid_len;
                                }
                                memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
 
-                               if (!ssidbroad){
+                               if (!ssidbroad) {
                                        strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
                                        ieee->current_network.ssid_len = tmp_ssid_len;
                                }
@@ -1541,16 +1541,16 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
 {
        struct ieee80211_authentication *a;
        u8 *t;
-       if (skb->len <  (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
+       if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) {
                IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
                return 0xcafe;
        }
        *challenge = NULL;
        a = (struct ieee80211_authentication *) skb->data;
-       if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
+       if (skb->len > (sizeof(struct ieee80211_authentication) + 3)) {
                t = skb->data + sizeof(struct ieee80211_authentication);
 
-               if(*(t++) == MFIE_TYPE_CHALLENGE){
+               if (*(t++) == MFIE_TYPE_CHALLENGE) {
                        *chlen = *(t++);
                        *challenge = kmemdup(t, *chlen, GFP_ATOMIC);
                        if (!*challenge)
@@ -1567,7 +1567,7 @@ static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
 {
        struct ieee80211_authentication *a;
 
-       if (skb->len <  (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
+       if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) {
                IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
                return -1;
        }
@@ -1601,7 +1601,7 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb,
        tag = skb->data + sizeof (struct ieee80211_hdr_3addr  );
 
        while (tag+1 < skbend){
-               if (*tag == 0){
+               if (*tag == 0) {
                        ssid = tag+2;
                        ssidlen = *(tag+1);
                        break;
@@ -1642,7 +1642,7 @@ static inline u16 assoc_parse(struct ieee80211_device *ieee, struct sk_buff *skb
        struct ieee80211_assoc_response_frame *response_head;
        u16 status_code;
 
-       if (skb->len <  sizeof(struct ieee80211_assoc_response_frame)){
+       if (skb->len < sizeof(struct ieee80211_assoc_response_frame)) {
                IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
                return 0xcafe;
        }
@@ -1672,7 +1672,7 @@ ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
        //IEEE80211DMESG("Rx probe");
        ieee->softmac_stats.rx_probe_rq++;
        //DMESG("Dest is "MACSTR, MAC2STR(dest));
-       if (probe_rq_parse(ieee, skb, dest)){
+       if (probe_rq_parse(ieee, skb, dest)) {
                //IEEE80211DMESG("Was for me!");
                ieee->softmac_stats.tx_probe_rs++;
                ieee80211_resp_to_probe(ieee, dest);
@@ -1703,7 +1703,7 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
        //unsigned long flags;
 
        ieee->softmac_stats.rx_ass_rq++;
-       if (assoc_rq_parse(skb,dest) != -1){
+       if (assoc_rq_parse(skb, dest) != -1) {
                ieee80211_resp_to_assoc_rq(ieee, dest);
        }
 
@@ -1755,13 +1755,13 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h,
                (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
                return 0;
 
-       if(time_l){
+       if (time_l) {
                *time_l = ieee->current_network.last_dtim_sta_time[0]
                        + (ieee->current_network.beacon_interval
                        * ieee->current_network.dtim_period) * 1000;
        }
 
-       if(time_h){
+       if (time_h) {
                *time_h = ieee->current_network.last_dtim_sta_time[1];
                if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
                        *time_h += 1;
@@ -1782,7 +1782,7 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
 
        spin_lock_irqsave(&ieee->lock, flags);
 
-       if((ieee->ps == IEEE80211_PS_DISABLED ||
+       if ((ieee->ps == IEEE80211_PS_DISABLED ||
                ieee->iw_mode != IW_MODE_INFRA ||
                ieee->state != IEEE80211_LINKED)){
 
@@ -1841,8 +1841,8 @@ out:
 
 void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
 {
-       if(ieee->sta_sleep == 0){
-               if(nl){
+       if (ieee->sta_sleep == 0) {
+               if (nl) {
                        printk("Warning: driver is probably failing to report TX ps error\n");
                        ieee->ps_request_tx_ack(ieee->dev);
                        ieee80211_sta_ps_send_null_frame(ieee, 0);
@@ -1856,7 +1856,7 @@ void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
 
        ieee->sta_sleep = 0;
 
-       if(nl){
+       if (nl) {
                ieee->ps_request_tx_ack(ieee->dev);
                ieee80211_sta_ps_send_null_frame(ieee, 0);
        }
@@ -1870,7 +1870,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
 
        if(ieee->sta_sleep == 2){
                /* Null frame with PS bit set */
-               if(success){
+               if (success) {
                        ieee->sta_sleep = 1;
                        ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl);
                }
@@ -1881,7 +1881,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
        /* 21112005 - tx again null without PS bit if lost */
        else {
 
-               if((ieee->sta_sleep == 0) && !success){
+               if ((ieee->sta_sleep == 0) && !success) {
                        spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
                        ieee80211_sta_ps_send_null_frame(ieee, 0);
                        spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
@@ -1920,6 +1920,66 @@ static void ieee80211_process_action(struct ieee80211_device *ieee,
        return;
 
 }
+
+static 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;
@@ -1967,7 +2024,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
                                ieee->softmac_stats.rx_ass_ok++;
                                /* station support qos */
                                /* Let the register setting defaultly with Legacy station */
-                               if(ieee->qos_support) {
+                               if (ieee->qos_support) {
                                        assoc_resp = (struct ieee80211_assoc_response_frame *)skb->data;
                                        memset(network, 0, sizeof(*network));
                                        if (ieee80211_parse_info_param(ieee,assoc_resp->info_element,\
@@ -2013,68 +2070,16 @@ 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->softmac_features & IEEE_SOFTMAC_ASSOCIATE) {
+                       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.
@@ -2152,7 +2156,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
        ieee->stats.tx_bytes += txb->payload_size;
        ieee->stats.tx_packets++;
        tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE);
-       if(tcb_desc->bMulticast) {
+       if (tcb_desc->bMulticast) {
                ieee->stats.multicast++;
        }
        /* if xmit available, just xmit it immediately, else just insert it to the wait queue */
@@ -2224,7 +2228,7 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee)
 
        spin_lock_irqsave(&ieee->lock, flags);
        init_mgmt_queue(ieee);
-       if (ieee->tx_pending.txb){
+       if (ieee->tx_pending.txb) {
                ieee80211_txb_free(ieee->tx_pending.txb);
                ieee->tx_pending.txb = NULL;
        }
@@ -2246,7 +2250,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee)
 
        ieee->queue_stop = 0;
 
-       if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
+       if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) {
                while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
 
                        header = (struct ieee80211_hdr_3addr  *) skb->data;
@@ -2265,7 +2269,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee)
        if (!ieee->queue_stop && ieee->tx_pending.txb)
                ieee80211_resume_tx(ieee);
 
-       if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
+       if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) {
                ieee->softmac_stats.swtxawake++;
                netif_wake_queue(ieee->dev);
        }
@@ -2280,7 +2284,7 @@ void ieee80211_stop_queue(struct ieee80211_device *ieee)
        //unsigned long flags;
        //spin_lock_irqsave(&ieee->lock,flags);
 
-       if (! netif_queue_stopped(ieee->dev)){
+       if (!netif_queue_stopped(ieee->dev)) {
                netif_stop_queue(ieee->dev);
                ieee->softmac_stats.swtxstop++;
        }
@@ -2301,7 +2305,7 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee)
 {
        ieee->assoc_id = 1;
 
-       if (ieee->current_network.ssid_len == 0){
+       if (ieee->current_network.ssid_len == 0) {
                strncpy(ieee->current_network.ssid,
                        IEEE80211_DEFAULT_TX_ESSID,
                        IW_ESSID_MAX_SIZE);
@@ -2325,7 +2329,7 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee)
 
 static void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
 {
-       if(ieee->raw_tx){
+       if (ieee->raw_tx) {
 
                if (ieee->data_hard_resume)
                        ieee->data_hard_resume(ieee->dev);
@@ -2345,13 +2349,13 @@ static void ieee80211_start_ibss_wq(struct work_struct *work)
         * (abort) this wq (when syncro scanning) before sleeping
         * on the semaphore
         */
-       if(!ieee->proto_started){
+       if (!ieee->proto_started) {
                printk("==========oh driver down return\n");
                return;
        }
        down(&ieee->wx_sem);
 
-       if (ieee->current_network.ssid_len == 0){
+       if (ieee->current_network.ssid_len == 0) {
                strcpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID);
                ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
                ieee->ssid_set = 1;
@@ -2382,7 +2386,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work)
                ieee80211_start_scan_syncro(ieee);
 
        /* the network definitively is not here.. create a new cell */
-       if (ieee->state == IEEE80211_NOLINK){
+       if (ieee->state == IEEE80211_NOLINK) {
                printk("creating new IBSS cell\n");
                if(!ieee->wap_set)
                        ieee80211_randomize_cell(ieee);
@@ -2456,9 +2460,9 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
        // Ref: 802.11d 11.1.3.3
        // STA shall not start a BSS unless properly formed Beacon frame including a Country IE.
        //
-       if(IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee))
+       if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee))
        {
-               if(! ieee->bGlobalDomain)
+               if (! ieee->bGlobalDomain)
                {
                        return;
                }
@@ -2479,7 +2483,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
         */
        spin_lock_irqsave(&ieee->lock, flags);
 
-       if (ieee->state == IEEE80211_NOLINK){
+       if (ieee->state == IEEE80211_NOLINK) {
                ieee->actscanning = true;
                ieee80211_start_scan(ieee);
        }
@@ -2633,7 +2637,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee)
 
        ieee->proto_started = 1;
 
-       if (ieee->current_network.channel == 0){
+       if (ieee->current_network.channel == 0) {
                do{
                        ch++;
                        if (ch > MAX_CHANNEL_NUMBER)
@@ -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 =
@@ -3140,7 +3141,7 @@ SendDisassociation(
                struct ieee80211_network *beacon = &ieee->current_network;
                struct sk_buff *skb;
                skb = ieee80211_disassociate_skb(beacon,ieee,asRsn);
-               if (skb){
+               if (skb) {
                                softmac_mgmt_xmit(skb, ieee);
                                //dev_kfree_skb_any(skb);//edit by thomas
                }
@@ -3155,7 +3156,7 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin
        down(&ieee->wx_sem);
        //IEEE_DEBUG_INFO("wpa_supplicant: len=%d\n", p->length);
 
-       if (p->length < sizeof(struct ieee_param) || !p->pointer){
+       if (p->length < sizeof(struct ieee_param) || !p->pointer) {
                ret = -EINVAL;
                goto out;
        }
@@ -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..714fbcace72b1bc12db648f4fb293eccf67d34bc 100644 (file)
@@ -36,7 +36,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info
 
        down(&ieee->wx_sem);
 
-       if(ieee->iw_mode == IW_MODE_INFRA){
+       if (ieee->iw_mode == IW_MODE_INFRA) {
                ret = -EOPNOTSUPP;
                goto out;
        }
@@ -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);
@@ -148,12 +148,12 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
 
        down(&ieee->wx_sem);
        /* use ifconfig hw ether */
-       if (ieee->iw_mode == IW_MODE_MASTER){
+       if (ieee->iw_mode == IW_MODE_MASTER) {
                ret = -1;
                goto out;
        }
 
-       if (temp->sa_family != ARPHRD_ETHER){
+       if (temp->sa_family != ARPHRD_ETHER) {
                ret = -EINVAL;
                goto out;
        }
@@ -345,7 +345,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work)
        ieee->state = IEEE80211_LINKED;
        ieee->link_change(ieee->dev);
        // To prevent the immediately calling watch_dog after scan.
-       if(ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
+       if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 )
        {
                ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1;
                ieee->LinkDetectInfo.NumRecvDataInPeriod= 1;
@@ -369,7 +369,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info
 
        down(&ieee->wx_sem);
 
-       if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
+       if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) {
                ret = -1;
                goto out;
        }
@@ -400,12 +400,12 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
 
        proto_started = ieee->proto_started;
 
-       if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
+       if (wrqu->essid.length > IW_ESSID_MAX_SIZE) {
                ret= -E2BIG;
                goto out;
        }
 
-       if (ieee->iw_mode == IW_MODE_MONITOR){
+       if (ieee->iw_mode == IW_MODE_MONITOR) {
                ret= -1;
                goto out;
        }
@@ -469,9 +469,9 @@ EXPORT_SYMBOL(ieee80211_wx_get_mode);
        printk(KERN_INFO"raw TX is %s\n",
              ieee->raw_tx ? "enabled" : "disabled");
 
-       if(ieee->iw_mode == IW_MODE_MONITOR)
+       if (ieee->iw_mode == IW_MODE_MONITOR)
        {
-               if(prev == 0 && ieee->raw_tx){
+               if (prev == 0 && ieee->raw_tx) {
                        if (ieee->data_hard_resume)
                                ieee->data_hard_resume(ieee->dev);
 
@@ -522,7 +522,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee,
        int ret = 0;
        down(&ieee->wx_sem);
 
-       if (wrqu->power.disabled){
+       if (wrqu->power.disabled) {
                ieee->ps = IEEE80211_PS_DISABLED;
                goto exit;
        }
@@ -572,7 +572,7 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee,
 {
        down(&ieee->wx_sem);
 
-       if(ieee->ps == IEEE80211_PS_DISABLED){
+       if (ieee->ps == IEEE80211_PS_DISABLED) {
                wrqu->power.disabled = 1;
                goto exit;
        }
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 1b4623c3f95ef3c0272c1b3118eb56db4c3dc204..618d2cbc049ec0118d5bb2ccb24fdc345ed6f85f 100644 (file)
@@ -46,14 +46,14 @@ static u8 TxTsDeleteBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTs)
        u8                      bSendDELBA = false;
 
        // Delete pending BA
-       if(pPendingBa->bValid)
+       if (pPendingBa->bValid)
        {
                DeActivateBAEntry(ieee, pPendingBa);
                bSendDELBA = true;
        }
 
        // Delete admitted BA
-       if(pAdmittedBa->bValid)
+       if (pAdmittedBa->bValid)
        {
                DeActivateBAEntry(ieee, pAdmittedBa);
                bSendDELBA = true;
@@ -74,7 +74,7 @@ static u8 RxTsDeleteBA(struct ieee80211_device *ieee, PRX_TS_RECORD pRxTs)
        PBA_RECORD              pBa = &pRxTs->RxAdmittedBARecord;
        u8                      bSendDELBA = false;
 
-       if(pBa->bValid)
+       if (pBa->bValid)
        {
                DeActivateBAEntry(ieee, pBa);
                bSendDELBA = true;
@@ -363,7 +363,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
 
        printk("====================>rx ADDBAREQ from :%pM\n", dst);
 //some other capability is not ready now.
-       if(     (ieee->current_network.qos_data.active == 0) ||
+       if ((ieee->current_network.qos_data.active == 0) ||
                (ieee->pHTInfo->bCurrentHTSupport == false)) //||
        //      (ieee->pStaQos->bEnableRxImmBA == false)        )
        {
@@ -373,7 +373,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
        }
        // Search for related traffic stream.
        // If there is no matched TS, reject the ADDBA request.
-       if(     !GetTs(
+       if (!GetTs(
                        ieee,
                        (PTS_COMMON_INFO *)(&pTS),
                        dst,
@@ -390,7 +390,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
        // We can do much more check here, including BufferSize, AMSDU_Support, Policy, StartSeqCtrl...
        // I want to check StartSeqCtrl to make sure when we start aggregation!!!
        //
-       if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
+       if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
        {
                rc = ADDBA_STATUS_INVALID_PARAM;
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "BA Policy is not correct in %s()\n", __func__);
@@ -522,7 +522,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
                // We can compare the value of BA parameter set that Peer returned and Self sent.
                // If it is OK, then admitted. Or we can send DELBA to cancel BA mechanism.
                //
-               if(pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
+               if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED)
                {
                        // Since this is a kind of ADDBA failed, we delay next ADDBA process.
                        pTS->bAddBaReqDelayed = true;
@@ -582,7 +582,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
                return -1;
        }
 
-       if(ieee->current_network.qos_data.active == 0 ||
+       if (ieee->current_network.qos_data.active == 0 ||
                ieee->pHTInfo->bCurrentHTSupport == false )
        {
                IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
@@ -600,7 +600,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
        {
                PRX_TS_RECORD   pRxTs;
 
-               if!GetTs(
+               if (!GetTs(
                                ieee,
                                (PTS_COMMON_INFO *)&pRxTs,
                                dst,
@@ -618,7 +618,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
        {
                PTX_TS_RECORD   pTxTs;
 
-               if(!GetTs(
+               if (!GetTs(
                        ieee,
                        (PTS_COMMON_INFO *)&pTxTs,
                        dst,
index e60d926a3973f42445ccb4437f75a336aacdce11..c2588f80625b99e23c9aaf519e35ef22f62c1746 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;
 }
 
 /********************************************************************************************************************
@@ -508,7 +503,7 @@ static u8 HTIOTActIsMgntUseCCK6M(struct ieee80211_network *network)
        // 2008/01/25 MH Judeg if we need to use OFDM to sned MGNT frame for broadcom AP.
        // 2008/01/28 MH We must prevent that we select null bssid to link.
 
-       if(network->broadcom_cap_exist)
+       if (network->broadcom_cap_exist)
        {
                retValue = 1;
        }
@@ -625,7 +620,7 @@ void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u
 
        // 2008.06.12
        // For RTL819X, if pairwisekey = wep/tkip, ap is ralink, we support only MCS0~7.
-       if(ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
+       if (ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev))
        {
                int i;
                for(i = 1; i< 16; i++)
@@ -752,7 +747,7 @@ void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg,
        *posRT2RTAgg++ = 0x01;
        *posRT2RTAgg = 0x10;//*posRT2RTAgg = 0x02;
 
-       if(ieee->bSupportRemoteWakeUp) {
+       if (ieee->bSupportRemoteWakeUp) {
                *posRT2RTAgg |= 0x08;//RT_HT_CAP_USE_WOW;
        }
 
@@ -879,17 +874,17 @@ u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSF
 
        for(i = 0; i < 16; i++)
        {
-               if(availableMcsRate[i] != 0)
+               if (availableMcsRate[i] != 0)
                {
                        bitMap = availableMcsRate[i];
                        for(j = 0; j < 8; j++)
                        {
-                               if((bitMap%2) != 0)
+                               if ((bitMap%2) != 0)
                                {
                                        if(HTMcsToDataRate(ieee, (8*i+j)) > HTMcsToDataRate(ieee, mcsRate))
                                                mcsRate = (8*i+j);
                                }
-                               bitMap = bitMap>>1;
+                               bitMap >>= 1;
                        }
                }
        }
@@ -1067,7 +1062,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee)
 
        // Lanhsin: mark for tmp to avoid deauth by ap from  s3
        //if(memcmp(pMgntInfo->Bssid, NETGEAR834Bv2_BROADCOM, 3)==0)
-       if(0)
+       if (0)
                {
 
                        pHTInfo->bCurrentAMPDUEnable = false;
@@ -1303,7 +1298,7 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee,    struct ieee80211_
 //     PHT_CAPABILITY_ELE              pPeerHTCap = (PHT_CAPABILITY_ELE)pNetwork->bssht.bdHTCapBuf;
        PHT_INFORMATION_ELE             pPeerHTInfo = (PHT_INFORMATION_ELE)pNetwork->bssht.bdHTInfoBuf;
 
-       if(pHTInfo->bCurrentHTSupport)
+       if (pHTInfo->bCurrentHTSupport)
        {
                //
                // Config current operation mode.
@@ -1328,7 +1323,7 @@ EXPORT_SYMBOL(HTUpdateSelfAndPeerSetting);
 ********************************************************************************************************************/
 u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame)
 {
-       if(ieee->pHTInfo->bCurrentHTSupport)
+       if (ieee->pHTInfo->bCurrentHTSupport)
        {
                if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
                        IEEE80211_DEBUG(IEEE80211_DL_HT, "HT CONTROL FILED EXIST!!\n");
@@ -1357,7 +1352,7 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH   Bandwidt
 //             return;
 
 //     spin_lock_irqsave(&(ieee->bw_spinlock), flags);
-       if(pHTInfo->bSwBwInProgress) {
+       if (pHTInfo->bSwBwInProgress) {
 //             spin_unlock_irqrestore(&(ieee->bw_spinlock), flags);
                return;
        }
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..a4795afeeb9ca619190802d744b6c49be3e7dd8d 100644 (file)
@@ -408,9 +408,8 @@ inline void force_pci_posting(struct net_device *dev)
 }
 
 static struct net_device_stats *rtl8192_stats(struct net_device *dev);
-void rtl8192_commit(struct net_device *dev);
-void rtl8192_restart(struct work_struct *work);
-void watch_dog_timer_callback(unsigned long data);
+static void rtl8192_restart(struct work_struct *work);
+static void watch_dog_timer_callback(unsigned long data);
 
 /****************************************************************************
  *   -----------------------------PROCFS STUFF-------------------------
@@ -827,7 +826,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 +964,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
@@ -1766,7 +1762,7 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev)
 }
 #endif
 
-extern void rtl8192_update_ratr_table(struct net_device *dev);
+static void rtl8192_update_ratr_table(struct net_device *dev);
 static void rtl8192_link_change(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
@@ -1971,7 +1967,7 @@ static int rtl8192_handle_assoc_response(struct net_device *dev,
 }
 
 
-void rtl8192_update_ratr_table(struct net_device *dev)
+static void rtl8192_update_ratr_table(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
        struct ieee80211_device *ieee = priv->ieee80211;
@@ -2067,7 +2063,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 +2073,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 +2138,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;
 
@@ -2247,9 +2242,9 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv)
        mutex_init(&priv->mutex);
 }
 
-extern  void    rtl819x_watchdog_wqcallback(struct work_struct *work);
+static void rtl819x_watchdog_wqcallback(struct work_struct *work);
 
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
+static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv);
 //init tasklet and wait_queue here. only 2.6 above kernel is considered
 #define DRV_NAME "wlan0"
 static void rtl8192_init_priv_task(struct net_device *dev)
@@ -2310,11 +2305,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 +2392,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 +2406,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 +2450,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 +2502,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 +2543,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 +2681,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 +2762,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 +2809,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 +2869,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 +2915,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 +2946,7 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev)
        }
 
        if (priv->RxCounter == RegRxCounter)
-               bStuck = TRUE;
+               bStuck = true;
 
        priv->RxCounter = RegRxCounter;
 
@@ -2961,10 +2956,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)) {
@@ -3021,9 +3016,9 @@ static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev)
 
 }
 
-void rtl8192_cancel_deferred_work(struct r8192_priv *priv);
-int _rtl8192_up(struct net_device *dev);
-int rtl8192_close(struct net_device *dev);
+static void rtl8192_cancel_deferred_work(struct r8192_priv *priv);
+static int _rtl8192_up(struct net_device *dev);
+static int rtl8192_close(struct net_device *dev);
 
 
 
@@ -3642,7 +3637,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 +4033,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 +4053,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 +4203,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 +4222,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 +4469,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..6e776e5433f67bfb96e6a5dda56c46713842436e 100644 (file)
@@ -177,7 +177,7 @@ static uint loadparam(struct _adapter *padapter, struct  net_device *pnetdev)
 
 static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev);
+       struct _adapter *padapter = netdev_priv(pnetdev);
        struct sockaddr *addr = p;
 
        if (padapter->bup == false)
@@ -187,7 +187,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
 
 static struct net_device_stats *r871x_net_get_stats(struct net_device *pnetdev)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(pnetdev);
+       struct _adapter *padapter = netdev_priv(pnetdev);
        struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
        struct recv_priv *precvpriv = &(padapter->recvpriv);
 
@@ -221,7 +221,7 @@ struct net_device *r8712_init_netdev(void)
                strcpy(ifname, "wlan%d");
                dev_alloc_name(pnetdev, ifname);
        }
-       padapter = (struct _adapter *) netdev_priv(pnetdev);
+       padapter = netdev_priv(pnetdev);
        padapter->pnetdev = pnetdev;
        pr_info("r8712u: register rtl8712_netdev_ops to netdev_ops\n");
        pnetdev->netdev_ops = &rtl8712_netdev_ops;
@@ -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);
@@ -384,7 +384,7 @@ static void enable_video_mode(struct _adapter *padapter, int cbw40_value)
  */
 static int netdev_open(struct net_device *pnetdev)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev);
+       struct _adapter *padapter = netdev_priv(pnetdev);
 
        mutex_lock(&padapter->mutex_start);
        if (padapter->bup == false) {
@@ -452,7 +452,7 @@ netdev_open_error:
  */
 static int netdev_close(struct net_device *pnetdev)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(pnetdev);
+       struct _adapter *padapter = netdev_priv(pnetdev);
 
        /* Close LED*/
        padapter->ledpriv.LedControlHandler(padapter, LED_CTL_POWER_OFF);
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..42fba3f5b593e08801a57269ede5e21da8c8841f 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;
@@ -360,7 +363,7 @@ static inline char *translate_scan(struct _adapter *padapter,
 
 static int wpa_set_auth_algs(struct net_device *dev, u32 value)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        int ret = 0;
 
        if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) {
@@ -392,7 +395,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
        int ret = 0;
        u32 wep_key_idx, wep_key_len = 0;
        struct NDIS_802_11_WEP   *pwep = NULL;
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct security_priv *psecuritypriv = &padapter->securitypriv;
 
@@ -626,7 +629,7 @@ static int r8711_wx_get_name(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        u32 ht_ielen = 0;
        char *p;
        u8 ht_cap = false;
@@ -682,7 +685,7 @@ static int r8711_wx_set_freq(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_freq *fwrq = &wrqu->freq;
        int rc = 0;
 
@@ -718,7 +721,7 @@ static int r8711_wx_get_freq(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
@@ -737,7 +740,7 @@ static int r8711_wx_set_mode(struct net_device *dev,
                             struct iw_request_info *a,
                             union iwreq_data *wrqu, char *b)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
 
        switch (wrqu->mode) {
@@ -768,7 +771,7 @@ static int r8711_wx_set_mode(struct net_device *dev,
 static int r8711_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
                             union iwreq_data *wrqu, char *b)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
@@ -787,7 +790,7 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                             struct iw_request_info *a,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct iw_pmksa *pPMK = (struct iw_pmksa *) extra;
        u8 strZeroMacAddress[ETH_ALEN] = {0x00};
@@ -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;
                        }
@@ -1059,7 +1061,7 @@ static int r8711_wx_set_wap(struct net_device *dev,
                         char *extra)
 {
        int ret = -EINPROGRESS;
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct  __queue *queue = &pmlmepriv->scanned_queue;
        struct sockaddr *temp = (struct sockaddr *)awrq;
@@ -1108,16 +1110,16 @@ static int r8711_wx_get_wap(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
        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;
 }
 
@@ -1126,7 +1128,7 @@ static int r871x_wx_set_mlme(struct net_device *dev,
                             union iwreq_data *wrqu, char *extra)
 {
        int ret = 0;
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_mlme *mlme = (struct iw_mlme *) extra;
 
        if (mlme == NULL)
@@ -1158,7 +1160,7 @@ static int r8711_wx_set_scan(struct net_device *dev,
                        struct iw_request_info *a,
                        union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        u8 status = true;
 
@@ -1207,7 +1209,7 @@ static int r8711_wx_get_scan(struct net_device *dev,
                                struct iw_request_info *a,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct  __queue *queue = &pmlmepriv->scanned_queue;
        struct wlan_network *pnetwork = NULL;
@@ -1261,7 +1263,7 @@ static int r8711_wx_set_essid(struct net_device *dev,
                                struct iw_request_info *a,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct  __queue *queue = &pmlmepriv->scanned_queue;
        struct wlan_network *pnetwork = NULL;
@@ -1324,7 +1326,7 @@ static int r8711_wx_get_essid(struct net_device *dev,
                                struct iw_request_info *a,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
        u32 len, ret = 0;
@@ -1344,7 +1346,7 @@ static int r8711_wx_set_rate(struct net_device *dev,
                                struct iw_request_info *a,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        u32 target_rate = wrqu->bitrate.value;
        u32 fixed = wrqu->bitrate.fixed;
        u32 ratevalue = 0;
@@ -1416,7 +1418,7 @@ static int r8711_wx_get_rate(struct net_device *dev,
                             struct iw_request_info *info,
                             union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
        struct ieee80211_ht_cap *pht_capie;
@@ -1473,7 +1475,7 @@ static int r8711_wx_get_rts(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        wrqu->rts.value = padapter->registrypriv.rts_thresh;
        wrqu->rts.fixed = 0;    /* no auto select */
@@ -1484,7 +1486,7 @@ static int r8711_wx_set_frag(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        if (wrqu->frag.disabled)
                padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
@@ -1501,7 +1503,7 @@ static int r8711_wx_get_frag(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        wrqu->frag.value = padapter->xmitpriv.frag_len;
        wrqu->frag.fixed = 0;   /* no auto select */
@@ -1527,7 +1529,7 @@ static int r8711_wx_set_enc(struct net_device *dev,
        struct NDIS_802_11_WEP   wep;
        enum NDIS_802_11_AUTHENTICATION_MODE authmode;
        struct iw_point *erq = &(wrqu->encoding);
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        key = erq->flags & IW_ENCODE_INDEX;
        memset(&wep, 0, sizeof(struct NDIS_802_11_WEP));
@@ -1619,7 +1621,7 @@ static int r8711_wx_get_enc(struct net_device *dev,
                                union iwreq_data *wrqu, char *keybuf)
 {
        uint key, ret = 0;
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_point *erq = &(wrqu->encoding);
        struct  mlme_priv       *pmlmepriv = &(padapter->mlmepriv);
 
@@ -1691,7 +1693,7 @@ static int r871x_wx_set_gen_ie(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        return r871x_set_wpa_ie(padapter, extra, wrqu->data.length);
 }
@@ -1700,7 +1702,7 @@ static int r871x_wx_set_auth(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_param *param = (struct iw_param *)&(wrqu->param);
        int paramid;
        int paramval;
@@ -1847,7 +1849,7 @@ static int r8711_wx_read32(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *keybuf)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        u32 addr;
        u32 data32;
 
@@ -1864,7 +1866,7 @@ static int r8711_wx_write32(struct net_device *dev,
                                 struct iw_request_info *info,
                                 union iwreq_data *wrqu, char *keybuf)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        u32 addr;
        u32 data32;
 
@@ -1892,7 +1894,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_point *p = &wrqu->data;
        struct oid_par_priv oid_par;
        struct mp_ioctl_handler *phandler;
@@ -1910,13 +1912,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
        bset = (u8)(p->flags & 0xFFFF);
        len = p->length;
        pparmbuf = NULL;
-       pparmbuf = kmalloc(len, GFP_ATOMIC);
-       if (pparmbuf == NULL) {
-               ret = -ENOMEM;
-               goto _r871x_mp_ioctl_hdl_exit;
-       }
-       if (copy_from_user(pparmbuf, p->pointer, len)) {
-               ret = -EFAULT;
+       pparmbuf = memdup_user(p->pointer, len);
+       if (IS_ERR(pparmbuf)) {
+               ret = PTR_ERR(pparmbuf);
                goto _r871x_mp_ioctl_hdl_exit;
        }
        poidparam = (struct mp_ioctl_param *)pparmbuf;
@@ -1975,7 +1973,7 @@ static int r871x_get_ap_info(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct  __queue *queue = &pmlmepriv->scanned_queue;
        struct iw_point *pdata = &wrqu->data;
@@ -2046,7 +2044,7 @@ static int r871x_set_pid(struct net_device *dev,
                                struct iw_request_info *info,
                                union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_point *pdata = &wrqu->data;
 
        if ((padapter->bDriverStopped) || (pdata == NULL))
@@ -2061,7 +2059,7 @@ static int r871x_set_chplan(struct net_device *dev,
                                union iwreq_data *wrqu, char *extra)
 {
        int ret = 0;
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_point *pdata = &wrqu->data;
        int ch_plan = -1;
 
@@ -2081,7 +2079,7 @@ static int r871x_wps_start(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_point *pdata = &wrqu->data;
        u32   u32wps_start = 0;
 
@@ -2105,7 +2103,7 @@ static int r871x_wps_start(struct net_device *dev,
 
 static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        switch (name) {
        case IEEE_PARAM_WPA_ENABLED:
@@ -2157,7 +2155,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
 
 static int wpa_mlme(struct net_device *dev, u32 command, u32 reason)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        switch (command) {
        case IEEE_MLME_STA_DEAUTH:
@@ -2178,7 +2176,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
 {
        struct ieee_param *param;
        int ret = 0;
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
 
        if (p->length < sizeof(struct ieee_param) || !p->pointer)
                return -EINVAL;
@@ -2331,7 +2329,7 @@ static iw_handler r8711_private_handler[] = {
 
 static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev)
 {
-       struct _adapter *padapter = (struct _adapter *) netdev_priv(dev);
+       struct _adapter *padapter = netdev_priv(dev);
        struct iw_statistics *piwstats = &padapter->iwstats;
        int tmp_level = 0;
        int tmp_qual = 0;
index 6318a0e65e6e6c9831f07ccde9f90b3c25967707..22262b3558bacd5db51f174cd416fdbc0f332c4e 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
@@ -265,8 +266,7 @@ void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
                /* clear WIFI_STATION_STATE; WIFI_AP_STATE; WIFI_ADHOC_STATE;
                 * WIFI_ADHOC_MASTER_STATE */
                _clr_fwstate_(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE |
-                             WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE |
-                             WIFI_AP_STATE);
+                             WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE);
                switch (networktype) {
                case Ndis802_11IBSS:
                        set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
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..bcd1a51288689d1043d069b3d96829baa87b8408 100644 (file)
@@ -153,7 +153,7 @@ static u32 getcrc32(u8 *buf, u32 len)
        u8 *p;
        u32  crc;
 
-       if (bcrc32initialized == 0)
+       if (!bcrc32initialized)
                crc32_init();
        crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
        for (p = buf; len > 0; ++p, --len)
@@ -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 039b598152bca572491e7020ac7abfddb504a7bc..d15fb1ad45b9f9128f924a96b56e32243aa12987 100644 (file)
@@ -162,7 +162,7 @@ void r8712_xmit_complete(struct _adapter *padapter, struct xmit_frame *pxframe)
 int r8712_xmit_entry(_pkt *pkt, struct  net_device *pnetdev)
 {
        struct xmit_frame *pxmitframe = NULL;
-       struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev);
+       struct _adapter *padapter = netdev_priv(pnetdev);
        struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
        int ret = 0;
 
index c6327c07291837396861062d23f3e0c1e40e3457..645668950e9cc817545ecb1a6f9279b1afcc9a38 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;
        }
 
@@ -262,15 +260,17 @@ void      expire_timeout_chk23a(struct rtw_adapter *padapter)
                        list_del_init(&psta->asoc_list);
                        pstapriv->asoc_list_cnt--;
 
-                       DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
+                       DBG_8723A("asoc expire %pM, state = 0x%x\n",
+                                 psta->hwaddr, psta->state);
                        updated = ap_free_sta23a(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING);
                } else {
                        /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */
                        if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt)
                                && padapter->xmitpriv.free_xmitframe_cnt < ((NR_XMITFRAME/pstapriv->asoc_list_cnt)/2)
                        ) {
-                               DBG_8723A("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__,
-                                         MAC_ARG(psta->hwaddr),
+                               DBG_8723A("%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n",
+                                         __func__,
+                                         psta->hwaddr,
                                          psta->sleepq_len,
                                          padapter->xmitpriv.free_xmitframe_cnt,
                                          pstapriv->asoc_list_cnt);
@@ -307,7 +307,8 @@ void        expire_timeout_chk23a(struct rtw_adapter *padapter)
 
                psta->keep_alive_trycnt++;
                if (ret == _SUCCESS) {
-                       DBG_8723A("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr));
+                       DBG_8723A("asoc check, sta(%pM) is alive\n",
+                                 psta->hwaddr);
                        psta->expire_to = pstapriv->expire_to;
                        psta->keep_alive_trycnt = 0;
                        continue;
@@ -319,7 +320,8 @@ void        expire_timeout_chk23a(struct rtw_adapter *padapter)
 
                psta->keep_alive_trycnt = 0;
 
-               DBG_8723A("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state);
+               DBG_8723A("asoc expire %pM, state = 0x%x\n",
+                         psta->hwaddr, psta->state);
                spin_lock_bh(&pstapriv->asoc_list_lock);
                if (!list_empty(&psta->asoc_list)) {
                        list_del_init(&psta->asoc_list);
@@ -785,6 +787,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 */
@@ -1045,7 +1048,7 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr)
        struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
        struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q;
 
-       DBG_8723A("%s(acl_num =%d) =" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr));
+       DBG_8723A("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, addr);
 
        if ((NUM_ACL-1) < pacl_list->num)
                return -1;
@@ -1477,8 +1480,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 %pM HT Capabilities Info: 0x%04x\n",
+                         psta->hwaddr, ht_capab);
 
                if (psta->no_ht_set) {
                        psta->no_ht_set = 0;
@@ -1490,10 +1493,9 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                                psta->no_ht_gf_set = 1;
                                pmlmepriv->num_sta_ht_no_gf++;
                        }
-                       DBG_8723A("%s STA " MAC_FMT " - no "
-                                  "greenfield, num of non-gf stations %d\n",
-                                  __func__, MAC_ARG(psta->hwaddr),
-                                  pmlmepriv->num_sta_ht_no_gf);
+                       DBG_8723A("%s STA %pM - no greenfield, num of non-gf stations %d\n",
+                                 __func__, psta->hwaddr,
+                                 pmlmepriv->num_sta_ht_no_gf);
                }
 
                if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) {
@@ -1501,10 +1503,9 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                                psta->ht_20mhz_set = 1;
                                pmlmepriv->num_sta_ht_20mhz++;
                        }
-                       DBG_8723A("%s STA " MAC_FMT " - 20 MHz HT, "
-                                  "num of 20MHz HT STAs %d\n",
-                                  __func__, MAC_ARG(psta->hwaddr),
-                                  pmlmepriv->num_sta_ht_20mhz);
+                       DBG_8723A("%s STA %pM - 20 MHz HT, num of 20MHz HT STAs %d\n",
+                                 __func__, psta->hwaddr,
+                                 pmlmepriv->num_sta_ht_20mhz);
                }
 
        } else {
@@ -1513,10 +1514,9 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info
                        pmlmepriv->num_sta_no_ht++;
                }
                if (pmlmepriv->htpriv.ht_option) {
-                       DBG_8723A("%s STA " MAC_FMT
-                                  " - no HT, num of non-HT stations %d\n",
-                                  __func__, MAC_ARG(psta->hwaddr),
-                                  pmlmepriv->num_sta_no_ht);
+                       DBG_8723A("%s STA %pM - no HT, num of non-HT stations %d\n",
+                                 __func__, psta->hwaddr,
+                                 pmlmepriv->num_sta_no_ht);
                }
        }
 
index 2447a56df8381c48eddac40fe3d7fcd1c05c6f6f..46aea16cbf7887c429c200aa3b11cb413b265c3e 100644 (file)
@@ -299,9 +299,8 @@ post_process:
                pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback;
                if (!pcmd_callback) {
                        RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                                ("mlme_cmd_hdl(): pcmd_callback = 0x%p, "
-                                 "cmdcode = 0x%x\n",
-                                 pcmd_callback, pcmd->cmdcode));
+                                "mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n",
+                                pcmd_callback, pcmd->cmdcode);
                        rtw_free_cmd_obj23a(pcmd);
                } else {
                        /* need consider that free cmd_obj in
@@ -310,8 +309,8 @@ post_process:
                }
        } else {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("%s: cmdcode = 0x%x callback not defined!\n",
-                         __func__, pcmd->cmdcode));
+                        "%s: cmdcode = 0x%x callback not defined!\n",
+                        __func__, pcmd->cmdcode);
                rtw_free_cmd_obj23a(pcmd);
        }
 }
@@ -343,7 +342,7 @@ int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter,
        rtw_free_network_queue23a(padapter);
 
        RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                ("%s: flush network queue\n", __func__));
+                "%s: flush network queue\n", __func__);
 
        init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara,
                                   GEN_CMD_CODE(_SiteSurvey));
@@ -412,12 +411,12 @@ int rtw_createbss_cmd23a(struct rtw_adapter  *padapter)
 
        if (pmlmepriv->assoc_ssid.ssid_len == 0) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                        (" createbss for Any SSid:%s\n",
-                         pmlmepriv->assoc_ssid.ssid));
+                        "createbss for Any SSid:%s\n",
+                        pmlmepriv->assoc_ssid.ssid);
        } else {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                        (" createbss for SSid:%s\n",
-                         pmlmepriv->assoc_ssid.ssid));
+                        "createbss for SSid:%s\n",
+                        pmlmepriv->assoc_ssid.ssid);
        }
 
        pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
@@ -460,19 +459,18 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
 
        if (pmlmepriv->assoc_ssid.ssid_len == 0) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_,
-                        ("+Join cmd: Any SSid\n"));
+                        "+Join cmd: Any SSid\n");
        } else {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_,
-                        ("+Join cmd: SSid =[%s]\n",
-                         pmlmepriv->assoc_ssid.ssid));
+                        "+Join cmd: SSid =[%s]\n",
+                        pmlmepriv->assoc_ssid.ssid);
        }
 
        pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
        if (!pcmd) {
                res = _FAIL;
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("rtw_joinbss_cmd23a: memory allocate for cmd_obj "
-                         "fail!!!\n"));
+                        "rtw_joinbss_cmd23a: memory allocate for cmd_obj fail!!!\n");
                goto exit;
        }
 
@@ -497,7 +495,7 @@ int rtw_joinbss_cmd23a(struct rtw_adapter *padapter,
                res = _FAIL;
 
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("rtw_joinbss_cmd23a :psecnetwork == NULL!!!\n"));
+                        "rtw_joinbss_cmd23a :psecnetwork == NULL!!!\n");
 
                goto exit;
        }
@@ -599,7 +597,7 @@ int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms,
        int res = _SUCCESS;
 
        RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_,
-                ("+rtw_disassoc_cmd23a\n"));
+                "+rtw_disassoc_cmd23a\n");
 
        /* prepare cmd parameter */
        param = kzalloc(sizeof(*param), GFP_ATOMIC);
@@ -1291,8 +1289,7 @@ void rtw_survey_cmd_callback23a(struct rtw_adapter *padapter,
                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_bssid23a_"
-                         "LIST_SCAN Fail ************\n\n."));
+                        "********Error: MgntActrtw_set_802_11_bssid23a_LIST_SCAN Fail ************\n");
        }
 
        /*  free cmd */
@@ -1309,7 +1306,7 @@ void rtw_disassoc_cmd23a_callback(struct rtw_adapter *padapter,
                set_fwstate(pmlmepriv, _FW_LINKED);
                spin_unlock_bh(&pmlmepriv->lock);
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\n ***Error: disconnect_cmd_callback Fail ***\n."));
+                        "***Error: disconnect_cmd_callback Fail ***\n");
                return;
        }
 
@@ -1329,8 +1326,7 @@ void rtw_joinbss_cmd23a_callback(struct rtw_adapter *padapter,
                          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"));
+                        "********Error:rtw_select_and_join_from_scanned_queue Wait Sema  Fail ************\n");
                mod_timer(&pmlmepriv->assoc_timer,
                          jiffies + msecs_to_jiffies(1));
        }
@@ -1349,8 +1345,7 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter,
 
        if (pcmd->res != H2C_SUCCESS) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\n ********Error: rtw_createbss_cmd23a_callback  "
-                         "Fail ************\n\n."));
+                        "********Error: rtw_createbss_cmd23a_callback  Fail ************\n");
                mod_timer(&pmlmepriv->assoc_timer,
                          jiffies + msecs_to_jiffies(1));
        }
@@ -1366,9 +1361,8 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter,
                                                    GFP_KERNEL);
                        if (!psta) {
                                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                                        ("\nCan't alloc sta_info when "
-                                         "createbss_cmd_callback\n"));
-                               goto createbss_cmd_fail ;
+                                        "Can't alloc sta_info when createbss_cmd_callback\n");
+                               goto createbss_cmd_fail;
                        }
                }
 
@@ -1382,8 +1376,7 @@ void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter,
                        pwlan = rtw_get_oldest_wlan_network23a(&pmlmepriv->scanned_queue);
                        if (!pwlan) {
                                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                                        ("\n Error:  can't get pwlan in "
-                                         "rtw23a_joinbss_event_cb\n"));
+                                        "Error:  can't get pwlan in rtw23a_joinbss_event_cb\n");
                                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                goto createbss_cmd_fail;
                        }
@@ -1432,8 +1425,7 @@ void rtw_setstaKey_cmdrsp_callback23a(struct rtw_adapter *padapter,
 
        if (!psta) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\nERROR: rtw_setstaKey_cmdrsp_callback23a => "
-                         "can't get sta_info\n\n"));
+                        "ERROR: rtw_setstaKey_cmdrsp_callback23a => can't get sta_info\n");
                goto exit;
        }
 
@@ -1457,8 +1449,7 @@ void rtw_setassocsta_cmdrsp_callback23a(struct rtw_adapter *padapter,
 
        if (psta == NULL) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\nERROR: setassocsta_cmdrsp_callbac => can't "
-                         "get sta_info\n\n"));
+                        "ERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n");
                goto exit;
        }
 
index a6deddc02291392017e02ffc8c47fde8d27872cb..92a34db3bd4e3a245b3d486ecf643a2497516843 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 */
 
@@ -336,7 +335,6 @@ EFUSE_Write1Byte(struct rtw_adapter *Adapter, u16 Address, u8 Value)
        u32     k = 0;
        u16     contentLen = 0;
 
-       /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr =%x Data =%x\n", Address, Value)); */
        EFUSE_GetEfuseDefinition23a(Adapter, EFUSE_WIFI,
                                 TYPE_EFUSE_REAL_CONTENT_LEN,
                                 (void *)&contentLen);
@@ -405,8 +403,6 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data)
        u8      tmpidx = 0;
        int     bResult;
 
-       /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data =%x\n", addr, data)); */
-
        /* return       0; */
 
        /*  -----------------e-fuse reg ctrl --------------------------------- */
index bbbcfc8257da9499e7ac76e6fae7bcf62eb428fe..cdd7bc402ece86a778059a83fc866acfab182489 100644 (file)
@@ -472,8 +472,8 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
                left -= WPA_SELECTOR_LEN;
        } else if (left > 0) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("%s: ie length mismatch, %u too much",
-                         __func__, left));
+                        "%s: ie length mismatch, %u too much\n",
+                        __func__, left);
 
                return _FAIL;
        }
@@ -487,9 +487,8 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
 
                if (count == 0 || left < count * WPA_SELECTOR_LEN) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("%s: ie count botch (pairwise), "
-                                 "count %u left %u", __func__,
-                                 count, left));
+                                "%s: ie count botch (pairwise), count %u left %u\n",
+                                __func__, count, left);
                        return _FAIL;
                }
 
@@ -501,7 +500,7 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
                }
        } else if (left == 1) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("%s: ie too short (for key mgmt)", __func__));
+                        "%s: ie too short (for key mgmt)\n", __func__);
                return _FAIL;
        }
 
@@ -510,8 +509,8 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int
                        pos += 2;
                        if (!memcmp(pos, RTW_WPA_OUI23A_TYPE, 4)) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("%s : there has 802.1x auth\n",
-                                         __func__));
+                                        "%s : there has 802.1x auth\n",
+                                        __func__);
                                *is_8021x = 1;
                        }
                }
@@ -549,8 +548,8 @@ int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
                left -= RSN_SELECTOR_LEN;
        } else if (left > 0) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("%s: ie length mismatch, %u too much",
-                         __func__, left));
+                        "%s: ie length mismatch, %u too much\n",
+                        __func__, left);
                return _FAIL;
        }
 
@@ -563,9 +562,8 @@ int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
 
                if (count == 0 || left < count * RSN_SELECTOR_LEN) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("%s: ie count botch (pairwise), "
-                                 "count %u left %u",
-                                 __func__, count, left));
+                                "%s: ie count botch (pairwise), count %u left %u\n",
+                                __func__, count, left);
                        return _FAIL;
                }
 
@@ -577,7 +575,7 @@ int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
                }
        } else if (left == 1) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("%s: ie too short (for key mgmt)",  __func__));
+                        "%s: ie too short (for key mgmt)\n",  __func__);
 
                return _FAIL;
        }
@@ -587,8 +585,8 @@ int rtw_parse_wpa2_ie23a(const u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
                        pos += 2;
                        if (!memcmp(pos, SUITE_1X, 4)) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("%s (): there has 802.1x auth\n",
-                                         __func__));
+                                        "%s (): there has 802.1x auth\n",
+                                        __func__);
                                *is_8021x = 1;
                        }
                }
@@ -700,7 +698,7 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 
        if (pbuf && pbuf[1] > 0) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                        ("rtw_get_cipher_info: wpa_ielen: %d", pbuf[1]));
+                        "rtw_get_cipher_info: wpa_ielen: %d\n", pbuf[1]);
                r = rtw_parse_wpa_ie23a(pbuf, pbuf[1] + 2, &group_cipher,
                                     &pairwise_cipher, &is8021x);
                if (r == _SUCCESS) {
@@ -708,10 +706,9 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
                        pnetwork->BcnInfo.group_cipher = group_cipher;
                        pnetwork->BcnInfo.is_8021x = is8021x;
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                ("%s: pnetwork->pairwise_cipher: %d, is_"
-                                 "8021x is %d", __func__,
-                                 pnetwork->BcnInfo.pairwise_cipher,
-                                 pnetwork->BcnInfo.is_8021x));
+                                "%s: pnetwork->pairwise_cipher: %d, is_8021x is %d\n",
+                                __func__, pnetwork->BcnInfo.pairwise_cipher,
+                                pnetwork->BcnInfo.is_8021x);
                        ret = _SUCCESS;
                }
        } else {
@@ -719,24 +716,23 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 
                if (pbuf && pbuf[1] > 0) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                ("get RSN IE\n"));
+                                "get RSN IE\n");
                        r = rtw_parse_wpa2_ie23a(pbuf, pbuf[1] + 2,
                                              &group_cipher, &pairwise_cipher,
                                              &is8021x);
                        if (r == _SUCCESS) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("get RSN IE  OK!!!\n"));
+                                        "get RSN IE  OK!!!\n");
                                pnetwork->BcnInfo.pairwise_cipher =
                                        pairwise_cipher;
                                pnetwork->BcnInfo.group_cipher = group_cipher;
                                pnetwork->BcnInfo.is_8021x = is8021x;
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("%s: pnetwork->pairwise_cipher: %d,"
-                                         "pnetwork->group_cipher is %d, "
-                                         "is_8021x is %d", __func__,
-                                         pnetwork->BcnInfo.pairwise_cipher,
-                                         pnetwork->BcnInfo.group_cipher,
-                                         pnetwork->BcnInfo.is_8021x));
+                                        "%s: pnetwork->pairwise_cipher: %d,pnetwork->group_cipher is %d, is_8021x is %d\n",
+                                        __func__,
+                                        pnetwork->BcnInfo.pairwise_cipher,
+                                        pnetwork->BcnInfo.group_cipher,
+                                        pnetwork->BcnInfo.is_8021x);
                                ret = _SUCCESS;
                        }
                }
@@ -759,7 +755,7 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
                pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("%s: ssid =%s\n", __func__, pnetwork->network.Ssid.ssid));
+                "%s: ssid =%s\n", __func__, pnetwork->network.Ssid.ssid);
 
        pie = pnetwork->network.IEs;
        pie_len = pnetwork->network.IELength;
@@ -776,11 +772,11 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork)
                        pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP;
        }
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("%s: pnetwork->encryp_protocol is %x\n", __func__,
-                 pnetwork->BcnInfo.encryp_protocol));
+                "%s: pnetwork->encryp_protocol is %x\n", __func__,
+                pnetwork->BcnInfo.encryp_protocol);
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("%s: pnetwork->encryp_protocol is %x\n", __func__,
-                 pnetwork->BcnInfo.encryp_protocol));
+                "%s: pnetwork->encryp_protocol is %x\n", __func__,
+                pnetwork->BcnInfo.encryp_protocol);
        rtw_get_cipher_info(pnetwork);
 
        /* get bwmode and ch_offset */
index 7299ef0a2e54c735686102d4ad852565c6690d4f..3c09ea9b734804feba22bd632d6223b469ba84d9 100644 (file)
@@ -94,7 +94,7 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv)
 void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv)
 {
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("rtw_free_mlme_priv23a\n"));
+                "rtw_free_mlme_priv23a\n");
 
        rtw23a_free_mlme_priv_ie_data(pmlmepriv);
 }
@@ -196,9 +196,8 @@ int rtw_if_up23a(struct rtw_adapter *padapter)
        if (padapter->bDriverStopped || padapter->bSurpriseRemoved ||
            !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                        ("rtw_if_up23a:bDriverStopped(%d) OR "
-                         "bSurpriseRemoved(%d)", padapter->bDriverStopped,
-                         padapter->bSurpriseRemoved));
+                        "rtw_if_up23a:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n",
+                        padapter->bDriverStopped, padapter->bSurpriseRemoved);
                res = false;
        } else
                res =  true;
@@ -238,9 +237,9 @@ static void _rtw_roaming(struct rtw_adapter *padapter,
                pnetwork = &pmlmepriv->cur_network;
 
        if (padapter->mlmepriv.to_roaming > 0) {
-               DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n",
+               DBG_8723A("roaming from %s(%pM), length:%d\n",
                          pnetwork->network.Ssid.ssid,
-                         MAC_ARG(pnetwork->network.MacAddress),
+                         pnetwork->network.MacAddress,
                          pnetwork->network.Ssid.ssid_len);
                memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid,
                       sizeof(struct cfg80211_ssid));
@@ -466,7 +465,7 @@ static void rtw_update_scanned_network(struct rtw_adapter *adapter,
                if (!pnetwork) {
                        if (!oldest) {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                        ("\n\n\nsomething wrong here\n\n\n"));
+                                        "something wrong here\n");
                                goto exit;
                        }
                        pnetwork = oldest;
@@ -568,13 +567,6 @@ static int rtw_is_desired_network(struct rtw_adapter *adapter,
        return bselected;
 }
 
-/* TODO: Perry : For Power Management */
-void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
-{
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("receive atimdone_evet\n"));
-}
-
 void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf)
 {
        u32 len;
@@ -585,13 +577,12 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf)
        pnetwork = survey->bss;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid));
+                "rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid);
 
        len = get_wlan_bssid_ex_sz(pnetwork);
        if (len > (sizeof(struct wlan_bssid_ex))) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n ****rtw_survey_event_cb23a: return a wrong "
-                         "bss ***\n"));
+                        "****rtw_survey_event_cb23a: return a wrong bss ***\n");
                return;
        }
 
@@ -599,8 +590,6 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, const u8 *pbuf)
 
        /*  update IBSS_network 's timestamp */
        if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
-               /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                  "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */
                if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress,
                                     pnetwork->MacAddress)) {
                        struct wlan_network *ibss_wlan;
@@ -660,8 +649,8 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
        }
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("rtw_surveydone_event_callback23a: fw_state:%x\n\n",
-                 get_fwstate(pmlmepriv)));
+                "rtw_surveydone_event_callback23a: fw_state:%x\n",
+                get_fwstate(pmlmepriv));
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) {
                del_timer_sync(&pmlmepriv->scan_to_timer);
@@ -669,8 +658,8 @@ rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
                _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
        } else {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("nic status =%x, survey done event comes too late!\n",
-                         get_fwstate(pmlmepriv)));
+                        "nic status =%x, survey done event comes too late!\n",
+                        get_fwstate(pmlmepriv));
        }
 
        rtw_set_signal_stat_timer(&adapter->recvpriv);
@@ -725,7 +714,7 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv)
        struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue;
        struct list_head *plist, *phead, *ptemp;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, "+free_scanqueue\n");
        spin_lock_bh(&scan_queue->lock);
 
        phead = get_list_head(scan_queue);
@@ -752,11 +741,11 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter,
        struct sta_info *psta;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                ("+rtw_free_assoc_resources23a\n"));
+                "+rtw_free_assoc_resources23a\n");
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n",
-                 MAC_ARG(tgt_network->network.MacAddress),
-                 tgt_network->network.Ssid.ssid));
+                "tgt_network->network.MacAddress=%pM ssid=%s\n",
+                tgt_network->network.MacAddress,
+                tgt_network->network.Ssid.ssid);
 
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) {
                psta = rtw_get_stainfo23a(&adapter->stapriv,
@@ -788,7 +777,7 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter,
                pwlan->fixed = false;
        else
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("rtw_free_assoc_resources23a : pwlan== NULL\n"));
+                        "rtw_free_assoc_resources23a : pwlan== NULL\n");
 
        if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) &&
            adapter->stapriv.asoc_sta_count == 1)
@@ -808,7 +797,7 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("+rtw_indicate_connect23a\n"));
+                "+rtw_indicate_connect23a\n");
 
        pmlmepriv->to_join = false;
 
@@ -828,8 +817,8 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter)
        rtw_set_scan_deny(padapter, 3000);
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("-rtw_indicate_connect23a: fw_state=0x%08x\n",
-                 get_fwstate(pmlmepriv)));
+                "-rtw_indicate_connect23a: fw_state=0x%08x\n",
+                get_fwstate(pmlmepriv));
 }
 
 /*
@@ -840,7 +829,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter)
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("+rtw_indicate_disconnect23a\n"));
+                "+rtw_indicate_disconnect23a\n");
 
        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS);
 
@@ -998,8 +987,9 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter,
        DBG_8723A("%s\n", __func__);
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv),
-                 MAC_ARG(pnetwork->network.MacAddress)));
+                "fw_state:%x, BSSID:%pM\n",
+                get_fwstate(pmlmepriv),
+                pnetwork->network.MacAddress);
 
        /*  why not use ptarget_wlan?? */
        memcpy(&cur_network->network, &pnetwork->network,
@@ -1042,7 +1032,7 @@ rtw_joinbss_update_network23a(struct rtw_adapter *padapter,
        default:
                pmlmepriv->fw_state = WIFI_NULL_STATE;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("Invalid network_mode\n"));
+                        "Invalid network_mode\n");
                break;
        }
 
@@ -1077,16 +1067,16 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
        bool the_same_macaddr;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("joinbss event call back received with res=%d\n",
-                 pnetwork->join_res));
+                "joinbss event call back received with res=%d\n",
+                pnetwork->join_res);
 
        if (pmlmepriv->assoc_ssid.ssid_len == 0) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("@@@@@   joinbss event call back  for Any SSid\n"));
+                        "@@@@@   joinbss event call back  for Any SSid\n");
        } else {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("@@@@@   rtw23a_joinbss_event_cb for SSid:%s\n",
-                         pmlmepriv->assoc_ssid.ssid));
+                        "@@@@@   rtw23a_joinbss_event_cb for SSid:%s\n",
+                        pmlmepriv->assoc_ssid.ssid);
        }
 
        if (ether_addr_equal(pnetwork->network.MacAddress,
@@ -1098,15 +1088,14 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
        pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network);
        if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n\n ***joinbss_evt_callback return a wrong bss "
-                         "***\n\n"));
+                        "***joinbss_evt_callback return a wrong bss ***\n");
                return;
        }
 
        spin_lock_bh(&pmlmepriv->lock);
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("\n rtw23a_joinbss_event_cb !! _enter_critical\n"));
+                "rtw23a_joinbss_event_cb !! _enter_critical\n");
 
        if (pnetwork->join_res > 0) {
                spin_lock_bh(&pmlmepriv->scanned_queue.lock);
@@ -1155,8 +1144,7 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                                                              pnetwork);
                        else {
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                        ("Can't find ptarget_wlan when "
-                                         "joinbss_event callback\n"));
+                                        "Can't find ptarget_wlan when joinbss_event callback\n");
                                spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                goto ignore_joinbss_callback;
                        }
@@ -1169,8 +1157,7 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                                if (!ptarget_sta) {
                                        RT_TRACE(_module_rtl871x_mlme_c_,
                                                 _drv_err_,
-                                                ("Can't update stainfo when "
-                                                 "joinbss_event callback\n"));
+                                                "Can't update stainfo when joinbss_event callback\n");
                                        spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                                        goto ignore_joinbss_callback;
                                }
@@ -1183,19 +1170,19 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
                                /* adhoc mode will rtw_indicate_connect23a
                                   when rtw_stassoc_event_callback23a */
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("adhoc mode, fw_state:%x",
-                                         get_fwstate(pmlmepriv)));
+                                        "adhoc mode, fw_state:%x\n",
+                                        get_fwstate(pmlmepriv));
                        }
 
                        /* s5. Cancle assoc_timer */
                        del_timer_sync(&pmlmepriv->assoc_timer);
 
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                ("Cancle assoc_timer\n"));
+                                "Cancle assoc_timer\n");
                } else {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("rtw23a_joinbss_event_cb err: fw_state:%x",
-                                get_fwstate(pmlmepriv)));
+                                "rtw23a_joinbss_event_cb err: fw_state:%x\n",
+                                get_fwstate(pmlmepriv));
                        spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
                        goto ignore_joinbss_callback;
                }
@@ -1209,8 +1196,8 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf)
 
                if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("fail! clear _FW_UNDER_LINKING ^^^fw_state="
-                                 "%x\n", get_fwstate(pmlmepriv)));
+                                "fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n",
+                                get_fwstate(pmlmepriv));
                        _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
                }
        } else {
@@ -1261,8 +1248,7 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
        if (psta != NULL) {
                /* the sta have been in sta_info_queue => do nothing */
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("Error: rtw_stassoc_event_callback23a: sta has "
-                         "been in sta_hash_queue\n"));
+                        "Error: rtw_stassoc_event_callback23a: sta has been in sta_hash_queue\n");
                /* between drv has received this event before and
                   fw have not yet to set key to CAM_ENTRY) */
                return;
@@ -1272,8 +1258,7 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
                GFP_KERNEL);
        if (!psta) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("Can't alloc sta_info when "
-                         "rtw_stassoc_event_callback23a\n"));
+                        "Can't alloc sta_info when rtw_stassoc_event_callback23a\n");
                return;
        }
 
@@ -1330,8 +1315,7 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, const u8 *pbuf)
        else
                mac_id = pstadel->mac_id;
 
-       DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id,
-                 MAC_ARG(pstadel->macaddr));
+       DBG_8723A("%s(mac_id=%d)=%pM\n", __func__, mac_id, pstadel->macaddr);
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
                return;
@@ -1582,13 +1566,12 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv,
        }
 
        if (updated) {
-               DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] "
-                         "new candidate: %s("MAC_FMT") rssi:%d\n",
+               DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] new candidate: %s(%pM) rssi:%d\n",
                          pmlmepriv->assoc_by_bssid,
                          pmlmepriv->assoc_ssid.ssid,
                          adapter->mlmepriv.to_roaming,
                          (*candidate)->network.Ssid.ssid,
-                         MAC_ARG((*candidate)->network.MacAddress),
+                         (*candidate)->network.MacAddress,
                          (int)(*candidate)->network.Rssi);
        }
 
@@ -1653,8 +1636,8 @@ rtw_select_candidate_from_queue(struct mlme_priv *pmlmepriv)
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!pnetwork) {
                        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                                ("%s: return _FAIL:(pnetwork == NULL)\n",
-                                 __func__));
+                                "%s: return _FAIL:(pnetwork == NULL)\n",
+                                __func__);
                        goto exit;
                }
 
@@ -1680,7 +1663,7 @@ int rtw_do_join_adhoc(struct rtw_adapter *adapter)
        _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("switching to adhoc master\n"));
+                "switching to adhoc master\n");
 
        memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid,
               sizeof(struct cfg80211_ssid));
@@ -1693,7 +1676,7 @@ int rtw_do_join_adhoc(struct rtw_adapter *adapter)
        ret = rtw_createbss_cmd23a(adapter);
        if (ret != _SUCCESS) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("Error =>rtw_createbss_cmd23a status FAIL\n"));
+                        "Error =>rtw_createbss_cmd23a status FAIL\n");
        } else  {
                pmlmepriv->to_join = false;
        }
@@ -1739,9 +1722,10 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv)
                ret = _FAIL;
                goto exit;
        } else {
-               DBG_8723A("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__,
+               DBG_8723A("%s: candidate: %s(%pM, ch:%u)\n",
+                         __func__,
                          candidate->network.Ssid.ssid,
-                         MAC_ARG(candidate->network.MacAddress),
+                         candidate->network.MacAddress,
                          candidate->network.DSConfig);
        }
 
@@ -1781,8 +1765,8 @@ int rtw_set_auth23a(struct rtw_adapter *adapter,
        pcmd->rspsz = 0;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("after enqueue set_auth_cmd, auth_mode=%x\n",
-                 psecuritypriv->dot11AuthAlgrthm));
+                "after enqueue set_auth_cmd, auth_mode=%x\n",
+                psecuritypriv->dot11AuthAlgrthm);
 
        res = rtw_enqueue_cmd23a(pcmdpriv, pcmd);
 
@@ -1822,15 +1806,13 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
                psetkeyparm->algorithm = (unsigned char)
                        psecuritypriv->dot118021XGrpPrivacy;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n rtw_set_key23a: psetkeyparm->algorithm = "
-                         "(unsigned char)psecuritypriv->dot118021XGrpPrivacy "
-                         "=%d\n", psetkeyparm->algorithm));
+                        "rtw_set_key23a: psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy =%d\n",
+                        psetkeyparm->algorithm);
        } else {
                psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n rtw_set_key23a: psetkeyparm->algorithm = (u8)"
-                         "psecuritypriv->dot11PrivacyAlgrthm =%d\n",
-                         psetkeyparm->algorithm));
+                        "rtw_set_key23a: psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm =%d\n",
+                        psetkeyparm->algorithm);
        }
        psetkeyparm->keyid = keyid;/* 0~3 */
        psetkeyparm->set_tx = set_tx;
@@ -1841,8 +1823,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
                  psetkeyparm->algorithm, psetkeyparm->keyid,
                  pmlmepriv->key_mask);
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                ("\n rtw_set_key23a: psetkeyparm->algorithm =%d psetkeyparm->"
-                 "keyid = (u8)keyid =%d\n", psetkeyparm->algorithm, keyid));
+                "rtw_set_key23a: psetkeyparm->algorithm =%d psetkeyparm->keyid = (u8)keyid =%d\n",
+                psetkeyparm->algorithm, keyid);
 
        switch (psetkeyparm->algorithm) {
        case WLAN_CIPHER_SUITE_WEP40:
@@ -1869,9 +1851,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter,
                break;
        default:
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm"
-                         " = %x (must be 1 or 2 or 4 or 5)\n",
-                         psecuritypriv->dot11PrivacyAlgrthm));
+                        "rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm = %x (must be 1 or 2 or 4 or 5)\n",
+                        psecuritypriv->dot11PrivacyAlgrthm);
                res = _FAIL;
                kfree(pcmd);
                kfree(psetkeyparm);
@@ -1998,8 +1979,8 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie,
        uint ndissecuritytype = psecuritypriv->ndisencryptstatus;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                ("+rtw_restruct_sec_ie23a: ndisauthmode=%d "
-                 "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype));
+                "+rtw_restruct_sec_ie23a: ndisauthmode=%d ndissecuritytype=%d\n",
+                ndisauthmode, ndissecuritytype);
 
        ielength = 0;
        if (ndisauthmode == Ndis802_11AuthModeWPA ||
@@ -2065,8 +2046,8 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter *adapter)
 
        pdev_network->DSConfig = pregistrypriv->channel;
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("pregistrypriv->channel =%d, pdev_network->DSConfig = 0x%x\n",
-                 pregistrypriv->channel, pdev_network->DSConfig));
+                "pregistrypriv->channel =%d, pdev_network->DSConfig = 0x%x\n",
+                pregistrypriv->channel, pdev_network->DSConfig);
 
        if (cur_network->network.ifmode == NL80211_IFTYPE_ADHOC)
                pdev_network->ATIMWindow = 0;
index 0e0f73c86e53c5738dc5d728f2df0361d99c004e..196beafde6f077334adf6159edfa93090df5208c 100644 (file)
@@ -657,8 +657,8 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter,
 
        if (index > 13) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("Currently we do not support reserved sub-fr-type ="
-                         "%d\n", index));
+                        "Currently we do not support reserved sub-fr-type =%d\n",
+                        index);
                return;
        }
        ptable += index;
@@ -968,8 +968,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        pstat = rtw_get_stainfo23a(pstapriv, sa);
        if (!pstat) {
                /*  allocate a new one */
-               DBG_8723A("going to alloc stainfo for sa ="MAC_FMT"\n",
-                         MAC_ARG(sa));
+               DBG_8723A("going to alloc stainfo for sa =%pM\n", sa);
                pstat = rtw_alloc_stainfo23a(pstapriv, sa, GFP_ATOMIC);
                if (!pstat) {
                        DBG_8723A(" Exceed the upper limit of supported "
@@ -1396,8 +1395,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        /* now parse all ieee802_11 ie to point to elems */
 
        if (rtw_validate_frame_ies(pos, left)) {
-               DBG_8723A("STA " MAC_FMT " sent invalid association request\n",
-                         MAC_ARG(pstat->hwaddr));
+               DBG_8723A("STA %pM sent invalid association request\n",
+                         pstat->hwaddr);
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
                goto OnAssocReq23aFail;
        }
@@ -1407,8 +1406,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        p = cfg80211_find_ie(WLAN_EID_SSID, pos, left);
        if (!p || p[1] == 0) {
                /*  broadcast ssid, however it is not allowed in assocreq */
-               DBG_8723A("STA " MAC_FMT " sent invalid association request "
-                         "lacking an SSID\n", MAC_ARG(pstat->hwaddr));
+               DBG_8723A("STA %pM sent invalid association request lacking an SSID\n",
+                         pstat->hwaddr);
                status = WLAN_STATUS_UNSPECIFIED_FAILURE;
                goto OnAssocReq23aFail;
        } else {
@@ -1537,9 +1536,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
                int copy_len;
 
                if (psecuritypriv->wpa_psk == 0) {
-                       DBG_8723A("STA " MAC_FMT ": WPA/RSN IE in association "
-                       "request, but AP don't support WPA/RSN\n",
-                                 MAC_ARG(pstat->hwaddr));
+                       DBG_8723A("STA %pM: WPA/RSN IE in association request, but AP don't support WPA/RSN\n",
+                                 pstat->hwaddr);
 
                        status = WLAN_STATUS_INVALID_IE;
 
@@ -1614,8 +1612,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
                                        else
                                                pstat->uapsd_be = 0;
 
+                                       break;
                                }
-                               break;
                        } else {
                                break;
                        }
@@ -1645,8 +1643,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame)
        if (pstat->flags & WLAN_STA_HT &&
            (pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP ||
             pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) {
-               DBG_8723A("HT: " MAC_FMT " tried to use TKIP with HT "
-                         "association\n", MAC_ARG(pstat->hwaddr));
+               DBG_8723A("HT: %pM tried to use TKIP with HT association\n",
+                         pstat->hwaddr);
 
                /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */
                /* goto OnAssocReq23aFail; */
@@ -2687,7 +2685,7 @@ static int _issue_probereq(struct rtw_adapter *padapter,
        u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                ("+%s\n", __func__));
+                "+%s\n", __func__);
 
        pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
        if (!pmgntframe)
@@ -2758,7 +2756,7 @@ static int _issue_probereq(struct rtw_adapter *padapter,
        pattrib->last_txcmdsz = pattrib->pktlen;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                ("issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz));
+                "issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz);
 
        if (wait_ack) {
                ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe);
@@ -2806,17 +2804,16 @@ static int issue_probereq_ex(struct rtw_adapter *padapter,
 
        if (try_cnt && wait_ms) {
                if (da)
-                       DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d "
-                                 "in %u ms\n", __func__,
-                                 padapter->pnetdev->name,
-                                 MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                       DBG_8723A("%s(%s): to %pM, ch:%u%s, %d/%d in %u ms\n",
+                                 __func__, padapter->pnetdev->name,
+                                 da, rtw_get_oper_ch23a(padapter),
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
                else
                        DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
                                  __func__, padapter->pnetdev->name,
                                  rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
        }
 exit:
@@ -3460,17 +3457,16 @@ int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 
        if (try_cnt && wait_ms) {
                if (da)
-                       DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d "
-                                 "in %u ms\n", __func__,
-                                 padapter->pnetdev->name,
-                                 MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                       DBG_8723A("%s(%s): to %pM, ch:%u%s, %d/%d in %u ms\n",
+                                 __func__, padapter->pnetdev->name,
+                                 da, rtw_get_oper_ch23a(padapter),
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
                else
                        DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
                                  __func__, padapter->pnetdev->name,
                                  rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
        }
 exit:
@@ -3587,17 +3583,16 @@ int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 
        if (try_cnt && wait_ms) {
                if (da)
-                       DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d "
-                                 "in %u ms\n", __func__,
-                                 padapter->pnetdev->name,
-                                 MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                       DBG_8723A("%s(%s): to %pM, ch:%u%s, %d/%d in %u ms\n",
+                                 __func__, padapter->pnetdev->name,
+                                 da, rtw_get_oper_ch23a(padapter),
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
                else
                        DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
                                  __func__, padapter->pnetdev->name,
                                  rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
        }
 exit:
@@ -3615,7 +3610,7 @@ static int _issue_deauth(struct rtw_adapter *padapter, unsigned char *da,
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        int ret = _FAIL;
 
-       /* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */
+       /* DBG_8723A("%s to %pM\n", __func__, da); */
 
        pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
        if (!pmgntframe)
@@ -3660,7 +3655,7 @@ exit:
 int issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da,
                    unsigned short reason)
 {
-       DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da));
+       DBG_8723A("%s to %pM\n", __func__, da);
        return _issue_deauth(padapter, da, reason, false);
 }
 
@@ -3692,17 +3687,16 @@ static int issue_deauth_ex(struct rtw_adapter *padapter, u8 *da,
 
        if (try_cnt && wait_ms) {
                if (da)
-                       DBG_8723A("%s(%s): to "MAC_FMT", ch:%u%s, %d/%d "
-                                 "in %u ms\n", __func__,
-                                 padapter->pnetdev->name,
-                                 MAC_ARG(da), rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                       DBG_8723A("%s(%s): to %pM, ch:%u%s, %d/%d in %u ms\n",
+                                 __func__, padapter->pnetdev->name,
+                                 da, rtw_get_oper_ch23a(padapter),
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
                else
                        DBG_8723A("%s(%s):, ch:%u%s, %d/%d in %u ms\n",
                                  __func__, padapter->pnetdev->name,
                                  rtw_get_oper_ch23a(padapter),
-                                 ret == _SUCCESS?", acked":"", i, try_cnt,
+                                 ret == _SUCCESS ? ", acked" : "", i, try_cnt,
                                  jiffies_to_msecs(jiffies - start));
        }
 exit:
@@ -3719,8 +3713,8 @@ void issue_action_spct_ch_switch23a(struct rtw_adapter *padapter,
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 
-       DBG_8723A("%s(%s): ra ="MAC_FMT", ch:%u, offset:%u\n", __func__,
-                 padapter->pnetdev->name, MAC_ARG(ra), new_ch, ch_offset);
+       DBG_8723A("%s(%s): ra=%pM, ch:%u, offset:%u\n",
+                 __func__, padapter->pnetdev->name, ra, new_ch, ch_offset);
 
        pmgntframe = alloc_mgtxmitframe23a(pxmitpriv);
        if (!pmgntframe)
@@ -3767,7 +3761,6 @@ void issue_action_BA23a(struct rtw_adapter *padapter,
 {
        u16 start_seq;
        u16 BA_para_set;
-       u16 BA_timeout_value;
        u16 BA_starting_seqctrl;
        u16 BA_para;
        int max_rx_ampdu_factor;
@@ -3842,16 +3835,14 @@ 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,
                                   &mgmt->u.action.u.addba_req.capab);
 
-               BA_timeout_value = 5000;/*  5ms */
-               BA_timeout_value = cpu_to_le16(BA_timeout_value);
-               put_unaligned_le16(BA_timeout_value,
-                                  &mgmt->u.action.u.addba_req.timeout);
+               /*  5ms */
+               put_unaligned_le16(5000, &mgmt->u.action.u.addba_req.timeout);
 
                psta = rtw_get_stainfo23a(pstapriv, raddr);
                if (psta) {
@@ -4347,7 +4338,8 @@ static void start_create_ibss(struct rtw_adapter *padapter)
 
                /* issue beacon */
                if (send_beacon23a(padapter) == _FAIL) {
-                       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n"));
+                       RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
+                                "issuing beacon frame fail....\n");
 
                        report_join_res23a(padapter, -1);
                        pmlmeinfo->state = MSR_NOLINK;
@@ -4531,7 +4523,7 @@ static void process_80211d(struct rtw_adapter *padapter,
 
                p += 3;
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                        ("%s: 802.11d country =%s\n", __func__, country));
+                        "%s: 802.11d country =%s\n", __func__, country);
 
                i = 0;
                while ((ie - p) >= 3) {
@@ -4708,9 +4700,8 @@ static void process_80211d(struct rtw_adapter *padapter,
 
                                chplan_new[i].ScanType = SCAN_ACTIVE;
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_,
-                                        ("%s: change channel %d scan type "
-                                         "from passive to active\n",
-                                         __func__, channel));
+                                        "%s: change channel %d scan type from passive to active\n",
+                                        __func__, channel);
                        }
                        break;
                }
@@ -4745,7 +4736,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 +4787,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 +4831,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 +4881,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 +4909,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 +4935,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 +5942,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],
@@ -6066,7 +6057,7 @@ int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
        /*  checking if event code is valid */
        if (evt_code >= MAX_C2HEVT) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\nEvent Code(%d) mismatch!\n", evt_code));
+                        "Event Code(%d) mismatch!\n", evt_code);
                goto _abort_event_;
        }
 
@@ -6074,8 +6065,8 @@ int mlme_evt_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf)
        if (wlanevents[evt_code].parmsize != 0 &&
            wlanevents[evt_code].parmsize != evt_sz) {
                RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_,
-                        ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n",
-                         evt_code, wlanevents[evt_code].parmsize, evt_sz));
+                        "Event(%d) Parm Size mismatch (%d vs %d)!\n",
+                        evt_code, wlanevents[evt_code].parmsize, evt_sz);
                goto _abort_event_;
        }
 
index e2d51afe522c149862aababc5e0284fc9df66234..7488a104935b037427adbab657bbabb6607f9a3d 100644 (file)
@@ -202,17 +202,17 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv)
 
        if (pwrpriv->rpwm == pslv) {
                RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
-                       ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n",
-                        __func__, pwrpriv->rpwm, pslv));
+                        "%s: Already set rpwm[0x%02X], new = 0x%02X!\n",
+                        __func__, pwrpriv->rpwm, pslv);
                return;
        }
 
        if (padapter->bSurpriseRemoved == true ||
            padapter->hw_init_completed == false) {
                RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
-                        ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n",
-                         __func__, padapter->bSurpriseRemoved,
-                         padapter->hw_init_completed));
+                        "%s: SurpriseRemoved(%d) hw_init_completed(%d)\n",
+                        __func__, padapter->bSurpriseRemoved,
+                        padapter->hw_init_completed);
 
                pwrpriv->cpwm = PS_STATE_S4;
 
@@ -221,22 +221,21 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv)
 
        if (padapter->bDriverStopped == true) {
                RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
-                        ("%s: change power state(0x%02X) when DriverStopped\n",
-                         __func__, pslv));
+                        "%s: change power state(0x%02X) when DriverStopped\n",
+                        __func__, pslv);
 
                if (pslv < PS_STATE_S2) {
                        RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
-                                ("%s: Reject to enter PS_STATE(0x%02X) lower "
-                                 "than S2 when DriverStopped!!\n",
-                                 __func__, pslv));
+                                "%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n",
+                                __func__, pslv);
                        return;
                }
        }
 
        rpwm = pslv | pwrpriv->tog;
        RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
-                ("rtw_set_rpwm23a: rpwm = 0x%02x cpwm = 0x%02x\n",
-                 rpwm, pwrpriv->cpwm));
+                "rtw_set_rpwm23a: rpwm = 0x%02x cpwm = 0x%02x\n",
+                rpwm, pwrpriv->cpwm);
 
        pwrpriv->rpwm = pslv;
 
@@ -282,12 +281,12 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode,
        struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
 
        RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
-                        ("%s: PowerMode =%d Smart_PS =%d\n",
-                         __func__, ps_mode, smart_ps));
+                "%s: PowerMode =%d Smart_PS =%d\n",
+                __func__, ps_mode, smart_ps);
 
        if (ps_mode > PM_Card_Disable) {
                RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
-                        ("ps_mode:%d error\n", ps_mode));
+                        "ps_mode:%d error\n", ps_mode);
                return;
        }
 
index 559dddee26485df3ced453913850eb1b2e513e49..274a4b65c0226d33581f3cfde71e7ca04ad940ba 100644 (file)
@@ -299,12 +299,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
 
        if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("\n recvframe_chkmic:prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP\n"));
+                        "recvframe_chkmic:prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP\n");
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("\n recvframe_chkmic:da = 0x%02x:0x%02x:0x%02x:0x%02x:"
-                         "0x%02x:0x%02x\n", prxattrib->ra[0],
-                         prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3],
-                         prxattrib->ra[4], prxattrib->ra[5]));
+                        "recvframe_chkmic:da = %pM\n", prxattrib->ra);
 
                /* calculate mic code */
                if (stainfo != NULL) {
@@ -312,14 +309,13 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0];
 
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                        ("\n recvframe_chkmic: bcmc key\n"));
+                                        "recvframe_chkmic: bcmc key\n");
 
                                if (!psecuritypriv->binstallGrpkey) {
                                        res = _FAIL;
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
-                                                ("\n recvframe_chkmic:didn't "
-                                                 "install group key!!!!!!\n"));
+                                                "recvframe_chkmic:didn't install group key!\n");
                                        DBG_8723A("\n recvframe_chkmic:didn't "
                                                  "install group key!!!!!!\n");
                                        goto exit;
@@ -327,8 +323,7 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                        } else {
                                mickey = &stainfo->dot11tkiprxmickey.skey[0];
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n recvframe_chkmic: unicast "
-                                         "key\n"));
+                                        "recvframe_chkmic: unicast key\n");
                        }
 
                        /* icv_len included the mic code */
@@ -339,9 +334,8 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                prxattrib->iv_len;
 
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("\n prxattrib->iv_len =%d prxattrib->icv_len ="
-                                 "%d\n", prxattrib->iv_len,
-                                 prxattrib->icv_len));
+                                "prxattrib->iv_len =%d prxattrib->icv_len =%d\n",
+                                prxattrib->iv_len, prxattrib->icv_len);
 
                        /* care the length of the data */
                        rtw_seccalctkipmic23a(mickey, pframe, payload,
@@ -356,10 +350,9 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                if (miccode[i] != *(pframemic + i)) {
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
-                                                ("recvframe_chkmic:miccode"
-                                                 "[%d](%02x) != *(pframemic+"
-                                                 "%d)(%02x) ", i, miccode[i],
-                                                 i, *(pframemic + i)));
+                                                "recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x)\n",
+                                                i, miccode[i],
+                                                i, *(pframemic + i));
                                        bmic_err = true;
                                }
                        }
@@ -368,51 +361,44 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                int i;
 
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n *(pframemic-8)-*(pframemic-1) ="
-                                         "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:"
-                                         "0x%02x:0x%02x:0x%02x\n",
-                                         *(pframemic - 8), *(pframemic - 7),
-                                         *(pframemic - 6), *(pframemic - 5),
-                                         *(pframemic - 4), *(pframemic - 3),
-                                         *(pframemic - 2), *(pframemic - 1)));
+                                        "*(pframemic-8)-*(pframemic-1) =0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
+                                        *(pframemic - 8), *(pframemic - 7),
+                                        *(pframemic - 6), *(pframemic - 5),
+                                        *(pframemic - 4), *(pframemic - 3),
+                                        *(pframemic - 2), *(pframemic - 1));
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n *(pframemic-16)-*(pframemic-9) ="
-                                         "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:"
-                                         "0x%02x:0x%02x:0x%02x\n",
-                                         *(pframemic - 16), *(pframemic - 15),
-                                         *(pframemic - 14), *(pframemic - 13),
-                                         *(pframemic - 12), *(pframemic - 11),
-                                         *(pframemic - 10), *(pframemic - 9)));
+                                        "*(pframemic-16)-*(pframemic-9) =0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
+                                        *(pframemic - 16), *(pframemic - 15),
+                                        *(pframemic - 14), *(pframemic - 13),
+                                        *(pframemic - 12), *(pframemic - 11),
+                                        *(pframemic - 10), *(pframemic - 9));
 
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n ====== demp packet (len =%d) ======"
-                                         "\n", precvframe->pkt->len));
+                                        "====== demp packet (len =%d) ======\n",
+                                        precvframe->pkt->len);
                                for (i = 0; i < precvframe->pkt->len; i = i + 8) {
                                        RT_TRACE(_module_rtl871x_recv_c_,
-                                                _drv_err_, ("0x%02x:0x%02x:0x"
-                                                           "%02x:0x%02x:0x%0"
-                                                           "2x:0x%02x:0x%02x"
-                                                           ":0x%02x",
-                                                           *(precvframe->pkt->data+i),*(precvframe->pkt->data+i+1),
-                                                           *(precvframe->pkt->data+i+2),*(precvframe->pkt->data+i+3),
-                                                           *(precvframe->pkt->data+i+4),*(precvframe->pkt->data+i+5),
-                                                           *(precvframe->pkt->data+i+6),*(precvframe->pkt->data+i+7)));
+                                                _drv_err_,
+                                                "0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n",
+                                                *(precvframe->pkt->data+i),
+                                                *(precvframe->pkt->data+i+1),
+                                                *(precvframe->pkt->data+i+2),
+                                                *(precvframe->pkt->data+i+3),
+                                                *(precvframe->pkt->data+i+4),
+                                                *(precvframe->pkt->data+i+5),
+                                                *(precvframe->pkt->data+i+6),
+                                                *(precvframe->pkt->data+i+7));
                                }
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n ====== demp packet end [len =%d]"
-                                         "======\n", precvframe->pkt->len));
+                                        "====== demp packet end [len =%d]======\n",
+                                        precvframe->pkt->len);
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("\n hrdlen =%d,\n",
-                                         prxattrib->hdrlen));
+                                        "hrdlen =%d\n", prxattrib->hdrlen);
 
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                        ("ra = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%."
-                                         "2x 0x%.2x psecuritypriv->"
-                                         "binstallGrpkey =%d ",
-                                         prxattrib->ra[0], prxattrib->ra[1],
-                                         prxattrib->ra[2], prxattrib->ra[3],
-                                         prxattrib->ra[4], prxattrib->ra[5],
-                                         psecuritypriv->binstallGrpkey));
+                                        "ra = %pM psecuritypriv->binstallGrpkey =%d\n",
+                                        prxattrib->ra,
+                                        psecuritypriv->binstallGrpkey);
 
                                /*  double check key_index for some timing
                                    issue, cannot compare with
@@ -426,16 +412,17 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                if ((prxattrib->bdecrypted == true) &&
                                    (brpt_micerror == true)) {
                                        rtw_handle_tkip_mic_err23a(adapter, (u8)is_multicast_ether_addr(prxattrib->ra));
-                                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted));
+                                       RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
+                                                "mic error :prxattrib->bdecrypted =%d\n",
+                                                prxattrib->bdecrypted);
                                        DBG_8723A(" mic error :prxattrib->"
                                                  "bdecrypted =%d\n",
                                                  prxattrib->bdecrypted);
                                } else {
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
-                                                (" mic error :prxattrib->"
-                                                 "bdecrypted =%d ",
-                                                 prxattrib->bdecrypted));
+                                                "mic error :prxattrib->bdecrypted =%d\n",
+                                                prxattrib->bdecrypted);
                                        DBG_8723A(" mic error :prxattrib->"
                                                  "bdecrypted =%d\n",
                                                  prxattrib->bdecrypted);
@@ -449,14 +436,12 @@ int recvframe_chkmic(struct rtw_adapter *adapter,
                                        psecuritypriv->bcheck_grpkey = 1;
                                        RT_TRACE(_module_rtl871x_recv_c_,
                                                 _drv_err_,
-                                                ("psecuritypriv->bcheck_grp"
-                                                 "key = true"));
+                                                "psecuritypriv->bcheck_grpkey = true\n");
                                }
                        }
                } else {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("recvframe_chkmic: rtw_get_stainfo23a =="
-                                 "NULL!!!\n"));
+                                "recvframe_chkmic: rtw_get_stainfo23a ==NULL!!!\n");
                }
 
                skb_trim(precvframe->pkt, precvframe->pkt->len - 8);
@@ -481,8 +466,8 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter,
        int res = _SUCCESS;
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                ("prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n",
-                 prxattrib->bdecrypted, prxattrib->encrypt));
+                "prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n",
+                prxattrib->bdecrypted, prxattrib->encrypt);
 
        if (prxattrib->encrypt > 0) {
                u8 *iv = precv_frame->pkt->data + prxattrib->hdrlen;
@@ -565,8 +550,8 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter,
        psta = rtw_get_stainfo23a(pstapriv, psta_addr);
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm ="
-                 "%d\n", adapter->securitypriv.dot11AuthAlgrthm));
+                "########portctrl:adapter->securitypriv.dot11AuthAlgrthm =%d\n",
+                adapter->securitypriv.dot11AuthAlgrthm);
 
        prtnframe = precv_frame;
 
@@ -580,8 +565,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter,
                        /* blocked */
                        /* only accept EAPOL frame */
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("########portctrl:psta->ieee8021x_blocked =="
-                                 "1\n"));
+                                "########portctrl:psta->ieee8021x_blocked ==1\n");
 
                        if (ether_type != eapol_type) {
                                /* free this frame */
@@ -608,8 +592,8 @@ int recv_decache(struct recv_frame *precv_frame, u8 bretry,
 
        if (tid > 15) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                        ("recv_decache, (tid>15)! seq_ctrl = 0x%x, tid = 0x%x\n",
-                         seq_ctrl, tid));
+                        "recv_decache, (tid>15)! seq_ctrl = 0x%x, tid = 0x%x\n",
+                        seq_ctrl, tid);
 
                return _FAIL;
        }
@@ -617,9 +601,8 @@ int recv_decache(struct recv_frame *precv_frame, u8 bretry,
        if (1) { /* if (bretry) */
                if (seq_ctrl == prxcache->tid_rxseq[tid]) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                ("recv_decache, seq_ctrl = 0x%x, tid = 0x%x, "
-                                 "tid_rxseq = 0x%x\n",
-                                 seq_ctrl, tid, prxcache->tid_rxseq[tid]));
+                                "recv_decache, seq_ctrl = 0x%x, tid = 0x%x, tid_rxseq = 0x%x\n",
+                                seq_ctrl, tid, prxcache->tid_rxseq[tid]);
 
                        return _FAIL;
                }
@@ -777,7 +760,7 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter,
                /*  filter packets that SA is myself or multicast or broadcast */
                if (ether_addr_equal(myhwaddr, pattrib->src)) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                (" SA == myself\n"));
+                                "SA == myself\n");
                        ret = _FAIL;
                        goto exit;
                }
@@ -800,8 +783,7 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter,
                    and DA is my mac-address */
                if (!ether_addr_equal(pattrib->bssid, pattrib->src)) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("bssid != TA under STATION_MODE; drop "
-                                 "pkt\n"));
+                                "bssid != TA under STATION_MODE; drop pkt\n");
                        ret = _FAIL;
                        goto exit;
                }
@@ -843,7 +825,8 @@ static int sta2sta_data_frame(struct rtw_adapter *adapter,
                *psta = rtw_get_stainfo23a(pstapriv, sta_addr); /*  get ap_info */
 
        if (*psta == NULL) {
-               RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n"));
+               RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
+                        "can't get psta under sta2sta_data_frame ; drop pkt\n");
                ret = _FAIL;
                goto exit;
        }
@@ -879,7 +862,7 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
                /* filter packets that SA is myself or multicast or broadcast */
                if (ether_addr_equal(myhwaddr, pattrib->src)) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                (" SA == myself\n"));
+                                "SA == myself\n");
                        ret = _FAIL;
                        goto exit;
                }
@@ -887,8 +870,8 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
                /*  da should be for me */
                if (!ether_addr_equal(myhwaddr, pattrib->dst) && !bmcast) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                               (" ap2sta_data_frame:  compare DA fail; DA ="
-                                MAC_FMT"\n", MAC_ARG(pattrib->dst)));
+                                "ap2sta_data_frame:  compare DA failed; DA=%pM\n",
+                                pattrib->dst);
                        ret = _FAIL;
                        goto exit;
                }
@@ -898,15 +881,14 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
                    ether_addr_equal(mybssid, "\x0\x0\x0\x0\x0\x0") ||
                    !ether_addr_equal(pattrib->bssid, mybssid)) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                               (" ap2sta_data_frame:  compare BSSID fail ; "
-                                "BSSID ="MAC_FMT"\n", MAC_ARG(pattrib->bssid)));
+                                "ap2sta_data_frame:  compare BSSID failed; BSSID=%pM\n",
+                                pattrib->bssid);
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("mybssid ="MAC_FMT"\n", MAC_ARG(mybssid)));
+                                "mybssid=%pM\n", mybssid);
 
                        if (!bmcast) {
-                               DBG_8723A("issue_deauth23a to the nonassociated "
-                                         "ap =" MAC_FMT " for the reason(7)\n",
-                                         MAC_ARG(pattrib->bssid));
+                               DBG_8723A("issue_deauth23a to the nonassociated ap=%pM for the reason(7)\n",
+                                         pattrib->bssid);
                                issue_deauth23a(adapter, pattrib->bssid,
                                             WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
                        }
@@ -923,8 +905,7 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
 
                if (*psta == NULL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("ap2sta: can't get psta under STATION_MODE ;"
-                                 " drop pkt\n"));
+                                "ap2sta: can't get psta under STATION_MODE; drop pkt\n");
                        ret = _FAIL;
                        goto exit;
                }
@@ -952,7 +933,7 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
                *psta = rtw_get_stainfo23a(pstapriv, pattrib->bssid);
                if (*psta == NULL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("can't get psta under MP_MODE ; drop pkt\n"));
+                                "can't get psta under MP_MODE ; drop pkt\n");
                        ret = _FAIL;
                        goto exit;
                }
@@ -964,9 +945,8 @@ int ap2sta_data_frame(struct rtw_adapter *adapter,
                if (ether_addr_equal(myhwaddr, pattrib->dst) && !bmcast) {
                        *psta = rtw_get_stainfo23a(pstapriv, pattrib->bssid);
                        if (*psta == NULL) {
-                               DBG_8723A("issue_deauth23a to the ap =" MAC_FMT
-                                         " for the reason(7)\n",
-                                         MAC_ARG(pattrib->bssid));
+                               DBG_8723A("issue_deauth23a to the ap=%pM for the reason(7)\n",
+                                         pattrib->bssid);
 
                                issue_deauth23a(adapter, pattrib->bssid,
                                             WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
@@ -1010,10 +990,9 @@ int sta2ap_data_frame(struct rtw_adapter *adapter,
                *psta = rtw_get_stainfo23a(pstapriv, pattrib->src);
                if (*psta == NULL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("can't get psta under AP_MODE; drop pkt\n"));
-                       DBG_8723A("issue_deauth23a to sta =" MAC_FMT
-                                 " for the reason(7)\n",
-                                 MAC_ARG(pattrib->src));
+                                "can't get psta under AP_MODE; drop pkt\n");
+                       DBG_8723A("issue_deauth23a to sta=%pM for the reason(7)\n",
+                                 pattrib->src);
 
                        issue_deauth23a(adapter, pattrib->src,
                                     WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
@@ -1043,8 +1022,8 @@ int sta2ap_data_frame(struct rtw_adapter *adapter,
                        ret = RTW_RX_HANDLED;
                        goto exit;
                }
-               DBG_8723A("issue_deauth23a to sta =" MAC_FMT " for the reason(7)\n",
-                         MAC_ARG(pattrib->src));
+               DBG_8723A("issue_deauth23a to sta=%pM for the reason(7)\n",
+                         pattrib->src);
                issue_deauth23a(adapter, pattrib->src,
                             WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
                ret = RTW_RX_HANDLED;
@@ -1214,12 +1193,12 @@ static int validate_recv_mgnt_frame(struct rtw_adapter *padapter,
        /* struct mlme_priv *pmlmepriv = &adapter->mlmepriv; */
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                ("+validate_recv_mgnt_frame\n"));
+                "+validate_recv_mgnt_frame\n");
 
        precv_frame = recvframe_chk_defrag23a(padapter, precv_frame);
        if (precv_frame == NULL) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                        ("%s: fragment packet\n", __func__));
+                        "%s: fragment packet\n", __func__);
                return _SUCCESS;
        }
 
@@ -1305,7 +1284,7 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter,
                ether_addr_copy(pattrib->ra, hdr->addr1);
                ether_addr_copy(pattrib->ta, hdr->addr2);
                ret = _FAIL;
-               RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n"));
+               RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, "case 3\n");
                break;
        }
 
@@ -1314,7 +1293,7 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter,
 
        if (!psta) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        (" after to_fr_ds_chk; psta == NULL\n"));
+                        "after to_fr_ds_chk; psta == NULL\n");
                ret = _FAIL;
                goto exit;
        }
@@ -1357,26 +1336,25 @@ static int validate_recv_data_frame(struct rtw_adapter *adapter,
        if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) ==
            _FAIL) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("decache : drop pkt\n"));
+                        "decache : drop pkt\n");
                ret = _FAIL;
                goto exit;
        }
 
        if (pattrib->privacy) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("validate_recv_data_frame:pattrib->privacy =%x\n",
-                        pattrib->privacy));
+                        "validate_recv_data_frame:pattrib->privacy =%x\n",
+                        pattrib->privacy);
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("\n ^^^^^^^^^^^is_multicast_ether_addr"
-                         "(pattrib->ra(0x%02x)) =%d^^^^^^^^^^^^^^^6\n",
-                         pattrib->ra[0],
-                         is_multicast_ether_addr(pattrib->ra)));
+                        "^^^^^^^^^^^is_multicast_ether_addr(pattrib->ra(0x%02x)) =%d^^^^^^^^^^^^^^^6\n",
+                        pattrib->ra[0],
+                        is_multicast_ether_addr(pattrib->ra));
 
                GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt,
                               is_multicast_ether_addr(pattrib->ra));
 
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("\n pattrib->encrypt =%d\n", pattrib->encrypt));
+                        "pattrib->encrypt =%d\n", pattrib->encrypt);
 
                switch (pattrib->encrypt) {
                case WLAN_CIPHER_SUITE_WEP40:
@@ -1457,7 +1435,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter,
        /* add version chk */
        if (ver != 0) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("validate_recv_data_frame fail! (ver!= 0)\n"));
+                        "validate_recv_data_frame fail! (ver!= 0)\n");
                retval = _FAIL;
                goto exit;
        }
@@ -1482,7 +1460,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter,
                retval = validate_recv_mgnt_frame(adapter, precv_frame);
                if (retval == _FAIL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("validate_recv_mgnt_frame fail\n"));
+                                "validate_recv_mgnt_frame fail\n");
                }
                retval = _FAIL; /*  only data frame return _SUCCESS */
                break;
@@ -1490,7 +1468,7 @@ static int validate_recv_frame(struct rtw_adapter *adapter,
                retval = validate_recv_ctrl_frame(adapter, precv_frame);
                if (retval == _FAIL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("validate_recv_ctrl_frame fail\n"));
+                                "validate_recv_ctrl_frame fail\n");
                }
                retval = _FAIL; /*  only data frame return _SUCCESS */
                break;
@@ -1499,13 +1477,13 @@ static int validate_recv_frame(struct rtw_adapter *adapter,
                retval = validate_recv_data_frame(adapter, precv_frame);
                if (retval == _FAIL) {
                        struct recv_priv *precvpriv = &adapter->recvpriv;
-                       /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */
+
                        precvpriv->rx_drop++;
                }
                break;
        default:
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("validate_recv_data_frame fail! type = 0x%x\n", type));
+                        "validate_recv_data_frame fail! type = 0x%x\n", type);
                retval = _FAIL;
                break;
        }
@@ -1552,8 +1530,8 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe)
        len = skb->len - hdrlen;
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                ("\n === pattrib->hdrlen: %x,  pattrib->iv_len:%x ===\n\n",
-                 pattrib->hdrlen,  pattrib->iv_len));
+                "=== pattrib->hdrlen: %x,  pattrib->iv_len:%x ===\n",
+                pattrib->hdrlen,  pattrib->iv_len);
 
        pattrib->eth_type = eth_type;
        if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
@@ -1665,7 +1643,7 @@ struct recv_frame *recvframe_defrag(struct rtw_adapter *adapter,
        rtw_free_recvframe23a_queue(defrag_q);
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                ("Performance defrag!!!!!\n"));
+                "Performance defrag!!!!!\n");
 
 
 
@@ -1736,8 +1714,8 @@ struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
                        /* spin_unlock(&pdefrag_q->lock); */
 
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("Enqueuq: ismfrag = %d, fragnum = %d\n",
-                                 ismfrag, fragnum));
+                                "Enqueuq: ismfrag = %d, fragnum = %d\n",
+                                ismfrag, fragnum);
 
                        prtnframe = NULL;
 
@@ -1747,8 +1725,8 @@ struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
                        rtw_free_recvframe23a(precv_frame);
                        prtnframe = NULL;
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("Free because pdefrag_q == NULL: ismfrag = "
-                                 "%d, fragnum = %d\n", ismfrag, fragnum));
+                                "Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n",
+                                ismfrag, fragnum);
                }
        }
 
@@ -1763,8 +1741,8 @@ struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
 
                        /* call recvframe_defrag to defrag */
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("defrag: ismfrag = %d, fragnum = %d\n",
-                                 ismfrag, fragnum));
+                                "defrag: ismfrag = %d, fragnum = %d\n",
+                                ismfrag, fragnum);
                        precv_frame = recvframe_defrag(padapter, pdefrag_q);
                        prtnframe = precv_frame;
                } else {
@@ -1773,8 +1751,8 @@ struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
                        rtw_free_recvframe23a(precv_frame);
                        prtnframe = NULL;
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("Free because pdefrag_q == NULL: ismfrag = "
-                                 "%d, fragnum = %d\n", ismfrag, fragnum));
+                                "Free because pdefrag_q == NULL: ismfrag = %d, fragnum = %d\n",
+                                ismfrag, fragnum);
                }
 
        }
@@ -1783,8 +1761,7 @@ struct recv_frame *recvframe_chk_defrag23a(struct rtw_adapter *padapter,
                /* after defrag we must check tkip mic code */
                if (recvframe_chkmic(padapter,  prtnframe) == _FAIL) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("recvframe_chkmic(padapter,  prtnframe) =="
-                                 "_FAIL\n"));
+                                "recvframe_chkmic(padapter,  prtnframe) ==_FAIL\n");
                        rtw_free_recvframe23a(prtnframe);
                        prtnframe = NULL;
                }
@@ -1883,7 +1860,6 @@ static int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl,
                        continue;
                } else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) {
                        /* Duplicate entry is found!! Do not insert current entry. */
-                       /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */
 
                        /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock); */
                        return false;
@@ -1904,7 +1880,6 @@ static int enqueue_reorder_recvframe23a(struct recv_reorder_ctrl *preorder_ctrl,
        /* spin_unlock_ex(&ppending_recvframe_queue->lock); */
        /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock); */
 
-       /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */
        return true;
 }
 
@@ -1956,10 +1931,9 @@ int recv_indicatepkts_in_order(struct rtw_adapter *padapter,
 
                if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                ("recv_indicatepkts_in_order: indicate =%d "
-                                 "seq =%d amsdu =%d\n",
-                                 preorder_ctrl->indicate_seq,
-                                 pattrib->seq_num, pattrib->amsdu));
+                                "recv_indicatepkts_in_order: indicate =%d seq =%d amsdu =%d\n",
+                                preorder_ctrl->indicate_seq,
+                                pattrib->seq_num, pattrib->amsdu);
 
                        plist = plist->next;
                        list_del_init(&prframe->list);
@@ -2021,8 +1995,7 @@ int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
                        if ((padapter->bDriverStopped == false) &&
                            (padapter->bSurpriseRemoved == false)) {
                                RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                        ("@@@@  recv_indicatepkt_reorder -"
-                                         "recv_func recv_indicatepkt\n"));
+                                        "@@@@  recv_indicatepkt_reorder -recv_func recv_indicatepkt\n");
 
                                rtw_recv_indicatepkt23a(padapter, prframe);
                                return _SUCCESS;
@@ -2055,8 +2028,8 @@ int recv_indicatepkt_reorder(struct rtw_adapter *padapter,
        spin_lock_bh(&ppending_recvframe_queue->lock);
 
        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                ("recv_indicatepkt_reorder: indicate =%d seq =%d\n",
-                 preorder_ctrl->indicate_seq, pattrib->seq_num));
+                "recv_indicatepkt_reorder: indicate =%d seq =%d\n",
+                preorder_ctrl->indicate_seq, pattrib->seq_num);
 
        /* s2. check if winstart_b(indicate_seq) needs to been updated */
        if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) {
@@ -2149,7 +2122,7 @@ int process_recv_indicatepkts(struct rtw_adapter *padapter,
                retval = wlanhdr_to_ethhdr(prframe);
                if (retval != _SUCCESS) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("wlanhdr_to_ethhdr: drop pkt\n"));
+                                "wlanhdr_to_ethhdr: drop pkt\n");
                        return retval;
                }
 
@@ -2157,19 +2130,16 @@ int process_recv_indicatepkts(struct rtw_adapter *padapter,
                    (padapter->bSurpriseRemoved == false)) {
                        /* indicate this recv_frame */
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                ("@@@@ process_recv_indicatepkts- "
-                                 "recv_func recv_indicatepkt\n"));
+                                "@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n");
                        rtw_recv_indicatepkt23a(padapter, prframe);
                } else {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                ("@@@@ process_recv_indicatepkts- "
-                                 "recv_func free_indicatepkt\n"));
+                                "@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n");
 
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_,
-                                ("recv_func:bDriverStopped(%d) OR "
-                                 "bSurpriseRemoved(%d)",
-                                 padapter->bDriverStopped,
-                                 padapter->bSurpriseRemoved));
+                                "recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n",
+                                padapter->bDriverStopped,
+                                padapter->bSurpriseRemoved);
                        retval = _FAIL;
                        return retval;
                }
@@ -2188,7 +2158,7 @@ static int recv_func_prehandle(struct rtw_adapter *padapter,
        ret = validate_recv_frame(padapter, rframe);
        if (ret != _SUCCESS) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("recv_func: validate_recv_frame fail! drop pkt\n"));
+                        "recv_func: validate_recv_frame fail! drop pkt\n");
                rtw_free_recvframe23a(rframe);
                goto exit;
        }
@@ -2208,7 +2178,7 @@ static int recv_func_posthandle(struct rtw_adapter *padapter,
        prframe = decryptor(padapter, prframe);
        if (prframe == NULL) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("decryptor: drop pkt\n"));
+                        "decryptor: drop pkt\n");
                ret = _FAIL;
                goto _recv_data_drop;
        }
@@ -2216,7 +2186,7 @@ static int recv_func_posthandle(struct rtw_adapter *padapter,
        prframe = recvframe_chk_defrag23a(padapter, prframe);
        if (!prframe) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("recvframe_chk_defrag23a: drop pkt\n"));
+                        "recvframe_chk_defrag23a: drop pkt\n");
                goto _recv_data_drop;
        }
 
@@ -2235,7 +2205,7 @@ static int recv_func_posthandle(struct rtw_adapter *padapter,
        prframe = portctrl(padapter, prframe);
        if (!prframe) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("portctrl: drop pkt\n"));
+                        "portctrl: drop pkt\n");
                ret = _FAIL;
                goto _recv_data_drop;
        }
@@ -2245,7 +2215,7 @@ static int recv_func_posthandle(struct rtw_adapter *padapter,
        ret = process_recv_indicatepkts(padapter, prframe);
        if (ret != _SUCCESS) {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("recv_func: process_recv_indicatepkts fail!\n"));
+                        "recv_func: process_recv_indicatepkts fail!\n");
                rtw_free_recvframe23a(orig_prframe);/* free this recv_frame */
                goto _recv_data_drop;
        }
@@ -2334,8 +2304,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..af53c92fc3a29063c6e0ee9ddaf9a6db9f606d41 100644 (file)
@@ -31,11 +31,11 @@ struct arc4context {
 
 static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
 {
-       u32     t, u;
-       u32     keyindex;
-       u32     stateindex;
+       u32 t, u;
+       u32 keyindex;
+       u32 stateindex;
        u8 *state;
-       u32     counter;
+       u32 counter;
 
        state = parc4ctx->state;
        parc4ctx->x = 0;
@@ -55,7 +55,8 @@ static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
        }
 
 }
-static u32 arcfour_byte(       struct arc4context      *parc4ctx)
+
+static u32 arcfour_byte(struct arc4context *parc4ctx)
 {
        u32 x;
        u32 y;
@@ -75,19 +76,16 @@ static u32 arcfour_byte(    struct arc4context      *parc4ctx)
        return state[(sx + sy) & 0xff];
 }
 
-static void arcfour_encrypt(   struct arc4context      *parc4ctx,
-       u8 *dest,
-       u8 *src,
-       u32 len)
+static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest,
+                           u8 *src, u32 len)
 {
-       u32     i;
+       u32 i;
 
        for (i = 0; i < len; i++)
                dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-
 }
 
-static int bcrc32initialized = 0;
+static int bcrc32initialized;
 static u32 crc32_table[256];
 
 static u8 crc32_reverseBit(u8 data)
@@ -101,46 +99,48 @@ static u8 crc32_reverseBit(u8 data)
 
 static void crc32_init(void)
 {
+       int i, j;
+       u32 c;
+       u8 *p, *p1;
+       u8 k;
 
        if (bcrc32initialized == 1)
                return;
-       else{
-               int i, j;
-               u32 c;
-               u8 *p = (u8 *)&c, *p1;
-               u8 k;
-
-               c = 0x12340000;
-
-               for (i = 0; i < 256; ++i) {
-                       k = crc32_reverseBit((u8)i);
-                       for (c = ((u32)k) << 24, j = 8; j > 0; --j) {
-                               c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
-                       }
-                       p1 = (u8 *)&crc32_table[i];
-
-                       p1[0] = crc32_reverseBit(p[3]);
-                       p1[1] = crc32_reverseBit(p[2]);
-                       p1[2] = crc32_reverseBit(p[1]);
-                       p1[3] = crc32_reverseBit(p[0]);
-               }
-               bcrc32initialized = 1;
+
+       p = (u8 *) &c;
+       c = 0x12340000;
+
+       for (i = 0; i < 256; ++i) {
+               k = crc32_reverseBit((u8)i);
+
+               for (c = ((u32)k) << 24, j = 8; j > 0; --j)
+                       c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
+
+               p1 = (u8 *)&crc32_table[i];
+
+               p1[0] = crc32_reverseBit(p[3]);
+               p1[1] = crc32_reverseBit(p[2]);
+               p1[2] = crc32_reverseBit(p[1]);
+               p1[3] = crc32_reverseBit(p[0]);
        }
+
+       bcrc32initialized = 1;
 }
 
 static u32 getcrc32(u8 *buf, int len)
 {
        u8 *p;
-       u32  crc;
+       u32 crc;
 
-       if (bcrc32initialized == 0) crc32_init();
+       if (bcrc32initialized == 0)
+               crc32_init();
 
-       crc = 0xffffffff;       /* preload shift register, per CRC-32 spec */
+       crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
 
        for (p = buf; len > 0; ++p, --len)
-               crc = crc32_table[ (crc ^ *p) & 0xff] ^ (crc >> 8);
+               crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
 
-       return ~crc;    /* transmit complement, per CRC-32 spec */
+       return ~crc; /* transmit complement, per CRC-32 spec */
 }
 
 /* Need to consider the fragment  situation */
@@ -152,7 +152,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
        struct arc4context mycontext;
        int curfragnum, length, index;
        u32 keylength;
-       u8 *pframe, *payload, *iv;    /* wepkey */
+       u8 *pframe, *payload, *iv; /* wepkey */
        u8 wepkey[16];
        u8 hw_hdr_offset = 0;
        struct pkt_attrib *pattrib = &pxmitframe->attrib;
@@ -184,7 +184,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
                if ((curfragnum + 1) == pattrib->nr_frags) {
                        /* the last fragment */
                        length = pattrib->last_txcmdsz - pattrib->hdrlen -
-                               pattrib->iv_len- pattrib->icv_len;
+                               pattrib->iv_len - pattrib->icv_len;
 
                        *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 
@@ -210,7 +210,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
                     struct recv_frame *precvframe)
 {
        /*  exclude ICV */
-       u8 crc[4];
+       u32 actual_crc, expected_crc;
        struct arc4context mycontext;
        int length;
        u32 keylength;
@@ -243,19 +243,14 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
        arcfour_encrypt(&mycontext, payload, payload, length);
 
        /* calculate icv and compare the icv */
-       *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
+       actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
+       expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
 
-       if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
-           crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
+       if (actual_crc != expected_crc) {
                RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                        ("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload"
-                         "[length-1](%x) || crc[2](%x)!= payload[length-2](%x)"
-                         " || crc[1](%x)!= payload[length-3](%x) || crc[0](%x)"
-                         "!= payload[length-4](%x)\n",
-                         crc[3], payload[length - 1],
-                         crc[2], payload[length - 2],
-                         crc[1], payload[length - 3],
-                         crc[0], payload[length - 4]));
+                        "%s:icv CRC mismatch: "
+                        "actual: %08x, expected: %08x\n",
+                        __func__, actual_crc, expected_crc);
        }
 }
 
@@ -267,9 +262,8 @@ static u32 secmicgetuint32(u8 *p)
        s32 i;
        u32 res = 0;
 
-       for (i = 0; i<4; i++) {
-               res |= ((u32)(*p++)) << (8*i);
-       }
+       for (i = 0; i < 4; i++)
+               res |= ((u32)(*p++)) << (8 * i);
 
        return res;
 }
@@ -279,7 +273,7 @@ static void secmicputuint32(u8 *p, u32 val)
 {
        long i;
 
-       for (i = 0; i<4; i++) {
+       for (i = 0; i < 4; i++) {
                *p++ = (u8) (val & 0xff);
                val >>= 8;
        }
@@ -312,7 +306,7 @@ void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b)
 {
 
        /*  Append the byte to our word-sized buffer */
-       pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM);
+       pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM);
        pmicdata->nBytesInM++;
        /*  Process the word if it is full. */
        if (pmicdata->nBytesInM >= 4) {
@@ -336,7 +330,7 @@ void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbytes)
 {
 
        /*  This is simple */
-       while(nbytes > 0) {
+       while (nbytes > 0) {
                rtw_secmicappend23abyte23a(pmicdata, *src++);
                nbytes--;
        }
@@ -353,12 +347,11 @@ void rtw_secgetmic23a(struct mic_data *pmicdata, u8 *dst)
        rtw_secmicappend23abyte23a(pmicdata, 0);
        rtw_secmicappend23abyte23a(pmicdata, 0);
        /*  and then zeroes until the length is a multiple of 4 */
-       while(pmicdata->nBytesInM != 0) {
+       while (pmicdata->nBytesInM != 0)
                rtw_secmicappend23abyte23a(pmicdata, 0);
-       }
        /*  The appendByte function has already computed the result. */
        secmicputuint32(dst, pmicdata->L);
-       secmicputuint32(dst+4, pmicdata->R);
+       secmicputuint32(dst + 4, pmicdata->R);
        /*  Reset to the empty message. */
        secmicclear(pmicdata);
 
@@ -368,23 +361,22 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len,
                           u8 *mic_code, u8 pri)
 {
 
-       struct mic_data micdata;
-       u8 priority[4]={0x0, 0x0, 0x0, 0x0};
+       struct mic_data micdata;
+       u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
 
        rtw_secmicsetkey23a(&micdata, key);
-       priority[0]= pri;
+       priority[0] = pri;
 
        /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */
-       if (header[1]&1) {   /* ToDS == 1 */
-                       rtw_secmicappend23a(&micdata, &header[16], 6);  /* DA */
-               if (header[1]&2)  /* From Ds == 1 */
+       if (header[1]&1) { /* ToDS == 1 */
+                       rtw_secmicappend23a(&micdata, &header[16], 6); /* DA */
+               if (header[1]&2) /* From Ds == 1 */
                        rtw_secmicappend23a(&micdata, &header[24], 6);
                else
                        rtw_secmicappend23a(&micdata, &header[10], 6);
-       }
-       else{   /* ToDS == 0 */
-               rtw_secmicappend23a(&micdata, &header[4], 6);   /* DA */
-               if (header[1]&2)  /* From Ds == 1 */
+       } else { /* ToDS == 0 */
+               rtw_secmicappend23a(&micdata, &header[4], 6); /* DA */
+               if (header[1]&2) /* From Ds == 1 */
                        rtw_secmicappend23a(&micdata, &header[16], 6);
                else
                        rtw_secmicappend23a(&micdata, &header[10], 6);
@@ -403,11 +395,11 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len,
 #define   Lo8(v16)   ((u8)((v16)       & 0x00FF))
 #define   Hi8(v16)   ((u8)(((v16) >> 8) & 0x00FF))
 #define  Lo16(v32)   ((u16)((v32)       & 0xFFFF))
-#define  Hi16(v32)   ((u16)(((v32) >>16) & 0xFFFF))
+#define  Hi16(v32)   ((u16)(((v32) >> 16) & 0xFFFF))
 #define  Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8))
 
-/* select the Nth 16-bit word of the temporal key unsigned char array TK[]   */
-#define  TK16(N)     Mk16(tk[2*(N)+1], tk[2*(N)])
+/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */
+#define  TK16(N)     Mk16(tk[2 * (N) + 1], tk[2 * (N)])
 
 /* S-box lookup: 16 bits --> 16 bits */
 #define _S_(v16)     (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)])
@@ -420,76 +412,76 @@ void rtw_seccalctkipmic23a(u8 *key, u8 *header, u8 *data, u32 data_len,
 #define RC4_KEY_SIZE     16    /* 128-bit RC4KEY (104 bits unknown) */
 
 /* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */
-static const unsigned short Sbox1[2][256]=       /* Sbox for hash (can be in ROM)     */
-{ {
-   0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
-   0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
-   0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
-   0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
-   0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
-   0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
-   0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
-   0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
-   0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
-   0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
-   0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
-   0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
-   0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
-   0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
-   0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
-   0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
-   0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
-   0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
-   0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
-   0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
-   0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
-   0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
-   0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
-   0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
-   0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
-   0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
-   0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
-   0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
-   0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
-   0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
-   0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
-   0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
-  },
-
-   /* second half of table is unsigned char-reversed version of first! */
-   0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491,
-   0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
-   0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB,
-   0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B,
-   0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83,
-   0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A,
-   0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F,
-   0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA,
-   0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B,
-   0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713,
-   0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6,
-   0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85,
-   0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411,
-   0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B,
-   0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1,
-   0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF,
-   0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E,
-   0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6,
-   0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B,
-   0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD,
-   0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8,
-   0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2,
-   0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049,
-   0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810,
-   0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197,
-   0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F,
-   0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C,
-   0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927,
-   0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733,
-   0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5,
-   0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0,
-   0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C,
-  }
+static const unsigned short Sbox1[2][256] = {
+       /* Sbox for hash (can be in ROM) */
+       {
+               0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
+               0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
+               0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
+               0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
+               0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
+               0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
+               0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
+               0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
+               0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
+               0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
+               0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
+               0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
+               0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
+               0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
+               0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
+               0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
+               0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
+               0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
+               0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
+               0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
+               0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
+               0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
+               0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
+               0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
+               0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
+               0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
+               0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
+               0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
+               0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
+               0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
+               0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
+               0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
+       },
+       { /* second half of table is unsigned char-reversed version of first! */
+               0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491,
+               0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC,
+               0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB,
+               0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B,
+               0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83,
+               0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A,
+               0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F,
+               0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA,
+               0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B,
+               0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713,
+               0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6,
+               0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85,
+               0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411,
+               0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B,
+               0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1,
+               0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF,
+               0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E,
+               0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6,
+               0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B,
+               0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD,
+               0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8,
+               0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2,
+               0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049,
+               0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810,
+               0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197,
+               0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F,
+               0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C,
+               0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927,
+               0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733,
+               0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5,
+               0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0,
+               0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C,
+       }
 };
 
  /*
@@ -513,7 +505,7 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 {
        int  i;
 
-       /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5]     */
+       /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */
        p1k[0]      = Lo16(iv32);
        p1k[1]      = Hi16(iv32);
        p1k[2]      = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */
@@ -522,14 +514,14 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 
        /* Now compute an unbalanced Feistel cipher with 80-bit block */
        /* size on the 80-bit block P1K[], using the 128-bit key TK[] */
-       for (i = 0; i < PHASE1_LOOP_CNT ;i++) {
+       for (i = 0; i < PHASE1_LOOP_CNTi++) {
                /* Each add operation here is mod 2**16 */
-               p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0));
-               p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2));
-               p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4));
-               p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6));
-               p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0));
-               p1k[4] +=  (unsigned short)i;                    /* avoid "slide attacks" */
+               p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0));
+               p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2));
+               p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4));
+               p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6));
+               p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0));
+               p1k[4] +=  (unsigned short) i; /* avoid "slide attacks" */
                }
 
 }
@@ -560,42 +552,44 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32)
 static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
 {
        int  i;
-       u16 PPK[6];                          /* temporary key for mixing    */
+       u16 PPK[6]; /* temporary key for mixing    */
+
+       /* Note: all adds in the PPK[] equations below are mod 2**16 */
+       for (i = 0; i < 5; i++)
+               PPK[i] = p1k[i]; /* first, copy P1K to PPK */
 
-       /* Note: all adds in the PPK[] equations below are mod 2**16         */
-       for (i = 0;i<5;i++) PPK[i]= p1k[i];      /* first, copy P1K to PPK      */
-               PPK[5]  =  p1k[4] +iv16;             /* next,  add in IV16          */
+       PPK[5] = p1k[4] + iv16; /* next,  add in IV16 */
 
-       /* Bijective non-linear mixing of the 96 bits of PPK[0..5]           */
-       PPK[0] +=    _S_(PPK[5] ^ TK16(0));   /* Mix key in each "round"     */
-       PPK[1] +=    _S_(PPK[0] ^ TK16(1));
-       PPK[2] +=    _S_(PPK[1] ^ TK16(2));
-       PPK[3] +=    _S_(PPK[2] ^ TK16(3));
-       PPK[4] +=    _S_(PPK[3] ^ TK16(4));
-       PPK[5] +=    _S_(PPK[4] ^ TK16(5));   /* Total # S-box lookups == 6  */
+       /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */
+       PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */
+       PPK[1] += _S_(PPK[0] ^ TK16(1));
+       PPK[2] += _S_(PPK[1] ^ TK16(2));
+       PPK[3] += _S_(PPK[2] ^ TK16(3));
+       PPK[4] += _S_(PPK[3] ^ TK16(4));
+       PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */
 
-       /* Final sweep: bijective, "linear". Rotates kill LSB correlations   */
+       /* Final sweep: bijective, "linear". Rotates kill LSB correlations */
        PPK[0] +=  RotR1(PPK[5] ^ TK16(6));
-       PPK[1] +=  RotR1(PPK[0] ^ TK16(7));   /* Use all of TK[] in Phase2   */
+       PPK[1] +=  RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */
        PPK[2] +=  RotR1(PPK[1]);
        PPK[3] +=  RotR1(PPK[2]);
        PPK[4] +=  RotR1(PPK[3]);
        PPK[5] +=  RotR1(PPK[4]);
        /* Note: At this point, for a given key TK[0..15], the 96-bit output */
        /*       value PPK[0..5] is guaranteed to be unique, as a function   */
-       /*       of the 96-bit "input" value   {TA, IV32, IV16}. That is, P1K  */
-       /*       is now a keyed permutation of {TA, IV32, IV16}.               */
+       /*       of the 96-bit "input" value   {TA, IV32, IV16}. That is,    */
+       /*       P1K is now a keyed permutation of {TA, IV32, IV16}.         */
 
        /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key   */
-       rc4key[0] = Hi8(iv16);                /* RC4KEY[0..2] is the WEP IV  */
-       rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys  */
+       rc4key[0] = Hi8(iv16);                 /* RC4KEY[0..2] is the WEP IV */
+       rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */
        rc4key[2] = Lo8(iv16);
        rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1);
 
-       /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15]  (little-endian)       */
-       for (i = 0;i<6;i++) {
-               rc4key[4+2*i] = Lo8(PPK[i]);
-               rc4key[5+2*i] = Hi8(PPK[i]);
+       /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15]  (little-endian) */
+       for (i = 0; i < 6; i++) {
+               rc4key[4 + 2 * i] = Lo8(PPK[i]);
+               rc4key[5 + 2 * i] = Hi8(PPK[i]);
        }
 
 }
@@ -604,97 +598,107 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16)
 int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
                        struct xmit_frame *pxmitframe)
 {
-       u16     pnl;
-       u32     pnh;
-       u8      rc4key[16];
-       u8   ttkey[16];
-       u8      crc[4];
-       u8   hw_hdr_offset = 0;
+       u16 pnl;
+       u32 pnh;
+       u8 rc4key[16];
+       u8 ttkey[16];
+       u8 crc[4];
+       u8 hw_hdr_offset = 0;
        struct arc4context mycontext;
-       int                     curfragnum, length;
-       u32     prwskeylen;
-       u8      *pframe, *payload, *iv, *prwskey;
+       int curfragnum, length;
+       u32 prwskeylen;
+       u8 *pframe, *payload, *iv, *prwskey;
        union pn48 dot11txpn;
-       struct  sta_info                *stainfo;
-       struct  pkt_attrib       *pattrib = &pxmitframe->attrib;
-       struct  security_priv   *psecuritypriv = &padapter->securitypriv;
-       struct  xmit_priv               *pxmitpriv = &padapter->xmitpriv;
+       struct sta_info *stainfo;
+       struct pkt_attrib *pattrib = &pxmitframe->attrib;
+       struct security_priv *psecuritypriv = &padapter->securitypriv;
+       struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        int res = _SUCCESS;
 
+       if (pattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
+               return _FAIL;
+
        if (!pxmitframe->buf_addr)
                return _FAIL;
 
        hw_hdr_offset = TXDESC_OFFSET;
 
        pframe = pxmitframe->buf_addr + hw_hdr_offset;
-       /* 4 start to encrypt each fragment */
-       if (pattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
-               if (pattrib->psta)
-                       stainfo = pattrib->psta;
-               else {
-                       DBG_8723A("%s, call rtw_get_stainfo()\n", __func__);
-                       stainfo = rtw_get_stainfo23a(&padapter->stapriv,
-                                                    &pattrib->ra[0]);
-               }
 
-               if (stainfo!= NULL) {
+       if (pattrib->psta)
+               stainfo = pattrib->psta;
+       else {
+               DBG_8723A("%s, call rtw_get_stainfo()\n", __func__);
+               stainfo = rtw_get_stainfo23a(&padapter->stapriv,
+                                            &pattrib->ra[0]);
+       }
 
-                       if (!(stainfo->state &_FW_LINKED)) {
-                               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
-                               return _FAIL;
-                       }
+       if (stainfo == NULL) {
+               RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                        "%s: stainfo == NULL!!!\n", __func__);
+               DBG_8723A("%s, psta == NUL\n", __func__);
+               return _FAIL;
+       }
 
-                       RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: stainfo!= NULL!!!\n"));
+       RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                "%s: stainfo!= NULL!!!\n", __func__);
 
-                       if (is_multicast_ether_addr(pattrib->ra))
-                               prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
-                       else
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
+       if (!(stainfo->state & _FW_LINKED)) {
+               DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
+               return _FAIL;
+       }
 
-                       prwskeylen = 16;
+       if (is_multicast_ether_addr(pattrib->ra))
+               prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
+       else
+               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
 
-                       for (curfragnum = 0;curfragnum<pattrib->nr_frags;curfragnum++) {
-                               iv = pframe+pattrib->hdrlen;
-                               payload = pframe+pattrib->iv_len+pattrib->hdrlen;
+       prwskeylen = 16;
 
-                               GET_TKIP_PN(iv, dot11txpn);
+       /* 4 start to encrypt each fragment */
+       for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
+               iv = pframe + pattrib->hdrlen;
+               payload = pframe + pattrib->iv_len + pattrib->hdrlen;
 
-                               pnl = (u16)(dot11txpn.val);
-                               pnh = (u32)(dot11txpn.val>>16);
+               GET_TKIP_PN(iv, dot11txpn);
 
-                               phase1((u16 *)&ttkey[0], prwskey,&pattrib->ta[0], pnh);
+               pnl = (u16)(dot11txpn.val);
+               pnh = (u32)(dot11txpn.val>>16);
 
-                               phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl);
+               phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh);
 
-                               if ((curfragnum+1) == pattrib->nr_frags) {      /* 4 the last fragment */
-                                       length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len;
-                                       RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, pattrib->icv_len));
-                                       *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
+               phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl);
 
-                                       arcfour_init(&mycontext, rc4key, 16);
-                                       arcfour_encrypt(&mycontext, payload, payload, length);
-                                       arcfour_encrypt(&mycontext, payload+length, crc, 4);
+               if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */
+                       length = (pattrib->last_txcmdsz -
+                                 pattrib->hdrlen -
+                                 pattrib->iv_len -
+                                 pattrib->icv_len);
 
-                               }
-                               else{
-                                       length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ;
-                                       *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
-                                       arcfour_init(&mycontext, rc4key, 16);
-                                       arcfour_encrypt(&mycontext, payload, payload, length);
-                                       arcfour_encrypt(&mycontext, payload+length, crc, 4);
+                       RT_TRACE(_module_rtl871x_security_c_, _drv_info_,
+                                "pattrib->iv_len =%x, pattrib->icv_len =%x\n",
+                                pattrib->iv_len,
+                                pattrib->icv_len);
+                       *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 
-                               pframe+= pxmitpriv->frag_len;
-                               pframe = PTR_ALIGN(pframe, 4);
-                               }
-                       }
+                       arcfour_init(&mycontext, rc4key, 16);
+                       arcfour_encrypt(&mycontext, payload, payload, length);
+                       arcfour_encrypt(&mycontext, payload + length, crc, 4);
 
-               }
-               else{
-                       RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt23a: stainfo == NULL!!!\n"));
-                       DBG_8723A("%s, psta == NUL\n", __func__);
-                       res = _FAIL;
-               }
+               } else {
+                       length = (pxmitpriv->frag_len -
+                                 pattrib->hdrlen -
+                                 pattrib->iv_len -
+                                 pattrib->icv_len);
 
+                       *((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+                       arcfour_init(&mycontext, rc4key, 16);
+                       arcfour_encrypt(&mycontext, payload, payload, length);
+                       arcfour_encrypt(&mycontext, payload + length, crc, 4);
+
+                       pframe += pxmitpriv->frag_len;
+                       pframe  = PTR_ALIGN(pframe, 4);
+               }
        }
 
        return res;
@@ -706,72 +710,76 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 {
        u16 pnl;
        u32 pnh;
-       u8   rc4key[16];
-       u8   ttkey[16];
-       u8      crc[4];
+       u8 rc4key[16];
+       u8 ttkey[16];
+       u32 actual_crc, expected_crc;
        struct arc4context mycontext;
-       int     length;
-       u32     prwskeylen;
-       u8      *pframe, *payload, *iv, *prwskey;
+       int length;
+       u32 prwskeylen;
+       u8 *pframe, *payload, *iv, *prwskey;
        union pn48 dot11txpn;
-       struct  sta_info                *stainfo;
-       struct  rx_pkt_attrib *prxattrib = &precvframe->attrib;
-       struct  security_priv *psecuritypriv = &padapter->securitypriv;
+       struct sta_info *stainfo;
+       struct rx_pkt_attrib *prxattrib = &precvframe->attrib;
+       struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct sk_buff *skb = precvframe->pkt;
        int res = _SUCCESS;
 
+       if (prxattrib->encrypt != WLAN_CIPHER_SUITE_TKIP)
+               return _FAIL;
+
        pframe = skb->data;
 
+       stainfo = rtw_get_stainfo23a(&padapter->stapriv,
+                                    &prxattrib->ta[0]);
+       if (stainfo == NULL) {
+               RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                        "%s: stainfo == NULL!!!\n", __func__);
+               return _FAIL;
+       }
+
        /* 4 start to decrypt recvframe */
-       if (prxattrib->encrypt == WLAN_CIPHER_SUITE_TKIP) {
+       if (is_multicast_ether_addr(prxattrib->ra)) {
+               if (psecuritypriv->binstallGrpkey == 0) {
+                       res = _FAIL;
+                       DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
+                       goto exit;
+               }
+               prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
+               prwskeylen = 16;
+       } else {
+               RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                        "%s: stainfo!= NULL!!!\n", __func__);
+               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
+               prwskeylen = 16;
+       }
 
-               stainfo = rtw_get_stainfo23a(&padapter->stapriv,
-                                            &prxattrib->ta[0]);
-               if (stainfo!= NULL) {
-
-                       if (is_multicast_ether_addr(prxattrib->ra)) {
-                               if (psecuritypriv->binstallGrpkey == 0) {
-                                       res = _FAIL;
-                                       DBG_8723A("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__);
-                                       goto exit;
-                               }
-                               prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;
-                               prwskeylen = 16;
-                       } else {
-                               RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt23a: stainfo!= NULL!!!\n"));
-                               prwskey = &stainfo->dot118021x_UncstKey.skey[0];
-                               prwskeylen = 16;
-                       }
-
-                       iv = pframe+prxattrib->hdrlen;
-                       payload = pframe+prxattrib->iv_len+prxattrib->hdrlen;
-                       length = skb->len - prxattrib->hdrlen-prxattrib->iv_len;
-
-                       GET_TKIP_PN(iv, dot11txpn);
-
-                       pnl = (u16)(dot11txpn.val);
-                       pnh = (u32)(dot11txpn.val>>16);
-
-                       phase1((u16 *)&ttkey[0], prwskey,&prxattrib->ta[0], pnh);
-                       phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
-
-                       /* 4 decrypt payload include icv */
-                       arcfour_init(&mycontext, rc4key, 16);
-                       arcfour_encrypt(&mycontext, payload, payload, length);
+       iv = pframe + prxattrib->hdrlen;
+       payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
+       length = skb->len - prxattrib->hdrlen - prxattrib->iv_len;
 
-                       *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
+       GET_TKIP_PN(iv, dot11txpn);
 
-                       if (crc[3]!= payload[length-1] || crc[2]!= payload[length-2] || crc[1]!= payload[length-3] || crc[0]!= payload[length-4])
-                       {
-                           RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt23a:icv error crc[3](%x)!= payload[length-1](%x) || crc[2](%x)!= payload[length-2](%x) || crc[1](%x)!= payload[length-3](%x) || crc[0](%x)!= payload[length-4](%x)\n",
-                                               crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4]));
-                               res = _FAIL;
-                       }
-               } else {
-                       RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt23a: stainfo == NULL!!!\n"));
-                       res = _FAIL;
-               }
+       pnl = (u16)(dot11txpn.val);
+       pnh = (u32)(dot11txpn.val>>16);
+
+       phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);
+       phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);
+
+       /* 4 decrypt payload include icv */
+       arcfour_init(&mycontext, rc4key, 16);
+       arcfour_encrypt(&mycontext, payload, payload, length);
+
+       actual_crc = le32_to_cpu(getcrc32(payload, length - 4));
+       expected_crc = le32_to_cpu(get_unaligned_le32(&payload[length - 4]));
+
+       if (actual_crc != expected_crc) {
+               RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                        "%s:icv CRC mismatch: "
+                        "actual: %08x, expected: %08x\n",
+                        __func__, actual_crc, expected_crc);
+               res = _FAIL;
        }
+
 exit:
        return res;
 }
@@ -829,7 +837,7 @@ static void xor_128(u8 *a, u8 *b, u8 *out)
 {
        int i;
 
-       for (i = 0;i<16; i++)
+       for (i = 0; i < 16; i++)
                out[i] = a[i] ^ b[i];
 }
 
@@ -850,8 +858,7 @@ static void next_key(u8 *key, int round)
 {
        u8 rcon;
        u8 sbox_key[4];
-       u8 rcon_table[12] =
-       {
+       u8 rcon_table[12] = {
                0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
                0x1b, 0x36, 0x36, 0x36
        };
@@ -876,10 +883,8 @@ static void byte_sub(u8 *in, u8 *out)
 {
        int i;
 
-       for (i = 0; i< 16; i++) {
+       for (i = 0; i < 16; i++)
                out[i] = sbox(in[i]);
-       }
-
 }
 
 static void shift_row(u8 *in, u8 *out)
@@ -916,19 +921,19 @@ static void mix_column(u8 *in, u8 *out)
        u8 temp[4];
        u8 tempb[4];
 
-       for (i = 0 ; i<4; i++) {
+       for (i = 0; i < 4; i++) {
                if ((in[i] & 0x80) == 0x80)
-                   add1b[i] = 0x1b;
+                       add1b[i] = 0x1b;
                else
-                   add1b[i] = 0x00;
+                       add1b[i] = 0x00;
        }
 
-       swap_halfs[0] = in[2];    /* Swap halfs */
+       swap_halfs[0] = in[2]; /* Swap halfs */
        swap_halfs[1] = in[3];
        swap_halfs[2] = in[0];
        swap_halfs[3] = in[1];
 
-       rotl[0] = in[3];        /* Rotate left 8 bits */
+       rotl[0] = in[3]; /* Rotate left 8 bits */
        rotl[1] = in[0];
        rotl[2] = in[1];
        rotl[3] = in[2];
@@ -938,11 +943,10 @@ static void mix_column(u8 *in, u8 *out)
        andf7[2] = in[2] & 0x7f;
        andf7[3] = in[3] & 0x7f;
 
-       for (i = 3; i>0; i--) { /* logical shift left 1 bit */
+       for (i = 3; i > 0; i--) { /* logical shift left 1 bit */
                andf7[i] = andf7[i] << 1;
-               if ((andf7[i-1] & 0x80) == 0x80) {
-                   andf7[i] = (andf7[i] | 0x01);
-               }
+               if ((andf7[i - 1] & 0x80) == 0x80)
+                       andf7[i] = (andf7[i] | 0x01);
        }
        andf7[0] = andf7[0] << 1;
        andf7[0] = andf7[0] & 0xfe;
@@ -951,7 +955,7 @@ static void mix_column(u8 *in, u8 *out)
 
        xor_32(in, add1bf7, rotr);
 
-       temp[0] = rotr[0];         /* Rotate right 8 bits */
+       temp[0] = rotr[0]; /* Rotate right 8 bits */
        rotr[0] = rotr[1];
        rotr[1] = rotr[2];
        rotr[2] = rotr[3];
@@ -971,25 +975,26 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
        u8 intermediateb[16];
        u8 round_key[16];
 
-       for (i = 0; i<16; i++) round_key[i] = key[i];
+       for (i = 0; i < 16; i++)
+               round_key[i] = key[i];
 
        for (round = 0; round < 11; round++) {
                if (round == 0) {
-                   xor_128(round_key, data, ciphertext);
-                   next_key(round_key, round);
+                       xor_128(round_key, data, ciphertext);
+                       next_key(round_key, round);
                } else if (round == 10) {
-                   byte_sub(ciphertext, intermediatea);
-                   shift_row(intermediatea, intermediateb);
-                   xor_128(intermediateb, round_key, ciphertext);
+                       byte_sub(ciphertext, intermediatea);
+                       shift_row(intermediatea, intermediateb);
+                       xor_128(intermediateb, round_key, ciphertext);
                } else { /* 1 - 9 */
-                   byte_sub(ciphertext, intermediatea);
-                   shift_row(intermediatea, intermediateb);
-                   mix_column(&intermediateb[0], &intermediatea[0]);
-                   mix_column(&intermediateb[4], &intermediatea[4]);
-                   mix_column(&intermediateb[8], &intermediatea[8]);
-                   mix_column(&intermediateb[12], &intermediatea[12]);
-                   xor_128(intermediatea, round_key, ciphertext);
-                   next_key(round_key, round);
+                       byte_sub(ciphertext, intermediatea);
+                       shift_row(intermediatea, intermediateb);
+                       mix_column(&intermediateb[0], &intermediatea[0]);
+                       mix_column(&intermediateb[4], &intermediatea[4]);
+                       mix_column(&intermediateb[8], &intermediatea[8]);
+                       mix_column(&intermediateb[12], &intermediatea[12]);
+                       xor_128(intermediatea, round_key, ciphertext);
+                       next_key(round_key, round);
                }
        }
 
@@ -1006,9 +1011,9 @@ static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu,
 
        mic_iv[0] = 0x59;
        if (qc_exists && a4_exists)
-               mic_iv[1] = mpdu[30] & 0x0f;    /* QoS_TC           */
+               mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC        */
        if (qc_exists && !a4_exists)
-               mic_iv[1] = mpdu[24] & 0x0f;   /* mute bits 7-4    */
+               mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */
        if (!qc_exists)
                mic_iv[1] = 0x00;
        for (i = 2; i < 8; i++)
@@ -1028,15 +1033,15 @@ static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu)
 {
        mic_header1[0] = (u8)((header_length - 2) / 256);
        mic_header1[1] = (u8)((header_length - 2) % 256);
-       mic_header1[2] = mpdu[0] & 0xcf;    /* Mute CF poll & CF ack bits */
-       mic_header1[3] = mpdu[1] & 0xc7;    /* Mute retry, more data and pwr mgt bits */
-       mic_header1[4] = mpdu[4];       /* A1 */
+       mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */
+       mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */
+       mic_header1[4] = mpdu[4]; /* A1 */
        mic_header1[5] = mpdu[5];
        mic_header1[6] = mpdu[6];
        mic_header1[7] = mpdu[7];
        mic_header1[8] = mpdu[8];
        mic_header1[9] = mpdu[9];
-       mic_header1[10] = mpdu[10];     /* A2 */
+       mic_header1[10] = mpdu[10]; /* A2 */
        mic_header1[11] = mpdu[11];
        mic_header1[12] = mpdu[12];
        mic_header1[13] = mpdu[13];
@@ -1046,7 +1051,7 @@ static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu)
 }
 
 /************************************************/
-       /* construct_mic_header2()                      */
+/* construct_mic_header2()                      */
 /* Builds the last MIC header block from        */
 /* header fields.                               */
 /************************************************/
@@ -1055,9 +1060,10 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists,
 {
        int i;
 
-       for (i = 0; i<16; i++) mic_header2[i]= 0x00;
+       for (i = 0; i < 16; i++)
+               mic_header2[i] = 0x00;
 
-       mic_header2[0] = mpdu[16];    /* A3 */
+       mic_header2[0] = mpdu[16]; /* A3 */
        mic_header2[1] = mpdu[17];
        mic_header2[2] = mpdu[18];
        mic_header2[3] = mpdu[19];
@@ -1068,8 +1074,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists,
        mic_header2[7] = 0x00; /* mpdu[23]; */
 
        if (!qc_exists && a4_exists) {
-               for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i];   /* A4 */
-
+               for (i = 0; i < 6; i++)
+                       mic_header2[8+i] = mpdu[24+i]; /* A4 */
        }
 
        if (qc_exists && !a4_exists) {
@@ -1078,7 +1084,8 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists,
        }
 
        if (qc_exists && a4_exists) {
-               for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i];   /* A4 */
+               for (i = 0; i < 6; i++)
+                       mic_header2[8+i] = mpdu[24+i]; /* A4 */
 
                mic_header2[14] = mpdu[30] & 0x0f;
                mic_header2[15] = mpdu[31] & 0x00;
@@ -1096,19 +1103,21 @@ static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists,
 {
        int i = 0;
 
-       for (i = 0; i<16; i++) ctr_preload[i] = 0x00;
+       for (i = 0; i < 16; i++)
+               ctr_preload[i] = 0x00;
+
        i = 0;
 
-       ctr_preload[0] = 0x01;                                  /* flag */
+       ctr_preload[0] = 0x01; /* flag */
        if (qc_exists && a4_exists)
-               ctr_preload[1] = mpdu[30] & 0x0f;   /* QoC_Control */
+               ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */
        if (qc_exists && !a4_exists)
                ctr_preload[1] = mpdu[24] & 0x0f;
 
        for (i = 2; i < 8; i++)
-               ctr_preload[i] = mpdu[i + 8];                       /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
+               ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */
        for (i = 8; i < 14; i++)
-               ctr_preload[i] =    pn_vector[13 - i];          /* ctr_preload[8:13] = PN[5:0] */
+               ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */
        ctr_preload[14] =  (unsigned char) (c / 256); /* Ctr */
        ctr_preload[15] =  (unsigned char) (c % 256);
 
@@ -1128,8 +1137,8 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out)
 
 static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 {
-       uint    qc_exists, a4_exists, i, j, payload_remainder,
-               num_blocks, payload_index;
+       uint qc_exists, a4_exists, i, j, payload_remainder,
+            num_blocks, payload_index;
        u8 pn_vector[6];
        u8 mic_iv[16];
        u8 mic_header1[16];
@@ -1177,12 +1186,12 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
        } else {
                qc_exists = 0;
        }
-       pn_vector[0]= pframe[hdrlen];
-       pn_vector[1]= pframe[hdrlen+1];
-       pn_vector[2]= pframe[hdrlen+4];
-       pn_vector[3]= pframe[hdrlen+5];
-       pn_vector[4]= pframe[hdrlen+6];
-       pn_vector[5]= pframe[hdrlen+7];
+       pn_vector[0] = pframe[hdrlen];
+       pn_vector[1] = pframe[hdrlen + 1];
+       pn_vector[2] = pframe[hdrlen + 4];
+       pn_vector[3] = pframe[hdrlen + 5];
+       pn_vector[4] = pframe[hdrlen + 6];
+       pn_vector[5] = pframe[hdrlen + 7];
 
        construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector);
 
@@ -1193,7 +1202,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);
@@ -1224,12 +1233,12 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 
        /* Insert MIC into payload */
        for (j = 0; j < 8; j++)
-               pframe[payload_index+j] = mic[j];
+               pframe[payload_index + j] = mic[j];
 
        payload_index = hdrlen + 8;
        for (i = 0; i < num_blocks; i++) {
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
-                                     pframe, pn_vector, i+1);
+                                     pframe, pn_vector, i + 1);
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
                for (j = 0; j < 16; j++)
@@ -1241,15 +1250,15 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
                 * encrypt it and copy the unpadded part back
                 */
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe,
-                                     pn_vector, num_blocks+1);
+                                     pn_vector, num_blocks + 1);
 
                for (j = 0; j < 16; j++)
                        padded_buffer[j] = 0x00;
                for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = pframe[payload_index+j];
+                       padded_buffer[j] = pframe[payload_index + j];
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, padded_buffer, chain_buffer);
-               for (j = 0; j < payload_remainder;j++)
+               for (j = 0; j < payload_remainder; j++)
                        pframe[payload_index++] = chain_buffer[j];
        }
 
@@ -1260,11 +1269,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
        for (j = 0; j < 16; j++)
                padded_buffer[j] = 0x00;
        for (j = 0; j < 8; j++)
-               padded_buffer[j] = pframe[j+hdrlen+8+plen];
+               padded_buffer[j] = pframe[j + hdrlen + 8 + plen];
 
        aes128k128d(key, ctr_preload, aes_out);
        bitwise_xor(aes_out, padded_buffer, chain_buffer);
-       for (j = 0; j < 8;j++)
+       for (j = 0; j < 8; j++)
                pframe[payload_index++] = chain_buffer[j];
 
        return _SUCCESS;
@@ -1272,11 +1281,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 
 int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
                       struct xmit_frame *pxmitframe)
-{      /*  exclude ICV */
+{      /* exclude ICV */
        /* Intermediate Buffers */
        int curfragnum, length;
        u32 prwskeylen;
-       u8 *pframe, *prwskey;   /*  *payload,*iv */
+       u8 *pframe, *prwskey;
        u8 hw_hdr_offset = 0;
        struct sta_info *stainfo;
        struct pkt_attrib *pattrib = &pxmitframe->attrib;
@@ -1304,18 +1313,18 @@ int rtw_aes_encrypt23a(struct rtw_adapter *padapter,
 
        if (!stainfo) {
                RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                        ("rtw_aes_encrypt23a: stainfo == NULL!!!\n"));
+                        "%s: stainfo == NULL!!!\n", __func__);
                DBG_8723A("%s, psta == NUL\n", __func__);
                res = _FAIL;
                goto out;
        }
-       if (!(stainfo->state &_FW_LINKED)) {
+       if (!(stainfo->state & _FW_LINKED)) {
                DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n",
                          __func__, stainfo->state);
                return _FAIL;
        }
        RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                ("rtw_aes_encrypt23a: stainfo!= NULL!!!\n"));
+                "%s: stainfo!= NULL!!!\n", __func__);
 
        if (is_multicast_ether_addr(pattrib->ra))
                prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
@@ -1345,12 +1354,11 @@ out:
        return res;
 }
 
-static int aes_decipher(u8 *key, uint  hdrlen,
-                       u8 *pframe, uint plen)
+static int aes_decipher(u8 *key, uint hdrlen, u8 *pframe, uint plen)
 {
-       static u8       message[MAX_MSG_SIZE];
-       uint    qc_exists, a4_exists, i, j, payload_remainder,
-                       num_blocks, payload_index;
+       static u8 message[MAX_MSG_SIZE];
+       uint qc_exists, a4_exists, i, j, payload_remainder,
+            num_blocks, payload_index;
        int res = _SUCCESS;
        u8 pn_vector[6];
        u8 mic_iv[16];
@@ -1375,16 +1383,16 @@ static int aes_decipher(u8 *key, uint   hdrlen,
 
        /* start to decrypt the payload */
 
-       num_blocks = (plen-8) / 16; /* plen including llc, payload_length and mic) */
+       num_blocks = (plen - 8) / 16; /* plen including llc, payload_length and mic) */
 
-       payload_remainder = (plen-8) % 16;
+       payload_remainder = (plen - 8) % 16;
 
        pn_vector[0]  = pframe[hdrlen];
-       pn_vector[1]  = pframe[hdrlen+1];
-       pn_vector[2]  = pframe[hdrlen+4];
-       pn_vector[3]  = pframe[hdrlen+5];
-       pn_vector[4]  = pframe[hdrlen+6];
-       pn_vector[5]  = pframe[hdrlen+7];
+       pn_vector[1]  = pframe[hdrlen + 1];
+       pn_vector[2]  = pframe[hdrlen + 4];
+       pn_vector[3]  = pframe[hdrlen + 5];
+       pn_vector[4]  = pframe[hdrlen + 6];
+       pn_vector[5]  = pframe[hdrlen + 7];
 
        if ((hdrlen == sizeof(struct ieee80211_hdr_3addr) ||
            (hdrlen == sizeof(struct ieee80211_qos_hdr))))
@@ -1413,13 +1421,13 @@ static int aes_decipher(u8 *key, uint   hdrlen,
                qc_exists = 0;
        }
 
-       /*  now, decrypt pframe with hdrlen offset and plen long */
+       /* now, decrypt pframe with hdrlen offset and plen long */
 
        payload_index = hdrlen + 8; /*  8 is for extiv */
 
        for (i = 0; i < num_blocks; i++) {
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
-                                     pframe, pn_vector, i+1);
+                                     pframe, pn_vector, i + 1);
 
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);
@@ -1433,12 +1441,12 @@ static int aes_decipher(u8 *key, uint   hdrlen,
                 * encrypt it and copy the unpadded part back
                 */
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe,
-                                     pn_vector, num_blocks+1);
+                                     pn_vector, num_blocks + 1);
 
                for (j = 0; j < 16; j++)
                        padded_buffer[j] = 0x00;
                for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = pframe[payload_index+j];
+                       padded_buffer[j] = pframe[payload_index + j];
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, padded_buffer, chain_buffer);
                for (j = 0; j < payload_remainder; j++)
@@ -1446,27 +1454,27 @@ static int aes_decipher(u8 *key, uint   hdrlen,
        }
 
        /* start to calculate the mic */
-       if ((hdrlen +plen+8) <= MAX_MSG_SIZE)
-               memcpy(message, pframe, (hdrlen+plen+8)); /* 8 is for ext iv len */
+       if ((hdrlen + plen + 8) <= MAX_MSG_SIZE)
+               memcpy(message, pframe, (hdrlen + plen + 8)); /* 8 is for ext iv len */
 
        pn_vector[0] = pframe[hdrlen];
-       pn_vector[1] = pframe[hdrlen+1];
-       pn_vector[2] = pframe[hdrlen+4];
-       pn_vector[3] = pframe[hdrlen+5];
-       pn_vector[4] = pframe[hdrlen+6];
-       pn_vector[5] = pframe[hdrlen+7];
+       pn_vector[1] = pframe[hdrlen + 1];
+       pn_vector[2] = pframe[hdrlen + 4];
+       pn_vector[3] = pframe[hdrlen + 5];
+       pn_vector[4] = pframe[hdrlen + 6];
+       pn_vector[5] = pframe[hdrlen + 7];
 
        construct_mic_iv(mic_iv, qc_exists, a4_exists, message,
-                        plen-8, pn_vector);
+                        plen - 8, pn_vector);
 
        construct_mic_header1(mic_header1, hdrlen, message);
        construct_mic_header2(mic_header2, message, a4_exists, qc_exists);
 
-       payload_remainder = (plen-8) % 16;
-       num_blocks = (plen-8) / 16;
+       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);
@@ -1487,7 +1495,7 @@ static int aes_decipher(u8 *key, uint     hdrlen,
                for (j = 0; j < 16; j++)
                        padded_buffer[j] = 0x00;
                for (j = 0; j < payload_remainder; j++)
-                   padded_buffer[j] = message[payload_index++];
+                       padded_buffer[j] = message[payload_index++];
                bitwise_xor(aes_out, padded_buffer, chain_buffer);
                aes128k128d(key, chain_buffer, aes_out);
        }
@@ -1497,12 +1505,12 @@ static int aes_decipher(u8 *key, uint   hdrlen,
 
        /* Insert MIC into payload */
        for (j = 0; j < 8; j++)
-               message[payload_index+j] = mic[j];
+               message[payload_index + j] = mic[j];
 
        payload_index = hdrlen + 8;
-       for (i = 0; i< num_blocks; i++) {
+       for (i = 0; i < num_blocks; i++) {
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
-                                     message, pn_vector, i+1);
+                                     message, pn_vector, i + 1);
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, &message[payload_index], chain_buffer);
                for (j = 0; j < 16; j++)
@@ -1514,12 +1522,12 @@ static int aes_decipher(u8 *key, uint   hdrlen,
                 * encrypt it and copy the unpadded part back
                 */
                construct_ctr_preload(ctr_preload, a4_exists, qc_exists,
-                                     message, pn_vector, num_blocks+1);
+                                     message, pn_vector, num_blocks + 1);
 
                for (j = 0; j < 16; j++)
-                        padded_buffer[j] = 0x00;
+                       padded_buffer[j] = 0x00;
                for (j = 0; j < payload_remainder; j++)
-                       padded_buffer[j] = message[payload_index+j];
+                       padded_buffer[j] = message[payload_index + j];
                aes128k128d(key, ctr_preload, aes_out);
                bitwise_xor(aes_out, padded_buffer, chain_buffer);
                for (j = 0; j < payload_remainder; j++)
@@ -1533,7 +1541,7 @@ static int aes_decipher(u8 *key, uint     hdrlen,
        for (j = 0; j < 16; j++)
                padded_buffer[j] = 0x00;
        for (j = 0; j < 8; j++)
-               padded_buffer[j] = message[j+hdrlen+8+plen-8];
+               padded_buffer[j] = message[j + hdrlen + 8 + plen - 8];
 
        aes128k128d(key, ctr_preload, aes_out);
        bitwise_xor(aes_out, padded_buffer, chain_buffer);
@@ -1542,12 +1550,16 @@ static int aes_decipher(u8 *key, uint   hdrlen,
 
        /* compare the mic */
        for (i = 0; i < 8; i++) {
-               if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) {
+               if (pframe[hdrlen + 8 + plen - 8 + i] != message[hdrlen + 8 + plen - 8 + i]) {
                        RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                                ("aes_decipher:mic check error mic[%d]: pframe(%x) != message(%x)\n",
-                                i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]));
-                       DBG_8723A("aes_decipher:mic check error mic[%d]: pframe(%x) != message(%x)\n",
-                                 i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]);
+                                "%s:mic check error mic[%d]: pframe(%x) != message(%x)\n",
+                                __func__, i,
+                                pframe[hdrlen + 8 + plen - 8 + i],
+                                message[hdrlen + 8 + plen - 8 + i]);
+                       DBG_8723A("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n",
+                                 __func__, i,
+                                 pframe[hdrlen + 8 + plen - 8 + i],
+                                 message[hdrlen + 8 + plen - 8 + i]);
                        res = _FAIL;
                }
        }
@@ -1562,7 +1574,7 @@ int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct sk_buff *skb = precvframe->pkt;
        int length;
-       u8 *pframe, *prwskey;   /*  *payload,*iv */
+       u8 *pframe, *prwskey;
        int res = _SUCCESS;
 
        pframe = skb->data;
@@ -1573,17 +1585,18 @@ int rtw_aes_decrypt23a(struct rtw_adapter *padapter,
        stainfo = rtw_get_stainfo23a(&padapter->stapriv, &prxattrib->ta[0]);
        if (!stainfo) {
                RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                        ("rtw_aes_encrypt23a: stainfo == NULL!!!\n"));
+                        "%s: stainfo == NULL!!!\n", __func__);
                res = _FAIL;
                goto exit;
        }
 
        RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                ("rtw_aes_decrypt23a: stainfo!= NULL!!!\n"));
+                "%s: stainfo!= NULL!!!\n", __func__);
 
        if (is_multicast_ether_addr(prxattrib->ra)) {
-               /* in concurrent we should use sw decrypt in group key,
-                  so we remove this message */
+               /* in concurrent we should use sw decrypt in
+                * group key, so we remove this message
+                */
                if (!psecuritypriv->binstallGrpkey) {
                        res = _FAIL;
                        DBG_8723A("%s:rx bc/mc packets, but didn't install "
@@ -1613,9 +1626,10 @@ void rtw_use_tkipkey_handler23a(void *FunctionContext)
 {
        struct rtw_adapter *padapter = (struct rtw_adapter *)FunctionContext;
 
-       RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler23a ^^^\n"));
+       RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
+                "^^^%s ^^^\n", __func__);
        padapter->securitypriv.busetkipkey = 1;
        RT_TRACE(_module_rtl871x_security_c_, _drv_err_,
-                ("^^^rtw_use_tkipkey_handler23a padapter->securitypriv.busetkipkey =%d^^^\n",
-                padapter->securitypriv.busetkipkey));
+                "^^^%s padapter->securitypriv.busetkipkey =%d^^^\n",
+                __func__, padapter->securitypriv.busetkipkey);
 }
index d17998da860030d1bbce436a605ab0b33d8b29c7..b06bff74502ab8ec8e6c7303e51f95c7172b149a 100644 (file)
@@ -136,10 +136,10 @@ rtw_alloc_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr, gfp_t gfp)
        index = wifi_mac_hash(hwaddr);
 
        RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
-                ("rtw_alloc_stainfo23a: index  = %x", index));
+                "rtw_alloc_stainfo23a: index  = %x\n", index);
        if (index >= NUM_STA) {
                RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
-                        ("ERROR => rtw_alloc_stainfo23a: index >= NUM_STA"));
+                        "ERROR => rtw_alloc_stainfo23a: index >= NUM_STA\n");
                psta = NULL;
                goto exit;
        }
@@ -160,8 +160,8 @@ rtw_alloc_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr, gfp_t gfp)
                        &wRxSeqInitialValue, 2);
 
        RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
-                ("alloc number_%d stainfo  with hwaddr = %pM\n",
-                pstapriv->asoc_sta_count, hwaddr));
+                "alloc number_%d stainfo  with hwaddr = %pM\n",
+                pstapriv->asoc_sta_count, hwaddr);
 
        init_addba_retry_timer23a(psta);
 
@@ -249,10 +249,8 @@ int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta)
 
        list_del_init(&psta->hash_list);
        RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
-               ("\n free number_%d stainfo  with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
-                       pstapriv->asoc_sta_count, psta->hwaddr[0],
-                       psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3],
-                       psta->hwaddr[4], psta->hwaddr[5]));
+                "free number_%d stainfo  with hwaddr = %pM\n",
+                pstapriv->asoc_sta_count, psta->hwaddr);
        pstapriv->asoc_sta_count--;
 
        /*  re-init sta_info; 20061114  will be init in alloc_stainfo */
@@ -397,7 +395,7 @@ int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter)
        if (psta == NULL) {
                res = _FAIL;
                RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
-                        ("rtw_alloc_stainfo23a fail"));
+                        "rtw_alloc_stainfo23a fail\n");
                return res;
        }
        /*  default broadcast & multicast use macid 1 */
index 69d9e0f17fd8390544409fd2a1dfa3ed9bbed2aa..5280338aa387639780d512abc30cb2b76cb08da8 100644 (file)
@@ -876,9 +876,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
        }
 
        if (!ether_addr_equal(cur_network->network.MacAddress, mgmt->bssid)) {
-               DBG_8723A("%s: linked but recv other bssid bcn"
-                         MAC_FMT MAC_FMT "\n", __func__, MAC_ARG(mgmt->bssid),
-                         MAC_ARG(cur_network->network.MacAddress));
+               DBG_8723A("%s: linked but recv other bssid bcn %pM %pM\n",
+                         __func__, mgmt->bssid,
+                         cur_network->network.MacAddress);
                return _FAIL;
        }
 
@@ -926,10 +926,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
        }
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d "
-                 "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__,
-                 ssid, ssid_len, cur_network->network.Ssid.ssid,
-                 cur_network->network.Ssid.ssid_len));
+                "%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d cur_network->network.Ssid.Ssid:%s len:%d\n",
+                __func__, ssid, ssid_len, cur_network->network.Ssid.ssid,
+                cur_network->network.Ssid.ssid_len);
 
        if (ssid_len != cur_network->network.Ssid.ssid_len || ssid_len > 32 ||
            (ssid_len &&
@@ -947,8 +946,8 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
                privacy = 0;
 
        RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                ("%s(): cur_network->network.Privacy is %d, bssid.Privacy "
-                 "is %d\n", __func__, cur_network->network.Privacy, privacy));
+                "%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n",
+                __func__, cur_network->network.Privacy, privacy);
        if (cur_network->network.Privacy != privacy) {
                DBG_8723A("%s(), privacy is not match return FAIL\n", __func__);
                goto _mismatch;
@@ -962,10 +961,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
                                                 &pairwise_cipher, &is_8021x);
                        if (r == _SUCCESS)
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("%s pnetwork->pairwise_cipher: %d, "
-                                         "pnetwork->group_cipher: %d, is_802x "
-                                         ": %d\n", __func__, pairwise_cipher,
-                                         group_cipher, is_8021x));
+                                        "%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher: %d, is_802x : %d\n",
+                                        __func__, pairwise_cipher,
+                                        group_cipher, is_8021x);
                        }
        } else {
                p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
@@ -977,10 +975,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
                                                &pairwise_cipher, &is_8021x);
                        if (r == _SUCCESS)
                                RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_,
-                                        ("%s pnetwork->pairwise_cipher: %d, "
-                                         "group_cipher is %d, is_8021x is "
-                                         "%d\n", __func__, pairwise_cipher,
-                                         group_cipher, is_8021x));
+                                        "%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n",
+                                        __func__, pairwise_cipher,
+                                        group_cipher, is_8021x);
                } else {
                        if (privacy)
                                crypto = ENCRYP_PROTOCOL_WEP;
@@ -996,8 +993,8 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter,
 
        if (crypto == ENCRYP_PROTOCOL_WPA || crypto == ENCRYP_PROTOCOL_WPA2) {
                RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,
-                        ("%s cur_network->group_cipher is %d: %d\n", __func__,
-                         cur_network->BcnInfo.group_cipher, group_cipher));
+                        "%s cur_network->group_cipher is %d: %d\n", __func__,
+                        cur_network->BcnInfo.group_cipher, group_cipher);
                if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher ||
                    group_cipher != cur_network->BcnInfo.group_cipher) {
                        DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher "
index 1c82dffcf59610d0b78cf6b9f9882a7c15471f74..a4b6bb6c79a969b8483ee3154ef54228e7a4fbf9 100644 (file)
@@ -463,9 +463,7 @@ static int update_attrib(struct rtw_adapter *padapter,
                                        /*  67 : UDP BOOTP server */
                                        RT_TRACE(_module_rtl871x_xmit_c_,
                                                 _drv_err_,
-                                                ("======================"
-                                                 "update_attrib: get DHCP "
-                                                 "Packet\n"));
+                                                "======================update_attrib: get DHCP Packet\n");
                                        pattrib->dhcp_pkt = 1;
                                }
                        }
@@ -493,8 +491,8 @@ static int update_attrib(struct rtw_adapter *padapter,
                psta = rtw_get_stainfo23a(pstapriv, pattrib->ra);
                if (psta == NULL) { /*  if we cannot get psta => drrp the pkt */
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_,
-                                ("\nupdate_attrib => get sta_info fail, ra:"
-                                 MAC_FMT"\n", MAC_ARG(pattrib->ra)));
+                                "update_attrib => get sta_info fail, ra:%pM\n",
+                                pattrib->ra);
                        res = _FAIL;
                        goto exit;
                } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) &&
@@ -511,8 +509,8 @@ static int update_attrib(struct rtw_adapter *padapter,
        } else {
                /*  if we cannot get psta => drop the pkt */
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_,
-                        ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT
-                         "\n", MAC_ARG(pattrib->ra)));
+                        "update_attrib => get sta_info fail, ra:%pM\n",
+                        pattrib->ra);
                res = _FAIL;
                goto exit;
        }
@@ -544,16 +542,15 @@ static int update_attrib(struct rtw_adapter *padapter,
 
        if (psta->ieee8021x_blocked == true) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("\n psta->ieee8021x_blocked == true\n"));
+                        "psta->ieee8021x_blocked == true\n");
 
                pattrib->encrypt = 0;
 
                if ((pattrib->ether_type != ETH_P_PAE) &&
                    !check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("\npsta->ieee8021x_blocked == true,  "
-                                 "pattrib->ether_type(%.4x) != 0x888e\n",
-                                 pattrib->ether_type));
+                                "psta->ieee8021x_blocked == true,  pattrib->ether_type(%.4x) != 0x888e\n",
+                                pattrib->ether_type);
                        res = _FAIL;
                        goto exit;
                }
@@ -594,9 +591,8 @@ static int update_attrib(struct rtw_adapter *padapter,
 
                if (!padapter->securitypriv.busetkipkey) {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("\npadapter->securitypriv.busetkip"
-                                 "key(%d) == false drop packet\n",
-                                 padapter->securitypriv.busetkipkey));
+                                "padapter->securitypriv.busetkipkey(%d) == false drop packet\n",
+                                padapter->securitypriv.busetkipkey);
                        res = _FAIL;
                        goto exit;
                }
@@ -604,8 +600,8 @@ static int update_attrib(struct rtw_adapter *padapter,
                break;
        case WLAN_CIPHER_SUITE_CCMP:
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                        ("pattrib->encrypt =%d (WLAN_CIPHER_SUITE_CCMP)\n",
-                         pattrib->encrypt));
+                        "pattrib->encrypt =%d (WLAN_CIPHER_SUITE_CCMP)\n",
+                        pattrib->encrypt);
                pattrib->iv_len = IEEE80211_CCMP_HDR_LEN;
                pattrib->icv_len = IEEE80211_CCMP_MIC_LEN;
                break;
@@ -617,17 +613,17 @@ static int update_attrib(struct rtw_adapter *padapter,
        }
 
        RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                ("update_attrib: encrypt =%d\n", pattrib->encrypt));
+                "update_attrib: encrypt =%d\n", pattrib->encrypt);
 
        if (pattrib->encrypt && !psecuritypriv->hw_decrypted) {
                pattrib->bswenc = true;
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("update_attrib: encrypt =%d bswenc = true\n",
-                         pattrib->encrypt));
+                        "update_attrib: encrypt =%d bswenc = true\n",
+                        pattrib->encrypt);
        } else {
                pattrib->bswenc = false;
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                        ("update_attrib: bswenc = false\n"));
+                        "update_attrib: bswenc = false\n");
        }
        update_attrib_phy_info(pattrib, psta);
 
@@ -726,20 +722,18 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
                             curfragnum++) {
                                payload = PTR_ALIGN(payload, 4);
                                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                        ("=== curfragnum =%d, pframe = 0x%.2x, "
-                                         "0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x"
-                                         "%.2x, 0x%.2x, 0x%.2x,!!!\n",
-                                         curfragnum, *payload, *(payload + 1),
-                                         *(payload + 2), *(payload + 3),
-                                         *(payload + 4), *(payload + 5),
-                                         *(payload + 6), *(payload + 7)));
+                                        "=== curfragnum =%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n",
+                                        curfragnum, *payload, *(payload + 1),
+                                        *(payload + 2), *(payload + 3),
+                                        *(payload + 4), *(payload + 5),
+                                        *(payload + 6), *(payload + 7));
 
                                payload = payload + pattrib->hdrlen +
                                        pattrib->iv_len;
                                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                        ("curfragnum =%d pattrib->hdrlen =%d "
-                                         "pattrib->iv_len =%d", curfragnum,
-                                         pattrib->hdrlen, pattrib->iv_len));
+                                        "curfragnum =%d pattrib->hdrlen =%d pattrib->iv_len =%d\n",
+                                        curfragnum,
+                                        pattrib->hdrlen, pattrib->iv_len);
                                if ((curfragnum + 1) == pattrib->nr_frags) {
                                        length = pattrib->last_txcmdsz -
                                                pattrib->hdrlen -
@@ -761,25 +755,21 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
                                                pattrib->icv_len;
                                        RT_TRACE(_module_rtl871x_xmit_c_,
                                                 _drv_err_,
-                                                ("curfragnum =%d length =%d "
-                                                 "pattrib->icv_len =%d",
-                                                 curfragnum, length,
-                                                 pattrib->icv_len));
+                                                "curfragnum =%d length =%d pattrib->icv_len =%d\n",
+                                                curfragnum, length,
+                                                pattrib->icv_len);
                                }
                        }
                        rtw_secgetmic23a(&micdata, &mic[0]);
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("xmitframe_addmic: before add mic code!!\n"));
+                                "xmitframe_addmic: before add mic code!!\n");
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("xmitframe_addmic: pattrib->last_txcmdsz ="
-                                 "%d!!!\n", pattrib->last_txcmdsz));
+                                "xmitframe_addmic: pattrib->last_txcmdsz =%d!!!\n",
+                                pattrib->last_txcmdsz);
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("xmitframe_addmic: mic[0]= 0x%.2x , mic[1]="
-                                 "0x%.2x , mic[2]= 0x%.2x , mic[3]= 0x%.2x\n"
-                                 "mic[4]= 0x%.2x , mic[5]= 0x%.2x , mic[6]= 0x%.2x "
-                                 ", mic[7]= 0x%.2x !!!!\n", mic[0], mic[1],
-                                 mic[2], mic[3], mic[4], mic[5], mic[6],
-                                 mic[7]));
+                                "xmitframe_addmic: mic[0]= 0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x , mic[3]= 0x%.2x\nmic[4]= 0x%.2x , mic[5]= 0x%.2x , mic[6]= 0x%.2x , mic[7]= 0x%.2x !!!!\n",
+                                mic[0], mic[1], mic[2], mic[3],
+                                mic[4], mic[5], mic[6], mic[7]);
                        /* add mic code  and add the mic code length
                           in last_txcmdsz */
 
@@ -787,25 +777,24 @@ static int xmitframe_addmic(struct rtw_adapter *padapter,
                        pattrib->last_txcmdsz += 8;
 
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                                ("\n ======== last pkt ========\n"));
+                                "======== last pkt ========\n");
                        payload = payload - pattrib->last_txcmdsz + 8;
                        for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz;
-                            curfragnum = curfragnum + 8)
+                            curfragnum = curfragnum + 8) {
                                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                                        (" %.2x,  %.2x,  %.2x,  %.2x,  %.2x, "
-                                         " %.2x,  %.2x,  %.2x ",
-                                         *(payload + curfragnum),
-                                         *(payload + curfragnum + 1),
-                                         *(payload + curfragnum + 2),
-                                         *(payload + curfragnum + 3),
-                                         *(payload + curfragnum + 4),
-                                         *(payload + curfragnum + 5),
-                                         *(payload + curfragnum + 6),
-                                         *(payload + curfragnum + 7)));
-                       } else {
-                               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                        ("xmitframe_addmic: rtw_get_stainfo23a =="
-                                         "NULL!!!\n"));
+                                        "%.2x,  %.2x,  %.2x,  %.2x,  %.2x,  %.2x,  %.2x,  %.2x\n",
+                                        *(payload + curfragnum),
+                                        *(payload + curfragnum + 1),
+                                        *(payload + curfragnum + 2),
+                                        *(payload + curfragnum + 3),
+                                        *(payload + curfragnum + 4),
+                                        *(payload + curfragnum + 5),
+                                        *(payload + curfragnum + 6),
+                                        *(payload + curfragnum + 7));
+                       }
+               } else {
+                       RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
+                                "xmitframe_addmic: rtw_get_stainfo23a ==NULL!!!\n");
                }
        }
 
@@ -821,7 +810,7 @@ static int xmitframe_swencrypt(struct rtw_adapter *padapter,
        if (pattrib->bswenc) {
                /* DBG_8723A("start xmitframe_swencrypt\n"); */
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_,
-                        ("### xmitframe_swencrypt\n"));
+                        "### xmitframe_swencrypt\n");
                switch (pattrib->encrypt) {
                case WLAN_CIPHER_SUITE_WEP40:
                case WLAN_CIPHER_SUITE_WEP104:
@@ -839,7 +828,7 @@ static int xmitframe_swencrypt(struct rtw_adapter *padapter,
 
        } else {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_,
-                        ("### xmitframe_hwencrypt\n"));
+                        "### xmitframe_hwencrypt\n");
        }
 
        return _SUCCESS;
@@ -916,7 +905,9 @@ static int rtw_make_wlanhdr(struct rtw_adapter *padapter, u8 *hdr,
                                qos_option = true;
                }
                else {
-                       RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
+                       RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
+                                "fw_state:%x is not allowed to xmit frame\n",
+                                get_fwstate(pmlmepriv));
                        res = _FAIL;
                        goto exit;
                }
@@ -1117,7 +1108,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 
        if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("%s: rtw_make_wlanhdr fail; drop pkt\n", __func__));
+                        "%s: rtw_make_wlanhdr fail; drop pkt\n", __func__);
                res = _FAIL;
                goto exit;
        }
@@ -1172,11 +1163,10 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
                        memcpy(pframe, pattrib->iv, pattrib->iv_len);
 
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_,
-                                ("rtw_xmiaframe_coalesce23a: keyid =%d pattrib"
-                                 "->iv[3]=%.2x pframe =%.2x %.2x %.2x %.2x\n",
-                                 padapter->securitypriv.dot11PrivacyKeyIndex,
-                                 pattrib->iv[3], *pframe, *(pframe+1),
-                                 *(pframe+2), *(pframe+3)));
+                                "rtw_xmiaframe_coalesce23a: keyid =%d pattrib->iv[3]=%.2x pframe =%.2x %.2x %.2x %.2x\n",
+                                padapter->securitypriv.dot11PrivacyKeyIndex,
+                                pattrib->iv[3], *pframe, *(pframe+1),
+                                *(pframe+2), *(pframe+3));
                        pframe += pattrib->iv_len;
                        mpdu_len -= pattrib->iv_len;
                }
@@ -1223,8 +1213,8 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
                        break;
                } else {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("%s: There're still something in packet!\n",
-                                 __func__));
+                                "%s: There're still something in packet!\n",
+                                __func__);
                }
                hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS);
 
@@ -1234,7 +1224,7 @@ int rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb,
 
        if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"));
+                        "xmitframe_addmic(padapter, pxmitframe) == _FAIL\n");
                DBG_8723A("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n");
                res = _FAIL;
                goto exit;
@@ -1462,8 +1452,8 @@ static struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)
 
        if (list_empty(&pfree_xmit_queue->queue)) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                        ("rtw_alloc_xmitframe:%d\n",
-                         pxmitpriv->free_xmitframe_cnt));
+                        "rtw_alloc_xmitframe:%d\n",
+                        pxmitpriv->free_xmitframe_cnt);
                pxframe =  NULL;
        } else {
                phead = get_list_head(pfree_xmit_queue);
@@ -1475,8 +1465,8 @@ static struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)
                list_del_init(&pxframe->list);
                pxmitpriv->free_xmitframe_cnt--;
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                        ("rtw_alloc_xmitframe():free_xmitframe_cnt =%d\n",
-                         pxmitpriv->free_xmitframe_cnt));
+                        "rtw_alloc_xmitframe():free_xmitframe_cnt =%d\n",
+                        pxmitpriv->free_xmitframe_cnt);
        }
 
        spin_unlock_bh(&pfree_xmit_queue->lock);
@@ -1495,7 +1485,9 @@ struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv)
        spin_lock_bh(&queue->lock);
 
        if (list_empty(&queue->queue)) {
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe23a_ext:%d\n", pxmitpriv->free_xframe_ext_cnt));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_alloc_xmitframe23a_ext:%d\n",
+                        pxmitpriv->free_xframe_ext_cnt);
                pxframe =  NULL;
        } else {
                phead = get_list_head(queue);
@@ -1504,7 +1496,9 @@ struct xmit_frame *rtw_alloc_xmitframe23a_ext(struct xmit_priv *pxmitpriv)
 
                list_del_init(&pxframe->list);
                pxmitpriv->free_xframe_ext_cnt--;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe23a_ext():free_xmitframe_cnt =%d\n", pxmitpriv->free_xframe_ext_cnt));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_alloc_xmitframe23a_ext():free_xmitframe_cnt =%d\n",
+                        pxmitpriv->free_xframe_ext_cnt);
        }
 
        spin_unlock_bh(&queue->lock);
@@ -1521,7 +1515,8 @@ s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitf
        struct sk_buff *pndis_pkt = NULL;
 
        if (pxmitframe == NULL) {
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe23a():pxmitframe == NULL!!!!!!!!!!\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
+                        "====== rtw_free_xmitframe23a():pxmitframe == NULL!!!!!!!!!!\n");
                goto exit;
        }
 
@@ -1543,10 +1538,14 @@ s32 rtw_free_xmitframe23a(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitf
        list_add_tail(&pxmitframe->list, get_list_head(queue));
        if (pxmitframe->ext_tag == 0) {
                pxmitpriv->free_xmitframe_cnt++;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe23a():free_xmitframe_cnt =%d\n", pxmitpriv->free_xmitframe_cnt));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_,
+                        "rtw_free_xmitframe23a():free_xmitframe_cnt =%d\n",
+                        pxmitpriv->free_xmitframe_cnt);
        } else if (pxmitframe->ext_tag == 1) {
                pxmitpriv->free_xframe_ext_cnt++;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe23a():free_xframe_ext_cnt =%d\n", pxmitpriv->free_xframe_ext_cnt));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_,
+                        "rtw_free_xmitframe23a():free_xframe_ext_cnt =%d\n",
+                        pxmitpriv->free_xframe_ext_cnt);
        }
 
        spin_unlock_bh(&queue->lock);
@@ -1585,8 +1584,7 @@ int rtw_xmitframe_enqueue23a(struct rtw_adapter *padapter,
 {
        if (rtw_xmit23a_classifier(padapter, pxmitframe) == _FAIL) {
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("rtw_xmitframe_enqueue23a: drop xmit pkt for "
-                         "classifier fail\n"));
+                        "rtw_xmitframe_enqueue23a: drop xmit pkt for classifier fail\n");
                return _FAIL;
        }
 
@@ -1675,26 +1673,30 @@ struct tx_servq *rtw_get_sta_pending23a(struct rtw_adapter *padapter, struct sta
        case 2:
                ptxservq = &psta->sta_xmitpriv.bk_q;
                *(ac) = 3;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending23a : BK\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_get_sta_pending23a : BK\n");
                break;
        case 4:
        case 5:
                ptxservq = &psta->sta_xmitpriv.vi_q;
                *(ac) = 1;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending23a : VI\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_get_sta_pending23a : VI\n");
                break;
        case 6:
        case 7:
                ptxservq = &psta->sta_xmitpriv.vo_q;
                *(ac) = 0;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending23a : VO\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_get_sta_pending23a : VO\n");
                break;
        case 0:
        case 3:
        default:
                ptxservq = &psta->sta_xmitpriv.be_q;
                *(ac) = 2;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending23a : BE\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "rtw_get_sta_pending23a : BE\n");
                break;
        }
        return ptxservq;
@@ -1725,7 +1727,7 @@ int rtw_xmit23a_classifier(struct rtw_adapter *padapter,
                res = _FAIL;
                DBG_8723A("rtw_xmit23a_classifier: psta == NULL\n");
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                        ("rtw_xmit23a_classifier: psta == NULL\n"));
+                        "rtw_xmit23a_classifier: psta == NULL\n");
                goto exit;
        }
        if (!(psta->state & _FW_LINKED)) {
@@ -1876,14 +1878,15 @@ int rtw_xmit23a(struct rtw_adapter *padapter, struct sk_buff *skb)
 
        if (pxmitframe == NULL) {
                RT_TRACE(_module_xmit_osdep_c_, _drv_err_,
-                        ("rtw_xmit23a: no more pxmitframe\n"));
+                        "rtw_xmit23a: no more pxmitframe\n");
                return -1;
        }
 
        res = update_attrib(padapter, skb, &pxmitframe->attrib);
 
        if (res == _FAIL) {
-               RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit23a: update attrib fail\n"));
+               RT_TRACE(_module_xmit_osdep_c_, _drv_err_,
+                        "rtw_xmit23a: update attrib fail\n");
                rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
                return -1;
        }
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..ae090ab115856dc7d5e893369f9efa90be2030c7 100644 (file)
@@ -59,17 +59,15 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
                PwrCfgCmd = PwrSeqCmd[AryIdx];
 
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("HalPwrSeqCmdParsing23a: offset(%#x) cut_msk(%#x) "
-                         "fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) "
-                         "msk(%#x) value(%#x)\n",
-                         GET_PWR_CFG_OFFSET(PwrCfgCmd),
-                         GET_PWR_CFG_CUT_MASK(PwrCfgCmd),
-                         GET_PWR_CFG_FAB_MASK(PwrCfgCmd),
-                         GET_PWR_CFG_INTF_MASK(PwrCfgCmd),
-                         GET_PWR_CFG_BASE(PwrCfgCmd),
-                         GET_PWR_CFG_CMD(PwrCfgCmd),
-                         GET_PWR_CFG_MASK(PwrCfgCmd),
-                         GET_PWR_CFG_VALUE(PwrCfgCmd)));
+                        "HalPwrSeqCmdParsing23a: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n",
+                        GET_PWR_CFG_OFFSET(PwrCfgCmd),
+                        GET_PWR_CFG_CUT_MASK(PwrCfgCmd),
+                        GET_PWR_CFG_FAB_MASK(PwrCfgCmd),
+                        GET_PWR_CFG_INTF_MASK(PwrCfgCmd),
+                        GET_PWR_CFG_BASE(PwrCfgCmd),
+                        GET_PWR_CFG_CMD(PwrCfgCmd),
+                        GET_PWR_CFG_MASK(PwrCfgCmd),
+                        GET_PWR_CFG_VALUE(PwrCfgCmd));
 
                /* 2 Only Handle the command whose FAB, CUT, and Interface are
                   matched */
@@ -79,14 +77,12 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
                        switch (GET_PWR_CFG_CMD(PwrCfgCmd)) {
                        case PWR_CMD_READ:
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "PWR_CMD_READ\n"));
+                                        "HalPwrSeqCmdParsing23a: PWR_CMD_READ\n");
                                break;
 
                        case PWR_CMD_WRITE:
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "PWR_CMD_WRITE\n"));
+                                        "HalPwrSeqCmdParsing23a: PWR_CMD_WRITE\n");
                                offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
 
                                /*  Read the value from system register */
@@ -102,8 +98,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
 
                        case PWR_CMD_POLLING:
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "PWR_CMD_POLLING\n"));
+                                        "HalPwrSeqCmdParsing23a: PWR_CMD_POLLING\n");
 
                                bPollingBit = false;
                                offset = GET_PWR_CFG_OFFSET(PwrCfgCmd);
@@ -131,8 +126,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
 
                        case PWR_CMD_DELAY:
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "PWR_CMD_DELAY\n"));
+                                        "HalPwrSeqCmdParsing23a: PWR_CMD_DELAY\n");
                                if (GET_PWR_CFG_VALUE(PwrCfgCmd) ==
                                    PWRSEQ_DELAY_US)
                                        udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd));
@@ -145,15 +139,12 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
                                /*  When this command is parsed, end
                                    the process */
                                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "PWR_CMD_END\n"));
+                                        "HalPwrSeqCmdParsing23a: PWR_CMD_END\n");
                                return true;
-                               break;
 
                        default:
                                RT_TRACE(_module_hal_init_c_, _drv_err_,
-                                        ("HalPwrSeqCmdParsing23a: "
-                                         "Unknown CMD!!\n"));
+                                        "HalPwrSeqCmdParsing23a: Unknown CMD!!\n");
                                break;
                        }
                }
index bf4cae20bd1273cb6673818f47af586dea685774..530db57e8842cc5f85b9bff1f7dd30ce77b57352 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)
@@ -437,9 +395,6 @@ rtl8723a_set_ampdu_min_space(struct rtw_adapter *padapter, u8 MinSpacingToSet)
                if (MinSpacingToSet < SecMinSpace)
                        MinSpacingToSet = SecMinSpace;
 
-               /* RT_TRACE(COMP_MLME, DBG_LOUD,
-                  ("Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
-                  padapter->MgntInfo.MinSpaceCfg)); */
                MinSpacingToSet |=
                        rtl8723au_read8(padapter, REG_AMPDU_MIN_SPACE) & 0xf8;
                rtl8723au_write8(padapter, REG_AMPDU_MIN_SPACE,
@@ -479,9 +434,6 @@ void rtl8723a_set_ampdu_factor(struct rtw_adapter *padapter, u8 FactorToSet)
                        rtl8723au_write8(padapter, REG_AGGLEN_LMT + index,
                                         pRegToSet[index]);
                }
-
-               /* RT_TRACE(COMP_MLME, DBG_LOUD,
-                  ("Set HW_VAR_AMPDU_FACTOR: %#x\n", FactorToSet)); */
        }
 }
 
@@ -666,14 +618,8 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex)
                /*  write content 0 is equall to mark invalid */
                /* delay_ms(40); */
                rtl8723au_write32(padapter, WCAMI, ulContent);
-               /* RT_TRACE(COMP_SEC, DBG_LOUD,
-                  ("rtl8723a_cam_empty_entry(): WRITE A4: %lx\n",
-                  ulContent));*/
                /* delay_ms(40); */
                rtl8723au_write32(padapter, REG_CAMCMD, ulCommand);
-               /* RT_TRACE(COMP_SEC, DBG_LOUD,
-                  ("rtl8723a_cam_empty_entry(): WRITE A0: %lx\n",
-                  ulCommand));*/
        }
 }
 
index 5269b46445f4c236ad4e04d6ea4b0dfc6a7a40f5..ec543cfe1b45d2c1c6605c4c9ae9b7241133d45e 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 c912ab89bc3e9dd875590bd2533a758293d79cbb..cb2bdda6b0eba3478dc82a7c5851a51424b6cf42 100644 (file)
@@ -22,3 +22,18 @@ void ODM_InitDebugSetting23a(struct dm_odm_t *pDM_Odm)
 }
 
 u32 GlobalDebugLevel23A;
+
+void rt_trace(int comp, int level, const char *fmt, ...)
+{
+       struct va_format vaf;
+       va_list args;
+
+       va_start(args, fmt);
+
+       vaf.fmt = fmt;
+       vaf.va = &args;
+
+       pr_info(DRIVER_PREFIX " [0x%08x,%d] %pV", comp, level, &vaf);
+
+       va_end(args);
+}
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..cf15f80836badfd625e63e7a3d241686a6f0fb9a 100644 (file)
@@ -1554,7 +1554,8 @@ static void bthci_ResetBtSec(struct rtw_adapter *padapter, struct bt_security *p
                pBtSec->bUsedHwEncrypt = true;
        else
                pBtSec->bUsedHwEncrypt = false;
-       RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("%s: bUsedHwEncrypt =%d\n", __func__, pBtSec->bUsedHwEncrypt));
+       RT_TRACE(_module_rtl871x_security_c_, _drv_info_,
+                "%s: bUsedHwEncrypt =%d\n", __func__, pBtSec->bUsedHwEncrypt);
 
        pBtSec->RSNIE.Octet = pBtSec->RSNIEBuf;
 }
@@ -3208,7 +3209,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));
 
@@ -4518,8 +4519,8 @@ bthci_StateConnecting(struct rtw_adapter *padapter,
                RTPRINT(FIOCTL, IOCTL_STATE, ("STATE_CMD_MAC_CONNECT_COMPLETE\n"));
 
                if (pBTInfo->BtAsocEntry[EntryNum].AMPRole == AMP_BTAP_JOINER) {
-                       RT_TRACE(_module_rtl871x_security_c_,
-                                _drv_info_, ("StateConnecting \n"));
+                       RT_TRACE(_module_rtl871x_security_c_, _drv_info_,
+                                "StateConnecting\n");
                }
                break;
        case STATE_CMD_DISCONNECT_PHY_LINK:
@@ -5796,7 +5797,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 +5861,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;
@@ -11206,15 +11197,17 @@ void rtl8723a_BT_init_hal_vars(struct rtw_adapter *padapter)
        pHalData->bt_coexist.bt_radiosharedtype = pHalData->EEPROMBluetoothRadioShared;
 
        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                ("BT Coexistance = 0x%x\n", rtl8723a_BT_coexist(padapter)));
+                "BT Coexistance = 0x%x\n", rtl8723a_BT_coexist(padapter));
 
        if (rtl8723a_BT_coexist(padapter)) {
                if (pHalData->bt_coexist.BT_Ant_Num == Ant_x2) {
                        BTDM_SetBtCoexCurrAntNum(padapter, 2);
-                       RT_TRACE(_module_hal_init_c_, _drv_info_, ("BlueTooth BT_Ant_Num = Antx2\n"));
+                       RT_TRACE(_module_hal_init_c_, _drv_info_,
+                                "BlueTooth BT_Ant_Num = Antx2\n");
                } else if (pHalData->bt_coexist.BT_Ant_Num == Ant_x1) {
                        BTDM_SetBtCoexCurrAntNum(padapter, 1);
-                       RT_TRACE(_module_hal_init_c_, _drv_info_, ("BlueTooth BT_Ant_Num = Antx1\n"));
+                       RT_TRACE(_module_hal_init_c_, _drv_info_,
+                                "BlueTooth BT_Ant_Num = Antx1\n");
                }
                pHalData->bt_coexist.bBTBusyTraffic = false;
                pHalData->bt_coexist.bBTTrafficModeSet = false;
@@ -11223,8 +11216,8 @@ void rtl8723a_BT_init_hal_vars(struct rtw_adapter *padapter)
                pHalData->bt_coexist.PreviousState = 0;
 
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("bt_radiosharedType = 0x%x\n",
-                        pHalData->bt_coexist.bt_radiosharedtype));
+                        "bt_radiosharedType = 0x%x\n",
+                        pHalData->bt_coexist.bt_radiosharedtype);
        }
 }
 
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..04d01833dc304486dc5cb37b5b17acf1234026d2 100644 (file)
@@ -95,7 +95,7 @@ static int _WriteFW(struct rtw_adapter *padapter, void *buffer, u32 size)
                        goto exit;
        }
        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                ("_WriteFW Done- for Normal chip.\n"));
+                "_WriteFW Done- for Normal chip.\n");
 
 exit:
        return ret;
@@ -115,13 +115,13 @@ static int _FWFreeToGo(struct rtw_adapter *padapter)
 
        if (counter >= POLLING_READY_TIMEOUT_COUNT) {
                RT_TRACE(_module_hal_init_c_, _drv_err_,
-                        ("%s: chksum report fail! REG_MCUFWDL:0x%08x\n",
-                         __func__, value32));
+                        "%s: chksum report fail! REG_MCUFWDL:0x%08x\n",
+                        __func__, value32);
                return _FAIL;
        }
        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                ("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__,
-                 value32));
+                "%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__,
+                value32);
 
        value32 = rtl8723au_read32(padapter, REG_MCUFWDL);
        value32 |= MCUFWDL_RDY;
@@ -134,17 +134,16 @@ static int _FWFreeToGo(struct rtw_adapter *padapter)
                value32 = rtl8723au_read32(padapter, REG_MCUFWDL);
                if (value32 & WINTINI_RDY) {
                        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                ("%s: Polling FW ready success!! "
-                                 "REG_MCUFWDL:0x%08x\n",
-                                 __func__, value32));
+                                "%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n",
+                                __func__, value32);
                        return _SUCCESS;
                }
                udelay(5);
        } while (counter++ < POLLING_READY_TIMEOUT_COUNT);
 
        RT_TRACE(_module_hal_init_c_, _drv_err_,
-                ("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
-                 __func__, value32));
+                "%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n",
+                __func__, value32);
        return _FAIL;
 }
 
@@ -173,8 +172,8 @@ void rtl8723a_FirmwareSelfReset(struct rtw_adapter *padapter)
                        u1bTmp = rtl8723au_read8(padapter, REG_SYS_FUNC_EN + 1);
                }
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("-%s: 8051 reset success (%d)\n", __func__,
-                         Delay));
+                        "-%s: 8051 reset success (%d)\n", __func__,
+                        Delay);
 
                if ((Delay == 0)) {
                        /* force firmware reset */
@@ -206,13 +205,12 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
        int fw_size;
        static int log_version;
 
-       RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__));
+       RT_TRACE(_module_hal_init_c_, _drv_info_, "+%s\n", __func__);
 
        if (IS_8723A_A_CUT(pHalData->VersionID)) {
                fw_name = "rtlwifi/rtl8723aufw_A.bin";
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("rtl8723a_FirmwareDownload: R8723FwImageArray_UMC "
-                         "for RTL8723A A CUT\n"));
+                        "rtl8723a_FirmwareDownload: R8723FwImageArray_UMC for RTL8723A A CUT\n");
        } else if (IS_8723A_B_CUT(pHalData->VersionID)) {
                /*  WLAN Fw. */
                if (padapter->registrypriv.wifi_spec == 1) {
@@ -234,7 +232,7 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
                /*  <Roger_TODO> We should download proper RAM Code here
                    to match the ROM code. */
                RT_TRACE(_module_hal_init_c_, _drv_err_,
-                        ("%s: unknow version!\n", __func__));
+                        "%s: unknown version!\n", __func__);
                rtStatus = _FAIL;
                goto Exit;
        }
@@ -319,11 +317,11 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
        rtStatus = _FWFreeToGo(padapter);
        if (_SUCCESS != rtStatus) {
                RT_TRACE(_module_hal_init_c_, _drv_err_,
-                        ("DL Firmware failed!\n"));
+                        "DL Firmware failed!\n");
                goto Exit;
        }
        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                ("Firmware is ready to run!\n"));
+                "Firmware is ready to run!\n");
 
 Exit:
        kfree(firmware_buf);
@@ -424,15 +422,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 +521,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 +626,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 +716,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 +738,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 +749,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 +762,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);
 }
 
@@ -831,7 +817,7 @@ static void ResumeTxBeacon(struct rtw_adapter *padapter)
            we record the value */
        /*  which should be read from register to a global variable. */
 
-       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+ResumeTxBeacon\n"));
+       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, "+ResumeTxBeacon\n");
 
        pHalData->RegFwHwTxQCtrl |= BIT(6);
        rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2,
@@ -849,7 +835,7 @@ static void StopTxBeacon(struct rtw_adapter *padapter)
            we record the value */
        /*  which should be read from register to a global variable. */
 
-       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+StopTxBeacon\n"));
+       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, "+StopTxBeacon\n");
 
        pHalData->RegFwHwTxQCtrl &= ~BIT(6);
        rtl8723au_write8(padapter, REG_FWHW_TXQ_CTRL + 2,
@@ -995,7 +981,7 @@ int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt)
        switch (c2h_evt->id) {
        case C2H_DBG:
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("C2HCommandHandler: %s\n", c2h_evt->payload));
+                        "C2HCommandHandler: %s\n", c2h_evt->payload);
                break;
 
        case C2H_CCX_TX_RPT:
@@ -1005,22 +991,22 @@ int c2h_handler_8723a(struct rtw_adapter *padapter, struct c2h_evt_hdr *c2h_evt)
                break;
        case C2H_HW_INFO_EXCH:
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("[BT], C2H_HW_INFO_EXCH\n"));
+                        "[BT], C2H_HW_INFO_EXCH\n");
                for (i = 0; i < c2h_evt->plen; i++) {
                        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                                ("[BT], tmpBuf[%d]= 0x%x\n", i,
-                                 c2h_evt->payload[i]));
+                                "[BT], tmpBuf[%d]= 0x%x\n", i,
+                                c2h_evt->payload[i]);
                }
                break;
 
        case C2H_C2H_H2C_TEST:
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("[BT], C2H_H2C_TEST\n"));
+                        "[BT], C2H_H2C_TEST\n");
                RT_TRACE(_module_hal_init_c_, _drv_info_,
-                        ("[BT], tmpBuf[0]/[1]/[2]/[3]/[4]= 0x%x/ 0x%x/ "
-                         "0x%x/ 0x%x/ 0x%x\n", c2h_evt->payload[0],
-                         c2h_evt->payload[1], c2h_evt->payload[2],
-                         c2h_evt->payload[3], c2h_evt->payload[4]));
+                        "[BT], tmpBuf[0]/[1]/[2]/[3]/[4]= 0x%x/ 0x%x/ 0x%x/ 0x%x/ 0x%x\n",
+                        c2h_evt->payload[0],
+                        c2h_evt->payload[1], c2h_evt->payload[2],
+                        c2h_evt->payload[3], c2h_evt->payload[4]);
                break;
 
        case C2H_BT_INFO:
@@ -1095,7 +1081,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,14 +1134,13 @@ 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_,
-                                ("Failed to polling write LLT done at "
-                                 "address %d!\n", address));
+                                "Failed to polling write LLT done at address %d!\n",
+                                address);
                        status = _FAIL;
                        break;
                }
@@ -1174,16 +1158,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 +1173,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;
 }
@@ -1272,8 +1252,6 @@ e.        SYS_FUNC_EN 0x02[7:0] = 0x14            reset BB state machine
 
        /*  2010/08/12 MH We need to set BB/GLBAL reset to save power
            for SS mode. */
-
-/*     RT_TRACE(COMP_INIT, DBG_LOUD, ("======> RF off and reset BB.\n")); */
 }
 
 static void _ResetDigitalProcedure1_92C(struct rtw_adapter *padapter,
@@ -1402,8 +1380,6 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM)
                value8 = rtl8723au_read8(padapter, REG_LDOV12D_CTRL);
                value8 &= ~LDV12_EN;
                rtl8723au_write8(padapter, REG_LDOV12D_CTRL, value8);
-/*             RT_TRACE(COMP_INIT, DBG_LOUD,
-               (" REG_LDOV12D_CTRL Reg0x21:0x%02x.\n", value8)); */
        }
 
        /*****************************
@@ -1435,9 +1411,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);
 
@@ -1451,7 +1427,7 @@ int CardDisableHWSM(struct rtw_adapter *padapter, u8 resetMCU)
        _DisableAnalog(padapter, false);
 
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("======> Card disable finished.\n"));
+                "======> Card disable finished.\n");
 
        return _SUCCESS;
 }
@@ -1459,9 +1435,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);
@@ -1478,8 +1453,6 @@ int CardDisableWithoutHWSM(struct rtw_adapter *padapter)
        /*   ==== Disable analog sequence === */
        _DisableAnalog(padapter, true);
 
-       /* RT_TRACE(COMP_INIT, DBG_LOUD,
-          ("<====== Card Disable Without HWSM .\n")); */
        return _SUCCESS;
 }
 
@@ -1496,7 +1469,7 @@ void Hal_InitPGData(struct rtw_adapter *padapter, u8 *PROMContent)
                }
        } else {
                RT_TRACE(_module_hci_hal_init_c_, _drv_notice_,
-                        ("AutoLoad Fail reported from CR9346!!\n"));
+                        "AutoLoad Fail reported from CR9346!!\n");
                /* update to default value 0xFF */
                if (!pEEPROM->EepromOrEfuse)
                        EFUSE_ShadowMapUpdate23a(padapter, EFUSE_WIFI);
@@ -1521,7 +1494,7 @@ void Hal_EfuseParseIDCode(struct rtw_adapter *padapter, u8 *hwinfo)
        }
 
        RT_TRACE(_module_hal_init_c_, _drv_info_,
-                ("EEPROM ID = 0x%04x\n", EEPROMId));
+                "EEPROM ID = 0x%04x\n", EEPROMId);
 }
 
 static void Hal_EEValueCheck(u8 EEType, void *pInValue, void *pOutValue)
@@ -1536,9 +1509,8 @@ static void Hal_EEValueCheck(u8 EEType, void *pInValue, void *pOutValue)
                        *pOut = *pIn;
                else {
                        RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
-                                ("EETYPE_TX_PWR, value =%d is invalid, set "
-                                 "to default = 0x%x\n",
-                                 *pIn, EEPROM_Default_TxPowerLevel));
+                                "EETYPE_TX_PWR, value =%d is invalid, set to default = 0x%x\n",
+                                *pIn, EEPROM_Default_TxPowerLevel);
                        *pOut = EEPROM_Default_TxPowerLevel;
                }
        }
@@ -1676,35 +1648,34 @@ Hal_EfuseParsetxpowerinfo_8723A(struct rtw_adapter *padapter,
        for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) {
                for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
                        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                                ("RF(%u)-Ch(%u) [CCK / HT40_1S / HT40_2S] = "
-                                 "[0x%x / 0x%x / 0x%x]\n",
-                                 rfPath, ch,
-                                 pHalData->TxPwrLevelCck[rfPath][ch],
-                                 pHalData->TxPwrLevelHT40_1S[rfPath][ch],
-                                 pHalData->TxPwrLevelHT40_2S[rfPath][ch]));
+                                "RF(%u)-Ch(%u) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
+                                rfPath, ch,
+                                pHalData->TxPwrLevelCck[rfPath][ch],
+                                pHalData->TxPwrLevelHT40_1S[rfPath][ch],
+                                pHalData->TxPwrLevelHT40_2S[rfPath][ch]);
 
                }
        }
        for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
                RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                        ("RF-A Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch,
-                         pHalData->TxPwrHt20Diff[RF_PATH_A][ch],
-                         pHalData->TxPwrHt20Diff[RF_PATH_A][ch]));
+                        "RF-A Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch,
+                        pHalData->TxPwrHt20Diff[RF_PATH_A][ch],
+                        pHalData->TxPwrHt20Diff[RF_PATH_A][ch]);
        }
        for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++)
                RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                        ("RF-A Legacy to Ht40 Diff[%u] = 0x%x\n", ch,
-                         pHalData->TxPwrLegacyHtDiff[RF_PATH_A][ch]));
+                        "RF-A Legacy to Ht40 Diff[%u] = 0x%x\n", ch,
+                        pHalData->TxPwrLegacyHtDiff[RF_PATH_A][ch]);
        for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) {
                RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                        ("RF-B Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch,
-                         pHalData->TxPwrHt20Diff[RF_PATH_B][ch],
-                         pHalData->TxPwrHt20Diff[RF_PATH_B][ch]));
+                        "RF-B Ht20 to HT40 Diff[%u] = 0x%x(%d)\n", ch,
+                        pHalData->TxPwrHt20Diff[RF_PATH_B][ch],
+                        pHalData->TxPwrHt20Diff[RF_PATH_B][ch]);
        }
        for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++)
                RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                        ("RF-B Legacy to HT40 Diff[%u] = 0x%x\n", ch,
-                         pHalData->TxPwrLegacyHtDiff[RF_PATH_B][ch]));
+                        "RF-B Legacy to HT40 Diff[%u] = 0x%x\n", ch,
+                        pHalData->TxPwrLegacyHtDiff[RF_PATH_B][ch]);
        if (!AutoLoadFail) {
                struct registry_priv *registry_par = &padapter->registrypriv;
                if (registry_par->regulatory_tid == 0xff) {
@@ -1721,7 +1692,7 @@ Hal_EfuseParsetxpowerinfo_8723A(struct rtw_adapter *padapter,
                pHalData->EEPROMRegulatory = 0;
        }
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory));
+                "EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory);
 
        if (!AutoLoadFail)
                pHalData->bTXPowerDataReadFromEEPORM = true;
@@ -1747,8 +1718,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;
@@ -1771,8 +1742,8 @@ Hal_EfuseParseEEPROMVer(struct rtw_adapter *padapter,
        else
                pHalData->EEPROMVersion = 1;
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n",
-                 pHalData->EEPROMVersion));
+                "Hal_EfuseParseEEPROMVer(), EEVer = %d\n",
+                pHalData->EEPROMVersion);
 }
 
 void
@@ -1805,10 +1776,10 @@ Hal_EfuseParseCustomerID(struct rtw_adapter *padapter,
                pHalData->EEPROMSubCustomerID = 0;
        }
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID));
+                "EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID);
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("EEPROM SubCustomer ID: 0x%02x\n",
-                 pHalData->EEPROMSubCustomerID));
+                "EEPROM SubCustomer ID: 0x%02x\n",
+                pHalData->EEPROMSubCustomerID);
 }
 
 void
@@ -1837,8 +1808,8 @@ Hal_EfuseParseXtal_8723A(struct rtw_adapter *pAdapter,
                pHalData->CrystalCap = EEPROM_Default_CrystalCap_8723A;
        }
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("%s: CrystalCap = 0x%2x\n", __func__,
-                 pHalData->CrystalCap));
+                "%s: CrystalCap = 0x%2x\n", __func__,
+                pHalData->CrystalCap);
 }
 
 void
@@ -1875,9 +1846,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 +1895,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..46a30659c96f5fab7f3814e91cd6e3e3c257966b 100644 (file)
@@ -121,18 +121,15 @@ PHY_SetBBReg(struct rtw_adapter *Adapter, u32 RegAddr, u32 BitMask, u32   Data)
 {
        u32 OriginalValue, BitShift;
 
-       /* RT_TRACE(COMP_RF, DBG_TRACE, ("--->PHY_SetBBReg(): RegAddr(%#lx), BitMask(%#lx), Data(%#lx)\n", RegAddr, BitMask, 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);
 
        /* RTPRINT(FPHY, PHY_BBW, ("BBW MASK = 0x%lx Addr[0x%lx]= 0x%lx\n", BitMask, RegAddr, Data)); */
-       /* RT_TRACE(COMP_RF, DBG_TRACE, ("<---PHY_SetBBReg(): RegAddr(%#lx), BitMask(%#lx), Data(%#lx)\n", RegAddr, BitMask, Data)); */
 }
 
 /*  */
@@ -190,25 +187,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 +315,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 +386,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 +413,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 +420,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;
@@ -552,131 +545,51 @@ storePwrIndexDiffRateOffset(struct rtw_adapter *Adapter, u32 RegAddr,
 
        if (RegAddr == rTxAGC_A_Rate18_06) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][0])); */
        }
        if (RegAddr == rTxAGC_A_Rate54_24) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][1] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][1] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][1])); */
        }
        if (RegAddr == rTxAGC_A_CCK1_Mcs32) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][6] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][6] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][6])); */
        }
        if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0xffffff00) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][7] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][7] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][7])); */
        }
        if (RegAddr == rTxAGC_A_Mcs03_Mcs00) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][2] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][2] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][2])); */
        }
        if (RegAddr == rTxAGC_A_Mcs07_Mcs04) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][3] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][3] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][3])); */
        }
        if (RegAddr == rTxAGC_A_Mcs11_Mcs08) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][4] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][4] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][4])); */
        }
        if (RegAddr == rTxAGC_A_Mcs15_Mcs12) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][5] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][5] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][5])); */
        }
        if (RegAddr == rTxAGC_B_Rate18_06) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][8] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][8] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][8])); */
        }
        if (RegAddr == rTxAGC_B_Rate54_24) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][9] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][9] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][9])); */
        }
        if (RegAddr == rTxAGC_B_CCK1_55_Mcs32) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][14] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][14] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][14])); */
        }
        if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0x000000ff) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][15] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][15] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][15])); */
        }
        if (RegAddr == rTxAGC_B_Mcs03_Mcs00) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][10] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][10] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][10])); */
        }
        if (RegAddr == rTxAGC_B_Mcs07_Mcs04) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][11] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][11] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][11])); */
        }
        if (RegAddr == rTxAGC_B_Mcs11_Mcs08) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][12] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][12] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][12])); */
        }
        if (RegAddr == rTxAGC_B_Mcs15_Mcs12) {
                pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][13] = Data;
-               /* RT_TRACE(COMP_INIT, DBG_TRACE,
-                  ("MCSTxPowerLevelOriginalOffset[%d][13] = 0x%lx\n",
-                  pHalData->pwrGroupCnt, */
-               /*      pHalData->MCSTxPowerLevelOriginalOffset[
-                       pHalData->pwrGroupCnt][13])); */
                pHalData->pwrGroupCnt++;
        }
 }
@@ -831,7 +744,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 +833,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;
 
@@ -982,10 +891,7 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter)
                break;
 
        default:
-               /*RT_TRACE(COMP_DBG, DBG_LOUD,
-                 ("PHY_SetBWMode23aCallback8192C(): unknown Bandwidth: %#X\n" \
-                 , pHalData->CurrentChannelBW));*/
-                       break;
+               break;
        }
        /* Skip over setting of J-mode in BB register here. Default value
           is "None J mode". Emily 20070315 */
@@ -994,41 +900,8 @@ _PHY_SetBWMode23a92C(struct rtw_adapter *Adapter)
        /* NowL = PlatformEFIORead4Byte(Adapter, TSFR); */
        /* NowH = PlatformEFIORead4Byte(Adapter, TSFR+4); */
        /* EndTime = ((u64)NowH << 32) + NowL; */
-       /* 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; */
 
-       /* RT_TRACE(COMP_SCAN, DBG_LOUD,
-          ("<== PHY_SetBWMode23aCallback8192C() \n")); */
+       rtl8723a_phy_rf6052set_bw(Adapter, pHalData->CurrentChannelBW);
 }
 
  /*-----------------------------------------------------------------------------
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..0fec84bcb5d98a33445041d15a98055a111d52e7 100644 (file)
@@ -48,7 +48,7 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter)
        if (!precvpriv->precv_buf) {
                res = _FAIL;
                RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                        ("alloc recv_buf fail!\n"));
+                        "alloc recv_buf fail!\n");
                goto exit;
        }
 
@@ -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 1759487329ab70905561d2aee96d37319b916431..6bf87fe866445accd98d12ac6030a71a2b6c35dc 100644 (file)
@@ -42,7 +42,7 @@ static int urb_zero_packet_chk(struct rtw_adapter *padapter, int sz)
 
 static void rtl8192cu_cal_txdesc_chksum(struct tx_desc *ptxdesc)
 {
-               u16     *usPtr = (u16 *)ptxdesc;
+               __le16  *usPtr = (__le16 *)ptxdesc;
                u32 count = 16;         /*  (32 bytes / 2 bytes per XOR) => 16 times */
                u32 index;
                u16 checksum = 0;
@@ -130,7 +130,7 @@ static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw)
        }
 }
 
-static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt)
+static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz)
 {
        int     pull = 0;
        uint    qsel;
@@ -143,7 +143,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag
        struct mlme_ext_info    *pmlmeinfo = &pmlmeext->mlmext_info;
        int     bmcst = is_multicast_ether_addr(pattrib->ra);
 
-       if ((!bagg_pkt) && (urb_zero_packet_chk(padapter, sz) == 0)) {
+       if (urb_zero_packet_chk(padapter, sz) == 0) {
                ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ);
                pull = 1;
                pxmitframe->pkt_offset--;
@@ -272,7 +272,8 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag
        if (bmcst)
                ptxdesc->txdw0 |= cpu_to_le32(BIT(24));
 
-       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("offset0-txdesc = 0x%x\n", ptxdesc->txdw0));
+       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                "offset0-txdesc = 0x%x\n", ptxdesc->txdw0);
 
        /* offset 4 */
        /*  pkt_offset, unit:8 bytes padding */
@@ -303,7 +304,7 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter,
 
        mem_addr = pxmitframe->buf_addr;
 
-       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n"));
+       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, "rtw_dump_xframe()\n");
 
        for (t = 0; t < pattrib->nr_frags; t++) {
                if (inner_ret != _SUCCESS && ret == _SUCCESS)
@@ -311,7 +312,7 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter,
 
                if (t != (pattrib->nr_frags - 1)) {
                        RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
-                                ("pattrib->nr_frags =%d\n", pattrib->nr_frags));
+                                "pattrib->nr_frags =%d\n", pattrib->nr_frags);
 
                        sz = pxmitpriv->frag_len;
                        sz = sz - 4 - pattrib->icv_len;
@@ -320,7 +321,7 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter,
                        sz = pattrib->last_txcmdsz;
                }
 
-               pull = update_txdesc(pxmitframe, mem_addr, sz, false);
+               pull = update_txdesc(pxmitframe, mem_addr, sz);
 
                if (pull) {
                        mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */
@@ -338,7 +339,7 @@ static int rtw_dump_xframe(struct rtw_adapter *padapter,
                rtw_count_tx_stats23a(padapter, pxmitframe, sz);
 
                RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
-                        ("rtw_write_port, w_sz =%d\n", w_sz));
+                        "rtw_write_port, w_sz =%d\n", w_sz);
 
                mem_addr += w_sz;
 
@@ -365,7 +366,7 @@ bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter,
        phwxmits = pxmitpriv->hwxmits;
        hwentry = pxmitpriv->hwxmit_entry;
 
-       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("xmitframe_complete()\n"));
+       RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, "xmitframe_complete()\n");
 
        if (pxmitbuf == NULL) {
                pxmitbuf = rtw_alloc_xmitbuf23a(pxmitpriv);
@@ -388,7 +389,8 @@ bool rtl8723au_xmitframe_complete(struct rtw_adapter *padapter,
                        rtw_os_xmit_complete23a(padapter, pxmitframe);/* always return ndis_packet after rtw_xmitframe_coalesce23a */
                }
 
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("xmitframe_complete(): rtw_dump_xframe\n"));
+               RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
+                        "xmitframe_complete(): rtw_dump_xframe\n");
 
                if (res == _SUCCESS) {
                        rtw_dump_xframe(padapter, pxmitframe);
@@ -481,7 +483,7 @@ enqueue:
 
        if (res != _SUCCESS) {
                RT_TRACE(_module_xmit_osdep_c_, _drv_err_,
-                        ("pre_xmitframe: enqueue xmitframe fail\n"));
+                        "pre_xmitframe: enqueue xmitframe fail\n");
                rtw_free_xmitframe23a(pxmitpriv, pxmitframe);
 
                /*  Trick, make the statistics correct */
index adbf1c2dd383ac9fd921e422b143bc40cb84e99c..42ae29d26302d4e1f2649754debdcd981d80c82b 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" */
@@ -530,7 +516,7 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
        /*  Check if MAC has already power on. by tynli. 2011.05.27. */
        val8 = rtl8723au_read8(Adapter, REG_CR);
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("%s: REG_CR 0x100 = 0x%02x\n", __func__, val8));
+                "%s: REG_CR 0x100 = 0x%02x\n", __func__, val8);
        /* Fix 92DU-VC S3 hang with the reason is that secondary mac is not
           initialized. */
        /* 0x100 value of first mac is 0xEA while 0x100 value of secondary
@@ -540,13 +526,13 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
        } else {
                mac_on = true;
                RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                        ("%s: MAC has already power on\n", __func__));
+                        "%s: MAC has already power on\n", __func__);
        }
 
        status = _InitPowerOn(Adapter);
        if (status == _FAIL) {
                RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
-                        ("Failed to init power on!\n"));
+                        "Failed to init power on!\n");
                goto exit;
        }
 
@@ -561,7 +547,7 @@ int rtl8723au_hal_init(struct rtw_adapter *Adapter)
                status =  InitLLTTable23a(Adapter, boundary);
                if (status == _FAIL) {
                        RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
-                                ("Failed to init LLT table\n"));
+                                "Failed to init LLT table\n");
                        goto exit;
                }
        }
@@ -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,15 +736,16 @@ 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. */
        if (((rtl8723au_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) !=
             0x83000000)) {
                PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT(24), 1);
-               RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("%s: IQK fail recorver\n", __func__));
+               RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
+                        "%s: IQK fail recover\n", __func__);
        }
 
        /* ack for xmit mgmt frames. */
@@ -806,19 +796,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;
@@ -829,7 +818,7 @@ static void phy_SsPwrSwitch92CU(struct rtw_adapter *Adapter,
                else
                        sps0 &= ~(BIT(0) | BIT(3));
 
-               RT_TRACE(_module_hal_init_c_, _drv_err_, ("SS LVL1\n"));
+               RT_TRACE(_module_hal_init_c_, _drv_err_, "SS LVL1\n");
                /*  Disable RF and BB only for SelectSuspend. */
 
                /*  1. Set BB/RF to shutdown. */
@@ -840,13 +829,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 +845,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 */
@@ -949,14 +934,14 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
 
        status = _SUCCESS;
 
-       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("===> usb_inirp_init\n"));
+       RT_TRACE(_module_hci_hal_init_c_, _drv_info_, "===> usb_inirp_init\n");
 
        /* issue Rx irp to receive data */
        precvbuf = (struct recv_buf *)precvpriv->precv_buf;
        for (i = 0; i < NR_RECVBUFF; i++) {
                if (rtl8723au_read_port(Adapter, 0, precvbuf) == _FAIL) {
                        RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
-                                ("usb_rx_init: usb_read_port error\n"));
+                                "usb_rx_init: usb_read_port error\n");
                        status = _FAIL;
                        goto exit;
                }
@@ -964,7 +949,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
        }
        if (rtl8723au_read_interrupt(Adapter) == _FAIL) {
                RT_TRACE(_module_hci_hal_init_c_, _drv_err_,
-                        ("%s: usb_read_interrupt error\n", __func__));
+                        "%s: usb_read_interrupt error\n", __func__);
                status = _FAIL;
        }
        pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR);
@@ -973,7 +958,7 @@ int rtl8723au_inirp_init(struct rtw_adapter *Adapter)
        rtl8723au_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]);
 exit:
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("<=== usb_inirp_init\n"));
+                "<=== usb_inirp_init\n");
        return status;
 }
 
@@ -982,7 +967,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter)
        struct hal_data_8723a   *pHalData = GET_HAL_DATA(Adapter);
 
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("\n ===> usb_rx_deinit\n"));
+                "===> usb_rx_deinit\n");
        rtl8723au_read_port_cancel(Adapter);
        pHalData->IntrMask[0] = rtl8723au_read32(Adapter, REG_USB_HIMR);
        MSG_8723A("%s pHalData->IntrMask = 0x%04x\n", __func__,
@@ -990,7 +975,7 @@ int rtl8723au_inirp_deinit(struct rtw_adapter *Adapter)
        pHalData->IntrMask[0] = 0x0;
        rtl8723au_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]);
        RT_TRACE(_module_hci_hal_init_c_, _drv_info_,
-                ("\n <=== usb_rx_deinit\n"));
+                "<=== usb_rx_deinit\n");
        return _SUCCESS;
 }
 
@@ -1037,11 +1022,10 @@ static void Hal_EfuseParseMACAddr_8723AU(struct rtw_adapter *padapter,
        }
 
        RT_TRACE(_module_hci_hal_init_c_, _drv_notice_,
-                ("Hal_EfuseParseMACAddr_8723AU: Permanent Address =%02x:%02x:"
-                 "%02x:%02x:%02x:%02x\n",
-                 pEEPROM->mac_addr[0], pEEPROM->mac_addr[1],
-                 pEEPROM->mac_addr[2], pEEPROM->mac_addr[3],
-                 pEEPROM->mac_addr[4], pEEPROM->mac_addr[5]));
+                "Hal_EfuseParseMACAddr_8723AU: Permanent Address =%02x:%02x:%02x:%02x:%02x:%02x\n",
+                pEEPROM->mac_addr[0], pEEPROM->mac_addr[1],
+                pEEPROM->mac_addr[2], pEEPROM->mac_addr[3],
+                pEEPROM->mac_addr[4], pEEPROM->mac_addr[5]);
 }
 
 static void readAdapterInfo(struct rtw_adapter *padapter)
@@ -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));
 }
@@ -1192,8 +1165,6 @@ int GetHalDefVar8192CUsb(struct rtw_adapter *Adapter,
        }
                break;
        default:
-               /* RT_TRACE(COMP_INIT, DBG_WARNING, ("GetHalDefVar8192CUsb(): "
-                  "Unkown variable: %d!\n", eVariable)); */
                bResult = _FAIL;
                break;
        }
@@ -1211,7 +1182,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 +1254,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 a6d16adce107fa788776552a23f61ff140a4487c..371e6b373420c18a950828c9e14b4fa87b59d467 100644 (file)
@@ -297,14 +297,12 @@ urb_submit:
                case -ENODEV:
                case -ESHUTDOWN:
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_read_port_complete:bSurpriseRemoved ="
-                                 "true\n"));
+                                "usb_read_port_complete:bSurpriseRemoved =true\n");
                        /* Fall Through here */
                case -ENOENT:
                        padapter->bDriverStopped = true;
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_read_port_complete:bDriverStopped ="
-                                 "true\n"));
+                                "usb_read_port_complete:bDriverStopped =true\n");
                        break;
                case -EPROTO:
                        break;
@@ -367,16 +365,16 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
 
        do {
                RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                        ("recvbuf2recvframe: rxdesc = offsset 0:0x%08x, "
-                         "4:0x%08x, 8:0x%08x, C:0x%08x\n", prxstat->rxdw0,
-                         prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4));
+                        "recvbuf2recvframe: rxdesc = offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n",
+                        prxstat->rxdw0, prxstat->rxdw1,
+                        prxstat->rxdw2, prxstat->rxdw4);
 
                prxstat = (struct recv_stat *)pbuf;
 
                precvframe = rtw_alloc_recvframe23a(pfree_recv_queue);
                if (!precvframe) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("recvbuf2recvframe: precvframe == NULL\n"));
+                                "recvbuf2recvframe: precvframe == NULL\n");
                        DBG_8723A("%s()-%d: rtw_alloc_recvframe23a() failed! RX "
                                  "Drop!\n", __func__, __LINE__);
                        goto _exit_recvbuf2recvframe;
@@ -400,7 +398,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
 
                if (pattrib->pkt_len <= 0 || pkt_offset > transfer_len) {
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-                                ("recvbuf2recvframe: pkt_len<= 0\n"));
+                                "recvbuf2recvframe: pkt_len<= 0\n");
                        DBG_8723A("%s()-%d: RX Warning!\n",
                                  __func__, __LINE__);
                        rtw_free_recvframe23a(precvframe);
@@ -471,8 +469,7 @@ static int recvbuf2recvframe(struct rtw_adapter *padapter, struct sk_buff *pskb)
 
                if (rtw_recv_entry23a(precvframe) != _SUCCESS)
                        RT_TRACE(_module_rtl871x_recv_c_, _drv_err_,
-                                ("recvbuf2recvframe: rtw_recv_entry23a"
-                                 "(precvframe) != _SUCCESS\n"));
+                                "recvbuf2recvframe: rtw_recv_entry23a(precvframe) != _SUCCESS\n");
 
                pkt_cnt--;
                transfer_len -= pkt_offset;
@@ -520,16 +517,15 @@ static void usb_read_port_complete(struct urb *purb)
        struct recv_priv *precvpriv = &padapter->recvpriv;
 
        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                ("usb_read_port_complete!!!\n"));
+                "usb_read_port_complete!!!\n");
 
        precvpriv->rx_pending_cnt--;
 
        if (padapter->bSurpriseRemoved || padapter->bDriverStopped ||
            padapter->bReadPortCancel) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_read_port_complete:bDriverStopped(%d) OR "
-                         "bSurpriseRemoved(%d)\n", padapter->bDriverStopped,
-                         padapter->bSurpriseRemoved));
+                        "usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n",
+                        padapter->bDriverStopped, padapter->bSurpriseRemoved);
 
                DBG_8723A("%s()-%d: RX Warning! bDriverStopped(%d) OR "
                          "bSurpriseRemoved(%d) bReadPortCancel(%d)\n",
@@ -542,9 +538,7 @@ static void usb_read_port_complete(struct urb *purb)
                if (purb->actual_length > MAX_RECVBUF_SZ ||
                    purb->actual_length < RXDESC_SIZE) {
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_read_port_complete: (purb->actual_"
-                                 "length > MAX_RECVBUF_SZ) || (purb->actual_"
-                                 "length < RXDESC_SIZE)\n"));
+                                "usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n");
                        rtl8723au_read_port(padapter, 0, precvbuf);
                        DBG_8723A("%s()-%d: RX Warning!\n",
                                  __func__, __LINE__);
@@ -564,8 +558,8 @@ static void usb_read_port_complete(struct urb *purb)
                }
        } else {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_read_port_complete : purb->status(%d) != 0 \n",
-                         purb->status));
+                        "usb_read_port_complete : purb->status(%d) != 0\n",
+                        purb->status);
                skb_put(precvbuf->pskb, purb->actual_length);
                precvbuf->pskb = NULL;
 
@@ -583,14 +577,12 @@ static void usb_read_port_complete(struct urb *purb)
                case -ENODEV:
                case -ESHUTDOWN:
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_read_port_complete:bSurprise"
-                                 "Removed = true\n"));
+                                "usb_read_port_complete:bSurpriseRemoved = true\n");
                        /* Intentional fall through here */
                case -ENOENT:
                        padapter->bDriverStopped = true;
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_read_port_complete:"
-                                 "bDriverStopped = true\n"));
+                                "usb_read_port_complete:bDriverStopped = true\n");
                        break;
                case -EPROTO:
                case -EOVERFLOW:
@@ -620,14 +612,13 @@ int rtl8723au_read_port(struct rtw_adapter *adapter, u32 cnt,
 
        if (adapter->bDriverStopped || adapter->bSurpriseRemoved) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_read_port:(padapter->bDriverStopped ||"
-                         "padapter->bSurpriseRemoved)!!!\n"));
+                        "usb_read_port:(padapter->bDriverStopped ||padapter->bSurpriseRemoved)!!!\n");
                return _FAIL;
        }
 
        if (!precvbuf) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_read_port:precvbuf == NULL\n"));
+                        "usb_read_port:precvbuf == NULL\n");
                return _FAIL;
        }
 
@@ -638,7 +629,8 @@ int rtl8723au_read_port(struct rtw_adapter *adapter, u32 cnt,
        if (!precvbuf->pskb) {
                precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
                if (precvbuf->pskb == NULL) {
-                       RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n"));
+                       RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
+                                "init_recvbuf(): alloc_skb fail!\n");
                        return _FAIL;
                }
 
@@ -661,8 +653,8 @@ int rtl8723au_read_port(struct rtw_adapter *adapter, u32 cnt,
        err = usb_submit_urb(purb, GFP_ATOMIC);
        if ((err) && (err != -EPERM)) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("cannot submit rx in-token(err = 0x%.8x), URB_STATUS "
-                         "= 0x%.8x", err, purb->status));
+                        "cannot submit rx in-token(err = 0x%.8x), URB_STATUS = 0x%.8x\n",
+                        err, purb->status);
                DBG_8723A("cannot submit rx in-token(err = 0x%08x), urb_status "
                          "= %d\n", err, purb->status);
                ret = _FAIL;
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..3aa40a32555ed88904837710545c47c5e59217c8 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
 
@@ -265,9 +251,6 @@ join_res:
 > 0: TID
 */
 
-#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
-
 #define MAXTID 16
 
 #define WME_OUI_TYPE 2
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 b6b01732a7259f0a8af7108b2102a5921c6969ea..159183e9cab008d6c4a3d360e91e4be89dba8537 100644 (file)
 
 extern u32 GlobalDebugLevel23A;
 
+__printf(3, 4)
+void rt_trace(int comp, int level, const char *fmt, ...);
 
-#define RT_TRACE(_Comp, _Level, Fmt)                                   \
+#define RT_TRACE(_Comp, _Level, Fmt, ...)                              \
 do {                                                                   \
-       if (_Level <= GlobalDebugLevel23A) {                            \
-               pr_info("%s [0x%08x,%d]", DRIVER_PREFIX,                \
-                        (unsigned int)_Comp, _Level);                  \
-               pr_info Fmt;                                            \
-       }                                                               \
+       if (_Level <= GlobalDebugLevel23A)                              \
+               rt_trace(_Comp, _Level, Fmt, ##__VA_ARGS__);            \
 } while (0)
 
 #define RT_PRINT_DATA(_Comp, _Level, _TitleString, _HexData,           \
index 537bd8214efe1deaa0ada916c80e3c13b6603437..b139ed40cb2729555152af9e0df8be2d0ab40930 100644 (file)
@@ -729,7 +729,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, u8 key_index,
        if (keyparms->cipher == WLAN_CIPHER_SUITE_WEP40 ||
            keyparms->cipher == WLAN_CIPHER_SUITE_WEP104) {
                RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_,
-                        ("wpa_set_encryption, crypt.alg = WEP\n"));
+                        "wpa_set_encryption, crypt.alg = WEP\n");
                DBG_8723A("wpa_set_encryption, crypt.alg = WEP\n");
 
                if (psecuritypriv->bWepDefaultKeyIdxSet == 0) {
@@ -1076,8 +1076,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
                ret = -ENOENT;
                goto exit;
        }
-       DBG_8723A("%s(%s): mac =" MAC_FMT "\n", __func__, ndev->name,
-                 MAC_ARG(mac));
+       DBG_8723A("%s(%s): mac=%pM\n", __func__, ndev->name, mac);
 
        /* for infra./P2PClient mode */
        if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
@@ -1085,8 +1084,8 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
                struct wlan_network *cur_network = &pmlmepriv->cur_network;
 
                if (!ether_addr_equal(mac, cur_network->network.MacAddress)) {
-                       DBG_8723A("%s, mismatch bssid =" MAC_FMT "\n", __func__,
-                                 MAC_ARG(cur_network->network.MacAddress));
+                       DBG_8723A("%s, mismatch bssid=%pM\n",
+                                 __func__, cur_network->network.MacAddress);
                        ret = -ENOENT;
                        goto exit;
                }
@@ -1128,14 +1127,14 @@ static int cfg80211_infrastructure_mode(struct rtw_adapter *padapter,
        old_mode = cur_network->network.ifmode;
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_,
-                ("+%s: old =%d new =%d fw_state = 0x%08x\n", __func__,
-                 old_mode, ifmode, get_fwstate(pmlmepriv)));
+                "+%s: old =%d new =%d fw_state = 0x%08x\n", __func__,
+                old_mode, ifmode, get_fwstate(pmlmepriv));
 
        if (old_mode != ifmode) {
                spin_lock_bh(&pmlmepriv->lock);
 
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        (" change mode!"));
+                        "change mode!\n");
 
                if (old_mode == NL80211_IFTYPE_AP ||
                    old_mode == NL80211_IFTYPE_P2P_GO) {
@@ -1195,10 +1194,6 @@ static int cfg80211_infrastructure_mode(struct rtw_adapter *padapter,
 
                /* SecClearAllKeys(adapter); */
 
-               /* RT_TRACE(COMP_OID_SET, DBG_LOUD,
-                  ("set_infrastructure: fw_state:%x after changing mode\n", */
-               /* get_fwstate(pmlmepriv))); */
-
                spin_unlock_bh(&pmlmepriv->lock);
        }
 
@@ -1603,7 +1598,7 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                          pie[i + 4], pie[i + 5], pie[i + 6], pie[i + 7]);
        if (ielen < RSN_HEADER_LEN) {
                RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_,
-                        ("Ie len too short %d\n", (int)ielen));
+                        "Ie len too short %d\n", (int)ielen);
                ret = -1;
                goto exit;
        }
@@ -1726,11 +1721,10 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
                rtl8723a_off_rcr_am(padapter);
 
        RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
-                ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->"
-                 "securitypriv.ndisencryptstatus =%d padapter->"
-                 "securitypriv.ndisauthtype =%d\n", pairwise_cipher,
-                 padapter->securitypriv.ndisencryptstatus,
-                 padapter->securitypriv.ndisauthtype));
+                "rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n",
+                pairwise_cipher,
+                padapter->securitypriv.ndisencryptstatus,
+                padapter->securitypriv.ndisauthtype);
 
 exit:
        if (ret)
@@ -1746,7 +1740,7 @@ static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
 
        if (keyid >= NUM_WEP_KEYS) {
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
-                        ("%s:keyid>4 =>fail\n", __func__));
+                        "%s:keyid>4 =>fail\n", __func__);
                res = _FAIL;
                goto exit;
        }
@@ -1755,45 +1749,45 @@ static int rtw_cfg80211_add_wep(struct rtw_adapter *padapter,
        case WLAN_KEY_LEN_WEP40:
                psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP40;
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        ("%s:wep->KeyLength = 5\n", __func__));
+                        "%s:wep->KeyLength = 5\n", __func__);
                break;
        case WLAN_KEY_LEN_WEP104:
                psecuritypriv->dot11PrivacyAlgrthm = WLAN_CIPHER_SUITE_WEP104;
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        ("%s:wep->KeyLength = 13\n", __func__));
+                        "%s:wep->KeyLength = 13\n", __func__);
                break;
        default:
                psecuritypriv->dot11PrivacyAlgrthm = 0;
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        ("%s:wep->KeyLength!= 5 or 13\n", __func__));
+                        "%s:wep->KeyLength!= 5 or 13\n", __func__);
                res = _FAIL;
                goto exit;
        }
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                ("%s:before memcpy, wep->KeyLength = 0x%x keyid =%x\n",
-                 __func__, wep->keylen, keyid));
+                "%s:before memcpy, wep->KeyLength = 0x%x keyid =%x\n",
+                __func__, wep->keylen, keyid);
 
        memcpy(&psecuritypriv->wep_key[keyid], wep, sizeof(struct rtw_wep_key));
 
        psecuritypriv->dot11PrivacyKeyIndex = keyid;
 
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                ("%s:security key material : "
-                 "%x %x %x %x %x %x %x %x %x %x %x %x %x\n", __func__,
-                 psecuritypriv->wep_key[keyid].key[0],
-                 psecuritypriv->wep_key[keyid].key[1],
-                 psecuritypriv->wep_key[keyid].key[2],
-                 psecuritypriv->wep_key[keyid].key[3],
-                 psecuritypriv->wep_key[keyid].key[4],
-                 psecuritypriv->wep_key[keyid].key[5],
-                 psecuritypriv->wep_key[keyid].key[6],
-                 psecuritypriv->wep_key[keyid].key[7],
-                 psecuritypriv->wep_key[keyid].key[8],
-                 psecuritypriv->wep_key[keyid].key[9],
-                 psecuritypriv->wep_key[keyid].key[10],
-                 psecuritypriv->wep_key[keyid].key[11],
-                 psecuritypriv->wep_key[keyid].key[12]));
+                "%s:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
+                __func__,
+                psecuritypriv->wep_key[keyid].key[0],
+                psecuritypriv->wep_key[keyid].key[1],
+                psecuritypriv->wep_key[keyid].key[2],
+                psecuritypriv->wep_key[keyid].key[3],
+                psecuritypriv->wep_key[keyid].key[4],
+                psecuritypriv->wep_key[keyid].key[5],
+                psecuritypriv->wep_key[keyid].key[6],
+                psecuritypriv->wep_key[keyid].key[7],
+                psecuritypriv->wep_key[keyid].key[8],
+                psecuritypriv->wep_key[keyid].key[9],
+                psecuritypriv->wep_key[keyid].key[10],
+                psecuritypriv->wep_key[keyid].key[11],
+                psecuritypriv->wep_key[keyid].key[12]);
 
        res = rtw_set_key23a(padapter, psecuritypriv, keyid, 1);
 
@@ -1815,7 +1809,7 @@ static int rtw_set_ssid(struct rtw_adapter *padapter,
 
        if (padapter->hw_init_completed == false) {
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
-                        ("set_ssid: hw_init_completed == false =>exit!!!\n"));
+                        "set_ssid: hw_init_completed == false =>exit!!!\n");
                status = _FAIL;
                goto exit;
        }
@@ -1828,7 +1822,7 @@ static int rtw_set_ssid(struct rtw_adapter *padapter,
 
        if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
                RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                        ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n"));
+                        "set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n");
 
                if (pmlmepriv->assoc_ssid.ssid_len ==
                    newnetwork->network.Ssid.ssid_len &&
@@ -1837,9 +1831,9 @@ static int rtw_set_ssid(struct rtw_adapter *padapter,
                            newnetwork->network.Ssid.ssid_len)) {
                        if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
                                RT_TRACE(_module_rtl871x_ioctl_set_c_,
-                                        _drv_err_, ("New SSID is same SSID, "
-                                                    "fw_state = 0x%08x\n",
-                                                    get_fwstate(pmlmepriv)));
+                                        _drv_err_,
+                                        "New SSID is same SSID, fw_state = 0x%08x\n",
+                                        get_fwstate(pmlmepriv));
 
                                if (rtw_is_same_ibss23a(padapter, pnetwork)) {
                                        /*
@@ -1875,15 +1869,15 @@ static int rtw_set_ssid(struct rtw_adapter *padapter,
                        }
                } else {
                        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("Set SSID not the same ssid\n"));
+                                "Set SSID not the same ssid\n");
                        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("set_ssid =[%s] len = 0x%x\n",
-                                 newnetwork->network.Ssid.ssid,
-                                 newnetwork->network.Ssid.ssid_len));
+                                "set_ssid =[%s] len = 0x%x\n",
+                                newnetwork->network.Ssid.ssid,
+                                newnetwork->network.Ssid.ssid_len);
                        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_,
-                                ("assoc_ssid =[%s] len = 0x%x\n",
-                                 pmlmepriv->assoc_ssid.ssid,
-                                 pmlmepriv->assoc_ssid.ssid_len));
+                                "assoc_ssid =[%s] len = 0x%x\n",
+                                pmlmepriv->assoc_ssid.ssid,
+                                pmlmepriv->assoc_ssid.ssid_len);
 
                        rtw_disassoc_cmd23a(padapter, 0, true);
 
@@ -1947,7 +1941,7 @@ release_mlme_lock:
 
 exit:
        RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_,
-                ("-%s: status =%d\n", __func__, status));
+                "-%s: status =%d\n", __func__, status);
 
        return status;
 }
@@ -1989,7 +1983,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev,
        DBG_8723A("ssid =%s, len =%zu\n", sme->ssid, sme->ssid_len);
 
        if (sme->bssid)
-               DBG_8723A("bssid =" MAC_FMT "\n", MAC_ARG(sme->bssid));
+               DBG_8723A("bssid=%pM\n", sme->bssid);
 
        if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) {
                ret = -EBUSY;
@@ -2523,8 +2517,8 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb,
 
                mgmt = (struct ieee80211_mgmt *)dot11_hdr;
 
-               DBG_8723A("RTW_Tx:da =" MAC_FMT " via %s(%s)\n",
-                         MAC_ARG(mgmt->da), __func__, ndev->name);
+               DBG_8723A("RTW_Tx:da=%pM via %s(%s)\n",
+                         mgmt->da, __func__, ndev->name);
                category = mgmt->u.action.category;
                action = mgmt->u.action.u.wme_action.action_code;
                DBG_8723A("RTW_Tx:category(%u), action(%u)\n",
@@ -2877,7 +2871,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy,
                return ret;
        }
 
-       DBG_8723A("free sta macaddr =" MAC_FMT "\n", MAC_ARG(mac));
+       DBG_8723A("free sta macaddr=%pM\n", mac);
 
        if (is_broadcast_ether_addr(mac))
                return -EINVAL;
@@ -3053,8 +3047,7 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
        cfg80211_mgmt_tx_status(padapter->rtw_wdev, *cookie, buf, len, ack,
                                GFP_KERNEL);
 
-       DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch,
-                 MAC_ARG(hdr->da));
+       DBG_8723A("RTW_Tx:tx_ch =%d, da =%pM\n", tx_ch, hdr->da);
        category = hdr->u.action.category;
        action = hdr->u.action.u.wme_action.action_code;
        DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, action);
index 1b23eb13222b76baafb92d974a9308fabd836203..83696360c2932d7c66cd1671712a284a1b3f231d 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;
 
@@ -342,7 +342,7 @@ int rtw_init_netdev23a_name23a(struct net_device *pnetdev, const char *ifname)
 {
        if (dev_alloc_name(pnetdev, ifname) < 0) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("dev_alloc_name, fail!\n"));
+                        "dev_alloc_name, fail!\n");
        }
        netif_carrier_off(pnetdev);
        return 0;
@@ -357,7 +357,7 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter)
        struct rtw_adapter *padapter;
        struct net_device *pnetdev;
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "+init_net_dev\n");
 
        pnetdev = alloc_etherdev_mq(sizeof(struct rtw_adapter), 4);
        if (!pnetdev)
@@ -456,11 +456,11 @@ int rtw_init_drv_sw23a(struct rtw_adapter *padapter)
 {
        int ret8 = _SUCCESS;
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw23a\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "+rtw_init_drv_sw23a\n");
 
        if (rtw_init_cmd_priv23a(&padapter->cmdpriv) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't init cmd_priv\n"));
+                        "Can't init cmd_priv\n");
                ret8 = _FAIL;
                goto exit;
        }
@@ -469,14 +469,14 @@ int rtw_init_drv_sw23a(struct rtw_adapter *padapter)
 
        if (rtw_init_evt_priv23a(&padapter->evtpriv) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't init evt_priv\n"));
+                        "Can't init evt_priv\n");
                ret8 = _FAIL;
                goto exit;
        }
 
        if (rtw_init_mlme_priv23a(padapter) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't init mlme_priv\n"));
+                        "Can't init mlme_priv\n");
                ret8 = _FAIL;
                goto exit;
        }
@@ -484,7 +484,7 @@ int rtw_init_drv_sw23a(struct rtw_adapter *padapter)
 
        if (init_mlme_ext_priv23a(padapter) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't init mlme_ext_priv\n"));
+                        "Can't init mlme_ext_priv\n");
                ret8 = _FAIL;
                goto exit;
        }
@@ -521,40 +521,40 @@ int rtw_init_drv_sw23a(struct rtw_adapter *padapter)
 
 exit:
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw23a\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "-rtw_init_drv_sw23a\n");
        return ret8;
 }
 
 void rtw_cancel_all_timer23a(struct rtw_adapter *padapter)
 {
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("+rtw_cancel_all_timer23a\n"));
+                "+rtw_cancel_all_timer23a\n");
 
        del_timer_sync(&padapter->mlmepriv.assoc_timer);
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("%s:cancel association timer complete!\n", __func__));
+                "%s:cancel association timer complete!\n", __func__);
 
        del_timer_sync(&padapter->mlmepriv.scan_to_timer);
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("%s:cancel scan_to_timer!\n", __func__));
+                "%s:cancel scan_to_timer!\n", __func__);
 
        del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer);
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("%s:cancel dynamic_chk_timer!\n", __func__));
+                "%s:cancel dynamic_chk_timer!\n", __func__);
 
        del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer);
 
        del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer);
        rtw_clear_scan_deny(padapter);
        RT_TRACE(_module_os_intfs_c_, _drv_info_,
-                ("%s:cancel set_scan_deny_timer!\n", __func__));
+                "%s:cancel set_scan_deny_timer!\n", __func__);
 
        del_timer_sync(&padapter->recvpriv.signal_stat_timer);
 }
 
 int rtw_free_drv_sw23a(struct rtw_adapter *padapter)
 {
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw23a"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "==>rtw_free_drv_sw23a\n");
 
        free_mlme_ext_priv23a(&padapter->mlmeextpriv);
 
@@ -574,7 +574,7 @@ int rtw_free_drv_sw23a(struct rtw_adapter *padapter)
        kfree(padapter->HalData);
        padapter->HalData = NULL;
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw23a\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "-rtw_free_drv_sw23a\n");
        return _SUCCESS;
 }
 
@@ -594,8 +594,8 @@ static int _rtw_drv_register_netdev(struct rtw_adapter *padapter, char *name)
                ret = _FAIL;
                goto error_register_netdev;
        }
-       DBG_8723A("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__,
-                 (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr));
+       DBG_8723A("%s, MAC Address (if%d) = %pM\n",
+                 __func__, padapter->iface_id + 1, pnetdev->dev_addr);
        return ret;
 
 error_register_netdev:
@@ -647,7 +647,7 @@ int netdev_open23a(struct net_device *pnetdev)
        int ret = 0;
        int status;
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - dev_open\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "+871x_drv - dev_open\n");
        DBG_8723A("+871x_drv - drv_open, bup =%d\n", padapter->bup);
 
        mutex_lock(&adapter_to_dvobj(padapter)->hw_init_mutex);
@@ -662,12 +662,11 @@ int netdev_open23a(struct net_device *pnetdev)
                status = rtl8723au_hal_init(padapter);
                if (status == _FAIL) {
                        RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                                ("rtl871x_hal_init(): Can't init h/w!\n"));
+                                "rtl871x_hal_init(): Can't init h/w!\n");
                        goto netdev_open23a_error;
                }
 
-               DBG_8723A("MAC Address = "MAC_FMT"\n",
-                         MAC_ARG(pnetdev->dev_addr));
+               DBG_8723A("MAC Address = %pM\n", pnetdev->dev_addr);
 
                if (init_hw_mlme_ext23a(padapter) == _FAIL) {
                        DBG_8723A("can't init mlme_ext_priv\n");
@@ -695,7 +694,7 @@ int netdev_open23a(struct net_device *pnetdev)
        else
                netif_tx_wake_all_queues(pnetdev);
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - dev_open\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "-871x_drv - dev_open\n");
        DBG_8723A("-871x_drv - drv_open, bup =%d\n", padapter->bup);
 exit:
        mutex_unlock(&adapter_to_dvobj(padapter)->hw_init_mutex);
@@ -708,7 +707,7 @@ netdev_open23a_error:
        netif_tx_stop_all_queues(pnetdev);
 
        RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                ("-871x_drv - dev_open, fail!\n"));
+                "-871x_drv - dev_open, fail!\n");
        DBG_8723A("-871x_drv - drv_open fail, bup =%d\n", padapter->bup);
 
        ret = -1;
@@ -729,7 +728,7 @@ static int ips_netdrv_open(struct rtw_adapter *padapter)
        status = rtl8723au_hal_init(padapter);
        if (status == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("ips_netdrv_open(): Can't init h/w!\n"));
+                        "ips_netdrv_open(): Can't init h/w!\n");
                goto netdev_open23a_error;
        }
 
@@ -807,7 +806,7 @@ static int netdev_close(struct net_device *pnetdev)
 {
        struct rtw_adapter *padapter = netdev_priv(pnetdev);
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "+871x_drv - drv_close\n");
 
        padapter->net_closed = true;
 
@@ -835,7 +834,7 @@ static int netdev_close(struct net_device *pnetdev)
 
        rtw_scan_abort23a(padapter);
 
-       RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-871x_drv - drv_close\n"));
+       RT_TRACE(_module_os_intfs_c_, _drv_info_, "-871x_drv - drv_close\n");
        DBG_8723A("-871x_drv - drv_close, bup =%d\n", padapter->bup);
 
        return 0;
index bcd970baf4052deaa4e1d67d7a22f2fa3d61b10e..084b506ae16161bb6ecfa009fd8515395ae45e31 100644 (file)
@@ -81,19 +81,19 @@ int rtw_recv_indicatepkt23a(struct rtw_adapter *padapter,
        skb = precv_frame->pkt;
        if (!skb) {
                RT_TRACE(_module_recv_osdep_c_, _drv_err_,
-                        ("rtw_recv_indicatepkt23a():skb == NULL!!!!\n"));
+                        "rtw_recv_indicatepkt23a():skb == NULL!!!!\n");
                goto _recv_indicatepkt_drop;
        }
 
        RT_TRACE(_module_recv_osdep_c_, _drv_info_,
-                ("rtw_recv_indicatepkt23a():skb != NULL !!!\n"));
+                "rtw_recv_indicatepkt23a():skb != NULL !!!\n");
        RT_TRACE(_module_recv_osdep_c_, _drv_info_,
-                ("rtw_recv_indicatepkt23a():precv_frame->hdr.rx_data =%p\n",
-                 precv_frame->pkt->data));
+                "rtw_recv_indicatepkt23a():precv_frame->hdr.rx_data =%p\n",
+                precv_frame->pkt->data);
        RT_TRACE(_module_recv_osdep_c_, _drv_info_,
-                ("\n skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n",
-                 skb->head, skb->data,
-                 skb_tail_pointer(skb), skb_end_pointer(skb), skb->len));
+                "skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n",
+                skb->head, skb->data,
+                skb_tail_pointer(skb), skb_end_pointer(skb), skb->len);
 
        if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
                struct sk_buff *pskb2 = NULL;
@@ -148,7 +148,7 @@ _recv_indicatepkt_end:
        rtw_free_recvframe23a(precv_frame);
 
        RT_TRACE(_module_recv_osdep_c_, _drv_info_,
-                ("\n rtw_recv_indicatepkt23a :after netif_rx!!!!\n"));
+                "rtw_recv_indicatepkt23a :after netif_rx!!!!\n");
        return _SUCCESS;
 
 _recv_indicatepkt_drop:
index 05755b870a5fbeaeda0de95d1a7dc1e7c9980e09..27b3a5b7d8d4022e241f8f3b751a53fd187725b3 100644 (file)
@@ -159,7 +159,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
 
        if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) {
                RT_TRACE(_module_os_intfs_c_, _drv_err_,
-                        ("\n Can't INIT rtw_init_intf_priv\n"));
+                        "Can't INIT rtw_init_intf_priv\n");
                goto free_dvobj;
        }
        /* 3 misc */
@@ -213,7 +213,7 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf)
 
 void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter)
 {
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+usb_intf_stop\n");
 
        /* disable_hw_interrupt */
        if (!padapter->bSurpriseRemoved) {
@@ -221,7 +221,7 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter)
                 * TODO:
                 */
                RT_TRACE(_module_hci_intfs_c_, _drv_err_,
-                        ("SurpriseRemoved == false\n"));
+                        "SurpriseRemoved == false\n");
        }
 
        /* cancel in irp */
@@ -231,13 +231,14 @@ void rtl8723a_usb_intf_stop(struct rtw_adapter *padapter)
        rtl8723au_write_port_cancel(padapter);
 
        /* todo:cancel other irps */
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "-usb_intf_stop\n");
 }
 
 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"));
+
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+rtw_dev_unload\n");
 
        if (padapter->bup) {
                DBG_8723A("===> rtw_dev_unload\n");
@@ -261,10 +262,10 @@ static void rtw_dev_unload(struct rtw_adapter *padapter)
                padapter->bup = false;
        } else {
                RT_TRACE(_module_hci_intfs_c_, _drv_err_,
-                        ("r871x_dev_unload():padapter->bup == false\n"));
+                        "r871x_dev_unload():padapter->bup == false\n");
        }
        DBG_8723A("<=== rtw_dev_unload\n");
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "-rtw_dev_unload\n");
 }
 
 static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
@@ -435,7 +436,7 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
        /* step 5. */
        if (rtw_init_drv_sw23a(padapter) == _FAIL) {
                RT_TRACE(_module_hci_intfs_c_, _drv_err_,
-                        ("Initialize driver software resource Failed!\n"));
+                        "Initialize driver software resource Failed!\n");
                goto free_hal_data;
        }
 
@@ -533,13 +534,13 @@ static int rtw_drv_init(struct usb_interface *pusb_intf,
        struct dvobj_priv *dvobj;
        int status = _FAIL;
 
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+rtw_drv_init\n");
 
        /* Initialize dvobj_priv */
        dvobj = usb_dvobj_init(pusb_intf);
        if (!dvobj) {
                RT_TRACE(_module_hci_intfs_c_, _drv_err_,
-                        ("initialize device object priv Failed!\n"));
+                        "initialize device object priv Failed!\n");
                goto exit;
        }
 
@@ -554,7 +555,7 @@ static int rtw_drv_init(struct usb_interface *pusb_intf,
        if (status != _SUCCESS)
                goto free_if1;
        RT_TRACE(_module_hci_intfs_c_, _drv_err_,
-                ("-871x_drv - drv_init, success!\n"));
+                "-871x_drv - drv_init, success!\n");
 
        status = _SUCCESS;
 
@@ -586,7 +587,7 @@ static void rtw_disconnect(struct usb_interface *pusb_intf)
 
        usb_set_intfdata(pusb_intf, NULL);
 
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+dev_remove()\n");
 
        rtw_pm_set_ips23a(padapter, IPS_NONE);
        rtw_pm_set_lps23a(padapter, PS_MODE_ACTIVE);
@@ -597,21 +598,19 @@ static void rtw_disconnect(struct usb_interface *pusb_intf)
 
        usb_dvobj_deinit(pusb_intf);
 
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n"));
+       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)
 {
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+rtw_drv_entry\n");
        return usb_register(usb_drv);
 }
 
 static void __exit rtw_drv_halt(void)
 {
-       RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n"));
+       RT_TRACE(_module_hci_intfs_c_, _drv_err_, "+rtw_drv_halt\n");
        DBG_8723A("+rtw_drv_halt\n");
 
        usb_deregister(usb_drv);
index 3e19b3b2c1c21751fafe15162685f03c636279ea..0cdaef0a8c24b2bd89935686bb68035bf42e84cb 100644 (file)
@@ -58,9 +58,8 @@ static void usb_write_port23a_complete(struct urb *purb)
        if (padapter->bSurpriseRemoved || padapter->bDriverStopped ||
            padapter->bWritePortCancel) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_write_port23a_complete:bDriverStopped(%d) OR "
-                         "bSurpriseRemoved(%d)", padapter->bDriverStopped,
-                         padapter->bSurpriseRemoved));
+                        "usb_write_port23a_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n",
+                        padapter->bDriverStopped, padapter->bSurpriseRemoved);
                DBG_8723A("%s(): TX Warning! bDriverStopped(%d) OR "
                          "bSurpriseRemoved(%d) bWritePortCancel(%d) "
                          "pxmitbuf->ext_tag(%x)\n", __func__,
@@ -72,14 +71,14 @@ static void usb_write_port23a_complete(struct urb *purb)
 
        if (purb->status) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_write_port23a_complete : purb->status(%d) "
-                         "!= 0\n", purb->status));
+                        "usb_write_port23a_complete : purb->status(%d) != 0\n",
+                        purb->status);
                DBG_8723A("###=> urb_write_port_complete status(%d)\n",
                          purb->status);
                if (purb->status == -EPIPE || purb->status == -EPROTO) {
                } else if (purb->status == -EINPROGRESS) {
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_write_port23a_complete: EINPROGESS\n"));
+                                "usb_write_port23a_complete: EINPROGESS\n");
                        goto check_completion;
                } else if (purb->status == -ENOENT) {
                        DBG_8723A("%s: -ENOENT\n", __func__);
@@ -89,18 +88,16 @@ static void usb_write_port23a_complete(struct urb *purb)
                        goto check_completion;
                } else if (purb->status == -ESHUTDOWN) {
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_write_port23a_complete: ESHUTDOWN\n"));
+                                "usb_write_port23a_complete: ESHUTDOWN\n");
                        padapter->bDriverStopped = true;
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_write_port23a_complete:bDriverStopped "
-                                 "= true\n"));
+                                "usb_write_port23a_complete:bDriverStopped = true\n");
                        goto check_completion;
                } else {
                        padapter->bSurpriseRemoved = true;
                        DBG_8723A("bSurpriseRemoved = true\n");
                        RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                                ("usb_write_port23a_complete:bSurpriseRemoved "
-                                 "= true\n"));
+                                "usb_write_port23a_complete:bSurpriseRemoved = true\n");
                        goto check_completion;
                }
        }
@@ -132,12 +129,12 @@ int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
        int status;
        int ret = _FAIL;
 
-       RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port23a\n"));
+       RT_TRACE(_module_hci_ops_os_c_, _drv_err_, "+usb_write_port23a\n");
 
        if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("%s:(padapter->bDriverStopped || "
-                         "padapter->bSurpriseRemoved)!!!\n", __func__));
+                        "%s:(padapter->bDriverStopped || padapter->bSurpriseRemoved)!!!\n",
+                        __func__);
                rtw23a_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY);
                goto exit;
        }
@@ -188,8 +185,8 @@ int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
                                     RTW_SCTX_DONE_WRITE_PORT_ERR);
                DBG_8723A("usb_write_port23a, status =%d\n", status);
                RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
-                        ("usb_write_port23a(): usb_submit_urb, status =%x\n",
-                        status));
+                        "usb_write_port23a(): usb_submit_urb, status =%x\n",
+                        status);
 
                switch (status) {
                case -ENODEV:
@@ -201,7 +198,7 @@ int rtl8723au_write_port(struct rtw_adapter *padapter, u32 addr, u32 cnt,
                goto exit;
        }
        ret = _SUCCESS;
-       RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port23a\n"));
+       RT_TRACE(_module_hci_ops_os_c_, _drv_err_, "-usb_write_port23a\n");
 
 exit:
        if (ret != _SUCCESS)
index 69f88848715abc9d61f58ed9cbabcf91b18e8e43..9a14074ecec0551cd583b8cb3c295d7e5aa7dbf9 100644 (file)
@@ -123,11 +123,11 @@ int rtw_xmit23a_entry23a(struct sk_buff *skb, struct net_device *pnetdev)
        struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
        int res = 0;
 
-       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n"));
+       RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, "+xmit_enry\n");
 
        if (!rtw_if_up23a(padapter)) {
                RT_TRACE(_module_xmit_osdep_c_, _drv_err_,
-                        ("rtw_xmit23a_entry23a: rtw_if_up23a fail\n"));
+                        "rtw_xmit23a_entry23a: rtw_if_up23a fail\n");
                goto drop_packet;
        }
 
@@ -139,16 +139,16 @@ int rtw_xmit23a_entry23a(struct sk_buff *skb, struct net_device *pnetdev)
 
        pxmitpriv->tx_pkts++;
        RT_TRACE(_module_xmit_osdep_c_, _drv_info_,
-                ("rtw_xmit23a_entry23a: tx_pkts=%d\n",
-                (u32)pxmitpriv->tx_pkts));
+                "rtw_xmit23a_entry23a: tx_pkts=%d\n",
+                (u32)pxmitpriv->tx_pkts);
        goto exit;
 
 drop_packet:
        pxmitpriv->tx_drop++;
        dev_kfree_skb_any(skb);
        RT_TRACE(_module_xmit_osdep_c_, _drv_notice_,
-                ("rtw_xmit23a_entry23a: drop, tx_drop=%d\n",
-                (u32)pxmitpriv->tx_drop));
+                "rtw_xmit23a_entry23a: drop, tx_drop=%d\n",
+                (u32)pxmitpriv->tx_drop);
 exit:
        return 0;
 }
index 17b4471c4d6d2241b1c6c670ee55f999afd36d50..f7fd03a94e5fa94c5228dd1e71f312f378af3d45 100644 (file)
@@ -3,4 +3,4 @@ obj-$(CONFIG_RTS5208) := rts5208.o
 ccflags-y := -Idrivers/scsi
 
 rts5208-y := rtsx.o rtsx_chip.o rtsx_transport.o rtsx_scsi.o \
-       rtsx_card.o general.o sd.o xd.o ms.o spi.o
+       rtsx_card.o general.o sd.o xd.o ms.o spi.o trace.o
index a47a19135d49ff27fd8d4edd164f389f1bd6bb80..ee818b0dc4011f7aab19db049e7fb6f82958f197 100644 (file)
@@ -26,9 +26,6 @@
 #include <linux/vmalloc.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
 #include "ms.h"
 
 static inline void ms_set_err_code(struct rtsx_chip *chip, u8 err_code)
@@ -47,7 +44,8 @@ static inline int ms_check_err_code(struct rtsx_chip *chip, u8 err_code)
 
 static int ms_parse_err_code(struct rtsx_chip *chip)
 {
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode,
@@ -78,7 +76,8 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode,
        if (retval < 0) {
                rtsx_clear_ms_error(chip);
                ms_set_err_code(chip, MS_TO_ERROR);
-               TRACE_RET(chip, ms_parse_err_code(chip));
+               rtsx_trace(chip);
+               return ms_parse_err_code(chip);
        }
 
        ptr = rtsx_get_cmd_data(chip) + 1;
@@ -86,13 +85,15 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode,
        if (!(tpc & 0x08)) {            /* Read Packet */
                if (*ptr & MS_CRC16_ERR) {
                        ms_set_err_code(chip, MS_CRC16_ERROR);
-                       TRACE_RET(chip, ms_parse_err_code(chip));
+                       rtsx_trace(chip);
+                       return ms_parse_err_code(chip);
                }
        } else {                        /* Write Packet */
                if (CHK_MSPRO(ms_card) && !(*ptr & 0x80)) {
                        if (*ptr & (MS_INT_ERR | MS_INT_CMDNK)) {
                                ms_set_err_code(chip, MS_CMD_NK);
-                               TRACE_RET(chip, ms_parse_err_code(chip));
+                               rtsx_trace(chip);
+                               return ms_parse_err_code(chip);
                        }
                }
        }
@@ -100,22 +101,25 @@ static int ms_transfer_tpc(struct rtsx_chip *chip, u8 trans_mode,
        if (*ptr & MS_RDY_TIMEOUT) {
                rtsx_clear_ms_error(chip);
                ms_set_err_code(chip, MS_TO_ERROR);
-               TRACE_RET(chip, ms_parse_err_code(chip));
+               rtsx_trace(chip);
+               return ms_parse_err_code(chip);
        }
 
        return STATUS_SUCCESS;
 }
 
 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;
        u8 val, err_code = 0;
        enum dma_data_direction dir;
 
-       if (!buf || !buf_len)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!buf || !buf_len) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (trans_mode == MS_TM_AUTO_READ) {
                dir = DMA_FROM_DEVICE;
@@ -124,7 +128,8 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode,
                dir = DMA_TO_DEVICE;
                err_code = MS_FLASH_WRITE_ERROR;
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        rtsx_init_cmd(chip);
@@ -160,12 +165,19 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 trans_mode,
                else
                        retval = STATUS_FAIL;
 
-               TRACE_RET(chip, retval);
+               rtsx_trace(chip);
+               return retval;
        }
 
-       RTSX_READ_REG(chip, MS_TRANS_CFG, &val);
-       if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT))
-               TRACE_RET(chip, STATUS_FAIL);
+       retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       if (val & (MS_INT_CMDNK | MS_INT_ERR | MS_CRC16_ERR | MS_RDY_TIMEOUT)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -176,8 +188,10 @@ static int ms_write_bytes(struct rtsx_chip *chip,
        struct ms_info *ms_card = &(chip->ms_card);
        int retval, i;
 
-       if (!data || (data_len < cnt))
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!data || (data_len < cnt)) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -211,25 +225,28 @@ static int ms_write_bytes(struct rtsx_chip *chip,
                if (!(tpc & 0x08)) {
                        if (val & MS_CRC16_ERR) {
                                ms_set_err_code(chip, MS_CRC16_ERROR);
-                               TRACE_RET(chip, ms_parse_err_code(chip));
+                               rtsx_trace(chip);
+                               return ms_parse_err_code(chip);
                        }
                } else {
                        if (CHK_MSPRO(ms_card) && !(val & 0x80)) {
                                if (val & (MS_INT_ERR | MS_INT_CMDNK)) {
                                        ms_set_err_code(chip, MS_CMD_NK);
-                                       TRACE_RET(chip,
-                                               ms_parse_err_code(chip));
+                                       rtsx_trace(chip);
+                                       return ms_parse_err_code(chip);
                                }
                        }
                }
 
                if (val & MS_RDY_TIMEOUT) {
                        ms_set_err_code(chip, MS_TO_ERROR);
-                       TRACE_RET(chip, ms_parse_err_code(chip));
+                       rtsx_trace(chip);
+                       return ms_parse_err_code(chip);
                }
 
                ms_set_err_code(chip, MS_TO_ERROR);
-               TRACE_RET(chip, ms_parse_err_code(chip));
+               rtsx_trace(chip);
+               return ms_parse_err_code(chip);
        }
 
        return STATUS_SUCCESS;
@@ -242,8 +259,10 @@ static int ms_read_bytes(struct rtsx_chip *chip,
        int retval, i;
        u8 *ptr;
 
-       if (!data)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!data) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -277,25 +296,28 @@ static int ms_read_bytes(struct rtsx_chip *chip,
                if (!(tpc & 0x08)) {
                        if (val & MS_CRC16_ERR) {
                                ms_set_err_code(chip, MS_CRC16_ERROR);
-                               TRACE_RET(chip, ms_parse_err_code(chip));
+                               rtsx_trace(chip);
+                               return ms_parse_err_code(chip);
                        }
                } else {
                        if (CHK_MSPRO(ms_card) && !(val & 0x80)) {
                                if (val & (MS_INT_ERR | MS_INT_CMDNK)) {
                                        ms_set_err_code(chip, MS_CMD_NK);
-                                       TRACE_RET(chip,
-                                               ms_parse_err_code(chip));
+                                       rtsx_trace(chip);
+                                       return ms_parse_err_code(chip);
                                }
                        }
                }
 
                if (val & MS_RDY_TIMEOUT) {
                        ms_set_err_code(chip, MS_TO_ERROR);
-                       TRACE_RET(chip, ms_parse_err_code(chip));
+                       rtsx_trace(chip);
+                       return ms_parse_err_code(chip);
                }
 
                ms_set_err_code(chip, MS_TO_ERROR);
-               TRACE_RET(chip, ms_parse_err_code(chip));
+               rtsx_trace(chip);
+               return ms_parse_err_code(chip);
        }
 
        ptr = rtsx_get_cmd_data(chip) + 1;
@@ -331,7 +353,8 @@ static int ms_set_rw_reg_addr(struct rtsx_chip *chip,
                rtsx_clear_ms_error(chip);
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 static int ms_send_cmd(struct rtsx_chip *chip, u8 cmd, u8 cfg)
@@ -369,12 +392,16 @@ static int ms_set_init_para(struct rtsx_chip *chip)
        }
 
        retval = switch_clock(chip, ms_card->ms_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = select_card(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -385,37 +412,87 @@ static int ms_switch_clock(struct rtsx_chip *chip)
        int retval;
 
        retval = select_card(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = switch_clock(chip, ms_card->ms_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
 
 static int ms_pull_ctl_disable(struct rtsx_chip *chip)
 {
+       int retval;
+
        if (CHECK_PID(chip, 0x5208)) {
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF,
-                       MS_D1_PD | MS_D2_PD | MS_CLK_PD | MS_D6_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF,
-                       MS_D3_PD | MS_D0_PD | MS_BS_PD | XD_D4_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF,
-                       MS_D7_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF,
-                       XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF,
-                       MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL6, 0xFF,
-                       MS_D5_PD | MS_D4_PD);
+               retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF,
+                                            MS_D1_PD | MS_D2_PD | MS_CLK_PD | MS_D6_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF,
+                                            MS_D3_PD | MS_D0_PD | MS_BS_PD | XD_D4_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF,
+                                            MS_D7_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF,
+                                            XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF,
+                                            MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF,
+                                            MS_D5_PD | MS_D4_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else if (CHECK_PID(chip, 0x5288)) {
                if (CHECK_BARO_PKG(chip, QFN)) {
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF, 0x4B);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF, 0x69);
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL1,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL2,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL3,
+                                                    0xFF, 0x4B);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL4,
+                                                    0xFF, 0x69);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        }
 
@@ -455,8 +532,10 @@ static int ms_pull_ctl_enable(struct rtsx_chip *chip)
        }
 
        retval = rtsx_send_cmd(chip, MS_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -475,29 +554,41 @@ static int ms_prepare_reset(struct rtsx_chip *chip)
        ms_card->pro_under_formatting = 0;
 
        retval = ms_power_off_card3v3(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!chip->ft2_fast_mode)
                wait_timeout(250);
 
        retval = enable_card_clock(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (chip->asic_code) {
                retval = ms_pull_ctl_enable(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               RTSX_WRITE_REG(chip, FPGA_PULL_CTL,
-                       FPGA_MS_PULL_CTL_BIT | 0x20, 0);
+               retval = rtsx_write_register(chip, FPGA_PULL_CTL,
+                                            FPGA_MS_PULL_CTL_BIT | 0x20, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        if (!chip->ft2_fast_mode) {
                retval = card_power_on(chip, MS_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(150);
 
@@ -510,30 +601,52 @@ static int ms_prepare_reset(struct rtsx_chip *chip)
                if (chip->ocp_stat & oc_mask) {
                        dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n",
                                chip->ocp_stat);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
        }
 
-       RTSX_WRITE_REG(chip, CARD_OE, MS_OUTPUT_EN, MS_OUTPUT_EN);
+       retval = rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN,
+                                    MS_OUTPUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (chip->asic_code) {
-               RTSX_WRITE_REG(chip, MS_CFG, 0xFF,
-                       SAMPLE_TIME_RISING | PUSH_TIME_DEFAULT |
-                       NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1);
+               retval = rtsx_write_register(chip, MS_CFG, 0xFF,
+                                            SAMPLE_TIME_RISING | PUSH_TIME_DEFAULT | NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else {
-               RTSX_WRITE_REG(chip, MS_CFG, 0xFF,
-                       SAMPLE_TIME_FALLING | PUSH_TIME_DEFAULT |
-                       NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1);
+               retval = rtsx_write_register(chip, MS_CFG, 0xFF,
+                                            SAMPLE_TIME_FALLING | PUSH_TIME_DEFAULT | NO_EXTEND_TOGGLE | MS_BUS_WIDTH_1);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
+       retval = rtsx_write_register(chip, MS_TRANS_CFG, 0xFF,
+                                    NO_WAIT_INT | NO_AUTO_READ_INT_REG);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CARD_STOP, MS_STOP | MS_CLR_ERR,
+                                    MS_STOP | MS_CLR_ERR);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
        }
-       RTSX_WRITE_REG(chip, MS_TRANS_CFG,
-               0xFF, NO_WAIT_INT | NO_AUTO_READ_INT_REG);
-       RTSX_WRITE_REG(chip, CARD_STOP,
-               MS_STOP | MS_CLR_ERR, MS_STOP | MS_CLR_ERR);
 
        retval = ms_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -545,8 +658,10 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus)
        u8 val;
 
        retval = ms_set_rw_reg_addr(chip, Pro_StatusReg, 6, SystemParm, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        for (i = 0; i < MS_MAX_RETRY_COUNT; i++) {
                retval = ms_transfer_tpc(chip, MS_TM_READ_BYTES, READ_REG,
@@ -554,29 +669,49 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, PPBUF_BASE2 + 2, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2 + 2, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "Type register: 0x%x\n", val);
        if (val != 0x01) {
                if (val != 0x02)
                        ms_card->check_ms_flow = 1;
 
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_READ_REG(chip, PPBUF_BASE2 + 4, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2 + 4, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "Category register: 0x%x\n", val);
        if (val != 0) {
                ms_card->check_ms_flow = 1;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_READ_REG(chip, PPBUF_BASE2 + 5, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2 + 5, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "Class register: 0x%x\n", val);
        if (val == 0) {
-               RTSX_READ_REG(chip, PPBUF_BASE2, &val);
+               retval = rtsx_read_register(chip, PPBUF_BASE2, &val);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if (val & WRT_PRTCT)
                        chip->card_wp |= MS_CARD;
                else
@@ -586,12 +721,17 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus)
                chip->card_wp |= MS_CARD;
        } else {
                ms_card->check_ms_flow = 1;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        ms_card->ms_type |= TYPE_MSPRO;
 
-       RTSX_READ_REG(chip, PPBUF_BASE2 + 3, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2 + 3, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "IF Mode register: 0x%x\n", val);
        if (val == 0) {
                ms_card->ms_type &= 0x0F;
@@ -602,7 +742,8 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus)
                        ms_card->ms_type &= 0x0F;
 
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -618,7 +759,8 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip)
        do {
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                for (i = 0; i < MS_MAX_RETRY_COUNT; i++) {
@@ -627,11 +769,15 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip)
                        if (retval == STATUS_SUCCESS)
                                break;
                }
-               if (i == MS_MAX_RETRY_COUNT)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (i == MS_MAX_RETRY_COUNT) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
-               if (k > 100)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (k > 100) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                k++;
                wait_timeout(100);
@@ -642,14 +788,18 @@ static int ms_confirm_cpu_startup(struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_ERR) {
                if (val & INT_REG_CMDNK)
                        chip->card_wp |= (MS_CARD);
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
        /* --  end confirm CPU startup */
 
@@ -669,8 +819,10 @@ static int ms_switch_parallel_bus(struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -689,21 +841,31 @@ static int ms_switch_8bit_bus(struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, MS_CFG, 0x98,
-               MS_BUS_WIDTH_8 | SAMPLE_TIME_FALLING);
+       retval = rtsx_write_register(chip, MS_CFG, 0x98,
+                                    MS_BUS_WIDTH_8 | SAMPLE_TIME_FALLING);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        ms_card->ms_type |= MS_8BIT;
        retval = ms_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        for (i = 0; i < MS_MAX_RETRY_COUNT; i++) {
                retval = ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT,
                                        1, NO_WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -716,22 +878,29 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus)
 
        for (i = 0; i < 3; i++) {
                retval = ms_prepare_reset(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_identify_media_type(chip, switch_8bit_bus);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_confirm_cpu_startup(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_switch_parallel_bus(chip);
                if (retval != STATUS_SUCCESS) {
                        if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                                ms_set_err_code(chip, MS_NO_CARD);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        continue;
                } else {
@@ -739,23 +908,37 @@ static int ms_pro_reset_flow(struct rtsx_chip *chip, int switch_8bit_bus)
                }
        }
 
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* Switch MS-PRO into Parallel mode */
-       RTSX_WRITE_REG(chip, MS_CFG, 0x18, MS_BUS_WIDTH_4);
-       RTSX_WRITE_REG(chip, MS_CFG, PUSH_TIME_ODD, PUSH_TIME_ODD);
+       retval = rtsx_write_register(chip, MS_CFG, 0x18, MS_BUS_WIDTH_4);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, MS_CFG, PUSH_TIME_ODD,
+                                    PUSH_TIME_ODD);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = ms_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* If MSPro HG Card, We shall try to switch to 8-bit bus */
        if (CHK_MSHG(ms_card) && chip->support_ms_8bit && switch_8bit_bus) {
                retval = ms_switch_8bit_bus(chip);
                if (retval != STATUS_SUCCESS) {
                        ms_card->switch_8bit_fail = 1;
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -771,8 +954,10 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode)
        ms_cleanup_work(chip);
 
        retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf[0] = 0;
        buf[1] = mode;
@@ -782,16 +967,26 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode)
        buf[5] = 0;
 
        retval = ms_write_bytes(chip, PRO_WRITE_REG, 6, NO_WAIT_INT, buf, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_send_cmd(chip, XC_CHG_POWER, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, MS_TRANS_CFG, buf);
-       if (buf[0] & (MS_INT_CMDNK | MS_INT_ERR))
-               TRACE_RET(chip, STATUS_FAIL);
+       retval = rtsx_read_register(chip, MS_TRANS_CFG, buf);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       if (buf[0] & (MS_INT_CMDNK | MS_INT_ERR)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -813,8 +1008,10 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
 #endif
 
        retval = ms_set_rw_reg_addr(chip, Pro_IntReg, 2, Pro_SystemParm, 7);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_MS8BIT(ms_card))
                data[0] = PARALLEL_8BIT_IF;
@@ -836,12 +1033,16 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf = kmalloc(64 * 512, GFP_KERNEL);
-       if (buf == NULL)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        for (i = 0; i < MS_MAX_RETRY_COUNT; i++) {
                retval = ms_send_cmd(chip, PRO_READ_ATRB, WAIT_INT);
@@ -851,11 +1052,13 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
                if (retval != STATUS_SUCCESS) {
                        kfree(buf);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                if (!(val & MS_INT_BREQ)) {
                        kfree(buf);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                retval = ms_transfer_data(chip, MS_TM_AUTO_READ,
                                        PRO_READ_LONG_DATA, 0x40, WAIT_INT,
@@ -867,7 +1070,8 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
        }
        if (retval != STATUS_SUCCESS) {
                kfree(buf);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        i = 0;
@@ -875,7 +1079,8 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
                if (retval != STATUS_SUCCESS) {
                        kfree(buf);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if ((val & MS_INT_CED) || !(val & MS_INT_BREQ))
@@ -885,7 +1090,8 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                                        PRO_READ_LONG_DATA, 0, WAIT_INT);
                if (retval != STATUS_SUCCESS) {
                        kfree(buf);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                i++;
@@ -893,18 +1099,21 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
 
        if (retval != STATUS_SUCCESS) {
                kfree(buf);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if ((buf[0] != 0xa5) && (buf[1] != 0xc3)) {
                /* Signature code is wrong */
                kfree(buf);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if ((buf[4] < 1) || (buf[4] > 12)) {
                kfree(buf);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        for (i = 0; i < buf[4]; i++) {
@@ -929,15 +1138,18 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                                sys_info_addr, sys_info_size);
                        if (sys_info_size != 96)  {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (sys_info_addr < 0x1A0) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if ((sys_info_size + sys_info_addr) > 0x8000) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
 #ifdef SUPPORT_MSXC
@@ -964,15 +1176,18 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                                model_name_addr, model_name_size);
                        if (model_name_size != 48)  {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (model_name_addr < 0x1A0) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if ((model_name_size + model_name_addr) > 0x8000) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        found_model_name = 1;
@@ -985,7 +1200,8 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
 
        if (i == buf[4]) {
                kfree(buf);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        class_code =  buf[sys_info_addr + 0];
@@ -1030,15 +1246,21 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
 
 #ifdef SUPPORT_MSXC
        if (CHK_MSXC(ms_card)) {
-               if (class_code != 0x03)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (class_code != 0x03) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               if (class_code != 0x02)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (class_code != 0x02) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 #else
-       if (class_code != 0x02)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (class_code != 0x02) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 #endif
 
        if (device_type != 0x00) {
@@ -1046,12 +1268,15 @@ static int ms_read_attribute_info(struct rtsx_chip *chip)
                                (device_type == 0x03)) {
                        chip->card_wp |= MS_CARD;
                } else {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
-       if (sub_class & 0xC0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (sub_class & 0xC0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "class_code: 0x%x, device_type: 0x%x, sub_class: 0x%x\n",
                class_code, device_type, sub_class);
@@ -1099,16 +1324,21 @@ Retry:
        if (retval != STATUS_SUCCESS) {
                if (ms_card->switch_8bit_fail) {
                        retval = ms_pro_reset_flow(chip, 0);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                } else {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
        retval = ms_read_attribute_info(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
 #ifdef XC_POWERCLASS
        if (CHK_HG8BIT(ms_card))
@@ -1148,8 +1378,10 @@ Retry:
 
 #ifdef SUPPORT_MAGIC_GATE
        retval = mg_set_tpc_para_sub(chip, 0, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 #endif
 
        if (CHK_HG8BIT(ms_card))
@@ -1166,16 +1398,21 @@ static int ms_read_status_reg(struct rtsx_chip *chip)
        u8 val[2];
 
        retval = ms_set_rw_reg_addr(chip, StatusReg0, 2, 0, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_read_bytes(chip, READ_REG, 2, NO_WAIT_INT, val, 2);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val[1] & (STS_UCDT | STS_UCEX | STS_UCFG)) {
                ms_set_err_code(chip, MS_FLASH_READ_ERROR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1191,8 +1428,10 @@ static int ms_read_extra_data(struct rtsx_chip *chip,
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_MS4BIT(ms_card)) {
                /* Parallel interface */
@@ -1213,8 +1452,10 @@ static int ms_read_extra_data(struct rtsx_chip *chip,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -1223,35 +1464,46 @@ static int ms_read_extra_data(struct rtsx_chip *chip,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_CMDNK) {
                ms_set_err_code(chip, MS_CMD_NK);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (val & INT_REG_CED) {
                if (val & INT_REG_ERR) {
                        retval = ms_read_status_reg(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        retval = ms_set_rw_reg_addr(chip, OverwriteFlag,
                                                MS_EXTRA_SIZE, SystemParm, 6);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
        }
 
        retval = ms_read_bytes(chip, READ_REG, MS_EXTRA_SIZE, NO_WAIT_INT,
                        data, MS_EXTRA_SIZE);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (buf && buf_len) {
                if (buf_len > MS_EXTRA_SIZE)
@@ -1269,13 +1521,17 @@ static int ms_write_extra_data(struct rtsx_chip *chip,
        int retval, i;
        u8 val, data[16];
 
-       if (!buf || (buf_len < MS_EXTRA_SIZE))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!buf || (buf_len < MS_EXTRA_SIZE)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 6 + MS_EXTRA_SIZE);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_MS4BIT(ms_card))
                data[0] = 0x88;
@@ -1293,26 +1549,34 @@ static int ms_write_extra_data(struct rtsx_chip *chip,
 
        retval = ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE),
                                NO_WAIT_INT, data, 16);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_CMDNK) {
                ms_set_err_code(chip, MS_CMD_NK);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (val & INT_REG_CED) {
                if (val & INT_REG_ERR) {
                        ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1328,8 +1592,10 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num)
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_MS4BIT(ms_card))
                data[0] = 0x88;
@@ -1343,28 +1609,36 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num)
        data[5] = page_num;
 
        retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_CMDNK) {
                ms_set_err_code(chip, MS_CMD_NK);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (val & INT_REG_CED) {
                if (val & INT_REG_ERR) {
                        if (!(val & INT_REG_BREQ)) {
                                ms_set_err_code(chip,  MS_FLASH_READ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        retval = ms_read_status_reg(chip);
                        if (retval != STATUS_SUCCESS)
@@ -1373,18 +1647,23 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num)
                } else {
                        if (!(val & INT_REG_BREQ)) {
                                ms_set_err_code(chip, MS_BREQ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
        }
 
        retval = ms_transfer_tpc(chip, MS_TM_NORMAL_READ, READ_PAGE_DATA,
                                0, NO_WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (ms_check_err_code(chip, MS_FLASH_WRITE_ERROR)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1397,13 +1676,17 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk)
        u8 val, data[8], extra[MS_EXTRA_SIZE];
 
        retval = ms_read_extra_data(chip, phy_blk, 0, extra, MS_EXTRA_SIZE);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 7);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -1421,27 +1704,35 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk)
        data[7] = 0xFF;
 
        retval = ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT, data, 7);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_CMDNK) {
                ms_set_err_code(chip, MS_CMD_NK);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (val & INT_REG_CED) {
                if (val & INT_REG_ERR) {
                        ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1457,8 +1748,10 @@ static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk)
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -1474,18 +1767,24 @@ static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk)
        data[5] = 0;
 
        retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT, data, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
 ERASE_RTY:
        retval = ms_send_cmd(chip, BLOCK_ERASE, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (val & INT_REG_CMDNK) {
                if (i < 3) {
@@ -1495,13 +1794,15 @@ ERASE_RTY:
 
                ms_set_err_code(chip, MS_CMD_NK);
                ms_set_bad_block(chip, phy_blk);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (val & INT_REG_CED) {
                if (val & INT_REG_ERR) {
                        ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1544,13 +1845,16 @@ static int ms_init_page(struct rtsx_chip *chip, u16 phy_blk, u16 log_blk,
        for (i = start_page; i < end_page; i++) {
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = ms_write_extra_data(chip, phy_blk, i,
                                        extra, MS_EXTRA_SIZE);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1560,7 +1864,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",
@@ -1569,42 +1874,58 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
                start_page, end_page);
 
        retval = ms_read_extra_data(chip, new_blk, 0, extra, MS_EXTRA_SIZE);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_read_status_reg(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, PPBUF_BASE2, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (val & BUF_FULL) {
                retval = ms_send_cmd(chip, CLEAR_BUF, WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (!(val & INT_REG_CED)) {
                        ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
        for (i = start_page; i < end_page; i++) {
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                ms_read_extra_data(chip, old_blk, i, extra, MS_EXTRA_SIZE);
 
                retval = ms_set_rw_reg_addr(chip, OverwriteFlag,
                                        MS_EXTRA_SIZE, SystemParm, 6);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -1621,39 +1942,48 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 
                retval = ms_write_bytes(chip, WRITE_REG, 6, NO_WAIT_INT,
                                        data, 6);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ms_set_err_code(chip, MS_NO_ERROR);
                retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (val & INT_REG_CMDNK) {
                        ms_set_err_code(chip, MS_CMD_NK);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (val & INT_REG_CED) {
                        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,
                                                        MS_TM_NORMAL_READ,
                                                        READ_PAGE_DATA,
                                                        0, NO_WAIT_INT);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
                                if (uncorrect_flag) {
                                        ms_set_page_status(log_blk, setPS_NG,
@@ -1684,13 +2014,16 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
                                        if (retval == STATUS_SUCCESS)
                                                break;
                                }
-                               if (rty_cnt == MS_MAX_RETRY_COUNT)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (rty_cnt == MS_MAX_RETRY_COUNT) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
 
                        if (!(val & INT_REG_BREQ)) {
                                ms_set_err_code(chip, MS_BREQ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1724,35 +2057,45 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 
                retval = ms_write_bytes(chip, WRITE_REG, (6 + MS_EXTRA_SIZE),
                                        NO_WAIT_INT, data, 16);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ms_set_err_code(chip, MS_NO_ERROR);
                retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (val & INT_REG_CMDNK) {
                        ms_set_err_code(chip, MS_CMD_NK);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (val & INT_REG_CED) {
                        if (val & INT_REG_ERR) {
                                ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
                if (i == 0) {
                        retval = ms_set_rw_reg_addr(chip, OverwriteFlag,
                                                MS_EXTRA_SIZE, SystemParm, 7);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -1771,29 +2114,37 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 
                        retval = ms_write_bytes(chip, WRITE_REG, 7,
                                                NO_WAIT_INT, data, 8);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        ms_set_err_code(chip, MS_NO_ERROR);
                        retval = ms_read_bytes(chip, GET_INT, 1,
                                        NO_WAIT_INT, &val, 1);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if (val & INT_REG_CMDNK) {
                                ms_set_err_code(chip, MS_CMD_NK);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        if (val & INT_REG_CED) {
                                if (val & INT_REG_ERR) {
                                        ms_set_err_code(chip,
                                                        MS_FLASH_WRITE_ERROR);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        }
                }
@@ -1814,20 +2165,30 @@ static int reset_ms(struct rtsx_chip *chip)
 #endif
 
        retval = ms_prepare_reset(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_card->ms_type |= TYPE_MS;
 
        retval = ms_send_cmd(chip, MS_RESET, NO_WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_read_status_reg(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, PPBUF_BASE2, &val);
+       retval = rtsx_read_register(chip, PPBUF_BASE2, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (val & WRT_PRTCT)
                chip->card_wp |= MS_CARD;
        else
@@ -1840,7 +2201,8 @@ RE_SEARCH:
        while (i < (MAX_DEFECTIVE_BLOCK + 2)) {
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = ms_read_extra_data(chip, i, 0, extra, MS_EXTRA_SIZE);
@@ -1860,7 +2222,8 @@ RE_SEARCH:
 
        if (i == (MAX_DEFECTIVE_BLOCK + 2)) {
                dev_dbg(rtsx_dev(chip), "No boot block found!");
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        for (j = 0; j < 3; j++) {
@@ -1875,8 +2238,10 @@ RE_SEARCH:
        }
 
        retval = ms_read_page(chip, ms_card->boot_block, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* Read MS system information as sys_info */
        rtsx_init_cmd(chip);
@@ -1885,8 +2250,10 @@ RE_SEARCH:
                rtsx_add_cmd(chip, READ_REG_CMD, PPBUF_BASE2 + 0x1A0 + i, 0, 0);
 
        retval = rtsx_send_cmd(chip, MS_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = rtsx_get_cmd_data(chip);
        memcpy(ms_card->raw_sys_info, ptr, 96);
@@ -1908,8 +2275,10 @@ RE_SEARCH:
        rtsx_add_cmd(chip, READ_REG_CMD, MS_4bit_Support, 0, 0);
 
        retval = rtsx_send_cmd(chip, MS_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = rtsx_get_cmd_data(chip);
 
@@ -1982,19 +2351,36 @@ RE_SEARCH:
        /* Switch I/F Mode */
        if (ptr[15]) {
                retval = ms_set_rw_reg_addr(chip, 0, 0, SystemParm, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
-               RTSX_WRITE_REG(chip, PPBUF_BASE2, 0xFF, 0x88);
-               RTSX_WRITE_REG(chip, PPBUF_BASE2 + 1, 0xFF, 0);
+               retval = rtsx_write_register(chip, PPBUF_BASE2, 0xFF, 0x88);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, PPBUF_BASE2 + 1, 0xFF, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                retval = ms_transfer_tpc(chip, MS_TM_WRITE_BYTES, WRITE_REG, 1,
                                        NO_WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
-               RTSX_WRITE_REG(chip, MS_CFG, 0x58 | MS_NO_CHECK_INT,
-                       MS_BUS_WIDTH_4 | PUSH_TIME_ODD | MS_NO_CHECK_INT);
+               retval = rtsx_write_register(chip, MS_CFG,
+                                            0x58 | MS_NO_CHECK_INT,
+                                            MS_BUS_WIDTH_4 | PUSH_TIME_ODD | MS_NO_CHECK_INT);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                ms_card->ms_type |= MS_4BIT;
        }
@@ -2020,29 +2406,41 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip)
 
        size = ms_card->segment_cnt * sizeof(struct zone_entry);
        ms_card->segment = vzalloc(size);
-       if (ms_card->segment == NULL)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (ms_card->segment == NULL) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_read_page(chip, ms_card->boot_block, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, INIT_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto INIT_FAIL;
+       }
 
        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);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto INIT_FAIL;
+               }
 
                retval = rtsx_read_register(chip, reg_addr++, &val2);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, INIT_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto INIT_FAIL;
+               }
 
                defect_block = ((u16)val1 << 8) | val2;
                if (defect_block == 0xFFFF)
                        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,16 +2585,19 @@ 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);
 
        if (ms_card->segment == NULL) {
                retval = ms_init_l2p_tbl(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, retval);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        if (ms_card->segment[seg_no].build_flag) {
@@ -2214,15 +2615,19 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 
        if (segment->l2p_table == NULL) {
                segment->l2p_table = vmalloc(table_size * 2);
-               if (segment->l2p_table == NULL)
-                       TRACE_GOTO(chip, BUILD_FAIL);
+               if (segment->l2p_table == NULL) {
+                       rtsx_trace(chip);
+                       goto BUILD_FAIL;
+               }
        }
        memset((u8 *)(segment->l2p_table), 0xff, table_size * 2);
 
        if (segment->free_table == NULL) {
                segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2);
-               if (segment->free_table == NULL)
-                       TRACE_GOTO(chip, BUILD_FAIL);
+               if (segment->free_table == NULL) {
+                       rtsx_trace(chip);
+                       goto BUILD_FAIL;
+               }
        }
        memset((u8 *)(segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2);
 
@@ -2236,10 +2641,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 +2704,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,17 +2743,20 @@ 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;
                                return STATUS_SUCCESS;
                        }
                        retval = ms_init_page(chip, phy_blk, log_blk, 0, 1);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_GOTO(chip, BUILD_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               goto 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;
@@ -2374,14 +2784,18 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
                                phy_blk = ms_get_unused_block(chip, 0);
                                retval = ms_copy_page(chip, tmp_blk, phy_blk,
                                                log_blk, 0, ms_card->page_off + 1);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
                                segment->l2p_table[log_blk] = phy_blk;
 
                                retval = ms_set_bad_block(chip, tmp_blk);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
                }
        }
@@ -2411,12 +2825,16 @@ int reset_ms_card(struct rtsx_chip *chip)
        memset(ms_card, 0, sizeof(struct ms_info));
 
        retval = enable_card_clock(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = select_card(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_card->ms_type = 0;
 
@@ -2424,24 +2842,31 @@ int reset_ms_card(struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                if (ms_card->check_ms_flow) {
                        retval = reset_ms(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                } else {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
        retval = ms_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!CHK_MSPRO(ms_card)) {
                /* Build table for the last segment,
                 * to check if L2P table block exists, erasing it
                 */
                retval = ms_build_l2p_tbl(chip, ms_card->total_block / 512 - 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        dev_dbg(rtsx_dev(chip), "ms_card->ms_type = 0x%x\n", ms_card->ms_type);
@@ -2470,8 +2895,10 @@ static int mspro_set_rw_cmd(struct rtsx_chip *chip,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -2511,8 +2938,10 @@ static inline int ms_auto_tune_clock(struct rtsx_chip *chip)
        }
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -2522,7 +2951,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 +2977,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) {
@@ -2560,15 +2990,21 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
        }
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (srb->sc_data_direction == DMA_FROM_DEVICE)
                trans_mode = MS_TM_AUTO_READ;
        else
                trans_mode = MS_TM_AUTO_WRITE;
 
-       RTSX_READ_REG(chip, MS_TRANS_CFG, &val);
+       retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (ms_card->seq_mode) {
                if ((ms_card->pre_dir != srb->sc_data_direction)
@@ -2581,8 +3017,10 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                        ms_card->total_sec_cnt = 0;
                        if (val & MS_INT_BREQ) {
                                retval = ms_send_cmd(chip, PRO_STOP, WAIT_INT);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
                                rtsx_write_register(chip, RBCTL, RB_FLUSH, RB_FLUSH);
                        }
@@ -2609,7 +3047,8 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                retval = mspro_set_rw_cmd(chip, start_sector, count, rw_cmd);
                if (retval != STATUS_SUCCESS) {
                        ms_card->seq_mode = 0;
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -2624,7 +3063,8 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        chip->rw_need_retry = 0;
                        dev_dbg(rtsx_dev(chip), "No card exist, exit mspro_rw_multi_sector\n");
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (val & MS_INT_BREQ)
@@ -2636,7 +3076,8 @@ static int mspro_rw_multi_sector(struct scsi_cmnd *srb,
                        ms_auto_tune_clock(chip);
                }
 
-               TRACE_RET(chip, retval);
+               rtsx_trace(chip);
+               return retval;
        }
 
        if (ms_card->seq_mode) {
@@ -2664,13 +3105,15 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
        retval = ms_switch_clock(chip);
        if (retval != STATUS_SUCCESS) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp);
        if (retval != STATUS_SUCCESS) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (!(tmp & MS_INT_BREQ)) {
@@ -2679,7 +3122,8 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
                        return STATUS_SUCCESS;
                }
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (short_data_len >= 256)
@@ -2691,14 +3135,16 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
                                MS_NO_CHECK_INT);
        if (retval != STATUS_SUCCESS) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = ms_read_bytes(chip, PRO_READ_SHORT_DATA, cnt, WAIT_INT,
                        data, 8);
        if (retval != STATUS_SUCCESS) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        total_progress = (data[0] << 24) | (data[1] << 16) |
@@ -2723,7 +3169,8 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
                retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp);
                if (retval != STATUS_SUCCESS) {
                        ms_card->format_status = FORMAT_FAIL;
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                if (tmp & (MS_INT_CED | MS_INT_CMDNK |
                                MS_INT_BREQ | MS_INT_ERR))
@@ -2735,17 +3182,20 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
        retval = rtsx_write_register(chip, MS_CFG, MS_NO_CHECK_INT, 0);
        if (retval != STATUS_SUCCESS) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (i == 5000) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) {
                ms_card->format_status = FORMAT_FAIL;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (tmp & MS_INT_CED) {
@@ -2756,7 +3206,8 @@ static int mspro_read_format_progress(struct rtsx_chip *chip,
        } else {
                ms_card->format_status = FORMAT_FAIL;
                ms_card->pro_under_formatting = 0;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -2780,7 +3231,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;
@@ -2788,12 +3239,16 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
        u16 para;
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, Pro_TPCParm, 0x01);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        memset(buf, 0, 2);
        switch (short_data_len) {
@@ -2818,8 +3273,10 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (quick_format)
                para = 0x0000;
@@ -2827,13 +3284,21 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                para = 0x0001;
 
        retval = mspro_set_rw_cmd(chip, 0, para, PRO_FORMAT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, MS_TRANS_CFG, &tmp);
+       retval = rtsx_read_register(chip, MS_TRANS_CFG, &tmp);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
-       if (tmp & (MS_INT_CMDNK | MS_INT_ERR))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (tmp & (MS_INT_CMDNK | MS_INT_ERR)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if ((tmp & (MS_INT_BREQ | MS_INT_CED)) == MS_INT_BREQ) {
                ms_card->pro_under_formatting = 1;
@@ -2850,7 +3315,8 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                return STATUS_SUCCESS;
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 
@@ -2869,14 +3335,17 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk,
        if (retval == STATUS_SUCCESS) {
                if ((extra[1] & 0x30) != 0x30) {
                        ms_set_err_code(chip, MS_FLASH_READ_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_MS4BIT(ms_card))
                data[0] = 0x88;
@@ -2895,14 +3364,18 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
 
        retval = ms_send_cmd(chip, BLOCK_READ, WAIT_INT);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = buf;
 
@@ -2911,16 +3384,20 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk,
 
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (val & INT_REG_CMDNK) {
                        ms_set_err_code(chip, MS_CMD_NK);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                if (val & INT_REG_ERR) {
                        if (val & INT_REG_BREQ) {
@@ -2933,34 +3410,42 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk,
                                                                page_addr, extra, MS_EXTRA_SIZE);
                                        }
                                        ms_set_err_code(chip, MS_FLASH_READ_ERROR);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        } else {
                                ms_set_err_code(chip, MS_FLASH_READ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                } else {
                        if (!(val & INT_REG_BREQ)) {
                                ms_set_err_code(chip, MS_BREQ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
                if (page_addr == (end_page - 1)) {
                        if (!(val & INT_REG_CED)) {
                                retval = ms_send_cmd(chip, BLOCK_END, WAIT_INT);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
 
                        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT,
                                        &val, 1);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if (!(val & INT_REG_CED)) {
                                ms_set_err_code(chip, MS_FLASH_READ_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        trans_cfg = NO_WAIT_INT;
@@ -2993,19 +3478,22 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk,
                        if (retval == -ETIMEDOUT) {
                                ms_set_err_code(chip, MS_TO_ERROR);
                                rtsx_clear_ms_error(chip);
-                               TRACE_RET(chip, STATUS_TIMEDOUT);
+                               rtsx_trace(chip);
+                               return STATUS_TIMEDOUT;
                        }
 
                        retval = rtsx_read_register(chip, MS_TRANS_CFG, &val);
                        if (retval != STATUS_SUCCESS) {
                                ms_set_err_code(chip, MS_TO_ERROR);
                                rtsx_clear_ms_error(chip);
-                               TRACE_RET(chip, STATUS_TIMEDOUT);
+                               rtsx_trace(chip);
+                               return STATUS_TIMEDOUT;
                        }
                        if (val & (MS_CRC16_ERR | MS_RDY_TIMEOUT)) {
                                ms_set_err_code(chip, MS_CRC16_ERROR);
                                rtsx_clear_ms_error(chip);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -3029,8 +3517,10 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
        if (!start_page) {
                retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                        SystemParm, 7);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (CHK_MS4BIT(ms_card))
                        data[0] = 0x88;
@@ -3047,24 +3537,32 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
 
                retval = ms_write_bytes(chip, WRITE_REG, 7, NO_WAIT_INT,
                                        data, 8);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ms_set_err_code(chip, MS_NO_ERROR);
                retval = ms_transfer_tpc(chip, MS_TM_READ_BYTES, GET_INT, 1,
                                        NO_WAIT_INT);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE,
                                SystemParm, (6 + MS_EXTRA_SIZE));
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ms_set_err_code(chip, MS_NO_ERROR);
 
@@ -3096,20 +3594,26 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        for (i = 0; i < MS_MAX_RETRY_COUNT; i++) {
                retval = ms_send_cmd(chip, BLOCK_WRITE, WAIT_INT);
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = buf;
        for (page_addr = start_page; page_addr < end_page; page_addr++) {
@@ -3117,20 +3621,24 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
 
                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                        ms_set_err_code(chip, MS_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (val & INT_REG_CMDNK) {
                        ms_set_err_code(chip, MS_CMD_NK);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                if (val & INT_REG_ERR) {
                        ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                if (!(val & INT_REG_BREQ)) {
                        ms_set_err_code(chip, MS_BREQ_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                udelay(30);
@@ -3161,34 +3669,43 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
                        ms_set_err_code(chip, MS_TO_ERROR);
                        rtsx_clear_ms_error(chip);
 
-                       if (retval == -ETIMEDOUT)
-                               TRACE_RET(chip, STATUS_TIMEDOUT);
-                       else
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval == -ETIMEDOUT) {
+                               rtsx_trace(chip);
+                               return STATUS_TIMEDOUT;
+                       }
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = ms_read_bytes(chip, GET_INT, 1, NO_WAIT_INT, &val, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if ((end_page - start_page) == 1) {
                        if (!(val & INT_REG_CED)) {
                                ms_set_err_code(chip, MS_FLASH_WRITE_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                } else {
                        if (page_addr == (end_page - 1)) {
                                if (!(val & INT_REG_CED)) {
                                        retval = ms_send_cmd(chip, BLOCK_END,
                                                        WAIT_INT);
-                                       if (retval != STATUS_SUCCESS)
-                                               TRACE_RET(chip, STATUS_FAIL);
+                                       if (retval != STATUS_SUCCESS) {
+                                               rtsx_trace(chip);
+                                               return STATUS_FAIL;
+                                       }
                                }
 
                                retval = ms_read_bytes(chip, GET_INT, 1,
                                                NO_WAIT_INT, &val, 1);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
 
                        if ((page_addr == (end_page - 1)) ||
@@ -3196,7 +3713,8 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk,
                                if (!(val & INT_REG_CED)) {
                                        ms_set_err_code(chip,
                                                        MS_FLASH_WRITE_ERROR);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        }
                }
@@ -3217,8 +3735,10 @@ static int ms_finish_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 
        retval = ms_copy_page(chip, old_blk, new_blk, log_blk,
                        page_off, ms_card->page_off + 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        seg_no = old_blk >> 9;
 
@@ -3244,8 +3764,10 @@ static int ms_prepare_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
        if (start_page) {
                retval = ms_copy_page(chip, old_blk, new_blk, log_blk,
                                0, start_page);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -3260,8 +3782,10 @@ int ms_delay_write(struct rtsx_chip *chip)
 
        if (delay_write->delay_write_flag) {
                retval = ms_set_init_para(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                delay_write->delay_write_flag = 0;
                retval = ms_finish_write(chip,
@@ -3269,8 +3793,10 @@ int ms_delay_write(struct rtsx_chip *chip)
                                        delay_write->new_phyblock,
                                        delay_write->logblock,
                                        delay_write->pageoff);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -3309,7 +3835,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
        retval = ms_switch_clock(chip);
        if (retval != STATUS_SUCCESS) {
                ms_rw_fail(srb, chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        log_blk = (u16)(start_sector >> ms_card->block_shift);
@@ -3325,7 +3852,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (retval != STATUS_SUCCESS) {
                        chip->card_fail |= MS_CARD;
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -3342,7 +3870,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        old_blk = delay_write->old_phyblock;
                        new_blk = delay_write->new_phyblock;
@@ -3357,7 +3886,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 #endif
                        old_blk = ms_get_l2p_tbl(chip, seg_no,
@@ -3366,7 +3896,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if ((old_blk == 0xFFFF) || (new_blk == 0xFFFF)) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = ms_prepare_write(chip, old_blk, new_blk,
@@ -3375,11 +3906,13 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                                        set_sense_type(chip, lun,
                                                SENSE_TYPE_MEDIA_NOT_PRESENT);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 #ifdef MS_DELAY_WRITE
                }
@@ -3391,11 +3924,13 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
                old_blk = ms_get_l2p_tbl(chip, seg_no,
@@ -3403,7 +3938,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (old_blk == 0xFFFF) {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -3436,10 +3972,12 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        ms_rw_fail(srb, chip);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (srb->sc_data_direction == DMA_TO_DEVICE) {
@@ -3475,7 +4013,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                chip->card_fail |= MS_CARD;
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -3483,14 +4022,16 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                        log_blk - ms_start_idx[seg_no]);
                if (old_blk == 0xFFFF) {
                        ms_rw_fail(srb, chip);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (srb->sc_data_direction == DMA_TO_DEVICE) {
                        new_blk = ms_get_unused_block(chip, seg_no);
                        if (new_blk == 0xFFFF) {
                                ms_rw_fail(srb, chip);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -3515,11 +4056,13 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                if (detect_card_cd(chip, MS_CARD) != STATUS_SUCCESS) {
                                        set_sense_type(chip, lun,
                                                SENSE_TYPE_MEDIA_NOT_PRESENT);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
 
                                ms_rw_fail(srb, chip);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 #endif
                }
@@ -3581,12 +4124,16 @@ static int ms_poll_int(struct rtsx_chip *chip)
        rtsx_add_cmd(chip, CHECK_REG_CMD, MS_TRANS_CFG, MS_INT_CED, MS_INT_CED);
 
        retval = rtsx_send_cmd(chip, MS_CARD, 5000);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        val = *rtsx_get_cmd_data(chip);
-       if (val & MS_INT_ERR)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (val & MS_INT_ERR) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -3649,12 +4196,15 @@ static int mg_send_ex_cmd(struct rtsx_chip *chip, u8 cmd, u8 entry_num)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (i == MS_MAX_RETRY_COUNT)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == MS_MAX_RETRY_COUNT) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (check_ms_err(chip)) {
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -3671,8 +4221,10 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type,
        else
                retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6);
 
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf[0] = 0;
        buf[1] = 0;
@@ -3684,8 +4236,10 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type,
        }
        retval = ms_write_bytes(chip, PRO_WRITE_REG, (type == 0) ? 1 : 6,
                                NO_WAIT_INT, buf, 6);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -3699,19 +4253,23 @@ int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (scsi_bufflen(srb) < 12) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = mg_send_ex_cmd(chip, MG_SET_LID, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        memset(buf1, 0, 32);
@@ -3723,12 +4281,14 @@ int mg_set_leaf_id(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                buf1, 32);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -3744,12 +4304,16 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf = kmalloc(1540, GFP_KERNEL);
-       if (!buf)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        buf[0] = 0x04;
        buf[1] = 0x1A;
@@ -3759,7 +4323,8 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = mg_send_ex_cmd(chip, MG_GET_LEKB, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_GOTO(chip, GetEKBFinish);
+               rtsx_trace(chip);
+               goto GetEKBFinish;
        }
 
        retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA,
@@ -3767,12 +4332,14 @@ int mg_get_local_EKB(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
                rtsx_clear_ms_error(chip);
-               TRACE_GOTO(chip, GetEKBFinish);
+               rtsx_trace(chip);
+               goto GetEKBFinish;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        bufflen = min_t(int, 1052, scsi_bufflen(srb));
@@ -3795,25 +4362,30 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = mg_send_ex_cmd(chip, MG_GET_ID, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT,
                        buf, 32);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        memcpy(ms_card->magic_gate_id, buf, 16);
@@ -3822,14 +4394,16 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = ms_poll_int(chip);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 #endif
 
        retval = mg_send_ex_cmd(chip, MG_SET_RD, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        bufflen = min_t(int, 12, scsi_bufflen(srb));
@@ -3845,12 +4419,14 @@ int mg_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                32, WAIT_INT, buf, 32);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        ms_card->mg_auth = 0;
@@ -3869,25 +4445,30 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = mg_send_ex_cmd(chip, MG_MAKE_RMS, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = ms_read_bytes(chip, PRO_READ_SHORT_DATA, 32, WAIT_INT,
                        buf1, 32);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        buf2[0] = 0x00;
@@ -3905,7 +4486,8 @@ int mg_get_rsp_chg(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = ms_poll_int(chip);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 #endif
 
@@ -3924,13 +4506,16 @@ int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = mg_send_ex_cmd(chip, MG_MAKE_KSE, 0);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        bufflen = min_t(int, 12, scsi_bufflen(srb));
@@ -3946,12 +4531,14 @@ int mg_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                buf, 32);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        ms_card->mg_auth = 1;
@@ -3970,12 +4557,16 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf = kmalloc(1028, GFP_KERNEL);
-       if (!buf)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        buf[0] = 0x04;
        buf[1] = 0x02;
@@ -3985,7 +4576,8 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = mg_send_ex_cmd(chip, MG_GET_IBD, ms_card->mg_entry_num);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_GOTO(chip, GetICVFinish);
+               rtsx_trace(chip);
+               goto GetICVFinish;
        }
 
        retval = ms_transfer_data(chip, MS_TM_AUTO_READ, PRO_READ_LONG_DATA,
@@ -3993,12 +4585,14 @@ int mg_get_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
                rtsx_clear_ms_error(chip);
-               TRACE_GOTO(chip, GetICVFinish);
+               rtsx_trace(chip);
+               goto GetICVFinish;
        }
        if (check_ms_err(chip)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
                rtsx_clear_ms_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        bufflen = min_t(int, 1028, scsi_bufflen(srb));
@@ -4023,12 +4617,16 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        ms_cleanup_work(chip);
 
        retval = ms_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        buf = kmalloc(1028, GFP_KERNEL);
-       if (!buf)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        bufflen = min_t(int, 1028, scsi_bufflen(srb));
        rtsx_stor_get_xfer_buf(buf, bufflen, srb);
@@ -4045,7 +4643,8 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                } else {
                        set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR);
                }
-               TRACE_GOTO(chip, SetICVFinish);
+               rtsx_trace(chip);
+               goto SetICVFinish;
        }
 
 #ifdef MG_SET_ICV_SLOW
@@ -4084,7 +4683,8 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                        SENSE_TYPE_MG_WRITE_ERR);
                        }
                        retval = STATUS_FAIL;
-                       TRACE_GOTO(chip, SetICVFinish);
+                       rtsx_trace(chip);
+                       goto SetICVFinish;
                }
        }
 #else
@@ -4102,7 +4702,8 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                } else {
                        set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR);
                }
-               TRACE_GOTO(chip, SetICVFinish);
+               rtsx_trace(chip);
+               goto SetICVFinish;
        }
 #endif
 
@@ -4142,22 +4743,37 @@ int ms_power_off_card3v3(struct rtsx_chip *chip)
        int retval;
 
        retval = disable_card_clock(chip, MS_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (chip->asic_code) {
                retval = ms_pull_ctl_disable(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               RTSX_WRITE_REG(chip, FPGA_PULL_CTL,
-                       FPGA_MS_PULL_CTL_BIT | 0x20, FPGA_MS_PULL_CTL_BIT);
+               retval = rtsx_write_register(chip, FPGA_PULL_CTL,
+                                            FPGA_MS_PULL_CTL_BIT | 0x20,
+                                            FPGA_MS_PULL_CTL_BIT);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
+       retval = rtsx_write_register(chip, CARD_OE, MS_OUTPUT_EN, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
        }
-       RTSX_WRITE_REG(chip, CARD_OE, MS_OUTPUT_EN, 0);
        if (!chip->ft2_fast_mode) {
                retval = card_power_off(chip, MS_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -4185,8 +4801,10 @@ int release_ms_card(struct rtsx_chip *chip)
 #endif
 
        retval = ms_power_off_card3v3(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
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..d64b6ed9c0c967eb725a8911bc04138e6d25430d 100644 (file)
 #include <linux/workqueue.h>
 
 #include "rtsx.h"
-#include "rtsx_chip.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
-#include "general.h"
-
 #include "ms.h"
 #include "sd.h"
 #include "xd.h"
@@ -137,8 +131,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 +1030,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 +1042,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 9e6ecb7457b502d45a76dee849e7570dc1b63421..262441bcfc41ab5f0b2a5c9bacbd11081ad88fd7 100644 (file)
@@ -46,9 +46,6 @@
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_host.h>
 
-#include "trace.h"
-#include "general.h"
-
 #define CR_DRIVER_NAME         "rts5208"
 
 #define pci_get_bus_and_slot(bus, devfn)       \
@@ -181,4 +178,14 @@ enum xfer_buf_dir  {TO_XFER_BUF, FROM_XFER_BUF};
 
 int rtsx_read_pci_cfg_byte(u8 bus, u8 dev, u8 func, u8 offset, u8 *val);
 
+#define _MSG_TRACE
+
+#include "trace.h"
+#include "rtsx_chip.h"
+#include "rtsx_transport.h"
+#include "rtsx_scsi.h"
+#include "rtsx_card.h"
+#include "rtsx_sys.h"
+#include "general.h"
+
 #endif  /* __REALTEK_RTSX_H */
index b4595ab3f02b18c0d9e376fd68013b9a04069155..437436f5dbdd33f8d4b8b8b75094190954fe44d6 100644 (file)
 #include <linux/kernel.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
-
-#include "rtsx_sys.h"
-#include "general.h"
-
 #include "sd.h"
 #include "xd.h"
 #include "ms.h"
@@ -657,8 +650,10 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
        dev_dbg(rtsx_dev(chip), "Switch SSC clock to %dMHz (cur_clk = %d)\n",
                clk, chip->cur_clk);
 
-       if ((clk <= 2) || (N > max_N))
-               TRACE_RET(chip, STATUS_FAIL);
+       if ((clk <= 2) || (N > max_N)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        mcu_cnt = (u8)(125/clk + 3);
        if (mcu_cnt > 7)
@@ -697,11 +692,17 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
        }
 
        retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        udelay(10);
-       RTSX_WRITE_REG(chip, CLK_CTL, CLK_LOW_FREQ, 0);
+       retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        chip->cur_clk = clk;
 
@@ -710,6 +711,7 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
 
 int switch_normal_clock(struct rtsx_chip *chip, int clk)
 {
+       int retval;
        u8 sel, div, mcu_cnt;
        int sd_vpclk_phase_reset = 0;
 
@@ -790,26 +792,62 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
        default:
                dev_dbg(rtsx_dev(chip), "Try to switch to an illegal clock (%d)\n",
                        clk);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_WRITE_REG(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
+       retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (sd_vpclk_phase_reset) {
-               RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0);
-               RTSX_WRITE_REG(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET, 0);
+               retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
+                                            PHASE_NOT_RESET, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
+                                            PHASE_NOT_RESET, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
+       retval = rtsx_write_register(chip, CLK_DIV, 0xFF,
+                                    (div << 4) | mcu_cnt);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
        }
-       RTSX_WRITE_REG(chip, CLK_DIV, 0xFF, (div << 4) | mcu_cnt);
-       RTSX_WRITE_REG(chip, CLK_SEL, 0xFF, sel);
 
        if (sd_vpclk_phase_reset) {
                udelay(200);
-               RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET,
-                               PHASE_NOT_RESET);
-               RTSX_WRITE_REG(chip, SD_VPCLK1_CTL, PHASE_NOT_RESET,
-                               PHASE_NOT_RESET);
+               retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
+                                            PHASE_NOT_RESET, PHASE_NOT_RESET);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
+                                            PHASE_NOT_RESET, PHASE_NOT_RESET);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                udelay(200);
        }
-       RTSX_WRITE_REG(chip, CLK_CTL, 0xFF, 0);
+       retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        chip->cur_clk = clk;
 
@@ -844,6 +882,7 @@ void trans_dma_enable(enum dma_data_direction dir, struct rtsx_chip *chip,
 
 int enable_card_clock(struct rtsx_chip *chip, u8 card)
 {
+       int retval;
        u8 clk_en = 0;
 
        if (card & XD_CARD)
@@ -853,13 +892,18 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card)
        if (card & MS_CARD)
                clk_en |= MS_CLK_EN;
 
-       RTSX_WRITE_REG(chip, CARD_CLK_EN, clk_en, clk_en);
+       retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
 
 int disable_card_clock(struct rtsx_chip *chip, u8 card)
 {
+       int retval;
        u8 clk_en = 0;
 
        if (card & XD_CARD)
@@ -869,7 +913,11 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card)
        if (card & MS_CARD)
                clk_en |= MS_CLK_EN;
 
-       RTSX_WRITE_REG(chip, CARD_CLK_EN, clk_en, 0);
+       retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -893,8 +941,10 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
        rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        udelay(chip->pmos_pwr_on_interval);
 
@@ -902,14 +952,17 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
        rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
 
 int card_power_off(struct rtsx_chip *chip, u8 card)
 {
+       int retval;
        u8 mask, val;
 
        if (CHECK_LUN_MODE(chip, SD_MS_2LUN) && (card == MS_CARD)) {
@@ -920,7 +973,11 @@ int card_power_off(struct rtsx_chip *chip, u8 card)
                val = SD_POWER_OFF;
        }
 
-       RTSX_WRITE_REG(chip, CARD_PWR_CTL, mask, val);
+       retval = rtsx_write_register(chip, CARD_PWR_CTL, mask, val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -932,8 +989,10 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
        unsigned int lun = SCSI_LUN(srb);
        int i;
 
-       if (chip->rw_card[lun] == NULL)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (chip->rw_card[lun] == NULL) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        for (i = 0; i < 3; i++) {
                chip->rw_need_retry = 0;
@@ -942,11 +1001,14 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (retval != STATUS_SUCCESS) {
                        if (rtsx_check_chip_exist(chip) != STATUS_SUCCESS) {
                                rtsx_release_chip(chip);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (detect_card_cd(chip, chip->cur_card) !=
-                                                       STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                                                       STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if (!chip->rw_need_retry) {
                                dev_dbg(rtsx_dev(chip), "RW fail, but no need to retry\n");
@@ -965,6 +1027,7 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
 
 int card_share_mode(struct rtsx_chip *chip, int card)
 {
+       int retval;
        u8 mask, value;
 
        if (CHECK_PID(chip, 0x5208)) {
@@ -975,8 +1038,10 @@ int card_share_mode(struct rtsx_chip *chip, int card)
                        value = CARD_SHARE_48_MS;
                else if (card == XD_CARD)
                        value = CARD_SHARE_48_XD;
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
        } else if (CHECK_PID(chip, 0x5288)) {
                mask = 0x03;
@@ -986,14 +1051,21 @@ int card_share_mode(struct rtsx_chip *chip, int card)
                        value = CARD_SHARE_BAROSSA_MS;
                else if (card == XD_CARD)
                        value = CARD_SHARE_BAROSSA_XD;
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_WRITE_REG(chip, CARD_SHARE_MODE, mask, value);
+       retval = rtsx_write_register(chip, CARD_SHARE_MODE, mask, value);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1014,15 +1086,23 @@ int select_card(struct rtsx_chip *chip, int card)
                        mod = XD_MOD_SEL;
                else if (card == SPI_CARD)
                        mod = SPI_MOD_SEL;
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
-               RTSX_WRITE_REG(chip, CARD_SELECT, 0x07, mod);
+               retval = rtsx_write_register(chip, CARD_SELECT, 0x07, mod);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                chip->cur_card = card;
 
                retval =  card_share_mode(chip, card);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1067,12 +1147,15 @@ int detect_card_cd(struct rtsx_chip *chip, int card)
                card_cd = XD_EXIST;
        } else {
                dev_dbg(rtsx_dev(chip), "Wrong card type: 0x%x\n", card);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        status = rtsx_readl(chip, RTSX_BIPR);
-       if (!(status & card_cd))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!(status & card_cd)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
index 75cf5889bda4ec42172038f2ef8c52f883233c12..8f2cf9a4ec69b52f878174e29d2ecf175a5dd55f 100644 (file)
@@ -1061,7 +1061,13 @@ int card_power_off(struct rtsx_chip *chip, u8 card);
 
 static inline int card_power_off_all(struct rtsx_chip *chip)
 {
-       RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0x0F, 0x0F);
+       int retval;
+
+       retval = rtsx_write_register(chip, CARD_PWR_CTL, 0x0F, 0x0F);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
index 9593d8132938ee334ad3ec4dc5d9704c07ae4863..0c1716ebc827477ccd041389d2e64932a9c02642 100644 (file)
 #include <linux/vmalloc.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
-#include "rtsx_chip.h"
-#include "rtsx_sys.h"
-#include "general.h"
-
 #include "sd.h"
 #include "xd.h"
 #include "ms.h"
@@ -123,22 +116,46 @@ void rtsx_disable_bus_int(struct rtsx_chip *chip)
 
 static int rtsx_pre_handle_sdio_old(struct rtsx_chip *chip)
 {
+       int retval;
+
        if (chip->ignore_sd && CHK_SDIO_EXIST(chip)) {
                if (chip->asic_code) {
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF,
-                                      MS_INS_PU | SD_WP_PU |
-                                      SD_CD_PU | SD_CMD_PU);
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL5,
+                                                    0xFF,
+                                                    MS_INS_PU | SD_WP_PU | SD_CD_PU | SD_CMD_PU);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                } else {
-                       RTSX_WRITE_REG(chip, FPGA_PULL_CTL, 0xFF,
-                                      FPGA_SD_PULL_CTL_EN);
+                       retval = rtsx_write_register(chip, FPGA_PULL_CTL,
+                                                    0xFF,
+                                                    FPGA_SD_PULL_CTL_EN);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+               }
+               retval = rtsx_write_register(chip, CARD_SHARE_MODE, 0xFF,
+                                            CARD_SHARE_48_SD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
                }
-               RTSX_WRITE_REG(chip, CARD_SHARE_MODE, 0xFF, CARD_SHARE_48_SD);
 
                /* Enable SDIO internal clock */
-               RTSX_WRITE_REG(chip, 0xFF2C, 0x01, 0x01);
+               retval = rtsx_write_register(chip, 0xFF2C, 0x01, 0x01);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
-               RTSX_WRITE_REG(chip, SDIO_CTRL, 0xFF,
-                              SDIO_BUS_CTRL | SDIO_CD_CTRL);
+               retval = rtsx_write_register(chip, SDIO_CTRL, 0xFF,
+                                            SDIO_BUS_CTRL | SDIO_CD_CTRL);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                chip->sd_int = 1;
                chip->sd_io = 1;
@@ -153,22 +170,30 @@ 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);
+                       retval = rtsx_read_register(chip, 0xFE5A, &tmp);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        if (tmp & 0x08)
-                               sw_bypass_sd = 1;
+                               sw_bypass_sd = true;
                } else if (CHECK_PID(chip, 0x5208)) {
-                       RTSX_READ_REG(chip, 0xFE70, &tmp);
+                       retval = rtsx_read_register(chip, 0xFE70, &tmp);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        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);
@@ -180,17 +205,37 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
        if (sw_bypass_sd) {
                u8 cd_toggle_mask = 0;
 
-               RTSX_READ_REG(chip, TLPTISTAT, &tmp);
+               retval = rtsx_read_register(chip, TLPTISTAT, &tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                cd_toggle_mask = 0x08;
 
                if (tmp & cd_toggle_mask) {
                        /* Disable sdio_bus_auto_switch */
-                       if (CHECK_PID(chip, 0x5288))
-                               RTSX_WRITE_REG(chip, 0xFE5A, 0x08, 0x00);
-                       else if (CHECK_PID(chip, 0x5208))
-                               RTSX_WRITE_REG(chip, 0xFE70, 0x80, 0x00);
+                       if (CHECK_PID(chip, 0x5288)) {
+                               retval = rtsx_write_register(chip, 0xFE5A,
+                                                            0x08, 0x00);
+                               if (retval) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
+                       } else if (CHECK_PID(chip, 0x5208)) {
+                               retval = rtsx_write_register(chip, 0xFE70,
+                                                            0x80, 0x00);
+                               if (retval) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
+                       }
 
-                       RTSX_WRITE_REG(chip, TLPTISTAT, 0xFF, tmp);
+                       retval = rtsx_write_register(chip, TLPTISTAT, 0xFF,
+                                                    tmp);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
 
                        chip->need_reset |= SD_CARD;
                } else {
@@ -198,27 +243,52 @@ static int rtsx_pre_handle_sdio_new(struct rtsx_chip *chip)
 
                        if (chip->asic_code) {
                                retval = sd_pull_ctl_enable(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        } else {
-                               RTSX_WRITE_REG(chip, FPGA_PULL_CTL,
-                                              FPGA_SD_PULL_CTL_BIT | 0x20, 0);
+                               retval = rtsx_write_register(chip,
+                                                            FPGA_PULL_CTL,
+                                                            FPGA_SD_PULL_CTL_BIT | 0x20,
+                                                            0);
+                               if (retval) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
                        }
                        retval = card_share_mode(chip, SD_CARD);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        /* Enable sdio_bus_auto_switch */
-                       if (CHECK_PID(chip, 0x5288))
-                               RTSX_WRITE_REG(chip, 0xFE5A, 0x08, 0x08);
-                       else if (CHECK_PID(chip, 0x5208))
-                               RTSX_WRITE_REG(chip, 0xFE70, 0x80, 0x80);
+                       if (CHECK_PID(chip, 0x5288)) {
+                               retval = rtsx_write_register(chip, 0xFE5A,
+                                                            0x08, 0x08);
+                               if (retval) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
+                       } else if (CHECK_PID(chip, 0x5208)) {
+                               retval = rtsx_write_register(chip, 0xFE70,
+                                                            0x80, 0x80);
+                               if (retval) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
+                       }
 
                        chip->chip_insert_with_sdio = 1;
                        chip->sd_io = 1;
                }
        } else {
-               RTSX_WRITE_REG(chip, TLPTISTAT, 0x08, 0x08);
+               retval = rtsx_write_register(chip, TLPTISTAT, 0x08, 0x08);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                chip->need_reset |= SD_CARD;
        }
@@ -237,25 +307,36 @@ static int rtsx_reset_aspm(struct rtsx_chip *chip)
 
                ret = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFF,
                                        chip->aspm_l0s_l1_en);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                return STATUS_SUCCESS;
        }
 
-       if (CHECK_PID(chip, 0x5208))
-               RTSX_WRITE_REG(chip, ASPM_FORCE_CTL, 0xFF, 0x3F);
+       if (CHECK_PID(chip, 0x5208)) {
+               ret = rtsx_write_register(chip, ASPM_FORCE_CTL, 0xFF, 0x3F);
+               if (ret) {
+                       rtsx_trace(chip);
+                       return ret;
+               }
+       }
        ret = rtsx_write_config_byte(chip, LCTLR, chip->aspm_l0s_l1_en);
-       if (ret != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (ret != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        chip->aspm_level[0] = chip->aspm_l0s_l1_en;
        if (CHK_SDIO_EXIST(chip)) {
                chip->aspm_level[1] = chip->aspm_l0s_l1_en;
                ret = rtsx_write_cfg_dw(chip, CHECK_PID(chip, 0x5288) ? 2 : 1,
                                        0xC0, 0xFF, chip->aspm_l0s_l1_en);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        chip->aspm_enabled = 1;
@@ -273,7 +354,11 @@ static int rtsx_enable_pcie_intr(struct rtsx_chip *chip)
        }
 
        if (chip->phy_debug_mode) {
-               RTSX_WRITE_REG(chip, CDRESUMECTL, 0x77, 0);
+               ret = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0);
+               if (ret) {
+                       rtsx_trace(chip);
+                       return ret;
+               }
                rtsx_disable_bus_int(chip);
        } else {
                rtsx_enable_bus_int(chip);
@@ -283,23 +368,31 @@ static int rtsx_enable_pcie_intr(struct rtsx_chip *chip)
                u16 reg;
 
                ret = rtsx_read_phy_register(chip, 0x00, &reg);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                reg &= 0xFE7F;
                reg |= 0x80;
                ret = rtsx_write_phy_register(chip, 0x00, reg);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ret = rtsx_read_phy_register(chip, 0x1C, &reg);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                reg &= 0xFFF7;
                ret = rtsx_write_phy_register(chip, 0x1C, reg);
-               if (ret != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (ret != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (chip->driver_first_load && (chip->ic_version < IC_VER_C))
@@ -316,47 +409,116 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
 
        rtsx_disable_aspm(chip);
 
-       RTSX_WRITE_REG(chip, HOST_SLEEP_STATE, 0x03, 0x00);
+       retval = rtsx_write_register(chip, HOST_SLEEP_STATE, 0x03, 0x00);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        /* Disable card clock */
-       RTSX_WRITE_REG(chip, CARD_CLK_EN, 0x1E, 0);
+       retval = rtsx_write_register(chip, CARD_CLK_EN, 0x1E, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
 #ifdef SUPPORT_OCP
        /* SSC power on, OCD power on */
-       if (CHECK_LUN_MODE(chip, SD_MS_2LUN))
-               RTSX_WRITE_REG(chip, FPDCTL, OC_POWER_DOWN, 0);
-       else
-               RTSX_WRITE_REG(chip, FPDCTL, OC_POWER_DOWN, MS_OC_POWER_DOWN);
+       if (CHECK_LUN_MODE(chip, SD_MS_2LUN)) {
+               retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       } else {
+               retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN,
+                                            MS_OC_POWER_DOWN);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
 
-       RTSX_WRITE_REG(chip, OCPPARA1, OCP_TIME_MASK, OCP_TIME_800);
-       RTSX_WRITE_REG(chip, OCPPARA2, OCP_THD_MASK, OCP_THD_244_946);
-       RTSX_WRITE_REG(chip, OCPCTL, 0xFF, CARD_OC_INT_EN | CARD_DETECT_EN);
+       retval = rtsx_write_register(chip, OCPPARA1, OCP_TIME_MASK,
+                                    OCP_TIME_800);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, OCPPARA2, OCP_THD_MASK,
+                                    OCP_THD_244_946);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, OCPCTL, 0xFF,
+                                    CARD_OC_INT_EN | CARD_DETECT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 #else
        /* OC power down */
-       RTSX_WRITE_REG(chip, FPDCTL, OC_POWER_DOWN, OC_POWER_DOWN);
+       retval = rtsx_write_register(chip, FPDCTL, OC_POWER_DOWN,
+                                    OC_POWER_DOWN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 #endif
 
-       if (!CHECK_PID(chip, 0x5288))
-               RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0xFF, 0x03);
+       if (!CHECK_PID(chip, 0x5288)) {
+               retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0xFF, 0x03);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
 
        /* Turn off LED */
-       RTSX_WRITE_REG(chip, CARD_GPIO, 0xFF, 0x03);
+       retval = rtsx_write_register(chip, CARD_GPIO, 0xFF, 0x03);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        /* Reset delink mode */
-       RTSX_WRITE_REG(chip, CHANGE_LINK_STATE, 0x0A, 0);
+       retval = rtsx_write_register(chip, CHANGE_LINK_STATE, 0x0A, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        /* Card driving select */
-       RTSX_WRITE_REG(chip, CARD_DRIVE_SEL, 0xFF, chip->card_drive_sel);
+       retval = rtsx_write_register(chip, CARD_DRIVE_SEL, 0xFF,
+                                    chip->card_drive_sel);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
 #ifdef LED_AUTO_BLINK
-       RTSX_WRITE_REG(chip, CARD_AUTO_BLINK, 0xFF,
-                      LED_BLINK_SPEED | BLINK_EN | LED_GPIO0);
+       retval = rtsx_write_register(chip, CARD_AUTO_BLINK, 0xFF,
+                                    LED_BLINK_SPEED | BLINK_EN | LED_GPIO0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 #endif
 
        if (chip->asic_code) {
                /* Enable SSC Clock */
-               RTSX_WRITE_REG(chip, SSC_CTL1, 0xFF, SSC_8X_EN | SSC_SEL_4M);
-               RTSX_WRITE_REG(chip, SSC_CTL2, 0xFF, 0x12);
+               retval = rtsx_write_register(chip, SSC_CTL1, 0xFF,
+                                            SSC_8X_EN | SSC_SEL_4M);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SSC_CTL2, 0xFF, 0x12);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        /* Disable cd_pwr_save (u_force_rst_core_en=0, u_cd_rst_core_en=0)
@@ -366,55 +528,84 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
              bit[5]    u_mac_phy_rst_n_dbg     rst_value = 1
              bit[4]    u_non_sticky_rst_n_dbg  rst_value = 0
        */
-       RTSX_WRITE_REG(chip, CHANGE_LINK_STATE, 0x16, 0x10);
+       retval = rtsx_write_register(chip, CHANGE_LINK_STATE, 0x16, 0x10);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        /* Enable ASPM */
        if (chip->aspm_l0s_l1_en) {
                retval = rtsx_reset_aspm(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
                if (chip->asic_code && CHECK_PID(chip, 0x5208)) {
                        retval = rtsx_write_phy_register(chip, 0x07, 0x0129);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
                retval = rtsx_write_config_byte(chip, LCTLR,
                                                chip->aspm_l0s_l1_en);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        retval = rtsx_write_config_byte(chip, 0x81, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_SDIO_EXIST(chip)) {
                retval = rtsx_write_cfg_dw(chip,
                                           CHECK_PID(chip, 0x5288) ? 2 : 1,
                                           0xC0, 0xFF00, 0x0100);
 
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (CHECK_PID(chip, 0x5288) && !CHK_SDIO_EXIST(chip)) {
                retval = rtsx_write_cfg_dw(chip, 2, 0xC0, 0xFFFF, 0x0103);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = rtsx_write_cfg_dw(chip, 2, 0x84, 0xFF, 0x03);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
-       RTSX_WRITE_REG(chip, IRQSTAT0, LINK_RDY_INT, LINK_RDY_INT);
+       retval = rtsx_write_register(chip, IRQSTAT0, LINK_RDY_INT,
+                                    LINK_RDY_INT);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
-       RTSX_WRITE_REG(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80);
+       retval = rtsx_write_register(chip, PERST_GLITCH_WIDTH, 0xFF, 0x80);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = rtsx_enable_pcie_intr(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        chip->need_reset = 0;
 
@@ -436,13 +627,19 @@ int rtsx_reset_chip(struct rtsx_chip *chip)
 #else  /* HW_AUTO_SWITCH_SD_BUS */
                retval = rtsx_pre_handle_sdio_old(chip);
 #endif  /* HW_AUTO_SWITCH_SD_BUS */
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
        } else {
                chip->sd_io = 0;
-               RTSX_WRITE_REG(chip, SDIO_CTRL, SDIO_BUS_CTRL | SDIO_CD_CTRL,
-                              0);
+               retval = rtsx_write_register(chip, SDIO_CTRL,
+                                            SDIO_BUS_CTRL | SDIO_CD_CTRL, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
 nextcard:
@@ -450,43 +647,91 @@ nextcard:
                chip->need_reset |= XD_CARD;
        if (chip->int_reg & MS_EXIST)
                chip->need_reset |= MS_CARD;
-       if (chip->int_reg & CARD_EXIST)
-               RTSX_WRITE_REG(chip, SSC_CTL1, SSC_RSTB, SSC_RSTB);
+       if (chip->int_reg & CARD_EXIST) {
+               retval = rtsx_write_register(chip, SSC_CTL1, SSC_RSTB,
+                                            SSC_RSTB);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
 
        dev_dbg(rtsx_dev(chip), "In %s, chip->need_reset = 0x%x\n", __func__,
                (unsigned int)(chip->need_reset));
 
-       RTSX_WRITE_REG(chip, RCCTL, 0x01, 0x00);
+       retval = rtsx_write_register(chip, RCCTL, 0x01, 0x00);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (CHECK_PID(chip, 0x5208) || CHECK_PID(chip, 0x5288)) {
                /* Turn off main power when entering S3/S4 state */
-               RTSX_WRITE_REG(chip, MAIN_PWR_OFF_CTL, 0x03, 0x03);
+               retval = rtsx_write_register(chip, MAIN_PWR_OFF_CTL, 0x03,
+                                            0x03);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        if (chip->remote_wakeup_en && !chip->auto_delink_en) {
-               RTSX_WRITE_REG(chip, WAKE_SEL_CTL, 0x07, 0x07);
-               if (chip->aux_pwr_exist)
-                       RTSX_WRITE_REG(chip, PME_FORCE_CTL, 0xFF, 0x33);
+               retval = rtsx_write_register(chip, WAKE_SEL_CTL, 0x07, 0x07);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               if (chip->aux_pwr_exist) {
+                       retval = rtsx_write_register(chip, PME_FORCE_CTL,
+                                                    0xFF, 0x33);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+               }
        } else {
-               RTSX_WRITE_REG(chip, WAKE_SEL_CTL, 0x07, 0x04);
-               RTSX_WRITE_REG(chip, PME_FORCE_CTL, 0xFF, 0x30);
+               retval = rtsx_write_register(chip, WAKE_SEL_CTL, 0x07, 0x04);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, PME_FORCE_CTL, 0xFF, 0x30);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
-       if (CHECK_PID(chip, 0x5208) && (chip->ic_version >= IC_VER_D))
-               RTSX_WRITE_REG(chip, PETXCFG, 0x1C, 0x14);
+       if (CHECK_PID(chip, 0x5208) && (chip->ic_version >= IC_VER_D)) {
+               retval = rtsx_write_register(chip, PETXCFG, 0x1C, 0x14);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
 
        if (chip->asic_code && CHECK_PID(chip, 0x5208)) {
                retval = rtsx_clr_phy_reg_bit(chip, 0x1C, 2);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (chip->ft2_fast_mode) {
-               RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF,
-                              MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON);
+               retval = rtsx_write_register(chip, CARD_PWR_CTL, 0xFF,
+                                            MS_PARTIAL_POWER_ON | SD_PARTIAL_POWER_ON);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                udelay(chip->pmos_pwr_on_interval);
-               RTSX_WRITE_REG(chip, CARD_PWR_CTL, 0xFF,
-                              MS_POWER_ON | SD_POWER_ON);
+               retval = rtsx_write_register(chip, CARD_PWR_CTL, 0xFF,
+                                            MS_POWER_ON | SD_POWER_ON);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                wait_timeout(200);
        }
@@ -501,13 +746,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 +763,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;
                }
        }
@@ -537,14 +784,24 @@ static int rts5208_init(struct rtsx_chip *chip)
        u16 reg = 0;
        u8 val = 0;
 
-       RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03);
-       RTSX_READ_REG(chip, CLK_SEL, &val);
+       retval = rtsx_write_register(chip, CLK_SEL, 0x03, 0x03);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_read_register(chip, CLK_SEL, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        chip->asic_code = val == 0 ? 1 : 0;
 
        if (chip->asic_code) {
                retval = rtsx_read_phy_register(chip, 0x1C, &reg);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                dev_dbg(rtsx_dev(chip), "Value of phy register 0x1C is 0x%x\n",
                        reg);
@@ -552,16 +809,28 @@ static int rts5208_init(struct rtsx_chip *chip)
                chip->phy_debug_mode = reg & PHY_DEBUG_MODE ? 1 : 0;
 
        } else {
-               RTSX_READ_REG(chip, 0xFE80, &val);
+               retval = rtsx_read_register(chip, 0xFE80, &val);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                chip->ic_version = val;
                chip->phy_debug_mode = 0;
        }
 
-       RTSX_READ_REG(chip, PDINFO, &val);
+       retval = rtsx_read_register(chip, PDINFO, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val);
        chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0;
 
-       RTSX_READ_REG(chip, 0xFE50, &val);
+       retval = rtsx_read_register(chip, 0xFE50, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        chip->hw_bypass_sd = val & 0x01 ? 1 : 0;
 
        rtsx_read_config_byte(chip, 0x0E, &val);
@@ -571,7 +840,11 @@ static int rts5208_init(struct rtsx_chip *chip)
                CLR_SDIO_EXIST(chip);
 
        if (chip->use_hw_setting) {
-               RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val);
+               retval = rtsx_read_register(chip, CHANGE_LINK_STATE, &val);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                chip->auto_delink_en = val & 0x80 ? 1 : 0;
        }
 
@@ -584,27 +857,49 @@ static int rts5288_init(struct rtsx_chip *chip)
        u8 val = 0, max_func;
        u32 lval = 0;
 
-       RTSX_WRITE_REG(chip, CLK_SEL, 0x03, 0x03);
-       RTSX_READ_REG(chip, CLK_SEL, &val);
+       retval = rtsx_write_register(chip, CLK_SEL, 0x03, 0x03);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_read_register(chip, CLK_SEL, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        chip->asic_code = val == 0 ? 1 : 0;
 
        chip->ic_version = 0;
        chip->phy_debug_mode = 0;
 
-       RTSX_READ_REG(chip, PDINFO, &val);
+       retval = rtsx_read_register(chip, PDINFO, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "PDINFO: 0x%x\n", val);
        chip->aux_pwr_exist = val & AUX_PWR_DETECTED ? 1 : 0;
 
-       RTSX_READ_REG(chip, CARD_SHARE_MODE, &val);
+       retval = rtsx_read_register(chip, CARD_SHARE_MODE, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "CARD_SHARE_MODE: 0x%x\n", val);
        chip->baro_pkg = val & 0x04 ? QFN : LQFP;
 
-       RTSX_READ_REG(chip, 0xFE5A, &val);
+       retval = rtsx_read_register(chip, 0xFE5A, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        chip->hw_bypass_sd = val & 0x10 ? 1 : 0;
 
        retval = rtsx_read_cfg_dw(chip, 0, 0x718, &lval);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        max_func = (u8)((lval >> 29) & 0x07);
        dev_dbg(rtsx_dev(chip), "Max function number: %d\n", max_func);
@@ -614,7 +909,11 @@ static int rts5288_init(struct rtsx_chip *chip)
                CLR_SDIO_EXIST(chip);
 
        if (chip->use_hw_setting) {
-               RTSX_READ_REG(chip, CHANGE_LINK_STATE, &val);
+               retval = rtsx_read_register(chip, CHANGE_LINK_STATE, &val);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                chip->auto_delink_en = val & 0x80 ? 1 : 0;
 
                if (CHECK_BARO_PKG(chip, LQFP))
@@ -693,21 +992,33 @@ int rtsx_init_chip(struct rtsx_chip *chip)
        if ((chip->mmc_ddr_tx_phase > 31) || (chip->mmc_ddr_tx_phase < 0))
                chip->mmc_ddr_tx_phase = 0;
 
-       RTSX_WRITE_REG(chip, FPDCTL, SSC_POWER_DOWN, 0);
+       retval = rtsx_write_register(chip, FPDCTL, SSC_POWER_DOWN, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        wait_timeout(200);
-       RTSX_WRITE_REG(chip, CLK_DIV, 0x07, 0x07);
+       retval = rtsx_write_register(chip, CLK_DIV, 0x07, 0x07);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        dev_dbg(rtsx_dev(chip), "chip->use_hw_setting = %d\n",
                chip->use_hw_setting);
 
        if (CHECK_PID(chip, 0x5208)) {
                retval = rts5208_init(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
        } else if (CHECK_PID(chip, 0x5288)) {
                retval = rts5288_init(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (chip->ss_en == 2)
@@ -754,8 +1065,10 @@ int rtsx_init_chip(struct rtsx_chip *chip)
        }
 
        retval = rtsx_reset_chip(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -784,31 +1097,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 +1148,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 +1200,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) {
@@ -1153,14 +1466,17 @@ int rtsx_write_register(struct rtsx_chip *chip, u16 addr, u8 mask, u8 data)
        for (i = 0; i < MAX_RW_REG_CNT; i++) {
                val = rtsx_readl(chip, RTSX_HAIMR);
                if ((val & (1 << 31)) == 0) {
-                       if (data != (u8)val)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (data != (u8)val) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        return STATUS_SUCCESS;
                }
        }
 
-       TRACE_RET(chip, STATUS_TIMEDOUT);
+       rtsx_trace(chip);
+       return STATUS_TIMEDOUT;
 }
 
 int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data)
@@ -1181,8 +1497,10 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data)
                        break;
        }
 
-       if (i >= MAX_RW_REG_CNT)
-               TRACE_RET(chip, STATUS_TIMEDOUT);
+       if (i >= MAX_RW_REG_CNT) {
+               rtsx_trace(chip);
+               return STATUS_TIMEDOUT;
+       }
 
        if (data)
                *data = (u8)(val & 0xFF);
@@ -1193,13 +1511,19 @@ int rtsx_read_register(struct rtsx_chip *chip, u16 addr, u8 *data)
 int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask,
                      u32 val)
 {
+       int retval;
        u8 mode = 0, tmp;
        int i;
 
        for (i = 0; i < 4; i++) {
                if (mask & 0xFF) {
-                       RTSX_WRITE_REG(chip, CFGDATA0 + i,
-                                      0xFF, (u8)(val & mask & 0xFF));
+                       retval = rtsx_write_register(chip, CFGDATA0 + i,
+                                                    0xFF,
+                                                    (u8)(val & mask & 0xFF));
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        mode |= (1 << i);
                }
                mask >>= 8;
@@ -1207,14 +1531,31 @@ int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask,
        }
 
        if (mode) {
-               RTSX_WRITE_REG(chip, CFGADDR0, 0xFF, (u8)addr);
-               RTSX_WRITE_REG(chip, CFGADDR1, 0xFF, (u8)(addr >> 8));
+               retval = rtsx_write_register(chip, CFGADDR0, 0xFF, (u8)addr);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CFGADDR1, 0xFF,
+                                            (u8)(addr >> 8));
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
-               RTSX_WRITE_REG(chip, CFGRWCTL, 0xFF,
-                              0x80 | mode | ((func_no & 0x03) << 4));
+               retval = rtsx_write_register(chip, CFGRWCTL, 0xFF,
+                                            0x80 | mode | ((func_no & 0x03) << 4));
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                for (i = 0; i < MAX_RW_REG_CNT; i++) {
-                       RTSX_READ_REG(chip, CFGRWCTL, &tmp);
+                       retval = rtsx_read_register(chip, CFGRWCTL, &tmp);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        if ((tmp & 0x80) == 0)
                                break;
                }
@@ -1225,22 +1566,44 @@ int rtsx_write_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 mask,
 
 int rtsx_read_cfg_dw(struct rtsx_chip *chip, u8 func_no, u16 addr, u32 *val)
 {
+       int retval;
        int i;
        u8 tmp;
        u32 data = 0;
 
-       RTSX_WRITE_REG(chip, CFGADDR0, 0xFF, (u8)addr);
-       RTSX_WRITE_REG(chip, CFGADDR1, 0xFF, (u8)(addr >> 8));
-       RTSX_WRITE_REG(chip, CFGRWCTL, 0xFF, 0x80 | ((func_no & 0x03) << 4));
+       retval = rtsx_write_register(chip, CFGADDR0, 0xFF, (u8)addr);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CFGADDR1, 0xFF, (u8)(addr >> 8));
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CFGRWCTL, 0xFF,
+                                    0x80 | ((func_no & 0x03) << 4));
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        for (i = 0; i < MAX_RW_REG_CNT; i++) {
-               RTSX_READ_REG(chip, CFGRWCTL, &tmp);
+               retval = rtsx_read_register(chip, CFGRWCTL, &tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if ((tmp & 0x80) == 0)
                        break;
        }
 
        for (i = 0; i < 4; i++) {
-               RTSX_READ_REG(chip, CFGDATA0 + i, &tmp);
+               retval = rtsx_read_register(chip, CFGDATA0 + i, &tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                data |= (u32)tmp << (i * 8);
        }
 
@@ -1259,8 +1622,10 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
        int dw_len, i, j;
        int retval;
 
-       if (!buf)
-               TRACE_RET(chip, STATUS_NOMEM);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_NOMEM;
+       }
 
        if ((len + offset) % 4)
                dw_len = (len + offset) / 4 + 1;
@@ -1270,13 +1635,16 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
        dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
 
        data = vzalloc(dw_len * 4);
-       if (!data)
-               TRACE_RET(chip, STATUS_NOMEM);
+       if (!data) {
+               rtsx_trace(chip);
+               return STATUS_NOMEM;
+       }
 
        mask = vzalloc(dw_len * 4);
        if (!mask) {
                vfree(data);
-               TRACE_RET(chip, STATUS_NOMEM);
+               rtsx_trace(chip);
+               return STATUS_NOMEM;
        }
 
        j = 0;
@@ -1300,7 +1668,8 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
                if (retval != STATUS_SUCCESS) {
                        vfree(data);
                        vfree(mask);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1327,15 +1696,18 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
        dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
 
        data = vmalloc(dw_len * 4);
-       if (!data)
-               TRACE_RET(chip, STATUS_NOMEM);
+       if (!data) {
+               rtsx_trace(chip);
+               return STATUS_NOMEM;
+       }
 
        for (i = 0; i < dw_len; i++) {
                retval = rtsx_read_cfg_dw(chip, func, aligned_addr + i * 4,
                                          data + i);
                if (retval != STATUS_SUCCESS) {
                        vfree(data);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1358,51 +1730,99 @@ 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;
+       int retval;
+       bool finished = false;
+       int i;
        u8 tmp;
 
-       RTSX_WRITE_REG(chip, PHYDATA0, 0xFF, (u8)val);
-       RTSX_WRITE_REG(chip, PHYDATA1, 0xFF, (u8)(val >> 8));
-       RTSX_WRITE_REG(chip, PHYADDR, 0xFF, addr);
-       RTSX_WRITE_REG(chip, PHYRWCTL, 0xFF, 0x81);
+       retval = rtsx_write_register(chip, PHYDATA0, 0xFF, (u8)val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, PHYDATA1, 0xFF, (u8)(val >> 8));
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, PHYADDR, 0xFF, addr);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, PHYRWCTL, 0xFF, 0x81);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        for (i = 0; i < 100000; i++) {
-               RTSX_READ_REG(chip, PHYRWCTL, &tmp);
+               retval = rtsx_read_register(chip, PHYRWCTL, &tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if (!(tmp & 0x80)) {
-                       finished = 1;
+                       finished = true;
                        break;
                }
        }
 
-       if (!finished)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!finished) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
 
 int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val)
 {
-       int i, finished = 0;
+       int retval;
+       bool finished = false;
+       int i;
        u16 data = 0;
        u8 tmp;
 
-       RTSX_WRITE_REG(chip, PHYADDR, 0xFF, addr);
-       RTSX_WRITE_REG(chip, PHYRWCTL, 0xFF, 0x80);
+       retval = rtsx_write_register(chip, PHYADDR, 0xFF, addr);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, PHYRWCTL, 0xFF, 0x80);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        for (i = 0; i < 100000; i++) {
-               RTSX_READ_REG(chip, PHYRWCTL, &tmp);
+               retval = rtsx_read_register(chip, PHYRWCTL, &tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if (!(tmp & 0x80)) {
-                       finished = 1;
+                       finished = true;
                        break;
                }
        }
 
-       if (!finished)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!finished) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_READ_REG(chip, PHYDATA0, &tmp);
+       retval = rtsx_read_register(chip, PHYDATA0, &tmp);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        data = tmp;
-       RTSX_READ_REG(chip, PHYDATA1, &tmp);
+       retval = rtsx_read_register(chip, PHYDATA1, &tmp);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        data |= (u16)tmp << 8;
 
        if (val)
@@ -1413,22 +1833,37 @@ int rtsx_read_phy_register(struct rtsx_chip *chip, u8 addr, u16 *val)
 
 int rtsx_read_efuse(struct rtsx_chip *chip, u8 addr, u8 *val)
 {
+       int retval;
        int i;
        u8 data = 0;
 
-       RTSX_WRITE_REG(chip, EFUSE_CTRL, 0xFF, 0x80|addr);
+       retval = rtsx_write_register(chip, EFUSE_CTRL, 0xFF, 0x80 | addr);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        for (i = 0; i < 100; i++) {
-               RTSX_READ_REG(chip, EFUSE_CTRL, &data);
+               retval = rtsx_read_register(chip, EFUSE_CTRL, &data);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if (!(data & 0x80))
                        break;
                udelay(1);
        }
 
-       if (data & 0x80)
-               TRACE_RET(chip, STATUS_TIMEDOUT);
+       if (data & 0x80) {
+               rtsx_trace(chip);
+               return STATUS_TIMEDOUT;
+       }
 
-       RTSX_READ_REG(chip, EFUSE_DATA, &data);
+       retval = rtsx_read_register(chip, EFUSE_DATA, &data);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (val)
                *val = data;
 
@@ -1437,6 +1872,7 @@ int rtsx_read_efuse(struct rtsx_chip *chip, u8 addr, u8 *val)
 
 int rtsx_write_efuse(struct rtsx_chip *chip, u8 addr, u8 val)
 {
+       int retval;
        int i, j;
        u8 data = 0, tmp = 0xFF;
 
@@ -1447,18 +1883,33 @@ int rtsx_write_efuse(struct rtsx_chip *chip, u8 addr, u8 val)
                tmp &= (~(u8)(1 << i));
                dev_dbg(rtsx_dev(chip), "Write 0x%x to 0x%x\n", tmp, addr);
 
-               RTSX_WRITE_REG(chip, EFUSE_DATA, 0xFF, tmp);
-               RTSX_WRITE_REG(chip, EFUSE_CTRL, 0xFF, 0xA0|addr);
+               retval = rtsx_write_register(chip, EFUSE_DATA, 0xFF, tmp);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, EFUSE_CTRL, 0xFF,
+                                            0xA0 | addr);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                for (j = 0; j < 100; j++) {
-                       RTSX_READ_REG(chip, EFUSE_CTRL, &data);
+                       retval = rtsx_read_register(chip, EFUSE_CTRL, &data);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        if (!(data & 0x80))
                                break;
                        wait_timeout(3);
                }
 
-               if (data & 0x80)
-                       TRACE_RET(chip, STATUS_TIMEDOUT);
+               if (data & 0x80) {
+                       rtsx_trace(chip);
+                       return STATUS_TIMEDOUT;
+               }
 
                wait_timeout(5);
        }
@@ -1472,14 +1923,18 @@ int rtsx_clr_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit)
        u16 value;
 
        retval = rtsx_read_phy_register(chip, reg, &value);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (value & (1 << bit)) {
                value &= ~(1 << bit);
                retval = rtsx_write_phy_register(chip, reg, value);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1491,14 +1946,18 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit)
        u16 value;
 
        retval = rtsx_read_phy_register(chip, reg, &value);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if ((value & (1 << bit)) == 0) {
                value |= (1 << bit);
                retval = rtsx_write_phy_register(chip, reg, value);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1506,9 +1965,14 @@ int rtsx_set_phy_reg_bit(struct rtsx_chip *chip, u8 reg, u8 bit)
 
 int rtsx_check_link_ready(struct rtsx_chip *chip)
 {
+       int retval;
        u8 val;
 
-       RTSX_READ_REG(chip, IRQSTAT0, &val);
+       retval = rtsx_read_register(chip, IRQSTAT0, &val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        dev_dbg(rtsx_dev(chip), "IRQSTAT0: 0x%x\n", val);
        if (val & LINK_RDY_INT) {
@@ -1615,7 +2079,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 +2089,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);
                }
@@ -1814,8 +2278,10 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
        u16 reg_addr;
        u8 *ptr;
 
-       if (!buf)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        ptr = buf;
        reg_addr = PPBUF_BASE2;
@@ -1826,8 +2292,10 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
                        rtsx_add_cmd(chip, READ_REG_CMD, reg_addr++, 0, 0);
 
                retval = rtsx_send_cmd(chip, 0, 250);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                memcpy(ptr, rtsx_get_cmd_data(chip), 256);
                ptr += 256;
@@ -1840,8 +2308,10 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
                        rtsx_add_cmd(chip, READ_REG_CMD, reg_addr++, 0, 0);
 
                retval = rtsx_send_cmd(chip, 0, 250);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        memcpy(ptr, rtsx_get_cmd_data(chip), buf_len%256);
@@ -1856,8 +2326,10 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
        u16 reg_addr;
        u8 *ptr;
 
-       if (!buf)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        ptr = buf;
        reg_addr = PPBUF_BASE2;
@@ -1871,8 +2343,10 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
                }
 
                retval = rtsx_send_cmd(chip, 0, 250);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (buf_len%256) {
@@ -1885,8 +2359,10 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
                }
 
                retval = rtsx_send_cmd(chip, 0, 250);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1894,8 +2370,10 @@ int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len)
 
 int rtsx_check_chip_exist(struct rtsx_chip *chip)
 {
-       if (rtsx_readl(chip, 0) == 0xFFFFFFFF)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (rtsx_readl(chip, 0) == 0xFFFFFFFF) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1918,8 +2396,10 @@ int rtsx_force_power_on(struct rtsx_chip *chip, u8 ctl)
 
        if (mask) {
                retval = rtsx_write_register(chip, FPDCTL, mask, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (CHECK_PID(chip, 0x5288))
                        wait_timeout(200);
@@ -1947,8 +2427,10 @@ int rtsx_force_power_down(struct rtsx_chip *chip, u8 ctl)
        if (mask) {
                val = mask;
                retval = rtsx_write_register(chip, FPDCTL, mask, val);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
index feac98661cec0ea2f064273641135e5f792af9e8..c295b1eedb44ec7e67896fe965ce7ee02f22a948 100644 (file)
@@ -988,20 +988,4 @@ int rtsx_read_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len);
 int rtsx_write_ppbuf(struct rtsx_chip *chip, u8 *buf, int buf_len);
 int rtsx_check_chip_exist(struct rtsx_chip *chip);
 
-#define RTSX_WRITE_REG(chip, addr, mask, data)                         \
-       do {                                                            \
-               int retval = rtsx_write_register((chip), (addr), (mask), (data)); \
-               if (retval != STATUS_SUCCESS) {                         \
-                       TRACE_RET((chip), retval);                      \
-               }                                                       \
-       } while (0)
-
-#define RTSX_READ_REG(chip, addr, data)                                        \
-       do {                                                            \
-               int retval = rtsx_read_register((chip), (addr), (data)); \
-               if (retval != STATUS_SUCCESS) {                         \
-                       TRACE_RET((chip), retval);                      \
-               }                                                       \
-       } while (0)
-
 #endif  /* __REALTEK_RTSX_CHIP_H */
index 11610826acf19111934a5fc0252f8a371c5810d9..8a5d6a8e780f3a63658083f19f3adb494ec574aa 100644 (file)
 #include <linux/vmalloc.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_sys.h"
-#include "rtsx_card.h"
-#include "rtsx_chip.h"
-#include "rtsx_scsi.h"
 #include "sd.h"
 #include "ms.h"
 #include "spi.h"
@@ -39,7 +34,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 +306,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 +482,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,
@@ -510,8 +507,10 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        buf = vmalloc(scsi_bufflen(srb));
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
 #ifdef SUPPORT_MAGIC_GATE
        if ((chip->mspro_formatter_enable) &&
@@ -519,10 +518,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)
@@ -587,12 +584,14 @@ static int start_stop_unit(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (check_card_ready(chip, lun))
                        return TRANSPORT_GOOD;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
 
                break;
        }
 
-       TRACE_RET(chip, TRANSPORT_ERROR);
+       rtsx_trace(chip);
+       return TRANSPORT_ERROR;
 }
 
 
@@ -607,7 +606,8 @@ static int allow_medium_removal(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (prevent) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return TRANSPORT_GOOD;
@@ -644,8 +644,10 @@ static int request_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        buf = vmalloc(scsi_bufflen(srb));
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        tmp = (unsigned char *)sense;
        memcpy(buf, tmp, scsi_bufflen(srb));
@@ -665,7 +667,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 +688,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 +759,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);
 
@@ -765,32 +767,35 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
                scsi_set_resid(srb, scsi_bufflen(srb));
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 #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;
                }
        }
 #endif
 
        buf = kmalloc(dataSize, GFP_KERNEL);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        pageCode = srb->cmnd[2] & 0x3f;
 
@@ -869,7 +874,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun) || (get_card_size(chip, lun) == 0)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (!(CHK_BIT(chip->lun_mc, lun))) {
@@ -885,7 +891,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                 */
                dev_dbg(rtsx_dev(chip), "SD card being erased!\n");
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (get_lun_card(chip, lun) == SD_CARD) {
@@ -893,7 +900,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        dev_dbg(rtsx_dev(chip), "SD card locked!\n");
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_READ_FORBIDDEN);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 #endif
@@ -916,7 +924,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                sec_cnt = ((u16)(srb->cmnd[9]) << 8) | srb->cmnd[10];
        } else {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        /* In some test, we will receive a start_sec like 0xFFFFFFFF.
@@ -926,7 +935,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if ((start_sec > get_card_size(chip, lun)) ||
                        ((start_sec + sec_cnt) > get_card_size(chip, lun))) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LBA_OVER_RANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (sec_cnt == 0) {
@@ -942,7 +952,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                else
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR);
 
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (srb->sc_data_direction == DMA_TO_DEVICE) {
@@ -950,7 +961,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        dev_dbg(rtsx_dev(chip), "Write protected card!\n");
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_WRITE_PROTECT);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -969,7 +981,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
                }
                retval = TRANSPORT_FAILED;
-               TRACE_GOTO(chip, Exit);
+               rtsx_trace(chip);
+               goto Exit;
        } else {
                chip->rw_fail_cnt[lun] = 0;
                retval = TRANSPORT_GOOD;
@@ -994,15 +1007,18 @@ static int read_format_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (!check_card_ready(chip, lun)) {
                if (!chip->mspro_formatter_enable) {
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
        buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12;
 
        buf = kmalloc(buf_len, GFP_KERNEL);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        buf[i++] = 0;
        buf[i++] = 0;
@@ -1067,7 +1083,8 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (!(CHK_BIT(chip->lun_mc, lun))) {
@@ -1077,8 +1094,10 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        }
 
        buf = kmalloc(8, GFP_KERNEL);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        card_size = get_card_size(chip, lun);
        buf[0] = (unsigned char)((card_size - 1) >> 24);
@@ -1116,15 +1135,18 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        len = ((u16)srb->cmnd[4] << 8) | srb->cmnd[5];
 
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -1133,7 +1155,8 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -1165,7 +1188,8 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (len == 511) {
@@ -1173,14 +1197,17 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval != STATUS_SUCCESS) {
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        } else {
                len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb),
                                        len);
                buf = vmalloc(len);
-               if (buf == NULL)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (buf == NULL) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                rtsx_stor_get_xfer_buf(buf, len, srb);
                scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -1191,7 +1218,8 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                vfree(buf);
                                set_sense_type(chip, SCSI_LUN(srb),
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
                        }
                }
 
@@ -1221,18 +1249,22 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (addr < 0xFC00) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -1241,7 +1273,8 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -1274,13 +1307,16 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (addr < 0xFC00) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
        buf = vmalloc(len);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        rtsx_stor_get_xfer_buf(buf, len, srb);
        scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -1289,7 +1325,8 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -1298,7 +1335,8 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -1314,12 +1352,14 @@ static int get_sd_csd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (get_lun_card(chip, lun) != SD_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -1361,14 +1401,17 @@ static int trace_msg_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if ((scsi_bufflen(srb) < buf_len) || (scsi_sglist(srb) == NULL)) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        clear = srb->cmnd[2];
 
        buf = vmalloc(scsi_bufflen(srb));
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
        ptr = buf;
 
        if (chip->trace_msg[chip->msg_idx].valid)
@@ -1500,7 +1543,8 @@ static int set_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                default:
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        } else if (srb->cmnd[3] == 2) {
                if (srb->cmnd[4]) {
@@ -1523,14 +1567,16 @@ static int set_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, SCSI_LUN(srb),
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
                        }
 
                        turn_off_led(chip, LED_GPIO);
                }
        } else {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return TRANSPORT_GOOD;
@@ -1562,7 +1608,8 @@ static int get_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                default:
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
 
                rtsx_stor_set_xfer_buf(&tmp, 1, srb);
@@ -1572,7 +1619,8 @@ static int get_variable(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                rtsx_stor_set_xfer_buf(&tmp, 1, srb);
        } else {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return TRANSPORT_GOOD;
@@ -1610,7 +1658,8 @@ static int dma_access_ring_buffer(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_WRITE_ERR);
 
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        scsi_set_resid(srb, 0);
 
@@ -1757,7 +1806,8 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (!CHECK_PID(chip, 0x5208)) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        phy_debug_mode = (int)(srb->cmnd[3]);
@@ -1765,35 +1815,47 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (phy_debug_mode) {
                chip->phy_debug_mode = 1;
                retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
 
                rtsx_disable_bus_int(chip);
 
                retval = rtsx_read_phy_register(chip, 0x1C, &reg);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
 
                reg |= 0x0001;
                retval = rtsx_write_phy_register(chip, 0x1C, reg);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
        } else {
                chip->phy_debug_mode = 0;
                retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0x77);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
 
                rtsx_enable_bus_int(chip);
 
                retval = rtsx_read_phy_register(chip, 0x1C, &reg);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
 
                reg &= 0xFFFE;
                retval = rtsx_write_phy_register(chip, 0x1C, reg);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
+               }
        }
 
        return TRANSPORT_GOOD;
@@ -1824,7 +1886,8 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (cmd_type > 2) {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                addr = (srb->cmnd[5] << 8) | srb->cmnd[6];
                mask = srb->cmnd[7];
@@ -1842,7 +1905,8 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (scsi_bufflen(srb) < 1) {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                rtsx_stor_set_xfer_buf(&value, 1, srb);
                scsi_set_resid(srb, 0);
@@ -1850,12 +1914,14 @@ static int rw_mem_cmd_buf(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return TRANSPORT_GOOD;
@@ -1902,15 +1968,18 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (len) {
                buf = vmalloc(len);
-               if (!buf)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (!buf) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                retval = rtsx_force_power_on(chip, SSC_PDCTL);
                if (retval != STATUS_SUCCESS) {
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
 
                for (i = 0; i < len / 2; i++) {
@@ -1919,7 +1988,8 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                vfree(buf);
                                set_sense_type(chip, SCSI_LUN(srb),
                                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
                        }
 
                        buf[2*i] = (u8)(val >> 8);
@@ -1963,8 +2033,10 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                        len);
 
                buf = vmalloc(len);
-               if (buf == NULL)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (buf == NULL) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                rtsx_stor_get_xfer_buf(buf, len, srb);
                scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -1974,7 +2046,8 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
 
                for (i = 0; i < len / 2; i++) {
@@ -1984,7 +2057,8 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                vfree(buf);
                                set_sense_type(chip, SCSI_LUN(srb),
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
                        }
                }
 
@@ -2011,7 +2085,8 @@ static int erase_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        mode = srb->cmnd[3];
@@ -2022,19 +2097,22 @@ static int erase_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval != STATUS_SUCCESS) {
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        } else if (mode == 1) {
                retval = spi_erase_eeprom_byte(chip, addr);
                if (retval != STATUS_SUCCESS) {
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        } else {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return TRANSPORT_GOOD;
@@ -2058,15 +2136,18 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        len = ((u16)srb->cmnd[6] << 8) | srb->cmnd[7];
 
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -2075,7 +2156,8 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -2107,8 +2189,10 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
        buf = vmalloc(len);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        rtsx_stor_get_xfer_buf(buf, len, srb);
        scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -2117,7 +2201,8 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -2126,7 +2211,8 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -2153,15 +2239,18 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        len = srb->cmnd[5];
 
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        for (i = 0; i < len; i++) {
@@ -2170,7 +2259,8 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        vfree(buf);
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
@@ -2203,8 +2293,10 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        len = (u8)min_t(unsigned int, scsi_bufflen(srb), len);
        buf = vmalloc(len);
-       if (buf == NULL)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        rtsx_stor_get_xfer_buf(buf, len, srb);
        scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -2212,21 +2304,24 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = rtsx_force_power_on(chip, SSC_PDCTL);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
-               TRACE_RET(chip, TRANSPORT_ERROR);
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
        }
 
        if (chip->asic_code) {
                retval = rtsx_read_phy_register(chip, 0x08, &val);
                if (retval != STATUS_SUCCESS) {
                        vfree(buf);
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
                }
 
                retval = rtsx_write_register(chip, PWR_GATE_CTRL,
                                        LDO3318_PWR_MASK, LDO_OFF);
                if (retval != STATUS_SUCCESS) {
                        vfree(buf);
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
                }
 
                wait_timeout(600);
@@ -2235,14 +2330,16 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                                0x4C00 | chip->phy_voltage);
                if (retval != STATUS_SUCCESS) {
                        vfree(buf);
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
                }
 
                retval = rtsx_write_register(chip, PWR_GATE_CTRL,
                                        LDO3318_PWR_MASK, LDO_ON);
                if (retval != STATUS_SUCCESS) {
                        vfree(buf);
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
                }
 
                wait_timeout(600);
@@ -2251,7 +2348,8 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = card_power_on(chip, SPI_CARD);
        if (retval != STATUS_SUCCESS) {
                vfree(buf);
-               TRACE_RET(chip, TRANSPORT_ERROR);
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
        }
 
        wait_timeout(50);
@@ -2262,7 +2360,8 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        set_sense_type(chip, SCSI_LUN(srb),
                                SENSE_TYPE_MEDIA_WRITE_ERR);
                        result = TRANSPORT_FAILED;
-                       TRACE_GOTO(chip, Exit);
+                       rtsx_trace(chip);
+                       goto Exit;
                }
        }
 
@@ -2270,25 +2369,33 @@ Exit:
        vfree(buf);
 
        retval = card_power_off(chip, SPI_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        if (chip->asic_code) {
                retval = rtsx_write_register(chip, PWR_GATE_CTRL,
                                        LDO3318_PWR_MASK, LDO_OFF);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                wait_timeout(600);
 
                retval = rtsx_write_phy_register(chip, 0x08, val);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                retval = rtsx_write_register(chip, PWR_GATE_CTRL,
                                        LDO3318_PWR_MASK, LDO_ON);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
        }
 
        return result;
@@ -2297,7 +2404,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,26 +2425,30 @@ 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),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        retval = rtsx_read_cfg_seq(chip, func, addr, buf, len);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
                vfree(buf);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        len = (u16)min_t(unsigned int, scsi_bufflen(srb), len);
@@ -2351,7 +2463,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,20 +2484,23 @@ 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),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
        buf = vmalloc(len);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        rtsx_stor_get_xfer_buf(buf, len, srb);
        scsi_set_resid(srb, scsi_bufflen(srb) - len);
@@ -2393,7 +2509,8 @@ static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, SCSI_LUN(srb), SENSE_TYPE_MEDIA_WRITE_ERR);
                vfree(buf);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        vfree(buf);
@@ -2483,7 +2600,8 @@ static int app_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        default:
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return result;
@@ -2626,7 +2744,8 @@ static int get_card_bus_width(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        card = get_lun_card(chip, lun);
@@ -2634,7 +2753,8 @@ static int get_card_bus_width(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                bus_width = chip->card_bus_width[lun];
        } else {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -2651,7 +2771,8 @@ static int spi_vendor_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (CHECK_PID(chip, 0x5208) || CHECK_PID(chip, 0x5288)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        rtsx_disable_aspm(chip);
@@ -2700,13 +2821,16 @@ static int spi_vendor_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                rtsx_write_register(chip, CARD_GPIO_DIR, 0x07, gpio_dir);
 
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        rtsx_write_register(chip, CARD_GPIO_DIR, 0x07, gpio_dir);
 
-       if (result != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (result != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
        return TRANSPORT_GOOD;
 }
@@ -2765,7 +2889,8 @@ static int vendor_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        default:
                set_sense_type(chip, SCSI_LUN(srb),
                        SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return result;
@@ -2797,18 +2922,21 @@ 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);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if ((srb->cmnd[3] != 0x4D) || (srb->cmnd[4] != 0x47) ||
                (srb->cmnd[5] != 0x66) || (srb->cmnd[6] != 0x6D) ||
                (srb->cmnd[7] != 0x74)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        rtsx_disable_aspm(chip);
@@ -2820,35 +2948,40 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (!check_card_ready(chip, lun) ||
                                (get_card_size(chip, lun) == 0)) {
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
        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);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (chip->card_wp & MS_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (!CHK_MSPRO(ms_card)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        retval = mspro_format(srb, chip, MS_SHORT_DATA_LEN, quick_format);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_FORMAT_CMD_FAILED);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -2867,18 +3000,21 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        if (get_lun_card(chip, lun) != MS_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if ((srb->cmnd[2] != 0xB0) || (srb->cmnd[4] != 0x4D) ||
                (srb->cmnd[5] != 0x53) || (srb->cmnd[6] != 0x49) ||
                (srb->cmnd[7] != 0x44)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        dev_info_id = srb->cmnd[3];
@@ -2886,7 +3022,8 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (!CHK_MSXC(ms_card) && (dev_info_id == 0x13)) ||
                        !CHK_MSPRO(ms_card)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (dev_info_id == 0x15)
@@ -2895,8 +3032,10 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                buf_len = data_len = 0x6A;
 
        buf = kmalloc(buf_len, GFP_KERNEL);
-       if (!buf)
-               TRACE_RET(chip, TRANSPORT_ERROR);
+       if (!buf) {
+               rtsx_trace(chip);
+               return TRANSPORT_ERROR;
+       }
 
        i = 0;
        /*  GET Memory Stick Media Information Response Header */
@@ -2983,11 +3122,13 @@ static int sd_extention_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        if (get_lun_card(chip, lun) != SD_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        switch (srb->cmnd[0]) {
@@ -3017,7 +3158,8 @@ static int sd_extention_cmnd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        return result;
@@ -3044,21 +3186,25 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        if (get_lun_card(chip, lun) != MS_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (srb->cmnd[7] != KC_MG_R_PRO) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (!CHK_MSPRO(ms_card)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        key_format = srb->cmnd[10] & 0x3F;
@@ -3070,13 +3216,16 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[8] == 0x04) &&
                        (srb->cmnd[9] == 0x1C)) {
                        retval = mg_get_local_EKB(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
@@ -3085,13 +3234,16 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[8] == 0x00) &&
                        (srb->cmnd[9] == 0x24)) {
                        retval = mg_get_rsp_chg(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
@@ -3105,19 +3257,23 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[4] == 0x00) &&
                        (srb->cmnd[5] < 32)) {
                        retval = mg_get_ICV(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -3143,25 +3299,30 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!check_card_ready(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        if (check_card_wp(chip, lun)) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_PROTECT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        if (get_lun_card(chip, lun) != MS_CARD) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (srb->cmnd[7] != KC_MG_R_PRO) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (!CHK_MSPRO(ms_card)) {
                set_sense_type(chip, lun, SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        key_format = srb->cmnd[10] & 0x3F;
@@ -3173,13 +3334,16 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[8] == 0x00) &&
                        (srb->cmnd[9] == 0x0C)) {
                        retval = mg_set_leaf_id(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
@@ -3188,13 +3352,16 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[8] == 0x00) &&
                        (srb->cmnd[9] == 0x0C)) {
                        retval = mg_chg(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
@@ -3203,13 +3370,16 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[8] == 0x00) &&
                        (srb->cmnd[9] == 0x0C)) {
                        retval = mg_rsp(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
@@ -3223,19 +3393,23 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        (srb->cmnd[4] == 0x00) &&
                        (srb->cmnd[5] < 32)) {
                        retval = mg_set_ICV(srb, chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -3264,7 +3438,8 @@ int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        /* Logical Unit Not Ready Format in Progress */
                        set_sense_data(chip, lun, CUR_ERR,
                                       0x02, 0, 0x04, 0x04, 0, 0);
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 #endif
@@ -3276,7 +3451,8 @@ int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        /* Logical Unit Not Ready Format in Progress */
                        set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04,
                                        0, (u16)(ms_card->progress));
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
        }
 
index dab1995d1a6a5f9276edaaecf876fad2e166de77..f27491e802edeef46587208b6fc747d41c506270 100644 (file)
 #include <linux/sched.h>
 
 #include "rtsx.h"
-#include "rtsx_scsi.h"
-#include "rtsx_transport.h"
-#include "rtsx_chip.h"
-#include "rtsx_card.h"
 
 /***********************************************************************
  * Scatter-gather transfer buffer access routines
@@ -276,7 +272,8 @@ int rtsx_send_cmd(struct rtsx_chip *chip, u8 card, int timeout)
                dev_dbg(rtsx_dev(chip), "chip->int_reg = 0x%x\n",
                        chip->int_reg);
                err = -ETIMEDOUT;
-               TRACE_GOTO(chip, finish_send_cmd);
+               rtsx_trace(chip);
+               goto finish_send_cmd;
        }
 
        spin_lock_irq(&rtsx->reg_lock);
@@ -642,7 +639,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..a8d657bb5c1bca8f99be1ea050a952ff9d337afa 100644 (file)
@@ -25,9 +25,6 @@
 #include <linux/sched.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
 #include "sd.h"
 
 #define SD_MAX_RETRY_COUNT     3
@@ -108,13 +105,19 @@ static void sd_init_reg_addr(struct rtsx_chip *chip)
 
 static int sd_check_data0_status(struct rtsx_chip *chip)
 {
+       int retval;
        u8 stat;
 
-       RTSX_READ_REG(chip, REG_SD_STAT1, &stat);
+       retval = rtsx_read_register(chip, REG_SD_STAT1, &stat);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (!(stat & SD_DAT0_STATUS)) {
                sd_set_err_code(chip, SD_BUSY);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -187,7 +190,8 @@ RTY_SEND_CMD:
                                retval = sd_check_data0_status(chip);
                                if (retval != STATUS_SUCCESS) {
                                        rtsx_clear_sd_error(chip);
-                                       TRACE_RET(chip, retval);
+                                       rtsx_trace(chip);
+                                       return retval;
                                }
                        } else {
                                sd_set_err_code(chip, SD_TO_ERR);
@@ -198,7 +202,8 @@ RTY_SEND_CMD:
                }
                rtsx_clear_sd_error(chip);
 
-               TRACE_RET(chip, retval);
+               rtsx_trace(chip);
+               return retval;
        }
 
        if (rsp_type == SD_RSP_TYPE_R0)
@@ -208,14 +213,16 @@ RTY_SEND_CMD:
 
        if ((ptr[0] & 0xC0) != 0) {
                sd_set_err_code(chip, SD_STS_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (!(rsp_type & SD_NO_CHECK_CRC7)) {
                if (ptr[stat_idx] & SD_CRC7_ERR) {
                        if (cmd_idx == WRITE_MULTIPLE_BLOCK) {
                                sd_set_err_code(chip, SD_CRC_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (rty_cnt < SD_MAX_RETRY_COUNT) {
                                wait_timeout(20);
@@ -223,7 +230,8 @@ RTY_SEND_CMD:
                                goto RTY_SEND_CMD;
                        } else {
                                sd_set_err_code(chip, SD_CRC_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
        }
@@ -232,8 +240,10 @@ RTY_SEND_CMD:
                if ((cmd_idx != SEND_RELATIVE_ADDR) &&
                        (cmd_idx != SEND_IF_COND)) {
                        if (cmd_idx != STOP_TRANSMISSION) {
-                               if (ptr[1] & 0x80)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (ptr[1] & 0x80) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
 #ifdef SUPPORT_SD_LOCK
                        if (ptr[1] & 0x7D)
@@ -243,17 +253,20 @@ RTY_SEND_CMD:
                        {
                                dev_dbg(rtsx_dev(chip), "ptr[1]: 0x%02x\n",
                                        ptr[1]);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (ptr[2] & 0xFF) {
                                dev_dbg(rtsx_dev(chip), "ptr[2]: 0x%02x\n",
                                        ptr[2]);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (ptr[3] & 0x80) {
                                dev_dbg(rtsx_dev(chip), "ptr[3]: 0x%02x\n",
                                        ptr[3]);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (ptr[3] & 0x01)
                                sd_card->sd_data_buf_ready = 1;
@@ -282,8 +295,10 @@ static int sd_read_data(struct rtsx_chip *chip,
        if (!buf)
                buf_len = 0;
 
-       if (buf_len > 512)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (buf_len > 512) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -323,13 +338,16 @@ static int sd_read_data(struct rtsx_chip *chip,
                                            SD_RSP_TYPE_R1, NULL, 0);
                }
 
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (buf && buf_len) {
                retval = rtsx_read_ppbuf(chip, buf, buf_len);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -350,13 +368,16 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,
 
        if (buf_len > 512) {
                /* This function can't write data more than one page */
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (buf && buf_len) {
                retval = rtsx_write_ppbuf(chip, buf, buf_len);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        rtsx_init_cmd(chip);
@@ -395,7 +416,8 @@ static int sd_write_data(struct rtsx_chip *chip, u8 trans_mode,
                                sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0);
                }
 
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -412,7 +434,8 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)
        for (i = 0; i < 6; i++) {
                if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                        sd_set_err_code(chip, SD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = sd_send_cmd_get_rsp(chip, SEND_CSD, sd_card->sd_addr,
@@ -421,8 +444,10 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)
                        break;
        }
 
-       if (i == 6)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == 6) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        memcpy(sd_card->raw_csd, rsp + 1, 15);
 
@@ -464,10 +489,12 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)
                        else
                                sd_card->sd_clock = CLK_20;
                } else {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (CHK_MMC_SECTOR_MODE(sd_card)) {
@@ -507,8 +534,8 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)
 
 static int sd_set_sample_push_timing(struct rtsx_chip *chip)
 {
+       int retval;
        struct sd_info *sd_card = &(chip->sd_card);
-
        u8 val = 0;
 
        if ((chip->sd_ctl & SD_PUSH_POINT_CTL_MASK) == SD_PUSH_POINT_DELAY)
@@ -536,7 +563,11 @@ static int sd_set_sample_push_timing(struct rtsx_chip *chip)
                        val |= 0x08;
        }
 
-       RTSX_WRITE_REG(chip, REG_SD_CFG1, 0x1C, val);
+       retval = rtsx_write_register(chip, REG_SD_CFG1, 0x1C, val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -585,6 +616,7 @@ static void sd_choose_proper_clock(struct rtsx_chip *chip)
 
 static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div)
 {
+       int retval;
        u8 mask = 0, val = 0;
 
        mask = 0x60;
@@ -595,7 +627,11 @@ static int sd_set_clock_divider(struct rtsx_chip *chip, u8 clk_div)
        else if (clk_div == SD_CLK_DIVIDE_256)
                val = 0x20;
 
-       RTSX_WRITE_REG(chip, REG_SD_CFG1, mask, val);
+       retval = rtsx_write_register(chip, REG_SD_CFG1, mask, val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -606,14 +642,18 @@ static int sd_set_init_para(struct rtsx_chip *chip)
        int retval;
 
        retval = sd_set_sample_push_timing(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        sd_choose_proper_clock(chip);
 
        retval = switch_clock(chip, sd_card->sd_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -636,8 +676,10 @@ int sd_select_card(struct rtsx_chip *chip, int select)
        }
 
        retval = sd_send_cmd_get_rsp(chip, cmd_idx, addr, cmd_type, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -651,8 +693,10 @@ static int sd_update_lock_status(struct rtsx_chip *chip)
 
        retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, rsp, 5);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (rsp[1] & 0x02)
                sd_card->sd_lock_status |= SD_LOCKED;
@@ -662,8 +706,10 @@ static int sd_update_lock_status(struct rtsx_chip *chip)
        dev_dbg(rtsx_dev(chip), "sd_card->sd_lock_status = 0x%x\n",
                sd_card->sd_lock_status);
 
-       if (rsp[1] & 0x01)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (rsp[1] & 0x01) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -680,15 +726,18 @@ static int sd_wait_state_data_ready(struct rtsx_chip *chip, u8 state,
                retval = sd_send_cmd_get_rsp(chip, SEND_STATUS,
                                        sd_card->sd_addr, SD_RSP_TYPE_R1, rsp,
                                        5);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (((rsp[3] & 0x1E) == state) &&
                        ((rsp[3] & 0x01) == data_ready))
                        return STATUS_SUCCESS;
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage)
@@ -700,24 +749,39 @@ static int sd_change_bank_voltage(struct rtsx_chip *chip, u8 voltage)
                        retval = rtsx_write_phy_register(chip, 0x08,
                                                        0x4FC0 |
                                                        chip->phy_voltage);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                } else {
-                       RTSX_WRITE_REG(chip, SD_PAD_CTL, SD_IO_USING_1V8, 0);
+                       retval = rtsx_write_register(chip, SD_PAD_CTL,
+                                                    SD_IO_USING_1V8, 0);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        } else if (voltage == SD_IO_1V8) {
                if (chip->asic_code) {
                        retval = rtsx_write_phy_register(chip, 0x08,
                                                        0x4C40 |
                                                        chip->phy_voltage);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                } else {
-                       RTSX_WRITE_REG(chip, SD_PAD_CTL, SD_IO_USING_1V8,
-                               SD_IO_USING_1V8);
+                       retval = rtsx_write_register(chip, SD_PAD_CTL,
+                                                    SD_IO_USING_1V8,
+                                                    SD_IO_USING_1V8);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -728,33 +792,61 @@ static int sd_voltage_switch(struct rtsx_chip *chip)
        int retval;
        u8 stat;
 
-       RTSX_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP,
-               SD_CLK_TOGGLE_EN);
+       retval = rtsx_write_register(chip, SD_BUS_STAT,
+                                    SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP,
+                                    SD_CLK_TOGGLE_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = sd_send_cmd_get_rsp(chip, VOLTAGE_SWITCH, 0, SD_RSP_TYPE_R1,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        udelay(chip->sd_voltage_switch_delay);
 
-       RTSX_READ_REG(chip, SD_BUS_STAT, &stat);
+       retval = rtsx_read_register(chip, SD_BUS_STAT, &stat);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
                                SD_DAT1_STATUS | SD_DAT0_STATUS)) {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_WRITE_REG(chip, SD_BUS_STAT, 0xFF, SD_CLK_FORCE_STOP);
+       retval = rtsx_write_register(chip, SD_BUS_STAT, 0xFF,
+                                    SD_CLK_FORCE_STOP);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        retval = sd_change_bank_voltage(chip, SD_IO_1V8);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        wait_timeout(50);
 
-       RTSX_WRITE_REG(chip, SD_BUS_STAT, 0xFF, SD_CLK_TOGGLE_EN);
+       retval = rtsx_write_register(chip, SD_BUS_STAT, 0xFF,
+                                    SD_CLK_TOGGLE_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        wait_timeout(10);
 
-       RTSX_READ_REG(chip, SD_BUS_STAT, &stat);
+       retval = rtsx_read_register(chip, SD_BUS_STAT, &stat);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if ((stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
                                SD_DAT1_STATUS | SD_DAT0_STATUS)) !=
                        (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
@@ -763,23 +855,48 @@ static int sd_voltage_switch(struct rtsx_chip *chip)
                rtsx_write_register(chip, SD_BUS_STAT,
                                SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
                rtsx_write_register(chip, CARD_CLK_EN, 0xFF, 0);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_WRITE_REG(chip, SD_BUS_STAT, SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP,
-               0);
+       retval = rtsx_write_register(chip, SD_BUS_STAT,
+                                    SD_CLK_TOGGLE_EN | SD_CLK_FORCE_STOP, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
 
 static int sd_reset_dcm(struct rtsx_chip *chip, u8 tune_dir)
 {
+       int retval;
+
        if (tune_dir == TUNE_RX) {
-               RTSX_WRITE_REG(chip, DCM_DRP_CTL, 0xFF, DCM_RESET | DCM_RX);
-               RTSX_WRITE_REG(chip, DCM_DRP_CTL, 0xFF, DCM_RX);
+               retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF,
+                                            DCM_RESET | DCM_RX);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_RX);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else {
-               RTSX_WRITE_REG(chip, DCM_DRP_CTL, 0xFF, DCM_RESET | DCM_TX);
-               RTSX_WRITE_REG(chip, DCM_DRP_CTL, 0xFF, DCM_TX);
+               retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF,
+                                            DCM_RESET | DCM_TX);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, DCM_DRP_CTL, 0xFF, DCM_TX);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -791,7 +908,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,19 +917,42 @@ 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;
        }
 
        if (chip->asic_code) {
-               RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, CHANGE_CLK);
-               RTSX_WRITE_REG(chip, SD_VP_CTL, 0x1F, sample_point);
-               RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET, 0);
-               RTSX_WRITE_REG(chip, SD_VPCLK0_CTL, PHASE_NOT_RESET,
-                       PHASE_NOT_RESET);
-               RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0);
+               retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK,
+                                            CHANGE_CLK);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SD_VP_CTL, 0x1F,
+                                            sample_point);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
+                                            PHASE_NOT_RESET, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
+                                            PHASE_NOT_RESET, PHASE_NOT_RESET);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CLK_CTL, CHANGE_CLK, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else {
                rtsx_read_register(chip, SD_VP_CTL, &val);
                dev_dbg(rtsx_dev(chip), "SD_VP_CTL: 0x%x\n", val);
@@ -820,16 +960,34 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
                dev_dbg(rtsx_dev(chip), "SD_DCMPS_CTL: 0x%x\n", val);
 
                if (ddr_rx) {
-                       RTSX_WRITE_REG(chip, SD_VP_CTL, PHASE_CHANGE,
-                               PHASE_CHANGE);
+                       retval = rtsx_write_register(chip, SD_VP_CTL,
+                                                    PHASE_CHANGE,
+                                                    PHASE_CHANGE);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        udelay(50);
-                       RTSX_WRITE_REG(chip, SD_VP_CTL, 0xFF,
-                               PHASE_CHANGE | PHASE_NOT_RESET | sample_point);
+                       retval = rtsx_write_register(chip, SD_VP_CTL, 0xFF,
+                                                    PHASE_CHANGE | PHASE_NOT_RESET | sample_point);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                } else {
-                       RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, CHANGE_CLK);
+                       retval = rtsx_write_register(chip, CLK_CTL,
+                                                    CHANGE_CLK, CHANGE_CLK);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        udelay(50);
-                       RTSX_WRITE_REG(chip, SD_VP_CTL, 0xFF,
-                                       PHASE_NOT_RESET | sample_point);
+                       retval = rtsx_write_register(chip, SD_VP_CTL, 0xFF,
+                                                    PHASE_NOT_RESET | sample_point);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
                udelay(100);
 
@@ -839,26 +997,52 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
                rtsx_add_cmd(chip, CHECK_REG_CMD, SD_DCMPS_CTL,
                        DCMPS_CHANGE_DONE, DCMPS_CHANGE_DONE);
                retval = rtsx_send_cmd(chip, SD_CARD, 100);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, Fail);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto Fail;
+               }
 
                val = *rtsx_get_cmd_data(chip);
-               if (val & DCMPS_ERROR)
-                       TRACE_GOTO(chip, Fail);
+               if (val & DCMPS_ERROR) {
+                       rtsx_trace(chip);
+                       goto Fail;
+               }
 
-               if ((val & DCMPS_CURRENT_PHASE) != sample_point)
-                       TRACE_GOTO(chip, Fail);
+               if ((val & DCMPS_CURRENT_PHASE) != sample_point) {
+                       rtsx_trace(chip);
+                       goto Fail;
+               }
 
-               RTSX_WRITE_REG(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0);
-               if (ddr_rx)
-                       RTSX_WRITE_REG(chip, SD_VP_CTL, PHASE_CHANGE, 0);
-               else
-                       RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0);
+               retval = rtsx_write_register(chip, SD_DCMPS_CTL,
+                                            DCMPS_CHANGE, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               if (ddr_rx) {
+                       retval = rtsx_write_register(chip, SD_VP_CTL,
+                                                    PHASE_CHANGE, 0);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+               } else {
+                       retval = rtsx_write_register(chip, CLK_CTL,
+                                                    CHANGE_CLK, 0);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+               }
 
                udelay(50);
        }
 
-       RTSX_WRITE_REG(chip, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0);
+       retval = rtsx_write_register(chip, SD_CFG1, SD_ASYNC_FIFO_NOT_RST, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 
@@ -883,8 +1067,10 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)
 
        retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        cmd[0] = 0x40 | SEND_SCR;
        cmd[1] = 0;
@@ -896,13 +1082,16 @@ static int sd_check_spec(struct rtsx_chip *chip, u8 bus_width)
                        buf, 8, 250);
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        memcpy(sd_card->raw_scr, buf, 8);
 
-       if ((buf[0] & 0x0F) == 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if ((buf[0] & 0x0F) == 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -944,7 +1133,8 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group,
                        break;
 
                default:
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else if (func_group == SD_FUNC_GROUP_3) {
                support_offset = FUNCTION_GROUP3_SUPPORT_OFFSET;
@@ -971,7 +1161,8 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group,
                        break;
 
                default:
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else if (func_group == SD_FUNC_GROUP_4) {
                support_offset = FUNCTION_GROUP4_SUPPORT_OFFSET;
@@ -998,23 +1189,27 @@ static int sd_query_switch_result(struct rtsx_chip *chip, u8 func_group,
                        break;
 
                default:
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (func_group == SD_FUNC_GROUP_1) {
                if (!(buf[support_offset] & support_mask) ||
                        ((buf[query_switch_offset] & 0x0F) != query_switch)) {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
        /* Check 'Busy Status' */
        if ((buf[DATA_STRUCTURE_VER_OFFSET] == 0x01) &&
                    ((buf[check_busy_offset] & switch_busy) == switch_busy)) {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1056,7 +1251,8 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,
                        buf, 64, 250);
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        dev_dbg(rtsx_dev(chip), "%*ph\n", 64, buf);
@@ -1083,19 +1279,33 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,
 
                dev_dbg(rtsx_dev(chip), "Maximum current consumption: %dmA\n",
                        cc);
-               if ((cc == 0) || (cc > 800))
-                       TRACE_RET(chip, STATUS_FAIL);
+               if ((cc == 0) || (cc > 800)) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sd_query_switch_result(chip, func_group,
                                                func_to_switch, buf, 64);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if ((cc > 400) || (func_to_switch > CURRENT_LIMIT_400)) {
-                       RTSX_WRITE_REG(chip, OCPPARA2, SD_OCP_THD_MASK,
-                               chip->sd_800mA_ocp_thd);
-                       RTSX_WRITE_REG(chip, CARD_PWR_CTL, PMOS_STRG_MASK,
-                               PMOS_STRG_800mA);
+                       retval = rtsx_write_register(chip, OCPPARA2,
+                                                    SD_OCP_THD_MASK,
+                                                    chip->sd_800mA_ocp_thd);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PWR_CTL,
+                                                    PMOS_STRG_MASK,
+                                                    PMOS_STRG_800mA);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        }
 
@@ -1121,12 +1331,13 @@ 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) {
                        sd_set_err_code(chip, SD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = sd_check_switch_mode(chip, SD_CHECK_MODE, func_group,
@@ -1137,14 +1348,19 @@ 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;
                        }
 
-                       RTSX_READ_REG(chip, SD_STAT1, &stat);
+                       retval = rtsx_read_register(chip, SD_STAT1, &stat);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                        if (stat & SD_CRC16_ERR) {
                                dev_dbg(rtsx_dev(chip), "SD CRC16 error when switching mode\n");
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1154,8 +1370,10 @@ static int sd_check_switch(struct rtsx_chip *chip,
                wait_timeout(20);
        }
 
-       if (!switch_good)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!switch_good) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1170,8 +1388,10 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)
        /* Get supported functions */
        retval = sd_check_switch_mode(chip, SD_CHECK_MODE,
                        NO_ARGUMENT, NO_ARGUMENT, bus_width);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail);
 
@@ -1239,7 +1459,8 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)
                                sd_card->sd_switch_fail = SDR104_SUPPORT_MASK |
                                        DDR50_SUPPORT_MASK | SDR50_SUPPORT_MASK;
                        }
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (func_to_switch == SDR104_SUPPORT)
@@ -1253,10 +1474,17 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)
        }
 
        if (CHK_SD_DDR50(sd_card)) {
-               RTSX_WRITE_REG(chip, SD_PUSH_POINT_CTL, 0x06, 0x04);
+               retval = rtsx_write_register(chip, SD_PUSH_POINT_CTL, 0x06,
+                                            0x04);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                retval = sd_set_sample_push_timing(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        if (!func_to_switch || (func_to_switch == HS_SUPPORT)) {
@@ -1310,15 +1538,22 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)
                retval = sd_check_switch(chip, SD_FUNC_GROUP_4, func_to_switch,
                                        bus_width);
                if (retval != STATUS_SUCCESS) {
-                       if (sd_check_err_code(chip, SD_NO_CARD))
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (sd_check_err_code(chip, SD_NO_CARD)) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
                dev_dbg(rtsx_dev(chip), "Switch current limit finished! (%d)\n",
                        retval);
        }
 
-       if (CHK_SD_DDR50(sd_card))
-               RTSX_WRITE_REG(chip, SD_PUSH_POINT_CTL, 0x06, 0);
+       if (CHK_SD_DDR50(sd_card)) {
+               retval = rtsx_write_register(chip, SD_PUSH_POINT_CTL, 0x06, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1330,7 +1565,11 @@ static int sd_wait_data_idle(struct rtsx_chip *chip)
        u8 val = 0;
 
        for (i = 0; i < 100; i++) {
-               RTSX_READ_REG(chip, SD_DATA_STATE, &val);
+               retval = rtsx_read_register(chip, SD_DATA_STATE, &val);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
                if (val & SD_DATA_IDLE) {
                        retval = STATUS_SUCCESS;
                        break;
@@ -1348,8 +1587,10 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
        u8 cmd[5];
 
        retval = sd_change_phase(chip, sample_point, TUNE_RX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        cmd[0] = 0x40 | SEND_TUNING_PATTERN;
        cmd[1] = 0;
@@ -1363,7 +1604,8 @@ static int sd_sdr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
                (void)sd_wait_data_idle(chip);
 
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1376,15 +1618,19 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
        u8 cmd[5];
 
        retval = sd_change_phase(chip, sample_point, TUNE_RX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "sd ddr tuning rx\n");
 
        retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        cmd[0] = 0x40 | SD_STATUS;
        cmd[1] = 0;
@@ -1398,7 +1644,8 @@ static int sd_ddr_tuning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
                (void)sd_wait_data_idle(chip);
 
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1418,8 +1665,10 @@ static int mmc_ddr_tunning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
                bus_width = SD_BUS_WIDTH_1;
 
        retval = sd_change_phase(chip, sample_point, TUNE_RX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "mmc ddr tuning rx\n");
 
@@ -1435,7 +1684,8 @@ static int mmc_ddr_tunning_rx_cmd(struct rtsx_chip *chip, u8 sample_point)
                (void)sd_wait_data_idle(chip);
 
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1447,11 +1697,17 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)
        int retval;
 
        retval = sd_change_phase(chip, sample_point, TUNE_TX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
-               SD_RSP_80CLK_TIMEOUT_EN);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    SD_RSP_80CLK_TIMEOUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
                SD_RSP_TYPE_R1, NULL, 0);
@@ -1459,11 +1715,17 @@ static int sd_sdr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)
                if (sd_check_err_code(chip, SD_RSP_TIMEOUT)) {
                        rtsx_write_register(chip, SD_CFG3,
                                        SD_RSP_80CLK_TIMEOUT_EN, 0);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1475,8 +1737,10 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)
        u8 cmd[5], bus_width;
 
        retval = sd_change_phase(chip, sample_point, TUNE_TX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_SD(sd_card)) {
                bus_width = SD_BUS_WIDTH_4;
@@ -1490,11 +1754,17 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)
        }
 
        retval = sd_wait_state_data_ready(chip, 0x08, 1, 1000);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
-               SD_RSP_80CLK_TIMEOUT_EN);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    SD_RSP_80CLK_TIMEOUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        cmd[0] = 0x40 | PROGRAM_CSD;
        cmd[1] = 0;
@@ -1507,10 +1777,16 @@ static int sd_ddr_tuning_tx_cmd(struct rtsx_chip *chip, u8 sample_point)
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_sd_error(chip);
                rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr, SD_RSP_TYPE_R1,
                        NULL, 0);
@@ -1524,7 +1800,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 +1814,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 +1827,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;
 
@@ -1654,8 +1931,10 @@ static int sd_tuning_rx(struct rtsx_chip *chip)
        } else {
                if (CHK_MMC_DDR52(sd_card))
                        tuning_cmd = mmc_ddr_tunning_rx_cmd;
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        for (i = 0; i < 3; i++) {
@@ -1663,7 +1942,8 @@ static int sd_tuning_rx(struct rtsx_chip *chip)
                for (j = MAX_PHASE; j >= 0; j--) {
                        if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                                sd_set_err_code(chip, SD_NO_CARD);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = tuning_cmd(chip, (u8)j);
@@ -1680,12 +1960,16 @@ static int sd_tuning_rx(struct rtsx_chip *chip)
        dev_dbg(rtsx_dev(chip), "RX phase_map = 0x%08x\n", phase_map);
 
        final_phase = sd_search_final_phase(chip, phase_map, TUNE_RX);
-       if (final_phase == 0xFF)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (final_phase == 0xFF) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_change_phase(chip, final_phase, TUNE_RX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1698,8 +1982,12 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)
        u32 phase_map;
        u8 final_phase;
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
-               SD_RSP_80CLK_TIMEOUT_EN);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    SD_RSP_80CLK_TIMEOUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        phase_map = 0;
        for (i = MAX_PHASE; i >= 0; i--) {
@@ -1707,7 +1995,8 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)
                        sd_set_err_code(chip, SD_NO_CARD);
                        rtsx_write_register(chip, SD_CFG3,
                                                SD_RSP_80CLK_TIMEOUT_EN, 0);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = sd_change_phase(chip, (u8)i, TUNE_TX);
@@ -1722,18 +2011,27 @@ static int sd_ddr_pre_tuning_tx(struct rtsx_chip *chip)
                        phase_map |= 1 << i;
        }
 
-       RTSX_WRITE_REG(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN, 0);
+       retval = rtsx_write_register(chip, SD_CFG3, SD_RSP_80CLK_TIMEOUT_EN,
+                                    0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        dev_dbg(rtsx_dev(chip), "DDR TX pre tune phase_map = 0x%08x\n",
                phase_map);
 
        final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX);
-       if (final_phase == 0xFF)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (final_phase == 0xFF) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_change_phase(chip, final_phase, TUNE_TX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "DDR TX pre tune phase: %d\n",
                (int)final_phase);
@@ -1759,8 +2057,10 @@ static int sd_tuning_tx(struct rtsx_chip *chip)
        } else {
                if (CHK_MMC_DDR52(sd_card))
                        tuning_cmd = sd_ddr_tuning_tx_cmd;
-               else
-                       TRACE_RET(chip, STATUS_FAIL);
+               else {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        for (i = 0; i < 3; i++) {
@@ -1770,7 +2070,8 @@ static int sd_tuning_tx(struct rtsx_chip *chip)
                                sd_set_err_code(chip, SD_NO_CARD);
                                rtsx_write_register(chip, SD_CFG3,
                                                    SD_RSP_80CLK_TIMEOUT_EN, 0);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = tuning_cmd(chip, (u8)j);
@@ -1787,12 +2088,16 @@ static int sd_tuning_tx(struct rtsx_chip *chip)
        dev_dbg(rtsx_dev(chip), "TX phase_map = 0x%08x\n", phase_map);
 
        final_phase = sd_search_final_phase(chip, phase_map, TUNE_TX);
-       if (final_phase == 0xFF)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (final_phase == 0xFF) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_change_phase(chip, final_phase, TUNE_TX);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1802,12 +2107,16 @@ static int sd_sdr_tuning(struct rtsx_chip *chip)
        int retval;
 
        retval = sd_tuning_tx(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_tuning_rx(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1818,23 +2127,31 @@ static int sd_ddr_tuning(struct rtsx_chip *chip)
 
        if (!(chip->sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) {
                retval = sd_ddr_pre_tuning_tx(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
                retval = sd_change_phase(chip, (u8)chip->sd_ddr_tx_phase,
                                        TUNE_TX);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        retval = sd_tuning_rx(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!(chip->sd_ctl & SD_DDR_TX_PHASE_SET_BY_USER)) {
                retval = sd_tuning_tx(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1846,23 +2163,31 @@ static int mmc_ddr_tuning(struct rtsx_chip *chip)
 
        if (!(chip->sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) {
                retval = sd_ddr_pre_tuning_tx(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
                retval = sd_change_phase(chip, (u8)chip->mmc_ddr_tx_phase,
                                        TUNE_TX);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        retval = sd_tuning_rx(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!(chip->sd_ctl & MMC_DDR_TX_PHASE_SET_BY_USER)) {
                retval = sd_tuning_tx(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1875,12 +2200,16 @@ int sd_switch_clock(struct rtsx_chip *chip)
        int re_tuning = 0;
 
        retval = select_card(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = switch_clock(chip, sd_card->sd_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (re_tuning) {
                if (CHK_SD(sd_card)) {
@@ -1893,8 +2222,10 @@ int sd_switch_clock(struct rtsx_chip *chip)
                                retval = mmc_ddr_tuning(chip);
                }
 
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1924,41 +2255,100 @@ static int sd_prepare_reset(struct rtsx_chip *chip)
        chip->sd_io = 0;
 
        retval = sd_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, retval);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
-       RTSX_WRITE_REG(chip, REG_SD_CFG1, 0xFF, 0x40);
+       retval = rtsx_write_register(chip, REG_SD_CFG1, 0xFF, 0x40);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_STOP, SD_STOP | SD_CLR_ERR,
-               SD_STOP | SD_CLR_ERR);
+       retval = rtsx_write_register(chip, CARD_STOP, SD_STOP | SD_CLR_ERR,
+                                    SD_STOP | SD_CLR_ERR);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = select_card(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
 
 static int sd_pull_ctl_disable(struct rtsx_chip *chip)
 {
+       int retval;
+
        if (CHECK_PID(chip, 0x5208)) {
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF,
-                       XD_D3_PD | SD_D7_PD | SD_CLK_PD | SD_D5_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF,
-                       SD_D6_PD | SD_D0_PD | SD_D1_PD | XD_D5_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF,
-                       SD_D4_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF,
-                       XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF,
-                       MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD);
+               retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF,
+                                            XD_D3_PD | SD_D7_PD | SD_CLK_PD | SD_D5_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF,
+                                            SD_D6_PD | SD_D0_PD | SD_D1_PD | XD_D5_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF,
+                                            SD_D4_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF,
+                                            XD_RDY_PD | SD_D3_PD | SD_D2_PD | XD_ALE_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF,
+                                            MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF,
+                                            MS_D5_PD | MS_D4_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else if (CHECK_PID(chip, 0x5288)) {
                if (CHECK_BARO_PKG(chip, QFN)) {
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF, 0x4B);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF, 0x69);
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL1,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL2,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL3,
+                                                    0xFF, 0x4B);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL4,
+                                                    0xFF, 0x69);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        }
 
@@ -1998,8 +2388,10 @@ int sd_pull_ctl_enable(struct rtsx_chip *chip)
        }
 
        retval = rtsx_send_cmd(chip, SD_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -2009,29 +2401,41 @@ static int sd_init_power(struct rtsx_chip *chip)
        int retval;
 
        retval = sd_power_off_card3v3(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!chip->ft2_fast_mode)
                wait_timeout(250);
 
        retval = enable_card_clock(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (chip->asic_code) {
                retval = sd_pull_ctl_enable(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               RTSX_WRITE_REG(chip, FPGA_PULL_CTL, FPGA_SD_PULL_CTL_BIT | 0x20,
-                       0);
+               retval = rtsx_write_register(chip, FPGA_PULL_CTL,
+                                            FPGA_SD_PULL_CTL_BIT | 0x20, 0);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        if (!chip->ft2_fast_mode) {
                retval = card_power_on(chip, SD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(260);
 
@@ -2039,21 +2443,37 @@ static int sd_init_power(struct rtsx_chip *chip)
                if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) {
                        dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n",
                                chip->ocp_stat);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
        }
 
-       RTSX_WRITE_REG(chip, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN);
+       retval = rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN,
+                                    SD_OUTPUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
 
 static int sd_dummy_clock(struct rtsx_chip *chip)
 {
-       RTSX_WRITE_REG(chip, REG_SD_CFG3, 0x01, 0x01);
+       int retval;
+
+       retval = rtsx_write_register(chip, REG_SD_CFG3, 0x01, 0x01);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        wait_timeout(5);
-       RTSX_WRITE_REG(chip, REG_SD_CFG3, 0x01, 0);
+       retval = rtsx_write_register(chip, REG_SD_CFG3, 0x01, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -2085,7 +2505,8 @@ static int sd_read_lba0(struct rtsx_chip *chip)
                5, 512, 1, bus_width, NULL, 0, 100);
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -2101,8 +2522,10 @@ static int sd_check_wp_state(struct rtsx_chip *chip)
 
        retval = sd_send_cmd_get_rsp(chip, APP_CMD,
                        sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        cmd[0] = 0x40 | SD_STATUS;
        cmd[1] = 0;
@@ -2117,7 +2540,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip)
 
                sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, NULL, 0);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        dev_dbg(rtsx_dev(chip), "ACMD13:\n");
@@ -2141,14 +2565,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 +2582,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)
@@ -2165,12 +2590,16 @@ Switch_Fail:
 #endif
 
        retval = sd_prepare_reset(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_dummy_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (CHK_SDIO_EXIST(chip) && !CHK_SDIO_IGNORED(chip) && try_sdio) {
                int rty_cnt = 0;
@@ -2178,7 +2607,8 @@ Switch_Fail:
                for (; rty_cnt < chip->sdio_retry_cnt; rty_cnt++) {
                        if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                                sd_set_err_code(chip, SD_NO_CARD);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = sd_send_cmd_get_rsp(chip, IO_SEND_OP_COND, 0,
@@ -2190,7 +2620,8 @@ Switch_Fail:
                                        dev_dbg(rtsx_dev(chip), "SD_IO card (Function number: %d)!\n",
                                                func_num);
                                        chip->sd_io = 1;
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
 
                                break;
@@ -2208,8 +2639,10 @@ Switch_Fail:
 RTY_SD_RST:
        retval = sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        wait_timeout(20);
 
@@ -2217,7 +2650,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;
                }
        }
@@ -2227,8 +2660,10 @@ RTY_SD_RST:
 
                retval = sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0,
                                        SD_RSP_TYPE_R0, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(20);
        }
@@ -2239,14 +2674,17 @@ RTY_SD_RST:
                if (retval != STATUS_SUCCESS) {
                        if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                                sd_set_err_code(chip, SD_NO_CARD);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        j++;
                        if (j < 3)
                                goto RTY_SD_RST;
-                       else
-                               TRACE_RET(chip, STATUS_FAIL);
+                       else {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
 
                retval = sd_send_cmd_get_rsp(chip, SD_APP_OP_COND, voltage,
@@ -2255,16 +2693,20 @@ RTY_SD_RST:
                        k++;
                        if (k < 3)
                                goto RTY_SD_RST;
-                       else
-                               TRACE_RET(chip, STATUS_FAIL);
+                       else {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
 
                i++;
                wait_timeout(20);
        } while (!(rsp[1] & 0x80) && (i < 255));
 
-       if (i == 255)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == 255) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (hi_cap_flow) {
                if (rsp[1] & 0x40)
@@ -2272,29 +2714,35 @@ 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);
 
        if (support_1v8) {
                retval = sd_voltage_switch(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        retval = sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        for (i = 0; i < 3; i++) {
                retval = sd_send_cmd_get_rsp(chip, SEND_RELATIVE_ADDR, 0,
                                        SD_RSP_TYPE_R6, rsp, 5);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                sd_card->sd_addr = (u32)rsp[1] << 24;
                sd_card->sd_addr += (u32)rsp[2] << 16;
@@ -2304,18 +2752,24 @@ RTY_SD_RST:
        }
 
        retval = sd_check_csd(chip, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_select_card(chip, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
 #ifdef SUPPORT_SD_LOCK
 SD_UNLOCK_ENTRY:
        retval = sd_update_lock_status(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (sd_card->sd_lock_status & SD_LOCKED) {
                sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE | SD_PWD_EXIST);
@@ -2327,24 +2781,32 @@ SD_UNLOCK_ENTRY:
 
        retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_send_cmd_get_rsp(chip, SET_CLR_CARD_DETECT, 0,
                                SD_RSP_TYPE_R1, NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (support_1v8) {
                retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr,
                                        SD_RSP_TYPE_R1, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2,
                                        SD_RSP_TYPE_R1, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                switch_bus_width = SD_BUS_WIDTH_4;
        } else {
@@ -2353,15 +2815,19 @@ SD_UNLOCK_ENTRY:
 
        retval = sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, SD_RSP_TYPE_R1,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return 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 +2844,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;
                        }
@@ -2397,13 +2863,17 @@ SD_UNLOCK_ENTRY:
        if (!support_1v8) {
                retval = sd_send_cmd_get_rsp(chip, APP_CMD, sd_card->sd_addr,
                                        SD_RSP_TYPE_R1, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sd_send_cmd_get_rsp(chip, SET_BUS_WIDTH, 2,
                                        SD_RSP_TYPE_R1, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
 #ifdef SUPPORT_SD_LOCK
@@ -2413,12 +2883,18 @@ SD_UNLOCK_ENTRY:
        if (!sd20_mode && CHK_SD30_SPEED(sd_card)) {
                int read_lba0 = 1;
 
-               RTSX_WRITE_REG(chip, SD30_DRIVE_SEL, 0x07,
-                       chip->sd30_drive_sel_1v8);
+               retval = rtsx_write_register(chip, SD30_DRIVE_SEL, 0x07,
+                                            chip->sd30_drive_sel_1v8);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
 
                retval = sd_set_init_para(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (CHK_SD_DDR50(sd_card))
                        retval = sd_ddr_tuning(chip);
@@ -2427,14 +2903,17 @@ SD_UNLOCK_ENTRY:
 
                if (retval != STATUS_SUCCESS) {
                        if (sd20_mode) {
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        } else {
                                retval = sd_init_power(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
-                               try_sdio = 0;
-                               sd20_mode = 1;
+                               try_sdio = false;
+                               sd20_mode = true;
                                goto Switch_Fail;
                        }
                }
@@ -2452,14 +2931,17 @@ SD_UNLOCK_ENTRY:
                        retval = sd_read_lba0(chip);
                        if (retval != STATUS_SUCCESS) {
                                if (sd20_mode) {
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                } else {
                                        retval = sd_init_power(chip);
-                                       if (retval != STATUS_SUCCESS)
-                                               TRACE_RET(chip, STATUS_FAIL);
+                                       if (retval != STATUS_SUCCESS) {
+                                               rtsx_trace(chip);
+                                               return STATUS_FAIL;
+                                       }
 
-                                       try_sdio = 0;
-                                       sd20_mode = 1;
+                                       try_sdio = false;
+                                       sd20_mode = true;
                                        goto Switch_Fail;
                                }
                        }
@@ -2467,15 +2949,27 @@ SD_UNLOCK_ENTRY:
        }
 
        retval = sd_check_wp_state(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        chip->card_bus_width[chip->card2lun[SD_CARD]] = 4;
 
 #ifdef SUPPORT_SD_LOCK
        if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) {
-               RTSX_WRITE_REG(chip, REG_SD_BLOCK_CNT_H, 0xFF, 0x02);
-               RTSX_WRITE_REG(chip, REG_SD_BLOCK_CNT_L, 0xFF, 0x00);
+               retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_H, 0xFF,
+                                            0x02);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_L, 0xFF,
+                                            0x00);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 #endif
 
@@ -2493,8 +2987,10 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)
 
        retval = sd_send_cmd_get_rsp(chip, BUSTEST_W, 0, SD_RSP_TYPE_R1, NULL,
                                0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, SWITCH_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return SWITCH_FAIL;
+       }
 
        if (width == MMC_8BIT_BUS) {
                buf[0] = 0x55;
@@ -2510,20 +3006,25 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)
        }
 
        retval = rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0x02);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, SWITCH_ERR);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return SWITCH_ERR;
+       }
 
        retval = sd_write_data(chip, SD_TM_AUTO_WRITE_3,
                        NULL, 0, byte_cnt, 1, bus_width, buf, len, 100);
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_sd_error(chip);
                rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0);
-               TRACE_RET(chip, SWITCH_ERR);
+               rtsx_trace(chip);
+               return SWITCH_ERR;
        }
 
        retval = rtsx_write_register(chip, REG_SD_CFG3, 0x02, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, SWITCH_ERR);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return SWITCH_ERR;
+       }
 
        dev_dbg(rtsx_dev(chip), "SD/MMC CMD %d\n", BUSTEST_R);
 
@@ -2558,7 +3059,8 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)
        retval = rtsx_send_cmd(chip, SD_CARD, 100);
        if (retval < 0) {
                rtsx_clear_sd_error(chip);
-               TRACE_RET(chip, SWITCH_ERR);
+               rtsx_trace(chip);
+               return SWITCH_ERR;
        }
 
        ptr = rtsx_get_cmd_data(chip) + 1;
@@ -2600,11 +3102,12 @@ static int mmc_test_switch_bus(struct rtsx_chip *chip, u8 width)
                }
        }
 
-       TRACE_RET(chip, SWITCH_FAIL);
+       rtsx_trace(chip);
+       return SWITCH_FAIL;
 }
 
 
-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;
@@ -2651,14 +3154,16 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)
                        sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
                                        SD_RSP_TYPE_R1, NULL, 0);
                }
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        ptr = rtsx_get_cmd_data(chip);
        if (ptr[0] & SD_TRANSFER_ERR) {
                sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
                                SD_RSP_TYPE_R1, NULL, 0);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (CHK_MMC_SECTOR_MODE(sd_card)) {
@@ -2690,8 +3195,10 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)
 
        sd_choose_proper_clock(chip);
        retval = switch_clock(chip, sd_card->sd_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* Test Bus Procedure */
        retval = mmc_test_switch_bus(chip, MMC_8BIT_BUS);
@@ -2713,10 +3220,12 @@ static int mmc_switch_timing_bus(struct rtsx_chip *chip, int switch_ddr)
                        CLR_MMC_8BIT(sd_card);
                        CLR_MMC_4BIT(sd_card);
                } else {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else {
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -2727,7 +3236,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;
@@ -2739,21 +3248,26 @@ static int reset_mmc(struct rtsx_chip *chip)
 
 Switch_Fail:
        retval = sd_prepare_reset(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, retval);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        SET_MMC(sd_card);
 
 RTY_MMC_RST:
        retval = sd_send_cmd_get_rsp(chip, GO_IDLE_STATE, 0, SD_RSP_TYPE_R0,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        do {
                if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                        sd_set_err_code(chip, SD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = sd_send_cmd_get_rsp(chip, SEND_OP_COND,
@@ -2767,7 +3281,8 @@ RTY_MMC_RST:
                                        sd_clr_err_code(chip);
                                        goto RTY_MMC_RST;
                                } else {
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        } else {
                                j++;
@@ -2775,7 +3290,8 @@ RTY_MMC_RST:
                                        sd_clr_err_code(chip);
                                        goto RTY_MMC_RST;
                                } else {
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        }
                }
@@ -2784,8 +3300,10 @@ RTY_MMC_RST:
                i++;
        } while (!(rsp[1] & 0x80) && (i < 255));
 
-       if (i == 255)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (i == 255) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if ((rsp[1] & 0x60) == 0x40)
                SET_MMC_SECTOR_MODE(sd_card);
@@ -2794,40 +3312,54 @@ RTY_MMC_RST:
 
        retval = sd_send_cmd_get_rsp(chip, ALL_SEND_CID, 0, SD_RSP_TYPE_R2,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        sd_card->sd_addr = 0x00100000;
        retval = sd_send_cmd_get_rsp(chip, SET_RELATIVE_ADDR, sd_card->sd_addr,
                                SD_RSP_TYPE_R6, rsp, 5);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_check_csd(chip, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        spec_ver = (sd_card->raw_csd[0] & 0x3C) >> 2;
 
        retval = sd_select_card(chip, 1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, 0x200, SD_RSP_TYPE_R1,
                                NULL, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
 #ifdef SUPPORT_SD_LOCK
 MMC_UNLOCK_ENTRY:
        retval = sd_update_lock_status(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 #endif
 
        retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        chip->card_bus_width[chip->card2lun[SD_CARD]] = 1;
 
@@ -2837,29 +3369,39 @@ MMC_UNLOCK_ENTRY:
                        retval = mmc_switch_timing_bus(chip, switch_ddr);
                        if (retval != STATUS_SUCCESS) {
                                retval = sd_init_power(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                                sd_card->mmc_dont_switch_bus = 1;
-                               TRACE_GOTO(chip, Switch_Fail);
+                               rtsx_trace(chip);
+                               goto Switch_Fail;
                        }
                }
 
-               if (CHK_MMC_SECTOR_MODE(sd_card) && (sd_card->capacity == 0))
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (CHK_MMC_SECTOR_MODE(sd_card) && (sd_card->capacity == 0)) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (switch_ddr && CHK_MMC_DDR52(sd_card)) {
                        retval = sd_set_init_para(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        retval = mmc_ddr_tuning(chip);
                        if (retval != STATUS_SUCCESS) {
                                retval = sd_init_power(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
-                               switch_ddr = 0;
-                               TRACE_GOTO(chip, Switch_Fail);
+                               switch_ddr = false;
+                               rtsx_trace(chip);
+                               goto Switch_Fail;
                        }
 
                        retval = sd_wait_state_data_ready(chip, 0x08, 1, 1000);
@@ -2867,11 +3409,14 @@ MMC_UNLOCK_ENTRY:
                                retval = sd_read_lba0(chip);
                                if (retval != STATUS_SUCCESS) {
                                        retval = sd_init_power(chip);
-                                       if (retval != STATUS_SUCCESS)
-                                               TRACE_RET(chip, STATUS_FAIL);
+                                       if (retval != STATUS_SUCCESS) {
+                                               rtsx_trace(chip);
+                                               return STATUS_FAIL;
+                                       }
 
-                                       switch_ddr = 0;
-                                       TRACE_GOTO(chip, Switch_Fail);
+                                       switch_ddr = false;
+                                       rtsx_trace(chip);
+                                       goto Switch_Fail;
                                }
                        }
                }
@@ -2879,8 +3424,18 @@ MMC_UNLOCK_ENTRY:
 
 #ifdef SUPPORT_SD_LOCK
        if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) {
-               RTSX_WRITE_REG(chip, REG_SD_BLOCK_CNT_H, 0xFF, 0x02);
-               RTSX_WRITE_REG(chip, REG_SD_BLOCK_CNT_L, 0xFF, 0x00);
+               retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_H, 0xFF,
+                                            0x02);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, REG_SD_BLOCK_CNT_L, 0xFF,
+                                            0x00);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 #endif
 
@@ -2902,71 +3457,103 @@ int reset_sd_card(struct rtsx_chip *chip)
        chip->capacity[chip->card2lun[SD_CARD]] = 0;
 
        retval = enable_card_clock(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (chip->ignore_sd && CHK_SDIO_EXIST(chip) &&
                !CHK_SDIO_IGNORED(chip)) {
                if (chip->asic_code) {
                        retval = sd_pull_ctl_enable(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                } else {
                        retval = rtsx_write_register(chip, FPGA_PULL_CTL,
                                                FPGA_SD_PULL_CTL_BIT | 0x20, 0);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
                retval = card_share_mode(chip, SD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                chip->sd_io = 1;
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = sd_init_power(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (chip->sd_ctl & RESET_MMC_FIRST) {
                retval = reset_mmc(chip);
                if (retval != STATUS_SUCCESS) {
-                       if (sd_check_err_code(chip, SD_NO_CARD))
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (sd_check_err_code(chip, SD_NO_CARD)) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        retval = reset_sd(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
        } else {
                retval = reset_sd(chip);
                if (retval != STATUS_SUCCESS) {
-                       if (sd_check_err_code(chip, SD_NO_CARD))
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (sd_check_err_code(chip, SD_NO_CARD)) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if (chip->sd_io) {
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        } else {
                                retval = reset_mmc(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
                }
        }
 
        retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, REG_SD_BYTE_CNT_L, 0xFF, 0);
-       RTSX_WRITE_REG(chip, REG_SD_BYTE_CNT_H, 0xFF, 2);
+       retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_L, 0xFF, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_H, 0xFF, 2);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity;
 
        retval = sd_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "sd_card->sd_type = 0x%x\n", sd_card->sd_type);
 
@@ -2992,29 +3579,47 @@ static int reset_mmc_only(struct rtsx_chip *chip)
        chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity = 0;
 
        retval = enable_card_clock(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_init_power(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = reset_mmc(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = sd_set_clock_divider(chip, SD_CLK_DIVIDE_0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, REG_SD_BYTE_CNT_L, 0xFF, 0);
-       RTSX_WRITE_REG(chip, REG_SD_BYTE_CNT_H, 0xFF, 2);
+       retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_L, 0xFF, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, REG_SD_BYTE_CNT_H, 0xFF, 2);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity;
 
        retval = sd_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        dev_dbg(rtsx_dev(chip), "In reset_mmc_only, sd_card->sd_type = 0x%x\n",
                sd_card->sd_type);
@@ -3032,15 +3637,18 @@ static int wait_data_buf_ready(struct rtsx_chip *chip)
        for (i = 0; i < WAIT_DATA_READY_RTY_CNT; i++) {
                if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                        sd_set_err_code(chip, SD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                sd_card->sd_data_buf_ready = 0;
 
                retval = sd_send_cmd_get_rsp(chip, SEND_STATUS,
                                sd_card->sd_addr, SD_RSP_TYPE_R1, NULL, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                if (sd_card->sd_data_buf_ready) {
                        return sd_send_cmd_get_rsp(chip, SEND_STATUS,
@@ -3050,7 +3658,8 @@ static int wait_data_buf_ready(struct rtsx_chip *chip)
 
        sd_set_err_code(chip, SD_TO_ERR);
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 void sd_stop_seq_mode(struct rtsx_chip *chip)
@@ -3118,8 +3727,10 @@ static inline int sd_auto_tune_clock(struct rtsx_chip *chip)
        }
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -3156,7 +3767,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
                        chip->card_fail |= SD_CARD;
                        chip->capacity[chip->card2lun[SD_CARD]] = 0;
                        chip->rw_need_retry = 1;
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -3170,7 +3782,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
        retval = sd_switch_clock(chip);
        if (retval != STATUS_SUCCESS) {
                sd_set_err_code(chip, SD_IO_ERR);
-               TRACE_GOTO(chip, RW_FAIL);
+               rtsx_trace(chip);
+               goto RW_FAIL;
        }
 
        if (sd_card->seq_mode &&
@@ -3191,7 +3804,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
                if (retval != STATUS_SUCCESS) {
                        chip->rw_need_retry = 1;
                        sd_set_err_code(chip, SD_STS_ERR);
-                       TRACE_GOTO(chip, RW_FAIL);
+                       rtsx_trace(chip);
+                       goto RW_FAIL;
                }
 
                sd_card->seq_mode = 0;
@@ -3199,7 +3813,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
                retval = rtsx_write_register(chip, RBCTL, RB_FLUSH, RB_FLUSH);
                if (retval != STATUS_SUCCESS) {
                        sd_set_err_code(chip, SD_IO_ERR);
-                       TRACE_GOTO(chip, RW_FAIL);
+                       rtsx_trace(chip);
+                       goto RW_FAIL;
                }
 
                if ((sd_card->pre_sec_cnt < 0x80)
@@ -3290,21 +3905,24 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
 
                                chip->rw_need_retry = 1;
                                sd_set_err_code(chip, SD_TO_ERR);
-                               TRACE_GOTO(chip, RW_FAIL);
+                               rtsx_trace(chip);
+                               goto RW_FAIL;
                        }
 
                        retval = wait_data_buf_ready(chip);
                        if (retval != STATUS_SUCCESS) {
                                chip->rw_need_retry = 1;
                                sd_set_err_code(chip, SD_TO_ERR);
-                               TRACE_GOTO(chip, RW_FAIL);
+                               rtsx_trace(chip);
+                               goto RW_FAIL;
                        }
 
                        retval = sd_send_cmd_get_rsp(chip, WRITE_MULTIPLE_BLOCK,
                                        data_addr, SD_RSP_TYPE_R1, NULL, 0);
                        if (retval != STATUS_SUCCESS) {
                                chip->rw_need_retry = 1;
-                               TRACE_GOTO(chip, RW_FAIL);
+                               rtsx_trace(chip);
+                               goto RW_FAIL;
                        }
 
                        rtsx_init_cmd(chip);
@@ -3348,7 +3966,8 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
                if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                        chip->rw_need_retry = 0;
                        dev_dbg(rtsx_dev(chip), "No card exist, exit sd_rw\n");
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                chip->rw_need_retry = 1;
@@ -3357,21 +3976,25 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector,
                                        SD_RSP_TYPE_R1b, NULL, 0);
                if (retval != STATUS_SUCCESS) {
                        sd_set_err_code(chip, SD_STS_ERR);
-                       TRACE_GOTO(chip, RW_FAIL);
+                       rtsx_trace(chip);
+                       goto RW_FAIL;
                }
 
                if (stat & (SD_CRC7_ERR | SD_CRC16_ERR | SD_CRC_WRITE_ERR)) {
                        dev_dbg(rtsx_dev(chip), "SD CRC error, tune clock!\n");
                        sd_set_err_code(chip, SD_CRC_ERR);
-                       TRACE_GOTO(chip, RW_FAIL);
+                       rtsx_trace(chip);
+                       goto RW_FAIL;
                }
 
                if (err == STATUS_TIMEDOUT) {
                        sd_set_err_code(chip, SD_TO_ERR);
-                       TRACE_GOTO(chip, RW_FAIL);
+                       rtsx_trace(chip);
+                       goto RW_FAIL;
                }
 
-               TRACE_RET(chip, err);
+               rtsx_trace(chip);
+               return err;
        }
 
        sd_card->pre_sec_addr = start_sector;
@@ -3386,7 +4009,8 @@ RW_FAIL:
        if (detect_card_cd(chip, SD_CARD) != STATUS_SUCCESS) {
                chip->rw_need_retry = 0;
                dev_dbg(rtsx_dev(chip), "No card exist, exit sd_rw\n");
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (sd_check_err_code(chip, SD_CRC_ERR)) {
@@ -3407,7 +4031,8 @@ RW_FAIL:
                }
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 #ifdef SUPPORT_CPRM
@@ -3417,7 +4042,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;
@@ -3473,13 +4098,16 @@ RTY_SEND_CMD:
 
                        if (rsp_type & SD_WAIT_BUSY_END) {
                                retval = sd_check_data0_status(chip);
-                               if (retval != STATUS_SUCCESS)
-                                       TRACE_RET(chip, retval);
+                               if (retval != STATUS_SUCCESS) {
+                                       rtsx_trace(chip);
+                                       return retval;
+                               }
                        } else {
                                sd_set_err_code(chip, SD_TO_ERR);
                        }
                }
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (rsp_type == SD_RSP_TYPE_R0)
@@ -3489,14 +4117,16 @@ RTY_SEND_CMD:
 
        if ((ptr[0] & 0xC0) != 0) {
                sd_set_err_code(chip, SD_STS_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (!(rsp_type & SD_NO_CHECK_CRC7)) {
                if (ptr[stat_idx] & SD_CRC7_ERR) {
                        if (cmd_idx == WRITE_MULTIPLE_BLOCK) {
                                sd_set_err_code(chip, SD_CRC_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        if (rty_cnt < SD_MAX_RETRY_COUNT) {
                                wait_timeout(20);
@@ -3504,16 +4134,19 @@ RTY_SEND_CMD:
                                goto RTY_SEND_CMD;
                        } else {
                                sd_set_err_code(chip, SD_CRC_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
        }
 
        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 (ptr[1] & 0x80)
-                               TRACE_RET(chip, STATUS_FAIL);
+               if ((cmd_idx != STOP_TRANSMISSION) && !special_check) {
+                       if (ptr[1] & 0x80) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                }
 #ifdef SUPPORT_SD_LOCK
                if (ptr[1] & 0x7D)
@@ -3521,19 +4154,26 @@ RTY_SEND_CMD:
                if (ptr[1] & 0x7F)
 #endif
                {
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
+               if (ptr[2] & 0xF8) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
-               if (ptr[2] & 0xF8)
-                       TRACE_RET(chip, STATUS_FAIL);
 
                if (cmd_idx == SELECT_CARD) {
                        if (rsp_type == SD_RSP_TYPE_R2) {
-                               if ((ptr[3] & 0x1E) != 0x04)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if ((ptr[3] & 0x1E) != 0x04) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
 
                        } else if (rsp_type == SD_RSP_TYPE_R0) {
-                               if ((ptr[3] & 0x1E) != 0x03)
-                                       TRACE_RET(chip, STATUS_FAIL);
+                               if ((ptr[3] & 0x1E) != 0x03) {
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
+                               }
                        }
                }
        }
@@ -3570,8 +4210,10 @@ int ext_sd_get_rsp(struct rtsx_chip *chip, int len, u8 *rsp, u8 rsp_type)
        rtsx_add_cmd(chip, READ_REG_CMD, REG_SD_CMD5, 0xFF, 0);
 
        retval = rtsx_send_cmd(chip, SD_CARD, 100);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (rsp) {
                int min_len = (rsp_len < len) ? rsp_len : len;
@@ -3617,7 +4259,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (!(CHK_BIT(chip->lun_mc, lun))) {
                SET_BIT(chip->lun_mc, lun);
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) ||
@@ -3625,7 +4268,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) ||
                (0x64 != srb->cmnd[8])) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        switch (srb->cmnd[1] & 0x0F) {
@@ -3639,7 +4283,8 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        buf[5] = (1 == CHK_SD(sd_card)) ?  0x01 : 0x02;
@@ -3702,30 +4347,34 @@ 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) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
        if (sd_card->pre_cmd_err) {
                sd_card->pre_cmd_err = 0;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        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];
@@ -3733,64 +4382,83 @@ int sd_execute_no_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = get_rsp_type(srb, &rsp_type, &rsp_len);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        sd_card->last_rsp_type = rsp_type;
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
 #ifdef SUPPORT_SD_LOCK
        if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
                if (CHK_MMC_8BIT(sd_card)) {
                        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03,
                                                SD_BUS_WIDTH_8);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) {
                        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03,
                                                SD_BUS_WIDTH_4);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
                }
        }
 #else
        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 #endif
 
        if (standby) {
                retval = sd_select_card(chip, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Cmd_Failed;
+               }
        }
 
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Cmd_Failed;
+               }
        }
 
        retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type,
-                       sd_card->rsp, rsp_len, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
+                       sd_card->rsp, rsp_len, false);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Cmd_Failed;
+       }
 
        if (standby) {
                retval = sd_select_card(chip, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Cmd_Failed;
+               }
        }
 
 #ifdef SUPPORT_SD_LOCK
        retval = sd_update_lock_status(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Cmd_Failed;
+       }
 #endif
 
        scsi_set_resid(srb, 0);
@@ -3804,7 +4472,8 @@ SD_Execute_Cmd_Failed:
        if (!(chip->card_ready & SD_CARD))
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
 
-       TRACE_RET(chip, TRANSPORT_FAILED);
+       rtsx_trace(chip);
+       return TRANSPORT_FAILED;
 }
 
 int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
@@ -3812,35 +4481,39 @@ 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) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (sd_card->pre_cmd_err) {
                sd_card->pre_cmd_err = 0;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
        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];
@@ -3848,13 +4521,16 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = get_rsp_type(srb, &rsp_type, &rsp_len);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        sd_card->last_rsp_type = rsp_type;
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
 #ifdef SUPPORT_SD_LOCK
        if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
@@ -3874,23 +4550,29 @@ 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);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
        }
 
        if (standby) {
                retval = sd_select_card(chip, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
        }
 
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
        }
 
        if (data_len <= 512) {
@@ -3909,16 +4591,19 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                cmd[4] = srb->cmnd[6];
 
                buf = kmalloc(data_len, GFP_KERNEL);
-               if (buf == NULL)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (buf == NULL) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                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);
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
                }
 
                min_len = min(data_len, scsi_bufflen(srb));
@@ -3964,49 +4649,63 @@ 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);
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
                }
 
        } else {
-               TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+               rtsx_trace(chip);
+               goto SD_Execute_Read_Cmd_Failed;
        }
 
        retval = ext_sd_get_rsp(chip, rsp_len, sd_card->rsp, rsp_type);
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Read_Cmd_Failed;
+       }
 
        if (standby) {
                retval = sd_select_card(chip, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
        }
 
        if (send_cmd12) {
                retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION,
-                               0, SD_RSP_TYPE_R1b, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+                               0, SD_RSP_TYPE_R1b, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto 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);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
 
                retval = rtsx_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
 
                retval = rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Read_Cmd_Failed;
+               }
        }
 
        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,
@@ -4016,8 +4715,10 @@ int sd_execute_read_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Read_Cmd_Failed);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Read_Cmd_Failed;
+       }
 
        scsi_set_resid(srb, 0);
        return TRANSPORT_GOOD;
@@ -4033,7 +4734,8 @@ SD_Execute_Read_Cmd_Failed:
        if (!(chip->card_ready & SD_CARD))
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
 
-       TRACE_RET(chip, TRANSPORT_FAILED);
+       rtsx_trace(chip);
+       return TRANSPORT_FAILED;
 }
 
 int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
@@ -4041,9 +4743,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;
@@ -4053,28 +4755,32 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!sd_card->sd_pass_thru_en) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (sd_card->pre_cmd_err) {
                sd_card->pre_cmd_err = 0;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
        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];
@@ -4091,68 +4797,87 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = get_rsp_type(srb, &rsp_type, &rsp_len);
        if (retval != STATUS_SUCCESS) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
        sd_card->last_rsp_type = rsp_type;
 
        retval = sd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 
 #ifdef SUPPORT_SD_LOCK
        if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
                if (CHK_MMC_8BIT(sd_card)) {
                        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03,
                                                SD_BUS_WIDTH_8);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
 
                } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) {
                        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03,
                                                SD_BUS_WIDTH_4);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, TRANSPORT_FAILED);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return TRANSPORT_FAILED;
+                       }
                }
        }
 #else
        retval = rtsx_write_register(chip, REG_SD_CFG1, 0x03, SD_BUS_WIDTH_4);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, TRANSPORT_FAILED);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
+       }
 #endif
 
        if (data_len < 512) {
                retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len,
-                               SD_RSP_TYPE_R1, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
        }
 
        if (standby) {
                retval = sd_select_card(chip, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
        }
 
        if (acmd) {
                retval = ext_sd_send_cmd_get_rsp(chip, APP_CMD,
                                                sd_card->sd_addr,
-                                               SD_RSP_TYPE_R1, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
        }
 
        retval = ext_sd_send_cmd_get_rsp(chip, cmd_idx, arg, rsp_type,
-                       sd_card->rsp, rsp_len, 0);
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                       sd_card->rsp, rsp_len, false);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Write_Cmd_Failed;
+       }
 
        if (data_len <= 512) {
                u16 i;
                u8 *buf;
 
                buf = kmalloc(data_len, GFP_KERNEL);
-               if (buf == NULL)
-                       TRACE_RET(chip, TRANSPORT_ERROR);
+               if (buf == NULL) {
+                       rtsx_trace(chip);
+                       return TRANSPORT_ERROR;
+               }
 
                rtsx_stor_get_xfer_buf(buf, data_len, srb);
 
@@ -4170,7 +4895,8 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        retval = rtsx_send_cmd(chip, 0, 250);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               rtsx_trace(chip);
+                               goto SD_Execute_Write_Cmd_Failed;
                        }
 
                        rtsx_init_cmd(chip);
@@ -4181,7 +4907,8 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        retval = rtsx_send_cmd(chip, 0, 250);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               rtsx_trace(chip);
+                               goto SD_Execute_Write_Cmd_Failed;
                        }
                } else {
                        rtsx_init_cmd(chip);
@@ -4192,7 +4919,8 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        retval = rtsx_send_cmd(chip, 0, 250);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               rtsx_trace(chip);
+                               goto SD_Execute_Write_Cmd_Failed;
                        }
                }
 
@@ -4243,13 +4971,15 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                        DMA_TO_DEVICE, 10000);
 
        } else {
-               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               rtsx_trace(chip);
+               goto SD_Execute_Write_Cmd_Failed;
        }
 
        if (retval < 0) {
-               write_err = 1;
+               write_err = true;
                rtsx_clear_sd_error(chip);
-               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               rtsx_trace(chip);
+               goto SD_Execute_Write_Cmd_Failed;
        }
 
 #ifdef SUPPORT_SD_LOCK
@@ -4275,34 +5005,44 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (standby) {
                retval = sd_select_card(chip, 1);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
        }
 
        if (send_cmd12) {
                retval = ext_sd_send_cmd_get_rsp(chip, STOP_TRANSMISSION,
-                               0, SD_RSP_TYPE_R1b, NULL, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               0, SD_RSP_TYPE_R1b, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto 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);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                               SD_RSP_TYPE_R1, NULL, 0, false);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
 
                retval = rtsx_write_register(chip, SD_BYTE_CNT_H, 0xFF, 0x02);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
 
                rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       goto SD_Execute_Write_Cmd_Failed;
+               }
        }
 
        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,
@@ -4312,8 +5052,10 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval == STATUS_SUCCESS)
                        break;
        }
-       if (retval != STATUS_SUCCESS)
-               TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               goto SD_Execute_Write_Cmd_Failed;
+       }
 
 #ifdef SUPPORT_SD_LOCK
        if (cmd_idx == LOCK_UNLOCK) {
@@ -4339,7 +5081,8 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                                retval = reset_sd(chip);
                                                if (retval != STATUS_SUCCESS) {
                                                        sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST);
-                                                       TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
+                                                       rtsx_trace(chip);
+                                                       goto SD_Execute_Write_Cmd_Failed;
                                                }
                                        }
 
@@ -4352,7 +5095,8 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (lock_cmd_fail) {
                scsi_set_resid(srb, 0);
                set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 #endif  /* SUPPORT_SD_LOCK */
 
@@ -4370,7 +5114,8 @@ SD_Execute_Write_Cmd_Failed:
        if (!(chip->card_ready & SD_CARD))
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
 
-       TRACE_RET(chip, TRANSPORT_FAILED);
+       rtsx_trace(chip);
+       return TRANSPORT_FAILED;
 }
 
 int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip)
@@ -4382,20 +5127,23 @@ int sd_get_cmd_rsp(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!sd_card->sd_pass_thru_en) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (sd_card->pre_cmd_err) {
                sd_card->pre_cmd_err = 0;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        data_len = ((u16)srb->cmnd[7] << 8) | srb->cmnd[8];
 
        if (sd_card->last_rsp_type == SD_RSP_TYPE_R0) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        } else if (sd_card->last_rsp_type == SD_RSP_TYPE_R2) {
                count = (data_len < 17) ? data_len : 17;
        } else {
@@ -4420,13 +5168,15 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
        if (!sd_card->sd_pass_thru_en) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if (sd_card->pre_cmd_err) {
                sd_card->pre_cmd_err = 0;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        if ((0x53 != srb->cmnd[2]) || (0x44 != srb->cmnd[3]) ||
@@ -4434,7 +5184,8 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                (0x61 != srb->cmnd[6]) || (0x72 != srb->cmnd[7]) ||
                (0x64 != srb->cmnd[8])) {
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        switch (srb->cmnd[1] & 0x0F) {
@@ -4450,7 +5201,8 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 #endif
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
                        sd_card->pre_cmd_err = 1;
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
 #ifdef SUPPORT_SD_LOCK
                sd_card->sd_lock_status &= ~SD_SDR_RST;
@@ -4462,13 +5214,15 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                if (retval != STATUS_SUCCESS) {
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
                        sd_card->pre_cmd_err = 1;
-                       TRACE_RET(chip, TRANSPORT_FAILED);
+                       rtsx_trace(chip);
+                       return TRANSPORT_FAILED;
                }
                break;
 
        default:
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_INVALID_CMD_FIELD);
-               TRACE_RET(chip, TRANSPORT_FAILED);
+               rtsx_trace(chip);
+               return TRANSPORT_FAILED;
        }
 
        scsi_set_resid(srb, 0);
@@ -4492,26 +5246,41 @@ int sd_power_off_card3v3(struct rtsx_chip *chip)
        int retval;
 
        retval = disable_card_clock(chip, SD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_OE, SD_OUTPUT_EN, 0);
+       retval = rtsx_write_register(chip, CARD_OE, SD_OUTPUT_EN, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (!chip->ft2_fast_mode) {
                retval = card_power_off(chip, SD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(50);
        }
 
        if (chip->asic_code) {
                retval = sd_pull_ctl_disable(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               RTSX_WRITE_REG(chip, FPGA_PULL_CTL,
-                       FPGA_SD_PULL_CTL_BIT | 0x20, FPGA_SD_PULL_CTL_BIT);
+               retval = rtsx_write_register(chip, FPGA_PULL_CTL,
+                                            FPGA_SD_PULL_CTL_BIT | 0x20,
+                                            FPGA_SD_PULL_CTL_BIT);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -4538,8 +5307,10 @@ int release_sd_card(struct rtsx_chip *chip)
        memset(sd_card->raw_scr, 0, 8);
 
        retval = sd_power_off_card3v3(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
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 29f4a80844fa61f8440975a7da2c6e9d7087f17f..e67e7ecc2cbd6fdb082d1c364b73f9fe8f9117cd 100644 (file)
@@ -25,9 +25,6 @@
 #include <linux/sched.h>
 
 #include "rtsx.h"
-#include "rtsx_transport.h"
-#include "rtsx_scsi.h"
-#include "rtsx_card.h"
 #include "spi.h"
 
 static inline void spi_set_err_code(struct rtsx_chip *chip, u8 err_code)
@@ -39,10 +36,20 @@ static inline void spi_set_err_code(struct rtsx_chip *chip, u8 err_code)
 
 static int spi_init(struct rtsx_chip *chip)
 {
-       RTSX_WRITE_REG(chip, SPI_CONTROL, 0xFF,
-               CS_POLARITY_LOW | DTO_MSB_FIRST | SPI_MASTER | SPI_MODE0 |
-               SPI_AUTO);
-       RTSX_WRITE_REG(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF);
+       int retval;
+
+       retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
+                                    CS_POLARITY_LOW | DTO_MSB_FIRST | SPI_MASTER | SPI_MODE0 | SPI_AUTO);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
+                                    SAMPLE_DELAY_HALF);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -52,25 +59,51 @@ static int spi_set_init_para(struct rtsx_chip *chip)
        struct spi_info *spi = &(chip->spi);
        int retval;
 
-       RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER1, 0xFF, (u8)(spi->clk_div >> 8));
-       RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER0, 0xFF, (u8)(spi->clk_div));
+       retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF,
+                                    (u8)(spi->clk_div >> 8));
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF,
+                                    (u8)(spi->clk_div));
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = switch_clock(chip, spi->spi_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = select_card(chip, SPI_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN);
-       RTSX_WRITE_REG(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN);
+       retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
+                                    SPI_CLK_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
+                                    SPI_OUTPUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        wait_timeout(10);
 
        retval = spi_init(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -91,7 +124,8 @@ static int sf_polling_status(struct rtsx_chip *chip, int msec)
        if (retval < 0) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_BUSY_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -119,7 +153,8 @@ static int sf_enable_write(struct rtsx_chip *chip, u8 ins)
        if (retval < 0) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -147,7 +182,8 @@ static int sf_disable_write(struct rtsx_chip *chip, u8 ins)
        if (retval < 0) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -205,7 +241,8 @@ static int sf_erase(struct rtsx_chip *chip, u8 ins, u8 addr_mode, u32 addr)
        if (retval < 0) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -221,25 +258,56 @@ static int spi_init_eeprom(struct rtsx_chip *chip)
        else
                clk = CLK_30;
 
-       RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00);
-       RTSX_WRITE_REG(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27);
+       retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        retval = switch_clock(chip, clk);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = select_card(chip, SPI_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_CLK_EN, SPI_CLK_EN, SPI_CLK_EN);
-       RTSX_WRITE_REG(chip, CARD_OE, SPI_OUTPUT_EN, SPI_OUTPUT_EN);
+       retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
+                                    SPI_CLK_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
+                                    SPI_OUTPUT_EN);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        wait_timeout(10);
 
-       RTSX_WRITE_REG(chip, SPI_CONTROL, 0xFF,
-               CS_POLARITY_HIGH | SPI_EEPROM_AUTO);
-       RTSX_WRITE_REG(chip, SPI_TCTL, EDO_TIMING_MASK, SAMPLE_DELAY_HALF);
+       retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
+                                    CS_POLARITY_HIGH | SPI_EEPROM_AUTO);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
+       retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
+                                    SAMPLE_DELAY_HALF);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -258,8 +326,10 @@ static int spi_eeprom_program_enable(struct rtsx_chip *chip)
                SPI_TRANSFER0_END);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -269,12 +339,16 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
        int retval;
 
        retval = spi_init_eeprom(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = spi_eeprom_program_enable(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -288,10 +362,16 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
                SPI_TRANSFER0_END);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -301,12 +381,16 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
        int retval;
 
        retval = spi_init_eeprom(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = spi_eeprom_program_enable(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -322,10 +406,16 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
                SPI_TRANSFER0_END);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -337,8 +427,10 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val)
        u8 data;
 
        retval = spi_init_eeprom(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -355,16 +447,26 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val)
                SPI_TRANSFER0_END);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        wait_timeout(5);
-       RTSX_READ_REG(chip, SPI_DATA, &data);
+       retval = rtsx_read_register(chip, SPI_DATA, &data);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (val)
                *val = data;
 
-       RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -374,12 +476,16 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val)
        int retval;
 
        retval = spi_init_eeprom(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = spi_eeprom_program_enable(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -396,10 +502,16 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val)
                SPI_TRANSFER0_END);
 
        retval = rtsx_send_cmd(chip, 0, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -449,13 +561,15 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        len = ((u16)(srb->cmnd[7]) << 8) | srb->cmnd[8];
        if (len > 512) {
                spi_set_err_code(chip, SPI_INVALID_COMMAND);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = spi_set_init_para(chip);
        if (retval != STATUS_SUCCESS) {
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        rtsx_init_cmd(chip);
@@ -497,19 +611,23 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval < 0) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (len) {
                buf = kmalloc(len, GFP_KERNEL);
-               if (!buf)
-                       TRACE_RET(chip, STATUS_ERROR);
+               if (!buf) {
+                       rtsx_trace(chip);
+                       return STATUS_ERROR;
+               }
 
                retval = rtsx_read_ppbuf(chip, buf, len);
                if (retval != STATUS_SUCCESS) {
                        spi_set_err_code(chip, SPI_READ_ERR);
                        kfree(buf);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                rtsx_stor_set_xfer_buf(buf, scsi_bufflen(srb), srb);
@@ -541,12 +659,15 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = spi_set_init_para(chip);
        if (retval != STATUS_SUCCESS) {
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
-       if (buf == NULL)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (buf == NULL) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        while (len) {
                u16 pagelen = SF_PAGE_LEN - (u8)addr;
@@ -598,7 +719,8 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        kfree(buf);
                        rtsx_clear_spi_error(chip);
                        spi_set_err_code(chip, SPI_HW_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                rtsx_stor_access_xfer_buf(buf, pagelen, srb, &index, &offset,
@@ -634,19 +756,23 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = spi_set_init_para(chip);
        if (retval != STATUS_SUCCESS) {
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (program_mode == BYTE_PROGRAM) {
                buf = kmalloc(4, GFP_KERNEL);
-               if (!buf)
-                       TRACE_RET(chip, STATUS_ERROR);
+               if (!buf) {
+                       rtsx_trace(chip);
+                       return STATUS_ERROR;
+               }
 
                while (len) {
                        retval = sf_enable_write(chip, SPI_WREN);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        rtsx_stor_access_xfer_buf(buf, 1, srb, &index, &offset,
@@ -665,13 +791,15 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        addr++;
@@ -684,12 +812,16 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                int first_byte = 1;
 
                retval = sf_enable_write(chip, SPI_WREN);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                buf = kmalloc(4, GFP_KERNEL);
-               if (!buf)
-                       TRACE_RET(chip, STATUS_ERROR);
+               if (!buf) {
+                       rtsx_trace(chip);
+                       return STATUS_ERROR;
+               }
 
                while (len) {
                        rtsx_stor_access_xfer_buf(buf, 1, srb, &index, &offset,
@@ -713,13 +845,15 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        len--;
@@ -728,16 +862,22 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                kfree(buf);
 
                retval = sf_disable_write(chip, SPI_WRDI);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sf_polling_status(chip, 100);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else if (program_mode == PAGE_PROGRAM) {
                buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
-               if (!buf)
-                       TRACE_RET(chip, STATUS_NOMEM);
+               if (!buf) {
+                       rtsx_trace(chip);
+                       return STATUS_NOMEM;
+               }
 
                while (len) {
                        u16 pagelen = SF_PAGE_LEN - (u8)addr;
@@ -748,7 +888,8 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                        retval = sf_enable_write(chip, SPI_WREN);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        rtsx_init_cmd(chip);
@@ -767,13 +908,15 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                                kfree(buf);
                                rtsx_clear_spi_error(chip);
                                spi_set_err_code(chip, SPI_HW_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = sf_polling_status(chip, 100);
                        if (retval != STATUS_SUCCESS) {
                                kfree(buf);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        addr += pagelen;
@@ -783,7 +926,8 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
                kfree(buf);
        } else {
                spi_set_err_code(chip, SPI_INVALID_COMMAND);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -805,28 +949,38 @@ int spi_erase_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = spi_set_init_para(chip);
        if (retval != STATUS_SUCCESS) {
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        if (erase_mode == PAGE_ERASE) {
                retval = sf_enable_write(chip, SPI_WREN);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sf_erase(chip, ins, 1, addr);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else if (erase_mode == CHIP_ERASE) {
                retval = sf_enable_write(chip, SPI_WREN);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = sf_erase(chip, ins, 0, 0);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
                spi_set_err_code(chip, SPI_INVALID_COMMAND);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -844,12 +998,15 @@ int spi_write_flash_status(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        retval = spi_set_init_para(chip);
        if (retval != STATUS_SUCCESS) {
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = sf_enable_write(chip, ewsr);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -871,7 +1028,8 @@ int spi_write_flash_status(struct scsi_cmnd *srb, struct rtsx_chip *chip)
        if (retval != STATUS_SUCCESS) {
                rtsx_clear_spi_error(chip);
                spi_set_err_code(chip, SPI_HW_ERR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
diff --git a/drivers/staging/rts5208/trace.c b/drivers/staging/rts5208/trace.c
new file mode 100644 (file)
index 0000000..1bddbdf
--- /dev/null
@@ -0,0 +1,26 @@
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+#include "rtsx.h"
+
+#ifdef _MSG_TRACE
+
+void _rtsx_trace(struct rtsx_chip *chip, const char *file, const char *func,
+                int line)
+{
+       struct trace_msg_t *msg = &chip->trace_msg[chip->msg_idx];
+
+       file = kbasename(file);
+       dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", file, func, line);
+
+       strncpy(msg->file, file, MSG_FILE_LEN - 1);
+       strncpy(msg->func, func, MSG_FUNC_LEN - 1);
+       msg->line = (u16)line;
+       get_current_time(msg->timeval_buf, TIME_VAL_LEN);
+       msg->valid = 1;
+
+       chip->msg_idx++;
+       if (chip->msg_idx >= TRACE_ITEM_CNT)
+               chip->msg_idx = 0;
+}
+#endif
index a9ab4077b283eedc7e48b8a638fce0a3c915ec50..5b807874c1d7f01c9cd8808c4eda7bf41b278404 100644 (file)
 #ifndef __REALTEK_RTSX_TRACE_H
 #define __REALTEK_RTSX_TRACE_H
 
-#define _MSG_TRACE
+struct rtsx_chip;
 
 #ifdef _MSG_TRACE
-static inline char *filename(char *path)
+void _rtsx_trace(struct rtsx_chip *chip, const char *file, const char *func,
+                int line);
+#define rtsx_trace(chip)                                               \
+       _rtsx_trace(chip, __FILE__, __func__, __LINE__)
+#else
+static inline void rtsx_trace(struct rtsx_chip *chip)
 {
-       char *ptr;
-
-       if (path == NULL)
-               return NULL;
-
-       ptr = path;
-
-       while (*ptr != '\0') {
-               if ((*ptr == '\\') || (*ptr == '/'))
-                       path = ptr + 1;
-
-               ptr++;
-       }
-
-       return path;
 }
-
-#define TRACE_RET(chip, ret)                                           \
-       do {                                                            \
-               char *_file = filename(__FILE__);                       \
-               dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file,       \
-                       __func__, __LINE__);                            \
-               (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
-               strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
-               strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
-               get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
-               (chip)->trace_msg[(chip)->msg_idx].valid = 1;           \
-               (chip)->msg_idx++;                                      \
-               if ((chip)->msg_idx >= TRACE_ITEM_CNT) {                \
-                       (chip)->msg_idx = 0;                            \
-               }                                                       \
-               return ret;                                             \
-       } while (0)
-
-#define TRACE_GOTO(chip, label)                                                \
-       do {                                                            \
-               char *_file = filename(__FILE__);                       \
-               dev_dbg(rtsx_dev(chip), "[%s][%s]:[%d]\n", _file,       \
-                       __func__, __LINE__);                            \
-               (chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
-               strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
-               strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
-               get_current_time((chip)->trace_msg[(chip)->msg_idx].timeval_buf, TIME_VAL_LEN); \
-               (chip)->trace_msg[(chip)->msg_idx].valid = 1;           \
-               (chip)->msg_idx++;                                      \
-               if ((chip)->msg_idx >= TRACE_ITEM_CNT) {                \
-                       (chip)->msg_idx = 0;                            \
-               }                                                       \
-               goto label;                                             \
-       } while (0)
-#else
-#define TRACE_RET(chip, ret)   return ret
-#define TRACE_GOTO(chip, label)        goto label
 #endif
 
 #endif  /* __REALTEK_RTSX_TRACE_H */
index 0d029fe92b40346028d1b05f5db2775d40ecd312..8fd108e50509137f9fa8a9993c141179172c60e4 100644 (file)
@@ -60,8 +60,10 @@ static int xd_set_init_para(struct rtsx_chip *chip)
                xd_card->xd_clock = CLK_50;
 
        retval = switch_clock(chip, xd_card->xd_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -72,12 +74,16 @@ static int xd_switch_clock(struct rtsx_chip *chip)
        int retval;
 
        retval = select_card(chip, XD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = switch_clock(chip, xd_card->xd_clock);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -99,8 +105,10 @@ static int xd_read_id(struct rtsx_chip *chip, u8 id_cmd, u8 *id_buf, u8 buf_len)
                rtsx_add_cmd(chip, READ_REG_CMD, (u16)(XD_ADDRESS1 + i), 0, 0);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 20);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = rtsx_get_cmd_data(chip) + 1;
        if (id_buf && buf_len) {
@@ -167,8 +175,10 @@ static int xd_read_redundant(struct rtsx_chip *chip, u32 page_addr,
        rtsx_add_cmd(chip, READ_REG_CMD, XD_PARITY, 0, 0);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 500);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (buf && buf_len) {
                u8 *ptr = rtsx_get_cmd_data(chip) + 1;
@@ -186,8 +196,10 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, int offset,
 {
        int retval, i;
 
-       if (!buf || (buf_len < 0))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!buf || (buf_len < 0)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -198,7 +210,8 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, int offset,
        retval = rtsx_send_cmd(chip, 0, 250);
        if (retval < 0) {
                rtsx_clear_xd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        memcpy(buf, rtsx_get_cmd_data(chip), buf_len);
@@ -212,8 +225,10 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
        int retval;
        u8 reg;
 
-       if (!buf || (buf_len < 10))
-               TRACE_RET(chip, STATUS_FAIL);
+       if (!buf || (buf_len < 10)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -233,25 +248,47 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
        retval = rtsx_send_cmd(chip, XD_CARD, 250);
        if (retval == -ETIMEDOUT) {
                rtsx_clear_xd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_READ_REG(chip, XD_PAGE_STATUS, &reg);
+       retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (reg != XD_GPG) {
                rtsx_clear_xd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
-       RTSX_READ_REG(chip, XD_CTL, &reg);
+       retval = rtsx_read_register(chip, XD_CTL, &reg);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) {
                retval = xd_read_data_from_ppb(chip, 0, buf, buf_len);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
                if (reg & XD_ECC1_ERROR) {
                        u8 ecc_bit, ecc_byte;
 
-                       RTSX_READ_REG(chip, XD_ECC_BIT1, &ecc_bit);
-                       RTSX_READ_REG(chip, XD_ECC_BYTE1, &ecc_byte);
+                       retval = rtsx_read_register(chip, XD_ECC_BIT1,
+                                                   &ecc_bit);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_read_register(chip, XD_ECC_BYTE1,
+                                                   &ecc_byte);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
 
                        dev_dbg(rtsx_dev(chip), "ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n",
                                ecc_bit, ecc_byte);
@@ -267,13 +304,25 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
                rtsx_clear_xd_error(chip);
 
                retval = xd_read_data_from_ppb(chip, 256, buf, buf_len);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
                if (reg & XD_ECC2_ERROR) {
                        u8 ecc_bit, ecc_byte;
 
-                       RTSX_READ_REG(chip, XD_ECC_BIT2, &ecc_bit);
-                       RTSX_READ_REG(chip, XD_ECC_BYTE2, &ecc_byte);
+                       retval = rtsx_read_register(chip, XD_ECC_BIT2,
+                                                   &ecc_bit);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_read_register(chip, XD_ECC_BYTE2,
+                                                   &ecc_byte);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
 
                        dev_dbg(rtsx_dev(chip), "ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n",
                                ecc_bit, ecc_byte);
@@ -287,7 +336,8 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
                }
        } else {
                rtsx_clear_xd_error(chip);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -363,24 +413,71 @@ static void xd_fill_pull_ctl_enable(struct rtsx_chip *chip)
 
 static int xd_pull_ctl_disable(struct rtsx_chip *chip)
 {
+       int retval;
+
        if (CHECK_PID(chip, 0x5208)) {
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF,
-                       XD_D3_PD | XD_D2_PD | XD_D1_PD | XD_D0_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF,
-                       XD_D7_PD | XD_D6_PD | XD_D5_PD | XD_D4_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF,
-                       XD_WP_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF,
-                       XD_RDY_PD | XD_WE_PD | XD_RE_PD | XD_ALE_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL5, 0xFF,
-                       MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
-               RTSX_WRITE_REG(chip, CARD_PULL_CTL6, 0xFF, MS_D5_PD | MS_D4_PD);
+               retval = rtsx_write_register(chip, CARD_PULL_CTL1, 0xFF,
+                                            XD_D3_PD | XD_D2_PD | XD_D1_PD | XD_D0_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF,
+                                            XD_D7_PD | XD_D6_PD | XD_D5_PD | XD_D4_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF,
+                                            XD_WP_PD | XD_CE_PD | XD_CLE_PD | XD_CD_PU);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF,
+                                            XD_RDY_PD | XD_WE_PD | XD_RE_PD | XD_ALE_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF,
+                                            MS_INS_PU | SD_WP_PD | SD_CD_PU | SD_CMD_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
+               retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF,
+                                            MS_D5_PD | MS_D4_PD);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        } else if (CHECK_PID(chip, 0x5288)) {
                if (CHECK_BARO_PKG(chip, QFN)) {
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL1, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL2, 0xFF, 0x55);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL3, 0xFF, 0x4B);
-                       RTSX_WRITE_REG(chip, CARD_PULL_CTL4, 0xFF, 0x69);
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL1,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL2,
+                                                    0xFF, 0x55);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL3,
+                                                    0xFF, 0x4B);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
+                       retval = rtsx_write_register(chip, CARD_PULL_CTL4,
+                                                    0xFF, 0x69);
+                       if (retval) {
+                               rtsx_trace(chip);
+                               return retval;
+                       }
                }
        }
 
@@ -394,8 +491,10 @@ static int reset_xd(struct rtsx_chip *chip)
        u8 *ptr, id_buf[4], redunt[11];
 
        retval = select_card(chip, XD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -418,13 +517,17 @@ static int reset_xd(struct rtsx_chip *chip)
        rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!chip->ft2_fast_mode) {
                retval = card_power_off(chip, XD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(250);
 
@@ -439,19 +542,24 @@ static int reset_xd(struct rtsx_chip *chip)
                }
 
                retval = rtsx_send_cmd(chip, XD_CARD, 100);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                retval = card_power_on(chip, XD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
 #ifdef SUPPORT_OCP
                wait_timeout(50);
                if (chip->ocp_stat & (SD_OC_NOW | SD_OC_EVER)) {
                        dev_dbg(rtsx_dev(chip), "Over current, OCPSTAT is 0x%x\n",
                                chip->ocp_stat);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
        }
@@ -472,15 +580,19 @@ static int reset_xd(struct rtsx_chip *chip)
        rtsx_add_cmd(chip, WRITE_REG_CMD, XD_CTL, XD_CE_DISEN, XD_CE_DISEN);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        if (!chip->ft2_fast_mode)
                wait_timeout(200);
 
        retval = xd_set_init_para(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* Read ID to check if the timing setting is right */
        for (i = 0; i < 4; i++) {
@@ -502,8 +614,10 @@ static int reset_xd(struct rtsx_chip *chip)
                rtsx_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0);
 
                retval = rtsx_send_cmd(chip, XD_CARD, 100);
-               if (retval < 0)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval < 0) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                ptr = rtsx_get_cmd_data(chip) + 1;
 
@@ -515,8 +629,10 @@ static int reset_xd(struct rtsx_chip *chip)
                        continue;
 
                retval = xd_read_id(chip, READ_ID, id_buf, 4);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                dev_dbg(rtsx_dev(chip), "READ_ID: 0x%x 0x%x 0x%x 0x%x\n",
                        id_buf[0], id_buf[1], id_buf[2], id_buf[3]);
@@ -596,8 +712,10 @@ static int reset_xd(struct rtsx_chip *chip)
                /* Confirm timing setting */
                for (j = 0; j < 10; j++) {
                        retval = xd_read_id(chip, READ_ID, id_buf, 4);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if (id_buf[1] != xd_card->device_code)
                                break;
@@ -613,23 +731,30 @@ static int reset_xd(struct rtsx_chip *chip)
                xd_card->addr_cycle = 0;
                xd_card->capacity = 0;
 
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        retval = xd_read_id(chip, READ_xD_ID, id_buf, 4);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
        dev_dbg(rtsx_dev(chip), "READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n",
                id_buf[0], id_buf[1], id_buf[2], id_buf[3]);
-       if (id_buf[2] != XD_ID_CODE)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (id_buf[2] != XD_ID_CODE) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        /* Search CIS block */
        for (i = 0; i < 24; i++) {
                u32 page_addr;
 
-               if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                page_addr = (u32)i << xd_card->block_shift;
 
@@ -667,8 +792,10 @@ static int reset_xd(struct rtsx_chip *chip)
                        page_addr += j;
 
                        retval = xd_read_cis(chip, page_addr, buf, 10);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
 
                        if ((buf[0] == 0x01) && (buf[1] == 0x03) &&
                                (buf[2] == 0xD9)
@@ -684,8 +811,10 @@ static int reset_xd(struct rtsx_chip *chip)
        }
 
        dev_dbg(rtsx_dev(chip), "CIS block: 0x%x\n", xd_card->cis_block);
-       if (xd_card->cis_block == 0xFFFF)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (xd_card->cis_block == 0xFFFF) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        chip->capacity[chip->card2lun[XD_CARD]] = xd_card->capacity;
 
@@ -739,15 +868,19 @@ static int xd_init_l2p_tbl(struct rtsx_chip *chip)
        dev_dbg(rtsx_dev(chip), "xd_init_l2p_tbl: zone_cnt = %d\n",
                xd_card->zone_cnt);
 
-       if (xd_card->zone_cnt < 1)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (xd_card->zone_cnt < 1) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        size = xd_card->zone_cnt * sizeof(struct zone_entry);
        dev_dbg(rtsx_dev(chip), "Buffer size for l2p table is %d\n", size);
 
        xd_card->zone = vmalloc(size);
-       if (!xd_card->zone)
-               TRACE_RET(chip, STATUS_ERROR);
+       if (!xd_card->zone) {
+               rtsx_trace(chip);
+               return STATUS_ERROR;
+       }
 
        for (i = 0; i < xd_card->zone_cnt; i++) {
                xd_card->zone[i].build_flag = 0;
@@ -927,16 +1060,22 @@ int reset_xd_card(struct rtsx_chip *chip)
        xd_card->delay_write.delay_write_flag = 0;
 
        retval = enable_card_clock(chip, XD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = reset_xd(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        retval = xd_init_l2p_tbl(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -950,8 +1089,10 @@ static int xd_mark_bad_block(struct rtsx_chip *chip, u32 phy_blk)
 
        dev_dbg(rtsx_dev(chip), "mark block 0x%x as bad block\n", phy_blk);
 
-       if (phy_blk == BLK_NOT_FOUND)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (phy_blk == BLK_NOT_FOUND) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -986,7 +1127,8 @@ static int xd_mark_bad_block(struct rtsx_chip *chip, u32 phy_blk)
                        xd_set_err_code(chip, XD_PRG_ERROR);
                else
                        xd_set_err_code(chip, XD_TO_ERROR);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1002,10 +1144,14 @@ static int xd_init_page(struct rtsx_chip *chip, u32 phy_blk,
 
        dev_dbg(rtsx_dev(chip), "Init block 0x%x\n", phy_blk);
 
-       if (start_page > end_page)
-               TRACE_RET(chip, STATUS_FAIL);
-       if (phy_blk == BLK_NOT_FOUND)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (start_page > end_page) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
+       if (phy_blk == BLK_NOT_FOUND) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -1040,7 +1186,8 @@ static int xd_init_page(struct rtsx_chip *chip, u32 phy_blk,
                } else {
                        xd_set_err_code(chip, XD_TO_ERROR);
                }
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        return STATUS_SUCCESS;
@@ -1057,24 +1204,34 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
        dev_dbg(rtsx_dev(chip), "Copy page from block 0x%x to block 0x%x\n",
                old_blk, new_blk);
 
-       if (start_page > end_page)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (start_page > end_page) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND))
-               TRACE_RET(chip, STATUS_FAIL);
+       if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        old_page = (old_blk << xd_card->block_shift) + start_page;
        new_page = (new_blk << xd_card->block_shift) + start_page;
 
        XD_CLR_BAD_NEWBLK(xd_card);
 
-       RTSX_WRITE_REG(chip, CARD_DATA_SOURCE, 0x01, PINGPONG_BUFFER);
+       retval = rtsx_write_register(chip, CARD_DATA_SOURCE, 0x01,
+                                    PINGPONG_BUFFER);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        for (i = start_page; i < end_page; i++) {
                if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                        rtsx_clear_xd_error(chip);
                        xd_set_err_code(chip, XD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                rtsx_init_cmd(chip);
@@ -1100,7 +1257,8 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
                                if (detect_card_cd(chip,
                                        XD_CARD) != STATUS_SUCCESS) {
                                        xd_set_err_code(chip, XD_NO_CARD);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
 
                                if (((reg & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) ==
@@ -1119,7 +1277,8 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
                                }
                        } else {
                                xd_set_err_code(chip, XD_TO_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1147,7 +1306,8 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
                        } else {
                                xd_set_err_code(chip, XD_TO_ERROR);
                        }
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                old_page++;
@@ -1172,14 +1332,17 @@ static int xd_reset_cmd(struct rtsx_chip *chip)
        rtsx_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 100);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        ptr = rtsx_get_cmd_data(chip) + 1;
        if (((ptr[0] & READY_FLAG) == READY_STATE) && (ptr[1] & XD_RDY))
                return STATUS_SUCCESS;
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
@@ -1189,8 +1352,10 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
        u8 reg = 0, *ptr;
        int i, retval;
 
-       if (phy_blk == BLK_NOT_FOUND)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (phy_blk == BLK_NOT_FOUND) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        page_addr = phy_blk << xd_card->block_shift;
 
@@ -1212,13 +1377,16 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
                        if (reg & PROGRAM_ERROR) {
                                xd_mark_bad_block(chip, phy_blk);
                                xd_set_err_code(chip, XD_PRG_ERROR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        } else {
                                xd_set_err_code(chip, XD_ERASE_FAIL);
                        }
                        retval = xd_reset_cmd(chip);
-                       if (retval != STATUS_SUCCESS)
-                               TRACE_RET(chip, STATUS_FAIL);
+                       if (retval != STATUS_SUCCESS) {
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
+                       }
                        continue;
                }
 
@@ -1226,7 +1394,8 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
                if (*ptr & PROGRAM_ERROR) {
                        xd_mark_bad_block(chip, phy_blk);
                        xd_set_err_code(chip, XD_PRG_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                return STATUS_SUCCESS;
@@ -1234,7 +1403,8 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
 
        xd_mark_bad_block(chip, phy_blk);
        xd_set_err_code(chip, XD_ERASE_FAIL);
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 
@@ -1266,15 +1436,19 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
 
        if (zone->l2p_table == NULL) {
                zone->l2p_table = vmalloc(2000);
-               if (zone->l2p_table == NULL)
-                       TRACE_GOTO(chip, Build_Fail);
+               if (zone->l2p_table == NULL) {
+                       rtsx_trace(chip);
+                       goto Build_Fail;
+               }
        }
        memset((u8 *)(zone->l2p_table), 0xff, 2000);
 
        if (zone->free_table == NULL) {
                zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2);
-               if (zone->free_table == NULL)
-                       TRACE_GOTO(chip, Build_Fail);
+               if (zone->free_table == NULL) {
+                       rtsx_trace(chip);
+                       goto Build_Fail;
+               }
        }
        memset((u8 *)(zone->free_table), 0xff, XD_FREE_TABLE_CNT * 2);
 
@@ -1440,8 +1614,10 @@ static int xd_send_cmd(struct rtsx_chip *chip, u8 cmd)
                XD_TRANSFER_END, XD_TRANSFER_END);
 
        retval = rtsx_send_cmd(chip, XD_CARD, 200);
-       if (retval < 0)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval < 0) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
@@ -1457,8 +1633,10 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk,
        u8 reg_val, page_cnt;
        int zone_no, retval, i;
 
-       if (start_page > end_page)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (start_page > end_page) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        page_cnt = end_page - start_page;
        zone_no = (int)(log_blk / 1000);
@@ -1474,7 +1652,8 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk,
 
                        if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                                xd_set_err_code(chip, XD_NO_CARD);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
        }
@@ -1509,21 +1688,31 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk,
 
                if (retval == -ETIMEDOUT) {
                        xd_set_err_code(chip, XD_TO_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                } else {
-                       TRACE_GOTO(chip, Fail);
+                       rtsx_trace(chip);
+                       goto Fail;
                }
        }
 
        return STATUS_SUCCESS;
 
 Fail:
-       RTSX_READ_REG(chip, XD_PAGE_STATUS, &reg_val);
+       retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg_val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (reg_val !=  XD_GPG)
                xd_set_err_code(chip, XD_PRG_ERROR);
 
-       RTSX_READ_REG(chip, XD_CTL, &reg_val);
+       retval = rtsx_read_register(chip, XD_CTL, &reg_val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE))
                                == (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE))
@@ -1533,7 +1722,8 @@ Fail:
 
                if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                        xd_set_err_code(chip, XD_NO_CARD);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                xd_set_err_code(chip, XD_ECC_ERROR);
@@ -1541,7 +1731,8 @@ Fail:
                new_blk = xd_get_unused_block(chip, zone_no);
                if (new_blk == NO_NEW_BLK) {
                        XD_CLR_BAD_OLDBLK(xd_card);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = xd_copy_page(chip, phy_blk, new_blk, 0,
@@ -1555,7 +1746,8 @@ Fail:
                                XD_CLR_BAD_NEWBLK(xd_card);
                        }
                        XD_CLR_BAD_OLDBLK(xd_card);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
                xd_set_l2p_tbl(chip, zone_no, log_off, (u16)(new_blk & 0x3FF));
                xd_erase_block(chip, phy_blk);
@@ -1563,7 +1755,8 @@ Fail:
                XD_CLR_BAD_OLDBLK(xd_card);
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 static int xd_finish_write(struct rtsx_chip *chip,
@@ -1576,8 +1769,10 @@ static int xd_finish_write(struct rtsx_chip *chip,
        dev_dbg(rtsx_dev(chip), "xd_finish_write, old_blk = 0x%x, new_blk = 0x%x, log_blk = 0x%x\n",
                old_blk, new_blk, log_blk);
 
-       if (page_off > xd_card->page_off)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (page_off > xd_card->page_off) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        zone_no = (int)(log_blk / 1000);
        log_off = (u16)(log_blk % 1000);
@@ -1589,7 +1784,8 @@ static int xd_finish_write(struct rtsx_chip *chip,
                        retval = xd_erase_block(chip, new_blk);
                        if (retval == STATUS_SUCCESS)
                                xd_set_unused_block(chip, new_blk);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        } else {
                retval = xd_copy_page(chip, old_blk, new_blk,
@@ -1601,7 +1797,8 @@ static int xd_finish_write(struct rtsx_chip *chip,
                                        xd_set_unused_block(chip, new_blk);
                        }
                        XD_CLR_BAD_NEWBLK(xd_card);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = xd_erase_block(chip, old_blk);
@@ -1633,8 +1830,10 @@ static int xd_prepare_write(struct rtsx_chip *chip,
 
        if (page_off) {
                retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1655,8 +1854,10 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
        dev_dbg(rtsx_dev(chip), "%s, old_blk = 0x%x, new_blk = 0x%x, log_blk = 0x%x\n",
                __func__, old_blk, new_blk, log_blk);
 
-       if (start_page > end_page)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (start_page > end_page) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        page_cnt = end_page - start_page;
        zone_no = (int)(log_blk / 1000);
@@ -1665,8 +1866,10 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
        page_addr = (new_blk << xd_card->block_shift) + start_page;
 
        retval = xd_send_cmd(chip, READ1_1);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        rtsx_init_cmd(chip);
 
@@ -1701,9 +1904,11 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
 
                if (retval == -ETIMEDOUT) {
                        xd_set_err_code(chip, XD_TO_ERROR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                } else {
-                       TRACE_GOTO(chip, Fail);
+                       rtsx_trace(chip);
+                       goto Fail;
                }
        }
 
@@ -1730,13 +1935,18 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
        return STATUS_SUCCESS;
 
 Fail:
-       RTSX_READ_REG(chip, XD_DAT, &reg_val);
+       retval = rtsx_read_register(chip, XD_DAT, &reg_val);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
        if (reg_val & PROGRAM_ERROR) {
                xd_set_err_code(chip, XD_PRG_ERROR);
                xd_mark_bad_block(chip, new_blk);
        }
 
-       TRACE_RET(chip, STATUS_FAIL);
+       rtsx_trace(chip);
+       return STATUS_FAIL;
 }
 
 #ifdef XD_DELAY_WRITE
@@ -1749,16 +1959,20 @@ int xd_delay_write(struct rtsx_chip *chip)
        if (delay_write->delay_write_flag) {
                dev_dbg(rtsx_dev(chip), "xd_delay_write\n");
                retval = xd_switch_clock(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                delay_write->delay_write_flag = 0;
                retval = xd_finish_write(chip,
                                delay_write->old_phyblock,
                                        delay_write->new_phyblock,
                                delay_write->logblock, delay_write->pageoff);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -1790,14 +2004,17 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
        ptr = (u8 *)scsi_sglist(srb);
 
        retval = xd_switch_clock(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
 
        if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                chip->card_fail |= XD_CARD;
                set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-               TRACE_RET(chip, STATUS_FAIL);
+               rtsx_trace(chip);
+               return STATUS_FAIL;
        }
 
        log_blk = start_sector >> xd_card->block_shift;
@@ -1810,7 +2027,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (retval != STATUS_SUCCESS) {
                        chip->card_fail |= XD_CARD;
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1828,7 +2046,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                if (retval != STATUS_SUCCESS) {
                                        set_sense_type(chip, lun,
                                                SENSE_TYPE_MEDIA_WRITE_ERR);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                        }
                        old_blk = delay_write->old_phyblock;
@@ -1844,7 +2063,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 #endif
                        old_blk = xd_get_l2p_tbl(chip, zone_no, log_off);
@@ -1853,7 +2073,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                (new_blk == BLK_NOT_FOUND)) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 
                        retval = xd_prepare_write(chip, old_blk, new_blk,
@@ -1863,11 +2084,13 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                        STATUS_SUCCESS) {
                                        set_sense_type(chip, lun,
                                                SENSE_TYPE_MEDIA_NOT_PRESENT);
-                                       TRACE_RET(chip, STATUS_FAIL);
+                                       rtsx_trace(chip);
+                                       return STATUS_FAIL;
                                }
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
 #ifdef XD_DELAY_WRITE
                }
@@ -1879,11 +2102,13 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
 
@@ -1891,7 +2116,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (old_blk == BLK_NOT_FOUND) {
                        set_sense_type(chip, lun,
                                SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
        }
 
@@ -1901,7 +2127,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                        chip->card_fail |= XD_CARD;
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if ((start_page + total_sec_cnt) > (xd_card->page_off + 1))
@@ -1917,7 +2144,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                } else {
                        retval = xd_write_multiple_pages(chip, old_blk,
@@ -1927,7 +2155,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (retval != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1948,7 +2177,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                chip->card_fail |= XD_CARD;
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1961,7 +2191,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
 
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                if (srb->sc_data_direction == DMA_TO_DEVICE) {
@@ -1969,7 +2200,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (new_blk == BLK_NOT_FOUND) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_WRITE_ERR);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                }
 
@@ -1988,7 +2220,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                        chip->card_fail |= XD_CARD;
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 
                retval = xd_finish_write(chip, old_blk, new_blk,
@@ -1997,10 +2230,12 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
                        if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
                                set_sense_type(chip, lun,
                                        SENSE_TYPE_MEDIA_NOT_PRESENT);
-                               TRACE_RET(chip, STATUS_FAIL);
+                               rtsx_trace(chip);
+                               return STATUS_FAIL;
                        }
                        set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR);
-                       TRACE_RET(chip, STATUS_FAIL);
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
                }
 #endif
        }
@@ -2049,25 +2284,39 @@ int xd_power_off_card3v3(struct rtsx_chip *chip)
        int retval;
 
        retval = disable_card_clock(chip, XD_CARD);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
-       RTSX_WRITE_REG(chip, CARD_OE, XD_OUTPUT_EN, 0);
+       retval = rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0);
+       if (retval) {
+               rtsx_trace(chip);
+               return retval;
+       }
 
        if (!chip->ft2_fast_mode) {
                retval = card_power_off(chip, XD_CARD);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
 
                wait_timeout(50);
        }
 
        if (chip->asic_code) {
                retval = xd_pull_ctl_disable(chip);
-               if (retval != STATUS_SUCCESS)
-                       TRACE_RET(chip, STATUS_FAIL);
+               if (retval != STATUS_SUCCESS) {
+                       rtsx_trace(chip);
+                       return STATUS_FAIL;
+               }
        } else {
-               RTSX_WRITE_REG(chip, FPGA_PULL_CTL, 0xFF, 0xDF);
+               retval = rtsx_write_register(chip, FPGA_PULL_CTL, 0xFF, 0xDF);
+               if (retval) {
+                       rtsx_trace(chip);
+                       return retval;
+               }
        }
 
        return STATUS_SUCCESS;
@@ -2087,8 +2336,10 @@ int release_xd_card(struct rtsx_chip *chip)
        xd_free_l2p_tbl(chip);
 
        retval = xd_power_off_card3v3(chip);
-       if (retval != STATUS_SUCCESS)
-               TRACE_RET(chip, STATUS_FAIL);
+       if (retval != STATUS_SUCCESS) {
+               rtsx_trace(chip);
+               return STATUS_FAIL;
+       }
 
        return STATUS_SUCCESS;
 }
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..c2bda1d38e41c1d21a500a69d2359f6dd43fe750 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,46 +2548,11 @@ 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;
 
-#ifdef SLIC_TRACE_DUMP_ENABLED
-       case SIOCSLICTRACEDUMP:
-               {
-                       u32 value;
-
-                       DBG_IOCTL("slic_ioctl  SIOCSLIC_TRACE_DUMP\n");
-
-                       if (copy_from_user(data, rq->ifr_data, 28)) {
-                               PRINT_ERROR
-                                   ("slic: copy_from_user FAILED getting initial simba param\n");
-                               return -EFAULT;
-                       }
-
-                       value = data[0];
-                       if (tracemon_request == SLIC_DUMP_DONE) {
-                               PRINT_ERROR
-                                   ("ATK Diagnostic Trace Dump Requested\n");
-                               tracemon_request = SLIC_DUMP_REQUESTED;
-                               tracemon_request_type = value;
-                               tracemon_timestamp = jiffies;
-                       } else if ((tracemon_request == SLIC_DUMP_REQUESTED) ||
-                                  (tracemon_request ==
-                                   SLIC_DUMP_IN_PROGRESS)) {
-                               PRINT_ERROR
-                                   ("ATK Diagnostic Trace Dump Requested but already in progress... ignore\n");
-                       } else {
-                               PRINT_ERROR
-                                   ("ATK Diagnostic Trace Dump Requested\n");
-                               tracemon_request = SLIC_DUMP_REQUESTED;
-                               tracemon_request_type = value;
-                               tracemon_timestamp = jiffies;
-                       }
-                       return 0;
-               }
-#endif
        case SIOCETHTOOL:
                if (copy_from_user(&ecmd, rq->ifr_data, sizeof(ecmd)))
                        return -EFAULT;
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..7b28328
--- /dev/null
@@ -0,0 +1,622 @@
+#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) {
+               /*
+               * 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) {
+               /* 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) {
+               /* 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..7826376
--- /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);
+}
+
+
+static 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.
+ */
+static 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
+ */
+static 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..3c7ea95
--- /dev/null
@@ -0,0 +1,1403 @@
+#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;
+
+
+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;
+
+       /*
+        * If not use spin_lock,system will die if user load driver
+        * and immediatly unload driver frequently (dual)
+        */
+       if (share->dual)
+               spin_lock(&share->slock);
+
+       share->accel.de_fillrect(&share->accel,
+                                base, pitch, Bpp,
+                                region->dx, region->dy,
+                                region->width, region->height,
+                                color, rop);
+       if (share->dual)
+               spin_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;
+
+       /*
+        * If not use spin_lock, system will die if user load driver
+        * and immediatly unload driver frequently (dual)
+        */
+       if (share->dual)
+               spin_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);
+       if (share->dual)
+               spin_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:
+       /*
+        * If not use spin_lock, system will die if user load driver
+        * and immediatly unload driver frequently (dual)
+        */
+       if (share->dual)
+               spin_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);
+       if (share->dual)
+               spin_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();
+
+       ret = pci_set_power_state(pdev, PCI_D0);
+       if (ret) {
+               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);
+               ret = pci_enable_device(pdev);
+               if (ret) {
+                       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_io(cursor->vstart, 0x0, cursor->size);
+               memset_io(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_io(cursor->vstart, 0x0, cursor->size);
+               memset_io(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;
+
+       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 = 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_io(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);
+
+       ret = fb_alloc_cmap(&info->cmap, 256, 0);
+       if (ret < 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);
+       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_io(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
+
+       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..c5a3726
--- /dev/null
@@ -0,0 +1,437 @@
+#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);
+}
+
+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..68d5cbc
--- /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;
+       void __iomem *pbuffer, *pstart;
+
+       /*  in byte*/
+       pitch = cursor->w >> 3;
+
+       /* in byte      */
+       count = pitch * cursor->h;
+
+       /* in byte */
+       offset = cursor->maxW * 2 / 8;
+
+       data = 0;
+       pstart = 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
+               iowrite16(data, pbuffer);
+
+               /* 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 += sizeof(u16);
+               }
+
+       }
+
+
+}
+
+
+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;
+       void __iomem *pbuffer, *pstart;
+
+       /*  in byte*/
+       pitch = cursor->w >> 3;
+
+       /* in byte      */
+       count = pitch * cursor->h;
+
+       /* in byte */
+       offset = cursor->maxW * 2 / 8;
+
+       data = 0;
+       pstart = 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
+               iowrite16(data, pbuffer);
+
+               /* 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 += sizeof(u16);
+               }
+
+       }
+}
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..77f51a07500470215cf024681444b72c425bb401 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)
@@ -777,6 +776,12 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
        if (err)
                return err;
 
+       err = pci_request_region(pdev, 0, "sm7xxfb");
+       if (err < 0) {
+               dev_err(&pdev->dev, "cannot reserve framebuffer region\n");
+               goto failed_regions;
+       }
+
        sprintf(smtcfb_fix.id, "sm%Xfb", ent->device);
 
        sfb = smtc_alloc_fb_info(pdev);
@@ -906,6 +911,9 @@ failed_fb:
        smtc_free_fb_info(sfb);
 
 failed_free:
+       pci_release_region(pdev, 0);
+
+failed_regions:
        pci_disable_device(pdev);
 
        return err;
@@ -923,6 +931,8 @@ static const struct pci_device_id smtcfb_pci_table[] = {
        {0,}
 };
 
+MODULE_DEVICE_TABLE(pci, smtcfb_pci_table);
+
 static void smtcfb_pci_remove(struct pci_dev *pdev)
 {
        struct smtcfb_info *sfb;
@@ -932,6 +942,8 @@ static void smtcfb_pci_remove(struct pci_dev *pdev)
        smtc_unmap_mmio(sfb);
        unregister_framebuffer(&sfb->fb);
        smtc_free_fb_info(sfb);
+       pci_release_region(pdev, 0);
+       pci_disable_device(pdev);
 }
 
 #ifdef CONFIG_PM
@@ -1017,7 +1029,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..c955976414ee8d7f46d2eadb4e6e6e33063192fa 100644 (file)
@@ -423,7 +423,8 @@ static void announce_edge(struct vc_data *vc, int msg_id)
        if (spk_bleeps & 1)
                bleep(spk_y);
        if ((spk_bleeps & 2) && (msg_id < edge_quiet))
-               synth_printf("%s\n", spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1));
+               synth_printf("%s\n",
+                       spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1));
 }
 
 static void speak_char(u_char ch)
@@ -1131,7 +1132,8 @@ static void spkup_write(const char *in_buf, int count)
        if (in_count > 2 && rep_count > 2) {
                if (last_type & CH_RPT) {
                        synth_printf(" ");
-                       synth_printf(spk_msg_get(MSG_REPEAT_DESC2), ++rep_count);
+                       synth_printf(spk_msg_get(MSG_REPEAT_DESC2),
+                                       ++rep_count);
                        synth_printf(" ");
                }
                rep_count = 0;
@@ -1527,7 +1529,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;
@@ -1847,7 +1849,8 @@ static void speakup_win_set(struct vc_data *vc)
                        win_right = spk_x;
                }
                snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_BOUNDARY),
-                        (win_start) ? spk_msg_get(MSG_END) : spk_msg_get(MSG_START),
+                        (win_start) ?
+                               spk_msg_get(MSG_END) : spk_msg_get(MSG_START),
                         (int)spk_y + 1, (int)spk_x + 1);
        }
        synth_printf("%s\n", info);
index 317bb8432a04251777cb5beee839b4607e739fa3..1b399214ecf7361ef5cf1ad83c650d0fb1bbc296 100644 (file)
@@ -34,6 +34,7 @@ struct old_serial_port {
 #define SPK_TIMEOUT 100
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
-#define spk_serial_tx_busy() ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY)
+#define spk_serial_tx_busy() \
+       ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY)
 
 #endif
index 898dce5e1243e754a7dafd652d12ff53069b59f8..a7f4962427f36b98d54e98518e8259ff11f044c8 100644 (file)
@@ -61,10 +61,12 @@ extern struct st_var_header *spk_get_var_header(enum var_id_t var_id);
 extern struct st_var_header *spk_var_header_by_name(const char *name);
 extern struct punc_var_t *spk_get_punc_var(enum var_id_t var_id);
 extern int spk_set_num_var(int val, struct st_var_header *var, int how);
-extern int spk_set_string_var(const char *page, struct st_var_header *var, int len);
+extern int spk_set_string_var(const char *page, struct st_var_header *var,
+                               int len);
 extern int spk_set_mask_bits(const char *input, const int which, const int how);
 extern special_func spk_special_handler;
-extern int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key);
+extern int spk_handle_help(struct vc_data *vc, u_char type, u_char ch,
+                               u_short key);
 extern int synth_init(char *name);
 extern void synth_release(void);
 
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..e0b5db9bb46e6eb24af420a8370a6b264ced3c16 100644 (file)
@@ -207,10 +207,12 @@ static void do_catch_up(struct spk_synth *synth)
                        if (time_after_eq(jiffies, jiff_max)) {
                                if (!in_escape)
                                        spk_serial_out(PROCSPEECH);
-                               spin_lock_irqsave(&speakup_info.spinlock, flags);
+                               spin_lock_irqsave(&speakup_info.spinlock,
+                                                       flags);
                                jiffy_delta_val = jiffy_delta->u.n.value;
                                delay_time_val = delay_time->u.n.value;
-                               spin_unlock_irqrestore(&speakup_info.spinlock, flags);
+                               spin_unlock_irqrestore(&speakup_info.spinlock,
+                                                       flags);
                                schedule_timeout(msecs_to_jiffies
                                                 (delay_time_val));
                                jiff_max = jiffies + jiffy_delta_val;
@@ -234,18 +236,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..437e13a85943dc00a0bbb7eb569eafe62589afb2 100644 (file)
@@ -423,10 +423,12 @@ static void do_catch_up(struct spk_synth *synth)
                        if (time_after_eq(jiffies, jiff_max)) {
                                if (!in_escape)
                                        dt_sendchar(PROCSPEECH);
-                               spin_lock_irqsave(&speakup_info.spinlock, flags);
+                               spin_lock_irqsave(&speakup_info.spinlock,
+                                                       flags);
                                jiffy_delta_val = jiffy_delta->u.n.value;
                                delay_time_val = delay_time->u.n.value;
-                               spin_unlock_irqrestore(&speakup_info.spinlock, flags);
+                               spin_unlock_irqrestore(&speakup_info.spinlock,
+                                                       flags);
                                schedule_timeout(msecs_to_jiffies
                                                 (delay_time_val));
                                jiff_max = jiffies + jiffy_delta_val;
@@ -491,18 +493,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..e8ff5d7d6419b3f8f53ccc5896c559eccfc83e45 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,
@@ -167,7 +168,8 @@ struct spk_synth {
        int *default_vol;
        int (*probe)(struct spk_synth *synth);
        void (*release)(void);
-       const char *(*synth_immediate)(struct spk_synth *synth, const char *buff);
+       const char *(*synth_immediate)(struct spk_synth *synth,
+                                       const char *buff);
        void (*catch_up)(struct spk_synth *synth);
        void (*flush)(struct spk_synth *synth);
        int (*is_alive)(struct spk_synth *synth);
@@ -179,6 +181,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..f93d0bb11b12d67f8d3b170e693b83e916c88f92 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,17 +275,13 @@ 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;
        }
 
        /* 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);
+               if (bus->device[i]) {
                        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)
                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)
                return;
-       }
        kmem_cache_free(cur_pool, p);
 }
 EXPORT_SYMBOL_GPL(uislib_cache_free);
@@ -1162,20 +1052,16 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf,
        int remaining_bytes = PROC_READ_BUFFER_SIZE;
 
 /* *start = buf; */
-       if (debug_buf == NULL) {
-               DBGINF("debug_buf == NULL; allocating buffer.\n.");
+       if (!debug_buf) {
                debug_buf = vmalloc(PROC_READ_BUFFER_SIZE);
 
-               if (debug_buf == NULL) {
-                       LOGERR("failed to allocate buffer to provide proc data.\n");
+               if (!debug_buf)
                        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;
@@ -1281,7 +1158,7 @@ static int process_incoming(void *v)
                                * Reschedule work to occur as soon as
                                * possible. */
                                idle_cycles = 0;
-                               if (new_tail == NULL) {
+                               if (!new_tail) {
                                        dev->first_busy_cnt++;
                                        if (!
                                            (list_is_last
@@ -1294,10 +1171,10 @@ static int process_incoming(void *v)
                                        }
                                }
                        }
-                       if (incoming_ti.should_stop)
+                       if (kthread_should_stop())
                                break;
                }
-               if (new_tail != NULL) {
+               if (new_tail) {
                        tot_moved_to_tail_cnt++;
                        list_move_tail(new_tail, &poll_dev_chan);
                }
@@ -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..203de0b5f6071fd9ff5d1ff86113bd869a44f1b0 100644 (file)
 
 static struct cdev file_cdev;
 static struct visorchannel **file_controlvm_channel;
-static dev_t majordev = -1; /**< indicates major num for device */
-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 const struct file_operations visorchipset_fops = {
-       .owner = THIS_MODULE,
-       .open = visorchipset_open,
-       .read = NULL,
-       .write = NULL,
-       .unlocked_ioctl = visorchipset_ioctl,
-       .release = visorchipset_release,
-       .mmap = visorchipset_mmap,
-};
-
-int
-visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
-{
-       int rc = 0;
-
-       file_controlvm_channel = controlvm_channel;
-       majordev = major_dev;
-       cdev_init(&file_cdev, &visorchipset_fops);
-       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);
-                       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);
-                       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);
-               return -1;
-       }
-       INFODRV("Registered char device for %s (major=%d)",
-               MYDRVNAME, MAJOR(majordev));
-       return 0;
-}
 
 void
-visorchipset_file_cleanup(void)
+visorchipset_file_cleanup(dev_t major_dev)
 {
        if (file_cdev.ops != NULL)
                cdev_del(&file_cdev);
        file_cdev.ops = NULL;
-       if (registered) {
-               if (MAJOR(majordev) >= 0) {
-                       unregister_chrdev_region(majordev, 1);
-                       majordev = MKDEV(0, 0);
-               }
-               registered = FALSE;
-       }
+       unregister_chrdev_region(major_dev, 1);
 }
 
 static int
@@ -105,7 +45,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 +54,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 +65,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 +79,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 +110,51 @@ 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;
        }
 }
+
+static const struct file_operations visorchipset_fops = {
+       .owner = THIS_MODULE,
+       .open = visorchipset_open,
+       .read = NULL,
+       .write = NULL,
+       .unlocked_ioctl = visorchipset_ioctl,
+       .release = visorchipset_release,
+       .mmap = visorchipset_mmap,
+};
+
+int
+visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
+{
+       int rc = 0;
+
+       file_controlvm_channel = controlvm_channel;
+       cdev_init(&file_cdev, &visorchipset_fops);
+       file_cdev.owner = THIS_MODULE;
+       if (MAJOR(major_dev) == 0) {
+               rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME);
+               /* dynamic major device number registration required */
+               if (rc < 0)
+                       return rc;
+       } else {
+               /* static major device number registration required */
+               rc = register_chrdev_region(major_dev, 1, MYDRVNAME);
+               if (rc < 0)
+                       return rc;
+       }
+       rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
+       if (rc < 0) {
+               unregister_chrdev_region(major_dev, 1);
+               return rc;
+       }
+       return 0;
+}
index dc7a19556b3f127af30079dba3bf66b08d76b602..51f7699b744bd3df40bf72dd0c8f0189d36e9a17 100644 (file)
@@ -22,6 +22,6 @@
 
 int visorchipset_file_init(dev_t majorDev,
                           struct visorchannel **pControlVm_channel);
-void visorchipset_file_cleanup(void);
+void visorchipset_file_cleanup(dev_t major_dev);
 
 #endif
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..d8a2d6f5a75d7ac953f6747056c956172c6103d5 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,16 +145,16 @@ 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 *
-parser_init_byteStream(u64 addr, u32 bytes, BOOL isLocal, BOOL *tryAgain)
+struct parser_context *
+parser_init_byte_stream(u64 addr, u32 bytes, BOOL local, BOOL *retry)
 {
-       return parser_init_guts(addr, bytes, isLocal, FALSE, tryAgain);
+       return parser_init_guts(addr, bytes, local, FALSE, retry);
 }
 
 /* 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;
@@ -185,40 +165,33 @@ 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)
+void *parser_byte_stream_get(struct parser_context *ctx, ulong *nbytes)
 {
        if (!ctx->byte_stream)
                return NULL;
        if (nbytes)
                *nbytes = ctx->param_bytes;
-       return (void *) ctx->data;
+       return (void *)ctx->data;
 }
 
 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 +211,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 +219,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 +262,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 +293,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 +315,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 +333,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 +347,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 +385,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 +397,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..2b903f1beff2e309d390cc1041780fa77a34a51c 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,
-                                      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);
+struct parser_context *parser_init(u64 addr, u32 bytes, BOOL isLocal,
+                                  BOOL *tryAgain);
+struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, BOOL local,
+                                      BOOL *retry);
+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_byte_stream_get(struct parser_context *ctx, ulong *nbytes);
+void parser_done(struct parser_context *ctx);
 
 #endif
index 98f3ba4c13acefb42ab78b94ed4430af1a464ead..bd46df9ef45a36095aa637d9ad911ec8b2cf247f 100644 (file)
@@ -133,7 +133,6 @@ struct visorchipset_bus_info {
        u8 *description;        /* UTF8 */
        u64 reserved1;
        u32 reserved2;
-       MYPROCOBJECT *proc_object;
        struct {
                u32 server:1;
                /* Add new fields above. */
index f606ee9e0de908fb1107ce6f66fbe07785f3f6c9..f2663d2c753003cdb62171e176baa61b2051cee3 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,8 +48,8 @@
 * message, we switch back to fast polling mode.
 */
 #define MIN_IDLE_SECONDS 10
-static ulong Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-static ulong Most_recent_message_jiffies;      /* when we got our last
+static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+static ulong most_recent_message_jiffies;      /* when we got our last
                                                 * controlvm message */
 static inline char *
 NONULLSTR(char *s)
@@ -66,83 +65,74 @@ static int clientregistered;
 #define MAX_CHIPSET_EVENTS 2
 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
 
-static struct delayed_work Periodic_controlvm_work;
-static struct workqueue_struct *Periodic_controlvm_workqueue;
-static DEFINE_SEMAPHORE(NotifierLock);
+static struct delayed_work periodic_controlvm_work;
+static struct workqueue_struct *periodic_controlvm_workqueue;
+static DEFINE_SEMAPHORE(notifier_lock);
 
-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;
-static const uuid_le UltraDiagPoolChannelProtocolGuid =
+static struct controlvm_message_header g_diag_msg_hdr;
+static struct controlvm_message_header g_chipset_msg_hdr;
+static struct controlvm_message_header g_del_dump_msg_hdr;
+static const uuid_le spar_diag_pool_channel_protocol_uuid =
        SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
 /* 0xffffff is an invalid Bus/Device number */
-static ulong g_diagpoolBusNo = 0xffffff;
-static ulong g_diagpoolDevNo = 0xffffff;
-static struct controlvm_message_packet g_DeviceChangeStatePacket;
+static ulong g_diagpool_bus_no = 0xffffff;
+static ulong g_diagpool_dev_no = 0xffffff;
+static struct controlvm_message_packet g_devicechangestate_packet;
 
 /* Only VNIC and VHBA channels are sent to visorclientbus (aka
  * "visorhackbus")
  */
 #define FOR_VISORHACKBUS(channel_type_guid) \
        (((uuid_le_cmp(channel_type_guid,\
-                      spar_vnic_channel_protocol_uuid) == 0)\
-       || (uuid_le_cmp(channel_type_guid,\
+                      spar_vnic_channel_protocol_uuid) == 0) ||\
+       (uuid_le_cmp(channel_type_guid,\
                        spar_vhba_channel_protocol_uuid) == 0)))
 #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
 
 #define is_diagpool_channel(channel_type_guid) \
-        (uuid_le_cmp(channel_type_guid, UltraDiagPoolChannelProtocolGuid) == 0)
+       (uuid_le_cmp(channel_type_guid,\
+                    spar_diag_pool_channel_protocol_uuid) == 0)
 
-static LIST_HEAD(BusInfoList);
-static LIST_HEAD(DevInfoList);
+static LIST_HEAD(bus_info_list);
+static LIST_HEAD(dev_info_list);
 
-static struct visorchannel *ControlVm_channel;
+static struct visorchannel *controlvm_channel;
 
-typedef struct {
+/* Manages the request payload in the controlvm channel */
+static 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;
+} controlvm_payload_info;
 
-static struct channel_header *Test_Vnic_channel;
-
-typedef struct {
-       struct controlvm_message_header Dumpcapture_header;
-       struct controlvm_message_header Gettextdump_header;
-       struct controlvm_message_header Dumpcomplete_header;
-       BOOL Gettextdump_outstanding;
+/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
+ * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
+ */
+static struct livedump_info {
+       struct controlvm_message_header dumpcapture_header;
+       struct controlvm_message_header gettextdump_header;
+       struct controlvm_message_header dumpcomplete_header;
+       BOOL gettextdump_outstanding;
        u32 crc32;
        ulong length;
        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;
+} 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
  * this scenario, we simply stash the controlvm message, then attempt to
  * process it again the next time controlvm_periodic_work() runs.
  */
-static struct controlvm_message ControlVm_Pending_Msg;
-static BOOL ControlVm_Pending_Msg_Valid = FALSE;
+static struct controlvm_message controlvm_pending_msg;
+static BOOL controlvm_pending_msg_valid = FALSE;
 
 /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
  * TRANSMIT_FILE PutFile payloads.
  */
-static struct kmem_cache *Putfile_buffer_list_pool;
-static const char Putfile_buffer_list_pool_name[] =
+static struct kmem_cache *putfile_buffer_list_pool;
+static const char putfile_buffer_list_pool_name[] =
        "controlvm_putfile_buffer_list_pool";
 
 /* This identifies a data buffer that has been received via a controlvm messages
@@ -150,14 +140,14 @@ 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.
  * Each entry in this list identifies an outstanding TRANSMIT_FILE
  * conversation.
  */
-static LIST_HEAD(Putfile_request_list);
+static LIST_HEAD(putfile_request_list);
 
 /* This describes a buffer and its current state of transfer (e.g., how many
  * bytes have already been supplied as putfile data, and how many bytes are
@@ -165,7 +155,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 */
@@ -213,7 +203,7 @@ struct putfile_request {
        int completion_status;
 };
 
-static atomic_t Visorchipset_cache_buffers_in_use = ATOMIC_INIT(0);
+static atomic_t visorchipset_cache_buffers_in_use = ATOMIC_INIT(0);
 
 struct parahotplug_request {
        struct list_head list;
@@ -222,23 +212,23 @@ struct parahotplug_request {
        struct controlvm_message msg;
 };
 
-static LIST_HEAD(Parahotplug_request_list);
-static DEFINE_SPINLOCK(Parahotplug_request_list_lock); /* lock for above */
+static LIST_HEAD(parahotplug_request_list);
+static DEFINE_SPINLOCK(parahotplug_request_list_lock); /* lock for above */
 static void parahotplug_process_list(void);
 
 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
  * CONTROLVM_REPORTEVENT.
  */
-static struct visorchipset_busdev_notifiers BusDev_Server_Notifiers;
-static struct visorchipset_busdev_notifiers BusDev_Client_Notifiers;
+static struct visorchipset_busdev_notifiers busdev_server_notifiers;
+static struct visorchipset_busdev_notifiers busdev_client_notifiers;
 
-static void bus_create_response(ulong busNo, int response);
-static void bus_destroy_response(ulong busNo, int response);
-static void device_create_response(ulong busNo, ulong devNo, int response);
-static void device_destroy_response(ulong busNo, ulong devNo, int response);
-static void device_resume_response(ulong busNo, ulong devNo, int response);
+static void bus_create_response(ulong bus_no, int response);
+static void bus_destroy_response(ulong bus_no, int response);
+static void device_create_response(ulong bus_no, ulong dev_no, int response);
+static void device_destroy_response(ulong bus_no, ulong dev_no, int response);
+static void device_resume_response(ulong bus_no, ulong dev_no, int response);
 
-static struct visorchipset_busdev_responders BusDev_Responders = {
+static struct visorchipset_busdev_responders busdev_responders = {
        .bus_create = bus_create_response,
        .bus_destroy = bus_destroy_response,
        .device_create = device_create_response,
@@ -248,49 +238,55 @@ static struct visorchipset_busdev_responders BusDev_Responders = {
 };
 
 /* info for /dev/visorchipset */
-static dev_t MajorDev = -1; /**< indicates major num for device */
+static dev_t major_dev = -1; /**< indicates major num for device */
 
 /* prototypes for attributes */
 static ssize_t toolaction_show(struct device *dev,
-       struct device_attribute *attr, char *buf);
+                              struct device_attribute *attr, char *buf);
 static ssize_t toolaction_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count);
+                               struct device_attribute *attr,
+                               const char *buf, size_t count);
 static DEVICE_ATTR_RW(toolaction);
 
 static ssize_t boottotool_show(struct device *dev,
-       struct device_attribute *attr, char *buf);
+                              struct device_attribute *attr, char *buf);
 static ssize_t boottotool_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count);
+                               struct device_attribute *attr, const char *buf,
+                               size_t count);
 static DEVICE_ATTR_RW(boottotool);
 
 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
-       char *buf);
+                         char *buf);
 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
-       const char *buf, size_t count);
+                          const char *buf, size_t count);
 static DEVICE_ATTR_RW(error);
 
 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
-       char *buf);
+                          char *buf);
 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
-       const char *buf, size_t count);
+                           const char *buf, size_t count);
 static DEVICE_ATTR_RW(textid);
 
 static ssize_t remaining_steps_show(struct device *dev,
-       struct device_attribute *attr, char *buf);
+                                   struct device_attribute *attr, char *buf);
 static ssize_t remaining_steps_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count);
+                                    struct device_attribute *attr,
+                                    const char *buf, size_t count);
 static DEVICE_ATTR_RW(remaining_steps);
 
 static ssize_t chipsetready_store(struct device *dev,
-               struct device_attribute *attr, const char *buf, size_t count);
+                                 struct device_attribute *attr,
+                                 const char *buf, size_t count);
 static DEVICE_ATTR_WO(chipsetready);
 
 static ssize_t devicedisabled_store(struct device *dev,
-               struct device_attribute *attr, const char *buf, size_t count);
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t count);
 static DEVICE_ATTR_WO(devicedisabled);
 
 static ssize_t deviceenabled_store(struct device *dev,
-               struct device_attribute *attr, const char *buf, size_t count);
+                                  struct device_attribute *attr,
+                                  const char *buf, size_t count);
 static DEVICE_ATTR_WO(deviceenabled);
 
 static struct attribute *visorchipset_install_attrs[] = {
@@ -336,47 +332,48 @@ static const struct attribute_group *visorchipset_dev_groups[] = {
 };
 
 /* /sys/devices/platform/visorchipset */
-static struct platform_device Visorchipset_platform_device = {
+static struct platform_device visorchipset_platform_device = {
        .name = "visorchipset",
        .id = -1,
        .dev.groups = visorchipset_dev_groups,
 };
 
 /* Function prototypes */
-static void controlvm_respond(struct controlvm_message_header *msgHdr,
+static void controlvm_respond(struct controlvm_message_header *msg_hdr,
                              int response);
 static void controlvm_respond_chipset_init(
-               struct controlvm_message_header *msgHdr, int response,
+               struct controlvm_message_header *msg_hdr, int response,
                enum ultra_chipset_feature features);
 static void controlvm_respond_physdev_changestate(
-               struct controlvm_message_header *msgHdr, int response,
+               struct controlvm_message_header *msg_hdr, int response,
                struct spar_segment_state state);
 
 static ssize_t toolaction_show(struct device *dev,
                               struct device_attribute *attr,
                               char *buf)
 {
-       u8 toolAction;
+       u8 tool_action;
 
-       visorchannel_read(ControlVm_channel,
+       visorchannel_read(controlvm_channel,
                offsetof(struct spar_controlvm_channel_protocol,
-                          tool_action), &toolAction, sizeof(u8));
-       return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
+                        tool_action), &tool_action, sizeof(u8));
+       return scnprintf(buf, PAGE_SIZE, "%u\n", tool_action);
 }
 
 static ssize_t toolaction_store(struct device *dev,
                                struct device_attribute *attr,
                                const char *buf, size_t count)
 {
-       u8 toolAction;
+       u8 tool_action;
        int ret;
 
-       if (kstrtou8(buf, 10, &toolAction) != 0)
+       if (kstrtou8(buf, 10, &tool_action) != 0)
                return -EINVAL;
 
-       ret = visorchannel_write(ControlVm_channel,
-               offsetof(struct spar_controlvm_channel_protocol, tool_action),
-               &toolAction, sizeof(u8));
+       ret = visorchannel_write(controlvm_channel,
+               offsetof(struct spar_controlvm_channel_protocol,
+                        tool_action),
+               &tool_action, sizeof(u8));
 
        if (ret)
                return ret;
@@ -387,14 +384,14 @@ static ssize_t boottotool_show(struct device *dev,
                               struct device_attribute *attr,
                               char *buf)
 {
-       struct efi_spar_indication efiSparIndication;
+       struct efi_spar_indication efi_spar_indication;
 
-       visorchannel_read(ControlVm_channel,
-               offsetof(struct spar_controlvm_channel_protocol,
-                       efi_spar_ind), &efiSparIndication,
-               sizeof(struct efi_spar_indication));
+       visorchannel_read(controlvm_channel,
+                         offsetof(struct spar_controlvm_channel_protocol,
+                                  efi_spar_ind), &efi_spar_indication,
+                         sizeof(struct efi_spar_indication));
        return scnprintf(buf, PAGE_SIZE, "%u\n",
-                       efiSparIndication.boot_to_tool);
+                        efi_spar_indication.boot_to_tool);
 }
 
 static ssize_t boottotool_store(struct device *dev,
@@ -402,17 +399,16 @@ static ssize_t boottotool_store(struct device *dev,
                                const char *buf, size_t count)
 {
        int val, ret;
-       struct efi_spar_indication efiSparIndication;
+       struct efi_spar_indication efi_spar_indication;
 
        if (kstrtoint(buf, 10, &val) != 0)
                return -EINVAL;
 
-       efiSparIndication.boot_to_tool = val;
-       ret = visorchannel_write(ControlVm_channel,
+       efi_spar_indication.boot_to_tool = val;
+       ret = visorchannel_write(controlvm_channel,
                        offsetof(struct spar_controlvm_channel_protocol,
-                               efi_spar_ind),
-                       &(efiSparIndication),
-               sizeof(struct efi_spar_indication));
+                                efi_spar_ind), &(efi_spar_indication),
+                                sizeof(struct efi_spar_indication));
 
        if (ret)
                return ret;
@@ -420,18 +416,19 @@ static ssize_t boottotool_store(struct device *dev,
 }
 
 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
-               char *buf)
+                         char *buf)
 {
        u32 error;
 
-       visorchannel_read(ControlVm_channel, offsetof(
-               struct spar_controlvm_channel_protocol, installation_error),
-               &error, sizeof(u32));
+       visorchannel_read(controlvm_channel,
+                         offsetof(struct spar_controlvm_channel_protocol,
+                                  installation_error),
+                         &error, sizeof(u32));
        return scnprintf(buf, PAGE_SIZE, "%i\n", error);
 }
 
 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
-               const char *buf, size_t count)
+                          const char *buf, size_t count)
 {
        u32 error;
        int ret;
@@ -439,114 +436,81 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
        if (kstrtou32(buf, 10, &error) != 0)
                return -EINVAL;
 
-       ret = visorchannel_write(ControlVm_channel,
-                       offsetof(struct spar_controlvm_channel_protocol,
-                               installation_error),
-                       &error, sizeof(u32));
+       ret = visorchannel_write(controlvm_channel,
+               offsetof(struct spar_controlvm_channel_protocol,
+                        installation_error),
+               &error, sizeof(u32));
        if (ret)
                return ret;
        return count;
 }
 
 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
-               char *buf)
+                          char *buf)
 {
-       u32 textId;
+       u32 text_id;
 
-       visorchannel_read(ControlVm_channel, offsetof(
-               struct spar_controlvm_channel_protocol, installation_text_id),
-               &textId, sizeof(u32));
-       return scnprintf(buf, PAGE_SIZE, "%i\n", textId);
+       visorchannel_read(controlvm_channel,
+                         offsetof(struct spar_controlvm_channel_protocol,
+                                  installation_text_id),
+                         &text_id, sizeof(u32));
+       return scnprintf(buf, PAGE_SIZE, "%i\n", text_id);
 }
 
 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
-               const char *buf, size_t count)
+                           const char *buf, size_t count)
 {
-       u32 textId;
+       u32 text_id;
        int ret;
 
-       if (kstrtou32(buf, 10, &textId) != 0)
+       if (kstrtou32(buf, 10, &text_id) != 0)
                return -EINVAL;
 
-       ret = visorchannel_write(ControlVm_channel,
-                       offsetof(struct spar_controlvm_channel_protocol,
-                               installation_text_id),
-                       &textId, sizeof(u32));
+       ret = visorchannel_write(controlvm_channel,
+               offsetof(struct spar_controlvm_channel_protocol,
+                        installation_text_id),
+               &text_id, sizeof(u32));
        if (ret)
                return ret;
        return count;
 }
 
-
 static ssize_t remaining_steps_show(struct device *dev,
-       struct device_attribute *attr, char *buf)
+                                   struct device_attribute *attr, char *buf)
 {
-       u16 remainingSteps;
+       u16 remaining_steps;
 
-       visorchannel_read(ControlVm_channel,
-               offsetof(struct spar_controlvm_channel_protocol,
-                       installation_remaining_steps),
-               &remainingSteps,
-               sizeof(u16));
-       return scnprintf(buf, PAGE_SIZE, "%hu\n", remainingSteps);
+       visorchannel_read(controlvm_channel,
+                         offsetof(struct spar_controlvm_channel_protocol,
+                                  installation_remaining_steps),
+                         &remaining_steps, sizeof(u16));
+       return scnprintf(buf, PAGE_SIZE, "%hu\n", remaining_steps);
 }
 
 static ssize_t remaining_steps_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count)
+                                    struct device_attribute *attr,
+                                    const char *buf, size_t count)
 {
-       u16 remainingSteps;
+       u16 remaining_steps;
        int ret;
 
-       if (kstrtou16(buf, 10, &remainingSteps) != 0)
+       if (kstrtou16(buf, 10, &remaining_steps) != 0)
                return -EINVAL;
 
-       ret = visorchannel_write(ControlVm_channel,
-                       offsetof(struct spar_controlvm_channel_protocol,
-                               installation_remaining_steps),
-                       &remainingSteps, sizeof(u16));
+       ret = visorchannel_write(controlvm_channel,
+               offsetof(struct spar_controlvm_channel_protocol,
+                        installation_remaining_steps),
+               &remaining_steps, sizeof(u16));
        if (ret)
                return ret;
        return count;
 }
 
-#if 0
-static void
-testUnicode(void)
-{
-       wchar_t unicodeString[] = { 'a', 'b', 'c', 0 };
-       char s[sizeof(unicodeString) * NLS_MAX_CHARSET_SIZE];
-       wchar_t unicode2[99];
-
-       /* NOTE: Either due to a bug, or feature I don't understand, the
-        *       kernel utf8_mbstowcs() and utf_wcstombs() do NOT copy the
-        *       trailed NUL byte!!   REALLY!!!!!    Arrrrgggghhhhh
-        */
-
-       LOGINF("sizeof(wchar_t) = %d", sizeof(wchar_t));
-       LOGINF("utf8_wcstombs=%d",
-              chrs = utf8_wcstombs(s, unicodeString, sizeof(s)));
-       if (chrs >= 0)
-               s[chrs] = '\0'; /* GRRRRRRRR */
-       LOGINF("s='%s'", s);
-       LOGINF("utf8_mbstowcs=%d", chrs = utf8_mbstowcs(unicode2, s, 100));
-       if (chrs >= 0)
-               unicode2[chrs] = 0;     /* GRRRRRRRR */
-       if (memcmp(unicodeString, unicode2, sizeof(unicodeString)) == 0)
-               LOGINF("strings match... good");
-       else
-               LOGINF("strings did not match!!");
-}
-#endif
-
 static void
-busInfo_clear(void *v)
+bus_info_clear(void *v)
 {
        struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v);
 
-       if (p->proc_object) {
-               visor_proc_DestroyObject(p->proc_object);
-               p->proc_object = NULL;
-       }
        kfree(p->name);
        p->name = NULL;
 
@@ -558,7 +522,7 @@ busInfo_clear(void *v)
 }
 
 static void
-devInfo_clear(void *v)
+dev_info_clear(void *v)
 {
        struct visorchipset_device_info *p =
                        (struct visorchipset_device_info *)(v);
@@ -593,22 +557,22 @@ visorchipset_register_busdev_server(
                        struct visorchipset_busdev_responders *responders,
                        struct ultra_vbus_deviceinfo *driver_info)
 {
-       down(&NotifierLock);
-       if (notifiers == NULL) {
-               memset(&BusDev_Server_Notifiers, 0,
-                      sizeof(BusDev_Server_Notifiers));
+       down(&notifier_lock);
+       if (!notifiers) {
+               memset(&busdev_server_notifiers, 0,
+                      sizeof(busdev_server_notifiers));
                serverregistered = 0;   /* clear flag */
        } else {
-               BusDev_Server_Notifiers = *notifiers;
+               busdev_server_notifiers = *notifiers;
                serverregistered = 1;   /* set flag */
        }
        if (responders)
-               *responders = BusDev_Responders;
+               *responders = busdev_responders;
        if (driver_info)
                bus_device_info_init(driver_info, "chipset", "visorchipset",
-                                  VERSION, NULL);
+                                    VERSION, NULL);
 
-       up(&NotifierLock);
+       up(&notifier_lock);
 }
 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
 
@@ -618,21 +582,21 @@ visorchipset_register_busdev_client(
                        struct visorchipset_busdev_responders *responders,
                        struct ultra_vbus_deviceinfo *driver_info)
 {
-       down(&NotifierLock);
-       if (notifiers == NULL) {
-               memset(&BusDev_Client_Notifiers, 0,
-                      sizeof(BusDev_Client_Notifiers));
+       down(&notifier_lock);
+       if (!notifiers) {
+               memset(&busdev_client_notifiers, 0,
+                      sizeof(busdev_client_notifiers));
                clientregistered = 0;   /* clear flag */
        } else {
-               BusDev_Client_Notifiers = *notifiers;
+               busdev_client_notifiers = *notifiers;
                clientregistered = 1;   /* set flag */
        }
        if (responders)
-               *responders = BusDev_Responders;
+               *responders = busdev_responders;
        if (driver_info)
                bus_device_info_init(driver_info, "chipset(bolts)",
                                     "visorchipset", VERSION, NULL);
-       up(&NotifierLock);
+       up(&notifier_lock);
 }
 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
 
@@ -642,14 +606,14 @@ cleanup_controlvm_structures(void)
        struct visorchipset_bus_info *bi, *tmp_bi;
        struct visorchipset_device_info *di, *tmp_di;
 
-       list_for_each_entry_safe(bi, tmp_bi, &BusInfoList, entry) {
-               busInfo_clear(bi);
+       list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
+               bus_info_clear(bi);
                list_del(&bi->entry);
                kfree(bi);
        }
 
-       list_for_each_entry_safe(di, tmp_di, &DevInfoList, entry) {
-               devInfo_clear(di);
+       list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
+               dev_info_clear(di);
                list_del(&di->entry);
                kfree(di);
        }
@@ -664,9 +628,8 @@ 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;
+               goto cleanup;
        }
        chipset_inited = 1;
        POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
@@ -681,7 +644,7 @@ chipset_init(struct controlvm_message *inmsg)
         * features-aware driver. */
        features |= ULTRA_CHIPSET_FEATURE_REPLY;
 
-Away:
+cleanup:
        if (rc < 0)
                cleanup_controlvm_structures();
        if (inmsg->hdr.flags.response_expected)
@@ -690,10 +653,10 @@ Away:
 
 static void
 controlvm_init_response(struct controlvm_message *msg,
-                       struct controlvm_message_header *msgHdr, int response)
+                       struct controlvm_message_header *msg_hdr, int response)
 {
        memset(msg, 0, sizeof(struct controlvm_message));
-       memcpy(&msg->hdr, msgHdr, sizeof(struct controlvm_message_header));
+       memcpy(&msg->hdr, msg_hdr, sizeof(struct controlvm_message_header));
        msg->hdr.payload_bytes = 0;
        msg->hdr.payload_vm_offset = 0;
        msg->hdr.payload_max_bytes = 0;
@@ -704,59 +667,54 @@ controlvm_init_response(struct controlvm_message *msg,
 }
 
 static void
-controlvm_respond(struct controlvm_message_header *msgHdr, int response)
+controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
 {
        struct controlvm_message outmsg;
 
-       controlvm_init_response(&outmsg, msgHdr, response);
+       controlvm_init_response(&outmsg, msg_hdr, response);
        /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
        * back the deviceChangeState structure in the packet. */
-       if (msgHdr->id == CONTROLVM_DEVICE_CHANGESTATE
-           && g_DeviceChangeStatePacket.device_change_state.bus_no ==
-           g_diagpoolBusNo
-           && 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 (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
+           g_devicechangestate_packet.device_change_state.bus_no ==
+           g_diagpool_bus_no &&
+           g_devicechangestate_packet.device_change_state.dev_no ==
+           g_diagpool_dev_no)
+               outmsg.cmd = g_devicechangestate_packet;
+       if (outmsg.hdr.flags.test_message == 1)
                return;
-       }
-       if (!visorchannel_signalinsert(ControlVm_channel,
+
+       if (!visorchannel_signalinsert(controlvm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
 
 static void
-controlvm_respond_chipset_init(struct controlvm_message_header *msgHdr,
+controlvm_respond_chipset_init(struct controlvm_message_header *msg_hdr,
                               int response,
                               enum ultra_chipset_feature features)
 {
        struct controlvm_message outmsg;
 
-       controlvm_init_response(&outmsg, msgHdr, response);
+       controlvm_init_response(&outmsg, msg_hdr, response);
        outmsg.cmd.init_chipset.features = features;
-       if (!visorchannel_signalinsert(ControlVm_channel,
+       if (!visorchannel_signalinsert(controlvm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
 
 static void controlvm_respond_physdev_changestate(
-               struct controlvm_message_header *msgHdr, int response,
+               struct controlvm_message_header *msg_hdr, int response,
                struct spar_segment_state state)
 {
        struct controlvm_message outmsg;
 
-       controlvm_init_response(&outmsg, msgHdr, response);
+       controlvm_init_response(&outmsg, msg_hdr, response);
        outmsg.cmd.device_change_state.state = state;
        outmsg.cmd.device_change_state.flags.phys_device = 1;
-       if (!visorchannel_signalinsert(ControlVm_channel,
+       if (!visorchannel_signalinsert(controlvm_channel,
                                       CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
                return;
        }
 }
@@ -765,56 +723,50 @@ void
 visorchipset_save_message(struct controlvm_message *msg,
                          enum crash_obj_type type)
 {
-       u32 localSavedCrashMsgOffset;
-       u16 localSavedCrashMsgCount;
+       u32 crash_msg_offset;
+       u16 crash_msg_count;
 
        /* get saved message count */
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_count),
-                             &localSavedCrashMsgCount, sizeof(u16)) < 0) {
-               LOGERR("failed to get Saved Message Count");
+                             &crash_msg_count, sizeof(u16)) < 0) {
                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);
+       if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
                POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
-                                localSavedCrashMsgCount,
+                                crash_msg_count,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        /* get saved crash message offset */
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_offset),
-                             &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
-               LOGERR("failed to get Saved Message Offset");
+                             &crash_msg_offset, sizeof(u32)) < 0) {
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        if (type == CRASH_BUS) {
-               if (visorchannel_write(ControlVm_channel,
-                                      localSavedCrashMsgOffset,
+               if (visorchannel_write(controlvm_channel,
+                                      crash_msg_offset,
                                       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;
                }
        } else {
-               if (visorchannel_write(ControlVm_channel,
-                                      localSavedCrashMsgOffset +
+               if (visorchannel_write(controlvm_channel,
+                                      crash_msg_offset +
                                       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;
@@ -824,134 +776,118 @@ visorchipset_save_message(struct controlvm_message *msg,
 EXPORT_SYMBOL_GPL(visorchipset_save_message);
 
 static void
-bus_responder(enum controlvm_id cmdId, ulong busNo, int response)
+bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response)
 {
        struct visorchipset_bus_info *p = NULL;
        BOOL need_clear = FALSE;
 
-       p = findbus(&BusInfoList, busNo);
-       if (!p) {
-               LOGERR("internal error busNo=%lu", busNo);
+       p = findbus(&bus_info_list, bus_no);
+       if (!p)
                return;
-       }
+
        if (response < 0) {
-               if ((cmdId == CONTROLVM_BUS_CREATE) &&
+               if ((cmd_id == CONTROLVM_BUS_CREATE) &&
                    (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
                        /* undo the row we just created... */
-                       delbusdevices(&DevInfoList, busNo);
+                       delbusdevices(&dev_info_list, bus_no);
        } else {
-               if (cmdId == CONTROLVM_BUS_CREATE)
+               if (cmd_id == CONTROLVM_BUS_CREATE)
                        p->state.created = 1;
-               if (cmdId == CONTROLVM_BUS_DESTROY)
+               if (cmd_id == CONTROLVM_BUS_DESTROY)
                        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)cmd_id)
                return;
-       }
        controlvm_respond(&p->pending_msg_hdr, response);
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
        if (need_clear) {
-               busInfo_clear(p);
-               delbusdevices(&DevInfoList, busNo);
+               bus_info_clear(p);
+               delbusdevices(&dev_info_list, bus_no);
        }
 }
 
 static void
-device_changestate_responder(enum controlvm_id cmdId,
-                            ulong busNo, ulong devNo, int response,
-                            struct spar_segment_state responseState)
+device_changestate_responder(enum controlvm_id cmd_id,
+                            ulong bus_no, ulong dev_no, int response,
+                            struct spar_segment_state response_state)
 {
        struct visorchipset_device_info *p = NULL;
        struct controlvm_message outmsg;
 
-       p = finddevice(&DevInfoList, busNo, devNo);
-       if (!p) {
-               LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
+       p = finddevice(&dev_info_list, bus_no, dev_no);
+       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 != cmd_id)
                return;
-       }
 
        controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
 
-       outmsg.cmd.device_change_state.bus_no = busNo;
-       outmsg.cmd.device_change_state.dev_no = devNo;
-       outmsg.cmd.device_change_state.state = responseState;
+       outmsg.cmd.device_change_state.bus_no = bus_no;
+       outmsg.cmd.device_change_state.dev_no = dev_no;
+       outmsg.cmd.device_change_state.state = response_state;
 
-       if (!visorchannel_signalinsert(ControlVm_channel,
-                                      CONTROLVM_QUEUE_REQUEST, &outmsg)) {
-               LOGERR("signalinsert failed!");
+       if (!visorchannel_signalinsert(controlvm_channel,
+                                      CONTROLVM_QUEUE_REQUEST, &outmsg))
                return;
-       }
 
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
 }
 
 static void
-device_responder(enum controlvm_id cmdId, ulong busNo, ulong devNo,
+device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no,
                 int response)
 {
        struct visorchipset_device_info *p = NULL;
        BOOL need_clear = FALSE;
 
-       p = finddevice(&DevInfoList, busNo, devNo);
-       if (!p) {
-               LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
+       p = finddevice(&dev_info_list, bus_no, dev_no);
+       if (!p)
                return;
-       }
        if (response >= 0) {
-               if (cmdId == CONTROLVM_DEVICE_CREATE)
+               if (cmd_id == CONTROLVM_DEVICE_CREATE)
                        p->state.created = 1;
-               if (cmdId == CONTROLVM_DEVICE_DESTROY)
+               if (cmd_id == CONTROLVM_DEVICE_DESTROY)
                        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)cmd_id)
                return;
-       }
+
        controlvm_respond(&p->pending_msg_hdr, response);
        p->pending_msg_hdr.id = CONTROLVM_INVALID;
        if (need_clear)
-               devInfo_clear(p);
+               dev_info_clear(p);
 }
 
 static void
-bus_epilog(u32 busNo,
-          u32 cmd, struct controlvm_message_header *msgHdr,
-          int response, BOOL needResponse)
+bus_epilog(u32 bus_no,
+          u32 cmd, struct controlvm_message_header *msg_hdr,
+          int response, BOOL need_response)
 {
        BOOL notified = FALSE;
 
-       struct visorchipset_bus_info *pBusInfo = findbus(&BusInfoList, busNo);
+       struct visorchipset_bus_info *bus_info = findbus(&bus_info_list,
+                                                        bus_no);
 
-       if (!pBusInfo) {
-               LOGERR("HUH? bad busNo=%d", busNo);
+       if (!bus_info)
                return;
-       }
-       if (needResponse) {
-               memcpy(&pBusInfo->pending_msg_hdr, msgHdr,
+
+       if (need_response) {
+               memcpy(&bus_info->pending_msg_hdr, msg_hdr,
                       sizeof(struct controlvm_message_header));
-       } else
-               pBusInfo->pending_msg_hdr.id = CONTROLVM_INVALID;
+       } else {
+               bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+       }
 
-       down(&NotifierLock);
+       down(&notifier_lock);
        if (response == CONTROLVM_RESP_SUCCESS) {
                switch (cmd) {
                case CONTROLVM_BUS_CREATE:
@@ -965,24 +901,24 @@ bus_epilog(u32 busNo,
                        * either server or client devices
                        * - BusDev_Client can handle ONLY client
                        * devices */
-                       if (BusDev_Server_Notifiers.bus_create) {
-                               (*BusDev_Server_Notifiers.bus_create) (busNo);
+                       if (busdev_server_notifiers.bus_create) {
+                               (*busdev_server_notifiers.bus_create) (bus_no);
                                notified = TRUE;
                        }
-                       if ((!pBusInfo->flags.server) /*client */ &&
-                           BusDev_Client_Notifiers.bus_create) {
-                               (*BusDev_Client_Notifiers.bus_create) (busNo);
+                       if ((!bus_info->flags.server) /*client */ &&
+                           busdev_client_notifiers.bus_create) {
+                               (*busdev_client_notifiers.bus_create) (bus_no);
                                notified = TRUE;
                        }
                        break;
                case CONTROLVM_BUS_DESTROY:
-                       if (BusDev_Server_Notifiers.bus_destroy) {
-                               (*BusDev_Server_Notifiers.bus_destroy) (busNo);
+                       if (busdev_server_notifiers.bus_destroy) {
+                               (*busdev_server_notifiers.bus_destroy) (bus_no);
                                notified = TRUE;
                        }
-                       if ((!pBusInfo->flags.server) /*client */ &&
-                           BusDev_Client_Notifiers.bus_destroy) {
-                               (*BusDev_Client_Notifiers.bus_destroy) (busNo);
+                       if ((!bus_info->flags.server) /*client */ &&
+                           busdev_client_notifiers.bus_destroy) {
+                               (*busdev_client_notifiers.bus_destroy) (bus_no);
                                notified = TRUE;
                        }
                        break;
@@ -995,45 +931,45 @@ bus_epilog(u32 busNo,
                 */
                ;
        else
-               bus_responder(cmd, busNo, response);
-       up(&NotifierLock);
+               bus_responder(cmd, bus_no, response);
+       up(&notifier_lock);
 }
 
 static void
-device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
-             struct controlvm_message_header *msgHdr, int response,
-             BOOL needResponse, BOOL for_visorbus)
+device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
+             struct controlvm_message_header *msg_hdr, int response,
+             BOOL need_response, BOOL for_visorbus)
 {
        struct visorchipset_busdev_notifiers *notifiers = NULL;
        BOOL notified = FALSE;
 
-       struct visorchipset_device_info *pDevInfo =
-               finddevice(&DevInfoList, busNo, devNo);
+       struct visorchipset_device_info *dev_info =
+               finddevice(&dev_info_list, bus_no, dev_no);
        char *envp[] = {
                "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
                NULL
        };
 
-       if (!pDevInfo) {
-               LOGERR("HUH? bad busNo=%d, devNo=%d", busNo, devNo);
+       if (!dev_info)
                return;
-       }
+
        if (for_visorbus)
-               notifiers = &BusDev_Server_Notifiers;
+               notifiers = &busdev_server_notifiers;
        else
-               notifiers = &BusDev_Client_Notifiers;
-       if (needResponse) {
-               memcpy(&pDevInfo->pending_msg_hdr, msgHdr,
+               notifiers = &busdev_client_notifiers;
+       if (need_response) {
+               memcpy(&dev_info->pending_msg_hdr, msg_hdr,
                       sizeof(struct controlvm_message_header));
-       } else
-               pDevInfo->pending_msg_hdr.id = CONTROLVM_INVALID;
+       } else {
+               dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+       }
 
-       down(&NotifierLock);
+       down(&notifier_lock);
        if (response >= 0) {
                switch (cmd) {
                case CONTROLVM_DEVICE_CREATE:
                        if (notifiers->device_create) {
-                               (*notifiers->device_create) (busNo, devNo);
+                               (*notifiers->device_create) (bus_no, dev_no);
                                notified = TRUE;
                        }
                        break;
@@ -1043,8 +979,8 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                            state.operating ==
                                segment_state_running.operating) {
                                if (notifiers->device_resume) {
-                                       (*notifiers->device_resume) (busNo,
-                                                                    devNo);
+                                       (*notifiers->device_resume) (bus_no,
+                                                                    dev_no);
                                        notified = TRUE;
                                }
                        }
@@ -1056,8 +992,8 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                                 * where server is lost
                                 */
                                if (notifiers->device_pause) {
-                                       (*notifiers->device_pause) (busNo,
-                                                                   devNo);
+                                       (*notifiers->device_pause) (bus_no,
+                                                                   dev_no);
                                        notified = TRUE;
                                }
                        } else if (state.alive == segment_state_paused.alive &&
@@ -1066,22 +1002,20 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                                /* this is lite pause where channel is
                                 * still valid just 'pause' of it
                                 */
-                               if (busNo == g_diagpoolBusNo
-                                   && devNo == g_diagpoolDevNo) {
-                                       LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)",
-                                            busNo, devNo);
+                               if (bus_no == g_diagpool_bus_no &&
+                                   dev_no == g_diagpool_dev_no) {
                                        /* this will trigger the
                                         * diag_shutdown.sh script in
                                         * the visorchipset hotplug */
                                        kobject_uevent_env
-                                           (&Visorchipset_platform_device.dev.
+                                           (&visorchipset_platform_device.dev.
                                             kobj, KOBJ_ONLINE, envp);
                                }
                        }
                        break;
                case CONTROLVM_DEVICE_DESTROY:
                        if (notifiers->device_destroy) {
-                               (*notifiers->device_destroy) (busNo, devNo);
+                               (*notifiers->device_destroy) (bus_no, dev_no);
                                notified = TRUE;
                        }
                        break;
@@ -1094,62 +1028,57 @@ device_epilog(u32 busNo, u32 devNo, struct spar_segment_state state, u32 cmd,
                 */
                ;
        else
-               device_responder(cmd, busNo, devNo, response);
-       up(&NotifierLock);
+               device_responder(cmd, bus_no, dev_no, response);
+       up(&notifier_lock);
 }
 
 static void
 bus_create(struct controlvm_message *inmsg)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
-       ulong busNo = cmd->create_bus.bus_no;
+       ulong bus_no = cmd->create_bus.bus_no;
        int rc = CONTROLVM_RESP_SUCCESS;
-       struct visorchipset_bus_info *pBusInfo = NULL;
-
+       struct visorchipset_bus_info *bus_info = NULL;
 
-       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,
+       bus_info = findbus(&bus_info_list, bus_no);
+       if (bus_info && (bus_info->state.created == 1)) {
+               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-               goto Away;
+               goto cleanup;
        }
-       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,
+       bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
+       if (!bus_info) {
+               POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
-               goto Away;
+               goto cleanup;
        }
 
-       INIT_LIST_HEAD(&pBusInfo->entry);
-       pBusInfo->bus_no = busNo;
-       pBusInfo->dev_no = cmd->create_bus.dev_count;
+       INIT_LIST_HEAD(&bus_info->entry);
+       bus_info->bus_no = bus_no;
+       bus_info->dev_no = cmd->create_bus.dev_count;
 
-       POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO);
+       POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
        if (inmsg->hdr.flags.test_message == 1)
-               pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST;
+               bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
        else
-               pBusInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
+               bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
 
-       pBusInfo->flags.server = inmsg->hdr.flags.server;
-       pBusInfo->chan_info.channel_addr = cmd->create_bus.channel_addr;
-       pBusInfo->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
-       pBusInfo->chan_info.channel_type_uuid =
+       bus_info->flags.server = inmsg->hdr.flags.server;
+       bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
+       bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
+       bus_info->chan_info.channel_type_uuid =
                        cmd->create_bus.bus_data_type_uuid;
-       pBusInfo->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
+       bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
 
-       list_add(&pBusInfo->entry, &BusInfoList);
+       list_add(&bus_info->entry, &bus_info_list);
 
-       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO);
+       POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
 
-Away:
-       bus_epilog(busNo, CONTROLVM_BUS_CREATE, &inmsg->hdr,
+cleanup:
+       bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1157,76 +1086,58 @@ static void
 bus_destroy(struct controlvm_message *inmsg)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
-       ulong busNo = cmd->destroy_bus.bus_no;
-       struct visorchipset_bus_info *pBusInfo;
+       ulong bus_no = cmd->destroy_bus.bus_no;
+       struct visorchipset_bus_info *bus_info;
        int rc = CONTROLVM_RESP_SUCCESS;
 
-       pBusInfo = findbus(&BusInfoList, busNo);
-       if (!pBusInfo) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo);
+       bus_info = findbus(&bus_info_list, bus_no);
+       if (!bus_info)
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-               goto Away;
-       }
-       if (pBusInfo->state.created == 0) {
-               LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed",
-                    busNo);
+       else if (bus_info->state.created == 0)
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-               goto Away;
-       }
 
-Away:
-       bus_epilog(busNo, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
+       bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
 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;
-       struct visorchipset_bus_info *pBusInfo = NULL;
+       ulong bus_no = cmd->configure_bus.bus_no;
+       struct visorchipset_bus_info *bus_info = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
        char s[99];
 
-       busNo = cmd->configure_bus.bus_no;
-       POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO);
+       bus_no = cmd->configure_bus.bus_no;
+       POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
+                        POSTCODE_SEVERITY_INFO);
 
-       pBusInfo = findbus(&BusInfoList, busNo);
-       if (!pBusInfo) {
-               LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid",
-                      busNo);
-               POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo,
+       bus_info = findbus(&bus_info_list, bus_no);
+       if (!bus_info) {
+               POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
                                 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,
+       } else if (bus_info->state.created == 0) {
+               POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-               goto Away;
-       }
-       /* 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,
+       } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
+               POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
-               goto Away;
-       }
-
-       pBusInfo->partition_handle = cmd->configure_bus.guest_handle;
-       pBusInfo->partition_uuid = parser_id_get(parser_ctx);
-       parser_param_start(parser_ctx, PARSERSTRING_NAME);
-       pBusInfo->name = parser_string_get(parser_ctx);
+       } else {
+               bus_info->partition_handle = cmd->configure_bus.guest_handle;
+               bus_info->partition_uuid = parser_id_get(parser_ctx);
+               parser_param_start(parser_ctx, PARSERSTRING_NAME);
+               bus_info->name = parser_string_get(parser_ctx);
 
-       visorchannel_uuid_id(&pBusInfo->partition_uuid, s);
-       POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO);
-Away:
-       bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
+               visorchannel_uuid_id(&bus_info->partition_uuid, s);
+               POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
+                                POSTCODE_SEVERITY_INFO);
+       }
+       bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
                   rc, inmsg->hdr.flags.response_expected == 1);
 }
 
@@ -1234,191 +1145,158 @@ static void
 my_device_create(struct controlvm_message *inmsg)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
-       ulong busNo = cmd->create_device.bus_no;
-       ulong devNo = cmd->create_device.dev_no;
-       struct visorchipset_device_info *pDevInfo = NULL;
-       struct visorchipset_bus_info *pBusInfo = NULL;
+       ulong bus_no = cmd->create_device.bus_no;
+       ulong dev_no = cmd->create_device.dev_no;
+       struct visorchipset_device_info *dev_info = NULL;
+       struct visorchipset_bus_info *bus_info = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
-       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,
+       dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+       if (dev_info && (dev_info->state.created == 1)) {
+               POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-               goto Away;
+               goto cleanup;
        }
-       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,
+       bus_info = findbus(&bus_info_list, bus_no);
+       if (!bus_info) {
+               POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-               goto Away;
+               goto cleanup;
        }
-       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,
+       if (bus_info->state.created == 0) {
+               POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
-               goto Away;
+               goto cleanup;
        }
-       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,
+       dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
+       if (!dev_info) {
+               POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
-               goto Away;
+               goto cleanup;
        }
 
-       INIT_LIST_HEAD(&pDevInfo->entry);
-       pDevInfo->bus_no = busNo;
-       pDevInfo->dev_no = devNo;
-       pDevInfo->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
-       POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo,
+       INIT_LIST_HEAD(&dev_info->entry);
+       dev_info->bus_no = bus_no;
+       dev_info->dev_no = dev_no;
+       dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
+       POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
 
        if (inmsg->hdr.flags.test_message == 1)
-               pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALTEST;
+               dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
        else
-               pDevInfo->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-       pDevInfo->chan_info.channel_addr = cmd->create_device.channel_addr;
-       pDevInfo->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
-       pDevInfo->chan_info.channel_type_uuid =
+               dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
+       dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
+       dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
+       dev_info->chan_info.channel_type_uuid =
                        cmd->create_device.data_type_uuid;
-       pDevInfo->chan_info.intr = cmd->create_device.intr;
-       list_add(&pDevInfo->entry, &DevInfoList);
-       POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo,
+       dev_info->chan_info.intr = cmd->create_device.intr;
+       list_add(&dev_info->entry, &dev_info_list);
+       POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
                         POSTCODE_SEVERITY_INFO);
-Away:
+cleanup:
        /* get the bus and devNo for DiagPool channel */
-       if (pDevInfo &&
-           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,
+       if (dev_info &&
+           is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
+               g_diagpool_bus_no = bus_no;
+               g_diagpool_dev_no = dev_no;
+       }
+       device_epilog(bus_no, dev_no, segment_state_running,
                      CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
                      inmsg->hdr.flags.response_expected == 1,
-                     FOR_VISORBUS(pDevInfo->chan_info.channel_type_uuid));
+                     FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
 }
 
 static void
 my_device_changestate(struct controlvm_message *inmsg)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
-       ulong busNo = cmd->device_change_state.bus_no;
-       ulong devNo = cmd->device_change_state.dev_no;
+       ulong bus_no = cmd->device_change_state.bus_no;
+       ulong dev_no = cmd->device_change_state.dev_no;
        struct spar_segment_state state = cmd->device_change_state.state;
-       struct visorchipset_device_info *pDevInfo = NULL;
+       struct visorchipset_device_info *dev_info = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
-       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,
+       dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+       if (!dev_info) {
+               POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
                                 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,
+       } else if (dev_info->state.created == 0) {
+               POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
                                 POSTCODE_SEVERITY_ERR);
                rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
        }
-Away:
-       if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo)
-               device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE,
-                             &inmsg->hdr, rc,
+       if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
+               device_epilog(bus_no, dev_no, state,
+                             CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
                              inmsg->hdr.flags.response_expected == 1,
                              FOR_VISORBUS(
-                                       pDevInfo->chan_info.channel_type_uuid));
+                                       dev_info->chan_info.channel_type_uuid));
 }
 
 static void
 my_device_destroy(struct controlvm_message *inmsg)
 {
        struct controlvm_message_packet *cmd = &inmsg->cmd;
-       ulong busNo = cmd->destroy_device.bus_no;
-       ulong devNo = cmd->destroy_device.dev_no;
-       struct visorchipset_device_info *pDevInfo = NULL;
+       ulong bus_no = cmd->destroy_device.bus_no;
+       ulong dev_no = cmd->destroy_device.dev_no;
+       struct visorchipset_device_info *dev_info = NULL;
        int rc = CONTROLVM_RESP_SUCCESS;
 
-       pDevInfo = finddevice(&DevInfoList, busNo, devNo);
-       if (!pDevInfo) {
-               LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid",
-                    busNo, devNo);
+       dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+       if (!dev_info)
                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);
+       else if (dev_info->state.created == 0)
                rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
-       }
 
-Away:
-       if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo)
-               device_epilog(busNo, devNo, segment_state_running,
+       if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
+               device_epilog(bus_no, dev_no, segment_state_running,
                              CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
                              inmsg->hdr.flags.response_expected == 1,
                              FOR_VISORBUS(
-                                       pDevInfo->chan_info.channel_type_uuid));
+                                       dev_info->chan_info.channel_type_uuid));
 }
 
 /* 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__);
+       if (!info) {
                rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
-               goto Away;
+               goto cleanup;
        }
-       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;
+               goto cleanup;
        }
        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);
+       if (!payload) {
                rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
-               goto Away;
+               goto cleanup;
        }
 
        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:
+cleanup:
        if (rc < 0) {
-               if (payload != NULL) {
+               if (payload) {
                        iounmap(payload);
                        payload = NULL;
                }
@@ -1427,43 +1305,41 @@ Away:
 }
 
 static void
-destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO *info)
+destroy_controlvm_payload_info(struct controlvm_payload_info *info)
 {
-       if (info->ptr != NULL) {
+       if (info->ptr) {
                iounmap(info->ptr);
                info->ptr = NULL;
        }
-       memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO));
+       memset(info, 0, sizeof(struct controlvm_payload_info));
 }
 
 static void
 initialize_controlvm_payload(void)
 {
-       HOSTADDRESS phys_addr = visorchannel_get_physaddr(ControlVm_channel);
-       u64 payloadOffset = 0;
-       u32 payloadBytes = 0;
+       HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
+       u64 payload_offset = 0;
+       u32 payload_bytes = 0;
 
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       request_payload_offset),
-                             &payloadOffset, sizeof(payloadOffset)) < 0) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
+                             &payload_offset, sizeof(payload_offset)) < 0) {
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       request_payload_bytes),
-                             &payloadBytes, sizeof(payloadBytes)) < 0) {
-               LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!");
+                             &payload_bytes, sizeof(payload_bytes)) < 0) {
                POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
        initialize_controlvm_payload_info(phys_addr,
-                                         payloadOffset, payloadBytes,
-                                         &ControlVm_payload_info);
+                                         payload_offset, payload_bytes,
+                                         &controlvm_payload_info);
 }
 
 /*  Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
@@ -1472,7 +1348,7 @@ initialize_controlvm_payload(void)
 int
 visorchipset_chipset_ready(void)
 {
-       kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
+       kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
        return CONTROLVM_RESP_SUCCESS;
 }
 EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
@@ -1484,7 +1360,7 @@ visorchipset_chipset_selftest(void)
        char *envp[] = { env_selftest, NULL };
 
        sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
-       kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
+       kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
                           envp);
        return CONTROLVM_RESP_SUCCESS;
 }
@@ -1496,49 +1372,48 @@ EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
 int
 visorchipset_chipset_notready(void)
 {
-       kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
+       kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
        return CONTROLVM_RESP_SUCCESS;
 }
 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
 
 static void
-chipset_ready(struct controlvm_message_header *msgHdr)
+chipset_ready(struct controlvm_message_header *msg_hdr)
 {
        int rc = visorchipset_chipset_ready();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->flags.response_expected && !visorchipset_holdchipsetready)
-               controlvm_respond(msgHdr, rc);
-       if (msgHdr->flags.response_expected && visorchipset_holdchipsetready) {
+       if (msg_hdr->flags.response_expected && !visorchipset_holdchipsetready)
+               controlvm_respond(msg_hdr, rc);
+       if (msg_hdr->flags.response_expected && visorchipset_holdchipsetready) {
                /* Send CHIPSET_READY response when all modules have been loaded
                 * and disks mounted for the partition
                 */
-               g_ChipSetMsgHdr = *msgHdr;
-               LOGINF("Holding CHIPSET_READY response");
+               g_chipset_msg_hdr = *msg_hdr;
        }
 }
 
 static void
-chipset_selftest(struct controlvm_message_header *msgHdr)
+chipset_selftest(struct controlvm_message_header *msg_hdr)
 {
        int rc = visorchipset_chipset_selftest();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->flags.response_expected)
-               controlvm_respond(msgHdr, rc);
+       if (msg_hdr->flags.response_expected)
+               controlvm_respond(msg_hdr, rc);
 }
 
 static void
-chipset_notready(struct controlvm_message_header *msgHdr)
+chipset_notready(struct controlvm_message_header *msg_hdr)
 {
        int rc = visorchipset_chipset_notready();
 
        if (rc != CONTROLVM_RESP_SUCCESS)
                rc = -rc;
-       if (msgHdr->flags.response_expected)
-               controlvm_respond(msgHdr, rc);
+       if (msg_hdr->flags.response_expected)
+               controlvm_respond(msg_hdr, rc);
 }
 
 /* This is your "one-stop" shop for grabbing the next message from the
@@ -1547,14 +1422,11 @@ chipset_notready(struct controlvm_message_header *msgHdr)
 static BOOL
 read_controlvm_event(struct controlvm_message *msg)
 {
-       if (visorchannel_signalremove(ControlVm_channel,
+       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,10 +1476,10 @@ 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);
-       if (req == NULL)
+       struct parahotplug_request *req;
+
+       req = kmalloc(sizeof(*req), GFP_KERNEL | __GFP_NORETRY);
+       if (!req)
                return NULL;
 
        req->id = parahotplug_next_id();
@@ -1652,13 +1524,7 @@ 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,
+       kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
                           envp);
 }
 
@@ -1672,23 +1538,25 @@ parahotplug_process_list(void)
        struct list_head *pos = NULL;
        struct list_head *tmp = NULL;
 
-       spin_lock(&Parahotplug_request_list_lock);
+       spin_lock(&parahotplug_request_list_lock);
 
-       list_for_each_safe(pos, tmp, &Parahotplug_request_list) {
+       list_for_each_safe(pos, tmp, &parahotplug_request_list) {
                struct parahotplug_request *req =
                    list_entry(pos, struct parahotplug_request, list);
-               if (time_after_eq(jiffies, req->expiration)) {
-                       list_del(pos);
-                       if (req->msg.hdr.flags.response_expected)
-                               controlvm_respond_physdev_changestate(
-                                       &req->msg.hdr,
-                                       CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
-                                       req->msg.cmd.device_change_state.state);
-                       parahotplug_request_destroy(req);
-               }
+
+               if (!time_after_eq(jiffies, req->expiration))
+                       continue;
+
+               list_del(pos);
+               if (req->msg.hdr.flags.response_expected)
+                       controlvm_respond_physdev_changestate(
+                               &req->msg.hdr,
+                               CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
+                               req->msg.cmd.device_change_state.state);
+               parahotplug_request_destroy(req);
        }
 
-       spin_unlock(&Parahotplug_request_list_lock);
+       spin_unlock(&parahotplug_request_list_lock);
 }
 
 /*
@@ -1702,10 +1570,10 @@ parahotplug_request_complete(int id, u16 active)
        struct list_head *pos = NULL;
        struct list_head *tmp = NULL;
 
-       spin_lock(&Parahotplug_request_list_lock);
+       spin_lock(&parahotplug_request_list_lock);
 
        /* Look for a request matching "id". */
-       list_for_each_safe(pos, tmp, &Parahotplug_request_list) {
+       list_for_each_safe(pos, tmp, &parahotplug_request_list) {
                struct parahotplug_request *req =
                    list_entry(pos, struct parahotplug_request, list);
                if (req->id == id) {
@@ -1713,7 +1581,7 @@ parahotplug_request_complete(int id, u16 active)
                         * respond.
                         */
                        list_del(pos);
-                       spin_unlock(&Parahotplug_request_list_lock);
+                       spin_unlock(&parahotplug_request_list_lock);
                        req->msg.cmd.device_change_state.state.active = active;
                        if (req->msg.hdr.flags.response_expected)
                                controlvm_respond_physdev_changestate(
@@ -1724,7 +1592,7 @@ parahotplug_request_complete(int id, u16 active)
                }
        }
 
-       spin_unlock(&Parahotplug_request_list_lock);
+       spin_unlock(&parahotplug_request_list_lock);
        return -1;
 }
 
@@ -1738,10 +1606,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)
                return;
-       }
 
        if (inmsg->cmd.device_change_state.state.active) {
                /* For enable messages, just respond with success
@@ -1755,8 +1621,8 @@ parahotplug_process_message(struct controlvm_message *inmsg)
                */
                parahotplug_request_kickoff(req);
                controlvm_respond_physdev_changestate(&inmsg->hdr,
-                               CONTROLVM_RESP_SUCCESS, inmsg->cmd.
-                               device_change_state.state);
+                       CONTROLVM_RESP_SUCCESS,
+                       inmsg->cmd.device_change_state.state);
                parahotplug_request_destroy(req);
        } else {
                /* For disable messages, add the request to the
@@ -1764,9 +1630,9 @@ parahotplug_process_message(struct controlvm_message *inmsg)
                * won't get responded to until the script has
                * indicated it's done.
                */
-               spin_lock(&Parahotplug_request_list_lock);
-               list_add_tail(&(req->list), &Parahotplug_request_list);
-               spin_unlock(&Parahotplug_request_list_lock);
+               spin_lock(&parahotplug_request_list_lock);
+               list_add_tail(&req->list, &parahotplug_request_list);
+               spin_unlock(&parahotplug_request_list_lock);
 
                parahotplug_request_kickoff(req);
        }
@@ -1787,135 +1653,94 @@ static BOOL
 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;
-       BOOL isLocalAddr = FALSE;
+       u64 parm_addr = 0;
+       u32 parm_bytes = 0;
+       struct parser_context *parser_ctx = NULL;
+       bool local_addr = 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!");
+       local_addr = (inmsg.hdr.flags.test_message == 1);
+       if (channel_addr == 0)
                return TRUE;
-       }
-       parametersAddr = channel_addr + inmsg.hdr.payload_vm_offset;
-       parametersBytes = inmsg.hdr.payload_bytes;
+       parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
+       parm_bytes = inmsg.hdr.payload_bytes;
 
        /* Parameter and channel addresses within test messages actually lie
         * within our OS-controlled memory.  We need to know that, because it
         * makes a difference in how we compute the virtual address.
         */
-       if (parametersAddr != 0 && parametersBytes != 0) {
+       if (parm_addr != 0 && parm_bytes != 0) {
                BOOL retry = FALSE;
 
                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);
-               }
+                   parser_init_byte_stream(parm_addr, parm_bytes,
+                                           local_addr, &retry);
+               if (!parser_ctx && retry)
+                       return FALSE;
        }
 
-       if (!isLocalAddr) {
+       if (!local_addr) {
                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);
-                       g_DiagMsgHdr = inmsg.hdr;
-                       g_DeviceChangeStatePacket = inmsg.cmd;
+                       g_diag_msg_hdr = inmsg.hdr;
+                       g_devicechangestate_packet = inmsg.cmd;
                        break;
                }
                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);
+                               -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
                break;
        }
 
-       if (parser_ctx != NULL) {
+       if (parser_ctx) {
                parser_done(parser_ctx);
                parser_ctx = NULL;
        }
@@ -1927,12 +1752,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;
 }
 
@@ -1940,69 +1762,63 @@ static void
 controlvm_periodic_work(struct work_struct *work)
 {
        struct controlvm_message inmsg;
-       BOOL gotACommand = FALSE;
+       BOOL got_command = FALSE;
        BOOL handle_command_failed = FALSE;
-       static u64 Poll_Count;
+       static u64 poll_count;
 
        /* make sure visorbus server is registered for controlvm callbacks */
        if (visorchipset_serverregwait && !serverregistered)
-               goto Away;
+               goto cleanup;
        /* make sure visorclientbus server is regsitered for controlvm
         * callbacks
         */
        if (visorchipset_clientregwait && !clientregistered)
-               goto Away;
+               goto cleanup;
 
-       Poll_Count++;
-       if (Poll_Count >= 250)
+       poll_count++;
+       if (poll_count >= 250)
                ;       /* keep going */
        else
-               goto Away;
+               goto cleanup;
 
        /* Check events to determine if response to CHIPSET_READY
         * should be sent
         */
-       if (visorchipset_holdchipsetready
-           && (g_ChipSetMsgHdr.id != CONTROLVM_INVALID)) {
+       if (visorchipset_holdchipsetready &&
+           (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) {
                if (check_chipset_events() == 1) {
-                       LOGINF("Sending CHIPSET_READY response");
-                       controlvm_respond(&g_ChipSetMsgHdr, 0);
+                       controlvm_respond(&g_chipset_msg_hdr, 0);
                        clear_chipset_events();
-                       memset(&g_ChipSetMsgHdr, 0,
+                       memset(&g_chipset_msg_hdr, 0,
                               sizeof(struct controlvm_message_header));
                }
        }
 
-       while (visorchannel_signalremove(ControlVm_channel,
+       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) {
+                                        &inmsg))
+               ;
+       if (!got_command) {
+               if (controlvm_pending_msg_valid) {
                        /* we throttled processing of a prior
                        * msg, so try to process it again
                        * rather than reading a new one
                        */
-                       inmsg = ControlVm_Pending_Msg;
-                       ControlVm_Pending_Msg_Valid = FALSE;
-                       gotACommand = TRUE;
-               } else
-                       gotACommand = read_controlvm_event(&inmsg);
+                       inmsg = controlvm_pending_msg;
+                       controlvm_pending_msg_valid = FALSE;
+                       got_command = true;
+               } else {
+                       got_command = read_controlvm_event(&inmsg);
+               }
        }
 
        handle_command_failed = FALSE;
-       while (gotACommand && (!handle_command_failed)) {
-               Most_recent_message_jiffies = jiffies;
+       while (got_command && (!handle_command_failed)) {
+               most_recent_message_jiffies = jiffies;
                if (handle_command(inmsg,
                                   visorchannel_get_physaddr
-                                  (ControlVm_channel)))
-                       gotACommand = read_controlvm_event(&inmsg);
+                                  (controlvm_channel)))
+                       got_command = read_controlvm_event(&inmsg);
                else {
                        /* this is a scenario where throttling
                        * is required, but probably NOT an
@@ -2011,56 +1827,51 @@ controlvm_periodic_work(struct work_struct *work)
                        * reprocess it on our next loop
                        */
                        handle_command_failed = TRUE;
-                       ControlVm_Pending_Msg = inmsg;
-                       ControlVm_Pending_Msg_Valid = TRUE;
+                       controlvm_pending_msg = inmsg;
+                       controlvm_pending_msg_valid = TRUE;
                }
        }
 
        /* parahotplug_worker */
        parahotplug_process_list();
 
-Away:
+cleanup:
 
        if (time_after(jiffies,
-                      Most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
+                      most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
                /* it's been longer than MIN_IDLE_SECONDS since we
                * 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);
+       queue_delayed_work(periodic_controlvm_workqueue,
+                          &periodic_controlvm_work, poll_jiffies);
 }
 
 static void
 setup_crash_devices_work_queue(struct work_struct *work)
 {
-
-       struct controlvm_message localCrashCreateBusMsg;
-       struct controlvm_message localCrashCreateDevMsg;
+       struct controlvm_message local_crash_bus_msg;
+       struct controlvm_message local_crash_dev_msg;
        struct controlvm_message msg;
-       u32 localSavedCrashMsgOffset;
-       u16 localSavedCrashMsgCount;
+       u32 local_crash_msg_offset;
+       u16 local_crash_msg_count;
 
        /* make sure visorbus server is registered for controlvm callbacks */
        if (visorchipset_serverregwait && !serverregistered)
-               goto Away;
+               goto cleanup;
 
        /* make sure visorclientbus server is regsitered for controlvm
         * callbacks
         */
        if (visorchipset_clientregwait && !clientregistered)
-               goto Away;
+               goto cleanup;
 
        POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
 
@@ -2072,118 +1883,108 @@ setup_crash_devices_work_queue(struct work_struct *work)
        chipset_init(&msg);
 
        /* get saved message count */
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_count),
-                             &localSavedCrashMsgCount, sizeof(u16)) < 0) {
-               LOGERR("failed to get Saved Message Count");
+                             &local_crash_msg_count, sizeof(u16)) < 0) {
                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);
+       if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
                POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
-                                localSavedCrashMsgCount,
+                                local_crash_msg_count,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        /* get saved crash message offset */
-       if (visorchannel_read(ControlVm_channel,
+       if (visorchannel_read(controlvm_channel,
                              offsetof(struct spar_controlvm_channel_protocol,
                                       saved_crash_message_offset),
-                             &localSavedCrashMsgOffset, sizeof(u32)) < 0) {
-               LOGERR("failed to get Saved Message Offset");
+                             &local_crash_msg_offset, sizeof(u32)) < 0) {
                POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        /* read create device message for storage bus offset */
-       if (visorchannel_read(ControlVm_channel,
-                             localSavedCrashMsgOffset,
-                             &localCrashCreateBusMsg,
+       if (visorchannel_read(controlvm_channel,
+                             local_crash_msg_offset,
+                             &local_crash_bus_msg,
                              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;
        }
 
        /* read create device message for storage device */
-       if (visorchannel_read(ControlVm_channel,
-                             localSavedCrashMsgOffset +
+       if (visorchannel_read(controlvm_channel,
+                             local_crash_msg_offset +
                              sizeof(struct controlvm_message),
-                             &localCrashCreateDevMsg,
+                             &local_crash_dev_msg,
                              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;
        }
 
        /* reuse IOVM create bus message */
-       if (localCrashCreateBusMsg.cmd.create_bus.channel_addr != 0)
-               bus_create(&localCrashCreateBusMsg);
-       else {
-               LOGERR("CrashCreateBusMsg is null, no dump will be taken");
+       if (local_crash_bus_msg.cmd.create_bus.channel_addr != 0) {
+               bus_create(&local_crash_bus_msg);
+       } else {
                POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
                                 POSTCODE_SEVERITY_ERR);
                return;
        }
 
        /* reuse create device message for storage device */
-       if (localCrashCreateDevMsg.cmd.create_device.channel_addr != 0)
-               my_device_create(&localCrashCreateDevMsg);
-       else {
-               LOGERR("CrashCreateDevMsg is null, no dump will be taken");
+       if (local_crash_dev_msg.cmd.create_device.channel_addr != 0) {
+               my_device_create(&local_crash_dev_msg);
+       } else {
                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:
+cleanup:
 
-       Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
+       poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
 
-       queue_delayed_work(Periodic_controlvm_workqueue,
-                          &Periodic_controlvm_work, Poll_jiffies);
+       queue_delayed_work(periodic_controlvm_workqueue,
+                          &periodic_controlvm_work, poll_jiffies);
 }
 
 static void
-bus_create_response(ulong busNo, int response)
+bus_create_response(ulong bus_no, int response)
 {
-       bus_responder(CONTROLVM_BUS_CREATE, busNo, response);
+       bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
 }
 
 static void
-bus_destroy_response(ulong busNo, int response)
+bus_destroy_response(ulong bus_no, int response)
 {
-       bus_responder(CONTROLVM_BUS_DESTROY, busNo, response);
+       bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
 }
 
 static void
-device_create_response(ulong busNo, ulong devNo, int response)
+device_create_response(ulong bus_no, ulong dev_no, int response)
 {
-       device_responder(CONTROLVM_DEVICE_CREATE, busNo, devNo, response);
+       device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
 }
 
 static void
-device_destroy_response(ulong busNo, ulong devNo, int response)
+device_destroy_response(ulong bus_no, ulong dev_no, int response)
 {
-       device_responder(CONTROLVM_DEVICE_DESTROY, busNo, devNo, response);
+       device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
 }
 
 void
 visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response)
 {
-
        device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
                                     bus_no, dev_no, response,
                                     segment_state_standby);
@@ -2191,22 +1992,20 @@ visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response)
 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
 
 static void
-device_resume_response(ulong busNo, ulong devNo, int response)
+device_resume_response(ulong bus_no, ulong dev_no, int response)
 {
        device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
-                                    busNo, devNo, response,
+                                    bus_no, dev_no, response,
                                     segment_state_running);
 }
 
 BOOL
 visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info)
 {
-       void *p = findbus(&BusInfoList, bus_no);
+       void *p = findbus(&bus_info_list, bus_no);
 
-       if (!p) {
-               LOGERR("(%lu) failed", bus_no);
+       if (!p)
                return FALSE;
-       }
        memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
        return TRUE;
 }
@@ -2215,12 +2014,10 @@ EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
 BOOL
 visorchipset_set_bus_context(ulong bus_no, void *context)
 {
-       struct visorchipset_bus_info *p = findbus(&BusInfoList, bus_no);
+       struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no);
 
-       if (!p) {
-               LOGERR("(%lu) failed", bus_no);
+       if (!p)
                return FALSE;
-       }
        p->bus_driver_context = context;
        return TRUE;
 }
@@ -2230,12 +2027,10 @@ BOOL
 visorchipset_get_device_info(ulong bus_no, ulong dev_no,
                             struct visorchipset_device_info *dev_info)
 {
-       void *p = finddevice(&DevInfoList, bus_no, dev_no);
+       void *p = finddevice(&dev_info_list, 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;
 }
@@ -2245,12 +2040,10 @@ BOOL
 visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context)
 {
        struct visorchipset_device_info *p =
-                       finddevice(&DevInfoList, bus_no, dev_no);
+                       finddevice(&dev_info_list, 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,11 +2071,10 @@ 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);
+
+       atomic_inc(&visorchipset_cache_buffers_in_use);
        return p;
 }
 
@@ -2291,16 +2083,16 @@ 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);
+
+       atomic_dec(&visorchipset_cache_buffers_in_use);
        kmem_cache_free(pool, p);
 }
 
 static ssize_t chipsetready_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count)
+                                 struct device_attribute *attr,
+                                 const char *buf, size_t count)
 {
        char msgtype[64];
 
@@ -2322,7 +2114,8 @@ static ssize_t chipsetready_store(struct device *dev,
  * and then passed back when the device has been removed.
  */
 static ssize_t devicedisabled_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count)
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t count)
 {
        uint id;
 
@@ -2338,7 +2131,8 @@ static ssize_t devicedisabled_store(struct device *dev,
  * and then passed back when the device has been brought back up.
  */
 static ssize_t deviceenabled_store(struct device *dev,
-       struct device_attribute *attr, const char *buf, size_t count)
+                                  struct device_attribute *attr,
+                                  const char *buf, size_t count)
 {
        uint id;
 
@@ -2353,133 +2147,102 @@ 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));
-       memset(&LiveDump_info, 0, sizeof(LiveDump_info));
-       atomic_set(&LiveDump_info.buffers_in_use, 0);
+       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));
+       memset(&livedump_info, 0, sizeof(livedump_info));
+       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;
+               goto cleanup;
        }
 
        addr = controlvm_get_channel_address();
        if (addr != 0) {
-               ControlVm_channel =
+               controlvm_channel =
                    visorchannel_create_with_lock
                    (addr,
                     sizeof(struct spar_controlvm_channel_protocol),
                     spar_controlvm_channel_protocol_uuid);
                if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
-                               visorchannel_get_header(ControlVm_channel))) {
-                       LOGINF("Channel %s (ControlVm) discovered",
-                              visorchannel_id(ControlVm_channel, s));
+                               visorchannel_get_header(controlvm_channel))) {
                        initialize_controlvm_payload();
                } else {
-                       LOGERR("controlvm channel is invalid");
-                       visorchannel_destroy(ControlVm_channel);
-                       ControlVm_channel = NULL;
+                       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);
+       major_dev = MKDEV(visorchipset_major, 0);
+       rc = visorchipset_file_init(major_dev, &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;
+               goto cleanup;
        }
 
-       memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       Putfile_buffer_list_pool =
-           kmem_cache_create(Putfile_buffer_list_pool_name,
+       putfile_buffer_list_pool =
+           kmem_cache_create(putfile_buffer_list_pool_name,
                              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");
+       if (!putfile_buffer_list_pool) {
                POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
                rc = -1;
-               goto Away;
+               goto cleanup;
        }
-       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,
+                       INIT_DELAYED_WORK(&periodic_controlvm_work,
                                          setup_crash_devices_work_queue);
                else
-                       INIT_DELAYED_WORK(&Periodic_controlvm_work,
+                       INIT_DELAYED_WORK(&periodic_controlvm_work,
                                          controlvm_periodic_work);
-               Periodic_controlvm_workqueue =
+               periodic_controlvm_workqueue =
                    create_singlethread_workqueue("visorchipset_controlvm");
 
-               if (Periodic_controlvm_workqueue == NULL) {
-                       ERRDRV("cannot create controlvm workqueue: (status=%d)\n",
-                              -ENOMEM);
+               if (!periodic_controlvm_workqueue) {
                        POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
                                         DIAG_SEVERITY_ERR);
                        rc = -ENOMEM;
-                       goto Away;
+                       goto cleanup;
                }
-               Most_recent_message_jiffies = jiffies;
-               Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-               rc = queue_delayed_work(Periodic_controlvm_workqueue,
-                                       &Periodic_controlvm_work, Poll_jiffies);
+               most_recent_message_jiffies = jiffies;
+               poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+               rc = queue_delayed_work(periodic_controlvm_workqueue,
+                                       &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;
+                       goto cleanup;
                }
-
        }
 
-       Visorchipset_platform_device.dev.devt = MajorDev;
-       if (platform_device_register(&Visorchipset_platform_device) < 0) {
-               ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n");
+       visorchipset_platform_device.dev.devt = major_dev;
+       if (platform_device_register(&visorchipset_platform_device) < 0) {
                POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
                rc = -1;
-               goto Away;
+               goto cleanup;
        }
-       LOGINF("visorchipset device created");
        POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
        rc = 0;
-Away:
+cleanup:
        if (rc) {
-               LOGERR("visorchipset_init failed");
                POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
                                 POSTCODE_SEVERITY_ERR);
        }
@@ -2489,40 +2252,34 @@ Away:
 static void
 visorchipset_exit(void)
 {
-       char s[99];
-
        POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 
        if (visorchipset_disable_controlvm) {
                ;
        } else {
-               cancel_delayed_work(&Periodic_controlvm_work);
-               flush_workqueue(Periodic_controlvm_workqueue);
-               destroy_workqueue(Periodic_controlvm_workqueue);
-               Periodic_controlvm_workqueue = NULL;
-               destroy_controlvm_payload_info(&ControlVm_payload_info);
+               cancel_delayed_work(&periodic_controlvm_work);
+               flush_workqueue(periodic_controlvm_workqueue);
+               destroy_workqueue(periodic_controlvm_workqueue);
+               periodic_controlvm_workqueue = NULL;
+               destroy_controlvm_payload_info(&controlvm_payload_info);
        }
-       Test_Vnic_channel = NULL;
-       if (Putfile_buffer_list_pool) {
-               kmem_cache_destroy(Putfile_buffer_list_pool);
-               Putfile_buffer_list_pool = NULL;
+       if (putfile_buffer_list_pool) {
+               kmem_cache_destroy(putfile_buffer_list_pool);
+               putfile_buffer_list_pool = NULL;
        }
 
        cleanup_controlvm_structures();
 
-       memset(&g_DiagMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_ChipSetMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       memset(&g_DelDumpMsgHdr, 0, sizeof(struct controlvm_message_header));
+       memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
 
-       LOGINF("Channel %s (ControlVm) disconnected",
-              visorchannel_id(ControlVm_channel, s));
-       visorchannel_destroy(ControlVm_channel);
+       visorchannel_destroy(controlvm_channel);
 
-       visorchipset_file_cleanup();
+       visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
        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 d871bbb78cef420118a7ca5fece80e43bb00f008..d9ab5a36e3bf0b026274540d2f23f6617e0b471c 100644 (file)
@@ -4,7 +4,6 @@
 
 obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o
 
-visorutil-y := charqueue.o  easyproc.o  periodic_work.o  procobjecttree.o  \
-               memregion_direct.o visorkmodutils.o
+visorutil-y := charqueue.o  periodic_work.o  memregion_direct.o visorkmodutils.o
 
 ccflags-y += -Idrivers/staging/unisys/include
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.
diff --git a/drivers/staging/unisys/visorutil/easyproc.c b/drivers/staging/unisys/visorutil/easyproc.c
deleted file mode 100644 (file)
index 40f1ae9..0000000
+++ /dev/null
@@ -1,377 +0,0 @@
-/* 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.
- */
-
-/** @file *********************************************************************
- *
- *  Handle procfs-specific tasks.
- *  Note that this file does not know about any module-specific things, nor
- *  does it know anything about what information to reveal as part of the proc
- *  entries.  The 2 functions that take care of displaying device and
- *  driver specific information are passed as parameters to
- *  visor_easyproc_InitDriver().
- *
- *      void show_device_info(struct seq_file *seq, void *p);
- *      void show_driver_info(struct seq_file *seq);
- *
- *  The second parameter to show_device_info is actually a pointer to the
- *  device-specific info to show.  It is the context that was originally
- *  passed to visor_easyproc_InitDevice().
- *
- ******************************************************************************
- */
-
-#include <linux/proc_fs.h>
-
-#include "uniklog.h"
-#include "timskmod.h"
-#include "easyproc.h"
-
-#define MYDRVNAME "easyproc"
-
-
-
-/*
- *   /proc/<ProcId>                              ProcDir
- *   /proc/<ProcId>/driver                       ProcDriverDir
- *   /proc/<ProcId>/driver/diag                  ProcDriverDiagFile
- *   /proc/<ProcId>/device                       ProcDeviceDir
- *   /proc/<ProcId>/device/0                     procDevicexDir
- *   /proc/<ProcId>/device/0/diag                procDevicexDiagFile
- */
-
-
-static ssize_t proc_write_device(struct file *file, const char __user *buffer,
-                                size_t count, loff_t *ppos);
-static ssize_t proc_write_driver(struct file *file, const char __user *buffer,
-                                size_t count, loff_t *ppos);
-
-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;
-}
-
-static int seq_show_driver(struct seq_file *seq, void *offset);
-static int proc_open_driver(struct inode *inode, struct file *file)
-{
-       return single_open(file, seq_show_driver, PDE_DATA(inode));
-}
-static const struct file_operations proc_fops_driver = {
-       .open = proc_open_driver,
-       .read = seq_read,
-       .write = proc_write_driver,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
-static int seq_show_device(struct seq_file *seq, void *offset);
-static int seq_show_device_property(struct seq_file *seq, void *offset);
-static int proc_open_device(struct inode *inode, struct file *file)
-{
-       return single_open(file, seq_show_device, PDE_DATA(inode));
-}
-static const struct file_operations proc_fops_device = {
-       .open = proc_open_device,
-       .read = seq_read,
-       .write = proc_write_device,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-static int proc_open_device_property(struct inode *inode, struct file *file)
-{
-       return single_open(file, seq_show_device_property, PDE_DATA(inode));
-}
-static const struct file_operations proc_fops_device_property = {
-       .open = proc_open_device_property,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
-
-
-void visor_easyproc_InitDriver(struct easyproc_driver_info *pdriver,
-                              char *procId,
-                              void (*show_driver_info)(struct seq_file *),
-                              void (*show_device_info)(struct seq_file *,
-                                                       void *))
-{
-       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)
-               pdriver->ProcDir = createProcDir(pdriver->ProcId, NULL);
-       if ((pdriver->ProcDir != NULL) && (pdriver->ProcDriverDir == NULL))
-               pdriver->ProcDriverDir = createProcDir("driver",
-                                                      pdriver->ProcDir);
-       if ((pdriver->ProcDir != NULL) && (pdriver->ProcDeviceDir == NULL))
-               pdriver->ProcDeviceDir = createProcDir("device",
-                                                      pdriver->ProcDir);
-       if ((pdriver->ProcDriverDir != NULL) &&
-           (pdriver->ProcDriverDiagFile == NULL)) {
-               pdriver->ProcDriverDiagFile =
-                       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);
-
-
-
-void visor_easyproc_InitDriverEx(struct easyproc_driver_info *pdriver,
-                                char *procId,
-                                void (*show_driver_info)(struct seq_file *),
-                                void (*show_device_info)(struct seq_file *,
-                                                         void *),
-                                void (*write_driver_info)(char *buf,
-                                                          size_t count,
-                                                          loff_t *ppos),
-                                void (*write_device_info)(char *buf,
-                                                          size_t count,
-                                                          loff_t *ppos,
-                                                          void *p))
-{
-       visor_easyproc_InitDriver(pdriver, procId,
-                                 show_driver_info, show_device_info);
-       pdriver->Write_driver_info = write_driver_info;
-       pdriver->Write_device_info = write_device_info;
-}
-EXPORT_SYMBOL_GPL(visor_easyproc_InitDriverEx);
-
-
-
-void visor_easyproc_DeInitDriver(struct easyproc_driver_info *pdriver)
-{
-       if (pdriver->ProcDriverDiagFile != NULL) {
-               remove_proc_entry("diag", pdriver->ProcDriverDir);
-               pdriver->ProcDriverDiagFile = NULL;
-       }
-       if (pdriver->ProcDriverDir != NULL) {
-               remove_proc_entry("driver", pdriver->ProcDir);
-               pdriver->ProcDriverDir = NULL;
-       }
-       if (pdriver->ProcDeviceDir != NULL) {
-               remove_proc_entry("device", pdriver->ProcDir);
-               pdriver->ProcDeviceDir = NULL;
-       }
-       if (pdriver->ProcDir != NULL) {
-               remove_proc_entry(pdriver->ProcId, NULL);
-               pdriver->ProcDir = NULL;
-       }
-       pdriver->ProcId = NULL;
-       pdriver->Show_driver_info = NULL;
-       pdriver->Show_device_info = NULL;
-       pdriver->Write_driver_info = NULL;
-       pdriver->Write_device_info = NULL;
-}
-EXPORT_SYMBOL_GPL(visor_easyproc_DeInitDriver);
-
-
-
-void visor_easyproc_InitDevice(struct easyproc_driver_info *pdriver,
-                              struct easyproc_device_info *p, int devno,
-                              void *devdata)
-{
-       if ((pdriver->ProcDeviceDir != NULL) && (p->procDevicexDir == NULL)) {
-               char s[29];
-
-               sprintf(s, "%d", devno);
-               p->procDevicexDir = createProcDir(s, pdriver->ProcDeviceDir);
-               p->devno = devno;
-       }
-       p->devdata = devdata;
-       p->pdriver = pdriver;
-       p->devno = devno;
-       if ((p->procDevicexDir != NULL) && (p->procDevicexDiagFile == NULL)) {
-               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));
-}
-EXPORT_SYMBOL_GPL(visor_easyproc_InitDevice);
-
-
-
-void visor_easyproc_CreateDeviceProperty(struct easyproc_device_info *p,
-                                        void (*show_property_info)
-                                        (struct seq_file *, void *),
-                                        char *property_name)
-{
-       size_t i;
-       struct easyproc_device_property_info *px = NULL;
-
-       if (p->procDevicexDir == NULL) {
-               ERRDRV("state error");
-               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");
-               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;
-}
-EXPORT_SYMBOL_GPL(visor_easyproc_CreateDeviceProperty);
-
-
-
-void visor_easyproc_DeInitDevice(struct easyproc_driver_info *pdriver,
-                                struct easyproc_device_info *p, int devno)
-{
-       size_t i;
-
-       for (i = 0; i < ARRAY_SIZE(p->device_property_info); i++) {
-               if (p->device_property_info[i].procEntry != NULL) {
-                       struct easyproc_device_property_info *px =
-                               &(p->device_property_info[i]);
-                       remove_proc_entry(px->property_name, p->procDevicexDir);
-                       px->procEntry = NULL;
-               }
-       }
-       if (p->procDevicexDiagFile != NULL) {
-               remove_proc_entry("diag", p->procDevicexDir);
-               p->procDevicexDiagFile = NULL;
-       }
-       if (p->procDevicexDir != NULL) {
-               char s[29];
-
-               sprintf(s, "%d", devno);
-               remove_proc_entry(s, pdriver->ProcDeviceDir);
-               p->procDevicexDir = NULL;
-       }
-       p->devdata = NULL;
-       p->pdriver = NULL;
-}
-EXPORT_SYMBOL_GPL(visor_easyproc_DeInitDevice);
-
-
-
-static int seq_show_driver(struct seq_file *seq, void *offset)
-{
-       struct easyproc_driver_info *p =
-               (struct easyproc_driver_info *)(seq->private);
-       if (!p)
-               return 0;
-       (*(p->Show_driver_info))(seq);
-       return 0;
-}
-
-
-
-static int seq_show_device(struct seq_file *seq, void *offset)
-{
-       struct easyproc_device_info *p =
-               (struct easyproc_device_info *)(seq->private);
-       if ((!p) || (!(p->pdriver)))
-               return 0;
-       (*(p->pdriver->Show_device_info))(seq, p->devdata);
-       return 0;
-}
-
-
-
-static int seq_show_device_property(struct seq_file *seq, void *offset)
-{
-       struct easyproc_device_property_info *p =
-               (struct easyproc_device_property_info *)(seq->private);
-       if ((!p) || (!(p->show_device_property_info)))
-               return 0;
-       (*(p->show_device_property_info))(seq, p->devdata);
-       return 0;
-}
-
-
-
-static ssize_t proc_write_driver(struct file *file, const char __user *buffer,
-                                size_t count, loff_t *ppos)
-{
-       struct seq_file *seq = (struct seq_file *)file->private_data;
-       struct easyproc_driver_info *p = NULL;
-       char local_buf[256];
-
-       if (seq == NULL)
-               return 0;
-       p = (struct easyproc_driver_info *)(seq->private);
-       if ((!p) || (!(p->Write_driver_info)))
-               return 0;
-       if (count >= sizeof(local_buf))
-               return -ENOMEM;
-       if (copy_from_user(local_buf, buffer, count))
-               return -EFAULT;
-       local_buf[count] = '\0';  /* be friendly */
-       (*(p->Write_driver_info))(local_buf, count, ppos);
-       return count;
-}
-
-
-
-static ssize_t proc_write_device(struct file *file, const char __user *buffer,
-                                size_t count, loff_t *ppos)
-{
-       struct seq_file *seq = (struct seq_file *)file->private_data;
-       struct easyproc_device_info *p = NULL;
-       char local_buf[256];
-
-       if (seq == NULL)
-               return 0;
-       p = (struct easyproc_device_info *)(seq->private);
-       if ((!p) || (!(p->pdriver)) || (!(p->pdriver->Write_device_info)))
-               return 0;
-       if (count >= sizeof(local_buf))
-               return -ENOMEM;
-       if (copy_from_user(local_buf, buffer, count))
-               return -EFAULT;
-       local_buf[count] = '\0';  /* be friendly */
-       (*(p->pdriver->Write_device_info))(local_buf, count, ppos, p->devdata);
-       return count;
-}
diff --git a/drivers/staging/unisys/visorutil/easyproc.h b/drivers/staging/unisys/visorutil/easyproc.h
deleted file mode 100644 (file)
index 6ce7d5e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* easyproc.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.
- */
-
-/** @file *********************************************************************
- *
- *  This describes the interfaces necessary for a simple /proc file
- *  implementation for a driver.
- *
- ******************************************************************************
- */
-
-#ifndef __EASYPROC_H__
-#define __EASYPROC_H__
-
-#include "timskmod.h"
-
-
-struct easyproc_driver_info {
-       struct proc_dir_entry *ProcDir;
-       struct proc_dir_entry *ProcDriverDir;
-       struct proc_dir_entry *ProcDriverDiagFile;
-       struct proc_dir_entry *ProcDeviceDir;
-       char *ProcId;
-       void (*Show_device_info)(struct seq_file *seq, void *p);
-       void (*Show_driver_info)(struct seq_file *seq);
-       void (*Write_device_info)(char *buf, size_t count,
-                                 loff_t *ppos, void *p);
-       void (*Write_driver_info)(char *buf, size_t count, loff_t *ppos);
-};
-
-/* property is a file under /proc/<x>/device/<x>/<property_name> */
-struct easyproc_device_property_info {
-       char property_name[25];
-       struct proc_dir_entry *procEntry;
-       struct easyproc_driver_info *pdriver;
-       void *devdata;
-       void (*show_device_property_info)(struct seq_file *seq, void *p);
-};
-
-struct easyproc_device_info {
-       struct proc_dir_entry *procDevicexDir;
-       struct proc_dir_entry *procDevicexDiagFile;
-       struct easyproc_driver_info *pdriver;
-       void *devdata;
-       int devno;
-       /*  allow for a number of custom properties for each device: */
-       struct easyproc_device_property_info device_property_info[10];
-};
-
-void visor_easyproc_InitDevice(struct easyproc_driver_info *pdriver,
-                              struct easyproc_device_info *p, int devno,
-                              void *devdata);
-void visor_easyproc_DeInitDevice(struct easyproc_driver_info *pdriver,
-                                struct easyproc_device_info *p, int devno);
-void visor_easyproc_InitDriver(struct easyproc_driver_info *pdriver,
-                              char *procId,
-                              void (*show_driver_info)(struct seq_file *),
-                              void (*show_device_info)(struct seq_file *,
-                                                       void *));
-void visor_easyproc_InitDriverEx(struct easyproc_driver_info *pdriver,
-                                char *procId,
-                                void (*show_driver_info)(struct seq_file *),
-                                void (*show_device_info)(struct seq_file *,
-                                                         void *),
-                                void (*Write_driver_info)(char *buf,
-                                                          size_t count,
-                                                          loff_t *ppos),
-                                void (*Write_device_info)(char *buf,
-                                                          size_t count,
-                                                          loff_t *ppos,
-                                                          void *p));
-void visor_easyproc_DeInitDriver(struct easyproc_driver_info *pdriver);
-void visor_easyproc_CreateDeviceProperty(struct easyproc_device_info *p,
-                                        void (*show_property_info)
-                                        (struct seq_file *, void *),
-                                        char *property_name);
-
-#endif
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 {
diff --git a/drivers/staging/unisys/visorutil/procobjecttree.c b/drivers/staging/unisys/visorutil/procobjecttree.c
deleted file mode 100644 (file)
index 82279ca..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/* procobjecttree.c
- *
- * 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.
- */
-
-#include "procobjecttree.h"
-
-#define MYDRVNAME "procobjecttree"
-
-
-
-/** This is context info that we stash in each /proc file entry, which we
- *  need in order to call the callback function that supplies the /proc read
- *  info for that file.
- */
-struct proc_dir_entry_context {
-       void (*show_property)(struct seq_file *, void *, int);
-       MYPROCOBJECT *procObject;
-       int propertyIndex;
-
-};
-
-/** This describes the attributes of a tree rooted at
- *  <procDirRoot>/<name[0]>/<name[1]>/...
- *  Properties for each object of this type will be located under
- *  <procDirRoot>/<name[0]>/<name[1]>/.../<objectName>/<propertyName>.
- */
-struct MYPROCTYPE_Tag {
-       const char **name;  /**< node names for this type, ending with NULL */
-       int nNames;         /**< num of node names in <name> */
-
-       /** root dir for this type tree in /proc */
-       struct proc_dir_entry *procDirRoot;
-
-       struct proc_dir_entry **procDirs;  /**< for each node in <name> */
-
-       /** bottom dir where objects will be rooted; i.e., this is
-        *  <procDirRoot>/<name[0]>/<name[1]>/.../, which is the same as the
-        *  last entry in the <procDirs> array. */
-       struct proc_dir_entry *procDir;
-
-       /** name for each property that objects of this type can have */
-       const char **propertyNames;
-
-       int nProperties;       /**< num of names in <propertyNames> */
-
-       /** Call this, passing MYPROCOBJECT.context and the property index
-        *  whenever someone reads the proc entry */
-       void (*show_property)(struct seq_file *, void *, int);
-};
-
-
-
-struct MYPROCOBJECT_Tag {
-       MYPROCTYPE *type;
-
-       /** This is the name of the dir node in /proc under which the
-        *  properties of this object will appear as files. */
-       char *name;
-
-       int namesize;   /**< number of bytes allocated for name */
-       void *context;  /**< passed to MYPROCTYPE.show_property */
-
-       /** <type.procDirRoot>/<type.name[0]>/<type.name[1]>/.../<name> */
-       struct proc_dir_entry *procDir;
-
-       /** a proc dir entry for each of the properties of the object;
-        *  properties are identified in MYPROCTYPE.propertyNames, so each of
-        *  the <procDirProperties> describes a single file like
-        *  <type.procDirRoot>/<type.name[0]>/<type.name[1]>/...
-        *           /<name>/<propertyName>
-        */
-       struct proc_dir_entry **procDirProperties;
-
-       /** this is a holding area for the context information that is needed
-        *  to run the /proc callback function */
-       struct proc_dir_entry_context *procDirPropertyContexts;
-};
-
-
-
-static struct proc_dir_entry *
-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;
-}
-
-static struct proc_dir_entry *
-createProcFile(const char *name, struct proc_dir_entry *parent,
-              const struct file_operations *fops, void *data)
-{
-       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;
-}
-
-static int seq_show(struct seq_file *seq, void *offset);
-static int proc_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, seq_show, PDE_DATA(inode));
-}
-
-static const struct file_operations proc_fops = {
-       .open = proc_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
-
-
-MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
-                                 const char **name,
-                                 const char **propertyNames,
-                                 void (*show_property)(struct seq_file *,
-                                                       void *, int))
-{
-       int i = 0;
-       MYPROCTYPE *rc = NULL, *type = NULL;
-       struct proc_dir_entry *parent = NULL;
-
-       if (procDirRoot == NULL) {
-               ERRDRV("procDirRoot cannot be NULL!\n");
-               goto Away;
-       }
-       if (name == NULL || name[0] == NULL) {
-               ERRDRV("name must contain at least 1 node name!\n");
-               goto Away;
-       }
-       type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY);
-       if (type == NULL) {
-               ERRDRV("out of memory\n");
-               goto Away;
-       }
-       type->name = name;
-       type->propertyNames = propertyNames;
-       type->nProperties = 0;
-       type->nNames = 0;
-       type->show_property = show_property;
-       type->procDirRoot = procDirRoot;
-       if (type->propertyNames != NULL)
-               while (type->propertyNames[type->nProperties] != NULL)
-                       type->nProperties++;
-       while (type->name[type->nNames] != NULL)
-               type->nNames++;
-       type->procDirs = kzalloc((type->nNames + 1) *
-                                sizeof(struct proc_dir_entry *),
-                                GFP_KERNEL | __GFP_NORETRY);
-       if (type->procDirs == NULL) {
-               ERRDRV("out of memory\n");
-               goto Away;
-       }
-       parent = procDirRoot;
-       for (i = 0; i < type->nNames; i++) {
-               type->procDirs[i] = createProcDir(type->name[i], parent);
-               if (type->procDirs[i] == NULL) {
-                       rc = NULL;
-                       goto Away;
-               }
-               parent = type->procDirs[i];
-       }
-       type->procDir = type->procDirs[type->nNames-1];
-       rc = type;
-Away:
-       if (rc == NULL) {
-               if (type != NULL) {
-                       visor_proc_DestroyType(type);
-                       type = NULL;
-               }
-       }
-       return rc;
-}
-EXPORT_SYMBOL_GPL(visor_proc_CreateType);
-
-
-
-void visor_proc_DestroyType(MYPROCTYPE *type)
-{
-       if (type == NULL)
-               return;
-       if (type->procDirs != NULL) {
-               int i = type->nNames-1;
-
-               while (i >= 0) {
-                       if (type->procDirs[i] != NULL) {
-                               struct proc_dir_entry *parent = NULL;
-
-                               if (i == 0)
-                                       parent = type->procDirRoot;
-                               else
-                                       parent = type->procDirs[i-1];
-                               remove_proc_entry(type->name[i], parent);
-                       }
-                       i--;
-               }
-               kfree(type->procDirs);
-               type->procDirs = NULL;
-       }
-       kfree(type);
-}
-EXPORT_SYMBOL_GPL(visor_proc_DestroyType);
-
-
-
-MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
-                                     const char *name, void *context)
-{
-       MYPROCOBJECT *obj = NULL, *rc = NULL;
-       int i = 0;
-
-       if (type == NULL) {
-               ERRDRV("type cannot be NULL\n");
-               goto Away;
-       }
-       obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
-       if (obj == NULL) {
-               ERRDRV("out of memory\n");
-               goto Away;
-       }
-       obj->type = type;
-       obj->context = context;
-       if (name == NULL) {
-               obj->name = NULL;
-               obj->procDir = type->procDir;
-       } else {
-               obj->namesize = strlen(name)+1;
-               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);
-               obj->procDir = createProcDir(obj->name, type->procDir);
-               if (obj->procDir == NULL)
-                       goto Away;
-       }
-       obj->procDirPropertyContexts =
-               kzalloc((type->nProperties + 1) *
-                       sizeof(struct proc_dir_entry_context),
-                       GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirPropertyContexts == NULL) {
-               ERRDRV("out of memory\n");
-               goto Away;
-       }
-       obj->procDirProperties = kzalloc((type->nProperties + 1) *
-                                        sizeof(struct proc_dir_entry *),
-                                        GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirProperties == NULL) {
-               ERRDRV("out of memory\n");
-               goto Away;
-       }
-       for (i = 0; i < type->nProperties; i++) {
-               obj->procDirPropertyContexts[i].procObject = obj;
-               obj->procDirPropertyContexts[i].propertyIndex = i;
-               obj->procDirPropertyContexts[i].show_property =
-                       type->show_property;
-               if (type->propertyNames[i][0] != '\0') {
-                       /* only create properties that have names */
-                       obj->procDirProperties[i] =
-                               createProcFile(type->propertyNames[i],
-                                       obj->procDir, &proc_fops,
-                                       &obj->procDirPropertyContexts[i]);
-                       if (obj->procDirProperties[i] == NULL) {
-                               rc = NULL;
-                               goto Away;
-                       }
-               }
-       }
-       rc = obj;
-Away:
-       if (rc == NULL) {
-               if (obj != NULL) {
-                       visor_proc_DestroyObject(obj);
-                       obj = NULL;
-               }
-       }
-       return rc;
-}
-EXPORT_SYMBOL_GPL(visor_proc_CreateObject);
-
-
-
-void visor_proc_DestroyObject(MYPROCOBJECT *obj)
-{
-       MYPROCTYPE *type = NULL;
-
-       if (obj == NULL)
-               return;
-       type = obj->type;
-       if (type == NULL)
-               return;
-       if (obj->procDirProperties != NULL) {
-               int i = 0;
-
-               for (i = 0; i < type->nProperties; i++) {
-                       if (obj->procDirProperties[i] != NULL) {
-                               remove_proc_entry(type->propertyNames[i],
-                                                 obj->procDir);
-                               obj->procDirProperties[i] = NULL;
-                       }
-               }
-               kfree(obj->procDirProperties);
-               obj->procDirProperties = NULL;
-       }
-
-       kfree(obj->procDirPropertyContexts);
-       obj->procDirPropertyContexts = NULL;
-
-       if (obj->procDir != NULL) {
-               if (obj->name != NULL)
-                       remove_proc_entry(obj->name, type->procDir);
-               obj->procDir = NULL;
-       }
-
-       kfree(obj->name);
-       obj->name = NULL;
-       kfree(obj);
-}
-EXPORT_SYMBOL_GPL(visor_proc_DestroyObject);
-
-
-
-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...");
-               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..74687761bd2ee0e6af91c89492875e07cebebc9c 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
@@ -116,7 +116,7 @@ void
 s_vGenerateTxParameter(
        struct vnt_private *pDevice,
        unsigned char byPktType,
-       void *pTxBufHead,
+       struct vnt_tx_fifo_head *,
        void *pvRrvTime,
        void *pvRTS,
        void *pvCTS,
@@ -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,14 +937,14 @@ s_vFillCTSHead(
  *
  * Return Value: none
  *
- -*/
-// unsigned int cbFrameSize,//Hdr+Payload+FCS
+ -
+ * unsigned int cbFrameSize, Hdr+Payload+FCS */
 static
 void
 s_vGenerateTxParameter(
        struct vnt_private *pDevice,
        unsigned char byPktType,
-       void *pTxBufHead,
+       struct vnt_tx_fifo_head *tx_buffer_head,
        void *pvRrvTime,
        void *pvRTS,
        void *pvCTS,
@@ -955,29 +955,26 @@ s_vGenerateTxParameter(
        unsigned short wCurrentRate
 )
 {
-       unsigned short wFifoCtl;
+       u16 fifo_ctl = le16_to_cpu(tx_buffer_head->fifo_ctl);
        bool bDisCRC = false;
        unsigned char byFBOption = AUTO_FB_NONE;
 
-       PSTxBufHead pFifoHead = (PSTxBufHead)pTxBufHead;
-
-       pFifoHead->wReserved = wCurrentRate;
-       wFifoCtl = pFifoHead->wFIFOCtl;
+       tx_buffer_head->current_rate = cpu_to_le16(wCurrentRate);
 
-       if (wFifoCtl & FIFOCTL_CRCDIS)
+       if (fifo_ctl & FIFOCTL_CRCDIS)
                bDisCRC = true;
 
-       if (wFifoCtl & FIFOCTL_AUTO_FB_0)
+       if (fifo_ctl & FIFOCTL_AUTO_FB_0)
                byFBOption = AUTO_FB_0;
-       else if (wFifoCtl & FIFOCTL_AUTO_FB_1)
+       else if (fifo_ctl & FIFOCTL_AUTO_FB_1)
                byFBOption = AUTO_FB_1;
 
        if (!pvRrvTime)
                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 +984,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 +1055,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 +1073,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 +1103,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 +1114,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 +1124,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 +1134,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 +1147,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 +1157,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 +1167,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 +1176,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;
@@ -1308,10 +1305,18 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx,
                            priv->hw->conf.chandef.chan->hw_value);
        }
 
-       if (current_rate > RATE_11M)
-               pkt_type = (u8)priv->byPacketType;
-       else
+       if (current_rate > RATE_11M) {
+               if (info->band == IEEE80211_BAND_5GHZ) {
+                       pkt_type = PK_TYPE_11A;
+               } else {
+                       if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
+                               pkt_type = PK_TYPE_11GB;
+                       else
+                               pkt_type = PK_TYPE_11GA;
+               }
+       } else {
                pkt_type = PK_TYPE_11B;
+       }
 
        /*Set fifo controls */
        if (pkt_type == PK_TYPE_11A)
@@ -1505,8 +1510,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 +1518,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..8dfe4381ddf76fa3a3aa9ddfb6d0cf8a878681cb 100644 (file)
@@ -1204,19 +1204,19 @@ typedef struct hfa484x_metacmd {
 #define WLAN_ACCESS_DENY       3   /* Do not authenticate "denied" stations. */
 
 /* XXX These are going away ASAP */
-typedef struct prism2sta_authlist {
+struct prism2sta_authlist {
        unsigned int cnt;
        u8 addr[WLAN_AUTH_MAX][ETH_ALEN];
        u8 assoc[WLAN_AUTH_MAX];
-} prism2sta_authlist_t;
+};
 
-typedef struct prism2sta_accesslist {
+struct prism2sta_accesslist {
        unsigned int modify;
        unsigned int cnt;
        u8 addr[WLAN_ACCESS_MAX][ETH_ALEN];
        unsigned int cnt1;
        u8 addr1[WLAN_ACCESS_MAX][ETH_ALEN];
-} prism2sta_accesslist_t;
+};
 
 typedef struct hfa384x {
        /* USB support data */
@@ -1348,10 +1348,10 @@ typedef struct hfa384x {
 
        hfa384x_InfFrame_t *scanresults;
 
-       prism2sta_authlist_t authlist;  /* Authenticated station list. */
-       unsigned int accessmode;        /* Access mode. */
-       prism2sta_accesslist_t allow;   /* Allowed station list. */
-       prism2sta_accesslist_t deny;    /* Denied station list. */
+       struct prism2sta_authlist authlist;     /* Authenticated station list. */
+       unsigned int accessmode;                /* Access mode. */
+       struct prism2sta_accesslist allow;      /* Allowed station list. */
+       struct prism2sta_accesslist deny;       /* Denied station list. */
 
 } hfa384x_t;
 
@@ -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 b65850a411274b33d2d8aa4430607dd7d45deeae..eb8622b78ec900e130c701a8128865a327c67c90 100644 (file)
@@ -21,8 +21,8 @@ struct iio_buffer;
  * struct iio_buffer_access_funcs - access functions for buffers.
  * @store_to:          actually store stuff to the buffer
  * @read_first_n:      try to get a specified number of bytes (must exist)
- * @data_available:    indicates whether data for reading from the buffer is
- *                     available.
+ * @data_available:    indicates how much data is available for reading from
+ *                     the buffer.
  * @request_update:    if a parameter change has been marked, update underlying
  *                     storage.
  * @set_bytes_per_datum:set number of bytes per datum
@@ -43,7 +43,7 @@ struct iio_buffer_access_funcs {
        int (*read_first_n)(struct iio_buffer *buffer,
                            size_t n,
                            char __user *buf);
-       bool (*data_available)(struct iio_buffer *buffer);
+       size_t (*data_available)(struct iio_buffer *buffer);
 
        int (*request_update)(struct iio_buffer *buffer);
 
@@ -72,6 +72,7 @@ struct iio_buffer_access_funcs {
  * @demux_bounce:      [INTERN] buffer for doing gather from incoming scan.
  * @buffer_list:       [INTERN] entry in the devices list of current buffers.
  * @ref:               [INTERN] reference count of the buffer.
+ * @watermark:         [INTERN] number of datums to wait for poll/read.
  */
 struct iio_buffer {
        int                                     length;
@@ -90,6 +91,7 @@ struct iio_buffer {
        void                                    *demux_bounce;
        struct list_head                        buffer_list;
        struct kref                             ref;
+       unsigned int                            watermark;
 };
 
 /**
index f6d1d252f08d31dadc33279aa1c6219b96f65c32..7668716cd73cb39fb09b993e35e0e3bdb74a7176 100644 (file)
@@ -9,7 +9,7 @@
 #define IIO_DAC_MAX517_H_
 
 struct max517_platform_data {
-       u16                             vref_mv[2];
+       u16                             vref_mv[8];
 };
 
 #endif /* IIO_DAC_MAX517_H_ */
index 03fa332ad2a8cec4e26c212b9333e56f0c6d6169..8ad87d1c5340bedf557bd498fcc03b10a123a8e9 100644 (file)
@@ -9,22 +9,8 @@
 #ifndef _IIO_EVENTS_H_
 #define _IIO_EVENTS_H_
 
-#include <linux/ioctl.h>
-#include <linux/types.h>
 #include <linux/iio/types.h>
-
-/**
- * struct iio_event_data - The actual event being pushed to userspace
- * @id:                event identifier
- * @timestamp: best estimate of time of event occurrence (often from
- *             the interrupt handler)
- */
-struct iio_event_data {
-       __u64   id;
-       __s64   timestamp;
-};
-
-#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
+#include <uapi/linux/iio/events.h>
 
 /**
  * IIO_EVENT_CODE() - create event identifier
@@ -70,18 +56,4 @@ struct iio_event_data {
 #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction)       \
        IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
 
-#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
-
-#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
-
-#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
-
-/* Event code number extraction depends on which type of event we have.
- * Perhaps review this function in the future*/
-#define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((__s16)(mask & 0xFFFF))
-#define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((__s16)(((mask) >> 16) & 0xFFFF))
-
-#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
-#define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1)
-
 #endif
index 80d8550610646fdc25aef65d93efde6ae9343341..d86b753e9b30166e0c370845145ac59d2b863a32 100644 (file)
@@ -338,6 +338,16 @@ struct iio_dev;
  *                     provide a custom of_xlate function that reads the
  *                     *args* and returns the appropriate index in registered
  *                     IIO channels array.
+ * @hwfifo_set_watermark: function pointer to set the current hardware
+ *                     fifo watermark level; see hwfifo_* entries in
+ *                     Documentation/ABI/testing/sysfs-bus-iio for details on
+ *                     how the hardware fifo operates
+ * @hwfifo_flush_to_buffer: function pointer to flush the samples stored
+ *                     in the hardware fifo to the device buffer. The driver
+ *                     should not flush more than count samples. The function
+ *                     must return the number of samples flushed, 0 if no
+ *                     samples were flushed or a negative integer if no samples
+ *                     were flushed and there was an error.
  **/
 struct iio_info {
        struct module                   *driver_module;
@@ -399,6 +409,9 @@ struct iio_info {
                                  unsigned *readval);
        int (*of_xlate)(struct iio_dev *indio_dev,
                        const struct of_phandle_args *iiospec);
+       int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
+       int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
+                                     unsigned count);
 };
 
 /**
index 580ed5bdb3fa9c0cdca4cfc29105f26c5de7ba95..942b6de68e2f3882ec17fbcebfa1e32e27204b0e 100644 (file)
 #ifndef _IIO_TYPES_H_
 #define _IIO_TYPES_H_
 
-enum iio_chan_type {
-       IIO_VOLTAGE,
-       IIO_CURRENT,
-       IIO_POWER,
-       IIO_ACCEL,
-       IIO_ANGL_VEL,
-       IIO_MAGN,
-       IIO_LIGHT,
-       IIO_INTENSITY,
-       IIO_PROXIMITY,
-       IIO_TEMP,
-       IIO_INCLI,
-       IIO_ROT,
-       IIO_ANGL,
-       IIO_TIMESTAMP,
-       IIO_CAPACITANCE,
-       IIO_ALTVOLTAGE,
-       IIO_CCT,
-       IIO_PRESSURE,
-       IIO_HUMIDITYRELATIVE,
-       IIO_ACTIVITY,
-       IIO_STEPS,
-       IIO_ENERGY,
-       IIO_DISTANCE,
-       IIO_VELOCITY,
-};
-
-enum iio_modifier {
-       IIO_NO_MOD,
-       IIO_MOD_X,
-       IIO_MOD_Y,
-       IIO_MOD_Z,
-       IIO_MOD_X_AND_Y,
-       IIO_MOD_X_AND_Z,
-       IIO_MOD_Y_AND_Z,
-       IIO_MOD_X_AND_Y_AND_Z,
-       IIO_MOD_X_OR_Y,
-       IIO_MOD_X_OR_Z,
-       IIO_MOD_Y_OR_Z,
-       IIO_MOD_X_OR_Y_OR_Z,
-       IIO_MOD_LIGHT_BOTH,
-       IIO_MOD_LIGHT_IR,
-       IIO_MOD_ROOT_SUM_SQUARED_X_Y,
-       IIO_MOD_SUM_SQUARED_X_Y_Z,
-       IIO_MOD_LIGHT_CLEAR,
-       IIO_MOD_LIGHT_RED,
-       IIO_MOD_LIGHT_GREEN,
-       IIO_MOD_LIGHT_BLUE,
-       IIO_MOD_QUATERNION,
-       IIO_MOD_TEMP_AMBIENT,
-       IIO_MOD_TEMP_OBJECT,
-       IIO_MOD_NORTH_MAGN,
-       IIO_MOD_NORTH_TRUE,
-       IIO_MOD_NORTH_MAGN_TILT_COMP,
-       IIO_MOD_NORTH_TRUE_TILT_COMP,
-       IIO_MOD_RUNNING,
-       IIO_MOD_JOGGING,
-       IIO_MOD_WALKING,
-       IIO_MOD_STILL,
-       IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
-};
-
-enum iio_event_type {
-       IIO_EV_TYPE_THRESH,
-       IIO_EV_TYPE_MAG,
-       IIO_EV_TYPE_ROC,
-       IIO_EV_TYPE_THRESH_ADAPTIVE,
-       IIO_EV_TYPE_MAG_ADAPTIVE,
-       IIO_EV_TYPE_CHANGE,
-};
+#include <uapi/linux/iio/types.h>
 
 enum iio_event_info {
        IIO_EV_INFO_ENABLE,
@@ -88,13 +19,6 @@ enum iio_event_info {
        IIO_EV_INFO_PERIOD,
 };
 
-enum iio_event_direction {
-       IIO_EV_DIR_EITHER,
-       IIO_EV_DIR_RISING,
-       IIO_EV_DIR_FALLING,
-       IIO_EV_DIR_NONE,
-};
-
 #define IIO_VAL_INT 1
 #define IIO_VAL_INT_PLUS_MICRO 2
 #define IIO_VAL_INT_PLUS_NANO 3
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);
index 68ceb97c458c90b96bf484df23a89a485d2b9ff3..38df23435ebbd399489326e649f828c8654878c0 100644 (file)
@@ -6,6 +6,7 @@ header-y += caif/
 header-y += dvb/
 header-y += hdlc/
 header-y += hsi/
+header-y += iio/
 header-y += isdn/
 header-y += mmc/
 header-y += nfsd/
diff --git a/include/uapi/linux/iio/Kbuild b/include/uapi/linux/iio/Kbuild
new file mode 100644 (file)
index 0000000..86f76d8
--- /dev/null
@@ -0,0 +1,3 @@
+# UAPI Header export list
+header-y += events.h
+header-y += types.h
diff --git a/include/uapi/linux/iio/events.h b/include/uapi/linux/iio/events.h
new file mode 100644 (file)
index 0000000..00bbdae
--- /dev/null
@@ -0,0 +1,42 @@
+/* The industrial I/O - event passing to userspace
+ *
+ * Copyright (c) 2008-2011 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#ifndef _UAPI_IIO_EVENTS_H_
+#define _UAPI_IIO_EVENTS_H_
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/**
+ * struct iio_event_data - The actual event being pushed to userspace
+ * @id:                event identifier
+ * @timestamp: best estimate of time of event occurrence (often from
+ *             the interrupt handler)
+ */
+struct iio_event_data {
+       __u64   id;
+       __s64   timestamp;
+};
+
+#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
+
+#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
+
+#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
+
+#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
+
+/* Event code number extraction depends on which type of event we have.
+ * Perhaps review this function in the future*/
+#define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((__s16)(mask & 0xFFFF))
+#define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((__s16)(((mask) >> 16) & 0xFFFF))
+
+#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
+#define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1)
+
+#endif /* _UAPI_IIO_EVENTS_H_ */
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
new file mode 100644 (file)
index 0000000..5c46019
--- /dev/null
@@ -0,0 +1,92 @@
+/* industrial I/O data types needed both in and out of kernel
+ *
+ * Copyright (c) 2008 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef _UAPI_IIO_TYPES_H_
+#define _UAPI_IIO_TYPES_H_
+
+enum iio_chan_type {
+       IIO_VOLTAGE,
+       IIO_CURRENT,
+       IIO_POWER,
+       IIO_ACCEL,
+       IIO_ANGL_VEL,
+       IIO_MAGN,
+       IIO_LIGHT,
+       IIO_INTENSITY,
+       IIO_PROXIMITY,
+       IIO_TEMP,
+       IIO_INCLI,
+       IIO_ROT,
+       IIO_ANGL,
+       IIO_TIMESTAMP,
+       IIO_CAPACITANCE,
+       IIO_ALTVOLTAGE,
+       IIO_CCT,
+       IIO_PRESSURE,
+       IIO_HUMIDITYRELATIVE,
+       IIO_ACTIVITY,
+       IIO_STEPS,
+       IIO_ENERGY,
+       IIO_DISTANCE,
+       IIO_VELOCITY,
+};
+
+enum iio_modifier {
+       IIO_NO_MOD,
+       IIO_MOD_X,
+       IIO_MOD_Y,
+       IIO_MOD_Z,
+       IIO_MOD_X_AND_Y,
+       IIO_MOD_X_AND_Z,
+       IIO_MOD_Y_AND_Z,
+       IIO_MOD_X_AND_Y_AND_Z,
+       IIO_MOD_X_OR_Y,
+       IIO_MOD_X_OR_Z,
+       IIO_MOD_Y_OR_Z,
+       IIO_MOD_X_OR_Y_OR_Z,
+       IIO_MOD_LIGHT_BOTH,
+       IIO_MOD_LIGHT_IR,
+       IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+       IIO_MOD_SUM_SQUARED_X_Y_Z,
+       IIO_MOD_LIGHT_CLEAR,
+       IIO_MOD_LIGHT_RED,
+       IIO_MOD_LIGHT_GREEN,
+       IIO_MOD_LIGHT_BLUE,
+       IIO_MOD_QUATERNION,
+       IIO_MOD_TEMP_AMBIENT,
+       IIO_MOD_TEMP_OBJECT,
+       IIO_MOD_NORTH_MAGN,
+       IIO_MOD_NORTH_TRUE,
+       IIO_MOD_NORTH_MAGN_TILT_COMP,
+       IIO_MOD_NORTH_TRUE_TILT_COMP,
+       IIO_MOD_RUNNING,
+       IIO_MOD_JOGGING,
+       IIO_MOD_WALKING,
+       IIO_MOD_STILL,
+       IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
+};
+
+enum iio_event_type {
+       IIO_EV_TYPE_THRESH,
+       IIO_EV_TYPE_MAG,
+       IIO_EV_TYPE_ROC,
+       IIO_EV_TYPE_THRESH_ADAPTIVE,
+       IIO_EV_TYPE_MAG_ADAPTIVE,
+       IIO_EV_TYPE_CHANGE,
+};
+
+enum iio_event_direction {
+       IIO_EV_DIR_EITHER,
+       IIO_EV_DIR_RISING,
+       IIO_EV_DIR_FALLING,
+       IIO_EV_DIR_NONE,
+};
+
+#endif /* _UAPI_IIO_TYPES_H_ */
+
diff --git a/tools/iio/Makefile b/tools/iio/Makefile
new file mode 100644 (file)
index 0000000..bf7ae6d
--- /dev/null
@@ -0,0 +1,16 @@
+CC = gcc
+CFLAGS = -Wall -g -D_GNU_SOURCE
+
+all: iio_event_monitor lsiio generic_buffer
+
+iio_event_monitor: iio_event_monitor.o iio_utils.o
+
+lsiio: lsiio.o iio_utils.o
+
+generic_buffer: generic_buffer.o iio_utils.o
+
+%.o: %.c iio_utils.h
+
+.PHONY: clean
+clean:
+       rm -f *.o iio_event_monitor lsiio generic_buffer
diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
new file mode 100644 (file)
index 0000000..f805493
--- /dev/null
@@ -0,0 +1,359 @@
+/* Industrialio buffer test code.
+ *
+ * Copyright (c) 2008 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is primarily intended as an example application.
+ * Reads the current buffer setup from sysfs and starts a short capture
+ * from the specified device, pretty printing the result after appropriate
+ * conversion.
+ *
+ * Command line parameters
+ * generic_buffer -n <device_name> -t <trigger_name>
+ * If trigger name is not specified the program assumes you want a dataready
+ * trigger associated with the device and goes looking for it.
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+#include <linux/types.h>
+#include <string.h>
+#include <poll.h>
+#include <endian.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include "iio_utils.h"
+
+/**
+ * size_from_channelarray() - calculate the storage size of a scan
+ * @channels:          the channel info array
+ * @num_channels:      number of channels
+ *
+ * Has the side effect of filling the channels[i].location values used
+ * in processing the buffer output.
+ **/
+int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
+{
+       int bytes = 0;
+       int i = 0;
+
+       while (i < num_channels) {
+               if (bytes % channels[i].bytes == 0)
+                       channels[i].location = bytes;
+               else
+                       channels[i].location = bytes - bytes%channels[i].bytes
+                               + channels[i].bytes;
+               bytes = channels[i].location + channels[i].bytes;
+               i++;
+       }
+       return bytes;
+}
+
+void print2byte(int input, struct iio_channel_info *info)
+{
+       /* First swap if incorrect endian */
+       if (info->be)
+               input = be16toh((uint16_t)input);
+       else
+               input = le16toh((uint16_t)input);
+
+       /*
+        * Shift before conversion to avoid sign extension
+        * of left aligned data
+        */
+       input >>= info->shift;
+       if (info->is_signed) {
+               int16_t val = input;
+
+               val &= (1 << info->bits_used) - 1;
+               val = (int16_t)(val << (16 - info->bits_used)) >>
+                       (16 - info->bits_used);
+               printf("%05f ", ((float)val + info->offset)*info->scale);
+       } else {
+               uint16_t val = input;
+
+               val &= (1 << info->bits_used) - 1;
+               printf("%05f ", ((float)val + info->offset)*info->scale);
+       }
+}
+/**
+ * process_scan() - print out the values in SI units
+ * @data:              pointer to the start of the scan
+ * @channels:          information about the channels. Note
+ *  size_from_channelarray must have been called first to fill the
+ *  location offsets.
+ * @num_channels:      number of channels
+ **/
+void process_scan(char *data,
+                 struct iio_channel_info *channels,
+                 int num_channels)
+{
+       int k;
+
+       for (k = 0; k < num_channels; k++)
+               switch (channels[k].bytes) {
+                       /* only a few cases implemented so far */
+               case 2:
+                       print2byte(*(uint16_t *)(data + channels[k].location),
+                                  &channels[k]);
+                       break;
+               case 4:
+                       if (!channels[k].is_signed) {
+                               uint32_t val = *(uint32_t *)
+                                       (data + channels[k].location);
+                               printf("%05f ", ((float)val +
+                                                channels[k].offset)*
+                                      channels[k].scale);
+
+                       }
+                       break;
+               case 8:
+                       if (channels[k].is_signed) {
+                               int64_t val = *(int64_t *)
+                                       (data +
+                                        channels[k].location);
+                               if ((val >> channels[k].bits_used) & 1)
+                                       val = (val & channels[k].mask) |
+                                               ~channels[k].mask;
+                               /* special case for timestamp */
+                               if (channels[k].scale == 1.0f &&
+                                   channels[k].offset == 0.0f)
+                                       printf("%" PRId64 " ", val);
+                               else
+                                       printf("%05f ", ((float)val +
+                                                        channels[k].offset)*
+                                              channels[k].scale);
+                       }
+                       break;
+               default:
+                       break;
+               }
+       printf("\n");
+}
+
+int main(int argc, char **argv)
+{
+       unsigned long num_loops = 2;
+       unsigned long timedelay = 1000000;
+       unsigned long buf_len = 128;
+
+       int ret, c, i, j, toread;
+       int fp;
+
+       int num_channels;
+       char *trigger_name = NULL, *device_name = NULL;
+       char *dev_dir_name, *buf_dir_name;
+
+       int datardytrigger = 1;
+       char *data;
+       ssize_t read_size;
+       int dev_num, trig_num;
+       char *buffer_access;
+       int scan_size;
+       int noevents = 0;
+       int notrigger = 0;
+       char *dummy;
+
+       struct iio_channel_info *channels;
+
+       while ((c = getopt(argc, argv, "l:w:c:et:n:g")) != -1) {
+               switch (c) {
+               case 'n':
+                       device_name = optarg;
+                       break;
+               case 't':
+                       trigger_name = optarg;
+                       datardytrigger = 0;
+                       break;
+               case 'e':
+                       noevents = 1;
+                       break;
+               case 'c':
+                       num_loops = strtoul(optarg, &dummy, 10);
+                       break;
+               case 'w':
+                       timedelay = strtoul(optarg, &dummy, 10);
+                       break;
+               case 'l':
+                       buf_len = strtoul(optarg, &dummy, 10);
+                       break;
+               case 'g':
+                       notrigger = 1;
+                       break;
+               case '?':
+                       return -1;
+               }
+       }
+
+       if (device_name == NULL)
+               return -1;
+
+       /* Find the device requested */
+       dev_num = find_type_by_name(device_name, "iio:device");
+       if (dev_num < 0) {
+               printf("Failed to find the %s\n", device_name);
+               ret = -ENODEV;
+               goto error_ret;
+       }
+       printf("iio device number being used is %d\n", dev_num);
+
+       asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
+
+       if (!notrigger) {
+               if (trigger_name == NULL) {
+                       /*
+                        * Build the trigger name. If it is device associated
+                        * its name is <device_name>_dev[n] where n matches
+                        * the device number found above.
+                        */
+                       ret = asprintf(&trigger_name,
+                                      "%s-dev%d", device_name, dev_num);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               goto error_ret;
+                       }
+               }
+
+               /* Verify the trigger exists */
+               trig_num = find_type_by_name(trigger_name, "trigger");
+               if (trig_num < 0) {
+                       printf("Failed to find the trigger %s\n", trigger_name);
+                       ret = -ENODEV;
+                       goto error_free_triggername;
+               }
+               printf("iio trigger number being used is %d\n", trig_num);
+       } else
+               printf("trigger-less mode selected\n");
+
+       /*
+        * Parse the files in scan_elements to identify what channels are
+        * present
+        */
+       ret = build_channel_array(dev_dir_name, &channels, &num_channels);
+       if (ret) {
+               printf("Problem reading scan element information\n");
+               printf("diag %s\n", dev_dir_name);
+               goto error_free_triggername;
+       }
+
+       /*
+        * Construct the directory name for the associated buffer.
+        * As we know that the lis3l02dq has only one buffer this may
+        * be built rather than found.
+        */
+       ret = asprintf(&buf_dir_name,
+                      "%siio:device%d/buffer", iio_dir, dev_num);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_free_triggername;
+       }
+
+       if (!notrigger) {
+               printf("%s %s\n", dev_dir_name, trigger_name);
+               /* Set the device trigger to be the data ready trigger found
+                * above */
+               ret = write_sysfs_string_and_verify("trigger/current_trigger",
+                                                   dev_dir_name,
+                                                   trigger_name);
+               if (ret < 0) {
+                       printf("Failed to write current_trigger file\n");
+                       goto error_free_buf_dir_name;
+               }
+       }
+
+       /* Setup ring buffer parameters */
+       ret = write_sysfs_int("length", buf_dir_name, buf_len);
+       if (ret < 0)
+               goto error_free_buf_dir_name;
+
+       /* Enable the buffer */
+       ret = write_sysfs_int("enable", buf_dir_name, 1);
+       if (ret < 0)
+               goto error_free_buf_dir_name;
+       scan_size = size_from_channelarray(channels, num_channels);
+       data = malloc(scan_size*buf_len);
+       if (!data) {
+               ret = -ENOMEM;
+               goto error_free_buf_dir_name;
+       }
+
+       ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_free_data;
+       }
+
+       /* Attempt to open non blocking the access dev */
+       fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
+       if (fp == -1) { /* If it isn't there make the node */
+               printf("Failed to open %s\n", buffer_access);
+               ret = -errno;
+               goto error_free_buffer_access;
+       }
+
+       /* Wait for events 10 times */
+       for (j = 0; j < num_loops; j++) {
+               if (!noevents) {
+                       struct pollfd pfd = {
+                               .fd = fp,
+                               .events = POLLIN,
+                       };
+
+                       poll(&pfd, 1, -1);
+                       toread = buf_len;
+
+               } else {
+                       usleep(timedelay);
+                       toread = 64;
+               }
+
+               read_size = read(fp,
+                                data,
+                                toread*scan_size);
+               if (read_size < 0) {
+                       if (errno == -EAGAIN) {
+                               printf("nothing available\n");
+                               continue;
+                       } else
+                               break;
+               }
+               for (i = 0; i < read_size/scan_size; i++)
+                       process_scan(data + scan_size*i,
+                                    channels,
+                                    num_channels);
+       }
+
+       /* Stop the buffer */
+       ret = write_sysfs_int("enable", buf_dir_name, 0);
+       if (ret < 0)
+               goto error_close_buffer_access;
+
+       if (!notrigger)
+               /* Disconnect the trigger - just write a dummy name. */
+               write_sysfs_string("trigger/current_trigger",
+                                  dev_dir_name, "NULL");
+
+error_close_buffer_access:
+       close(fp);
+error_free_data:
+       free(data);
+error_free_buffer_access:
+       free(buffer_access);
+error_free_buf_dir_name:
+       free(buf_dir_name);
+error_free_triggername:
+       if (datardytrigger)
+               free(trigger_name);
+error_ret:
+       return ret;
+}
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
new file mode 100644 (file)
index 0000000..427c271
--- /dev/null
@@ -0,0 +1,308 @@
+/* Industrialio event test code.
+ *
+ * Copyright (c) 2011-2012 Lars-Peter Clausen <lars@metafoo.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is primarily intended as an example application.
+ * Reads the current buffer setup from sysfs and starts a short capture
+ * from the specified device, pretty printing the result after appropriate
+ * conversion.
+ *
+ * Usage:
+ *     iio_event_monitor <device_name>
+ *
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <poll.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include "iio_utils.h"
+#include <linux/iio/events.h>
+#include <linux/iio/types.h>
+
+static const char * const iio_chan_type_name_spec[] = {
+       [IIO_VOLTAGE] = "voltage",
+       [IIO_CURRENT] = "current",
+       [IIO_POWER] = "power",
+       [IIO_ACCEL] = "accel",
+       [IIO_ANGL_VEL] = "anglvel",
+       [IIO_MAGN] = "magn",
+       [IIO_LIGHT] = "illuminance",
+       [IIO_INTENSITY] = "intensity",
+       [IIO_PROXIMITY] = "proximity",
+       [IIO_TEMP] = "temp",
+       [IIO_INCLI] = "incli",
+       [IIO_ROT] = "rot",
+       [IIO_ANGL] = "angl",
+       [IIO_TIMESTAMP] = "timestamp",
+       [IIO_CAPACITANCE] = "capacitance",
+       [IIO_ALTVOLTAGE] = "altvoltage",
+       [IIO_CCT] = "cct",
+       [IIO_PRESSURE] = "pressure",
+       [IIO_HUMIDITYRELATIVE] = "humidityrelative",
+       [IIO_ACTIVITY] = "activity",
+       [IIO_STEPS] = "steps",
+};
+
+static const char * const iio_ev_type_text[] = {
+       [IIO_EV_TYPE_THRESH] = "thresh",
+       [IIO_EV_TYPE_MAG] = "mag",
+       [IIO_EV_TYPE_ROC] = "roc",
+       [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
+       [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
+       [IIO_EV_TYPE_CHANGE] = "change",
+};
+
+static const char * const iio_ev_dir_text[] = {
+       [IIO_EV_DIR_EITHER] = "either",
+       [IIO_EV_DIR_RISING] = "rising",
+       [IIO_EV_DIR_FALLING] = "falling"
+};
+
+static const char * const iio_modifier_names[] = {
+       [IIO_MOD_X] = "x",
+       [IIO_MOD_Y] = "y",
+       [IIO_MOD_Z] = "z",
+       [IIO_MOD_X_AND_Y] = "x&y",
+       [IIO_MOD_X_AND_Z] = "x&z",
+       [IIO_MOD_Y_AND_Z] = "y&z",
+       [IIO_MOD_X_AND_Y_AND_Z] = "x&y&z",
+       [IIO_MOD_X_OR_Y] = "x|y",
+       [IIO_MOD_X_OR_Z] = "x|z",
+       [IIO_MOD_Y_OR_Z] = "y|z",
+       [IIO_MOD_X_OR_Y_OR_Z] = "x|y|z",
+       [IIO_MOD_LIGHT_BOTH] = "both",
+       [IIO_MOD_LIGHT_IR] = "ir",
+       [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
+       [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
+       [IIO_MOD_LIGHT_CLEAR] = "clear",
+       [IIO_MOD_LIGHT_RED] = "red",
+       [IIO_MOD_LIGHT_GREEN] = "green",
+       [IIO_MOD_LIGHT_BLUE] = "blue",
+       [IIO_MOD_QUATERNION] = "quaternion",
+       [IIO_MOD_TEMP_AMBIENT] = "ambient",
+       [IIO_MOD_TEMP_OBJECT] = "object",
+       [IIO_MOD_NORTH_MAGN] = "from_north_magnetic",
+       [IIO_MOD_NORTH_TRUE] = "from_north_true",
+       [IIO_MOD_NORTH_MAGN_TILT_COMP] = "from_north_magnetic_tilt_comp",
+       [IIO_MOD_NORTH_TRUE_TILT_COMP] = "from_north_true_tilt_comp",
+       [IIO_MOD_RUNNING] = "running",
+       [IIO_MOD_JOGGING] = "jogging",
+       [IIO_MOD_WALKING] = "walking",
+       [IIO_MOD_STILL] = "still",
+};
+
+static bool event_is_known(struct iio_event_data *event)
+{
+       enum iio_chan_type type = IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event->id);
+       enum iio_modifier mod = IIO_EVENT_CODE_EXTRACT_MODIFIER(event->id);
+       enum iio_event_type ev_type = IIO_EVENT_CODE_EXTRACT_TYPE(event->id);
+       enum iio_event_direction dir = IIO_EVENT_CODE_EXTRACT_DIR(event->id);
+
+       switch (type) {
+       case IIO_VOLTAGE:
+       case IIO_CURRENT:
+       case IIO_POWER:
+       case IIO_ACCEL:
+       case IIO_ANGL_VEL:
+       case IIO_MAGN:
+       case IIO_LIGHT:
+       case IIO_INTENSITY:
+       case IIO_PROXIMITY:
+       case IIO_TEMP:
+       case IIO_INCLI:
+       case IIO_ROT:
+       case IIO_ANGL:
+       case IIO_TIMESTAMP:
+       case IIO_CAPACITANCE:
+       case IIO_ALTVOLTAGE:
+       case IIO_CCT:
+       case IIO_PRESSURE:
+       case IIO_HUMIDITYRELATIVE:
+       case IIO_ACTIVITY:
+       case IIO_STEPS:
+               break;
+       default:
+               return false;
+       }
+
+       switch (mod) {
+       case IIO_NO_MOD:
+       case IIO_MOD_X:
+       case IIO_MOD_Y:
+       case IIO_MOD_Z:
+       case IIO_MOD_X_AND_Y:
+       case IIO_MOD_X_AND_Z:
+       case IIO_MOD_Y_AND_Z:
+       case IIO_MOD_X_AND_Y_AND_Z:
+       case IIO_MOD_X_OR_Y:
+       case IIO_MOD_X_OR_Z:
+       case IIO_MOD_Y_OR_Z:
+       case IIO_MOD_X_OR_Y_OR_Z:
+       case IIO_MOD_LIGHT_BOTH:
+       case IIO_MOD_LIGHT_IR:
+       case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+       case IIO_MOD_SUM_SQUARED_X_Y_Z:
+       case IIO_MOD_LIGHT_CLEAR:
+       case IIO_MOD_LIGHT_RED:
+       case IIO_MOD_LIGHT_GREEN:
+       case IIO_MOD_LIGHT_BLUE:
+       case IIO_MOD_QUATERNION:
+       case IIO_MOD_TEMP_AMBIENT:
+       case IIO_MOD_TEMP_OBJECT:
+       case IIO_MOD_NORTH_MAGN:
+       case IIO_MOD_NORTH_TRUE:
+       case IIO_MOD_NORTH_MAGN_TILT_COMP:
+       case IIO_MOD_NORTH_TRUE_TILT_COMP:
+       case IIO_MOD_RUNNING:
+       case IIO_MOD_JOGGING:
+       case IIO_MOD_WALKING:
+       case IIO_MOD_STILL:
+               break;
+       default:
+               return false;
+       }
+
+       switch (ev_type) {
+       case IIO_EV_TYPE_THRESH:
+       case IIO_EV_TYPE_MAG:
+       case IIO_EV_TYPE_ROC:
+       case IIO_EV_TYPE_THRESH_ADAPTIVE:
+       case IIO_EV_TYPE_MAG_ADAPTIVE:
+       case IIO_EV_TYPE_CHANGE:
+               break;
+       default:
+               return false;
+       }
+
+       switch (dir) {
+       case IIO_EV_DIR_EITHER:
+       case IIO_EV_DIR_RISING:
+       case IIO_EV_DIR_FALLING:
+       case IIO_EV_DIR_NONE:
+               break;
+       default:
+               return false;
+       }
+
+       return true;
+}
+
+static void print_event(struct iio_event_data *event)
+{
+       enum iio_chan_type type = IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event->id);
+       enum iio_modifier mod = IIO_EVENT_CODE_EXTRACT_MODIFIER(event->id);
+       enum iio_event_type ev_type = IIO_EVENT_CODE_EXTRACT_TYPE(event->id);
+       enum iio_event_direction dir = IIO_EVENT_CODE_EXTRACT_DIR(event->id);
+       int chan = IIO_EVENT_CODE_EXTRACT_CHAN(event->id);
+       int chan2 = IIO_EVENT_CODE_EXTRACT_CHAN2(event->id);
+       bool diff = IIO_EVENT_CODE_EXTRACT_DIFF(event->id);
+
+       if (!event_is_known(event)) {
+               printf("Unknown event: time: %lld, id: %llx\n",
+                               event->timestamp, event->id);
+               return;
+       }
+
+       printf("Event: time: %lld, ", event->timestamp);
+
+       if (mod != IIO_NO_MOD) {
+               printf("type: %s(%s), ",
+                       iio_chan_type_name_spec[type],
+                       iio_modifier_names[mod]);
+       } else {
+               printf("type: %s, ",
+                       iio_chan_type_name_spec[type]);
+       }
+
+       if (diff && chan >= 0 && chan2 >= 0)
+               printf("channel: %d-%d, ", chan, chan2);
+       else if (chan >= 0)
+               printf("channel: %d, ", chan);
+
+       printf("evtype: %s", iio_ev_type_text[ev_type]);
+
+       if (dir != IIO_EV_DIR_NONE)
+               printf(", direction: %s", iio_ev_dir_text[dir]);
+       printf("\n");
+}
+
+int main(int argc, char **argv)
+{
+       struct iio_event_data event;
+       const char *device_name;
+       char *chrdev_name;
+       int ret;
+       int dev_num;
+       int fd, event_fd;
+
+       if (argc <= 1) {
+               printf("Usage: %s <device_name>\n", argv[0]);
+               return -1;
+       }
+
+       device_name = argv[1];
+
+       dev_num = find_type_by_name(device_name, "iio:device");
+       if (dev_num >= 0) {
+               printf("Found IIO device with name %s with device number %d\n",
+                       device_name, dev_num);
+               ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num);
+               if (ret < 0) {
+                       ret = -ENOMEM;
+                       goto error_ret;
+               }
+       } else {
+               /* If we can't find a IIO device by name assume device_name is a
+                  IIO chrdev */
+               chrdev_name = strdup(device_name);
+       }
+
+       fd = open(chrdev_name, 0);
+       if (fd == -1) {
+               fprintf(stdout, "Failed to open %s\n", chrdev_name);
+               ret = -errno;
+               goto error_free_chrdev_name;
+       }
+
+       ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
+
+       close(fd);
+
+       if (ret == -1 || event_fd == -1) {
+               fprintf(stdout, "Failed to retrieve event fd\n");
+               ret = -errno;
+               goto error_free_chrdev_name;
+       }
+
+       while (true) {
+               ret = read(event_fd, &event, sizeof(event));
+               if (ret == -1) {
+                       if (errno == EAGAIN) {
+                               printf("nothing available\n");
+                               continue;
+                       } else {
+                               perror("Failed to read event from device");
+                               ret = -errno;
+                               break;
+                       }
+               }
+
+               print_event(&event);
+       }
+
+       close(event_fd);
+error_free_chrdev_name:
+       free(chrdev_name);
+error_ret:
+       return ret;
+}
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
new file mode 100644 (file)
index 0000000..6f64521
--- /dev/null
@@ -0,0 +1,669 @@
+/* IIO - useful set of util functionality
+ *
+ * Copyright (c) 2008 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#ifndef _IIO_UTILS_H
+#define _IIO_UTILS_H
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <dirent.h>
+#include <errno.h>
+#include <ctype.h>
+#include "iio_utils.h"
+
+const char *iio_dir = "/sys/bus/iio/devices/";
+
+static char * const iio_direction[] = {
+       "in",
+       "out",
+};
+
+/**
+ * iioutils_break_up_name() - extract generic name from full channel name
+ * @full_name: the full channel name
+ * @generic_name: the output generic channel name
+ **/
+int iioutils_break_up_name(const char *full_name,
+                                 char **generic_name)
+{
+       char *current;
+       char *w, *r;
+       char *working, *prefix = "";
+       int i;
+
+       for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++)
+               if (!strncmp(full_name, iio_direction[i],
+                            strlen(iio_direction[i]))) {
+                       prefix = iio_direction[i];
+                       break;
+               }
+
+       current = strdup(full_name + strlen(prefix) + 1);
+       working = strtok(current, "_\0");
+
+       w = working;
+       r = working;
+
+       while (*r != '\0') {
+               if (!isdigit(*r)) {
+                       *w = *r;
+                       w++;
+               }
+               r++;
+       }
+       *w = '\0';
+       asprintf(generic_name, "%s_%s", prefix, working);
+       free(current);
+
+       return 0;
+}
+
+/**
+ * iioutils_get_type() - find and process _type attribute data
+ * @is_signed: output whether channel is signed
+ * @bytes: output how many bytes the channel storage occupies
+ * @mask: output a bit mask for the raw data
+ * @be: big endian
+ * @device_dir: the iio device directory
+ * @name: the channel name
+ * @generic_name: the channel type name
+ **/
+int iioutils_get_type(unsigned *is_signed,
+                            unsigned *bytes,
+                            unsigned *bits_used,
+                            unsigned *shift,
+                            uint64_t *mask,
+                            unsigned *be,
+                            const char *device_dir,
+                            const char *name,
+                            const char *generic_name)
+{
+       FILE *sysfsfp;
+       int ret;
+       DIR *dp;
+       char *scan_el_dir, *builtname, *builtname_generic, *filename = 0;
+       char signchar, endianchar;
+       unsigned padint;
+       const struct dirent *ent;
+
+       ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+       ret = asprintf(&builtname, FORMAT_TYPE_FILE, name);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_free_scan_el_dir;
+       }
+       ret = asprintf(&builtname_generic, FORMAT_TYPE_FILE, generic_name);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_free_builtname;
+       }
+
+       dp = opendir(scan_el_dir);
+       if (dp == NULL) {
+               ret = -errno;
+               goto error_free_builtname_generic;
+       }
+       while (ent = readdir(dp), ent != NULL)
+               /*
+                * Do we allow devices to override a generic name with
+                * a specific one?
+                */
+               if ((strcmp(builtname, ent->d_name) == 0) ||
+                   (strcmp(builtname_generic, ent->d_name) == 0)) {
+                       ret = asprintf(&filename,
+                                      "%s/%s", scan_el_dir, ent->d_name);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               goto error_closedir;
+                       }
+                       sysfsfp = fopen(filename, "r");
+                       if (sysfsfp == NULL) {
+                               printf("failed to open %s\n", filename);
+                               ret = -errno;
+                               goto error_free_filename;
+                       }
+
+                       ret = fscanf(sysfsfp,
+                                    "%ce:%c%u/%u>>%u",
+                                    &endianchar,
+                                    &signchar,
+                                    bits_used,
+                                    &padint, shift);
+                       if (ret < 0) {
+                               printf("failed to pass scan type description\n");
+                               ret = -errno;
+                               goto error_close_sysfsfp;
+                       }
+                       *be = (endianchar == 'b');
+                       *bytes = padint / 8;
+                       if (*bits_used == 64)
+                               *mask = ~0;
+                       else
+                               *mask = (1 << *bits_used) - 1;
+                       if (signchar == 's')
+                               *is_signed = 1;
+                       else
+                               *is_signed = 0;
+                       fclose(sysfsfp);
+                       free(filename);
+
+                       filename = 0;
+                       sysfsfp = 0;
+               }
+error_close_sysfsfp:
+       if (sysfsfp)
+               fclose(sysfsfp);
+error_free_filename:
+       if (filename)
+               free(filename);
+error_closedir:
+       closedir(dp);
+error_free_builtname_generic:
+       free(builtname_generic);
+error_free_builtname:
+       free(builtname);
+error_free_scan_el_dir:
+       free(scan_el_dir);
+error_ret:
+       return ret;
+}
+
+int iioutils_get_param_float(float *output,
+                                   const char *param_name,
+                                   const char *device_dir,
+                                   const char *name,
+                                   const char *generic_name)
+{
+       FILE *sysfsfp;
+       int ret;
+       DIR *dp;
+       char *builtname, *builtname_generic;
+       char *filename = NULL;
+       const struct dirent *ent;
+
+       ret = asprintf(&builtname, "%s_%s", name, param_name);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+       ret = asprintf(&builtname_generic,
+                      "%s_%s", generic_name, param_name);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_free_builtname;
+       }
+       dp = opendir(device_dir);
+       if (dp == NULL) {
+               ret = -errno;
+               goto error_free_builtname_generic;
+       }
+       while (ent = readdir(dp), ent != NULL)
+               if ((strcmp(builtname, ent->d_name) == 0) ||
+                   (strcmp(builtname_generic, ent->d_name) == 0)) {
+                       ret = asprintf(&filename,
+                                      "%s/%s", device_dir, ent->d_name);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               goto error_closedir;
+                       }
+                       sysfsfp = fopen(filename, "r");
+                       if (!sysfsfp) {
+                               ret = -errno;
+                               goto error_free_filename;
+                       }
+                       fscanf(sysfsfp, "%f", output);
+                       break;
+               }
+error_free_filename:
+       if (filename)
+               free(filename);
+error_closedir:
+       closedir(dp);
+error_free_builtname_generic:
+       free(builtname_generic);
+error_free_builtname:
+       free(builtname);
+error_ret:
+       return ret;
+}
+
+/**
+ * bsort_channel_array_by_index() - reorder so that the array is in index order
+ *
+ **/
+
+void bsort_channel_array_by_index(struct iio_channel_info **ci_array,
+                                        int cnt)
+{
+
+       struct iio_channel_info temp;
+       int x, y;
+
+       for (x = 0; x < cnt; x++)
+               for (y = 0; y < (cnt - 1); y++)
+                       if ((*ci_array)[y].index > (*ci_array)[y+1].index) {
+                               temp = (*ci_array)[y + 1];
+                               (*ci_array)[y + 1] = (*ci_array)[y];
+                               (*ci_array)[y] = temp;
+                       }
+}
+
+/**
+ * build_channel_array() - function to figure out what channels are present
+ * @device_dir: the IIO device directory in sysfs
+ * @
+ **/
+int build_channel_array(const char *device_dir,
+                             struct iio_channel_info **ci_array,
+                             int *counter)
+{
+       DIR *dp;
+       FILE *sysfsfp;
+       int count, i;
+       struct iio_channel_info *current;
+       int ret;
+       const struct dirent *ent;
+       char *scan_el_dir;
+       char *filename;
+
+       *counter = 0;
+       ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
+       if (ret < 0) {
+               ret = -ENOMEM;
+               goto error_ret;
+       }
+       dp = opendir(scan_el_dir);
+       if (dp == NULL) {
+               ret = -errno;
+               goto error_free_name;
+       }
+       while (ent = readdir(dp), ent != NULL)
+               if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
+                          "_en") == 0) {
+                       ret = asprintf(&filename,
+                                      "%s/%s", scan_el_dir, ent->d_name);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               goto error_close_dir;
+                       }
+                       sysfsfp = fopen(filename, "r");
+                       if (sysfsfp == NULL) {
+                               ret = -errno;
+                               free(filename);
+                               goto error_close_dir;
+                       }
+                       fscanf(sysfsfp, "%i", &ret);
+                       if (ret == 1)
+                               (*counter)++;
+                       fclose(sysfsfp);
+                       free(filename);
+               }
+       *ci_array = malloc(sizeof(**ci_array) * (*counter));
+       if (*ci_array == NULL) {
+               ret = -ENOMEM;
+               goto error_close_dir;
+       }
+       seekdir(dp, 0);
+       count = 0;
+       while (ent = readdir(dp), ent != NULL) {
+               if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
+                          "_en") == 0) {
+                       int current_enabled = 0;
+
+                       current = &(*ci_array)[count++];
+                       ret = asprintf(&filename,
+                                      "%s/%s", scan_el_dir, ent->d_name);
+                       if (ret < 0) {
+                               ret = -ENOMEM;
+                               /* decrement count to avoid freeing name */
+                               count--;
+                               goto error_cleanup_array;
+                       }
+                       sysfsfp = fopen(filename, "r");
+                       if (sysfsfp == NULL) {
+                               free(filename);
+                               ret = -errno;
+                               goto error_cleanup_array;
+                       }
+                       fscanf(sysfsfp, "%i", &current_enabled);
+                       fclose(sysfsfp);
+
+                       if (!current_enabled) {
+                               free(filename);
+                               count--;
+                               continue;
+                       }
+
+                       current->scale = 1.0;
+                       current->offset = 0;
+                       current->name = strndup(ent->d_name,
+                                               strlen(ent->d_name) -
+                                               strlen("_en"));
+                       if (current->name == NULL) {
+                               free(filename);
+                               ret = -ENOMEM;
+                               goto error_cleanup_array;
+                       }
+                       /* Get the generic and specific name elements */
+                       ret = iioutils_break_up_name(current->name,
+                                                    &current->generic_name);
+                       if (ret) {
+                               free(filename);
+                               goto error_cleanup_array;
+                       }
+                       ret = asprintf(&filename,
+                                      "%s/%s_index",
+                                      scan_el_dir,
+                                      current->name);
+                       if (ret < 0) {
+                               free(filename);
+                               ret = -ENOMEM;
+                               goto error_cleanup_array;
+                       }
+                       sysfsfp = fopen(filename, "r");
+                       fscanf(sysfsfp, "%u", &current->index);
+                       fclose(sysfsfp);
+                       free(filename);
+                       /* Find the scale */
+                       ret = iioutils_get_param_float(&current->scale,
+                                                      "scale",
+                                                      device_dir,
+                                                      current->name,
+                                                      current->generic_name);
+                       if (ret < 0)
+                               goto error_cleanup_array;
+                       ret = iioutils_get_param_float(&current->offset,
+                                                      "offset",
+                                                      device_dir,
+                                                      current->name,
+                                                      current->generic_name);
+                       if (ret < 0)
+                               goto error_cleanup_array;
+                       ret = iioutils_get_type(&current->is_signed,
+                                               &current->bytes,
+                                               &current->bits_used,
+                                               &current->shift,
+                                               &current->mask,
+                                               &current->be,
+                                               device_dir,
+                                               current->name,
+                                               current->generic_name);
+               }
+       }
+
+       closedir(dp);
+       /* reorder so that the array is in index order */
+       bsort_channel_array_by_index(ci_array, *counter);
+
+       return 0;
+
+error_cleanup_array:
+       for (i = count - 1;  i >= 0; i--)
+               free((*ci_array)[i].name);
+       free(*ci_array);
+error_close_dir:
+       closedir(dp);
+error_free_name:
+       free(scan_el_dir);
+error_ret:
+       return ret;
+}
+
+/**
+ * find_type_by_name() - function to match top level types by name
+ * @name: top level type instance name
+ * @type: the type of top level instance being sort
+ *
+ * Typical types this is used for are device and trigger.
+ **/
+int find_type_by_name(const char *name, const char *type)
+{
+       const struct dirent *ent;
+       int number, numstrlen;
+
+       FILE *nameFile;
+       DIR *dp;
+       char thisname[IIO_MAX_NAME_LENGTH];
+       char *filename;
+
+       dp = opendir(iio_dir);
+       if (dp == NULL) {
+               printf("No industrialio devices available\n");
+               return -ENODEV;
+       }
+
+       while (ent = readdir(dp), ent != NULL) {
+               if (strcmp(ent->d_name, ".") != 0 &&
+                       strcmp(ent->d_name, "..") != 0 &&
+                       strlen(ent->d_name) > strlen(type) &&
+                       strncmp(ent->d_name, type, strlen(type)) == 0) {
+                       numstrlen = sscanf(ent->d_name + strlen(type),
+                                          "%d",
+                                          &number);
+                       /* verify the next character is not a colon */
+                       if (strncmp(ent->d_name + strlen(type) + numstrlen,
+                                       ":",
+                                       1) != 0) {
+                               filename = malloc(strlen(iio_dir)
+                                               + strlen(type)
+                                               + numstrlen
+                                               + 6);
+                               if (filename == NULL) {
+                                       closedir(dp);
+                                       return -ENOMEM;
+                               }
+                               sprintf(filename, "%s%s%d/name",
+                                       iio_dir,
+                                       type,
+                                       number);
+                               nameFile = fopen(filename, "r");
+                               if (!nameFile) {
+                                       free(filename);
+                                       continue;
+                               }
+                               free(filename);
+                               fscanf(nameFile, "%s", thisname);
+                               fclose(nameFile);
+                               if (strcmp(name, thisname) == 0) {
+                                       closedir(dp);
+                                       return number;
+                               }
+                       }
+               }
+       }
+       closedir(dp);
+       return -ENODEV;
+}
+
+int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
+{
+       int ret = 0;
+       FILE *sysfsfp;
+       int test;
+       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
+       if (temp == NULL)
+               return -ENOMEM;
+       sprintf(temp, "%s/%s", basedir, filename);
+       sysfsfp = fopen(temp, "w");
+       if (sysfsfp == NULL) {
+               printf("failed to open %s\n", temp);
+               ret = -errno;
+               goto error_free;
+       }
+       fprintf(sysfsfp, "%d", val);
+       fclose(sysfsfp);
+       if (verify) {
+               sysfsfp = fopen(temp, "r");
+               if (sysfsfp == NULL) {
+                       printf("failed to open %s\n", temp);
+                       ret = -errno;
+                       goto error_free;
+               }
+               fscanf(sysfsfp, "%d", &test);
+               fclose(sysfsfp);
+               if (test != val) {
+                       printf("Possible failure in int write %d to %s%s\n",
+                               val,
+                               basedir,
+                               filename);
+                       ret = -1;
+               }
+       }
+error_free:
+       free(temp);
+       return ret;
+}
+
+int write_sysfs_int(char *filename, char *basedir, int val)
+{
+       return _write_sysfs_int(filename, basedir, val, 0);
+}
+
+int write_sysfs_int_and_verify(char *filename, char *basedir, int val)
+{
+       return _write_sysfs_int(filename, basedir, val, 1);
+}
+
+int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
+{
+       int ret = 0;
+       FILE  *sysfsfp;
+       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
+       if (temp == NULL) {
+               printf("Memory allocation failed\n");
+               return -ENOMEM;
+       }
+       sprintf(temp, "%s/%s", basedir, filename);
+       sysfsfp = fopen(temp, "w");
+       if (sysfsfp == NULL) {
+               printf("Could not open %s\n", temp);
+               ret = -errno;
+               goto error_free;
+       }
+       fprintf(sysfsfp, "%s", val);
+       fclose(sysfsfp);
+       if (verify) {
+               sysfsfp = fopen(temp, "r");
+               if (sysfsfp == NULL) {
+                       printf("could not open file to verify\n");
+                       ret = -errno;
+                       goto error_free;
+               }
+               fscanf(sysfsfp, "%s", temp);
+               fclose(sysfsfp);
+               if (strcmp(temp, val) != 0) {
+                       printf("Possible failure in string write of %s "
+                               "Should be %s "
+                               "written to %s\%s\n",
+                               temp,
+                               val,
+                               basedir,
+                               filename);
+                       ret = -1;
+               }
+       }
+error_free:
+       free(temp);
+
+       return ret;
+}
+
+/**
+ * write_sysfs_string_and_verify() - string write, readback and verify
+ * @filename: name of file to write to
+ * @basedir: the sysfs directory in which the file is to be found
+ * @val: the string to write
+ **/
+int write_sysfs_string_and_verify(char *filename, char *basedir, char *val)
+{
+       return _write_sysfs_string(filename, basedir, val, 1);
+}
+
+int write_sysfs_string(char *filename, char *basedir, char *val)
+{
+       return _write_sysfs_string(filename, basedir, val, 0);
+}
+
+int read_sysfs_posint(char *filename, char *basedir)
+{
+       int ret;
+       FILE  *sysfsfp;
+       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
+       if (temp == NULL) {
+               printf("Memory allocation failed");
+               return -ENOMEM;
+       }
+       sprintf(temp, "%s/%s", basedir, filename);
+       sysfsfp = fopen(temp, "r");
+       if (sysfsfp == NULL) {
+               ret = -errno;
+               goto error_free;
+       }
+       fscanf(sysfsfp, "%d\n", &ret);
+       fclose(sysfsfp);
+error_free:
+       free(temp);
+       return ret;
+}
+
+int read_sysfs_float(char *filename, char *basedir, float *val)
+{
+       int ret = 0;
+       FILE  *sysfsfp;
+       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
+       if (temp == NULL) {
+               printf("Memory allocation failed");
+               return -ENOMEM;
+       }
+       sprintf(temp, "%s/%s", basedir, filename);
+       sysfsfp = fopen(temp, "r");
+       if (sysfsfp == NULL) {
+               ret = -errno;
+               goto error_free;
+       }
+       fscanf(sysfsfp, "%f\n", val);
+       fclose(sysfsfp);
+error_free:
+       free(temp);
+       return ret;
+}
+
+int read_sysfs_string(const char *filename, const char *basedir, char *str)
+{
+       int ret = 0;
+       FILE  *sysfsfp;
+       char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
+
+       if (temp == NULL) {
+               printf("Memory allocation failed");
+               return -ENOMEM;
+       }
+       sprintf(temp, "%s/%s", basedir, filename);
+       sysfsfp = fopen(temp, "r");
+       if (sysfsfp == NULL) {
+               ret = -errno;
+               goto error_free;
+       }
+       fscanf(sysfsfp, "%s\n", str);
+       fclose(sysfsfp);
+error_free:
+       free(temp);
+       return ret;
+}
+
+#endif /* _IIO_UTILS_H */
diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h
new file mode 100644 (file)
index 0000000..1bc837b
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef _IIO_UTILS_H_
+#define _IIO_UTILS_H_
+
+/* IIO - useful set of util functionality
+ *
+ * Copyright (c) 2008 Jonathan Cameron
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <stdint.h>
+
+/* Made up value to limit allocation sizes */
+#define IIO_MAX_NAME_LENGTH 30
+
+#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
+#define FORMAT_TYPE_FILE "%s_type"
+
+extern const char *iio_dir;
+
+/**
+ * struct iio_channel_info - information about a given channel
+ * @name: channel name
+ * @generic_name: general name for channel type
+ * @scale: scale factor to be applied for conversion to si units
+ * @offset: offset to be applied for conversion to si units
+ * @index: the channel index in the buffer output
+ * @bytes: number of bytes occupied in buffer output
+ * @mask: a bit mask for the raw output
+ * @is_signed: is the raw value stored signed
+ * @enabled: is this channel enabled
+ **/
+struct iio_channel_info {
+       char *name;
+       char *generic_name;
+       float scale;
+       float offset;
+       unsigned index;
+       unsigned bytes;
+       unsigned bits_used;
+       unsigned shift;
+       uint64_t mask;
+       unsigned be;
+       unsigned is_signed;
+       unsigned location;
+};
+
+int iioutils_break_up_name(const char *full_name, char **generic_name);
+int iioutils_get_type(unsigned *is_signed, unsigned *bytes,
+                                         unsigned *bits_used, unsigned *shift,
+                                         uint64_t *mask, unsigned *be,
+                                         const char *device_dir, const char *name,
+                                         const char *generic_name);
+int iioutils_get_param_float(float *output, const char *param_name,
+                                                        const char *device_dir, const char *name,
+                                                        const char *generic_name);
+void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt);
+int build_channel_array(const char *device_dir,
+                                               struct iio_channel_info **ci_array, int *counter);
+int find_type_by_name(const char *name, const char *type);
+int write_sysfs_int(char *filename, char *basedir, int val);
+int write_sysfs_int_and_verify(char *filename, char *basedir, int val);
+int write_sysfs_string_and_verify(char *filename, char *basedir, char *val);
+int write_sysfs_string(char *filename, char *basedir, char *val);
+int read_sysfs_posint(char *filename, char *basedir);
+int read_sysfs_float(char *filename, char *basedir, float *val);
+int read_sysfs_string(const char *filename, const char *basedir, char *str);
+
+#endif /* _IIO_UTILS_H_ */
diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c
new file mode 100644 (file)
index 0000000..c585440
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Industrial I/O utilities - lsiio.c
+ *
+ * Copyright (c) 2010 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <string.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+#include "iio_utils.h"
+
+
+static enum verbosity {
+       VERBLEVEL_DEFAULT,      /* 0 gives lspci behaviour */
+       VERBLEVEL_SENSORS,      /* 1 lists sensors */
+} verblevel = VERBLEVEL_DEFAULT;
+
+const char *type_device = "iio:device";
+const char *type_trigger = "trigger";
+
+
+static inline int check_prefix(const char *str, const char *prefix)
+{
+       return strlen(str) > strlen(prefix) &&
+               strncmp(str, prefix, strlen(prefix)) == 0;
+}
+
+static inline int check_postfix(const char *str, const char *postfix)
+{
+       return strlen(str) > strlen(postfix) &&
+               strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
+}
+
+static int dump_channels(const char *dev_dir_name)
+{
+       DIR *dp;
+       const struct dirent *ent;
+
+       dp = opendir(dev_dir_name);
+       if (dp == NULL)
+               return -errno;
+       while (ent = readdir(dp), ent != NULL)
+               if (check_prefix(ent->d_name, "in_") &&
+                   check_postfix(ent->d_name, "_raw")) {
+                       printf("   %-10s\n", ent->d_name);
+               }
+
+       return 0;
+}
+
+static int dump_one_device(const char *dev_dir_name)
+{
+       char name[IIO_MAX_NAME_LENGTH];
+       int dev_idx;
+       int retval;
+
+       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device),
+                       "%i", &dev_idx);
+       if (retval != 1)
+               return -EINVAL;
+       read_sysfs_string("name", dev_dir_name, name);
+       printf("Device %03d: %s\n", dev_idx, name);
+
+       if (verblevel >= VERBLEVEL_SENSORS)
+               return dump_channels(dev_dir_name);
+       return 0;
+}
+
+static int dump_one_trigger(const char *dev_dir_name)
+{
+       char name[IIO_MAX_NAME_LENGTH];
+       int dev_idx;
+       int retval;
+
+       retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger),
+                       "%i", &dev_idx);
+       if (retval != 1)
+               return -EINVAL;
+       read_sysfs_string("name", dev_dir_name, name);
+       printf("Trigger %03d: %s\n", dev_idx, name);
+       return 0;
+}
+
+static void dump_devices(void)
+{
+       const struct dirent *ent;
+       DIR *dp;
+
+       dp = opendir(iio_dir);
+       if (dp == NULL) {
+               printf("No industrial I/O devices available\n");
+               return;
+       }
+
+       while (ent = readdir(dp), ent != NULL) {
+               if (check_prefix(ent->d_name, type_device)) {
+                       char *dev_dir_name;
+
+                       asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
+                       dump_one_device(dev_dir_name);
+                       free(dev_dir_name);
+                       if (verblevel >= VERBLEVEL_SENSORS)
+                               printf("\n");
+               }
+       }
+       rewinddir(dp);
+       while (ent = readdir(dp), ent != NULL) {
+               if (check_prefix(ent->d_name, type_trigger)) {
+                       char *dev_dir_name;
+
+                       asprintf(&dev_dir_name, "%s%s", iio_dir, ent->d_name);
+                       dump_one_trigger(dev_dir_name);
+                       free(dev_dir_name);
+               }
+       }
+       closedir(dp);
+}
+
+int main(int argc, char **argv)
+{
+       int c, err = 0;
+
+       while ((c = getopt(argc, argv, "d:D:v")) != EOF) {
+               switch (c) {
+               case 'v':
+                       verblevel++;
+                       break;
+
+               case '?':
+               default:
+                       err++;
+                       break;
+               }
+       }
+       if (err || argc > optind) {
+               fprintf(stderr, "Usage: lsiio [options]...\n"
+                       "List industrial I/O devices\n"
+                       "  -v, --verbose\n"
+                       "      Increase verbosity (may be given multiple times)\n"
+                       );
+               exit(1);
+       }
+
+       dump_devices();
+
+       return 0;
+}